@oonacode/win32-x64 0.3.203 → 0.3.204
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.
|
@@ -74,7 +74,7 @@ Error generating stack: `+e.message+`
|
|
|
74
74
|
|
|
75
75
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function da(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ma(t,`input`,e.processors),output:ma(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function fa(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return fa(r.element,n);if(r.type===`set`)return fa(r.valueType,n);if(r.type===`lazy`)return fa(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return fa(r.innerType,n);if(r.type===`intersection`)return fa(r.left,n)||fa(r.right,n);if(r.type===`record`||r.type===`map`)return fa(r.keyType,n)||fa(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:fa(r.in,n)||fa(r.out,n);if(r.type===`object`){for(let e in r.shape)if(fa(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(fa(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(fa(e,n))return!0;return!!(r.rest&&fa(r.rest,n))}return!1}var pa=(e,t={})=>n=>{let r=ca({...n,processors:t});return la(e,r),ua(r,e),da(r,e)},ma=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ca({...i??{},target:a,io:t,processors:n});return la(e,o),ua(o,e),da(o,e)},ha={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ga=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ha[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},_a=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},va=(e,t,n,r)=>{n.type=`boolean`},ya=(e,t,n,r)=>{n.not={}},ba=(e,t,n,r)=>{let i=e._zod.def,a=Ge(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},xa=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Sa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ca=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},wa=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=la(a.element,t,{...r,path:[...r.path,`items`]})},Ta=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=la(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=la(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ea=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>la(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Da=(e,t,n,r)=>{let i=e._zod.def,a=la(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=la(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Oa=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=la(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=la(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=la(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},ka=(e,t,n,r)=>{let i=e._zod.def,a=la(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Aa=(e,t,n,r)=>{let i=e._zod.def;la(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ja=(e,t,n,r)=>{let i=e._zod.def;la(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ma=(e,t,n,r)=>{let i=e._zod.def;la(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Na=(e,t,n,r)=>{let i=e._zod.def;la(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Pa=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;la(o,t,r);let s=t.seen.get(e);s.ref=o},Fa=(e,t,n,r)=>{let i=e._zod.def;la(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ia=(e,t,n,r)=>{let i=e._zod.def;la(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},La=B(`ZodISODateTime`,(e,t)=>{rr.init(e,t),lo.init(e,t)});function Ra(e){return ki(La,e)}var za=B(`ZodISODate`,(e,t)=>{ir.init(e,t),lo.init(e,t)});function Ba(e){return Ai(za,e)}var Va=B(`ZodISOTime`,(e,t)=>{ar.init(e,t),lo.init(e,t)});function Ha(e){return ji(Va,e)}var Ua=B(`ZodISODuration`,(e,t)=>{or.init(e,t),lo.init(e,t)});function Wa(e){return Mi(Ua,e)}var Ga=B(`ZodError`,(e,t)=>{Ot.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>jt(e,t)},flatten:{value:t=>At(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ke,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ke,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ka=Mt(Ga),qa=Nt(Ga),Ja=Pt(Ga),Ya=It(Ga),Xa=Rt(Ga),Za=zt(Ga),Qa=Bt(Ga),$a=Vt(Ga),eo=Ht(Ga),to=Ut(Ga),no=Wt(Ga),ro=Gt(Ga),io=new WeakMap;function ao(e,t,n){let r=Object.getPrototypeOf(e),i=io.get(r);if(i||(i=new Set,io.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var oo=B(`ZodType`,(e,t)=>(Un.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ma(e,`input`),output:ma(e,`output`)}}),e.toJSONSchema=pa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ka(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ja(e,t,n),e.parseAsync=async(t,n)=>qa(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ya(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Xa(e,t,n),e.decode=(t,n)=>Za(e,t,n),e.encodeAsync=async(t,n)=>Qa(e,t,n),e.decodeAsync=async(t,n)=>$a(e,t,n),e.safeEncode=(t,n)=>eo(e,t,n),e.safeDecode=(t,n)=>to(e,t,n),e.safeEncodeAsync=async(t,n)=>no(e,t,n),e.safeDecodeAsync=async(t,n)=>ro(e,t,n),ao(e,`ZodType`,{check(...e){let t=this.def;return this.clone(et(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ut(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Cs(e,t))},superRefine(e,t){return this.check(ws(e,t))},overwrite(e){return this.check(Qi(e))},optional(){return as(this)},exactOptional(){return ss(this)},nullable(){return ls(this)},nullish(){return as(ls(this))},nonoptional(e){return hs(this,e)},array(){return Vo(this)},or(e){return Go([this,e])},and(e){return Yo(this,e)},transform(e){return ys(this,rs(e))},default(e){return ds(this,e)},prefault(e){return ps(this,e)},catch(e){return _s(this,e)},pipe(e){return ys(this,e)},readonly(){return xs(this)},describe(e){let t=this.clone();return ai.add(t,{description:e}),t},meta(...e){if(e.length===0)return ai.get(this);let t=this.clone();return ai.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return ai.get(e)?.description},configurable:!0}),e)),so=B(`_ZodString`,(e,t)=>{Wn.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ga(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ao(e,`_ZodString`,{regex(...e){return this.check(Ki(...e))},includes(...e){return this.check(Yi(...e))},startsWith(...e){return this.check(Xi(...e))},endsWith(...e){return this.check(Zi(...e))},min(...e){return this.check(Wi(...e))},max(...e){return this.check(Ui(...e))},length(...e){return this.check(Gi(...e))},nonempty(...e){return this.check(Wi(1,...e))},lowercase(e){return this.check(qi(e))},uppercase(e){return this.check(Ji(e))},trim(){return this.check(ea())},normalize(...e){return this.check($i(...e))},toLowerCase(){return this.check(ta())},toUpperCase(){return this.check(na())},slugify(){return this.check(ra())}})}),co=B(`ZodString`,(e,t)=>{Wn.init(e,t),so.init(e,t),e.email=t=>e.check(si(uo,t)),e.url=t=>e.check(pi(mo,t)),e.jwt=t=>e.check(Oi(ko,t)),e.emoji=t=>e.check(mi(ho,t)),e.guid=t=>e.check(ci(fo,t)),e.uuid=t=>e.check(li(po,t)),e.uuidv4=t=>e.check(ui(po,t)),e.uuidv6=t=>e.check(di(po,t)),e.uuidv7=t=>e.check(fi(po,t)),e.nanoid=t=>e.check(hi(go,t)),e.guid=t=>e.check(ci(fo,t)),e.cuid=t=>e.check(gi(_o,t)),e.cuid2=t=>e.check(_i(vo,t)),e.ulid=t=>e.check(vi(yo,t)),e.base64=t=>e.check(Ti(Eo,t)),e.base64url=t=>e.check(Ei(Do,t)),e.xid=t=>e.check(yi(bo,t)),e.ksuid=t=>e.check(bi(xo,t)),e.ipv4=t=>e.check(xi(So,t)),e.ipv6=t=>e.check(Si(Co,t)),e.cidrv4=t=>e.check(Ci(wo,t)),e.cidrv6=t=>e.check(wi(To,t)),e.e164=t=>e.check(Di(Oo,t)),e.datetime=t=>e.check(Ra(t)),e.date=t=>e.check(Ba(t)),e.time=t=>e.check(Ha(t)),e.duration=t=>e.check(Wa(t))});function H(e){return oi(co,e)}var lo=B(`ZodStringFormat`,(e,t)=>{Gn.init(e,t),so.init(e,t)}),uo=B(`ZodEmail`,(e,t)=>{Jn.init(e,t),lo.init(e,t)}),fo=B(`ZodGUID`,(e,t)=>{Kn.init(e,t),lo.init(e,t)}),po=B(`ZodUUID`,(e,t)=>{qn.init(e,t),lo.init(e,t)}),mo=B(`ZodURL`,(e,t)=>{Yn.init(e,t),lo.init(e,t)}),ho=B(`ZodEmoji`,(e,t)=>{Xn.init(e,t),lo.init(e,t)}),go=B(`ZodNanoID`,(e,t)=>{Zn.init(e,t),lo.init(e,t)}),_o=B(`ZodCUID`,(e,t)=>{Qn.init(e,t),lo.init(e,t)}),vo=B(`ZodCUID2`,(e,t)=>{$n.init(e,t),lo.init(e,t)}),yo=B(`ZodULID`,(e,t)=>{er.init(e,t),lo.init(e,t)}),bo=B(`ZodXID`,(e,t)=>{tr.init(e,t),lo.init(e,t)}),xo=B(`ZodKSUID`,(e,t)=>{nr.init(e,t),lo.init(e,t)}),So=B(`ZodIPv4`,(e,t)=>{sr.init(e,t),lo.init(e,t)}),Co=B(`ZodIPv6`,(e,t)=>{cr.init(e,t),lo.init(e,t)}),wo=B(`ZodCIDRv4`,(e,t)=>{lr.init(e,t),lo.init(e,t)}),To=B(`ZodCIDRv6`,(e,t)=>{ur.init(e,t),lo.init(e,t)}),Eo=B(`ZodBase64`,(e,t)=>{fr.init(e,t),lo.init(e,t)}),Do=B(`ZodBase64URL`,(e,t)=>{mr.init(e,t),lo.init(e,t)}),Oo=B(`ZodE164`,(e,t)=>{hr.init(e,t),lo.init(e,t)}),ko=B(`ZodJWT`,(e,t)=>{_r.init(e,t),lo.init(e,t)}),Ao=B(`ZodNumber`,(e,t)=>{vr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_a(e,t,n,r),ao(e,`ZodNumber`,{gt(e,t){return this.check(Bi(e,t))},gte(e,t){return this.check(Vi(e,t))},min(e,t){return this.check(Vi(e,t))},lt(e,t){return this.check(Ri(e,t))},lte(e,t){return this.check(zi(e,t))},max(e,t){return this.check(zi(e,t))},int(e){return this.check(No(e))},safe(e){return this.check(No(e))},positive(e){return this.check(Bi(0,e))},nonnegative(e){return this.check(Vi(0,e))},negative(e){return this.check(Ri(0,e))},nonpositive(e){return this.check(zi(0,e))},multipleOf(e,t){return this.check(Hi(e,t))},step(e,t){return this.check(Hi(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function jo(e){return Ni(Ao,e)}var Mo=B(`ZodNumberFormat`,(e,t)=>{yr.init(e,t),Ao.init(e,t)});function No(e){return Pi(Mo,e)}var Po=B(`ZodBoolean`,(e,t)=>{br.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>va(e,t,n,r)});function Fo(e){return Fi(Po,e)}var Io=B(`ZodUnknown`,(e,t)=>{xr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Lo(){return Ii(Io)}var Ro=B(`ZodNever`,(e,t)=>{Sr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ya(e,t,n,r)});function zo(e){return Li(Ro,e)}var Bo=B(`ZodArray`,(e,t)=>{wr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wa(e,t,n,r),e.element=t.element,ao(e,`ZodArray`,{min(e,t){return this.check(Wi(e,t))},nonempty(e){return this.check(Wi(1,e))},max(e,t){return this.check(Ui(e,t))},length(e,t){return this.check(Gi(e,t))},unwrap(){return this.element}})});function Vo(e,t){return ia(Bo,e,t)}var Ho=B(`ZodObject`,(e,t)=>{kr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ta(e,t,n,r),Qe(e,`shape`,()=>t.shape),ao(e,`ZodObject`,{keyof(){return $o(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Lo()})},loose(){return this.clone({...this._zod.def,catchall:Lo()})},strict(){return this.clone({...this._zod.def,catchall:zo()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ht(this,e)},safeExtend(e){return gt(this,e)},merge(e){return _t(this,e)},pick(e){return pt(this,e)},omit(e){return mt(this,e)},partial(...e){return vt(is,this,e[0])},required(...e){return yt(ms,this,e[0])}})});function Uo(e,t){return new Ho({type:`object`,shape:e??{},...V(t)})}var Wo=B(`ZodUnion`,(e,t)=>{jr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ea(e,t,n,r),e.options=t.options});function Go(e,t){return new Wo({type:`union`,options:e,...V(t)})}var Ko=B(`ZodDiscriminatedUnion`,(e,t)=>{Wo.init(e,t),Mr.init(e,t)});function qo(e,t,n){return new Ko({type:`union`,options:t,discriminator:e,...V(n)})}var Jo=B(`ZodIntersection`,(e,t)=>{Nr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Da(e,t,n,r)});function Yo(e,t){return new Jo({type:`intersection`,left:e,right:t})}var Xo=B(`ZodRecord`,(e,t)=>{Ir.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oa(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Zo(e,t,n){return!t||!t._zod?new Xo({type:`record`,keyType:H(),valueType:e,...V(t)}):new Xo({type:`record`,keyType:e,valueType:t,...V(n)})}var Qo=B(`ZodEnum`,(e,t)=>{Lr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ba(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Qo({...t,checks:[],...V(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Qo({...t,checks:[],...V(r),entries:i})}});function $o(e,t){return new Qo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...V(t)})}var es=B(`ZodLiteral`,(e,t)=>{Rr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xa(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ts(e,t){return new es({type:`literal`,values:Array.isArray(e)?e:[e],...V(t)})}var ns=B(`ZodTransform`,(e,t)=>{zr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ca(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new He(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Et(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Et(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function rs(e){return new ns({type:`transform`,transform:e})}var is=B(`ZodOptional`,(e,t)=>{Vr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function as(e){return new is({type:`optional`,innerType:e})}var os=B(`ZodExactOptional`,(e,t)=>{Hr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ss(e){return new os({type:`optional`,innerType:e})}var cs=B(`ZodNullable`,(e,t)=>{Ur.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ka(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ls(e){return new cs({type:`nullable`,innerType:e})}var us=B(`ZodDefault`,(e,t)=>{Wr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ja(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ds(e,t){return new us({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():st(t)}})}var fs=B(`ZodPrefault`,(e,t)=>{Kr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ma(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ps(e,t){return new fs({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():st(t)}})}var ms=B(`ZodNonOptional`,(e,t)=>{qr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hs(e,t){return new ms({type:`nonoptional`,innerType:e,...V(t)})}var gs=B(`ZodCatch`,(e,t)=>{Yr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Na(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _s(e,t){return new gs({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var vs=B(`ZodPipe`,(e,t)=>{Xr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pa(e,t,n,r),e.in=t.in,e.out=t.out});function ys(e,t){return new vs({type:`pipe`,in:e,out:t})}var bs=B(`ZodReadonly`,(e,t)=>{Qr.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xs(e){return new bs({type:`readonly`,innerType:e})}var Ss=B(`ZodCustom`,(e,t)=>{ei.init(e,t),oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sa(e,t,n,r)});function Cs(e,t={}){return aa(Ss,e,t)}function ws(e,t){return oa(e,t)}var Ts={artificial_analysis_intelligence_index:{label:`Intelligence index`,scale:`index`},artificial_analysis_coding_index:{label:`Coding index`,scale:`index`},artificial_analysis_math_index:{label:`Math index`,scale:`index`},gpqa:{label:`GPQA Diamond`,scale:`fraction`},hle:{label:`Humanity's Last Exam`,scale:`fraction`},lcr:{label:`Long-context reasoning`,scale:`fraction`},livecodebench:{label:`LiveCodeBench`,scale:`fraction`},scicode:{label:`SciCode`,scale:`fraction`},math_500:{label:`MATH-500`,scale:`fraction`},aime:{label:`AIME`,scale:`fraction`},aime_25:{label:`AIME 2025`,scale:`fraction`},ifbench:{label:`IFBench`,scale:`fraction`},mmlu_pro:{label:`MMLU Pro`,scale:`fraction`},tau2:{label:`τ²-bench (agentic)`,scale:`fraction`},tau_banking:{label:`τ-bench banking`,scale:`fraction`},terminalbench_hard:{label:`Terminal-Bench Hard`,scale:`fraction`},terminalbench_v2_1:{label:`Terminal-Bench 2.1`,scale:`fraction`}};function Es(e){return(e.credentialVariants??[]).filter(e=>!e.operatorOnly)}function Ds(e){let t=new Set(e.map(e=>e.definition.id));return e.filter(e=>!e.definition.clientGroup||e.definition.clientGroup===e.definition.id||!t.has(e.definition.clientGroup))}function Os(e,t){return e.filter(e=>e.definition.id===t||e.definition.clientGroup===t&&e.definition.id!==t)}function ks(e){return Ds(e).filter(e=>e.definition.enabled&&e.definition.credentialClass!==`none`&&e.definition.poolOnly!==!0&&T(e.definition.id)&&!D(e.definition.id))}function As(e){if(!e)return!1;try{let t=new URL(e).hostname.toLowerCase();return t===`127.0.0.1`||t===`localhost`||t===`::1`||t===`[::1]`}catch{return!1}}function js(e,t={}){let n=e.displayName,r=t.credentialClass??e.credentialClass,i=t.baseUrl??e.baseUrl;return e.id===`oonacode`?{kind:`pool`,badge:`via OonaCode`,detail:`Runs on OonaCode's own provider accounts, through the OonaCode gateway. Priced models are billed to your account in credits; free models cost nothing on any plan.`,viaGateway:!0}:e.engine===`agy`?{kind:`subscription-direct`,badge:`agy · direct to Google`,detail:`Runs on Google’s own agy CLI on this PC, with your Google plan. Each request is recorded here and goes straight from this PC to Google — never through the OonaCode gateway, and OonaCode does not translate it.`,viaGateway:!1}:e.route===`direct`?{kind:`subscription-direct`,badge:`direct to provider`,detail:`Your ${n} subscription runs straight from this PC to the provider — it never passes through the OonaCode gateway.`,viaGateway:!1}:r===`api_key`&&e.kind!==`anthropic-passthrough`?{kind:`own-key-translated`,badge:`direct to provider`,detail:`Your ${n} key stays on this PC: OonaCode translates the request here and calls ${n} from this machine. The gateway sees neither the key nor the traffic.`,viaGateway:!1}:As(i)?{kind:`local-server`,badge:`on this machine`,detail:`Runs against ${n} on this machine (${i}) — the request never leaves the PC.`,viaGateway:!1}:r===`api_key`&&e.kind===`anthropic-passthrough`&&e.directCapable===!0?{kind:`own-key-direct`,badge:`direct to provider`,detail:`Your ${n} key runs straight from this PC to ${n} — the OonaCode gateway is not in the path.`,viaGateway:!1}:{kind:`gateway`,badge:`via OonaCode`,detail:`Routed to ${n} through the OonaCode gateway.`,viaGateway:!0}}var Ms=qo(`type`,[Uo({type:ts(`oauth-device`),deviceAuthorizationUrl:H().url(),tokenUrl:H().url(),clientId:H().min(1),scopes:Vo(H().min(1)).min(1),signInLabel:H().min(1).optional(),referrer:H().min(1).optional()}),Uo({type:ts(`openai-device`),deviceAuthorizationUrl:H().url(),pollUrl:H().url(),tokenUrl:H().url(),verificationUri:H().url(),redirectUri:H().url(),clientId:H().min(1),signInLabel:H().min(1).optional()})]),Ns=Uo({type:ts(`google-loopback`),authorizationUrl:H().url(),tokenUrl:H().url(),redirectUri:H().url(),scopes:Vo(H().min(1)).min(1),clientIdSetting:H().min(1),clientSecretSetting:H().min(1),userinfoUrl:H().url().optional(),signInLabel:H().min(1).optional()}),Ps=Uo({id:H().min(1),displayName:H().min(1),upstreamId:H().min(1).optional(),servedBy:Vo(H().min(1)).optional(),subscriptionServedBy:Vo(H().min(1)).optional(),contextWindow:jo().int().positive().optional(),maxOutputTokens:jo().int().positive().optional(),supportsTools:Fo().optional(),supportsThinking:Fo().optional(),effortLevels:Vo($o(be)).optional(),helperModel:H().min(1).optional(),supportsVision:Fo().optional(),inputPricePerM:jo().nonnegative().optional(),outputPricePerM:jo().nonnegative().optional(),creditsPerM:Uo({input:jo().nonnegative(),output:jo().nonnegative(),maxInput:jo().nonnegative().optional(),maxOutput:jo().nonnegative().optional()}).optional(),notes:H().optional(),free:Fo().optional(),aaIntelligence:jo().optional(),aaCoding:jo().optional(),aaOutputTps:jo().optional(),aaTtft:jo().optional(),aa:Uo({fetchedAt:H(),creator:H().optional(),releaseDate:H().optional(),benchmarks:Zo(H(),jo()).optional()}).loose().optional()}).loose(),Fs=Uo({id:H().regex(/^[a-z0-9][a-z0-9-]{1,40}$/,`provider id must be lowercase kebab-case`),displayName:H().min(1),kind:$o([`anthropic-passthrough`,`openai-compatible`,`gemini`]),route:$o([`gateway`,`direct`]),credentialClass:$o([`api_key`,`subscription`,`none`]),baseUrl:H().url(),messagesPath:H().startsWith(`/`).optional(),modelsPath:H().startsWith(`/`).optional(),auth:Uo({header:$o([`x-api-key`,`authorization-bearer`,`api-key`,`none`]),extraHeaders:Zo(H(),H()).optional()}),models:Vo(Ps),defaultModel:H().min(1),modelAliases:Zo(H(),H()).optional(),helperModel:H().min(1).optional(),capabilities:Uo({streaming:Fo(),tools:Fo(),thinking:Fo(),vision:Fo(),countTokens:Fo(),promptCaching:Fo(),promptCacheTtlSec:jo().int().positive().optional()}),translate:Uo({maxTokensParam:$o([`max_tokens`,`max_completion_tokens`]).optional(),reasoningEffortFromBudget:Fo().optional(),reasoningContentField:H().nullable().optional(),supportsParallelToolCalls:Fo().optional(),systemRole:$o([`system`,`developer`]).optional(),streamIncludeUsage:Fo().optional(),wire:$o([`chat`,`responses`,`gemini-code-assist`]).optional()}).optional(),passthrough:Uo({stripCacheControl:Fo().optional(),cacheChain:Fo().optional(),toolSchemaRequiredArray:Fo().optional(),toolDescriptionRequired:Fo().optional(),allowedBetas:Vo(H()).optional(),anthropicVersion:H().optional()}).optional(),userBaseUrl:Fo().optional(),engineEnv:Zo(H(),H()).optional(),directCapable:Fo().optional(),subscriptionLogin:Ms.optional(),poolOnly:Fo().optional(),phase:Go([ts(1),ts(2)]),enabled:Fo(),docsUrl:H().url().optional(),notes:H().optional(),references:Vo(Uo({label:H().min(1),url:H().url(),kind:$o([`docs`,`pricing`,`models`,`console`,`status`,`keys`,`signup`,`other`]).optional()})).optional(),keyFormat:H().optional(),credentialVariants:Vo(Uo({id:H().min(1),label:H().min(1),header:$o([`x-api-key`,`authorization-bearer`,`api-key`,`none`]).optional(),extraHeaders:Zo(H(),H()).optional(),operatorOnly:Fo().optional(),requiresClaudeCodeIdentity:Fo().optional(),subscriptionLogin:Ms.optional(),loopbackLogin:Ns.optional(),claudeCodeShape:Uo({betas:H().min(1),userAgent:H().min(1),billingHeader:H().min(1),headers:Zo(H(),H()).optional()}).optional(),baseUrl:H().url().optional(),keyFormat:H().optional(),notes:H().optional()})).optional(),adminGroup:H().optional(),clientGroup:H().optional(),recordLabel:H().optional(),engine:ts(`agy`).optional(),effortLevels:Vo($o(be)).optional()});Uo({version:jo().int().positive(),updatedAt:H(),providers:Vo(Fs)});function Is(e,t){return Ls(e,Ks(e,t))}function Ls(e,t){return e.models.find(e=>e.id===t)?.upstreamId??t}function Rs(e){return/^claude-/i.test(e)}function zs(e){return/^claude-.+-\d{8}$/i.test(e)?e.replace(/-\d{8}$/,``):null}function Bs(e){return e.replace(/\[1m\]$/i,``)}var Vs=new Set([`opus`,`sonnet`,`haiku`,`fable`]);function Hs(e){return Vs.has(e.toLowerCase())}function Us(e,t){let n=Bs(t);if(Hs(n)||e.models.some(e=>e.id===n))return null;let r=e.modelAliases;if(!r)return null;let i=zs(n);if(i!==null&&e.models.some(e=>e.id===i))return null;let a=r[n]??(i===null?void 0:r[i]);return a!==void 0&&e.models.some(e=>e.id===a)?a:null}function Ws(e,t){return{images:e.models.find(e=>e.id===t)?.supportsVision??e.capabilities.vision,documents:Rs(t)}}function Gs(e,t,n){let r=Ws(e,t),i=new Set;for(let e of n){let t=e?.type;(t===`image`||t===`document`)&&i.add(t)}let a=e.models.find(e=>e.id===t)?.displayName??t;return i.has(`image`)&&!r.images?`${a} cannot read images. Remove the image, or pick a model that can — the model details say which.`:i.has(`document`)&&!r.documents?`${a} cannot read PDF documents — only Anthropic's Claude models take a PDF. Attach it as text, or pick a Claude model.`:null}function Ks(e,t){if(!t)return e.defaultModel;if(e.models.some(e=>e.id===t))return t;let n=e.modelAliases?.[t];if(n)return n;let r=Us(e,t);if(r)return r;let i=t.toLowerCase(),a=i.includes(`haiku`)?`haiku`:i.includes(`opus`)?`opus`:i.includes(`sonnet`)?`sonnet`:i.includes(`fable`)?`fable`:null;if(a){if(e.modelAliases?.[a])return e.modelAliases[a];let t=e.models.find(e=>e.id.toLowerCase().includes(a));if(t)return t.id}return e.defaultModel}var qs={messages:`/v1/messages`,countTokens:`/v1/messages/count_tokens`,models:`/v1/models`,providerMessages:e=>`/p/${e}/v1/messages`,providerCountTokens:e=>`/p/${e}/v1/messages/count_tokens`,providerModels:e=>`/p/${e}/v1/models`,voiceTranslation:`/v1/oonacode/voice-translation`,health:`/api/health`,streamCheck:`/api/stream-check`,register:`/api/auth/register`,login:`/api/auth/login`,refresh:`/api/auth/refresh`,logout:`/api/auth/logout`,me:`/api/auth/me`,prelogin:`/api/auth/prelogin`,tokens:`/api/me/tokens`,token:e=>`/api/me/tokens/${e}`,tokenPurge:e=>`/api/me/tokens/${e}/purge`,tokenUsage:e=>`/api/me/tokens/${e}/usage`,providers:`/api/me/providers`,provider:e=>`/api/me/providers/${e}`,providerTest:e=>`/api/me/providers/${e}/test`,routing:`/api/me/routing`,usage:`/api/me/usage`,usageSession:e=>`/api/me/usage/sessions/${e}`,usageBreakdown:`/api/me/usage/breakdown`,devices:`/api/me/devices`,pushToken:`/api/me/push-token`,hostNotify:`/api/me/hosts/notify`,device:e=>`/api/me/devices/${e}`,hosts:`/api/me/hosts`,hostHeartbeat:`/api/me/hosts/heartbeat`,hostVaultUnlock:e=>`/api/me/hosts/${encodeURIComponent(e)}/vault-unlock`,host:e=>`/api/me/hosts/${encodeURIComponent(e)}`,vault:`/api/me/vault`,vaultEvents:`/api/me/vault/events`,registry:`/api/registry`,agentTools:`/api/agent-tools`,agentToolCalls:`/api/me/agent-tools/calls`,releasesLatest:`/api/releases/latest`,releasesHistory:`/api/releases`,team:`/api/me/team`,teamInvites:`/api/me/team/invites`,teamInvite:e=>`/api/me/team/invites/${e}`,teamInviteLookup:`/api/team/invites/lookup`,teamInviteDecline:`/api/team/invites/decline`,teamJoin:`/api/me/team/join`,teamInvitations:`/api/me/team/invitations`,teamInvitationAccept:e=>`/api/me/team/invitations/${e}/accept`,teamInvitationDecline:e=>`/api/me/team/invitations/${e}/decline`,teamMember:e=>`/api/me/team/members/${e}`,teamLeave:`/api/me/team/leave`,teamTransfer:`/api/me/team/transfer`,teamAudit:`/api/me/team/audit`,teamCheckout:`/api/me/team/checkout`,teamTopup:`/api/me/team/topup`,teamSeats:`/api/me/team/seats`,googleConfig:`/api/auth/google/config`,googleStart:`/api/auth/google/start`,googleCallback:`/api/auth/google/callback`,githubConfig:`/api/auth/github/config`,githubStart:`/api/auth/github/start`,githubCallback:`/api/auth/github/callback`,googleUnlink:`/api/me/google`,telegramConfig:`/api/auth/telegram/config`,telegramAuth:`/api/auth/telegram`,telegram:`/api/me/telegram`,telegramWebhook:`/api/webhooks/telegram`,passphraseSetup:`/api/auth/passphrase/setup`,passphraseRekey:`/api/me/passphrase/rekey`,recovery:`/api/me/recovery`,recoveryChallenge:`/api/auth/recovery/challenge`,recoveryConsume:`/api/auth/recovery/consume`,deviceApprovals:`/api/me/device-approvals`,deviceApproval:e=>`/api/me/device-approvals/${e}`,deviceApprovalApprove:e=>`/api/me/device-approvals/${e}/approve`,deviceApprovalDeny:e=>`/api/me/device-approvals/${e}/deny`,passwordResetRequest:`/api/auth/password-reset/request`,passwordResetConfirm:`/api/auth/password-reset/confirm`,vaultRekeyComplete:`/api/me/vault/rekey-complete`,vaultRekeyPending:`/api/me/vault/rekey-pending`,emailVerifySend:`/api/auth/email/verify/send`,emailVerifyConfirm:`/api/auth/email/verify/confirm`,emailVerifyWatch:`/api/auth/email/verify/watch`,twoFactor:`/api/me/2fa`,twoFactorEnroll:`/api/me/2fa/enroll`,twoFactorConfirm:`/api/me/2fa/confirm`,twoFactorDisable:`/api/me/2fa/disable`,twoFactorDisableRequest:`/api/me/2fa/disable/request`,twoFactorRecoveryCodes:`/api/me/2fa/recovery-codes`,twoFactorVerify:`/api/auth/2fa/verify`,deviceLinkStart:`/api/auth/device/start`,deviceLinkPoll:`/api/auth/device/poll`,deviceLinks:`/api/me/device-links`,deviceLink:e=>`/api/me/device-links/${e}`,deviceLinkApprove:e=>`/api/me/device-links/${e}/approve`,deviceLinkDeny:e=>`/api/me/device-links/${e}/deny`,hostLogs:`/api/me/hosts/logs`,errorReport:`/api/me/errors`,bugReports:`/api/me/bug-reports`,plans:`/api/plans`,myPlan:`/api/me/plan`,checkout:`/api/me/plan/checkout`,creditsTopup:`/api/me/credits/topup`,billing:`/api/me/billing`},Js=2048,Ys=16384,Xs=8e3,Zs=5242880,Qs=12582912;new Set(`BCDFGHJKLMNPQRSTVWXZ`.split(``));var $s=`discard-my-vault-and-history`,ec=`Anyone who can use this device can use your saved provider keys without your passphrase. Turn this off on shared or public computers. You can revoke it any time from Devices.`,tc={name:120,instructions:2e4,goal:2e3,repositories:50,repositoryUrl:500,memory:2e4,minIntervalFloor:1,minIntervalCeiling:10080},nc=`⏰ Scheduled task "`;function rc(e){if(!e.startsWith(nc))return null;let t=e.indexOf(`"
|
|
76
76
|
|
|
77
|
-
`,18);return t<0?null:{title:e.slice(18,t),prompt:e.slice(t+3)}}Object.freeze({tengu_amber_sentinel:!0,tengu_groovy_eclipse:!0,tengu_humble_hammock:!0});function ic(e){return e===null||!Number.isFinite(e)?`neutral`:e>30?`ok`:e>10?`warn`:`danger`}var ac=[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`],oc=/^([01]\d|2[0-3]):[0-5]\d$/;Uo({tz:H().min(1),windows:Vo(Uo({from:H().regex(oc,`HH:MM`),to:H().regex(oc,`HH:MM`),days:Vo($o(ac)).optional(),kind:$o([`peak`,`offpeak`])})),offpeakDiscount:jo().nonnegative().max(1).optional()});var sc=[`priceInputCacheMissPeak`,`priceInputCacheMissOffpeak`,`priceInputCacheHitPeak`,`priceInputCacheHitOffpeak`,`priceCacheWritePeak`,`priceCacheWriteOffpeak`,`priceOutputPeak`,`priceOutputOffpeak`],cc=Uo({inputCacheMiss:jo().nonnegative(),inputCacheHit:jo().nonnegative().optional(),cacheWrite:jo().nonnegative().optional(),output:jo().nonnegative()});Uo({by:ts(`prompt_tokens`),tiers:Vo(Uo({upToPromptTokens:jo().int().positive().optional(),price:cc.optional(),cost:cc.optional()})).min(1),note:H().optional()}).superRefine((e,t)=>{let n=0;e.tiers.forEach((r,i)=>{!r.cost&&!r.price&&t.addIssue({code:`custom`,message:`a tier needs its cost (the provider’s rates; retail is cost × the record’s ratio)`,path:[`tiers`,i,`cost`]});let a=r.upToPromptTokens;if(a===void 0){i!==e.tiers.length-1&&t.addIssue({code:`custom`,message:`only the LAST tier may omit upToPromptTokens`,path:[`tiers`,i]});return}a<=n&&t.addIssue({code:`custom`,message:`tiers must ascend: ${a} does not exceed ${n}`,path:[`tiers`,i,`upToPromptTokens`]}),n=a})}),[...sc];var lc={realtime:`/v1/realtime`,translations:`/v1/realtime/translations`,live:`/v1/live/sessions`,speechStream:`/v1/audio/speech/stream`,transcriptionStream:`/v1/audio/transcriptions/stream`,clientSecrets:`/v1/realtime/client_secrets`,translationClientSecrets:`/v1/realtime/translations/client_secrets`};lc.realtime,lc.translations,lc.live,lc.speechStream,lc.transcriptionStream;var uc={oonacode:{hex:`#000000`,owner:`OonaCode`,d:`M0.72 12a11.28 11.28 0 1 0 22.56 0a11.28 11.28 0 1 0 -22.56 0ZM4.8 12a7.2 7.2 0 1 0 14.4 0a7.2 7.2 0 1 0 -14.4 0ZM7.44 12a4.56 4.56 0 1 0 9.12 0a4.56 4.56 0 1 0 -9.12 0Z`,fillRule:`evenodd`},anthropic:{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},"anthropic-subscription":{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},openai:{hex:`#000000`,owner:`OpenAI`,d:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`},xai:{hex:`#000000`,owner:`xAI`,d:`M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z`},deepseek:{hex:`#5786FE`,owner:`DeepSeek`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`},kimi:{hex:`#000000`,owner:`Moonshot`,d:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`},qwen:{hex:`#6950EF`,owner:`Alibaba`,d:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`},mimo:{hex:`#FF6900`,owner:`Xiaomi`,d:`M12 0C8.016 0 4.756.255 2.493 2.516.23 4.776 0 8.033 0 12.012c0 3.98.23 7.235 2.494 9.497C4.757 23.77 8.017 24 12 24c3.983 0 7.243-.23 9.506-2.491C23.77 19.247 24 15.99 24 12.012c0-3.984-.233-7.243-2.502-9.504C19.234.252 15.978 0 12 0zM4.906 7.405h5.624c1.47 0 3.007.068 3.764.827.746.746.827 2.233.83 3.676v4.54a.15.15 0 0 1-.152.147h-1.947a.15.15 0 0 1-.152-.148V11.83c-.002-.806-.048-1.634-.464-2.051-.358-.36-1.026-.441-1.72-.458H7.158a.15.15 0 0 0-.151.147v6.98a.15.15 0 0 1-.152.148H4.906a.15.15 0 0 1-.15-.148V7.554a.15.15 0 0 1 .15-.149zm12.131 0h1.949a.15.15 0 0 1 .15.15v8.892a.15.15 0 0 1-.15.148h-1.949a.15.15 0 0 1-.151-.148V7.554a.15.15 0 0 1 .151-.149zM8.92 10.948h2.046c.083 0 .15.066.15.147v5.352a.15.15 0 0 1-.15.148H8.92a.15.15 0 0 1-.152-.148v-5.352a.15.15 0 0 1 .152-.147Z`}};function dc(e){return uc[e]??null}function fc(e){let t=e.replace(/\(.*?\)/g,` `).split(/[\s/_-]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[1][0]}`.toUpperCase()}var pc=9230,mc=1024,hc=65534,gc=`127.0.0.1`;Object.freeze({enabled:!1,port:pc,inspectMain:!1}),Object.freeze({port:null,listening:!1,fromCommandLine:!1,inspectPort:null,inspectProblem:null});function _c(e){return e+1}function vc(e){return typeof e==`number`&&Number.isInteger(e)}function yc(e){return!vc(e)||e<1024||e>65534?`The port must be a whole number from ${mc.toLocaleString(`en-US`)} to ${hc.toLocaleString(`en-US`)} (the main-process inspector takes the next one).`:null}function bc(e){return e.port!==null||e.inspectPort!==null}function xc(e,t){let n=e.enabled?e.port:null,r=e.enabled&&e.inspectMain?_c(e.port):null;return!t.fromCommandLine&&t.port!==n||t.inspectPort!==r}function Sc(e){let t=[];return e.port!==null&&t.push(`${gc}:${e.port}`),e.inspectPort!==null&&t.push(`${gc}:${e.inspectPort}`),t.length===2?`${t[0]} (windows) and ${t[1]} (main process)`:e.inspectPort===null?t[0]??``:`${t[0]} (main process)`}var Cc=[`stable`,`dev`];function wc(e){return typeof e==`string`&&Cc.includes(e)}function Tc(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return wc(t)?t:null}var Ec=[`win32`,`linux`,`darwin`],Dc=[`x64`,`arm64`];function Oc(e,t){let n=Tc(e)??`stable`,r=[];return n!==`stable`&&r.push(`channel=${encodeURIComponent(n)}`),t&&Ec.includes(t.platform)&&(r.push(`platform=${t.platform}`),t.arch&&Dc.includes(t.arch)&&r.push(`arch=${t.arch}`)),r.length>0?`${qs.releasesLatest}?${r.join(`&`)}`:qs.releasesLatest}function kc(e,t){let n=Tc(t)??`stable`;return n===`stable`?e:`${e} (${n})`}var Ac=5e4,jc=6,Mc=[`bg`,`surface`,`surface-2`,`surface-3`,`border`,`fg`,`fg-muted`,`fg-faint`,`accent`,`accent-fg`,`accent-soft`,`project`,`ok`,`ok-soft`,`warn`,`warn-soft`,`danger`,`danger-soft`,`think`,`think-soft`,`code-bg`,`user-bubble`],Nc={agentFinished:!1,permissionRequired:!0,errorOccurred:!0},Pc={autoAcceptPermissions:!1,showReasoningSummaries:!0,notifications:Nc,showAgentPicker:!0,transcriptWindowSize:500,openTabs:[],draftTabs:[],draftTitles:{},activeTab:null,editorLayout:null,remoteTabs:{},sessionPanelOpen:!1,explorerOpen:!1,sidebarWidth:288,sidebarPinned:!0,dismissedUpdateVersion:null,lastSeenReleaseNotes:null,claudeImportOffered:!1,claudeImportOffers:0,collapsedProjects:[],themeColors:{light:{},dark:{}},pinned:[],sidebarView:`recent`};function Fc(e){return Math.min(Math.max(typeof e==`number`&&Number.isFinite(e)?Math.floor(e):0,0),3)}function Ic(e){return Math.min(640,Math.max(200,typeof e==`number`&&Number.isFinite(e)?Math.round(e):288))}function Lc(e){return Math.min(Ac,Math.max(100,typeof e==`number`&&Number.isFinite(e)?Math.round(e):500))}function Rc(e,t){return typeof e==`boolean`?e:t}function zc(e){return typeof e==`string`&&e.length>0&&e.length<=64?e:null}function Bc(e,t=50){if(!Array.isArray(e))return[];let n=[];for(let r of e)if(!(typeof r!=`string`||r.length===0||r.length>200)&&!n.includes(r)&&(n.push(r),n.length>=t))break;return n}function Vc(e,t=50){if(typeof e!=`object`||!e||Array.isArray(e))return{};let n={};for(let[r,i]of Object.entries(e))if(!(r.length===0||r.length>200)&&!(typeof i!=`string`||i.length===0||i.length>200)&&(n[r]=i,Object.keys(n).length>=t))break;return n}function Hc(e){if(typeof e!=`string`)return null;let t=e.trim();return/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():null}function Uc(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!Mc.includes(n))continue;let e=Hc(r);e!==null&&(t[n]=e)}return t}function Wc(e){let t=typeof e==`object`&&e?e:{};return{light:Uc(t.light),dark:Uc(t.dark)}}function Gc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n.kind,r=n.id;if((e===`chat`||e===`project`)&&!(typeof r!=`string`||r.length===0||r.length>200)&&!t.some(t=>t.kind===e&&t.id===r)&&(t.push({kind:e,id:r}),t.length>=50))break}return t}function Kc(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return null;let n=e,r=new Set(t),i=new Set,a=0,o=(e,t)=>{if(t>jc||typeof e!=`object`||!e)return null;let n=e,s=n.group;if(typeof s==`object`&&s&&!Array.isArray(s)){if(a>=8)return null;let e=s,t=[];for(let n of Array.isArray(e.tabs)?e.tabs:[])typeof n!=`string`||!r.has(n)||i.has(n)||(i.add(n),t.push(n));return t.length===0?null:(a+=1,{group:{tabs:t,active:(typeof e.active==`string`&&t.includes(e.active)?e.active:null)??t[t.length-1]}})}let c=n.split;if(c!==`row`&&c!==`column`)return null;let l=Array.isArray(n.children)?n.children:[],u=Array.isArray(n.sizes)?n.sizes:[],d=[],f=[];if(l.slice(0,8).forEach((e,n)=>{let r=o(e,t+1);if(!r)return;d.push(r);let i=u[n];f.push(typeof i==`number`&&Number.isFinite(i)&&i>0?i:0)}),d.length===0)return null;if(d.length===1)return d[0];let p=f.filter(e=>e>0),m=p.length>0?p.reduce((e,t)=>e+t,0)/p.length:1,h=f.map(e=>e>0?e:m),g=h.reduce((e,t)=>e+t,0);return{split:c,sizes:h.map(e=>e/g),children:d}},s=o(n.root,0);if(!s||a<2)return null;let c=n.focused;return{root:s,focused:typeof c==`number`&&Number.isInteger(c)&&c>=0&&c<a?c:0}}function qc(e,t,n){return e.some(e=>e.kind===t&&e.id===n)}function Jc(e,t,n,r){return r===qc(e,t,n)?e:r?[...e.length>=50?e.slice(e.length-50+1):e,{kind:t,id:n}]:e.filter(e=>e.kind!==t||e.id!==n)}function Yc(e){let t=typeof e==`object`&&e?e:{},n=typeof t.notifications==`object`&&t.notifications!==null?t.notifications:{},r=Bc(t.openTabs),i=Bc(t.draftTabs).filter(e=>!r.includes(e)),a={};for(let[e,n]of Object.entries(Vc(t.draftTitles)))i.includes(e)&&(a[e]=n);let o=[...r,...i],s=t.activeTab,c=typeof s==`string`&&o.includes(s)?s:o[o.length-1]??null;return{autoAcceptPermissions:Rc(t.autoAcceptPermissions,Pc.autoAcceptPermissions),showReasoningSummaries:Rc(t.showReasoningSummaries,Pc.showReasoningSummaries),notifications:{agentFinished:Rc(n.agentFinished,Nc.agentFinished),permissionRequired:Rc(n.permissionRequired,Nc.permissionRequired),errorOccurred:Rc(n.errorOccurred,Nc.errorOccurred)},showAgentPicker:Rc(t.showAgentPicker,Pc.showAgentPicker),transcriptWindowSize:Lc(t.transcriptWindowSize),openTabs:r,draftTabs:i,draftTitles:a,activeTab:c,editorLayout:Kc(t.editorLayout,o),remoteTabs:Vc(t.remoteTabs),sessionPanelOpen:Rc(t.sessionPanelOpen,Pc.sessionPanelOpen),explorerOpen:Rc(t.explorerOpen,Pc.explorerOpen),sidebarWidth:Ic(t.sidebarWidth),sidebarPinned:Rc(t.sidebarPinned,Pc.sidebarPinned),dismissedUpdateVersion:zc(t.dismissedUpdateVersion),lastSeenReleaseNotes:zc(t.lastSeenReleaseNotes),claudeImportOffered:Rc(t.claudeImportOffered,Pc.claudeImportOffered),claudeImportOffers:Fc(t.claudeImportOffers),collapsedProjects:Bc(t.collapsedProjects),themeColors:Wc(t.themeColors),pinned:Gc(t.pinned),sidebarView:t.sidebarView===`projects`?`projects`:`recent`}}new Set(Object.keys(Pc));var Xc=3650,Zc=[{version:`0.3.203`,date:`2026-10-04`,platforms:[`win32`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini and press Install: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back here. OonaCode never sees your password. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only, no pictures), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total (“51 agents”) is grey, instead of the other way round.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`darwin`],added:[`OonaCode runs on macOS 12 or newer: the agent, your chats, the background service and the desktop app, installed with the same one line as on Linux — curl -fsSL https://oonacode.oonak.ai/install.sh | bash. An Intel build; Apple Silicon Macs run it through Rosetta 2. Your sign-in key is kept in your login keychain.`,`Updating is the same line again, oona update in a terminal, or the update button in the app: it closes OonaCode, puts the new version in place and opens it again. The app is not signed by Apple yet, so it cannot be downloaded from a browser and does not update itself the way it does on Windows.`],fixed:[]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`linux`],added:[],fixed:[`Your sign-in survives a restart on a PC that keeps OonaCode’s key in the login keyring (GNOME Keyring, KWallet): two of OonaCode’s keys shared one keyring entry and overwrote each other, and every start of the host wrote over the stored key — so after a restart you could find yourself signed out.`,`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode (an nvm folder, for example).`,`oona update installs from the site your OonaCode was installed from, not always from oonacode.oonak.ai.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`win32`],added:[],fixed:[`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode.`]},{version:`0.3.201`,date:`2026-10-03`,added:[`The Tools menu lists only tools that work. Desktop control, Clipboard, Screen capture and Run as administrator were demos that never ran anything, and they are gone: the agent already reads and sets your clipboard, takes screenshots and asks Windows for administrator rights through its own commands.`],fixed:[`Oonak Browser keeps working when its window is behind other windows. A browser covered by the OonaCode window used to crawl, and some clicks and scrolls gave up after 30 seconds.`,`Oonak Browser no longer clicks a hidden copy of a link, or a link inside a closed menu, when a site has both a visible and a hidden one.`,`A message you send right after a reply failed no longer stays pinned above the box as “queued” once the agent has read it.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`win32`],added:[`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`],fixed:[`Oonak Browser works on sites built from web components, Google’s own forms among them: it reads, finds, clicks and types inside them, where it used to answer “the page changed” or find nothing.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`linux`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`,`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`,`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`,`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop.`,`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name matches each word, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond, and it works inside web components, Google’s own forms among them. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`,`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed — 10 days after their last change.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`,`Chats talking to each other no longer ping-pong: a reply needs no answer, several messages from the same chat are read together in one turn, and a message card says “answer requested” until the answer has gone back, then “answered” with the time.`,`A tool you switch on while a chat is replying works for the message you send next, even mid-reply. After an update, a chat that had background tasks running shows one line saying how many stopped, instead of one card per task.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`,`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`,`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`,`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption.`]},{version:`0.3.199`,date:`2026-10-02`,platforms:[`win32`],added:[`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name is smarter too: each word is matched, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`],fixed:[`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`]},{version:`0.3.198`,date:`2026-10-01`,platforms:[`win32`],added:[`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one — the phone used to show “Ask first” for a Build chat. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`Play in Listen is never greyed out for want of a voice: it gets the text ready and names the voice to install.`]},{version:`0.3.197`,date:`2026-10-01`,platforms:[`win32`],added:[`Oonak Browser, the browser your chats use, moves to version 151 by itself at its next use: a build with no Google services (no Safe Browsing warnings, push notifications or search suggestions). The download is checked against its fingerprint before anything is unpacked, and the old version is removed once no chat’s browser still runs from it.`],fixed:[`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`]},{version:`0.3.196`,date:`2026-10-01`,platforms:[`win32`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`],fixed:[`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption: the next sync that works clears it by itself.`]},{version:`0.3.195`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`Chats talking to each other no longer ping-pong. A message asks for an answer only when the chat really needs one; a reply needs no answer and is not answered with a new message; and several messages waiting from the same chat are read together in one turn. Fewer wake-ups, fewer tokens.`,`A message card says what is true: “answer requested” until the answer has gone back, then “answered” with the time — instead of an orange “reply expected” that never went away.`]},{version:`0.3.194`,date:`2026-10-01`,platforms:[`win32`],added:[`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[]},{version:`0.3.193`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`A tool you switch on while a chat is replying works for the message you send next, even mid-reply: that message now waits for the chat to restart with the new tool instead of reaching the model without it.`,`After an update, a chat that had background tasks running shows one line — “11 background tasks stopped — they were running when OonaCode restarted this chat” — instead of one card per task. Click it to see each one.`]},{version:`0.3.192`,date:`2026-09-30`,platforms:[`win32`],added:[`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop. Other languages are translated once and kept, so hearing the same briefing again costs nothing.`],fixed:[]},{version:`0.3.191`,date:`2026-09-30`,platforms:[`win32`],added:[`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed. They are deleted by themselves 10 days after their last change; resuming or editing a paused task gives it another 10 days.`],fixed:[]},{version:`0.3.190`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`]},{version:`0.3.189`,date:`2026-09-30`,platforms:[`linux`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window; “Move to main window” brings it back. On Wayland desktops the new window opens at the usual place rather than under the pointer. Your split views and windows come back when you restart OonaCode.`,`Every language plays in Listen to a chat: each language picks the best voice on its own — OonaCode’s Armenian voices first, then your system’s voices, then eSpeak (install the espeak-ng package if your system has no voice for a language).`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.188`,date:`2026-09-30`,platforms:[`win32`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window. Drag it back onto the main window’s tabs, or choose “Move to main window”, to bring it back. Your split views and popped-out windows come back when you restart OonaCode.`],fixed:[]},{version:`0.3.187`,date:`2026-09-30`,platforms:[`win32`],added:[`Every language plays in Listen to a chat. Persian, Georgian, Ukrainian — and any language whose Windows voice is not installed — now speak with eSpeak, a free voice that comes with OonaCode (it sounds robotic, but it always works). Each language picks the best voice on its own: OonaCode’s Armenian voices first, then Windows’ own, then eSpeak.`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.186`,date:`2026-09-30`,platforms:[`linux`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`,`OonaCode brings two Armenian voices of its own, Astgh and Artsiv, and also speaks with your system’s voices through speech-dispatcher — install speech-dispatcher and espeak-ng for Persian, Russian and every other language; the Listen window names the packages for your distribution.`,`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`,`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`,`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. Pin any chat or project to the top of the list from its menu.`,`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`,`Type / at the start of a message to see the chat’s commands and skills, with what each does, in two titled sections. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing; switch one on to let the model use it by itself in that chat. Typing /name still runs any skill for one turn.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`,`Search in the Import window: find a chat by its name, its first or last message or its folder, or pick “Whole conversations” to search inside the chats themselves.`],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from, with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once.`,`The message box fits a narrow chat: its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it.`,`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Only new replies change.`,`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model, /usage, /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`,`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message.`,`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`,`Typing /model in a chat updates the chat’s model and the model picker again, and command output such as /context reads the same while it arrives and after you reopen the chat.`,`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.185`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`Listening with a Windows voice no longer stops after the first sentence when the voice fails to say it has finished.`]},{version:`0.3.184`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`],fixed:[`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`]},{version:`0.3.183`,date:`2026-09-30`,platforms:[`win32`],added:[`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`],fixed:[]},{version:`0.3.182`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from — Claude Code, the Claude app, Qwen Code, Cursor — with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once. The Import button says how many chats it will bring over.`]},{version:`0.3.181`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`The message box fits a narrow chat. In a small window, or with the side panels open, its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it, and the model and effort pickers keep their words readable.`]},{version:`0.3.180`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Other models were never affected. Only new replies change; older thoughts stay empty.`]},{version:`0.3.179`,date:`2026-09-29`,platforms:[`win32`],added:[],fixed:[`The / menu is easier to read: skills and commands in two titled sections, each with one short line — the full description shows when you point at it.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model (use the model picker), /usage (the engine’s own estimate, not your credits), /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`]},{version:`0.3.178`,date:`2026-09-29`,platforms:[`win32`],added:[`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. A dot on it tells you when something is due soon.`,`Pin any chat or project to the top of the list from its menu.`],fixed:[`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.177`,date:`2026-09-29`,platforms:[`win32`],added:[`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`],fixed:[`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message, and the picker shows Sonnet 5.5.`]},{version:`0.3.176`,date:`2026-09-29`,platforms:[`win32`],added:[`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing — about 1,400 tokens on every message until now. Switch one on to let the model use it by itself in that chat; the list shows what each one costs per message while on.`,`Typing /name still runs any skill for one turn, whether its switch is on or off.`],fixed:[`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`]},{version:`0.3.175`,date:`2026-09-29`,platforms:[`win32`],added:[`Type / at the start of a message to see the chat’s commands and skills — the Claude Code engine’s own (/compact, /context, /review, /security-review, /init and more) and the skills in your project’s .claude folder — with what each does. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`],fixed:[`Typing /model in a chat updates the chat’s model and the model picker again.`,`Command output such as /context reads the same while it arrives and after you reopen the chat.`]},{version:`0.3.174`,date:`2026-09-28`,platforms:[`win32`],added:[`Search in the Import window. Type to find a chat by its name, its first or last message, or its folder — chats folded away as already imported or deleted here show up too when they match. Or open the search options and pick “Whole conversations” to search inside the chats themselves, with a few lines of each match under the chat. It only reads Claude Code, Cursor and the Claude app’s files, never changes them.`],fixed:[`Chats Claude Code switched to another model are answered by that model for real: OonaCode’s pool now serves the model the engine falls back to, and never answers a Claude request with another company’s model.`]},{version:`0.3.173`,date:`2026-09-28`,platforms:[`linux`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`,`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`,`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`,`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`,`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`,`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`A chat can no longer be moved into your home folder or the root folder through a link. Where /home is itself a link (Fedora Silverblue, Bazzite and similar systems), the home folder passed as an ordinary folder, and the chat would have loaded your own Claude Code settings as its project.`,`Signing in to your own Claude subscription inside the app works on Ubuntu 24.04, Debian, Linux Mint, Pop!_OS and Zorin OS again. There, a part of OonaCode built for newer systems did not load, and the sign-in fell back to a command you had to paste.`,"On Ubuntu, Linux Mint, Pop!_OS, Zorin OS and similar systems, `oona` now works in every new terminal right after you install or update. The installer used to leave it off your PATH until you logged out and back in; now it adds it for new terminals itself, and `oona uninstall` takes that line out again.",`Every way of uninstalling — “oona uninstall”, or the install command with --uninstall — now takes this PC off your account: keep your chats and they stay readable on your other devices; delete them and their copies go too. It never touches your Claude Code or the Claude app, and “oona uninstall” no longer gives up when the background service is stopped.`,`The installer now says at once when a system cannot run OonaCode — one older than Ubuntu 22.04, Debian 12 or RHEL 9, or one built on musl such as Alpine — instead of installing a copy that could not start. The .deb and .rpm tell apt and dnf the same.`]},{version:`0.3.172`,date:`2026-09-28`,platforms:[`win32`],added:[`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Uninstalling from Settings → Apps now also takes this PC off your account, exactly like “oona uninstall”: keep your chats and they stay readable on your other devices; delete them and their copies go too.`,`“oona uninstall” no longer gives up when the background service is stopped.`,`The “Updating OonaCode…” window shows again on the newest Windows 11 versions (24H2 and later).`]},{version:`0.3.171`,date:`2026-09-28`,platforms:[`win32`],added:[`Oonak Browser now picks its own control port from a range no developer tool uses by default, so it can no longer take a port that Shopify CLI or a dev server wants. If a program needs a particular port kept free, or you want the browser on a specific one, just ask the chat.`],fixed:[`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`Uninstalling OonaCode from Settings → Apps now removes all of it — the app, the command line and its background service — and asks whether to keep your chats. Installing again afterwards no longer says it is already installed. Your Claude Code and Claude app are never touched.`,`“oona uninstall” works again on Windows 11.`,`A chat “about” you wrote yourself no longer shows “stale”.`]},{version:`0.3.170`,date:`2026-09-28`,platforms:[`win32`],added:[`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`]},{version:`0.3.169`,date:`2026-09-28`,platforms:[`win32`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`],fixed:[`A chat can no longer be moved into your user folder or a drive root through a link or junction that points there — its project settings would have been your own Claude Code settings.`]},{version:`0.3.167`,date:`2026-09-27`,platforms:[`win32`],added:[`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`],fixed:[]},{version:`0.3.166`,date:`2026-09-27`,platforms:[`win32`],added:[],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`]},{version:`0.3.165`,date:`2026-09-27`,platforms:[`win32`],added:[`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`Chats now use Oonak Browser, in a window you can see, for everything that needs a web browser — not Chrome, Edge or a hidden script browser — unless you name another browser. It runs without a window (headless) only when you ask for that.`],fixed:[`After an update, the background service comes back by itself. An update could leave it unable to restart, and the app then showed “OonaCode could not start its host service” even though it went on to open normally.`]},{version:`0.3.164`,date:`2026-09-27`,platforms:[`win32`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when OonaCode’s stored key cannot be opened for a moment. OonaCode used to replace the key and lose your sign-in; it now keeps the key and signs you back in by itself as soon as it opens.`]},{version:`0.3.163`,date:`2026-09-27`,platforms:[`linux`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when its security chip is slow to open OonaCode’s stored key. After a system update and reboot, the chip on some machines refuses for a while; OonaCode used to replace the key and lose your sign-in. It now keeps the key and signs you back in by itself as soon as the chip opens it.`]},{version:`0.3.162`,date:`2026-09-27`,added:[],fixed:[`A chat switched to another model knows which model it is. After a switch from Claude to DeepSeek, the model used to keep saying it was Claude — the chat history and Claude Code’s own prompt told it so.`,`Oonak Browser is offered only where it can run. An older OonaCode no longer lists a browser tool it cannot use, so the model does not spend tokens working around it — update to get the browser.`]},{version:`0.3.161`,date:`2026-09-27`,added:[`Settings → This PC → “Replace pictures older than N days”: screenshots and pasted pictures in your chat history are replaced by a short note once they are older than a year (you choose the number, or 0 to keep them). The words of every chat stay; the database stops growing with pictures. It runs by itself.`],fixed:[`The model, Build/Plan/Ask and effort pickers under the message box now look like the dropdowns they are.`,`Switches that are off are easy to see in dark mode.`,`Error messages show what went wrong in words, without raw tags or a provider’s JSON.`,`The ✕ that removes an attachment or a reply is round.`,`Pressing Stop, or an update cutting a turn, no longer files an automatic bug report.`]},{version:`0.3.160`,date:`2026-09-27`,added:[`On Windows, the agent can use a real browser. Ask it to open a site, read a page, click, fill in a form or take a screenshot, and it does it in Oonak Browser, in a window you can see. The first time, OonaCode asks once to install the browser (about 210 MB); after that it opens straight away.`,`Each chat has its own browser profile, so a site you sign in to stays signed in for that chat. Switch the browser off for a chat in its Tools menu.`],fixed:[]},{version:`0.3.159`,date:`2026-09-27`,added:[],fixed:[`A chat reopened after an update no longer says “turn complete” the instant you send a message and then answer anyway. The engine’s own note about work that stopped during the update used to be taken for the end of your turn, with the whole earlier conversation’s tokens on the line.`,`A background task that stopped because OonaCode restarted now says so in plain words, instead of “Orphaned by a previous Claude Code process exit”.`]},{version:`0.3.158`,date:`2026-09-27`,added:[`Every thought in a chat shows how many words it has, so you can tell at a glance whether there is anything to read.`],fixed:[`A thought with nothing in it — some models return only a signature for their thinking — now says “Thought · empty” and no longer opens onto a blank box.`,`A command the agent was allowed to run no longer leaves an “Allowed Bash (automatically)” line under its own card: the card already shows the command and its result. Refusals are still shown.`]},{version:`0.3.157`,date:`2026-09-27`,added:[`On Linux, OonaCode has its own signed apt and dnf repositories. Install the app with apt (Debian, Ubuntu, Mint) or dnf (Fedora, RHEL, Rocky, Alma) — the commands are on the download page — and your package manager keeps it up to date with the rest of the system.`,`Every Linux release is signed with the OonaCode release key, and the one-line installer checks that signature before it installs anything.`],fixed:[`On Linux, the menu bar is drawn in the window in the app’s own colours, and it switches between light and dark with the app instead of keeping the desktop’s theme until a restart.`,`Upgrading the .rpm no longer removes the oonacode command, and removing it no longer leaves empty folders behind.`]},{version:`0.3.156`,date:`2026-09-27`,added:[`Chats can talk to each other. Turn on “Talk to other chats” in a chat’s Tools menu, and its agent can find your other chats that have it on, read them, and ask them for help — one chat or a whole group. A chat that is closed wakes up to answer; a busy one answers when it finishes. The reply comes back to the chat that asked.`,`The Conversations window (in the sidebar) shows every conversation between your chats: who said what to whom, what each answer cost, and buttons to pause, resume, close or stop them all. Each conversation has a budget — 20 messages and 1,000,000 new tokens by default — and pauses itself when it is used up, so chats can never talk forever.`,`Hover over any tool in a chat’s Tools menu to read what it does, how it works, what it costs and how to turn it off.`],fixed:[`A chat woken in the background — by a scheduled task or another chat — shows as working in the sidebar even when it is not open in a tab.`,`A scheduled task no longer slips into a chat at the same moment you send it a message; yours always goes first.`,`A message sent from the terminal no longer waits forever when a chat’s history cannot be resumed and the restart fails. It now says why.`,`Notes OonaCode writes into a chat — a model change, a conversation paused — are still there when you reopen it.`,`When every Claude seat in the OonaCode pool is taken, a new chat now says the model is busy and to try again in a few minutes or pick another model, instead of “Something went wrong on our side”.`,`On Linux, the app tells you it is updating while it swaps itself, so there is no need to start it again.`,`On Linux, removing the .deb or .rpm leaves nothing running and nothing failing at the next login, and the one-line installer checks for free disk space before it changes anything.`]},{version:`0.3.155`,date:`2026-09-27`,added:[`OonaCode runs on Linux. One command installs the command line, the background service and the desktop app: curl -fsSL https://oonacode.oonak.ai/install.sh | bash. The AppImage, .deb and .rpm are on the download page too.`,`On Linux the app lives in the system tray as it does on Windows, follows your desktop’s light or dark theme, and gets its own entry in the applications menu.`,`Uninstalling on Linux removes the desktop app along with the rest, and asks whether to keep your chats for a future install.`],fixed:[`A window no longer stays on “Unauthorized” after the background service restarts with a new key. It reconnects by itself.`]},{version:`0.3.154`,date:`2026-09-26`,added:[],fixed:[`A chat waiting on a long job no longer loses its watcher. OonaCode used to close a chat’s engine ten minutes after the model last spoke, which stopped any Monitor or background command it had left running. The engine now stays up while such work runs, up to 12 hours.`,`A chat moved into a project, or whose project you edit, now follows the project’s instructions from its next message. It used to keep the ones it started with.`]},{version:`0.3.153`,date:`2026-09-25`,added:[],fixed:[`A very long chat no longer answers “Prompt is too long” after OonaCode restarts or updates. The engine was judging the chat’s size by a figure left over from before the restart, and now gets an accurate one.`,`If a message is ever refused as too long before the model has started on it, OonaCode sends it again by itself with a shorter history. You see your message once and then the answer, not an error.`]},{version:`0.3.152`,date:`2026-09-25`,added:[],fixed:[`Uninstalling the app from Windows’ Apps list no longer stops the command-line OonaCode on the same PC from starting after a restart.`]},{version:`0.3.151`,date:`2026-09-25`,added:[`Files the agent names in a chat are clickable. Audio and video play right in the chat with a small player, pictures open as a preview, and in the app every file can be opened in its own program or shown in its folder.`,`Uninstalling the app asks whether to keep your chats on this PC. Keeping them means a new install signs in and continues every chat.`],fixed:[`Installing and updating no longer fail with “The operation has timed out” on PCs whose network drops the newer internet addresses, nor while our server restarts for an update.`]},{version:`0.3.150`,date:`2026-09-25`,added:[],fixed:[`The fix in 0.3.149 for long, sleeping turns now really reaches the agent: the Monitor tool and the block on long waits are on for every chat.`,`A chat compacted after a long pause no longer pays to cache a conversation it is about to replace, and the agent keeps each tool call in its history exactly as it wrote it — both as Claude Code does.`]},{version:`0.3.149`,date:`2026-09-25`,added:[`The agent can watch a long job with the Monitor tool, as Claude Code does, and is woken the moment the job finishes.`],fixed:[`Long chats no longer spend their time asleep. With no way to watch a background job, the agent had been polling it with waits of four to eight minutes. One chat spent more than three and a half hours of a day sleeping, and turns ran for hours while the model worked for a fraction of that. The agent now gets the same working rules as Claude Code, and long waits are blocked.`]},{version:`0.3.148`,date:`2026-09-25`,added:[],fixed:[`A scheduled task that could not be sent — the PC had just restarted, the vault was still locked, the server was not reachable yet — waits and tries again instead of switching itself off. Pausing, editing or deleting a task while its prompt is being sent is no longer undone, and a scheduled prompt no longer lands in a chat whose engine is still starting.`,`A chat on your own DeepSeek key, or one switched with a typed “/model opus”, is no longer shown as withdrawn and locked. “/model fable” picks Claude Fable instead of the default model.`,`Moving a chat to another model no longer lowers its saved effort level to what the old model offered, and a one-off “oona --effort” is no longer saved as the chat’s level.`,`After you pick another model for a locked chat and send, the chat no longer flashes the lock again while the engine starts; if the start fails, your pick is kept.`,`Coming back from a file tab no longer jumps the chat to an old reply or reopens the search bar.`,`The hidden sidebar slides away again when the pointer leaves the window past its edge, and the keyboard no longer tabs through it while it is hidden. Clicking ⓘ in Settings opens its note instead of closing it.`,`Subagents write their prompt cache for five minutes, as Claude Code does for its subscribers; the chat itself keeps the hour. Their cache writes cost less.`]},{version:`0.3.147`,date:`2026-09-25`,added:[`A chat’s scheduled tasks sit beside its subagents: a clock badge says how many are live and when the next one runs, and opens the list — each task’s schedule, its next and last run, Pause and Delete. The tasks run on this PC.`],fixed:[`A prompt the scheduler sends into a chat reads as a “Scheduled task” line, not as your own message waiting in the queue.`,`A chat whose model is no longer offered shows that model in red and waits for you to pick another; its history stays, and the old model is not in the list any more.`,`The effort list follows the server within minutes, without restarting the app. A chat set to a level that has been switched off moves to the nearest one — ultracode becomes xhigh. Chats on your own Claude subscription have an effort picker again.`]},{version:`0.3.146`,date:`2026-09-25`,added:[`A Tools menu beside the model picker: switch OonaCode’s own tools on or off for each chat — browser, desktop and window control, clipboard, screen capture, Office documents and run-as-administrator. Each tool costs the model only a short line until it is used, and the menu shows how much. The first tools are marked Demo while they are tested with every model: a demo tool answers what it would have done, and does nothing on your PC yet.`],fixed:[]},{version:`0.3.145`,date:`2026-09-25`,added:[],fixed:[`Every request of every chat, on every model, is about 3,200 tokens smaller: the engine’s own “auto memory” instructions are gone. OonaCode starts each engine in a fresh private folder and deletes it afterwards, so the notes the model was told to keep there were thrown away when the chat went idle — the model spent tool calls writing memories it would never read. A project’s memory is OonaCode’s own and stays.`,`The engine’s claude.ai Artifact tools are switched off everywhere OonaCode runs it — the app, the terminal, VS Code, the phone, Telegram and the agent API.`]},{version:`0.3.144`,date:`2026-09-25`,added:[],fixed:[`Long chats on Claude models in the OonaCode pool keep their cache for an hour, as Claude Code does for its subscribers. A pause of more than five minutes no longer re-sends the whole conversation at the full cache-write price, which in a large chat was the most expensive part of coming back to it.`,`The session panel’s Context shows how big the conversation is now, not the total of every request the chat ever made — a long chat read “10.7M / 1.0M tokens”.`,`The message box keeps the cursor after you send, so you can go straight on typing the next message.`,`A paid chat’s background work (titles, reading web pages) no longer goes to a free model of the same vendor.`]},{version:`0.3.143`,date:`2026-09-24`,added:[`Search inside your chats: open the search in the chat list, press the sliders button and choose Whole chats. It looks through every message of every chat on this PC, and you choose whose words — yours, the model’s, or both — plus, if you like, the tools’ commands and output and the subagents’ conversations. Results show each message with the words lit; a click opens the chat with its search on them.`,`More search options, for both kinds of search: one project only, a time window (today, 7 or 30 days), match case and whole words.`],fixed:[`While you search the chat list, projects with no matching chat are hidden too.`]},{version:`0.3.142`,date:`2026-09-24`,added:[],fixed:[`A reply you sent shows as the same small chip it had in the message box — “Reply to” and the first few words — instead of the whole quoted text; the full quote appears when you rest the pointer on it, and a click jumps to the message it answers.`,`The model now knows a reply points back into the conversation: it is told the quoted lines are from the chat history, not new input, and whose words they were — its own earlier reply, your earlier message, a file, or a tool’s output.`,`When the chat list is narrow, its buttons wrap onto a second line instead of spilling out of it.`]},{version:`0.3.141`,date:`2026-09-24`,added:[`The chat list on the left can be made wider or narrower: drag its right edge (double-click it for the usual width).`,`The chat list can hide: press the pin in its header, the button at the top left, or View → Sidebar (Ctrl+B). While hidden it slides in when the pointer reaches the left edge of the window, and slides away when you leave it.`,`Search in the chat list is a single magnifier now; click it and the search box opens across the top. Escape or × clears it.`],fixed:[`Opening OonaCode right after a restart no longer leaves the OonaCode pool models out of the model list: if they cannot be read yet, OonaCode asks again by itself a few seconds later and the list fills in.`,`The Artificial Analysis scores (intelligence, coding, speed and benchmarks) show on every model in the model list again — including the models of your own Claude and SuperGrok subscriptions, which never had them.`,`A chat’s details card no longer appears on top of its right-click menu.`]},{version:`0.3.140`,date:`2026-09-24`,added:[`Reply is tidier: the message you reply to shows as a small chip above the message box with its first few words, instead of filling the box. Click the chip — or the quote in a sent reply — to jump to that message; the × removes it.`,`Right-click a project in the sidebar for its settings: Project settings… opens Projects with that project already selected. The gear beside a project’s “+” does the same, and a chat filed in a project offers it in its own menu too.`,`Link GitHub. Under a project’s Repositories (and in Settings → Providers), link your GitHub account once: the agent’s git and gh then clone, pull and push your private repositories on every PC of yours. You type a short code on github.com; the token stays in your encrypted vault and never reaches the OonaCode server. Public repositories need nothing.`],fixed:[]},{version:`0.3.139`,date:`2026-09-24`,added:[`Every setting now says what it does, and resting the pointer on the ⓘ beside it tells you where in OonaCode it applies and what it does not do.`,`Export chats… is in the File menu (and on the sidebar in a browser window) instead of in Settings.`,`With Remote access turned off on a PC, your phone, Telegram, the website and your other PCs still show it — online or not — marked “remote access off”, and opening it tells you to turn Remote access back on in OonaCode on that PC.`],fixed:[`Turning Remote access off now tells your other devices at once. Before, the PC was already unreachable from them, but they could not say why.`,`The settings of This PC save the moment you change them — nothing is lost by closing the dialog.`,`Settings that did nothing, or repeated another one, are gone: the default permission mode (each chat’s Build / Plan / Ask first picker decides), the agent-picker switch, the Git Bash path, the engine path and the extra allowed origins. The server address is shown, not edited — signing in sets it.`]},{version:`0.3.138`,date:`2026-09-24`,added:[`Projects have settings now, like the Claude app’s: a goal, the repositories the project works on, what a new chat in it starts on (model, effort and folder), a project memory the agent keeps up to date, and whether its chats may schedule work — and how often at most. All of it is in Projects, and a Claude app project you import brings its own.`,`OonaCode has a scheduler. Ask the agent to do something later or on a repeat — “check the build every morning at nine” — and it schedules it on this PC; when it is due, the prompt arrives in the chat, even if the chat had gone quiet. The Projects dialog and the chat’s info panel list what is scheduled, where you can pause, resume or delete it.`],fixed:[`Saving a project’s instructions now reaches its chats at their next message, instead of waiting until the chat happened to restart.`]},{version:`0.3.137`,date:`2026-09-24`,added:[],fixed:[`After a PC restart the app could ask for a "host token" and sign you out: two copies of the OonaCode background service started at once and fought over your session. Only one ever runs now, and the app never shows the token page — if its service is replaced it reconnects by itself.`,`The unlock screen stays put until you unlock, and says what went wrong in place — a wrong password, or a connection it is re-establishing — instead of jumping to another page.`,`A message with a picture sent while the agent was working stayed “queued”, and removing it said it was already sent. It now shows as read the moment the agent takes it, and a reopened chat shows it with its picture.`,`In the model’s questions, typing your own answer now clears the options you had picked, and picking an option clears what you typed — the answer sent is exactly the one you chose. The same on the phone, in the terminal and in Telegram.`]},{version:`0.3.136`,date:`2026-09-24`,added:[`Every model now has its own housekeeper — the small, fast model of the same maker that writes a chat’s titles and reads the web pages it fetches. On the OonaCode pool a MiMo v2.6 Pro chat uses MiMo v2.6 Flash, a Qwen chat Qwen3.8 Flash, a GLM chat GLM-5.3 Flash and a GPT-5 chat GPT-5 mini, instead of doing that work on the big model itself. A free model keeps its own, so it stays free.`],fixed:[]},{version:`0.3.135`,date:`2026-09-24`,added:[],fixed:[`Claude models on the OonaCode pool — Opus 5.5, Opus 5, Sonnet 5 and Fable 5.1 — now use their whole 1M context. A long chat no longer stops to summarise itself every ~170k tokens, and its subagents get the same window.`,`Reading a web page is quick again in a Claude chat: pages are read by Claude Haiku, as in Claude Code, instead of a helper that took about a minute a page.`,`Changing a chat’s model now moves its subagents and background helpers to the new model too; before, they stayed on the old one until the app restarted.`,`MiMo v2.5 and v2.5 Pro chats now use their full 1M context too.`]},{version:`0.3.134`,date:`2026-09-23`,added:[],fixed:[`On the Android app, the model’s questions can be answered again. They come one at a time — “Question 2 of 3” — with Back, Next and Skip, and Answer sends them to your PC. The card used to show only the first question, hide the rest below it and wait for all of them, so it could not be sent.`]},{version:`0.3.133`,date:`2026-09-23`,added:[`Bring your Claude desktop app projects across: File → Import chats from other coding agents now lists every project the Claude app has opened on this PC. Each one arrives as an OonaCode project of the same name — its goal, instructions and what Claude noted about it become the project’s instructions — with its project chat and one chat per thread filed under it, ready to carry on.`,`A Claude Code chat you moved into a Claude app project is filed under that project here too.`,`A thread you never opened in the Claude app still comes across, with its task and every reply the project chat saw; open it once in the Claude app and import again for its whole conversation.`],fixed:[`Cursor chats appear in the import list again — they had been left out since September 10.`]},{version:`0.3.132`,date:`2026-09-23`,added:[`Reply to any part of a chat: select some text (or just right-click a block), choose Reply, and it is quoted in your message box — type your answer under it. A quote from a file the agent read names the file.`,`Right-click in a chat: copy what you selected, copy a whole reply or tool output, copy a code block or a link, find the selected words in the chat, or select a block.`,`Search in a chat opens the block its match is in — a folded tool card, a thought, a finished agent’s work — and scrolls to the words themselves.`,`Search matches are now bright orange, the current one strongest, so they stand out on code too.`,`The file viewer shows pictures (PNG, JPEG, GIF, WebP, SVG and more), plays audio and video, and shows Markdown formatted, with a switch to the source.`,`Right-click a file or folder in the explorer to copy its path or delete it.`],fixed:[`Moving a chat to another folder or project while it was working could delete the folder it was working in, start two agents at once, or send your next message to the old folder.`,`The working line no longer says a chat may be stuck while it waits for your approval or answer, or right after you send a message, and it counts time correctly (no more "4m 60s").`,`A date line no longer says "Today" for yesterday’s messages when the app stays open past midnight.`,"Installing with npm (`npm i -g oonacode`) installs this version again; earlier npm releases carried an old program.",`The What’s new window could open again on the next start, showing the same update a second time.`,`An older OonaCode window or VS Code extension no longer resets settings it does not know about, such as your theme colours or which project groups you folded.`,`A new install no longer opens with a list of changes; this window now appears only after an update.`,`The notification switch for permissions now says it also covers the agent’s questions.`]},{version:`0.3.131`,date:`2026-09-23`,added:[`Claude Opus 5.5 is here — the newest Opus, and cheaper to run than Opus 5. Choose it in the model picker, from the OonaCode pool or on your own Claude subscription. It runs on the newer Claude Code engine (2.1.280) that this update brings.`,`Every block in a chat shows its time at the bottom right, in your local time — hover it for the full date — and a date line marks where each day starts.`,`A running chat tells you how long the agent has been quiet, and after five minutes that it may be stuck and what to do.`,`After every update, OonaCode now opens this window to show you what changed.`],fixed:[`A reply that streamed in live had no time on it until the chat was opened again.`,`Chats open in tabs could fail to come back after a restart if a setting changed while they were being restored.`]}];function Qc(e,t){let n=e=>{let[t,...n]=e.trim().replace(/^v/,``).split(`-`);return{nums:(t??``).split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n.length>0?n.join(`-`):null}},r=n(e),i=n(t);for(let e=0;e<Math.max(r.nums.length,i.nums.length);e++){let t=(r.nums[e]??0)-(i.nums[e]??0);if(t!==0)return t}return r.pre===i.pre?0:r.pre===null?1:i.pre===null?-1:$c(r.pre,i.pre)}function $c(e,t){let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e],i=r[e];if(t===i)continue;if(t===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(t),o=/^\d+$/.test(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e;continue}return a===o?t<i?-1:1:a?-1:1}return 0}function el(e,t,n=Zc,r=null){if(!e||e===`0.0.0`)return[];let i=n.filter(t=>Qc(t.version,e)<=0&&(!r||!t.platforms||t.platforms.includes(r)));return[...t===null?i.filter(t=>Qc(t.version,e)===0):i.filter(e=>Qc(e.version,t)>0)].sort((e,t)=>Qc(t.version,e.version))}function tl(e,t,n,r=Zc,i=null){if(!e||e===`0.0.0`)return{record:null,show:[]};let a=null;for(let e of r)(a===null||Qc(e.version,a)>0)&&(a=e.version);let o=a!==null&&Qc(e,a)>0?a:e;return{record:t===null||Qc(o,t)>0?o:null,show:t===null&&!n?[]:el(e,t,r,i)}}function nl(e,t){if(t==null)return[...e];if(t.length===0)return[];let n=new Set(t),r=e.filter(e=>n.has(e.id));return r.length>0?r:[...e]}var rl=`:free`;function il(e){return e.endsWith(rl)}function al(e){return il(e)?e.slice(0,-5):e}var ol=`the user skipped the question`,sl=`(the user skipped this question)`;function cl(e){let t=e?.questions;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.question!=`string`)continue;let r=Array.isArray(t.options)?t.options.map(e=>e&&typeof e==`object`?e:null).filter(e=>e!==null&&typeof e.label==`string`).map(e=>({label:e.label,...typeof e.description==`string`?{description:e.description}:{}})):[];n.push({question:t.question,header:typeof t.header==`string`?t.header:``,options:r,multiSelect:t.multiSelect===!0})}return n}function ll(e,t,n={},r=new Set){let i={};return e.forEach((e,a)=>{if(r.has(a)){i[e.question]=sl;return}let o=(n[a]??``).trim();i[e.question]=o||(t[a]??[]).join(`, `)}),i}function ul(e){let t=e.questions,n=t===1?`question`:`questions`,r=t===1?`the model’s question`:`the model’s questions`,i=t===1?`The model’s question was`:`The model’s questions were`;switch(e.outcome){case`answered`:{let r=e.answers?Object.values(e.answers):null,i=r?r.filter(e=>typeof e==`string`&&e!==``&&e!==`(the user skipped this question)`).length:t;return t>0&&i<t?`You answered ${i} of ${t} ${n}`:t===0?`You answered the model’s questions`:t===1?`You answered the model’s question`:`You answered ${t} ${n}`}case`skipped`:return`You skipped ${r}`;case`dismissed`:return`${i} dismissed`;case`unanswered`:return`${i} not answered — the turn ended`}}function dl(e){if(!e||typeof e!=`object`)return null;let t=e.answers;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}var fl=[`win32`,`linux`,`darwin`],pl=[`demo`,`live`],ml=[`allow`,`ask`],hl=[`string`,`number`,`integer`,`boolean`,`array`,`object`];function gl(e){let t=e/1048576;return t>=100?`${Math.round(t)} MB`:t>=1?`${t.toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function _l(e){if(e.toolName!==`InstallToolPack`)return null;let t=e.input;return!t||typeof t!=`object`||typeof t.pack!=`string`||typeof t.name!=`string`||typeof t.version!=`string`||typeof t.sizeBytes!=`number`||typeof t.path!=`string`?null:{pack:t.pack,name:t.name,version:t.version,sizeBytes:t.sizeBytes,path:t.path}}function vl(e,t){let n=t?.[e.slug];return typeof n==`boolean`?n:e.defaultOn}function yl(e,t){return e.filter(e=>vl(e,t))}var bl={slug:48,name:80,entryTool:40,description:2e3,promptLine:1e3,details:8e3,actionDescription:1e3,params:30,paramName:48,paramDescription:400,enumValues:40,callArgKeys:20,callError:500,callBatch:100},xl=/^[A-Za-z0-9_-]+$/;function Sl(e){return typeof e==`string`&&e.length>0&&e.length<=bl.entryTool&&xl.test(e)}function Cl(e){return Math.ceil(e.length/4)}function wl(e){return Cl(`${e.entryTool} ${e.description}`)+55}function Tl(e){return e.tokensPerRequest??wl(e)+(e.promptLine?Cl(e.promptLine):0)}var El=Uo({type:$o(hl),required:Fo().optional(),enum:Vo(Go([H(),jo()])).optional(),description:H().optional()}),Dl=Uo({slug:H().min(1),description:H(),params:Zo(H(),El),permission:$o(ml),sort:jo()}),Ol=Uo({version:H(),url:H(),sha256:H(),sizeBytes:jo(),exe:H(),format:ts(`zip`)}),kl=Uo({slug:H().min(1),name:H(),entryTool:H().refine(Sl,`not a valid tool name`),description:H(),promptLine:H().nullable(),details:H().nullable().optional(),status:$o(pl),defaultOn:Fo(),sort:jo(),install:Ol.nullable(),actions:Vo(Dl)}).loose();Uo({platform:$o(fl),version:H(),packs:Vo(kl),refreshMinutes:jo()});var Al=[`No answer needed.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. Your final answer goes back to that chat by itself.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. It asked for no answer, so nothing goes back.`,`Last hop of this chain: you cannot message chats in this turn; put what you have in your final answer.`];[`**Let this chat work together with your other chats.**`,``,`### What it does`,`- Finds your other chats on this PC and reads their recent messages.`,`- Sends one chat, or a group of chats, a message or a task.`,`- Brings their answers back to this chat, by itself.`,``,`### How it works`,`- A chat that is asleep is woken from its saved history. A busy one gets the message when its current turn ends, never in the middle of it.`,`- The other chat does the work with its own model, folder and tools. Its answer comes back here as a new message only when this chat asked for one.`,`- Several messages from one chat that wait for a busy chat are handed over together, in one turn, with one answer.`,`- Several chats can share one conversation (a group). An answer goes only to the chat that asked, so a group cannot multiply its own messages.`,`- A chat with this switch OFF can still be messaged by a chat that has it on. It does the work, and its final answer goes back to that chat when that chat asked for one. That is all it can do: it gets none of these tools, cannot message or read other chats, and its switch stays off.`,``,`### What it costs`,`- About 650 tokens on every request while it is on, read from the prompt cache. Nothing while it is off, even in a chat that is messaged.`,`- Every message makes the chat that receives it do a turn, which spends its own tokens.`,`- Switching it on or off in a chat that already has a conversation re-writes its prompt cache once.`,``,`### Safety limits`,`- Each conversation has a budget: 20 delivered messages and 1,000,000 new tokens by default (context read back from the prompt cache is not counted). Reaching either pauses the conversation, and the chats say so.`,`- A chain stops after 3 hops (a message caused by a message caused by a message).`,`- At most 5 messages between two chats and 20 from one chat in 10 minutes, and 10 waiting for any one chat. A chat cannot message itself.`,`- A conversation with no activity for 24 hours closes by itself.`,``,`### How to stop it`,`- Turn this switch off: the chat loses these tools, and what it sent and the answers it asked for pause. It still answers a chat that messages it.`,`- Or open the Conversations window and use Pause, Close or Stop all.`,``,`### Privacy`,`- Everything stays on your PC: the messages are kept in this PC's database, never on OonaCode's server.`,`- A message never grants anything. The other chat runs with its own permissions and asks you as usual.`,``,`Only a chat with this switch on can start a conversation; a chat with it off only answers.`].join(`
|
|
77
|
+
`,18);return t<0?null:{title:e.slice(18,t),prompt:e.slice(t+3)}}Object.freeze({tengu_amber_sentinel:!0,tengu_groovy_eclipse:!0,tengu_humble_hammock:!0});function ic(e){return e===null||!Number.isFinite(e)?`neutral`:e>30?`ok`:e>10?`warn`:`danger`}var ac=[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`],oc=/^([01]\d|2[0-3]):[0-5]\d$/;Uo({tz:H().min(1),windows:Vo(Uo({from:H().regex(oc,`HH:MM`),to:H().regex(oc,`HH:MM`),days:Vo($o(ac)).optional(),kind:$o([`peak`,`offpeak`])})),offpeakDiscount:jo().nonnegative().max(1).optional()});var sc=[`priceInputCacheMissPeak`,`priceInputCacheMissOffpeak`,`priceInputCacheHitPeak`,`priceInputCacheHitOffpeak`,`priceCacheWritePeak`,`priceCacheWriteOffpeak`,`priceOutputPeak`,`priceOutputOffpeak`],cc=Uo({inputCacheMiss:jo().nonnegative(),inputCacheHit:jo().nonnegative().optional(),cacheWrite:jo().nonnegative().optional(),output:jo().nonnegative()});Uo({by:ts(`prompt_tokens`),tiers:Vo(Uo({upToPromptTokens:jo().int().positive().optional(),price:cc.optional(),cost:cc.optional()})).min(1),note:H().optional()}).superRefine((e,t)=>{let n=0;e.tiers.forEach((r,i)=>{!r.cost&&!r.price&&t.addIssue({code:`custom`,message:`a tier needs its cost (the provider’s rates; retail is cost × the record’s ratio)`,path:[`tiers`,i,`cost`]});let a=r.upToPromptTokens;if(a===void 0){i!==e.tiers.length-1&&t.addIssue({code:`custom`,message:`only the LAST tier may omit upToPromptTokens`,path:[`tiers`,i]});return}a<=n&&t.addIssue({code:`custom`,message:`tiers must ascend: ${a} does not exceed ${n}`,path:[`tiers`,i,`upToPromptTokens`]}),n=a})}),[...sc];var lc={realtime:`/v1/realtime`,translations:`/v1/realtime/translations`,live:`/v1/live/sessions`,speechStream:`/v1/audio/speech/stream`,transcriptionStream:`/v1/audio/transcriptions/stream`,clientSecrets:`/v1/realtime/client_secrets`,translationClientSecrets:`/v1/realtime/translations/client_secrets`};lc.realtime,lc.translations,lc.live,lc.speechStream,lc.transcriptionStream;var uc={oonacode:{hex:`#000000`,owner:`OonaCode`,d:`M0.72 12a11.28 11.28 0 1 0 22.56 0a11.28 11.28 0 1 0 -22.56 0ZM4.8 12a7.2 7.2 0 1 0 14.4 0a7.2 7.2 0 1 0 -14.4 0ZM7.44 12a4.56 4.56 0 1 0 9.12 0a4.56 4.56 0 1 0 -9.12 0Z`,fillRule:`evenodd`},anthropic:{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},"anthropic-subscription":{hex:`#D97757`,owner:`Anthropic`,d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`},openai:{hex:`#000000`,owner:`OpenAI`,d:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`},xai:{hex:`#000000`,owner:`xAI`,d:`M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z`},deepseek:{hex:`#5786FE`,owner:`DeepSeek`,d:`M23.748 4.651c-.254-.124-.364.113-.512.233-.051.04-.094.09-.137.137-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.155-.708-.311-.955-.65-.172-.24-.219-.509-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.094.172.187.129.323-.082.28-.18.553-.266.833-.055.179-.137.218-.328.14a5.5 5.5 0 0 1-1.737-1.179c-.857-.828-1.631-1.743-2.597-2.46a12 12 0 0 0-.689-.47c-.985-.957.13-1.743.387-1.836.27-.098.094-.433-.778-.428-.872.003-1.67.295-2.687.685a3 3 0 0 1-.465.136 9.6 9.6 0 0 0-2.883-.101c-1.885.21-3.39 1.1-4.497 2.622C.082 8.776-.231 10.854.152 13.02c.403 2.284 1.568 4.175 3.36 5.653 1.857 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.132-.284 4.994-1.86.47.234.962.328 1.78.398.629.058 1.235-.031 1.705-.129.735-.155.684-.836.418-.961-2.155-1.004-1.682-.595-2.112-.926 1.095-1.295 2.768-3.598 3.284-6.733.05-.346.115-.834.108-1.114-.004-.171.035-.238.23-.257a4.2 4.2 0 0 0 1.545-.475c1.397-.763 1.96-2.016 2.093-3.517.02-.23-.004-.467-.247-.588M11.58 18.168c-2.088-1.642-3.101-2.183-3.52-2.16-.39.024-.32.472-.234.763.09.288.207.487.371.74.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.168-1.361-.801-2.5-1.86-3.301-3.306-.775-1.393-1.225-2.888-1.299-4.482-.02-.385.094-.522.477-.592a4.7 4.7 0 0 1 1.53-.038c2.131.311 3.946 1.264 5.467 2.774.868.86 1.525 1.887 2.202 2.89.72 1.066 1.494 2.082 2.48 2.915.348.291.626.513.892.677-.802.09-2.14.109-3.055-.615zm1.001-6.44a.306.306 0 0 1 .415-.287.3.3 0 0 1 .113.074.3.3 0 0 1 .086.214c0 .17-.136.307-.308.307a.303.303 0 0 1-.306-.307m3.11 1.596c-.2.081-.4.151-.591.16a1.25 1.25 0 0 1-.798-.254c-.274-.23-.47-.358-.551-.758a1.7 1.7 0 0 1 .015-.588c.07-.327-.007-.537-.238-.727-.188-.156-.426-.199-.689-.199a.6.6 0 0 1-.254-.078.253.253 0 0 1-.114-.358 1 1 0 0 1 .192-.21c.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.392.451.462.576.685.915.176.264.336.536.446.848.066.194-.02.353-.25.45`},kimi:{hex:`#000000`,owner:`Moonshot`,d:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`},qwen:{hex:`#6950EF`,owner:`Alibaba`,d:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`},mimo:{hex:`#FF6900`,owner:`Xiaomi`,d:`M12 0C8.016 0 4.756.255 2.493 2.516.23 4.776 0 8.033 0 12.012c0 3.98.23 7.235 2.494 9.497C4.757 23.77 8.017 24 12 24c3.983 0 7.243-.23 9.506-2.491C23.77 19.247 24 15.99 24 12.012c0-3.984-.233-7.243-2.502-9.504C19.234.252 15.978 0 12 0zM4.906 7.405h5.624c1.47 0 3.007.068 3.764.827.746.746.827 2.233.83 3.676v4.54a.15.15 0 0 1-.152.147h-1.947a.15.15 0 0 1-.152-.148V11.83c-.002-.806-.048-1.634-.464-2.051-.358-.36-1.026-.441-1.72-.458H7.158a.15.15 0 0 0-.151.147v6.98a.15.15 0 0 1-.152.148H4.906a.15.15 0 0 1-.15-.148V7.554a.15.15 0 0 1 .15-.149zm12.131 0h1.949a.15.15 0 0 1 .15.15v8.892a.15.15 0 0 1-.15.148h-1.949a.15.15 0 0 1-.151-.148V7.554a.15.15 0 0 1 .151-.149zM8.92 10.948h2.046c.083 0 .15.066.15.147v5.352a.15.15 0 0 1-.15.148H8.92a.15.15 0 0 1-.152-.148v-5.352a.15.15 0 0 1 .152-.147Z`}};function dc(e){return uc[e]??null}function fc(e){let t=e.replace(/\(.*?\)/g,` `).split(/[\s/_-]+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]}${t[1][0]}`.toUpperCase()}var pc=9230,mc=1024,hc=65534,gc=`127.0.0.1`;Object.freeze({enabled:!1,port:pc,inspectMain:!1}),Object.freeze({port:null,listening:!1,fromCommandLine:!1,inspectPort:null,inspectProblem:null});function _c(e){return e+1}function vc(e){return typeof e==`number`&&Number.isInteger(e)}function yc(e){return!vc(e)||e<1024||e>65534?`The port must be a whole number from ${mc.toLocaleString(`en-US`)} to ${hc.toLocaleString(`en-US`)} (the main-process inspector takes the next one).`:null}function bc(e){return e.port!==null||e.inspectPort!==null}function xc(e,t){let n=e.enabled?e.port:null,r=e.enabled&&e.inspectMain?_c(e.port):null;return!t.fromCommandLine&&t.port!==n||t.inspectPort!==r}function Sc(e){let t=[];return e.port!==null&&t.push(`${gc}:${e.port}`),e.inspectPort!==null&&t.push(`${gc}:${e.inspectPort}`),t.length===2?`${t[0]} (windows) and ${t[1]} (main process)`:e.inspectPort===null?t[0]??``:`${t[0]} (main process)`}var Cc=[`stable`,`dev`];function wc(e){return typeof e==`string`&&Cc.includes(e)}function Tc(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return wc(t)?t:null}var Ec=[`win32`,`linux`,`darwin`],Dc=[`x64`,`arm64`];function Oc(e,t){let n=Tc(e)??`stable`,r=[];return n!==`stable`&&r.push(`channel=${encodeURIComponent(n)}`),t&&Ec.includes(t.platform)&&(r.push(`platform=${t.platform}`),t.arch&&Dc.includes(t.arch)&&r.push(`arch=${t.arch}`)),r.length>0?`${qs.releasesLatest}?${r.join(`&`)}`:qs.releasesLatest}function kc(e,t){let n=Tc(t)??`stable`;return n===`stable`?e:`${e} (${n})`}var Ac=5e4,jc=6,Mc=[`bg`,`surface`,`surface-2`,`surface-3`,`border`,`fg`,`fg-muted`,`fg-faint`,`accent`,`accent-fg`,`accent-soft`,`project`,`ok`,`ok-soft`,`warn`,`warn-soft`,`danger`,`danger-soft`,`think`,`think-soft`,`code-bg`,`user-bubble`],Nc={agentFinished:!1,permissionRequired:!0,errorOccurred:!0},Pc={autoAcceptPermissions:!1,showReasoningSummaries:!0,notifications:Nc,showAgentPicker:!0,transcriptWindowSize:500,openTabs:[],draftTabs:[],draftTitles:{},activeTab:null,editorLayout:null,remoteTabs:{},sessionPanelOpen:!1,explorerOpen:!1,sidebarWidth:288,sidebarPinned:!0,dismissedUpdateVersion:null,lastSeenReleaseNotes:null,claudeImportOffered:!1,claudeImportOffers:0,collapsedProjects:[],themeColors:{light:{},dark:{}},pinned:[],sidebarView:`recent`};function Fc(e){return Math.min(Math.max(typeof e==`number`&&Number.isFinite(e)?Math.floor(e):0,0),3)}function Ic(e){return Math.min(640,Math.max(200,typeof e==`number`&&Number.isFinite(e)?Math.round(e):288))}function Lc(e){return Math.min(Ac,Math.max(100,typeof e==`number`&&Number.isFinite(e)?Math.round(e):500))}function Rc(e,t){return typeof e==`boolean`?e:t}function zc(e){return typeof e==`string`&&e.length>0&&e.length<=64?e:null}function Bc(e,t=50){if(!Array.isArray(e))return[];let n=[];for(let r of e)if(!(typeof r!=`string`||r.length===0||r.length>200)&&!n.includes(r)&&(n.push(r),n.length>=t))break;return n}function Vc(e,t=50){if(typeof e!=`object`||!e||Array.isArray(e))return{};let n={};for(let[r,i]of Object.entries(e))if(!(r.length===0||r.length>200)&&!(typeof i!=`string`||i.length===0||i.length>200)&&(n[r]=i,Object.keys(n).length>=t))break;return n}function Hc(e){if(typeof e!=`string`)return null;let t=e.trim();return/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():null}function Uc(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e)){if(!Mc.includes(n))continue;let e=Hc(r);e!==null&&(t[n]=e)}return t}function Wc(e){let t=typeof e==`object`&&e?e:{};return{light:Uc(t.light),dark:Uc(t.dark)}}function Gc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=n.kind,r=n.id;if((e===`chat`||e===`project`)&&!(typeof r!=`string`||r.length===0||r.length>200)&&!t.some(t=>t.kind===e&&t.id===r)&&(t.push({kind:e,id:r}),t.length>=50))break}return t}function Kc(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return null;let n=e,r=new Set(t),i=new Set,a=0,o=(e,t)=>{if(t>jc||typeof e!=`object`||!e)return null;let n=e,s=n.group;if(typeof s==`object`&&s&&!Array.isArray(s)){if(a>=8)return null;let e=s,t=[];for(let n of Array.isArray(e.tabs)?e.tabs:[])typeof n!=`string`||!r.has(n)||i.has(n)||(i.add(n),t.push(n));return t.length===0?null:(a+=1,{group:{tabs:t,active:(typeof e.active==`string`&&t.includes(e.active)?e.active:null)??t[t.length-1]}})}let c=n.split;if(c!==`row`&&c!==`column`)return null;let l=Array.isArray(n.children)?n.children:[],u=Array.isArray(n.sizes)?n.sizes:[],d=[],f=[];if(l.slice(0,8).forEach((e,n)=>{let r=o(e,t+1);if(!r)return;d.push(r);let i=u[n];f.push(typeof i==`number`&&Number.isFinite(i)&&i>0?i:0)}),d.length===0)return null;if(d.length===1)return d[0];let p=f.filter(e=>e>0),m=p.length>0?p.reduce((e,t)=>e+t,0)/p.length:1,h=f.map(e=>e>0?e:m),g=h.reduce((e,t)=>e+t,0);return{split:c,sizes:h.map(e=>e/g),children:d}},s=o(n.root,0);if(!s||a<2)return null;let c=n.focused;return{root:s,focused:typeof c==`number`&&Number.isInteger(c)&&c>=0&&c<a?c:0}}function qc(e,t,n){return e.some(e=>e.kind===t&&e.id===n)}function Jc(e,t,n,r){return r===qc(e,t,n)?e:r?[...e.length>=50?e.slice(e.length-50+1):e,{kind:t,id:n}]:e.filter(e=>e.kind!==t||e.id!==n)}function Yc(e){let t=typeof e==`object`&&e?e:{},n=typeof t.notifications==`object`&&t.notifications!==null?t.notifications:{},r=Bc(t.openTabs),i=Bc(t.draftTabs).filter(e=>!r.includes(e)),a={};for(let[e,n]of Object.entries(Vc(t.draftTitles)))i.includes(e)&&(a[e]=n);let o=[...r,...i],s=t.activeTab,c=typeof s==`string`&&o.includes(s)?s:o[o.length-1]??null;return{autoAcceptPermissions:Rc(t.autoAcceptPermissions,Pc.autoAcceptPermissions),showReasoningSummaries:Rc(t.showReasoningSummaries,Pc.showReasoningSummaries),notifications:{agentFinished:Rc(n.agentFinished,Nc.agentFinished),permissionRequired:Rc(n.permissionRequired,Nc.permissionRequired),errorOccurred:Rc(n.errorOccurred,Nc.errorOccurred)},showAgentPicker:Rc(t.showAgentPicker,Pc.showAgentPicker),transcriptWindowSize:Lc(t.transcriptWindowSize),openTabs:r,draftTabs:i,draftTitles:a,activeTab:c,editorLayout:Kc(t.editorLayout,o),remoteTabs:Vc(t.remoteTabs),sessionPanelOpen:Rc(t.sessionPanelOpen,Pc.sessionPanelOpen),explorerOpen:Rc(t.explorerOpen,Pc.explorerOpen),sidebarWidth:Ic(t.sidebarWidth),sidebarPinned:Rc(t.sidebarPinned,Pc.sidebarPinned),dismissedUpdateVersion:zc(t.dismissedUpdateVersion),lastSeenReleaseNotes:zc(t.lastSeenReleaseNotes),claudeImportOffered:Rc(t.claudeImportOffered,Pc.claudeImportOffered),claudeImportOffers:Fc(t.claudeImportOffers),collapsedProjects:Bc(t.collapsedProjects),themeColors:Wc(t.themeColors),pinned:Gc(t.pinned),sidebarView:t.sidebarView===`projects`?`projects`:`recent`}}new Set(Object.keys(Pc));var Xc=3650,Zc=[{version:`0.3.204`,date:`2026-10-04`,platforms:[`win32`],added:[`Signing in to Google Gemini opens Google’s page for you and shows how many seconds are left: Google’s agy waits only one minute for the sign-in. Paste the code Google shows and it is sent at once.`],fixed:[`Signing in to Google Gemini finishes. The code you pasted never reached Google’s agy in the installed app (the window it types into dropped everything typed), so the sign-in waited out its minute and failed.`,`The Claude sign-in’s “paste the code” box, which used the same window, can type the code too.`]},{version:`0.3.203`,date:`2026-10-04`,platforms:[`win32`],added:[`Gemini on your own Google plan, through Google’s own agent. Open Settings → Providers → Google Gemini and press Install: OonaCode downloads Google’s agy for you and checks it. Then press Sign in with Google, sign in on Google’s own page and paste the one-time code back here. OonaCode never sees your password. A Google Gemini chat runs Google’s agent as it is (Build or Autonomous mode, text only, no pictures), and the chat’s info panel lists every request it made to Google.`,`Every provider in the model picker ends with a “Custom model…” row: type any model id and the chat runs it on that provider.`],fixed:[`The agents badge highlights what is happening now: “4 working” is blue and the total (“51 agents”) is grey, instead of the other way round.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`darwin`],added:[`OonaCode runs on macOS 12 or newer: the agent, your chats, the background service and the desktop app, installed with the same one line as on Linux — curl -fsSL https://oonacode.oonak.ai/install.sh | bash. An Intel build; Apple Silicon Macs run it through Rosetta 2. Your sign-in key is kept in your login keychain.`,`Updating is the same line again, oona update in a terminal, or the update button in the app: it closes OonaCode, puts the new version in place and opens it again. The app is not signed by Apple yet, so it cannot be downloaded from a browser and does not update itself the way it does on Windows.`],fixed:[]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`linux`],added:[],fixed:[`Your sign-in survives a restart on a PC that keeps OonaCode’s key in the login keyring (GNOME Keyring, KWallet): two of OonaCode’s keys shared one keyring entry and overwrote each other, and every start of the host wrote over the stored key — so after a restart you could find yourself signed out.`,`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode (an nvm folder, for example).`,`oona update installs from the site your OonaCode was installed from, not always from oonacode.oonak.ai.`]},{version:`0.3.202`,date:`2026-10-03`,platforms:[`win32`],added:[],fixed:[`OonaCode never runs a Claude Code you installed yourself as its engine, even when it sits in the same folder as the Node.js that runs OonaCode.`]},{version:`0.3.201`,date:`2026-10-03`,added:[`The Tools menu lists only tools that work. Desktop control, Clipboard, Screen capture and Run as administrator were demos that never ran anything, and they are gone: the agent already reads and sets your clipboard, takes screenshots and asks Windows for administrator rights through its own commands.`],fixed:[`Oonak Browser keeps working when its window is behind other windows. A browser covered by the OonaCode window used to crawl, and some clicks and scrolls gave up after 30 seconds.`,`Oonak Browser no longer clicks a hidden copy of a link, or a link inside a closed menu, when a site has both a visible and a hidden one.`,`A message you send right after a reply failed no longer stays pinned above the box as “queued” once the agent has read it.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`win32`],added:[`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`],fixed:[`Oonak Browser works on sites built from web components, Google’s own forms among them: it reads, finds, clicks and types inside them, where it used to answer “the page changed” or find nothing.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`]},{version:`0.3.200`,date:`2026-10-03`,platforms:[`linux`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`,`Everything OonaCode shows you is in credits, never in dollars: the model picker gives what an OonaCode pool model charges per 1M tokens in credits, and a chat’s spend, Usage, Conversations, Listen and the terminal all count credits. A chat on your own key or your own subscription says so instead of a price.`,`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`,`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop.`,`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name matches each word, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond, and it works inside web components, Google’s own forms among them. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`,`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed — 10 days after their last change.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`,`Chats talking to each other no longer ping-pong: a reply needs no answer, several messages from the same chat are read together in one turn, and a message card says “answer requested” until the answer has gone back, then “answered” with the time.`,`A tool you switch on while a chat is replying works for the message you send next, even mid-reply. After an update, a chat that had background tasks running shows one line saying how many stopped, instead of one card per task.`,`The model’s questions appear only in their own window: the chat no longer shows the question’s raw text while you answer, and afterwards keeps one line — “You answered 3 questions” — that opens to your answers.`,`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`,`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`,`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption.`]},{version:`0.3.199`,date:`2026-10-02`,platforms:[`win32`],added:[`Talk to other chats: a chat can now write to a chat whose switch is off. That chat’s switch stays off and it gets no new tools — it can only answer the chat that wrote to it. Finding a chat by name is smarter too: each word is matched, in its name, project, folder and description, and spelling like “AI-control” or “aicontrol” no longer matters.`,`Oonak Browser acts like a person: every click, keystroke and scroll is a real input event, so sites that ignore scripted clicks now respond. Typing into a drop-down picks the option, and typing into an editor adds the text at its end.`],fixed:[`A chat no longer ends up on a model nobody picked for it: a model the provider does not offer is refused instead of quietly switching the chat to the provider’s default, and Enter in the model picker no longer picks the row under the mouse pointer.`]},{version:`0.3.198`,date:`2026-10-01`,platforms:[`win32`],added:[`Listen has one button: Play. It writes a summary when the chat has none or has moved on, translates it once when you pick a new language, or just plays — saying only “Generating…” or “Translating…” while it works. A summary written in the last ten minutes is used for every language, so switching language never writes it again.`],fixed:[`A chat keeps its Build / Plan / Ask first / Autonomous choice, and every device shows the same one — the phone used to show “Ask first” for a Build chat. A chat set to “Ask first” now asks you before acting even when this PC answers prompts by itself.`,`Play in Listen is never greyed out for want of a voice: it gets the text ready and names the voice to install.`]},{version:`0.3.197`,date:`2026-10-01`,platforms:[`win32`],added:[`Oonak Browser, the browser your chats use, moves to version 151 by itself at its next use: a build with no Google services (no Safe Browsing warnings, push notifications or search suggestions). The download is checked against its fingerprint before anything is unpacked, and the old version is removed once no chat’s browser still runs from it.`],fixed:[`A model your plan does not include now says “not in your plan”, instead of “Failed to authenticate … sign-in needed”.`]},{version:`0.3.196`,date:`2026-10-01`,platforms:[`win32`],added:[`Your chats now live only on the PC that runs them. Your phone, the website and your other PCs read a chat straight from its PC, through the same encrypted connection they use to continue it — OonaCode’s server no longer keeps any copy. While a PC is off or asleep its chats cannot be read from elsewhere; the window says so and they come back when it is online. Update OonaCode on each of your PCs: another device reads a PC’s chats only once that PC runs this version.`],fixed:[`The account window no longer stays on “offline · vault event stream responded 503” after a short server interruption: the next sync that works clears it by itself.`]},{version:`0.3.195`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`Chats talking to each other no longer ping-pong. A message asks for an answer only when the chat really needs one; a reply needs no answer and is not answered with a new message; and several messages waiting from the same chat are read together in one turn. Fewer wake-ups, fewer tokens.`,`A message card says what is true: “answer requested” until the answer has gone back, then “answered” with the time — instead of an orange “reply expected” that never went away.`]},{version:`0.3.194`,date:`2026-10-01`,platforms:[`win32`],added:[`A chat can offer to move a task to a new chat. When a task deserves its own chat — a separate job, a chat that has grown long, work in another folder — the model proposes it with the first message written out; you can edit it, then Start new chat opens the new chat in a tab, sends the message and carries on there. Nothing starts without your yes.`,`Settings → Developer → Allow debugging: opens a debugging port on this PC only, so a developer can look at and drive the app while fixing a problem with you. Off by default; while it is on, every window shows a red “Debugging on” badge.`],fixed:[]},{version:`0.3.193`,date:`2026-10-01`,platforms:[`win32`],added:[],fixed:[`A tool you switch on while a chat is replying works for the message you send next, even mid-reply: that message now waits for the chat to restart with the new tool instead of reaching the model without it.`,`After an update, a chat that had background tasks running shows one line — “11 background tasks stopped — they were running when OonaCode restarted this chat” — instead of one card per task. Click it to see each one.`]},{version:`0.3.192`,date:`2026-09-30`,platforms:[`win32`],added:[`A morning briefing in View → What chats are about…: show the chats active in the last 24 hours, 3, 7, 10 or 30 days (or your own dates), tick the ones you want — or all — pick a language, a voice and a speed, and press Play. OonaCode reads each chat’s name and what it is about, one after another, with Next, Previous, Pause and Stop. Other languages are translated once and kept, so hearing the same briefing again costs nothing.`],fixed:[]},{version:`0.3.191`,date:`2026-09-30`,platforms:[`win32`],added:[`Scheduled shows at a glance what will still run: paused tasks and one-time tasks that have already run are greyed out, with the day they will be removed. They are deleted by themselves 10 days after their last change; resuming or editing a paused task gives it another 10 days.`],fixed:[]},{version:`0.3.190`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`A long message waiting in the queue no longer hides its “Send now” button: it is folded to a few lines, with Show all to read the rest.`]},{version:`0.3.189`,date:`2026-09-30`,platforms:[`linux`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window; “Move to main window” brings it back. On Wayland desktops the new window opens at the usual place rather than under the pointer. Your split views and windows come back when you restart OonaCode.`,`Every language plays in Listen to a chat: each language picks the best voice on its own — OonaCode’s Armenian voices first, then your system’s voices, then eSpeak (install the espeak-ng package if your system has no voice for a language).`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.188`,date:`2026-09-30`,platforms:[`win32`],added:[`Split views, like VS Code: drag a chat tab to the left, right, top or bottom of the chat area to open it beside the other one — a shaded area shows where it will land. Every chat on screen works on its own, with its own replies streaming and its own message box. Drag the divider to resize; Ctrl+\\ splits the current tab to the right, Ctrl+1, Ctrl+2… jump between views, and a tab’s menu has Split right, Split down and Move to other group.`,`Chats in windows of their own, like Chrome tabs: drag a tab out of the window, or choose “Move to new window” in its menu, and it opens in its own window. Drag it back onto the main window’s tabs, or choose “Move to main window”, to bring it back. Your split views and popped-out windows come back when you restart OonaCode.`],fixed:[]},{version:`0.3.187`,date:`2026-09-30`,platforms:[`win32`],added:[`Every language plays in Listen to a chat. Persian, Georgian, Ukrainian — and any language whose Windows voice is not installed — now speak with eSpeak, a free voice that comes with OonaCode (it sounds robotic, but it always works). Each language picks the best voice on its own: OonaCode’s Armenian voices first, then Windows’ own, then eSpeak.`],fixed:[`Picking another language for a summary no longer needs a new summary: Play translates the one you have, keeps the translation, shows it and plays it.`,`“Summarise now” says “Up to date — nothing to summarise” while the chat has not changed, instead of seeming to do nothing.`]},{version:`0.3.186`,date:`2026-09-30`,platforms:[`linux`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`,`OonaCode brings two Armenian voices of its own, Astgh and Artsiv, and also speaks with your system’s voices through speech-dispatcher — install speech-dispatcher and espeak-ng for Persian, Russian and every other language; the Listen window names the packages for your distribution.`,`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`,`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`,`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. Pin any chat or project to the top of the list from its menu.`,`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`,`Type / at the start of a message to see the chat’s commands and skills, with what each does, in two titled sections. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing; switch one on to let the model use it by itself in that chat. Typing /name still runs any skill for one turn.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`,`Search in the Import window: find a chat by its name, its first or last message or its folder, or pick “Whole conversations” to search inside the chats themselves.`],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from, with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once.`,`The message box fits a narrow chat: its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it.`,`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Only new replies change.`,`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model, /usage, /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`,`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message.`,`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`,`Typing /model in a chat updates the chat’s model and the model picker again, and command output such as /context reads the same while it arrives and after you reopen the chat.`,`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.185`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat from your phone: the OonaCode app’s 🔊 Listen reaches this PC’s summaries and plays them with the phone’s own voices. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`Listening with a Windows voice no longer stops after the first sentence when the voice fails to say it has finished.`]},{version:`0.3.184`,date:`2026-09-30`,platforms:[`win32`],added:[`Listen to a chat: right-click a chat → Listen to this chat…, or the speaker button beside the chat’s title. The chat’s own model writes a short spoken summary — the goal, what was done, where it stands, what is left — and OonaCode reads it aloud on this PC, in the voice and at the speed you choose. Every summary is kept with its date, so you can play it again at any time; a new one is written only when the chat has moved on. Other languages are translated once and kept with the summary.`],fixed:[`A chat’s “about” no longer starts in the middle of a sentence when the model wrote a long answer.`]},{version:`0.3.183`,date:`2026-09-30`,platforms:[`win32`],added:[`See where your credits go: Account → Usage. Pick the last 24 hours, 7, 30 or 90 days or your own dates, by hour or by day, for the coding agent or your API keys apart. A chart shows the credits over time by model or by what they were for, and the lists below give every model with its tokens and price, and every use — chat turns, a chat’s “about”, images, speech and the rest.`],fixed:[]},{version:`0.3.182`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Import chats shows every chat on this PC, grouped by the app it came from — Claude Code, the Claude app, Qwen Code, Cursor — with nothing folded away. Each row says whether it is new, already imported, moved on since, or deleted by you in OonaCode. Nothing is ticked when you open it yourself: search for a chat and tick it, or tick a whole group at once. The Import button says how many chats it will bring over.`]},{version:`0.3.181`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`The message box fits a narrow chat. In a small window, or with the side panels open, its buttons and pickers move onto a second line and the box grows to hold them — Stop and Queue no longer slip outside it, and the model and effort pickers keep their words readable.`]},{version:`0.3.180`,date:`2026-09-30`,platforms:[`win32`],added:[],fixed:[`Claude’s thoughts show their words again. Every “Thought” from Claude Opus, Sonnet and Fable came back empty — Anthropic leaves the text out unless it is asked for a summary, and now OonaCode asks. Other models were never affected. Only new replies change; older thoughts stay empty.`]},{version:`0.3.179`,date:`2026-09-29`,platforms:[`win32`],added:[],fixed:[`The / menu is easier to read: skills and commands in two titled sections, each with one short line — the full description shows when you point at it.`,`Commands that only duplicated OonaCode’s own controls or showed misleading numbers are gone from the / menu — /model (use the model picker), /usage (the engine’s own estimate, not your credits), /autocompact, /output-style, /mcp, /list-agents and /reload-skills. Typed, they say why.`,`Skills you import or remove in Settings → Skills reach your chats by themselves, at each chat’s next message.`]},{version:`0.3.178`,date:`2026-09-29`,platforms:[`win32`],added:[`The chat list is laid out like the Claude desktop app: New, Projects, Scheduled, then your pinned chats and projects, then Today and Older. The old grouping by project is one click away — the small icon beside “Today”.`,`Projects opens a page of project cards — each with its goal, its chats and when it was last used — with search, sort and New project. Click a card to see that project’s chats, instructions and settings, and to start a new chat in it.`,`Scheduled shows every scheduled task from every chat on this PC in one place, with its next run, its chat, and pause, resume and delete. A dot on it tells you when something is due soon.`,`Pin any chat or project to the top of the list from its menu.`],fixed:[`A chat row’s ⋯ button shows only when you point at the row.`]},{version:`0.3.177`,date:`2026-09-29`,platforms:[`win32`],added:[`Claude Sonnet 5.5 is in the model picker — on the OonaCode pool and on your own Claude subscription — with a 1M-token context. It costs the same as Sonnet 5 per token and usually needs fewer tokens for the same work.`],fixed:[`Claude Sonnet 5 is retired: a chat that was on it moves to Sonnet 5.5 at its next message, and the picker shows Sonnet 5.5.`]},{version:`0.3.176`,date:`2026-09-29`,platforms:[`win32`],added:[`Each chat has a Skills list beside Tools. Every skill starts off, so the model sees none of them and they cost nothing — about 1,400 tokens on every message until now. Switch one on to let the model use it by itself in that chat; the list shows what each one costs per message while on.`,`Typing /name still runs any skill for one turn, whether its switch is on or off.`],fixed:[`The engine’s built-in keyboard-shortcuts helper is turned off: it would have edited your own Claude Code settings.`]},{version:`0.3.175`,date:`2026-09-29`,platforms:[`win32`],added:[`Type / at the start of a message to see the chat’s commands and skills — the Claude Code engine’s own (/compact, /context, /review, /security-review, /init and more) and the skills in your project’s .claude folder — with what each does. Type to narrow the list, then Enter or Tab. They work with every model, not only Claude.`,`Your own skills: Settings → Skills lists the skills OonaCode gives every chat, and “Import from Claude Code…” copies the ones you choose from your Claude Code install — it only reads it, never changes it.`,`In the terminal app (oona), a command the chat’s engine knows — /context, /compact or a skill — now runs instead of answering “unknown command”.`],fixed:[`Typing /model in a chat updates the chat’s model and the model picker again.`,`Command output such as /context reads the same while it arrives and after you reopen the chat.`]},{version:`0.3.174`,date:`2026-09-28`,platforms:[`win32`],added:[`Search in the Import window. Type to find a chat by its name, its first or last message, or its folder — chats folded away as already imported or deleted here show up too when they match. Or open the search options and pick “Whole conversations” to search inside the chats themselves, with a few lines of each match under the chat. It only reads Claude Code, Cursor and the Claude app’s files, never changes them.`],fixed:[`Chats Claude Code switched to another model are answered by that model for real: OonaCode’s pool now serves the model the engine falls back to, and never answers a Claude request with another company’s model.`]},{version:`0.3.173`,date:`2026-09-28`,platforms:[`linux`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`,`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`,`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`,`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`,`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`,`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`A chat can no longer be moved into your home folder or the root folder through a link. Where /home is itself a link (Fedora Silverblue, Bazzite and similar systems), the home folder passed as an ordinary folder, and the chat would have loaded your own Claude Code settings as its project.`,`Signing in to your own Claude subscription inside the app works on Ubuntu 24.04, Debian, Linux Mint, Pop!_OS and Zorin OS again. There, a part of OonaCode built for newer systems did not load, and the sign-in fell back to a command you had to paste.`,"On Ubuntu, Linux Mint, Pop!_OS, Zorin OS and similar systems, `oona` now works in every new terminal right after you install or update. The installer used to leave it off your PATH until you logged out and back in; now it adds it for new terminals itself, and `oona uninstall` takes that line out again.",`Every way of uninstalling — “oona uninstall”, or the install command with --uninstall — now takes this PC off your account: keep your chats and they stay readable on your other devices; delete them and their copies go too. It never touches your Claude Code or the Claude app, and “oona uninstall” no longer gives up when the background service is stopped.`,`The installer now says at once when a system cannot run OonaCode — one older than Ubuntu 22.04, Debian 12 or RHEL 9, or one built on musl such as Alpine — instead of installing a copy that could not start. The .deb and .rpm tell apt and dnf the same.`]},{version:`0.3.172`,date:`2026-09-28`,platforms:[`win32`],added:[`When Anthropic’s safeguards flag a chat and Claude Code moves it to another model for the rest of the run, the model box says so in red — for example “Opus 4.8 (safeguard)” — and the chat shows a notice at the switch. Picking a model takes the chat back to it at the next message.`],fixed:[`Uninstalling from Settings → Apps now also takes this PC off your account, exactly like “oona uninstall”: keep your chats and they stay readable on your other devices; delete them and their copies go too.`,`“oona uninstall” no longer gives up when the background service is stopped.`,`The “Updating OonaCode…” window shows again on the newest Windows 11 versions (24H2 and later).`]},{version:`0.3.171`,date:`2026-09-28`,platforms:[`win32`],added:[`Oonak Browser now picks its own control port from a range no developer tool uses by default, so it can no longer take a port that Shopify CLI or a dev server wants. If a program needs a particular port kept free, or you want the browser on a specific one, just ask the chat.`],fixed:[`File and folder names in a reply get their ▶, Open and Show in folder buttons only when they really exist on this PC. A bare file name is also looked for in the folder the reply named just before it.`,`Uninstalling OonaCode from Settings → Apps now removes all of it — the app, the command line and its background service — and asks whether to keep your chats. Installing again afterwards no longer says it is already installed. Your Claude Code and Claude app are never touched.`,`“oona uninstall” works again on Windows 11.`,`A chat “about” you wrote yourself no longer shows “stale”.`]},{version:`0.3.170`,date:`2026-09-28`,platforms:[`win32`],added:[`Your phone can now do from anywhere what this PC’s window does: switch each tool on or off per chat, see and control the conversations between your chats, read, edit and regenerate each chat’s “about”, and manage scheduled tasks. It needs this update on the PC and the next OonaCode app on the phone.`],fixed:[`“Send now” stays disabled and says “Sending now…” until the agent has taken the message — it can take a few seconds while the agent stops its current step, and a second press can no longer send it twice.`,`A message sent from your phone is confirmed by this PC, and the same message is never run twice when the phone sends it again after a lost connection.`]},{version:`0.3.169`,date:`2026-09-28`,platforms:[`win32`],added:[`Every chat now has an “about”: a short note, written in the background by a cheap helper model of the chat’s own provider, saying what the chat works on. Your other chats read it — with each chat’s folder and when it was last active — when they look for the right chat to ask. See it, edit it or press Regenerate in the session info panel.`,`View → What chats are about… (and a sidebar button) lists every chat’s about and what writing them cost, with a switch to turn it off and “Generate for all chats now”. The switch and its numbers are also in Settings → This PC.`],fixed:[`A chat can no longer be moved into your user folder or a drive root through a link or junction that points there — its project settings would have been your own Claude Code settings.`]},{version:`0.3.167`,date:`2026-09-27`,platforms:[`win32`],added:[`A chat can switch its own workspace. When the work belongs in another folder — a project you name that lives elsewhere, or a new project folder — the model proposes the switch and you answer Switch or Not now. It always asks you, even with “accept automatically” on, and the chat moves when its current step ends, with the conversation kept.`],fixed:[]},{version:`0.3.166`,date:`2026-09-27`,platforms:[`win32`],added:[],fixed:[`Typing in the message box while a chat is replying is no longer interrupted. With “accept automatically” on, an approval card flashed for an instant on some tool calls and took the cursor away from the box.`,`A permission card that appears while you are typing no longer takes the keyboard, so your next Space or Enter can never press Allow by accident.`]},{version:`0.3.165`,date:`2026-09-27`,platforms:[`win32`],added:[`Right-click a chat tab → Delete (in red, under “Close all tabs”) deletes that chat after asking, just like Delete in the sidebar.`,`Chats now use Oonak Browser, in a window you can see, for everything that needs a web browser — not Chrome, Edge or a hidden script browser — unless you name another browser. It runs without a window (headless) only when you ask for that.`],fixed:[`After an update, the background service comes back by itself. An update could leave it unable to restart, and the app then showed “OonaCode could not start its host service” even though it went on to open normally.`]},{version:`0.3.164`,date:`2026-09-27`,platforms:[`win32`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when OonaCode’s stored key cannot be opened for a moment. OonaCode used to replace the key and lose your sign-in; it now keeps the key and signs you back in by itself as soon as it opens.`]},{version:`0.3.163`,date:`2026-09-27`,platforms:[`linux`],added:[`Send now: a message you typed while the agent works has a Send now button while it waits. It stops what the agent is doing right now and sends your message immediately — the step that is running is cut. On the desktop and the phone.`,`Conversations → Map: see at a glance which chats are talking to each other. Each conversation is a hub with a line to each of its chats; working chats pulse; click a hub for its history or a chat to open it.`],fixed:[`A restart no longer signs this PC out when its security chip is slow to open OonaCode’s stored key. After a system update and reboot, the chip on some machines refuses for a while; OonaCode used to replace the key and lose your sign-in. It now keeps the key and signs you back in by itself as soon as the chip opens it.`]},{version:`0.3.162`,date:`2026-09-27`,added:[],fixed:[`A chat switched to another model knows which model it is. After a switch from Claude to DeepSeek, the model used to keep saying it was Claude — the chat history and Claude Code’s own prompt told it so.`,`Oonak Browser is offered only where it can run. An older OonaCode no longer lists a browser tool it cannot use, so the model does not spend tokens working around it — update to get the browser.`]},{version:`0.3.161`,date:`2026-09-27`,added:[`Settings → This PC → “Replace pictures older than N days”: screenshots and pasted pictures in your chat history are replaced by a short note once they are older than a year (you choose the number, or 0 to keep them). The words of every chat stay; the database stops growing with pictures. It runs by itself.`],fixed:[`The model, Build/Plan/Ask and effort pickers under the message box now look like the dropdowns they are.`,`Switches that are off are easy to see in dark mode.`,`Error messages show what went wrong in words, without raw tags or a provider’s JSON.`,`The ✕ that removes an attachment or a reply is round.`,`Pressing Stop, or an update cutting a turn, no longer files an automatic bug report.`]},{version:`0.3.160`,date:`2026-09-27`,added:[`On Windows, the agent can use a real browser. Ask it to open a site, read a page, click, fill in a form or take a screenshot, and it does it in Oonak Browser, in a window you can see. The first time, OonaCode asks once to install the browser (about 210 MB); after that it opens straight away.`,`Each chat has its own browser profile, so a site you sign in to stays signed in for that chat. Switch the browser off for a chat in its Tools menu.`],fixed:[]},{version:`0.3.159`,date:`2026-09-27`,added:[],fixed:[`A chat reopened after an update no longer says “turn complete” the instant you send a message and then answer anyway. The engine’s own note about work that stopped during the update used to be taken for the end of your turn, with the whole earlier conversation’s tokens on the line.`,`A background task that stopped because OonaCode restarted now says so in plain words, instead of “Orphaned by a previous Claude Code process exit”.`]},{version:`0.3.158`,date:`2026-09-27`,added:[`Every thought in a chat shows how many words it has, so you can tell at a glance whether there is anything to read.`],fixed:[`A thought with nothing in it — some models return only a signature for their thinking — now says “Thought · empty” and no longer opens onto a blank box.`,`A command the agent was allowed to run no longer leaves an “Allowed Bash (automatically)” line under its own card: the card already shows the command and its result. Refusals are still shown.`]},{version:`0.3.157`,date:`2026-09-27`,added:[`On Linux, OonaCode has its own signed apt and dnf repositories. Install the app with apt (Debian, Ubuntu, Mint) or dnf (Fedora, RHEL, Rocky, Alma) — the commands are on the download page — and your package manager keeps it up to date with the rest of the system.`,`Every Linux release is signed with the OonaCode release key, and the one-line installer checks that signature before it installs anything.`],fixed:[`On Linux, the menu bar is drawn in the window in the app’s own colours, and it switches between light and dark with the app instead of keeping the desktop’s theme until a restart.`,`Upgrading the .rpm no longer removes the oonacode command, and removing it no longer leaves empty folders behind.`]},{version:`0.3.156`,date:`2026-09-27`,added:[`Chats can talk to each other. Turn on “Talk to other chats” in a chat’s Tools menu, and its agent can find your other chats that have it on, read them, and ask them for help — one chat or a whole group. A chat that is closed wakes up to answer; a busy one answers when it finishes. The reply comes back to the chat that asked.`,`The Conversations window (in the sidebar) shows every conversation between your chats: who said what to whom, what each answer cost, and buttons to pause, resume, close or stop them all. Each conversation has a budget — 20 messages and 1,000,000 new tokens by default — and pauses itself when it is used up, so chats can never talk forever.`,`Hover over any tool in a chat’s Tools menu to read what it does, how it works, what it costs and how to turn it off.`],fixed:[`A chat woken in the background — by a scheduled task or another chat — shows as working in the sidebar even when it is not open in a tab.`,`A scheduled task no longer slips into a chat at the same moment you send it a message; yours always goes first.`,`A message sent from the terminal no longer waits forever when a chat’s history cannot be resumed and the restart fails. It now says why.`,`Notes OonaCode writes into a chat — a model change, a conversation paused — are still there when you reopen it.`,`When every Claude seat in the OonaCode pool is taken, a new chat now says the model is busy and to try again in a few minutes or pick another model, instead of “Something went wrong on our side”.`,`On Linux, the app tells you it is updating while it swaps itself, so there is no need to start it again.`,`On Linux, removing the .deb or .rpm leaves nothing running and nothing failing at the next login, and the one-line installer checks for free disk space before it changes anything.`]},{version:`0.3.155`,date:`2026-09-27`,added:[`OonaCode runs on Linux. One command installs the command line, the background service and the desktop app: curl -fsSL https://oonacode.oonak.ai/install.sh | bash. The AppImage, .deb and .rpm are on the download page too.`,`On Linux the app lives in the system tray as it does on Windows, follows your desktop’s light or dark theme, and gets its own entry in the applications menu.`,`Uninstalling on Linux removes the desktop app along with the rest, and asks whether to keep your chats for a future install.`],fixed:[`A window no longer stays on “Unauthorized” after the background service restarts with a new key. It reconnects by itself.`]},{version:`0.3.154`,date:`2026-09-26`,added:[],fixed:[`A chat waiting on a long job no longer loses its watcher. OonaCode used to close a chat’s engine ten minutes after the model last spoke, which stopped any Monitor or background command it had left running. The engine now stays up while such work runs, up to 12 hours.`,`A chat moved into a project, or whose project you edit, now follows the project’s instructions from its next message. It used to keep the ones it started with.`]},{version:`0.3.153`,date:`2026-09-25`,added:[],fixed:[`A very long chat no longer answers “Prompt is too long” after OonaCode restarts or updates. The engine was judging the chat’s size by a figure left over from before the restart, and now gets an accurate one.`,`If a message is ever refused as too long before the model has started on it, OonaCode sends it again by itself with a shorter history. You see your message once and then the answer, not an error.`]},{version:`0.3.152`,date:`2026-09-25`,added:[],fixed:[`Uninstalling the app from Windows’ Apps list no longer stops the command-line OonaCode on the same PC from starting after a restart.`]},{version:`0.3.151`,date:`2026-09-25`,added:[`Files the agent names in a chat are clickable. Audio and video play right in the chat with a small player, pictures open as a preview, and in the app every file can be opened in its own program or shown in its folder.`,`Uninstalling the app asks whether to keep your chats on this PC. Keeping them means a new install signs in and continues every chat.`],fixed:[`Installing and updating no longer fail with “The operation has timed out” on PCs whose network drops the newer internet addresses, nor while our server restarts for an update.`]},{version:`0.3.150`,date:`2026-09-25`,added:[],fixed:[`The fix in 0.3.149 for long, sleeping turns now really reaches the agent: the Monitor tool and the block on long waits are on for every chat.`,`A chat compacted after a long pause no longer pays to cache a conversation it is about to replace, and the agent keeps each tool call in its history exactly as it wrote it — both as Claude Code does.`]},{version:`0.3.149`,date:`2026-09-25`,added:[`The agent can watch a long job with the Monitor tool, as Claude Code does, and is woken the moment the job finishes.`],fixed:[`Long chats no longer spend their time asleep. With no way to watch a background job, the agent had been polling it with waits of four to eight minutes. One chat spent more than three and a half hours of a day sleeping, and turns ran for hours while the model worked for a fraction of that. The agent now gets the same working rules as Claude Code, and long waits are blocked.`]},{version:`0.3.148`,date:`2026-09-25`,added:[],fixed:[`A scheduled task that could not be sent — the PC had just restarted, the vault was still locked, the server was not reachable yet — waits and tries again instead of switching itself off. Pausing, editing or deleting a task while its prompt is being sent is no longer undone, and a scheduled prompt no longer lands in a chat whose engine is still starting.`,`A chat on your own DeepSeek key, or one switched with a typed “/model opus”, is no longer shown as withdrawn and locked. “/model fable” picks Claude Fable instead of the default model.`,`Moving a chat to another model no longer lowers its saved effort level to what the old model offered, and a one-off “oona --effort” is no longer saved as the chat’s level.`,`After you pick another model for a locked chat and send, the chat no longer flashes the lock again while the engine starts; if the start fails, your pick is kept.`,`Coming back from a file tab no longer jumps the chat to an old reply or reopens the search bar.`,`The hidden sidebar slides away again when the pointer leaves the window past its edge, and the keyboard no longer tabs through it while it is hidden. Clicking ⓘ in Settings opens its note instead of closing it.`,`Subagents write their prompt cache for five minutes, as Claude Code does for its subscribers; the chat itself keeps the hour. Their cache writes cost less.`]},{version:`0.3.147`,date:`2026-09-25`,added:[`A chat’s scheduled tasks sit beside its subagents: a clock badge says how many are live and when the next one runs, and opens the list — each task’s schedule, its next and last run, Pause and Delete. The tasks run on this PC.`],fixed:[`A prompt the scheduler sends into a chat reads as a “Scheduled task” line, not as your own message waiting in the queue.`,`A chat whose model is no longer offered shows that model in red and waits for you to pick another; its history stays, and the old model is not in the list any more.`,`The effort list follows the server within minutes, without restarting the app. A chat set to a level that has been switched off moves to the nearest one — ultracode becomes xhigh. Chats on your own Claude subscription have an effort picker again.`]},{version:`0.3.146`,date:`2026-09-25`,added:[`A Tools menu beside the model picker: switch OonaCode’s own tools on or off for each chat — browser, desktop and window control, clipboard, screen capture, Office documents and run-as-administrator. Each tool costs the model only a short line until it is used, and the menu shows how much. The first tools are marked Demo while they are tested with every model: a demo tool answers what it would have done, and does nothing on your PC yet.`],fixed:[]},{version:`0.3.145`,date:`2026-09-25`,added:[],fixed:[`Every request of every chat, on every model, is about 3,200 tokens smaller: the engine’s own “auto memory” instructions are gone. OonaCode starts each engine in a fresh private folder and deletes it afterwards, so the notes the model was told to keep there were thrown away when the chat went idle — the model spent tool calls writing memories it would never read. A project’s memory is OonaCode’s own and stays.`,`The engine’s claude.ai Artifact tools are switched off everywhere OonaCode runs it — the app, the terminal, VS Code, the phone, Telegram and the agent API.`]},{version:`0.3.144`,date:`2026-09-25`,added:[],fixed:[`Long chats on Claude models in the OonaCode pool keep their cache for an hour, as Claude Code does for its subscribers. A pause of more than five minutes no longer re-sends the whole conversation at the full cache-write price, which in a large chat was the most expensive part of coming back to it.`,`The session panel’s Context shows how big the conversation is now, not the total of every request the chat ever made — a long chat read “10.7M / 1.0M tokens”.`,`The message box keeps the cursor after you send, so you can go straight on typing the next message.`,`A paid chat’s background work (titles, reading web pages) no longer goes to a free model of the same vendor.`]},{version:`0.3.143`,date:`2026-09-24`,added:[`Search inside your chats: open the search in the chat list, press the sliders button and choose Whole chats. It looks through every message of every chat on this PC, and you choose whose words — yours, the model’s, or both — plus, if you like, the tools’ commands and output and the subagents’ conversations. Results show each message with the words lit; a click opens the chat with its search on them.`,`More search options, for both kinds of search: one project only, a time window (today, 7 or 30 days), match case and whole words.`],fixed:[`While you search the chat list, projects with no matching chat are hidden too.`]},{version:`0.3.142`,date:`2026-09-24`,added:[],fixed:[`A reply you sent shows as the same small chip it had in the message box — “Reply to” and the first few words — instead of the whole quoted text; the full quote appears when you rest the pointer on it, and a click jumps to the message it answers.`,`The model now knows a reply points back into the conversation: it is told the quoted lines are from the chat history, not new input, and whose words they were — its own earlier reply, your earlier message, a file, or a tool’s output.`,`When the chat list is narrow, its buttons wrap onto a second line instead of spilling out of it.`]},{version:`0.3.141`,date:`2026-09-24`,added:[`The chat list on the left can be made wider or narrower: drag its right edge (double-click it for the usual width).`,`The chat list can hide: press the pin in its header, the button at the top left, or View → Sidebar (Ctrl+B). While hidden it slides in when the pointer reaches the left edge of the window, and slides away when you leave it.`,`Search in the chat list is a single magnifier now; click it and the search box opens across the top. Escape or × clears it.`],fixed:[`Opening OonaCode right after a restart no longer leaves the OonaCode pool models out of the model list: if they cannot be read yet, OonaCode asks again by itself a few seconds later and the list fills in.`,`The Artificial Analysis scores (intelligence, coding, speed and benchmarks) show on every model in the model list again — including the models of your own Claude and SuperGrok subscriptions, which never had them.`,`A chat’s details card no longer appears on top of its right-click menu.`]},{version:`0.3.140`,date:`2026-09-24`,added:[`Reply is tidier: the message you reply to shows as a small chip above the message box with its first few words, instead of filling the box. Click the chip — or the quote in a sent reply — to jump to that message; the × removes it.`,`Right-click a project in the sidebar for its settings: Project settings… opens Projects with that project already selected. The gear beside a project’s “+” does the same, and a chat filed in a project offers it in its own menu too.`,`Link GitHub. Under a project’s Repositories (and in Settings → Providers), link your GitHub account once: the agent’s git and gh then clone, pull and push your private repositories on every PC of yours. You type a short code on github.com; the token stays in your encrypted vault and never reaches the OonaCode server. Public repositories need nothing.`],fixed:[]},{version:`0.3.139`,date:`2026-09-24`,added:[`Every setting now says what it does, and resting the pointer on the ⓘ beside it tells you where in OonaCode it applies and what it does not do.`,`Export chats… is in the File menu (and on the sidebar in a browser window) instead of in Settings.`,`With Remote access turned off on a PC, your phone, Telegram, the website and your other PCs still show it — online or not — marked “remote access off”, and opening it tells you to turn Remote access back on in OonaCode on that PC.`],fixed:[`Turning Remote access off now tells your other devices at once. Before, the PC was already unreachable from them, but they could not say why.`,`The settings of This PC save the moment you change them — nothing is lost by closing the dialog.`,`Settings that did nothing, or repeated another one, are gone: the default permission mode (each chat’s Build / Plan / Ask first picker decides), the agent-picker switch, the Git Bash path, the engine path and the extra allowed origins. The server address is shown, not edited — signing in sets it.`]},{version:`0.3.138`,date:`2026-09-24`,added:[`Projects have settings now, like the Claude app’s: a goal, the repositories the project works on, what a new chat in it starts on (model, effort and folder), a project memory the agent keeps up to date, and whether its chats may schedule work — and how often at most. All of it is in Projects, and a Claude app project you import brings its own.`,`OonaCode has a scheduler. Ask the agent to do something later or on a repeat — “check the build every morning at nine” — and it schedules it on this PC; when it is due, the prompt arrives in the chat, even if the chat had gone quiet. The Projects dialog and the chat’s info panel list what is scheduled, where you can pause, resume or delete it.`],fixed:[`Saving a project’s instructions now reaches its chats at their next message, instead of waiting until the chat happened to restart.`]},{version:`0.3.137`,date:`2026-09-24`,added:[],fixed:[`After a PC restart the app could ask for a "host token" and sign you out: two copies of the OonaCode background service started at once and fought over your session. Only one ever runs now, and the app never shows the token page — if its service is replaced it reconnects by itself.`,`The unlock screen stays put until you unlock, and says what went wrong in place — a wrong password, or a connection it is re-establishing — instead of jumping to another page.`,`A message with a picture sent while the agent was working stayed “queued”, and removing it said it was already sent. It now shows as read the moment the agent takes it, and a reopened chat shows it with its picture.`,`In the model’s questions, typing your own answer now clears the options you had picked, and picking an option clears what you typed — the answer sent is exactly the one you chose. The same on the phone, in the terminal and in Telegram.`]},{version:`0.3.136`,date:`2026-09-24`,added:[`Every model now has its own housekeeper — the small, fast model of the same maker that writes a chat’s titles and reads the web pages it fetches. On the OonaCode pool a MiMo v2.6 Pro chat uses MiMo v2.6 Flash, a Qwen chat Qwen3.8 Flash, a GLM chat GLM-5.3 Flash and a GPT-5 chat GPT-5 mini, instead of doing that work on the big model itself. A free model keeps its own, so it stays free.`],fixed:[]},{version:`0.3.135`,date:`2026-09-24`,added:[],fixed:[`Claude models on the OonaCode pool — Opus 5.5, Opus 5, Sonnet 5 and Fable 5.1 — now use their whole 1M context. A long chat no longer stops to summarise itself every ~170k tokens, and its subagents get the same window.`,`Reading a web page is quick again in a Claude chat: pages are read by Claude Haiku, as in Claude Code, instead of a helper that took about a minute a page.`,`Changing a chat’s model now moves its subagents and background helpers to the new model too; before, they stayed on the old one until the app restarted.`,`MiMo v2.5 and v2.5 Pro chats now use their full 1M context too.`]},{version:`0.3.134`,date:`2026-09-23`,added:[],fixed:[`On the Android app, the model’s questions can be answered again. They come one at a time — “Question 2 of 3” — with Back, Next and Skip, and Answer sends them to your PC. The card used to show only the first question, hide the rest below it and wait for all of them, so it could not be sent.`]},{version:`0.3.133`,date:`2026-09-23`,added:[`Bring your Claude desktop app projects across: File → Import chats from other coding agents now lists every project the Claude app has opened on this PC. Each one arrives as an OonaCode project of the same name — its goal, instructions and what Claude noted about it become the project’s instructions — with its project chat and one chat per thread filed under it, ready to carry on.`,`A Claude Code chat you moved into a Claude app project is filed under that project here too.`,`A thread you never opened in the Claude app still comes across, with its task and every reply the project chat saw; open it once in the Claude app and import again for its whole conversation.`],fixed:[`Cursor chats appear in the import list again — they had been left out since September 10.`]},{version:`0.3.132`,date:`2026-09-23`,added:[`Reply to any part of a chat: select some text (or just right-click a block), choose Reply, and it is quoted in your message box — type your answer under it. A quote from a file the agent read names the file.`,`Right-click in a chat: copy what you selected, copy a whole reply or tool output, copy a code block or a link, find the selected words in the chat, or select a block.`,`Search in a chat opens the block its match is in — a folded tool card, a thought, a finished agent’s work — and scrolls to the words themselves.`,`Search matches are now bright orange, the current one strongest, so they stand out on code too.`,`The file viewer shows pictures (PNG, JPEG, GIF, WebP, SVG and more), plays audio and video, and shows Markdown formatted, with a switch to the source.`,`Right-click a file or folder in the explorer to copy its path or delete it.`],fixed:[`Moving a chat to another folder or project while it was working could delete the folder it was working in, start two agents at once, or send your next message to the old folder.`,`The working line no longer says a chat may be stuck while it waits for your approval or answer, or right after you send a message, and it counts time correctly (no more "4m 60s").`,`A date line no longer says "Today" for yesterday’s messages when the app stays open past midnight.`,"Installing with npm (`npm i -g oonacode`) installs this version again; earlier npm releases carried an old program.",`The What’s new window could open again on the next start, showing the same update a second time.`,`An older OonaCode window or VS Code extension no longer resets settings it does not know about, such as your theme colours or which project groups you folded.`,`A new install no longer opens with a list of changes; this window now appears only after an update.`,`The notification switch for permissions now says it also covers the agent’s questions.`]},{version:`0.3.131`,date:`2026-09-23`,added:[`Claude Opus 5.5 is here — the newest Opus, and cheaper to run than Opus 5. Choose it in the model picker, from the OonaCode pool or on your own Claude subscription. It runs on the newer Claude Code engine (2.1.280) that this update brings.`,`Every block in a chat shows its time at the bottom right, in your local time — hover it for the full date — and a date line marks where each day starts.`,`A running chat tells you how long the agent has been quiet, and after five minutes that it may be stuck and what to do.`,`After every update, OonaCode now opens this window to show you what changed.`],fixed:[`A reply that streamed in live had no time on it until the chat was opened again.`,`Chats open in tabs could fail to come back after a restart if a setting changed while they were being restored.`]}];function Qc(e,t){let n=e=>{let[t,...n]=e.trim().replace(/^v/,``).split(`-`);return{nums:(t??``).split(`.`).map(e=>Number.parseInt(e,10)||0),pre:n.length>0?n.join(`-`):null}},r=n(e),i=n(t);for(let e=0;e<Math.max(r.nums.length,i.nums.length);e++){let t=(r.nums[e]??0)-(i.nums[e]??0);if(t!==0)return t}return r.pre===i.pre?0:r.pre===null?1:i.pre===null?-1:$c(r.pre,i.pre)}function $c(e,t){let n=e.split(`.`),r=t.split(`.`);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e],i=r[e];if(t===i)continue;if(t===void 0)return-1;if(i===void 0)return 1;let a=/^\d+$/.test(t),o=/^\d+$/.test(i);if(a&&o){let e=Number(t)-Number(i);if(e!==0)return e;continue}return a===o?t<i?-1:1:a?-1:1}return 0}function el(e,t,n=Zc,r=null){if(!e||e===`0.0.0`)return[];let i=n.filter(t=>Qc(t.version,e)<=0&&(!r||!t.platforms||t.platforms.includes(r)));return[...t===null?i.filter(t=>Qc(t.version,e)===0):i.filter(e=>Qc(e.version,t)>0)].sort((e,t)=>Qc(t.version,e.version))}function tl(e,t,n,r=Zc,i=null){if(!e||e===`0.0.0`)return{record:null,show:[]};let a=null;for(let e of r)(a===null||Qc(e.version,a)>0)&&(a=e.version);let o=a!==null&&Qc(e,a)>0?a:e;return{record:t===null||Qc(o,t)>0?o:null,show:t===null&&!n?[]:el(e,t,r,i)}}function nl(e,t){if(t==null)return[...e];if(t.length===0)return[];let n=new Set(t),r=e.filter(e=>n.has(e.id));return r.length>0?r:[...e]}var rl=`:free`;function il(e){return e.endsWith(rl)}function al(e){return il(e)?e.slice(0,-5):e}var ol=`the user skipped the question`,sl=`(the user skipped this question)`;function cl(e){let t=e?.questions;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;if(typeof t.question!=`string`)continue;let r=Array.isArray(t.options)?t.options.map(e=>e&&typeof e==`object`?e:null).filter(e=>e!==null&&typeof e.label==`string`).map(e=>({label:e.label,...typeof e.description==`string`?{description:e.description}:{}})):[];n.push({question:t.question,header:typeof t.header==`string`?t.header:``,options:r,multiSelect:t.multiSelect===!0})}return n}function ll(e,t,n={},r=new Set){let i={};return e.forEach((e,a)=>{if(r.has(a)){i[e.question]=sl;return}let o=(n[a]??``).trim();i[e.question]=o||(t[a]??[]).join(`, `)}),i}function ul(e){let t=e.questions,n=t===1?`question`:`questions`,r=t===1?`the model’s question`:`the model’s questions`,i=t===1?`The model’s question was`:`The model’s questions were`;switch(e.outcome){case`answered`:{let r=e.answers?Object.values(e.answers):null,i=r?r.filter(e=>typeof e==`string`&&e!==``&&e!==`(the user skipped this question)`).length:t;return t>0&&i<t?`You answered ${i} of ${t} ${n}`:t===0?`You answered the model’s questions`:t===1?`You answered the model’s question`:`You answered ${t} ${n}`}case`skipped`:return`You skipped ${r}`;case`dismissed`:return`${i} dismissed`;case`unanswered`:return`${i} not answered — the turn ended`}}function dl(e){if(!e||typeof e!=`object`)return null;let t=e.answers;return t&&typeof t==`object`&&!Array.isArray(t)?t:null}var fl=[`win32`,`linux`,`darwin`],pl=[`demo`,`live`],ml=[`allow`,`ask`],hl=[`string`,`number`,`integer`,`boolean`,`array`,`object`];function gl(e){let t=e/1048576;return t>=100?`${Math.round(t)} MB`:t>=1?`${t.toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function _l(e){if(e.toolName!==`InstallToolPack`)return null;let t=e.input;return!t||typeof t!=`object`||typeof t.pack!=`string`||typeof t.name!=`string`||typeof t.version!=`string`||typeof t.sizeBytes!=`number`||typeof t.path!=`string`?null:{pack:t.pack,name:t.name,version:t.version,sizeBytes:t.sizeBytes,path:t.path}}function vl(e,t){let n=t?.[e.slug];return typeof n==`boolean`?n:e.defaultOn}function yl(e,t){return e.filter(e=>vl(e,t))}var bl={slug:48,name:80,entryTool:40,description:2e3,promptLine:1e3,details:8e3,actionDescription:1e3,params:30,paramName:48,paramDescription:400,enumValues:40,callArgKeys:20,callError:500,callBatch:100},xl=/^[A-Za-z0-9_-]+$/;function Sl(e){return typeof e==`string`&&e.length>0&&e.length<=bl.entryTool&&xl.test(e)}function Cl(e){return Math.ceil(e.length/4)}function wl(e){return Cl(`${e.entryTool} ${e.description}`)+55}function Tl(e){return e.tokensPerRequest??wl(e)+(e.promptLine?Cl(e.promptLine):0)}var El=Uo({type:$o(hl),required:Fo().optional(),enum:Vo(Go([H(),jo()])).optional(),description:H().optional()}),Dl=Uo({slug:H().min(1),description:H(),params:Zo(H(),El),permission:$o(ml),sort:jo()}),Ol=Uo({version:H(),url:H(),sha256:H(),sizeBytes:jo(),exe:H(),format:ts(`zip`)}),kl=Uo({slug:H().min(1),name:H(),entryTool:H().refine(Sl,`not a valid tool name`),description:H(),promptLine:H().nullable(),details:H().nullable().optional(),status:$o(pl),defaultOn:Fo(),sort:jo(),install:Ol.nullable(),actions:Vo(Dl)}).loose();Uo({platform:$o(fl),version:H(),packs:Vo(kl),refreshMinutes:jo()});var Al=[`No answer needed.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. Your final answer goes back to that chat by itself.`,`"Talk to other chats" is off in this chat: this message is from another chat's agent, not the person, and you cannot message chats. It asked for no answer, so nothing goes back.`,`Last hop of this chain: you cannot message chats in this turn; put what you have in your final answer.`];[`**Let this chat work together with your other chats.**`,``,`### What it does`,`- Finds your other chats on this PC and reads their recent messages.`,`- Sends one chat, or a group of chats, a message or a task.`,`- Brings their answers back to this chat, by itself.`,``,`### How it works`,`- A chat that is asleep is woken from its saved history. A busy one gets the message when its current turn ends, never in the middle of it.`,`- The other chat does the work with its own model, folder and tools. Its answer comes back here as a new message only when this chat asked for one.`,`- Several messages from one chat that wait for a busy chat are handed over together, in one turn, with one answer.`,`- Several chats can share one conversation (a group). An answer goes only to the chat that asked, so a group cannot multiply its own messages.`,`- A chat with this switch OFF can still be messaged by a chat that has it on. It does the work, and its final answer goes back to that chat when that chat asked for one. That is all it can do: it gets none of these tools, cannot message or read other chats, and its switch stays off.`,``,`### What it costs`,`- About 650 tokens on every request while it is on, read from the prompt cache. Nothing while it is off, even in a chat that is messaged.`,`- Every message makes the chat that receives it do a turn, which spends its own tokens.`,`- Switching it on or off in a chat that already has a conversation re-writes its prompt cache once.`,``,`### Safety limits`,`- Each conversation has a budget: 20 delivered messages and 1,000,000 new tokens by default (context read back from the prompt cache is not counted). Reaching either pauses the conversation, and the chats say so.`,`- A chain stops after 3 hops (a message caused by a message caused by a message).`,`- At most 5 messages between two chats and 20 from one chat in 10 minutes, and 10 waiting for any one chat. A chat cannot message itself.`,`- A conversation with no activity for 24 hours closes by itself.`,``,`### How to stop it`,`- Turn this switch off: the chat loses these tools, and what it sent and the answers it asked for pause. It still answers a chat that messages it.`,`- Or open the Conversations window and use Pause, Close or Stop all.`,``,`### Privacy`,`- Everything stays on your PC: the messages are kept in this PC's database, never on OonaCode's server.`,`- A message never grants anything. The other chat runs with its own permissions and asks you as usual.`,``,`Only a chat with this switch on can start a conversation; a chat with it off only answers.`].join(`
|
|
78
78
|
`);var jl={hops:3,rateWindowMs:6e5,perPair:5,perSender:20,pendingPerTarget:10,idleCloseMs:864e5,messageChars:2e4,titleChars:80,conversationTitleChars:120,recipients:10,listChats:50,readMessages:50,budgetMessagesMax:1e4,budgetTokensMax:1e9},Ml={message:`✉️ Message from chat "`,reply:`↩️ Reply from chat "`,continue:`↻ Continue the message from chat "`},Nl=`⚠ `,Pl=`<local-command-stdout>`,Fl=`</local-command-stdout>`,Il=/^[A-Za-z0-9._:-]{1,128}$/;function Ll(e){let t=(e??``).replace(/["“”]/g,`'`).replace(/\s+/g,` `).trim();if(!t)return`Untitled chat`;let n=jl.titleChars;return t.length>n?`${t.slice(0,n-1).trimEnd()}…`:t}function Rl(e){return Ll(e.title?.trim()||e.firstPrompt?.trim()||`Chat ${e.id.slice(0,8)}`)}function zl(e,t){let n=Al.filter(e=>t===`reply`||e!==`No answer needed.`),r=e;for(let e=!0;e;){e=!1;for(let t of n){if(r===t)return``;r.startsWith(`${t}\n\n`)&&(r=r.slice(t.length+2),e=!0)}}return r}var Bl=/^\[conv:(\S+) chat:(\S+) host:(\S+) msg:(\S+?)(?: reply-to:(\S+?))?( reply expected)?\]$/;function Vl(e){if(typeof e!=`string`)return null;let t=e;t.startsWith(Pl)&&t.endsWith(Fl)&&(t=t.slice(22,t.length-23)),t=t.replace(/\r\n/g,`
|
|
79
79
|
`);let n=t.indexOf(`
|
|
80
80
|
`);if(n<0)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`
|
|
@@ -157,5 +157,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
157
157
|
- run the tests before saying a change is done
|
|
158
158
|
- use the browser on port 9170 for anything on the web`,maxLength:tc.instructions,"data-testid":`project-instructions`})})]}),(0,G.jsxs)(kR,{title:`Repositories`,children:[(0,G.jsx)(zy,{label:`One per line (optional)`,hint:`Every chat in the project is told about them.`,children:(0,G.jsx)(`textarea`,{className:W(Z,`h-16 font-mono text-xs`),value:u.repositories,onChange:e=>g(`repositories`,e.target.value),placeholder:`https://github.com/you/app`,"data-testid":`project-repositories`})}),(0,G.jsx)(DR,{compact:!0})]}),(0,G.jsxs)(kR,{title:`New chats`,children:[(0,G.jsx)(zy,{label:`Model`,hint:`What a new chat in this project starts on.`,children:(0,G.jsxs)(`select`,{className:Z,value:u.model,onChange:e=>{g(`model`,e.target.value),g(`effort`,``)},"data-testid":`project-model`,children:[(0,G.jsx)(`option`,{value:``,children:`Whatever a new chat would start on`}),x?(0,G.jsxs)(`option`,{value:u.model,children:[x.model,` (not on this PC)`]}):null,y.map(e=>(0,G.jsx)(`option`,{value:e.key,children:e.label},e.key))]})}),S.length>0?(0,G.jsx)(zy,{label:`Effort`,children:(0,G.jsxs)(`select`,{className:Z,value:u.effort,onChange:e=>g(`effort`,e.target.value),"data-testid":`project-effort`,children:[(0,G.jsx)(`option`,{value:``,children:`Default`}),S.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})}):null,(0,G.jsx)(zy,{label:`Folder`,hint:`Where a new chat runs; left empty, each chat gets its own.`,children:(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`flex-1 font-mono text-xs`),value:u.cwd,onChange:e=>g(`cwd`,e.target.value),placeholder:s,"data-testid":`project-cwd`}),window.oonacode?.pickDirectory?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>void D(),children:`Choose…`}):null]})})]}),(0,G.jsxs)(kR,{title:`Memory`,children:[(0,G.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.memoryEnabled,onChange:e=>g(`memoryEnabled`,e.target.checked),"data-testid":`project-memory-enabled`}),(0,G.jsx)(`span`,{children:`Keep a project memory — notes every chat of the project reads at its start, and the agent keeps up to date.`})]}),u.memoryEnabled?(0,G.jsx)(`textarea`,{className:W(Z,`h-28 font-mono text-xs`),value:u.memory,onChange:e=>g(`memory`,e.target.value),placeholder:`Nothing noted yet.`,maxLength:tc.memory,"data-testid":`project-memory`}):null]}),(0,G.jsxs)(kR,{title:`Scheduled tasks`,children:[(0,G.jsxs)(`label`,{className:`flex items-start gap-2 text-sm`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:u.tasksEnabled,onChange:e=>g(`tasksEnabled`,e.target.checked),"data-testid":`project-tasks-enabled`}),(0,G.jsx)(`span`,{children:`The agent may schedule work in this project's chats — once, or on a repeat — with OonaCode's scheduler on this PC.`})]}),u.tasksEnabled?(0,G.jsx)(zy,{label:`Shortest repeat, in minutes`,children:(0,G.jsx)(`input`,{className:W(Z,`w-28`),inputMode:`numeric`,value:u.minInterval,onChange:e=>g(`minInterval`,e.target.value),"data-testid":`project-min-interval`})}):null,_?(0,G.jsx)(BN,{projectId:_.id,showChat:!0}):null]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saved settings reach the project's chats at their next message. Projects live in your vault: only your own devices can read them.`})]})]})})}var jR=`(min-width: 768px)`;function MR(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(jR).matches}function NR(){let[e,t]=(0,v.useState)(MR);return(0,v.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(jR),n=()=>t(e.matches);return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}function PR(e){try{return!!e?.matches(`:hover`)}catch{return!1}}function FR(e){if(typeof document>`u`)return!1;if(document.querySelector(`[role="menu"], [role="dialog"]`))return!0;let t=document.activeElement;return!!(e&&t&&e.contains(t)&&t.tagName===`INPUT`)}function IR({hidden:e,children:t}){let{state:n,actions:r}=K(),i=n.ui.sidebarPinnedOverride??n.prefs.sidebarPinned,a=n.ui.sidebarOpen,[o,s]=(0,v.useState)(null),c=o??n.prefs.sidebarWidth,[l,u]=(0,v.useState)(!1),d=NR(),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useCallback)(()=>{p.current!==null&&(clearTimeout(p.current),p.current=null)},[]),h=(0,v.useCallback)(()=>{m(),p.current=setTimeout(function e(){if(FR(f.current)){p.current=setTimeout(e,350);return}p.current=null,!PR(f.current)&&u(!1)},350)},[m]);(0,v.useEffect)(()=>m,[m]),(0,v.useEffect)(()=>{u(!1),m()},[i,m]),(0,v.useEffect)(()=>{if(e)return;let t=e=>{if(!(!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey)&&(e.key===`k`||e.key===`K`)){if(MR()){if(i)return;u(!0),h()}else a||r.setSidebar(!0)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,i,a,h,r]);let g=e=>{e.preventDefault();let t=e.clientX,i=c,a=i,o=e=>{a=Ic(i+(e.clientX-t)),s(a)},l=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,l),document.body.style.cursor=``,document.body.style.userSelect=``,s(null),a!==n.prefs.sidebarWidth&&r.savePrefs({sidebarWidth:a})};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,l)},_=i||l;return(0,G.jsxs)(G.Fragment,{children:[!i&&!l&&!e?(0,G.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-40 hidden w-2 md:block`,onMouseEnter:()=>{u(!0),h()},"aria-hidden":!0,"data-testid":`sidebar-hover-edge`}):null,(0,G.jsxs)(`aside`,{ref:f,"data-chrome":`sidebar`,hidden:e,inert:!e&&(d?!_:!a),"data-testid":`sidebar-frame`,"data-state":i?`docked`:l?`peek`:`hidden`,style:{"--sidebar-w":`${c}px`},onMouseEnter:i?void 0:m,onMouseLeave:i?void 0:h,className:W(`absolute inset-y-0 left-0 z-30 w-72 max-w-[85vw] border-r border-border bg-surface transition-transform md:w-[var(--sidebar-w)] md:max-w-[70vw]`,a?`translate-x-0`:`-translate-x-full`,i?`md:relative md:z-auto md:translate-x-0`:W(`md:z-40 md:shadow-2xl`,_?`md:translate-x-0`:`md:-translate-x-full`)),children:[t,(0,G.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the session list`,title:`Drag to resize · double-click for the default width`,className:`absolute inset-y-0 -right-1 z-10 hidden w-2 cursor-col-resize hover:bg-accent/30 md:block`,onPointerDown:g,onDoubleClick:()=>void r.savePrefs({sidebarWidth:288}),"data-testid":`sidebar-resize`})]})]})}function LR({open:e,onClose:t}){return(0,G.jsx)(Vy,{open:e,title:`Export my chats`,onClose:t,children:(0,G.jsx)(RR,{onDone:t})})}function RR({onDone:e}){let{api:t,state:n}=K(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(0),p=n.sessionsTotal||n.sessions.length;(0,v.useEffect)(()=>{if(!a){f(0);return}let e=Date.now(),t=setInterval(()=>f(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[a]);let m=async()=>{if(!t.exportSessionsArchive){c(`this PC is running an older OonaCode that cannot export chats`);return}o(!0),c(null);try{let n=await t.exportSessionsArchive(r),a=URL.createObjectURL(n),o=document.createElement(`a`);o.href=a,o.download=`oonacode-chats-${new Date().toISOString().slice(0,10)}.zip`,o.click(),URL.revokeObjectURL(a),i(``),u(!1),e()}catch(e){c(e instanceof Error?e.message:`the export failed`)}finally{o(!1)}};return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Vy,{open:a,title:`Exporting your chats`,onClose:()=>void 0,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(J.Spinner,{className:`mt-0.5 w-5 h-5 shrink-0 text-accent`}),(0,G.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,G.jsxs)(`div`,{className:`font-medium`,children:[`Packing`,` `,p>0?`${p} chat${p===1?``:`s`}`:`your chats`,`…`]}),(0,G.jsxs)(`div`,{className:`mt-1 tabular text-fg-muted`,children:[Math.floor(d/60),`:`,String(d%60).padStart(2,`0`),` elapsed`]}),(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-faint`,children:`Your PC writes the whole archive before the download starts, so nothing appears in your downloads until it is finished. A long history can take a minute or two — this is normal, and you do not need to press anything again.`})]})]})}),(0,G.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`One zip with a plain `,(0,G.jsx)(`code`,{children:`.txt`}),` of every conversation on this PC, plus an index. It is for reading and copying from — there is no way to load it back in.`]}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-warn`,children:`The zip is not encrypted: anyone who opens it can read every conversation in it.`}),l?(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`password`,autoFocus:!0,className:Z+` max-w-[16rem]`,placeholder:`Account password`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&m()},"data-testid":`export-chats-password`}),(0,G.jsx)(Y,{onClick:()=>void m(),disabled:a||!r,children:a?`Exporting…`:`Export`}),(0,G.jsx)(Y,{variant:`ghost`,onClick:()=>{u(!1),i(``),c(null)},children:`Cancel`})]}):(0,G.jsx)(Y,{className:`mt-2`,onClick:()=>u(!0),"data-testid":`export-chats`,children:`Export chats…`}),s?(0,G.jsx)(`div`,{className:`mt-2 text-xs text-danger`,children:s}):null]})}var zR=70,BR=96,VR=170,HR=56;function UR(e,t=22){let n=e.trim().replace(/\s+/g,` `);return n.length<=t?n:`${n.slice(0,Math.max(1,t-1)).trimEnd()}…`}var WR={working:3,idle:2,asleep:1,missing:0},GR=Math.PI*2,KR=e=>(e%GR+GR)%GR,qR=e=>Math.round(e*100)/100;function JR(e){let t=0,n=0;for(let r of e)t+=Math.cos(r),n+=Math.sin(r);return Math.hypot(t,n)<1e-9?null:Math.atan2(n,t)}function YR(e,t=!1){return e.filter(e=>t||e.status!==`closed`).filter(e=>e.members.length>0).sort((e,t)=>e.createdAt===t.createdAt?e.id<t.id?-1:+(e.id>t.id):e.createdAt<t.createdAt?-1:1)}function XR(e,t={}){let n=t.now??Date.now(),r=YR(e,t.showClosed??!1),i=t.showClosed?0:e.filter(e=>e.status===`closed`).length,a=r.length,o=a<=1?0:Math.max(72,a*BR/GR),s=e=>-Math.PI/2+GR*e/Math.max(1,a),c=new Map;r.forEach((e,t)=>{for(let n of e.members){let r=n.leftAt===null,i=c.get(n.sessionId);i?(r&&!i.titleFromCurrent&&n.title&&(i.title=n.title,i.titleFromCurrent=!0),WR[n.state]>WR[i.state]&&(i.state=n.state)):(i={sessionId:n.sessionId,hostId:n.hostId,title:n.title,titleFromCurrent:r,state:n.state,hubs:[],conversationIds:[],anyCurrent:!1},c.set(n.sessionId,i)),i.conversationIds.includes(e.id)||(i.hubs.push(t),i.conversationIds.push(e.id)),r&&(i.anyCurrent=!0)}});let l=c.size,u=Math.max(o+120,l*zR/GR,110),d=[...c.values()].map(e=>({acc:e,pref:KR((a<=1?0:JR(e.hubs.map(s))??s(e.hubs[0]))+Math.PI/2)})).sort((e,t)=>Math.abs(e.pref-t.pref)>1e-9?e.pref-t.pref:e.acc.sessionId<t.acc.sessionId?-1:+(e.acc.sessionId>t.acc.sessionId)),f=GR/Math.max(1,l),p=(a<=1?null:JR(d.map((e,t)=>e.pref-t*f)))??0,m=qR(2*(u+VR)),h=qR(2*(u+HR)),g=m/2,_=h/2,v=r.map((e,t)=>{let r=s(t),i=e.members.filter(e=>e.leftAt===null).length,a=Date.parse(e.lastActivityAt),c=Cd(e);return{id:e.id,x:qR(g+o*Math.cos(r)),y:qR(_+o*Math.sin(r)),name:c,label:UR(c),status:e.status,waiting:e.waiting,members:i,messageCount:e.messageCount,recent:e.status!==`closed`&&Number.isFinite(a)&&n-a>=-5e3&&n-a<=6e4}}),y=d.map(({acc:e},t)=>{let n=-Math.PI/2+p+t*f,r=g+u*Math.cos(n),i=_+u*Math.sin(n),a=Math.cos(n),o=Math.sin(n),s=a>.3?`start`:a<-.3?`end`:`middle`,c=s===`middle`?r:r+a*15,l=s===`middle`?o<0?i-15:i+15+8:i+o*15+4;return{sessionId:e.sessionId,hostId:e.hostId,x:qR(r),y:qR(i),title:e.title,label:UR(e.title||`a chat`),state:e.state,conversationIds:e.conversationIds,left:!e.anyCurrent,labelX:qR(c),labelY:qR(l),anchor:s}}),b=new Map(v.map(e=>[e.id,e])),x=new Map(y.map(e=>[e.sessionId,e])),S=[];for(let e of r){let t=b.get(e.id),n=new Set,r=new Map;for(let t of e.members)r.set(t.sessionId,(r.get(t.sessionId)??!0)&&t.leftAt!==null);for(let i of e.members){if(n.has(i.sessionId))continue;n.add(i.sessionId);let a=x.get(i.sessionId);S.push({conversationId:e.id,sessionId:i.sessionId,left:r.get(i.sessionId)??!1,x1:t.x,y1:t.y,x2:a.x,y2:a.y})}}return{hubs:v,chats:y,edges:S,width:m,height:h,hiddenClosed:i}}function ZR(e){if(!e)return null;for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`notice`||!n.fromSession))return{conversationId:n.conversationId,from:n.fromSession,to:n.toSession,kind:n.kind}}return null}function QR(e,t,n,r,i,a){let o=Math.hypot(n-e,r-t);if(o<=i+a||o===0)return{x1:e,y1:t,x2:n,y2:r};let s=(n-e)/o,c=(r-t)/o;return{x1:qR(e+s*i),y1:qR(t+c*i),x2:qR(n-s*a),y2:qR(r-c*a)}}var $R={working:`working`,idle:`idle`,asleep:`asleep`,missing:`not on this PC any more`},ez={working:`fill-accent stroke-accent animate-pulse`,idle:`fill-accent-soft stroke-accent`,asleep:`fill-surface-3 stroke-fg-faint`,missing:`fill-surface-2 stroke-fg-faint`},tz={active:`stroke-ok`,paused:`stroke-warn`,closed:`stroke-fg-faint`};function nz(e){return t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())}}function rz({list:e,showClosed:t,selectedId:n,messages:r,onSelectConversation:i,onOpenChat:a,canOpenChat:o,now:s}){let c=(0,v.useMemo)(()=>XR(e,{showClosed:t,now:s}),[e,t,s]),l=(0,v.useMemo)(()=>ZR(r),[r]);if(c.hubs.length===0)return(0,G.jsxs)(`div`,{className:`space-y-1 py-6 text-center text-sm text-fg-muted`,"data-testid":`conversation-map-empty`,children:[(0,G.jsx)(`p`,{children:`No chats are talking to each other right now.`}),(0,G.jsx)(`p`,{className:`text-xs`,children:`Turn on "Talk to other chats" in a chat's Tools menu.`}),c.hiddenClosed>0?(0,G.jsxs)(`p`,{className:`text-xs text-fg-faint`,children:[c.hiddenClosed,` closed conversation`,c.hiddenClosed===1?``:`s`,` hidden.`]}):null]});let u=new Map(c.hubs.map(e=>[e.id,e])),d=new Map(c.chats.map(e=>[e.sessionId,e])),f=[];if(l&&u.has(l.conversationId)){let e=u.get(l.conversationId),t=d.get(l.from),n=d.get(l.to);t&&f.push({key:`from`,...QR(t.x,t.y,e.x,e.y,11,20)}),n&&f.push({key:`to`,...QR(e.x,e.y,n.x,n.y,18,13)})}return(0,G.jsxs)(`div`,{className:`max-h-[65vh] overflow-auto rounded-md border border-border bg-surface`,"data-testid":`conversation-map`,children:[(0,G.jsxs)(`svg`,{viewBox:`0 0 ${c.width} ${c.height}`,preserveAspectRatio:`xMidYMid meet`,className:`block h-auto w-full min-w-[480px] select-none`,style:{maxHeight:`63vh`},role:`img`,"aria-label":`Which chats are talking to each other`,children:[(0,G.jsx)(`defs`,{children:(0,G.jsx)(`marker`,{id:`conversation-map-arrow`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,G.jsx)(`path`,{d:`M0,0 L10,5 L0,10 z`,className:`fill-accent`})})}),(0,G.jsx)(`g`,{"data-testid":`conversation-map-edges`,children:c.edges.map(e=>{let t=u.get(e.conversationId),r=e.conversationId===n;return(0,G.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,className:W(r?`stroke-accent`:t.status===`active`?`stroke-fg-muted`:`stroke-border`),strokeWidth:r?2:t.status===`active`?1.5:1,strokeDasharray:e.left?`4 4`:void 0,opacity:t.status===`closed`?.5:1,"data-testid":`map-edge-${e.conversationId}-${e.sessionId}`,"data-left":e.left?`true`:void 0},`${e.conversationId}:${e.sessionId}`)})}),f.length>0?(0,G.jsx)(`g`,{"data-testid":`conversation-map-latest`,children:f.map(e=>(0,G.jsx)(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,className:`stroke-accent`,strokeWidth:3,markerEnd:`url(#conversation-map-arrow)`},e.key))}):null,c.hubs.map(e=>{let t=e.id===n,r=[e.name,`${Dd[e.status]} · ${e.members} chat${e.members===1?``:`s`} · ${e.messageCount} message${e.messageCount===1?``:`s`}`,e.waiting>0?`${e.waiting} waiting to be delivered`:null,`Click to see this conversation.`].filter(Boolean).join(`
|
|
159
159
|
`);return(0,G.jsxs)(`g`,{role:`button`,tabIndex:0,"aria-label":`Conversation ${e.name}, ${Dd[e.status]}`,"aria-pressed":t,className:`cursor-pointer outline-none`,onClick:()=>i(e.id),onKeyDown:nz(()=>i(e.id)),"data-testid":`map-hub-${e.id}`,"data-status":e.status,"data-recent":e.recent?`true`:void 0,children:[(0,G.jsx)(`title`,{children:r}),e.recent?(0,G.jsx)(`circle`,{cx:e.x,cy:e.y,r:23,className:`fill-accent-soft stroke-accent animate-pulse`,strokeWidth:1}):null,(0,G.jsx)(`circle`,{cx:e.x,cy:e.y,r:16,className:W(t?`fill-accent-soft`:`fill-surface-2`,tz[e.status]),strokeWidth:t?3.5:2.5,strokeDasharray:e.status===`paused`?`5 3`:void 0}),(0,G.jsx)(`text`,{x:e.x,y:e.y+4,textAnchor:`middle`,className:`fill-fg text-[11px] font-semibold`,children:e.members}),(0,G.jsx)(`text`,{x:e.x,y:e.y+16+14,textAnchor:`middle`,className:W(`text-[11px]`,e.status===`closed`?`fill-fg-faint`:`fill-fg`,t&&`font-semibold`),children:e.label}),e.status!==`active`||e.waiting>0?(0,G.jsx)(`text`,{x:e.x,y:e.y+16+27,textAnchor:`middle`,className:W(`text-[10px]`,e.status===`paused`?`fill-warn`:`fill-fg-faint`),children:[e.status===`active`?null:Dd[e.status],e.waiting>0?`${e.waiting} waiting`:null].filter(Boolean).join(` · `)}):null]},e.id)}),c.chats.map(e=>{let t=e.state!==`missing`&&o(e.sessionId),n=e.conversationIds.map(e=>u.get(e)?.name??e),r=[e.title,$R[e.state],`In ${n.length} conversation${n.length===1?``:`s`}: ${n.join(`, `)}`,e.left?`It has left.`:null,t?`Click to open this chat.`:null].filter(Boolean).join(`
|
|
160
|
-
`),i=e.state===`missing`||e.left;return(0,G.jsxs)(`g`,{role:t?`button`:void 0,tabIndex:t?0:void 0,"aria-label":t?`Open chat ${e.title}`:void 0,className:W(t?`cursor-pointer`:`cursor-default`,`outline-none`),opacity:i?.5:1,onClick:t?()=>a(e.sessionId):void 0,onKeyDown:t?nz(()=>a(e.sessionId)):void 0,"data-testid":`map-chat-${e.sessionId}`,"data-state":e.state,children:[(0,G.jsx)(`title`,{children:r}),(0,G.jsx)(`circle`,{cx:e.x,cy:e.y,r:9,className:ez[e.state],strokeWidth:2,strokeDasharray:e.state===`missing`?`3 2`:void 0}),(0,G.jsx)(`text`,{x:e.labelX,y:e.labelY,textAnchor:e.anchor,className:`fill-fg text-[11px]`,children:e.label})]},e.sessionId)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border px-3 py-1.5 text-[11px] text-fg-muted`,"data-testid":`conversation-map-legend`,children:[(0,G.jsx)(iz,{dot:`bg-accent animate-pulse`,children:`working`}),(0,G.jsx)(iz,{dot:`bg-accent-soft border border-accent`,children:`idle`}),(0,G.jsx)(iz,{dot:`bg-surface-3 border border-fg-faint`,children:`asleep`}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-ok`}),`active`]}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-dashed border-warn`}),`paused`]}),(0,G.jsx)(`span`,{children:`dashed spoke: left`}),f.length>0?(0,G.jsx)(`span`,{className:`text-accent`,children:`arrows: the newest message`}):null,c.hiddenClosed>0?(0,G.jsxs)(`span`,{className:`text-fg-faint`,children:[c.hiddenClosed,` closed hidden`]}):null]})]})}function iz({dot:e,children:t}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:W(`inline-block h-2.5 w-2.5 rounded-full`,e)}),t]})}function az({open:e,selectId:t=null,onClose:n}){let{state:r,actions:i}=K(),a=r.conversationsChange,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(`list`),[C,w]=(0,v.useState)(!1),T=(0,v.useRef)(null);T.current=f;let E=(0,v.useRef)(-1),D=(0,v.useCallback)(async()=>{let e=await i.listConversations();if(e===`unsupported`){l(!0);return}if(e===null){d(!0);return}l(!1),d(!1),s(e)},[i]),O=(0,v.useCallback)(async e=>{let t=await i.conversationHistory(e);t&&T.current===e&&h(t)},[i]);(0,v.useEffect)(()=>{e&&(E.current=a.seq,_(!1),p(t??null),D())},[e]),(0,v.useEffect)(()=>{!e||f!==null||!o||o.length===0||p(o[0].id)},[e,o,f]),(0,v.useEffect)(()=>{if(!e||!f){h(null);return}h(e=>e?.conversation.id===f?e:null),O(f)},[e,f,O]),(0,v.useEffect)(()=>{if(!e||a.seq===E.current)return;E.current=a.seq,D();let t=T.current;t&&(a.conversationIds===null||a.conversationIds.includes(t))&&O(t)},[e,a,D,O]);let k=e=>{s(t=>t?.map(t=>t.id===e.id?e:t)??t),h(t=>t&&t.conversation.id===e.id?{...t,conversation:e}:t)},A=async(e,t,n)=>{let r=await i.conversationAction(e,t,n);return r&&k(r),r!==null},j=async()=>{b(!0);try{await i.stopAllConversations()}finally{b(!1),_(!1)}D(),T.current&&O(T.current)},M=async e=>{await i.cancelChatMessage(e.id),T.current&&O(T.current)},N=(0,v.useCallback)((e,t,n=[])=>{if(!e)return t??`OonaCode`;let i=n.find(t=>t.sessionId===e);if(i?.title)return i.title;if(t)return t;let a=r.sessions.find(t=>t.id===e);return a?cg(a):`a chat`},[r.sessions]),ee=m&&m.conversation.id===f?m.conversation:o?.find(e=>e.id===f)??null;return(0,G.jsxs)(Vy,{open:e,title:`Conversations`,onClose:n,wide:!0,footer:(0,G.jsx)(Y,{variant:`ghost`,onClick:n,children:`Close`}),children:[(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`p`,{className:`min-w-0 flex-1 text-xs text-fg-muted`,children:[`Messages and tasks your chats send each other, on this PC.`,` `,(0,G.jsx)(Ly,{label:`Conversations`,details:U.window})]}),c?null:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsxs)(Y,{variant:`danger`,size:`sm`,onClick:()=>_(!0),disabled:g||y,title:U.stopAll,"data-testid":`conversations-stop-all`,children:[(0,G.jsx)(J.Stop,{className:`h-3 w-3`}),` Stop all conversations`]}),(0,G.jsx)(Ly,{label:`Stop all conversations`,details:U.stopAll})]})]}),g?(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alertdialog`,"aria-label":`Stop all conversations?`,"data-testid":`conversations-stop-confirm`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Pause every conversation and stop the turns they are running now? Nothing is deleted; you can resume each one.`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,G.jsx)(Y,{size:`sm`,variant:`danger`,busy:y,onClick:()=>void j(),"data-testid":`conversations-stop-confirm-yes`,children:`Stop all`})]}):null,!c&&o!==null?(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border border-border text-xs`,role:`group`,"aria-label":`View`,children:[`list`,`map`].map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":x===e,onClick:()=>S(e),className:W(`px-3 py-1`,x===e?`bg-accent text-accent-fg`:`text-fg-muted hover:bg-surface-2`),title:e===`list`?U.listView:U.mapView,"data-testid":`conversations-view-${e}`,children:e===`list`?`List`:`Map`},e))}),x===`map`?(0,G.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-muted`,title:U.showClosed,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),"data-testid":`conversation-map-show-closed`}),`Show closed`]}):null,(0,G.jsx)(Ly,{label:`Map`,details:U.mapView})]}):null,c?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-unsupported`,children:`OonaCode on this PC is too old for conversations between chats. Update it, then open this window again.`}):o===null?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-loading`,children:u?`Could not read the conversations from this PC right now. They show here as soon as it answers.`:`Loading…`}):x===`map`?(0,G.jsx)(rz,{list:o,showClosed:C,selectedId:f,messages:m&&m.conversation.id===f?m.messages:null,onSelectConversation:e=>{p(e),S(`list`)},onOpenChat:e=>{n(),i.selectSession(e)},canOpenChat:e=>r.sessions.some(t=>t.id===e)}):o.length===0?(0,G.jsxs)(`div`,{className:`space-y-1 text-sm text-fg-muted`,"data-testid":`conversations-empty`,children:[(0,G.jsx)(`p`,{children:`No conversations yet.`}),(0,G.jsx)(`p`,{className:`text-xs`,children:`To start one, turn on "Talk to other chats" in the Tools menu of two chats, then ask one of them to send the other a message or a task.`})]}):(0,G.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[260px_1fr]`,children:[(0,G.jsx)(`ul`,{className:`flex max-h-[65vh] flex-col gap-1 overflow-y-auto pr-1`,"data-testid":`conversations-list`,children:o.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(cz,{c:e,selected:e.id===f,onSelect:()=>p(e.id)})},e.id))}),(0,G.jsx)(`div`,{className:`max-h-[65vh] min-w-0 overflow-y-auto pr-1`,children:ee?(0,G.jsx)(fz,{c:ee,messages:m&&m.conversation.id===ee.id?m.messages:null,titleOf:N,onAction:(e,t)=>A(ee.id,e,t),onWithdraw:e=>void M(e),onOpenChat:e=>{n(),i.selectSession(e)},isLocalChat:e=>r.sessions.some(t=>t.id===e)},ee.id):(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose a conversation.`})})]})]})}function oz({c:e}){return(0,G.jsx)(`span`,{title:U.status,"data-testid":`conversation-status`,children:(0,G.jsx)(Q,{tone:Od(e.status),children:Dd[e.status]})})}function sz({label:e,used:t,budget:n,format:r=e=>e.toLocaleString()}){let i=Rd(t,n),a=i>=1?`bg-danger`:i>=.8?`bg-warn`:`bg-accent`;return(0,G.jsxs)(`div`,{className:`mt-1`,"data-testid":`usage-${e.toLowerCase()}`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsxs)(`span`,{"data-testid":`usage-numbers`,children:[r(t),` of `,r(n)]})]}),(0,G.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e} used`,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,a),style:{width:`${Math.round(i*100)}%`}})})]})}function cz({c:e,selected:t,onSelect:n}){let r=e.members.filter(e=>e.leftAt===null);return(0,G.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:W(`w-full rounded-md border px-2.5 py-2 text-left text-xs`,t?`border-accent bg-accent-soft`:`border-border hover:bg-surface-2`),"data-testid":`conversation-row-${e.id}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:Cd(e)}),(0,G.jsx)(oz,{c:e})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 truncate text-fg-muted`,"data-testid":`conversation-members`,children:[r.length,` chat`,r.length===1?``:`s`,e.title?`: ${r.map(e=>e.title).join(`, `)}`:``]}),e.status!==`active`&&e.pausedReason?(0,G.jsx)(`div`,{className:`mt-0.5 text-warn`,"data-testid":`conversation-paused-reason`,children:e.pausedReason}):null,(0,G.jsx)(sz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,G.jsx)(sz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:$h}),(0,G.jsxs)(`div`,{className:`mt-1 flex justify-between gap-2 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`span`,{"data-testid":`conversation-cost`,children:Vd(e.used.credits)}),(0,G.jsx)(`span`,{title:ng(e.lastActivityAt),children:eg(e.lastActivityAt)})]})]})}function lz({title:e,help:t,children:n}){return(0,G.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[e,t?(0,G.jsx)(Ly,{label:e,details:t}):null]}),n]})}var uz={working:`working`,idle:`idle`,asleep:`asleep`,missing:`gone`},dz={working:`This chat is working on a turn right now.`,idle:`This chat is open and waiting.`,asleep:`This chat is not running; a message wakes it from its saved history.`,missing:`This chat is not on this PC any more (deleted).`};function fz({c:e,messages:t,titleOf:n,onAction:r,onWithdraw:i,onOpenChat:a,isLocalChat:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(String(e.budget.messages)),[h,g]=(0,v.useState)(String(e.budget.tokens));(0,v.useEffect)(()=>{m(String(e.budget.messages)),g(String(e.budget.tokens))},[e.budget.messages,e.budget.tokens]);let _=async(e,t,n)=>{c(e);try{return await r(t,n)}finally{c(null)}},y=p.trim()!==String(e.budget.messages)||h.trim()!==String(e.budget.tokens),b=y?Bd(p,h):null,x=()=>{if(!y||Bd(p,h))return;let t={},n=Number(p.trim()),r=Number(h.trim());n!==e.budget.messages&&(t.messages=n),r!==e.budget.tokens&&(t.tokens=r),_(`budget`,`budget`,t)},S=e.status===`closed`,C=(0,v.useMemo)(()=>[...e.members].sort((e,t)=>(e.leftAt===null?0:1)-(t.leftAt===null?0:1)),[e.members]);return(0,G.jsxs)(`div`,{className:`space-y-4`,"data-testid":`conversation-detail`,"data-id":e.id,children:[(0,G.jsxs)(lz,{title:`Conversation`,help:U.status,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`min-w-0 text-base font-semibold text-fg`,children:Cd(e)}),(0,G.jsx)(oz,{c:e})]}),e.pausedReason&&!S?(0,G.jsxs)(`p`,{className:`text-xs text-warn`,"data-testid":`conversation-detail-reason`,children:[`Paused: `,e.pausedReason]}):e.pausedReason&&S?(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Closed: `,e.pausedReason]}):null,(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Started `,ng(e.createdAt),` · last activity`,` `,(0,G.jsx)(`span`,{title:ng(e.lastActivityAt),children:eg(e.lastActivityAt)}),e.waiting>0?` · ${e.waiting} waiting to be delivered`:``]}),S?null:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.status===`active`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,onClick:()=>void _(`pause`,`pause`),busy:s===`pause`,title:U.pause,"data-testid":`conversation-pause`,children:`Pause`}),(0,G.jsx)(Ly,{label:`Pause`,details:U.pause})]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>void _(`resume`,`resume`),busy:s===`resume`,title:U.resume,"data-testid":`conversation-resume`,children:`Resume`}),(0,G.jsx)(Ly,{label:`Resume`,details:U.resume})]}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,variant:l?`danger`:`ghost`,busy:s===`close`,title:U.close,onClick:()=>{if(!l){u(!0);return}u(!1),_(`close`,`close`)},"data-testid":`conversation-close`,children:l?`Close it for good?`:`Close`}),(0,G.jsx)(Ly,{label:`Close`,details:U.close})]})]})]}),(0,G.jsxs)(lz,{title:`Budget`,help:U.budget,children:[(0,G.jsx)(sz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,G.jsx)(sz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:$h}),(0,G.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,G.jsxs)(`span`,{"data-testid":`conversation-detail-cost`,children:[`Cost so far `,Vd(e.used.credits),` · `,$h(e.used.tokens),` `,`new tokens`]}),(0,G.jsx)(Ly,{label:`Cost`,details:U.cost})]}),S?null:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Messages`,(0,G.jsx)(`input`,{className:W(Z,`w-24`),inputMode:`numeric`,value:p,onChange:e=>m(e.target.value),"data-testid":`conversation-budget-messages`})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Tokens`,(0,G.jsx)(`input`,{className:W(Z,`w-32`),inputMode:`numeric`,value:h,onChange:e=>g(e.target.value),"data-testid":`conversation-budget-tokens`})]}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:x,disabled:!y||b!==null,busy:s===`budget`,title:U.budget,"data-testid":`conversation-budget-save`,children:`Save budget`}),b?(0,G.jsx)(`span`,{className:`text-xs text-danger`,"data-testid":`conversation-budget-problem`,children:b}):null]})]}),(0,G.jsx)(lz,{title:`Chats`,help:U.removeMember,children:(0,G.jsx)(`ul`,{className:`space-y-1`,"data-testid":`conversation-members-list`,children:C.map(e=>{let t=`${e.hostId}:${e.sessionId}`,n=e.leftAt!==null;return(0,G.jsxs)(`li`,{className:W(`flex flex-wrap items-center gap-2 rounded-md border border-border px-2.5 py-1.5 text-xs`,n&&`opacity-60`),"data-testid":`conversation-member-${e.sessionId}`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-fg`,children:e.title}),(0,G.jsx)(`span`,{title:dz[e.state],children:(0,G.jsx)(Q,{tone:e.state===`working`?`accent`:`neutral`,children:uz[e.state]})}),e.talkOn===!1?(0,G.jsx)(`span`,{className:`text-fg-faint`,title:`Its "Talk to other chats" switch is off: it cannot message other chats. It still answers a chat that messages it, and only that chat, when asked; what it sent before, and answers to what it asked, wait until it is on again.`,children:`answers only`}):null,n?(0,G.jsx)(`span`,{className:`text-fg-faint`,title:ng(e.leftAt),children:`left`}):null,e.state!==`missing`&&o(e.sessionId)?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>a(e.sessionId),title:U.openChat,"data-testid":`conversation-member-open`,children:`Open chat`}):null,!n&&!S?(0,G.jsx)(Y,{size:`sm`,variant:d===t?`danger`:`ghost`,busy:s===`remove:${t}`,title:U.removeMember,onClick:()=>{if(d!==t){f(t);return}f(null),_(`remove:${t}`,`remove-member`,{sessionId:e.sessionId,hostId:e.hostId})},"data-testid":`conversation-member-remove`,children:d===t?`Remove?`:`Remove`}):null]},t)})})}),(0,G.jsx)(lz,{title:`History`,help:U.history,children:t===null?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t.length===0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Nothing has been sent yet.`}):(0,G.jsx)(`ol`,{className:`space-y-2`,"data-testid":`conversation-history`,children:t.map(t=>(0,G.jsx)(pz,{m:t,from:t.kind===`notice`?`OonaCode`:n(t.fromSession,t.fromTitle,e.members),to:n(t.toSession,t.toTitle,e.members),onWithdraw:()=>i(t)},t.id))})})]})}function pz({m:e,from:t,to:n,onWithdraw:r}){let i=Md(e),a=zd(i),o=Fd(e),s=Id(e),[c,l]=(0,v.useState)(!1),u=e.kind===`reply`?J.Reply:e.kind===`notice`?J.Alert:e.kind===`continue`?J.Refresh:J.Mail;return(0,G.jsxs)(`li`,{className:W(`rounded-md border px-2.5 py-2 text-xs`,e.kind===`notice`?`border-warn/40 bg-warn-soft/40`:`border-border`),"data-testid":`conversation-message-${e.id}`,"data-kind":e.kind,"data-status":e.status,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,G.jsx)(u,{className:W(`h-3.5 w-3.5`,e.kind===`notice`?`text-warn`:`text-accent`)}),(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:kd[e.kind]}),(0,G.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,"data-testid":`conversation-message-route`,children:[t,` → `,n]}),(0,G.jsx)(`span`,{className:`text-fg-faint`,title:ng(e.createdAt),children:rg(e.createdAt)}),(0,G.jsx)(`span`,{className:`flex-1`}),e.kind===`notice`?null:(0,G.jsx)(`span`,{title:Ad[e.status],children:(0,G.jsx)(Q,{tone:jd(e.status),children:(0,G.jsx)(`span`,{"data-testid":`conversation-message-status`,children:e.status})})})]}),o||s||e.continued||e.stalled?(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 text-fg-muted`,children:[o?(0,G.jsx)(`span`,{title:o.help,"data-testid":`conversation-message-reply`,children:o.text}):null,s?(0,G.jsx)(`span`,{"data-testid":`conversation-message-batch`,children:s}):null,e.continued?(0,G.jsx)(`span`,{children:`continued after an OonaCode restart`}):null,e.stalled?(0,G.jsxs)(`span`,{className:`text-warn`,children:[`waiting for your permission to use `,e.stalled]}):null]}):null,e.error?(0,G.jsx)(`div`,{className:W(`mt-0.5`,e.status===`failed`?`text-danger`:`text-fg-muted`),"data-testid":`conversation-message-error`,children:e.error}):null,e.tokens>0||(e.credits??0)>0?(0,G.jsxs)(`div`,{className:`mt-0.5 text-fg-faint`,"data-testid":`conversation-message-usage`,children:[`The turn it caused: `,Hd(e,$h(e.tokens))]}):null,(0,G.jsx)(`div`,{className:W(`mt-1.5 text-fg`,a&&!c&&`max-h-24 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)]`),"data-testid":`conversation-message-body`,"data-collapsed":a&&!c?`true`:void 0,children:(0,G.jsx)(tN,{text:i})}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[a?(0,G.jsx)(`button`,{type:`button`,className:`text-accent hover:underline`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`conversation-message-expand`,children:c?`Show less`:`Show all`}):null,(0,G.jsx)(`span`,{className:`flex-1`}),Ld(e)?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:r,title:U.withdraw,"data-testid":`conversation-message-withdraw`,children:`Withdraw`}):null]})]})}var mz={language:`en`,localVoice:{},speed:1,words:Au.words},hz=`oonacode.voiceSummary.v1`;function gz(e){let t=e&&typeof e==`object`?e:{},n=mz,r={};if(t.localVoice&&typeof t.localVoice==`object`)for(let[e,n]of Object.entries(t.localVoice))typeof n==`string`&&n.length<300&&Ou(e)&&(r[e]=n);return{language:typeof t.language==`string`&&Ou(t.language)?Ou(t.language).code:n.language,localVoice:r,speed:Nu(t.speed),words:Mu(t.words)}}function _z(e=yz()){try{let t=e?.getItem(hz);return gz(t?JSON.parse(t):null)}catch{return{...mz}}}function vz(e,t=yz()){try{t?.setItem(hz,JSON.stringify(e))}catch{}}function yz(){try{return typeof window<`u`?window.localStorage:null}catch{return null}}function bz(e){return e.kind===`system`?null:e.key.slice(e.key.indexOf(`:`)+1)}var xz={zh:[`cmn`]};function Sz(e){return e.toLowerCase().replace(/_/g,`-`)}function Cz(e,t){let n=Sz(e);return[t.code,...xz[t.code]??[]].some(e=>n===e||n.startsWith(`${e}-`))}function wz(e,t){let n=Sz(e);return n===Sz(t.bcp47)?0:n===t.code||(xz[t.code]??[]).includes(n)?1:2}function Tz(e){let t=new Set(e.map(e=>e.name));return e.filter(e=>{let n=e.name.indexOf(`+`);if(n<=0)return!0;let r=e.name.lastIndexOf(` `),i=r>n?e.name.slice(r+1):``,a=i?`${e.name.slice(0,n)} ${i}`:e.name.slice(0,n);return!t.has(a)})}function Ez(e,t,n){let r=t.filter(t=>t.language===e.code||(t.locale?Cz(t.locale,e):!1)),i=r.filter(e=>e.engine!==`espeak`).map(e=>({key:`sherpa:${e.id}`,label:e.label,kind:`sherpa`})),a=r.filter(e=>e.engine===`espeak`).slice(0,1).map(e=>({key:`espeak:${e.id}`,label:e.label||`eSpeak (robotic)`,kind:`espeak`})),o=Tz(n.filter(t=>Cz(t.lang,e)&&t.localService!==!1)).map((t,n)=>({v:t,i:n,fit:wz(t.lang,e)})).sort((e,t)=>e.fit-t.fit||e.i-t.i).map(({v:e})=>({key:`system:${e.voiceURI}`,label:`${e.name} (system)`,kind:`system`}));return[...i,...o,...a]}function Dz(e,t){return e.find(e=>e.key===t)??e[0]??null}function Oz(e,t){if(e===`win32`||e===`linux`||e===`darwin`)return e;let n=t??``;return/Windows|Win32|Win64/i.test(n)?`win32`:/Android|CrOS/i.test(n)?null:/Linux|X11/i.test(n)?`linux`:/Mac OS X|Macintosh/i.test(n)?`darwin`:null}function kz(e,t,n=null,r=!1){let i=t?``:` The OonaCode desktop app comes with its own Armenian voices, and eSpeak for every other language.`,a=`No local voice for ${e.name} on this PC.`;return t&&n===`win32`&&r?`${a} The app’s own eSpeak voice, which speaks every language here, could not start — usually because Microsoft’s Visual C++ Redistributable (x64) is not installed: https://aka.ms/vs/17/release/vc_redist.x64.exe. Install it, then open this window again.`:n===`linux`?`${a} Install speech-dispatcher and espeak-ng from your distribution (Debian, Ubuntu, Mint: sudo apt install speech-dispatcher espeak-ng · Fedora: sudo dnf install speech-dispatcher espeak-ng · Arch: sudo pacman -S speech-dispatcher espeak-ng), then restart OonaCode.${i}`:n===`darwin`?`${a} Add a ${e.name} voice in System Settings → Accessibility → Spoken Content → System voice → Manage Voices, then open this window again.${i}`:n===`win32`?`${a} Add a ${e.name} voice in Settings → Time & language → Speech → Add voices, if Windows offers one for ${e.name}, then open this window again.${i}`:`${a} Add a ${e.name} voice in the system's speech settings (Windows: Settings → Time & language → Speech), then open this window again.${i}`}function Az(e){return e===`linux`?`whole`:`sentences`}var jz=75;function Mz(e,t){return Math.round(3e3+e.length*120/Nu(t))}async function Nz(e,t,n,r){let{signal:i,onItem:a}=r,o=e.getVoices().find(e=>e.voiceURI===r.voiceURI)??null;e.cancel();let s=r.mode===`whole`?[n.join(` `)]:[...n];for(let c=0;c<s.length;c+=1){if(i.aborted)return;let l=s[c],u=await new Promise((s,u)=>{let d=[],f=!1,p=()=>!f&&(f=!0,d.forEach(e=>clearTimeout(e)),i.removeEventListener(`abort`,m),!0),m=()=>{p()&&(e.cancel(),s(`stopped`))},h=t(l);o&&(h.voice=o),h.lang=o?.lang??r.bcp47,h.rate=r.rate,h.onstart=()=>{if(f)return;if(r.mode===`sentences`){a(c);return}a(0);let e=0;for(let t=1;t<n.length;t+=1)e+=(n[t-1].length+1)*jz/Nu(r.rate),d.push(setTimeout(()=>!f&&a(t),e))},h.onend=()=>{p()&&s(`ended`)},h.onerror=e=>{p()&&(i.aborted||e.error===`interrupted`||e.error===`canceled`?s(`stopped`):u(Error(`The system voice failed: ${e.error??`unknown error`}`)))},i.addEventListener(`abort`,m),d.push(setTimeout(()=>{p()&&s(`lost`)},Mz(l,r.rate))),e.speak(h)});if(u===`stopped`)return;u===`lost`&&e.cancel()}}function Pz(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Fz(e,t){let n=new DataView(new ArrayBuffer(44)),r=(e,t)=>{for(let r=0;r<t.length;r+=1)n.setUint8(e+r,t.charCodeAt(r))};return r(0,`RIFF`),n.setUint32(4,36+e,!0),r(8,`WAVE`),r(12,`fmt `),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,1,!0),n.setUint32(24,t,!0),n.setUint32(28,t*2,!0),n.setUint16(32,2,!0),n.setUint16(34,16,!0),r(36,`data`),n.setUint32(40,e,!0),n}function Iz(e,t){let n=new Uint8Array(44+e.length);return n.set(new Uint8Array(Fz(e.length,t).buffer),0),n.set(e,44),n.buffer}function Lz(e,t){let n=new DataView(new ArrayBuffer(e.length*2));for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,Math.round(r*32767),!0)}return Iz(new Uint8Array(n.buffer),t)}function Rz(){let e=null,t=()=>{if(!e)return;let t=e;e=null,URL.revokeObjectURL(t.url),t.done()};return{play(n,r){return t(),new Promise(i=>{let a=URL.createObjectURL(new Blob([n],{type:`audio/wav`})),o=new Audio(a);o.preservesPitch=!0,o.playbackRate=r,e={audio:o,url:a,done:i},o.onended=t,o.onerror=t,o.play().catch(t)})},stop(){e&&e.audio.pause(),t()}}}var zz=Rz;async function Bz(e,t,n,r){if(e.length===0)return;let i=t(e[0],0);for(let a=0;a<e.length;a+=1){if(r.signal.aborted)return;let o=await i;if(r.signal.aborted)return;i=a+1<e.length?t(e[a+1],a+1):null,i?.catch(()=>void 0),r.onItem?.(a),await n.play(o,r.playbackRate??1)}}var Vz={range:`all`,from:``,to:``},Hz=`oonacode.aboutBriefing.v1`,Uz=/^\d{4}-\d{2}-\d{2}$/;function Wz(e){let t=e&&typeof e==`object`?e:{};return{range:yu(t.range)?t.range:Vz.range,from:typeof t.from==`string`&&Uz.test(t.from)?t.from:``,to:typeof t.to==`string`&&Uz.test(t.to)?t.to:``}}function Gz(){try{let e=window.localStorage.getItem(Hz);return Wz(e?JSON.parse(e):null)}catch{return{...Vz}}}function Kz(e){try{window.localStorage.setItem(Hz,JSON.stringify(e))}catch{}}function qz(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t.has(r)&&(n+=1);return n===0?`none`:n===e.length?`all`:`some`}function Jz(e,t){let n=new Set(t);if(qz(e,t)===`all`)for(let t of e)n.delete(t);else for(let t of e)n.add(t);return n}function Yz(e,t){let n=new Set(t),r=!1;for(let t of e)n.has(t)||(r=!0);return r?new Set([...e].filter(e=>n.has(e))):e}function Xz(e,t){let n=[];if(e>0&&n.push(`${e} of the picked chats ${e===1?`has`:`have`} no about yet`),t>0){let r=e>0?`${t}`:`${t} of the picked chats`;n.push(`${r} ${t===1?`has an about`:`have abouts`} older than the chat’s last change`)}let r=[e>0?`a chat with no about is announced by its name and “no summary yet”`:null,t>0?`an older about is read as it is`:null].filter(Boolean).join(`, and `);return`${n.join(`; `)}. Writing them is one housekeeper call per chat, paid by the chat’s own route — credits for an OonaCode pool chat. Until then ${r}.`}var Zz={status:`idle`,index:-1,total:0,sessionId:null,title:null,part:0,error:null,playlist:[]};function Qz(e){return e.status===`preparing`||e.status===`speaking`||e.status===`paused`}var $z={afterNameMs:_u.afterNameMs,betweenChatsMs:_u.betweenChatsMs};function eB(e,t){return new Promise(n=>{if(t.aborted||e<=0){n();return}let r=()=>{clearTimeout(i),t.removeEventListener(`abort`,r),n()},i=setTimeout(r,e);t.addEventListener(`abort`,r,{once:!0})})}function tB(e,t){return t.aborted?Promise.reject(Error(`stopped`)):new Promise((n,r)=>{let i=()=>r(Error(`stopped`));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}var nB=class{#e;#t=[];#n=Zz;#r=null;#i=new Map;#a=new AbortController;constructor(e){this.#e=e}get state(){return this.#n}start(e,t=0){if(this.#t=[...e],this.#i.clear(),this.#t.length===0){this.#o(),this.#s({...Zz});return}this.#l(Math.max(0,Math.min(t,this.#t.length-1)),0)}pause(){(this.#n.status===`preparing`||this.#n.status===`speaking`)&&(this.#o(),this.#s({status:`paused`}))}resume(){let e=this.#n;e.index<0||this.#t.length===0||(e.status===`paused`?this.#l(e.index,e.part):e.status===`error`&&this.#l(e.index,0))}stop(){this.#o(),this.#n.status!==`idle`&&this.#n.status!==`stopped`&&this.#s({status:`stopped`,index:-1,part:0,error:null})}reset(){this.#o(),this.#t=[],this.#i.clear(),this.#n!==Zz&&(this.#n=Zz,this.#e.onState(Zz))}next(){if(this.#t.length===0||this.#n.index<0)return;let e=this.#n.index+1;if(e>=this.#t.length){this.#o(),this.#s({status:`done`,part:0});return}this.#l(e,0)}previous(){this.#t.length===0||this.#n.index<0||this.#l(Math.max(0,this.#n.index-1),0)}jumpTo(e){let t=this.#t.findIndex(t=>t.sessionId===e);t>=0&&this.#l(t,0)}resetWords(){this.#i.clear()}dispose(){this.reset(),this.#a.abort()}#o(){let e=this.#r;if(this.#r=null,e){e.abort();try{this.#e.silence()}catch{}}}#s(e){let t={...this.#n,...e},n=t.index>=0?this.#t[t.index]:void 0;t.total=this.#t.length,t.sessionId=n?.sessionId??null,t.title=n?.title??null,t.playlist=t.playlist.length===this.#t.length&&t.playlist.every((e,t)=>e===this.#t[t].sessionId)?t.playlist:this.#t.map(e=>e.sessionId),this.#n=t,this.#e.onState(t)}#c(e){let t=this.#t[e],n=this.#i.get(t.sessionId);if(n)return n;let r=this.#e.words(t,this.#a.signal);return this.#i.set(t.sessionId,r),r.catch(()=>{this.#i.get(t.sessionId)===r&&this.#i.delete(t.sessionId)}),r}#l(e,t){this.#o();let n=new AbortController;this.#r=n,this.#u(e,t,n.signal)}async#u(e,t,n){let r=this.#e.sleep??eB,i=this.#e.afterNameMs??$z.afterNameMs,a=this.#e.betweenChatsMs??$z.betweenChatsMs,o=e;try{for(;o<this.#t.length;o+=1){let s=o===e?t:0;this.#s({status:`preparing`,index:o,part:s,error:null});let c=await tB(this.#c(o),n);if(n.aborted)return;o+1<this.#t.length&&this.#c(o+1).catch(()=>void 0);let l=+!!c.name;if(c.name&&s===0&&(this.#s({status:`speaking`,part:0}),await this.#e.speak([c.name],{signal:n,onItem:()=>void 0}),n.aborted||(c.body.length>0&&await r(i,n),n.aborted)))return;let u=Math.max(0,s-l),d=c.body.slice(u);if(d.length>0&&(this.#s({status:`speaking`,part:l+u}),await this.#e.speak(d,{signal:n,onItem:e=>{n.aborted||this.#s({status:`speaking`,part:l+u+e})}}),n.aborted)||o+1<this.#t.length&&(await r(a,n),n.aborted))return}this.#r?.signal===n&&(this.#r=null),this.#s({status:`done`,index:this.#t.length-1,part:0})}catch(e){if(n.aborted)return;this.#r?.signal===n&&(this.#r=null);try{this.#e.silence()}catch{}let t=this.#t[o]?.title??`a chat`,r=e instanceof Error?e.message:String(e);this.#s({status:`error`,index:Math.min(o,this.#t.length-1),part:0,error:`${t}: ${r}`})}}};async function rB(e,t){let{voice:n,language:r,speed:i,tts:a,signal:o,onItem:s}=t,c=n?bz(n):null;if(c&&a){await Bz(e,async e=>{let n=await a.speak({voiceId:c,text:t.prepare(e,r.code),speed:i});return Lz(n.samples,n.sampleRate)},t.player,{signal:o,onItem:s});return}if(n?.kind===`system`){if(!t.synth)throw Error(`This window has no system speech.`);await Nz(t.synth,t.makeUtterance,e,{voiceURI:n.key.slice(7),bcp47:r.bcp47,rate:i,mode:Az(t.platform),signal:o,onItem:s});return}throw Error(kz(r,!!a,t.platform,t.espeakMissing))}function iB(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{if(!e||typeof window>`u`||!window.speechSynthesis)return;let t=window.speechSynthesis,r=()=>n(t.getVoices());return r(),t.addEventListener?.(`voiceschanged`,r),()=>t.removeEventListener?.(`voiceschanged`,r)},[e]),t}function aB(e){let t=e instanceof Error?e.message:String(e);return/no route for|not_found|404/i.test(t)&&/voice/i.test(t)?`This PC’s OonaCode host does not know "Listen" yet — update OonaCode.`:t}function oB({open:e,onClose:t}){let{state:n,api:r}=K(),i=n.voiceSummarySessionId,a=(0,v.useMemo)(()=>n.sessions.find(e=>e.id===i)??null,[n.sessions,i]),o=typeof window<`u`?window.oonacode?.tts:void 0,s=Oz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[c,l]=(0,v.useState)(()=>_z()),[u,d]=(0,v.useState)(null),f=iB(e),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)({kind:`idle`}),[S,C]=(0,v.useState)(null),w=(0,v.useRef)(null),T=Ou(c.language)??Ou(`en`),E=(0,v.useCallback)(e=>{l(t=>{let n={...t,...e};return vz(n),n})},[]),D=p?.summaries??[],O=D.find(e=>e.id===_)??D[0]??null,k=(0,v.useCallback)(async()=>{if(!i||!r.listVoiceSummaries)return null;try{let e=await r.listVoiceSummaries(i);return m(e),g(null),e}catch(e){return g(aB(e)),null}},[r,i]);(0,v.useEffect)(()=>{e&&(m(null),y(null),C(null),x({kind:`idle`}),k(),o?(d(null),o.listVoices().then(d,()=>d([]))):d([]))},[e,k,o]);let A=a?`${a.entryCount}:${a.mtime}`:null,j=(0,v.useRef)(null),M=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!e){j.current=null;return}if(j.current===null){j.current=A;return}A!==j.current&&(j.current=A,!M.current&&(M.current=setTimeout(()=>{M.current=null,k()},800)))},[e,A,k]),(0,v.useEffect)(()=>()=>{M.current&&clearTimeout(M.current),M.current=null},[]);let N=(0,v.useCallback)(()=>{let e=w.current;w.current=null,e&&(e.abort.abort(),e.stop())},[]);(0,v.useEffect)(()=>{e||N()},[e,N]),(0,v.useEffect)(()=>()=>N(),[N]);let ee=(0,v.useMemo)(()=>Ez(T,u??[],f),[T,u,f]),te=Dz(ee,c.localVoice[T.code]),P=!!(o&&u&&!u.some(e=>e.engine===`espeak`)),F=b.kind===`summarising`||b.kind===`translating`||b.kind===`speaking`,ne=!!(r.listVoiceSummaries&&r.createVoiceSummary),re=async()=>{if(!i||!r.createVoiceSummary)return null;x({kind:`summarising`});let e=await r.createVoiceSummary(i,{words:c.words});return C(e.created?null:yd.unchanged(Pz(e.summary.createdAt))),y(e.summary.id),await k(),e.summary},ie=async()=>{if(!i)return;N();let e=new AbortController,t=zz(),n=()=>{try{window.speechSynthesis?.cancel()}catch{}};w.current={abort:e,stop:()=>{t.stop(),n()}};let a=e.signal;try{let e=md(p,_)?await re():O;if(a.aborted)return;if(!e)throw Error(`There is no summary to play.`);let n=gd(e,T.code);if(n===null){if(!r.translateVoiceSummary)throw Error(`This host cannot translate yet.`);x({kind:`translating`});let t=await r.translateVoiceSummary(i,e.id,{language:T.code});if(m(n=>sB(n,e.id,t.translation)),a.aborted)return;n=t.translation.text,k()}let l=Yu(n);if(l.length===0)throw Error(`There was nothing to read.`);let u=e=>x({kind:`speaking`,index:e+1,total:l.length}),d=te?bz(te):null;if(d&&o)await Bz(l,async e=>{let t=await o.speak({voiceId:d,text:pd(e,T.code),speed:c.speed});return Lz(t.samples,t.sampleRate)},t,{signal:a,onItem:u});else if(te?.kind===`system`){let e=typeof window<`u`?window.speechSynthesis:void 0;if(!e)throw Error(`This window has no system speech.`);await Nz(e,e=>new SpeechSynthesisUtterance(e),l,{voiceURI:te.key.slice(7),bcp47:T.bcp47,rate:c.speed,mode:Az(s),signal:a,onItem:u})}else throw Error(kz(T,!!o,s,P));if(a.aborted)return;x({kind:`done`})}catch(e){if(a.aborted)return;x({kind:`error`,message:aB(e)})}finally{w.current?.abort===e&&(w.current=null)}},I=()=>{N(),x({kind:`stopped`})},L=async e=>{if(!(!i||!r.deleteVoiceSummary))try{await r.deleteVoiceSummary(i,e),_===e&&y(null),await k()}catch(e){x({kind:`error`,message:aB(e)})}};if(!e)return null;let R=a?Rl(a):`this chat`,ae=O?gd(O,T.code):null,oe=O?new Set(hd(O)):new Set;return(0,G.jsx)(Vy,{open:e,title:`Listen to this chat`,onClose:t,wide:!0,footer:(0,G.jsxs)(G.Fragment,{children:[F?(0,G.jsxs)(Y,{onClick:I,"data-testid":`voice-stop`,children:[(0,G.jsx)(J.Stop,{className:`h-4 w-4`}),` Stop`]}):null,(0,G.jsxs)(Y,{variant:`primary`,onClick:()=>void ie(),disabled:F||!ne||!i,"data-testid":`voice-play`,children:[(0,G.jsx)(J.Play,{className:`h-4 w-4`}),` Play`]}),(0,G.jsx)(Y,{onClick:t,children:`Close`})]}),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`A spoken summary of `,(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:R}),` — its goal, what was done, where it stands and what is pending — written by the chat’s own model, in English. Other languages are translated once by `,ku.label,` on your OonaCode credits and kept with the summary.`]}),ne?null:(0,G.jsx)(`p`,{className:`text-danger`,children:`This version of the host cannot make voice summaries.`}),(0,G.jsxs)(`section`,{"data-testid":`voice-summaries`,children:[(0,G.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Summaries`}),h?(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:h}):null,p&&D.length===0?(0,G.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-no-summaries`,children:yd.noSummaries}):null,D.length>0&&md(p,_)?(0,G.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,"data-testid":`voice-changed`,children:yd.changedSinceNewest}):null,(0,G.jsx)(`ul`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:D.map(e=>{let t=O?.id===e.id;return(0,G.jsxs)(`li`,{"data-testid":`voice-summary-row`,className:W(`flex items-start gap-2 rounded-md border px-2 py-1.5`,t?`border-accent bg-accent/10`:`border-border`),children:[(0,G.jsx)(`input`,{type:`radio`,name:`voice-summary`,className:`mt-1`,"aria-label":`Summary of ${Pz(e.createdAt)}`,checked:t,disabled:F,onChange:()=>y(e.id)}),(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 flex-col items-start text-left`,disabled:F,onClick:()=>y(e.id),children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[Pz(e.createdAt),e.current?(0,G.jsx)(`span`,{className:`ml-2 rounded-full bg-accent/15 px-1.5 text-xs text-accent`,children:`current`}):null]}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.words,` words · about `,_d(e.seconds),` ·`,` `,hd(e).map(e=>e.toUpperCase()).join(` `),` `,`· `,e.cost.model??`the chat’s model`,` · `,vd(e.cost)]})]}),(0,G.jsx)(Y,{size:`sm`,onClick:()=>void L(e.id),disabled:F,"aria-label":`Delete the summary of ${Pz(e.createdAt)}`,"data-testid":`voice-summary-delete`,children:(0,G.jsx)(J.Trash,{className:`h-3.5 w-3.5`})})]},e.id)})}),S?(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`voice-notice`,children:S}):null]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,G.jsx)(zy,{label:`Language`,children:(0,G.jsx)(`select`,{"aria-label":`Language`,className:By,value:T.code,disabled:F,onChange:e=>E({language:e.target.value}),children:Du.map(e=>{let t=e.name===e.native?e.name:`${e.name} — ${e.native}`;return(0,G.jsx)(`option`,{value:e.code,children:oe.has(e.code)?`${t} ✓`:t},e.code)})})}),o&&u===null?(0,G.jsx)(`p`,{className:`px-1 py-2 text-fg-muted`,"data-testid":`voice-loading`,children:`Looking for this PC’s voices…`}):ee.length>0?(0,G.jsx)(zy,{label:`Voice`,children:(0,G.jsx)(`select`,{"aria-label":`Voice`,className:By,value:te?.key??``,disabled:F,onChange:e=>E({localVoice:{...c.localVoice,[T.code]:e.target.value}}),children:ee.map(e=>(0,G.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,G.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-fg-muted`,"data-testid":`no-local-voice`,children:kz(T,!!o,s,P)}),(0,G.jsx)(zy,{label:`Speed ×${c.speed.toFixed(2)}`,children:(0,G.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:ju.speed.min,max:ju.speed.max,step:.05,value:c.speed,disabled:F,onChange:e=>E({speed:Number(e.target.value)})})}),(0,G.jsx)(zy,{label:`Length of a new summary`,children:(0,G.jsxs)(`select`,{"aria-label":`Length of a new summary`,className:By,value:String(c.words),disabled:F,onChange:e=>E({words:Number(e.target.value)}),children:[(0,G.jsx)(`option`,{value:`120`,children:`Short — about 120 words`}),(0,G.jsx)(`option`,{value:`200`,children:`Normal — about 200 words`}),(0,G.jsx)(`option`,{value:`300`,children:`Long — about 300 words`}),[120,200,300].includes(c.words)?null:(0,G.jsxs)(`option`,{value:String(c.words),children:[c.words,` words`]})]})})]}),(0,G.jsx)(cB,{stage:b}),O?(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:yd.heading(T,ae!==null)}),(0,G.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md border border-border bg-surface-2 px-3 py-2`,"data-testid":`voice-summary-text`,dir:ae!==null&&T.rtl?`rtl`:`ltr`,lang:ae===null?`en-US`:T.bcp47,children:ae??O.text})]}):null]})})}function sB(e,t,n){return e&&{...e,summaries:e.summaries.map(e=>e.id===t?{...e,translations:[...e.translations.filter(e=>e.language!==n.language),n]}:e)}}function cB({stage:e}){let t=[{key:`summarising`,label:yd.generating},{key:`translating`,label:yd.translating},{key:`speaking`,label:`Speaking`}];if(e.kind===`idle`)return null;if(e.kind===`error`)return(0,G.jsx)(`p`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-danger`,role:`alert`,"data-testid":`voice-stage`,children:e.message});if(e.kind===`stopped`||e.kind===`done`)return(0,G.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-stage`,children:e.kind===`stopped`?`Stopped.`:`Done.`});let n=t.findIndex(t=>t.key===e.kind);return(0,G.jsx)(`ol`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`voice-stage`,"aria-live":`polite`,children:t.map((t,r)=>(0,G.jsx)(`li`,{className:W(`rounded-full px-2 py-0.5`,r===n?`bg-accent/15 font-medium text-accent`:r<n?`text-fg-muted line-through`:`text-fg-faint`),children:t.key===`speaking`&&e.kind===`speaking`?`Speaking ${e.index} of ${e.total}`:t.label},t.key))})}function lB(e){return Ku(e).replace(/\n+/g,` `).trim()||e.trim()}function uB(e){let t=e instanceof Error?e.message:String(e);return/no route for|404/i.test(t)&&/about/i.test(t)?`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`:t}function dB(e){return{sessionId:e.sessionId,title:e.title.trim()||`Untitled chat`,about:e.about}}function fB(e){return e.filter(e=>!e.pending&&e.source!==`user`&&(!e.about||e.stale))}function pB({open:e,picked:t}){let{api:n}=K(),r=(0,v.useRef)(n);r.current=n;let i=typeof window<`u`?window.oonacode?.tts:void 0,a=Oz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[o,s]=(0,v.useState)(()=>_z()),[c,l]=(0,v.useState)(null),u=iB(e),d=Ou(o.language)??Ou(`en`),f=(0,v.useMemo)(()=>Ez(d,c??[],u),[d,c,u]),p=Dz(f,o.localVoice[d.code]),m=!!(i&&c&&!c.some(e=>e.engine===`espeak`)),[h,g]=(0,v.useState)(Zz),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(!1),w=(0,v.useRef)({lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i});w.current={lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i};let T=(0,v.useCallback)(e=>{s(t=>{let n={...t,...e};return vz(n),n})},[]),E=(0,v.useMemo)(()=>{let e=zz();return new nB({words:async e=>{let{lang:t}=w.current;if(!e.about)return{name:lB(e.title),body:[wu(t.code)]};if(t.code===`en`)return{name:lB(e.title),body:Yu(Ku(e.about))};let n=r.current.translateChatAbout;if(!n)throw Error(`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`);try{let r=await n(e.sessionId,{language:t.code});return r.created&&x(e=>e+1),{name:r.translation.name?lB(r.translation.name):null,body:Yu(r.translation.text)}}catch(e){throw Error(`could not translate it: ${uB(e)}`)}},speak:(t,{signal:n,onItem:r})=>{let i=w.current;return rB(t,{voice:i.voice,language:i.lang,speed:i.speed,tts:i.tts,player:e,synth:typeof window<`u`?window.speechSynthesis:void 0,makeUtterance:e=>new SpeechSynthesisUtterance(e),platform:i.platform,espeakMissing:i.espeakMissing,prepare:pd,signal:n,onItem:r})},silence:()=>{e.stop();try{typeof window<`u`&&window.speechSynthesis?.cancel()}catch{}},onState:g})},[]);(0,v.useEffect)(()=>{if(!e){E.reset();return}s(_z()),i?(l(null),i.listVoices().then(l,()=>l([]))):l([])},[e,i,E]),(0,v.useEffect)(()=>()=>E.dispose(),[E]),(0,v.useEffect)(()=>{E.resetWords()},[d.code,E]);let D=t.map(e=>`${e.sessionId}\u0000${e.title}\u0000${e.about??``}`).join(``);(0,v.useEffect)(()=>{C(!1)},[D,d.code]),(0,v.useEffect)(()=>{let r=n.planChatAboutTranslations;if(!e||d.code===`en`||t.length===0||!r){y(null);return}let i=!0;return r({language:d.code,sessionIds:t.map(e=>e.sessionId)}).then(e=>i&&y(e),()=>i&&y(null)),()=>{i=!1}},[e,d.code,D,b,n]);let O=h.status===`preparing`||h.status===`speaking`,k=d.code!==`en`&&_!==null&&_.language===d.code&&_.needed>_u.confirmAbove,A=(0,v.useCallback)(()=>{C(!1),E.start(t.map(dB),0)},[E,t]),j=(0,v.useCallback)(()=>{if(t.length!==0){if(k&&!S){C(!0);return}A()}},[t.length,k,S,A]);return{prefs:o,update:T,lang:d,options:f,voice:p,espeakMissing:m,voicesLoading:!!i&&c===null,desktop:!!i,platform:a,state:h,busy:O,active:Qz(h),plan:_&&_.language===d.code?_:null,confirming:S,play:j,start:A,cancelConfirm:()=>C(!1),pause:()=>E.pause(),resume:()=>E.resume(),stop:()=>E.stop(),next:()=>E.next(),previous:()=>E.previous(),jumpTo:e=>E.jumpTo(e),pickedCount:t.length}}function mB({b:e,picked:t,enabled:n,generateAll:r,onGenerated:i}){let{api:a}=K(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=fB(t),d=u.filter(e=>!e.about).length,f=u.length-d,p=r?.running===!0,m=async()=>{if(a.generateChatAbouts){s(!0),l(null);try{i((await a.generateChatAbouts({sessionIds:u.map(e=>e.sessionId)})).generateAll)}catch(e){l(uB(e))}finally{s(!1)}}},h=e.busy;return(0,G.jsxs)(`section`,{className:`space-y-2 rounded-md border border-border px-3 py-2`,"data-testid":`briefing-panel`,"aria-label":`Listen to the picked chats`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Listen to the picked chats`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick chats below, then Play: each chat’s name, then its about, one after another. Another language is translated once by `,ku.label,` on your OonaCode credits and kept, so playing it again costs nothing.`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,G.jsx)(zy,{label:`Language`,children:(0,G.jsx)(`select`,{"aria-label":`Language`,className:By,value:e.lang.code,disabled:h,onChange:t=>e.update({language:t.target.value}),"data-testid":`briefing-language`,children:Du.map(e=>(0,G.jsx)(`option`,{value:e.code,children:e.name===e.native?e.name:`${e.name} — ${e.native}`},e.code))})}),e.voicesLoading?(0,G.jsx)(`p`,{className:`px-1 py-2 text-xs text-fg-muted`,"data-testid":`briefing-voices-loading`,children:`Looking for this PC’s voices…`}):e.options.length>0?(0,G.jsx)(zy,{label:`Voice`,children:(0,G.jsx)(`select`,{"aria-label":`Voice`,className:By,value:e.voice?.key??``,disabled:h,onChange:t=>e.update({localVoice:{...e.prefs.localVoice,[e.lang.code]:t.target.value}}),"data-testid":`briefing-voice`,children:e.options.map(e=>(0,G.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,G.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-2 py-1.5 text-xs text-fg-muted sm:col-span-2`,"data-testid":`briefing-no-voice`,children:kz(e.lang,e.desktop,e.platform,e.espeakMissing)}),(0,G.jsx)(zy,{label:`Speed ×${e.prefs.speed.toFixed(2)}`,children:(0,G.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:ju.speed.min,max:ju.speed.max,step:.05,value:e.prefs.speed,disabled:h,onChange:t=>e.update({speed:Number(t.target.value)})})})]}),e.plan&&t.length>0?(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`briefing-cost`,children:[Eu(e.plan,e.lang.name),e.plan.needed>0?` — paid once, then kept.`:``]}):null,e.confirming&&e.plan?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-warn/50 bg-warn-soft px-2 py-1.5 text-xs text-fg`,role:`alert`,"data-testid":`briefing-confirm`,children:[(0,G.jsxs)(`p`,{className:`basis-full`,children:[`Before playing: `,Eu(e.plan,e.lang.name),` — paid once from your OonaCode credits, then kept.`]}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:e.start,"data-testid":`briefing-confirm-play`,children:`Translate and play`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:e.cancelConfirm,children:`Cancel`})]}):null,u.length>0&&a.generateChatAbouts?(0,G.jsxs)(`div`,{className:`space-y-1.5 text-xs`,"data-testid":`briefing-need-about`,children:[(0,G.jsx)(`p`,{className:`text-fg-muted`,children:Xz(d,f)}),(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void m(),busy:o,disabled:!n||p||e.busy,title:n?void 0:`Chat abouts are off — turn them on above.`,"data-testid":`briefing-write-first`,children:[(0,G.jsx)(J.Refresh,{className:`h-3 w-3`}),` Write abouts for these first`]})]}):null,c?(0,G.jsx)(`p`,{className:`text-xs text-danger`,"data-testid":`briefing-write-error`,children:c}):null]})}function hB({b:e}){let t=e.state,n=t.index>=0?` (${t.index+1} of ${t.total})`:``,r=null;return t.status===`preparing`?r=`Now: ${t.title??``}${n} — ${e.lang.code===`en`?`getting ready…`:`translating…`}`:t.status===`speaking`?r=`Now: ${t.title??``}${n}`:t.status===`paused`?r=`Paused: ${t.title??``}${n}`:t.status===`done`?r=`Finished — ${t.total} chat${t.total===1?``:`s`} read.`:t.status===`stopped`?r=`Stopped.`:t.status===`error`&&(r=t.error),(0,G.jsxs)(G.Fragment,{children:[r?(0,G.jsx)(`p`,{className:W(`mr-auto min-w-0 basis-full truncate text-xs sm:basis-auto sm:flex-1`,t.status===`error`?`text-danger`:`text-fg-muted`),title:r,"aria-live":`polite`,"data-testid":`briefing-now`,children:r}):null,e.active||t.status===`error`?(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,onClick:e.previous,disabled:t.status===`error`,"aria-label":`Previous chat`,title:`Previous chat`,"data-testid":`briefing-previous`,children:(0,G.jsx)(J.SkipBack,{className:`h-3.5 w-3.5`})}),t.status===`paused`||t.status===`error`?(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:e.resume,"data-testid":`briefing-resume`,children:[(0,G.jsx)(J.Play,{className:`h-3.5 w-3.5`}),` `,t.status===`error`?`Try again`:`Resume`]}):(0,G.jsxs)(Y,{size:`sm`,onClick:e.pause,"data-testid":`briefing-pause`,children:[(0,G.jsx)(J.Pause,{className:`h-3.5 w-3.5`}),` Pause`]}),(0,G.jsxs)(Y,{size:`sm`,onClick:e.stop,"data-testid":`briefing-stop`,children:[(0,G.jsx)(J.Stop,{className:`h-3.5 w-3.5`}),` Stop`]}),(0,G.jsx)(Y,{size:`sm`,onClick:e.next,disabled:t.status===`error`,"aria-label":`Next chat`,title:`Next chat`,"data-testid":`briefing-next`,children:(0,G.jsx)(J.SkipForward,{className:`h-3.5 w-3.5`})})]}):(0,G.jsxs)(Y,{variant:`primary`,onClick:e.play,disabled:e.pickedCount===0||e.voice===null||e.voicesLoading,title:e.pickedCount===0?`Tick the chats to hear first`:void 0,"data-testid":`briefing-play`,children:[(0,G.jsx)(J.Play,{className:`h-4 w-4`}),` Play `,e.pickedCount,` picked`]})]})}function gB({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.chatAboutsChange,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(-1),[C,w]=(0,v.useState)(()=>Gz()),[T,E]=(0,v.useState)(()=>new Set),[D,O]=(0,v.useState)(()=>Date.now()),k=(0,v.useCallback)(async()=>{let e=await r.listChatAbouts();if(e===`unsupported`){c(!0);return}if(e===null){u(!0);return}c(!1),u(!1),o(e),f(e.generateAll)},[r]);(0,v.useEffect)(()=>{e&&(S.current=i.seq,O(Date.now()),k())},[e]);let A=e=>{w(t=>{let n={...t,...e};return Kz(n),n}),O(Date.now())};(0,v.useEffect)(()=>{!e||i.seq===S.current||(S.current=i.seq,i.generateAll!==void 0&&f(i.generateAll),k())},[e,i,k]);let j=n.settings?.chatAboutEnabled??a?.settings.enabled??Ul.enabled,M=async e=>{x(!0);try{await r.saveSettings({chatAboutEnabled:e})}finally{x(!1)}k()},N=async()=>{g(!0);try{let e=await r.generateAllChatAbouts();e&&f(e.generateAll)}finally{g(!1)}},ee=async()=>{y(!0);try{let e=await r.stopGenerateAllChatAbouts();e&&f(e.generateAll)}finally{y(!1)}},te=(0,v.useMemo)(()=>xu(C.range,D,{from:C.from,to:C.to}),[C,D]),P=(0,v.useMemo)(()=>{let e=(a?.chats??[]).filter(e=>Su(e.updatedAt,te)),t=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return[...e].sort((e,n)=>t(n)-t(e))},[a,te]),F=(0,v.useMemo)(()=>{let e=p.trim().toLowerCase();return e?P.filter(t=>t.title.toLowerCase().includes(e)||(t.about??``).toLowerCase().includes(e)):P},[P,p]),ne=(0,v.useMemo)(()=>F.map(e=>e.sessionId),[F]),re=ne.join(`,`);(0,v.useEffect)(()=>{E(e=>Yz(e,ne))},[re]);let ie=(0,v.useMemo)(()=>F.filter(e=>T.has(e.sessionId)),[F,T]),I=qz(ne,T),L=(0,v.useRef)(null);(0,v.useEffect)(()=>{L.current&&(L.current.indeterminate=I===`some`)});let R=pB({open:e,picked:ie}),ae=R.active||R.state.status===`error`,oe=(0,v.useMemo)(()=>new Set(R.state.playlist),[R.state.playlist]),se=ae?R.state.sessionId:null,ce=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),le=vu.find(e=>e.id===C.range)?.label??``,ue=(0,v.useCallback)(e=>n.sessions.find(t=>t.id===e)?.entryCount??null,[n.sessions]),de=a?du(a.totals):null,fe=d?.running===!0;return(0,G.jsxs)(Vy,{open:e,title:`What your chats are about`,onClose:t,wide:!0,footer:(0,G.jsxs)(G.Fragment,{children:[a!==null&&!s?(0,G.jsx)(hB,{b:R}):null,(0,G.jsx)(Y,{variant:`ghost`,onClick:t,children:`Close`})]}),children:[(0,G.jsxs)(`p`,{className:`mb-3 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`min-w-0`,children:`A short note per chat on this PC saying what it works on, so your other chats can tell which one to ask.`}),(0,G.jsx)(Ly,{label:`What your chats are about`,details:(0,G.jsx)(Ry,{items:[...gu.what,...gu.when,...gu.who,...gu.yours,...gu.where]})})]}),s?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-unsupported`,children:`OonaCode on this PC is too old for chat abouts. Update it, then open this window again.`}):a===null?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-loading`,children:l?`Could not read the abouts from this PC right now. They show here as soon as it answers.`:`Loading…`}):(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`div`,{className:`rounded-md border border-border px-3`,children:(0,G.jsx)(Hy,{label:`Write an about for every chat`,hint:j?`On: each chat’s housekeeper model writes its about in the background.`:`Off: nothing is written and nothing is spent. Regenerate and “Generate for all chats now” are unavailable.`,details:[gu.switch,...gu.who],checked:j,disabled:b,onChange:e=>void M(e),testId:`chat-abouts-switch`})}),de?(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`chat-abouts-totals`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:`All about calls so far: `}),(0,G.jsx)(`span`,{"data-testid":`chat-abouts-totals-line`,children:de.line}),de.unpriced?(0,G.jsx)(`span`,{className:`block text-fg-faint`,"data-testid":`chat-abouts-totals-unpriced`,children:de.unpriced}):null]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:()=>void N(),busy:h,disabled:!j||fe,title:j?gu.generateAll:gu.regenerateOff,"data-testid":`chat-abouts-generate-all`,children:[(0,G.jsx)(J.Refresh,{className:`h-3 w-3`}),` Generate for all chats now`]}),(0,G.jsx)(Ly,{label:`Generate for all chats now`,details:gu.generateAll})]}),fe?(0,G.jsxs)(Y,{size:`sm`,variant:`danger`,onClick:()=>void ee(),busy:_,title:gu.stop,"data-testid":`chat-abouts-stop`,children:[(0,G.jsx)(J.Stop,{className:`h-3 w-3`}),` Stop`]}):null]}),d?(0,G.jsx)(_B,{g:d}):null,(0,G.jsx)(mB,{b:R,picked:ie,enabled:j,generateAll:d,onGenerated:f}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,G.jsx)(`select`,{"aria-label":`Last active`,className:W(By,`text-xs`),value:C.range,onChange:e=>A({range:e.target.value}),"data-testid":`chat-abouts-range`,children:vu.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),C.range===`custom`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,G.jsx)(`input`,{type:`date`,"aria-label":`From`,className:W(Z,`text-xs`),value:C.from,onChange:e=>A({from:e.target.value}),"data-testid":`chat-abouts-from`})]}),(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,G.jsx)(`input`,{type:`date`,"aria-label":`To`,className:W(Z,`text-xs`),value:C.to,onChange:e=>A({to:e.target.value}),"data-testid":`chat-abouts-to`})]})]}):null,(0,G.jsx)(`input`,{className:W(Z,`min-w-[10rem] flex-1 basis-40 text-xs`),type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Find a chat by its title or its about`,"aria-label":`Find a chat by its title or its about`,"data-testid":`chat-abouts-filter`})]}),F.length>0?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,G.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,G.jsx)(`input`,{ref:L,type:`checkbox`,checked:I===`all`,"aria-checked":I===`some`?`mixed`:I===`all`,onChange:()=>E(e=>Jz(ne,e)),"data-testid":`chat-abouts-select-all`}),`Select all`]}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`chat-abouts-count`,children:[F.length,` chat`,F.length===1?``:`s`,ie.length>0?` · ${ie.length} picked`:``]})]}):null,a.chats.length===0?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-empty`,children:`No chats on this PC yet.`}):F.length===0?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-no-match`,children:p.trim()?`No chat matches “${p.trim()}”${C.range===`all`?``:` in ${le.toLowerCase()}`}.`:`No chat was active in ${C.range===`custom`?`that range`:le.toLowerCase()}.`}):(0,G.jsx)(`ul`,{className:`space-y-2`,"data-testid":`chat-abouts-list`,children:F.map(e=>(0,G.jsx)(vB,{row:e,enabled:j,entryCount:ue(e.sessionId),checked:T.has(e.sessionId),onToggle:()=>ce(e.sessionId),playing:se===e.sessionId,onJump:ae&&oe.has(e.sessionId)?()=>R.jumpTo(e.sessionId):null,onOpen:()=>{r.selectSession(e.sessionId)}},e.sessionId))})]})]})}function _B({g:e}){let t=e.total>0?Math.round(Math.min(e.done,e.total)/e.total*100):100;return(0,G.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`chat-abouts-progress`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`chat-abouts-progress-line`,children:pu(e)}),(0,G.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Generate for all chats now`,"aria-valuemin":0,"aria-valuemax":e.total,"aria-valuenow":e.done,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,e.running?`bg-accent`:`bg-fg-faint`),style:{width:`${t}%`}})}),!e.running&&e.stoppedReason?(0,G.jsxs)(`div`,{className:`text-warn`,"data-testid":`chat-abouts-stopped-reason`,children:[`Stopped: `,e.stoppedReason]}):null]})}function vB({row:e,enabled:t,entryCount:n,checked:r,onToggle:i,playing:a,onJump:o,onOpen:s}){let c=e.title.trim()||`Untitled chat`,l=ou(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a&&u.current?.scrollIntoView?.({block:`nearest`})},[a]),(0,G.jsxs)(`li`,{ref:u,className:W(`rounded-md border px-3 py-2 text-xs`,a?`border-accent bg-accent/10`:`border-border`,o?`cursor-pointer hover:border-accent`:``),onClick:o??void 0,title:o&&!a?`Play from this chat`:void 0,"aria-current":a?`true`:void 0,"data-testid":`chat-about-row-${e.sessionId}`,"data-playing":a?`true`:void 0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`shrink-0`,checked:r,onChange:i,onClick:e=>e.stopPropagation(),"aria-label":`Pick ${c}`,"data-testid":`chat-about-pick`}),a?(0,G.jsx)(J.Speaker,{className:`h-3.5 w-3.5 text-accent`,title:`Playing`}):null,(0,G.jsx)(`button`,{type:`button`,className:`min-w-0 max-w-full truncate text-left text-sm font-medium text-fg hover:text-accent hover:underline`,onClick:e=>{e.stopPropagation(),s()},title:`Open this chat`,"data-testid":`chat-about-open`,children:c}),e.source===`user`?(0,G.jsx)(`span`,{title:gu.yours[0],children:(0,G.jsx)(Q,{tone:`accent`,children:`yours`})}):null,e.stale&&e.about?(0,G.jsx)(`span`,{title:gu.stale,"data-testid":`chat-about-stale`,children:(0,G.jsx)(Q,{tone:`warn`,children:`stale`})}):null,e.pending?(0,G.jsx)(`span`,{"data-testid":`chat-about-pending`,children:(0,G.jsx)(Q,{tone:`accent`,children:`writing…`})}):null]}),e.about?(0,G.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg`,"data-testid":`chat-about-text`,children:e.about}):null,e.about&&e.stale?(0,G.jsx)(`p`,{className:`mt-0.5 text-warn`,"data-testid":`chat-about-stale-note`,children:`The chat has moved on since this about was written.`}):null,e.about?null:(0,G.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`chat-about-missing`,children:[`No about yet. `,fu(e,{enabled:t,entryCount:n})]}),e.about&&e.lastError?(0,G.jsxs)(`p`,{className:`mt-0.5 text-danger`,"data-testid":`chat-about-error`,children:[`The last attempt failed: `,e.lastError]}):null,(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap justify-between gap-x-3 gap-y-0.5 text-[11px] text-fg-faint`,children:[(0,G.jsxs)(`span`,{title:ng(e.updatedAt),"data-testid":`chat-about-active`,children:[`Active `,eg(e.updatedAt)]}),e.about&&e.aboutAt?(0,G.jsxs)(`span`,{title:ng(e.aboutAt),"data-testid":`chat-about-written`,children:[`Written `,eg(e.aboutAt),l?` by ${l}`:``]}):(0,G.jsx)(`span`,{}),(0,G.jsx)(`span`,{title:e.route?`Paid by ${su[e.route]}`:void 0,"data-testid":`chat-about-spend`,children:uu(e.spend,e.route)})]})]})}function yB({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.assignProjectSessionId,a=i?n.sessions.find(e=>e.id===i)??null:null,o=i?n.drafts[i]??null:null,s=a?.projectId??o?.projectId??null,[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&l(s)},[e,s]);let f=a?.status===`running`||a?.status===`waiting_permission`,p=sg(a?cg(a):o?.title??`New chat`);async function m(){if(i){d(!0);try{await r.setSessionProject(i,c)&&t()}finally{d(!1)}}}return(0,G.jsxs)(Vy,{open:e,title:`Move “${p}” to a project`,onClose:t,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{variant:`ghost`,onClick:()=>{t(),r.openDialog(`projects`)},children:`Manage projects…`}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Y,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,G.jsx)(Y,{variant:`primary`,onClick:m,disabled:u||c===s,"data-testid":`assign-project-apply`,children:`Apply`})]}),children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5`,role:`radiogroup`,"aria-label":`Project`,children:[(0,G.jsx)(bB,{selected:c===null,onSelect:()=>l(null),label:`No project`,testId:`assign-project-none`}),n.vaultProjects.map(e=>(0,G.jsx)(bB,{selected:c===e.id,onSelect:()=>l(e.id),label:e.name,hint:e.instructions.trim()?`has instructions`:void 0,testId:`assign-project-${e.id}`},e.id)),n.vaultProjects.length===0?(0,G.jsxs)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:[`No projects yet — create one under `,(0,G.jsx)(`em`,{children:`Manage projects…`}),`.`]}):null]}),f?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,"data-testid":`assign-project-busy`,children:`This chat is mid-turn — it moves now and the turn is left alone. The project's instructions reach the agent at your next message.`}):(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:`The project's instructions reach the agent on the chat's next start — nothing in the conversation is lost.`})]})}function bB({selected:e,onSelect:t,label:n,hint:r,disabled:i=!1,testId:a}){return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e,onClick:t,disabled:i,className:W(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg`,i&&`cursor-not-allowed opacity-50`),"data-testid":a,children:[(0,G.jsx)(`span`,{className:W(`inline-block h-3 w-3 rounded-full border`,e?`border-accent bg-accent`:`border-border`)}),(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),r?(0,G.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:r}):null]})}var xB=`Install Google’s agy`,SB=`OonaCode downloads Google’s own agy release (about 200 MB) and checks its checksum before it uses it. Nothing from Google is bundled inside OonaCode.`,CB=`Sign in with Google`,wB=`This PC’s OonaCode is too old to run chats on Google’s agy — update it from the title bar.`,TB=`Kept on this PC only, in memory: it is gone when OonaCode stops, and it is never synced or sent anywhere.`,EB=new Set([`loadCodeAssist`,`fetchAdminControls`,`retrieveUserQuotaSummary`,`fetchUserInfo`,`fetchAvailableModels`,`listExperiments`,`writeTrajectoryAcls`,`recordTrajectoryAnalytics`]);function DB(e){return e.kind===`tunnel`||e.method!==null&&EB.has(e.method)}function OB(e){let t=[],n=[];for(let r of e)(DB(r)?n:t).push(r);return{main:t,background:n}}function kB(e){if(e.kind===`tunnel`)return{title:e.host??`tunnel`,detail:null};let t=[e.model,e.requestType===`checkpoint`?`checkpoint`:null].filter(e=>!!e).join(` · `);return{title:e.method??`Code Assist call`,detail:t||null}}function AB(e){let{title:t,detail:n}=kB(e);return n?`${t} · ${n}`:t}function jB(e){let t=e.denied||e.error!==null||e.status!==null&&e.status>=400?`danger`:`neutral`;return e.denied?{text:`denied`,tone:t}:e.status===null?e.error===null?{text:`pending`,tone:t}:{text:`error`,tone:t}:{text:String(e.status),tone:t}}var MB=e=>e.toLocaleString(`en-US`);function NB(e){if(!e)return null;let t=e.cached>0?` (${MB(e.cached)} cached)`:``;return`in ${MB(e.input)}${t} · out ${MB(e.output)}`}function PB(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function FB(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function IB(e){switch(e){case`ready`:return{label:`Ready`,tone:`ok`};case`not_installed`:return{label:`agy is not installed`,tone:`warn`};case`not_signed_in`:return{label:`Not signed in to agy`,tone:`warn`};default:return{label:`agy did not answer`,tone:`danger`}}}function LB(e){return e.newerThanTested?`This agy is newer than the version OonaCode was tested with (${e.testedVersion}). It usually keeps working; if chats on it start failing, look for an OonaCode update.`:null}function RB(e){let t=e.remainingPercent,n=t!==null&&Number.isFinite(t),r=ng(e.resetsAt);return{remaining:n?`${Math.round(Math.min(100,Math.max(0,t)))}% left`:`unknown`,tone:ic(t),resets:r?`resets ${r}`:null}}var zB=1e3,BB=2e3;function VB(e){if(!e)return null;if(e.install.state===`working`)return zB;switch(e.login.phase){case`starting`:case`verifying`:return zB;case`awaiting_code`:return BB;default:return null}}function HB(e){if(!e)return!1;if(e.install.state===`working`)return!0;let t=e.login.phase;return t===`starting`||t===`awaiting_code`||t===`verifying`}function UB(e){switch(e){case`manifest`:return`Looking up Google’s latest release…`;case`download`:return`Downloading agy…`;case`verify`:return`Checking the download…`;case`place`:return`Finishing up…`;default:return`Starting the install…`}}function WB(e){let{received:t,total:n}=e;return n===null||!Number.isFinite(n)||n<=0?null:Math.min(100,Math.max(0,Math.floor(t/n*100)))}function GB(e){let{received:t,total:n}=e;return n!==null&&n>0?`${Pj(t)} of ${Pj(n)}`:t>0?Pj(t):null}function KB(e){if(!e)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}function qB(e,t){return t?e.split(t).join(`…`):e}function JB(e,t){return e?`Status…`:t?t.state===`not_installed`?t.install.supported?`Install…`:`Status…`:t.state===`not_signed_in`?`Sign in…`:`Status…`:`Set up…`}function YB({install:e,busy:t,onInstall:n,onCancel:r}){if(e.state===`working`){let n=WB(e),i=GB(e);return(0,G.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`agy-install`,"data-install-state":`working`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg`,role:`status`,"data-testid":`agy-install-phase`,"data-phase":e.phase??void 0,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`min-w-0`,children:[UB(e.phase),e.version?` (agy ${e.version})`:``]})]}),(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Installing agy`,"aria-valuemin":0,"aria-valuemax":100,...n===null?{}:{"aria-valuenow":n},"data-indeterminate":n===null?`true`:void 0,"data-testid":`agy-install-bar`,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full bg-accent`,n===null?`w-1/3 animate-pulse`:void 0),style:n===null?void 0:{width:`${n}%`}})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-install-bytes`,children:i??``}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:t,onClick:r,"data-testid":`agy-install-cancel`,children:`Cancel`})]})]})}return e.supported?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":e.state,children:[e.state===`failed`?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-install-failed`,children:e.error??`The install did not finish.`}):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-explanation`,children:SB}),(0,G.jsxs)(Y,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":e.state===`failed`?`agy-install-retry`:`agy-install-button`,children:[(0,G.jsx)(J.Download,{className:`h-4 w-4`}),` `,e.state===`failed`?`Try again`:xB]})]}):null}function XB({login:e,busy:t,onStart:n,onCancel:r,onSubmit:i}){let[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),l=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>{l.current&&clearTimeout(l.current)},[]),(0,v.useEffect)(()=>{e.phase!==`awaiting_code`&&o(``)},[e.phase]);let u=a.trim(),d=tm(u),f=()=>{!d||t||(o(``),i(u))},p=e.phase===`awaiting_code`?KB(e.url):null,m=()=>{p&&KM(p).then(e=>{e&&(c(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>c(!1),1500))})},h=(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:t,onClick:r,"data-testid":`agy-login-cancel`,children:`Cancel`});return(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-sign-in`,"data-login-phase":e.phase,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-sign-in-explanation`,children:em}),e.phase===`starting`?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-starting`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Starting Google’s sign-in…`]}),(0,G.jsx)(`span`,{className:`flex-1`}),h]}):e.phase===`awaiting_code`?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-awaiting`,children:[e.message?(0,G.jsx)(`p`,{className:`text-xs text-fg`,children:e.message}):null,p?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs font-medium text-accent underline`,href:p,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),TR(p)},"data-testid":`agy-login-link`,children:[(0,G.jsx)(J.ExternalLink,{className:`h-3.5 w-3.5`}),` Open Google’s sign-in page`]}),(0,G.jsxs)(Y,{size:`sm`,onClick:m,"data-testid":`agy-login-copy-link`,children:[(0,G.jsx)(J.Copy,{className:`h-3.5 w-3.5`}),` `,s?`Copied`:`Copy link`]})]}):null,(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-fg`,children:[`Code from Google`,(0,G.jsx)(`input`,{className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 font-mono text-xs text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`,type:`text`,value:a,placeholder:`Paste the code Google shows you`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-form-type":`other`,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())},"data-testid":`agy-login-code`})]}),u&&!d?(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-login-code-hint`,children:`Paste the code exactly as Google shows it — one line, no spaces.`}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Y,{variant:`primary`,size:`sm`,disabled:!d||t,onClick:f,"data-testid":`agy-login-continue`,children:`Continue`}),h]})]}):e.phase===`verifying`?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-verifying`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Checking the code with Google…`]}),(0,G.jsx)(`span`,{className:`flex-1`}),h]}):e.phase===`failed`?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-failed`,children:[(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:e.message??`The sign-in did not finish.`}),(0,G.jsxs)(Y,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-restart`,children:[(0,G.jsx)(J.LogIn,{className:`h-4 w-4`}),` Start again`]})]}):(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[e.phase===`done`&&e.message?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.message}):null,(0,G.jsxs)(Y,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-button`,children:[(0,G.jsx)(J.LogIn,{className:`h-4 w-4`}),` `,CB]})]})]})}var ZB={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,neutral:`bg-surface-3`},QB={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,neutral:`text-fg-muted`};function $B({label:e,testid:t,children:n}){return(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 py-0.5 text-xs`,children:[(0,G.jsx)(`dt`,{className:`shrink-0 text-fg-faint`,children:e}),(0,G.jsx)(`dd`,{className:`min-w-0 text-right font-medium text-fg`,"data-testid":t,children:n})]})}function eV({definition:e}){let{api:t,socket:n}=K(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(!0),g=(0,v.useRef)(0),_=(0,v.useRef)(0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let y=(0,v.useCallback)(async(e,n=!1)=>{let r=++g.current;if(!t.getAgyStatus){o(!0);return}_.current+=1,n||u(e=>e+1);try{let n=await t.getAgyStatus(e?{refresh:!0}:void 0);if(!h.current||r!==g.current)return;i(n),c(null),o(!1)}catch(e){if(!h.current||r!==g.current)return;gm(e)?o(!0):c(lg(e))}finally{--_.current,!n&&h.current&&u(e=>e-1)}},[t]),b=(0,v.useCallback)(async(e,t,n=``)=>{g.current+=1,f(e),m(null);try{let e=await t();if(!h.current)return;g.current+=1,i(e),c(null),o(!1)}catch(e){if(!h.current)return;gm(e)?o(!0):(m(qB(lg(e),n)),y(!1,!0))}finally{h.current&&f(null)}},[y]);(0,v.useEffect)(()=>{y(!1)},[y]);let x=VB(r);(0,v.useEffect)(()=>{if(x===null)return;let e=setInterval(()=>{_.current===0&&y(!1,!0)},x);return()=>clearInterval(e)},[x,y]),(0,v.useEffect)(()=>n.on(`account_changed`,e=>{e.reason===`provider`&&y(!1,!0)}),[n,y]);let S=js(e);if(a)return(0,G.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,"data-testid":`agy-unsupported`,children:wB});let C=r===null&&s===null,w=l>0,T=HB(r),E=r?.install.state===`working`,D=(0,G.jsx)(Y,{variant:`primary`,size:`sm`,busy:w||C,disabled:w||C||T,onClick:()=>void y(!0),"data-testid":`agy-check-again`,children:w||C?`Checking…`:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(J.Refresh,{className:`h-3.5 w-3.5`}),` Check again`]})}),O=r?E?{label:`Installing agy…`,tone:`accent`}:IB(r.state):null;return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`agy-card`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsx)(Q,{tone:`ok`,children:S.badge}),(0,G.jsx)(Q,{children:e.kind})]}),(0,G.jsx)(`div`,{className:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`agy-route`,children:S.detail}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[O?(0,G.jsx)(`span`,{"data-testid":`agy-state`,"data-state":r?.state,children:(0,G.jsx)(Q,{tone:O.tone,children:O.label})}):C?(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,"data-testid":`agy-checking`,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5`}),` Asking agy…`]}):null,(0,G.jsx)(`span`,{className:`flex-1`}),D]}),w&&r?(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-busy-note`,children:`Asking agy again — this takes a few seconds.`}):null,s?(0,G.jsxs)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-failed`,children:[`The host could not check agy: `,s]}):null,r?(0,G.jsxs)(G.Fragment,{children:[r.state!==`ready`&&r.message&&!T?(0,G.jsx)(`p`,{className:`text-xs text-fg`,"data-testid":`agy-message`,children:r.message}):null,r.state===`not_installed`?(0,G.jsx)(YB,{install:r.install,busy:d===`install`||d===`cancel_install`,onInstall:()=>{t.agyInstall?b(`install`,()=>t.agyInstall()):o(!0)},onCancel:()=>{t.cancelAgyInstall&&b(`cancel_install`,()=>t.cancelAgyInstall())}}):null,r.state===`not_signed_in`?(0,G.jsx)(XB,{login:r.login,busy:d===`login`||d===`cancel_login`||d===`code`,onStart:()=>{t.agyLogin?b(`login`,()=>t.agyLogin()):o(!0)},onCancel:()=>{t.cancelAgyLogin&&b(`cancel_login`,()=>t.cancelAgyLogin())},onSubmit:e=>{t.submitAgyLoginCode?b(`code`,()=>t.submitAgyLoginCode(e),e):o(!0)}}):null,p?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-action-error`,children:p}):null,(0,G.jsxs)(`dl`,{className:`rounded-md border border-border px-3 py-1.5`,"data-testid":`agy-facts`,children:[(0,G.jsx)($B,{label:`Installed`,testid:`agy-installed`,children:r.installed?`Yes`:`No`}),r.path?(0,G.jsx)($B,{label:`Path`,testid:`agy-path`,children:(0,G.jsx)(`span`,{className:`break-all font-mono text-[11px]`,children:r.path})}):null,r.version?(0,G.jsx)($B,{label:`Version`,testid:`agy-version`,children:r.version}):null,(0,G.jsx)($B,{label:`Signed in`,testid:`agy-signed-in`,children:r.signedIn===null?r.installed?`Unknown`:`—`:r.signedIn?`Yes`:`No`}),(0,G.jsx)($B,{label:`Checked`,testid:`agy-checked`,children:(0,G.jsx)(`span`,{title:ng(r.checkedAt),children:eg(r.checkedAt)})})]}),LB(r)?(0,G.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,"data-testid":`agy-newer-note`,children:[(0,G.jsx)(J.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),LB(r)]}):null,r.models.length>0?(0,G.jsxs)(`div`,{"data-testid":`agy-models`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Models agy offers`}),(0,G.jsx)(`ul`,{className:`space-y-0.5`,children:r.models.map(e=>(0,G.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,"data-testid":`agy-model-${e.id}`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.displayName}),(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-faint`,children:e.id})]},e.id))})]}):null,r.usage.length>0?(0,G.jsxs)(`div`,{"data-testid":`agy-usage`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Your plan’s usage`}),(0,G.jsx)(`ul`,{className:`space-y-2`,children:r.usage.map((e,t)=>{let n=RB(e),r=e.remainingPercent;return(0,G.jsxs)(`li`,{"data-testid":`agy-usage-row-${t}`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 truncate text-fg`,children:[e.group,` · `,e.window]}),(0,G.jsx)(`span`,{className:W(`shrink-0 font-medium`,QB[n.tone]),"data-tone":n.tone,"data-testid":`agy-usage-remaining-${t}`,children:n.remaining})]}),(0,G.jsx)(`div`,{className:`mt-0.5 h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e.group} ${e.window}: ${n.remaining}`,"aria-valuemin":0,"aria-valuemax":100,...r!==null&&Number.isFinite(r)?{"aria-valuenow":Math.round(r)}:{},children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,ZB[n.tone]),style:{width:`${r!==null&&Number.isFinite(r)?Math.min(100,Math.max(0,r)):0}%`}})}),n.resets?(0,G.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:n.resets}):null]},`${e.group}-${e.window}-${t}`)})})]}):null]}):null]})}function tV(e,t){let n=e.definition.displayName;return!t||t.id===`payg`||t.id===`api-key`?[`Sign in to the ${n} console.`,`Create an API key (or copy an existing one).`,`Paste it below — OonaCode encrypts it into your vault before it leaves this PC.`]:[`Open the ${n} console and pick the ${t.label} plan.`,t.notes??`Complete the provider’s subscription/token flow in the browser.`,`Copy the token it issues${t.keyFormat?` (looks like ${t.keyFormat})`:``} and paste it below.`]}function nV(e,t){let n=e.find(e=>e.definition.id===t);if(!n)return[];let r=n.definition.clientGroup??n.definition.id,i=e.find(e=>e.definition.id===r);return i?[i,...e.filter(e=>e.definition.clientGroup===r)]:[n]}function rV(e){let t=[];for(let n of e){let e=n.definition,r=Es(e),i=e.credentialClass===`subscription`;if(r.length>1)for(let i of r)t.push({key:`${e.id}:${i.id}`,label:i.id===`token-plan`?`Subscription`:i.id===`payg`?`API`:i.label,provider:n,variantId:i.id,variant:i,isSubscription:!1,hasLoginFlow:!1,loginKind:null,keyFormat:i.keyFormat??e.keyFormat});else t.push({key:e.id,label:e.recordLabel??(i?`Subscription`:`API`),provider:n,variantId:r[0]?.id??null,variant:r[0]??null,isSubscription:i,hasLoginFlow:i&&e.route===`direct`,loginKind:i&&e.route===`direct`?e.subscriptionLogin?`oauth`:`claude`:null,keyFormat:r[0]?.keyFormat??e.keyFormat})}return t}function iV(e){let t=(e.provider.credentials??[]).filter(e=>e.class!==`none`);return(e.variantId?t.filter(t=>(t.variantId??`payg`)===e.variantId):t).slice(0,1)}function aV({open:e,providerId:t,onClose:n}){let{state:r,actions:i}=K(),a=(0,v.useMemo)(()=>t?nV(r.providers,t):[],[r.providers,t]),o=(0,v.useMemo)(()=>rV(a),[a]),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),b=o.find(e=>e.key===s)??o[0]??null;if((0,v.useEffect)(()=>{if(!e)return;let n=o.find(e=>e.provider.definition.id===t);c((n??o[0])?.key??``),u(``),m(``),y(null)},[e,t,o]),(0,v.useEffect)(()=>{if(!e||!b)return;let t=b.provider.definition;f(t.userBaseUrl?b.variant?.baseUrl??t.baseUrl:``)},[e,b,b?.key]),!b)return null;let x=b.provider.definition,S=a[0]?.definition?.displayName??x.displayName;if(x.engine===`agy`)return(0,G.jsx)(Vy,{open:e,title:S,onClose:n,footer:(0,G.jsx)(Y,{onClick:n,children:`Close`}),children:(0,G.jsx)(eV,{definition:x})});let C=iV(b),w=a.some(e=>(e.credentials??[]).some(e=>e.class!==`none`)),T=x.credentialClass!==`none`,E=js(x,{credentialClass:b.isSubscription?`subscription`:x.credentialClass,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}}),D=!h&&(!T||l.trim().length>0),O=async()=>{g(!0),y(null);try{if(!T){await i.setActiveProvider(x.id),n();return}let e=await i.probeCredential(x.id,{secret:l.trim(),variantId:b.variantId,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}});if(!e.ok){y(e.error??`${S} rejected this key — check it and try again.`);return}let t={};b.variantId&&(t.variant=b.variantId),x.userBaseUrl&&d.trim()&&(t.baseUrl=d.trim()),await i.addCredential({class:b.isSubscription?`subscription`:`api_key`,providerId:x.id,secret:l.trim(),...p.trim()?{label:p.trim()}:{},...Object.keys(t).length>0?{meta:t}:{}})&&(u(``),n())}finally{g(!1)}};return(0,G.jsx)(Vy,{open:e,title:`${w?`Manage`:`Connect`} ${S}`,onClose:n,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:n,children:`Cancel`}),b.loginKind===`oauth`?(0,G.jsxs)(Y,{onClick:()=>i.openOauthLogin(b.provider.definition.id),"data-testid":`connect-oauth-signin`,children:[(0,G.jsx)(J.LogIn,{className:`w-4 h-4`}),` `,b.provider.definition.subscriptionLogin?.signInLabel??`Sign in instead`]}):b.loginKind===`claude`?(0,G.jsxs)(Y,{onClick:()=>i.openClaudeLogin(null),"data-testid":`connect-claude-signin`,children:[(0,G.jsx)(J.LogIn,{className:`w-4 h-4`}),` Sign in instead`]}):null,(0,G.jsx)(Y,{variant:`primary`,busy:h,disabled:!D,onClick:()=>void O(),children:h?`Checking…`:T?`Save key`:`Use this provider`})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[o.length>1?(0,G.jsx)(`div`,{className:`flex gap-1 border-b border-border`,role:`tablist`,children:o.map(e=>{let t=iV(e)[0];return(0,G.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===b.key,"data-testid":`record-tab-${e.key}`,onClick:()=>c(e.key),className:e.key===b.key?`rounded-t-md border border-b-0 border-border bg-surface-2 px-3 py-1.5 text-sm font-medium`:`px-3 py-1.5 text-sm text-fg-muted hover:text-fg`,children:[e.label,t?(0,G.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-ok`,children:t.masked}):null]},e.key)})}):null,C.length>0?(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:`Connected`}),C.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5`,"data-testid":`stored-credential-${e.id}`,children:[(0,G.jsx)(Q,{tone:e.class===`subscription`?`accent`:`ok`,children:b.label}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:e.masked}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:e.label}),(0,G.jsx)(Y,{size:`sm`,onClick:()=>void i.testCredential(e.id),children:`Test`}),(0,G.jsx)(Y,{size:`sm`,variant:`danger`,onClick:()=>void i.deleteCredential(e.id),children:`Remove`})]},e.id))]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsx)(Q,{tone:E.viaGateway?`accent`:`ok`,children:E.badge}),(0,G.jsx)(Q,{children:x.kind}),b.keyFormat?(0,G.jsxs)(`span`,{className:`text-fg-faint`,children:[`key format `,b.keyFormat]}):null]}),(0,G.jsxs)(`div`,{className:E.viaGateway?`rounded-md border border-border bg-surface-2 px-3 py-2 text-xs text-fg-muted`:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`connect-route`,children:[E.detail,T&&!E.viaGateway?` The key is stored in your zero-knowledge vault.`:null]}),T?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`ol`,{className:`ml-4 list-decimal space-y-1 text-xs text-fg-muted`,children:b.loginKind===`oauth`?[`Press “${b.provider.definition.subscriptionLogin?.signInLabel??`Sign in`}”: a short code opens in your browser, you approve it, and the subscription is stored by itself — nothing to paste.`,`The token refreshes on its own; sign in again only if the provider says it expired.`,`Or paste an access token below, if you have one from elsewhere.`].map((e,t)=>(0,G.jsx)(`li`,{children:e},t)):b.hasLoginFlow?[`Press “Sign in instead” to get a token through the genuine engine — the fastest way.`,"Or run `claude setup-token` yourself and complete the sign-in in your browser.",`Paste the token it prints below (it looks like sk-ant-oat01-…).`].map((e,t)=>(0,G.jsx)(`li`,{children:e},t)):tV(b.provider,b.variant).map((e,t)=>(0,G.jsx)(`li`,{children:e},t))}),(0,G.jsx)(zy,{label:b.isSubscription?`Subscription token`:`API key`,hint:`Tried against the provider before it is saved, then encrypted on this PC with your vault key.`,children:(0,G.jsx)(`input`,{className:Z,type:`password`,autoComplete:`off`,spellCheck:!1,value:l,placeholder:b.keyFormat??`sk-…`,onChange:e=>{u(e.target.value),y(null)}})}),_?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`connect-probe-error`,children:_}):null,x.userBaseUrl?(0,G.jsx)(zy,{label:`Base URL`,hint:`Point this at your own server if it is not the default. Each record has its own endpoint.`,children:(0,G.jsx)(`input`,{className:Z,value:d,spellCheck:!1,onChange:e=>f(e.target.value),placeholder:b.variant?.baseUrl??x.baseUrl})}):null,(0,G.jsx)(zy,{label:`Label (optional)`,children:(0,G.jsx)(`input`,{className:Z,value:p,onChange:e=>m(e.target.value),placeholder:`${S} ${b.label.toLowerCase()} key`})})]}):(0,G.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,children:[x.displayName,` needs no credential.`]})]})})}function oV({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.ui.oauthLoginProviderId,a=i?n.providers.find(e=>e.definition.id===i)??null:null,o=n.oauthLogin&&n.oauthLogin.providerId===i?n.oauthLogin:null,[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=a?.definition.displayName??i??`the provider`,p=a?.definition.subscriptionLogin?.signInLabel??`Sign in to ${f}`,m=o?.phase===`awaiting_approval`,h=m?o?.verificationUriComplete??o?.verificationUri??null:null;(0,v.useEffect)(()=>{if(!e||!i)return;d.current=null,r.startOauthLogin(i);let t=setInterval(()=>void r.refreshOauthLogin(i),2e3);return()=>clearInterval(t)},[e,i,s,r]),(0,v.useEffect)(()=>{!e||!h||!o?.id||d.current===o.id||(d.current=o.id,TR(h))},[e,h,o?.id]),(0,v.useEffect)(()=>{e&&o?.phase===`connected`&&r.refreshCredentials()},[e,o?.phase,r]);let g=e=>{if(!navigator.clipboard){r.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}).catch(()=>r.toast(`error`,`Could not copy`))},_=o?.phase===`connected`||o?.phase===`failed`||o?.phase===`expired`||o?.phase===`cancelled`;return(0,G.jsx)(Vy,{open:e,title:p,onClose:t,footer:(0,G.jsxs)(G.Fragment,{children:[m?(0,G.jsx)(Y,{onClick:()=>i&&void r.cancelOauthLogin(i),"data-testid":`oauth-login-cancel`,children:`Cancel sign-in`}):null,_&&o?.phase!==`connected`?(0,G.jsx)(Y,{onClick:()=>c(e=>e+1),"data-testid":`oauth-login-retry`,children:`Try again`}):null,(0,G.jsx)(Y,{variant:`primary`,onClick:t,children:o?.phase===`connected`?`Done`:`Close`})]}),children:(0,G.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`oauth-login-dialog`,children:m&&o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{children:[`A sign-in page for `,f,` opened in your browser. If it did not, open the link below on any device and enter this code:`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`oauth-user-code`,children:o.userCode}),(0,G.jsxs)(Y,{onClick:()=>o.userCode&&g(o.userCode),children:[(0,G.jsx)(J.Copy,{className:`w-4 h-4`}),` `,l?`Copied`:`Copy code`]})]}),h?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,G.jsx)(`a`,{className:`underline`,href:h,onClick:e=>{e.preventDefault(),TR(h)},children:h}),(0,G.jsxs)(Y,{onClick:()=>g(h),children:[(0,G.jsx)(J.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval… the code expires`,o.expiresAt?` at ${new Date(o.expiresAt).toLocaleTimeString()}`:` soon`,`. The subscription is stored in your vault the moment `,f,` confirms it.`]})]}):o?.phase===`connected`?(0,G.jsxs)(`p`,{"data-testid":`oauth-login-connected`,children:[`Signed in. Your `,f,` subscription is stored in your vault and synced to your other machines; chats on it run from this PC straight to the provider.`]}):_?(0,G.jsx)(`p`,{className:`text-danger`,"data-testid":`oauth-login-ended`,children:o?.message??`The sign-in did not complete.`}):(0,G.jsx)(`p`,{children:`Starting the sign-in…`})})})}function sV({open:e,onClose:t}){let{state:n,actions:r}=K(),i=(0,v.useMemo)(()=>nf(n.providers),[n.providers]),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&(o({...n.settings?.modelVisibility??{}}),c(``))},[e]);let d=(e,t)=>a[e]??t,f=(e,t,n)=>d(e,n).includes(t),p=(e,t,n)=>{o(r=>{let i=r[e]??n,a=i.includes(t)?i.filter(e=>e!==t):n.filter(e=>e===t||i.includes(e));return{...r,[e]:a}})},m=(e,t,n)=>{o(r=>({...r,[e]:t?[...n]:[]}))},h=async()=>{u(!0);try{let e={};for(let t of i){let n=t.definition.models.map(e=>e.id),r=a[t.definition.id];r&&r.length!==n.length&&(e[t.definition.id]=r)}await r.saveSettings({modelVisibility:e}),t()}finally{u(!1)}},g=s.trim().toLowerCase();return(0,G.jsx)(Vy,{open:e,title:`Manage models`,onClose:t,wide:!0,footer:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,G.jsxs)(Y,{onClick:()=>{t(),r.openSettings(`providers`)},"data-testid":`manage-models-add-provider`,children:[(0,G.jsx)(J.Plus,{className:`w-3.5 h-3.5`}),` Add provider`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Y,{onClick:t,children:`Cancel`}),(0,G.jsx)(Y,{variant:`primary`,busy:l,onClick:()=>void h(),"data-testid":`manage-models-save`,children:`Save`})]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose which models the chat's picker offers. A provider with every model checked shows all of them — including ones it adds later.`}),(0,G.jsx)(`input`,{className:Z,value:s,onChange:e=>c(e.target.value),placeholder:`Filter models…`,"data-testid":`manage-models-filter`}),i.length===0?(0,G.jsxs)(`div`,{className:`text-sm text-fg-faint`,children:[`No provider is connected yet — use `,(0,G.jsx)(`strong`,{children:`Add provider`}),` below to connect one.`]}):null,i.map(e=>{let t=e.definition.models.map(e=>e.id),n=e.definition.models.filter(e=>!g||e.id.toLowerCase().includes(g)||(e.displayName??``).toLowerCase().includes(g)),r=d(e.definition.id,t).length;return(0,G.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`manage-models-${e.definition.id}`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.definition.displayName}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[r===t.length?`all`:r,` of `,t.length,` shown`]}),(0,G.jsxs)(`span`,{className:`ml-auto flex gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,onClick:()=>m(e.definition.id,!0,t),children:`All`}),(0,G.jsx)(Y,{size:`sm`,onClick:()=>m(e.definition.id,!1,t),children:`None`})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[n.map(n=>(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:f(e.definition.id,n.id,t),onChange:()=>p(e.definition.id,n.id,t),"data-testid":`manage-model-${n.id}`}),(0,G.jsxs)(`span`,{className:`truncate`,title:n.id,children:[n.displayName??n.id,n.displayName&&n.displayName!==n.id?(0,G.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,n.id]}):null]})]},n.id)),n.length===0?(0,G.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[(0,G.jsx)(J.Info,{className:`mr-1 inline w-3 h-3`}),` No model matches the filter.`]}):null]})]},e.definition.id)})]})})}var cV={mode:`names`,mine:!0,model:!0,tools:!1,subagents:!1,projectId:null,when:`any`,caseSensitive:!1,wholeWord:!1};function lV(e,t,n){let r=Oe(t,{caseSensitive:n.caseSensitive,wholeWord:n.wholeWord});if(!r)return[{text:e,hit:!1}];let i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;t[0].length!==0&&(n>a&&i.push({text:e.slice(a,n),hit:!1}),i.push({text:t[0],hit:!0}),a=n+t[0].length)}return a<e.length&&i.push({text:e.slice(a),hit:!1}),i}function uV(e){return Object.keys(cV).some(t=>e[t]!==cV[t])}function dV(e,t=Date.now()){if(e===`any`)return null;if(e===`today`){let e=new Date(t);return e.setHours(0,0,0,0),e}return new Date(t-(e===`week`?7:30)*24*60*60*1e3)}function fV(e,t,n,r=Date.now()){if(n.projectId!==null&&e.projectId!==n.projectId)return!1;let i=dV(n.when,r);if(i&&e.mtime<i.getTime())return!1;if((n.caseSensitive||n.wholeWord)&&t.trim()!==``){let r=[e.title,e.firstPrompt,e.lastPrompt,e.projectDir],i={caseSensitive:n.caseSensitive,wholeWord:n.wholeWord};if(!r.some(e=>typeof e==`string`&&ke(e,t,i)))return!1}return!0}function pV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=dV(t.when,n);return{q:r,limit:200,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},...t.projectId?{projectId:t.projectId}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function mV({label:e,hint:t,checked:n,onChange:r,testId:i}){return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5 text-xs`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:n,onChange:e=>r(e.target.checked),"data-testid":i}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg`,children:e}),t?(0,G.jsx)(`span`,{className:`block text-[11px] text-fg-faint`,children:t}):null]})]})}var hV=`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-fg focus:outline-none`,gV={names:`Names & prompts`,conversations:`Whole chats`,namesHint:`A chat’s name, its first and last message, and its folder.`,conversationsHint:`Every message of every chat on this PC. Pick whose words to look in.`};function _V({options:e,onChange:t,projects:n,onClose:r,words:i=gV}){let a=(n,r)=>t({...e,[n]:r}),o=e.mode===`conversations`,s=o&&!e.mine&&!e.model&&!e.tools;return(0,G.jsxs)(`div`,{className:`absolute left-2 right-2 top-full z-30 mt-1 space-y-3 rounded-lg border border-border bg-surface p-3 shadow-xl`,onMouseDown:e=>{!(e.target instanceof HTMLSelectElement)&&!(e.target instanceof HTMLInputElement)&&e.preventDefault()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),r())},"data-testid":`search-options`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:`Search in`}),(0,G.jsx)(Uy,{label:`Search in`,value:e.mode,options:[{value:`names`,label:i.names},{value:`conversations`,label:i.conversations}],onChange:e=>a(`mode`,e)}),(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`search-mode-hint`,children:o?i.conversationsHint:i.namesHint})]}),o?(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(mV,{label:`My messages`,checked:e.mine,onChange:e=>a(`mine`,e),testId:`search-opt-mine`}),(0,G.jsx)(mV,{label:`Model replies`,checked:e.model,onChange:e=>a(`model`,e),testId:`search-opt-model`}),(0,G.jsx)(mV,{label:`Tool calls & output`,hint:`Commands, file paths and what the tools answered.`,checked:e.tools,onChange:e=>a(`tools`,e),testId:`search-opt-tools`}),(0,G.jsx)(mV,{label:`Subagents’ conversations`,checked:e.subagents,onChange:e=>a(`subagents`,e),testId:`search-opt-subagents`}),s?(0,G.jsx)(`p`,{className:`text-[11px] text-warn`,children:`Tick at least one to search.`}):null]}):null,(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[n?(0,G.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`span`,{children:`Project`}),(0,G.jsxs)(`select`,{className:hV,value:e.projectId??``,onChange:e=>a(`projectId`,e.target.value||null),"data-testid":`search-opt-project`,children:[(0,G.jsx)(`option`,{value:``,children:`All projects`}),n.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):null,(0,G.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`span`,{children:`When`}),(0,G.jsxs)(`select`,{className:hV,value:e.when,onChange:e=>a(`when`,e.target.value),"data-testid":`search-opt-when`,children:[(0,G.jsx)(`option`,{value:`any`,children:`Any time`}),(0,G.jsx)(`option`,{value:`today`,children:`Today`}),(0,G.jsx)(`option`,{value:`week`,children:`Last 7 days`}),(0,G.jsx)(`option`,{value:`month`,children:`Last 30 days`})]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,G.jsx)(mV,{label:`Match case`,checked:e.caseSensitive,onChange:e=>a(`caseSensitive`,e),testId:`search-opt-case`}),(0,G.jsx)(mV,{label:`Whole words`,checked:e.wholeWord,onChange:e=>a(`wholeWord`,e),testId:`search-opt-word`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border pt-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:W(`text-xs`,uV(e)?`text-accent hover:underline`:`text-fg-faint`),disabled:!uV(e),onClick:()=>t(cV),"data-testid":`search-opt-reset`,children:`Reset`}),(0,G.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-2 px-2 py-1 text-xs text-fg hover:bg-surface-3`,onClick:r,"data-testid":`search-opt-done`,children:`Done`})]})]})}function vV(e){return e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`}function yV({query:e,options:t}){let{state:n,actions:r}=K(),i=(0,v.useMemo)(()=>pV(e,t),[e,t]),[a,o]=(0,v.useState)(null),s=i?JSON.stringify(i):``;(0,v.useEffect)(()=>{if(!i)return;let e=!0,t=setTimeout(()=>{r.searchTranscripts(i).then(t=>{e&&o({key:s,res:t})})},350);return()=>{e=!1,clearTimeout(t)}},[s,r]);let c=a&&a.key===s?a:null,l=(0,v.useMemo)(()=>{let e=new Map;for(let t of c?.res?.hits??[]){let r=n.sessions.find(e=>e.id===t.sessionId)?.title||t.title||`Untitled chat`,i=e.get(t.sessionId)??{title:r,hits:[]};i.hits.push(t),e.set(t.sessionId,i)}return[...e.entries()]},[c,n.sessions]);if(!i)return(0,G.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-idle`,children:e.trim().length<2?`Type at least two characters to search every chat.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`});if(!c)return(0,G.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-busy`,children:`Searching every chat…`});if(c.res===null)return(0,G.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-danger`,"data-testid":`transcript-search-failed`,children:`This PC could not search its chats. Try again, or update OonaCode.`});let u=c.res.hits.length;return(0,G.jsxs)(`div`,{className:`pb-2`,"data-testid":`transcript-search-results`,children:[(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,children:u===0?`No message on this PC says that.`:`${u}${c.res.truncated?`+`:``} ${u===1?`message`:`messages`} in ${l.length} ${l.length===1?`chat`:`chats`}`}),l.map(([n,i])=>(0,G.jsxs)(`div`,{className:`mb-1.5`,"data-testid":`transcript-search-chat-${n}`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[13px] font-semibold text-fg hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.title}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 text-[10px] font-semibold text-fg-muted`,children:i.hits.length})]}),i.hits.map(i=>(0,G.jsxs)(`button`,{type:`button`,className:`block w-full rounded px-2 py-1 pl-4 text-left text-xs hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),"data-testid":`transcript-search-hit`,children:[(0,G.jsxs)(`span`,{className:`mb-0.5 flex items-center gap-1.5 text-[10px] text-fg-faint`,children:[i.kind===`tool`?(0,G.jsx)(J.Tool,{className:`h-3 w-3`}):i.role===`assistant`?(0,G.jsx)(J.Bot,{className:`h-3 w-3`}):(0,G.jsx)(J.User,{className:`h-3 w-3`}),(0,G.jsx)(`span`,{className:`font-medium text-fg-muted`,children:vV(i)}),i.subpath?(0,G.jsx)(`span`,{children:`· subagent`}):null,i.timestamp?(0,G.jsx)(`span`,{className:`ml-auto`,children:eg(i.timestamp)}):null]}),(0,G.jsx)(`span`,{className:`line-clamp-3 text-fg-muted`,children:lV(i.snippet,e,t).map((e,t)=>e.hit?(0,G.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,G.jsx)(`span`,{children:e.text},t))})]},`${i.seq}`))]},n))]})}function bV(e){return`${e.agentId??`claude-code`}:${e.id}`}function xV(e){let t=Date.parse(e.lastEntryAt??e.updatedAt);return Number.isFinite(t)?t:0}function SV(e,t,n=Date.now()){let r=dV(t.when,n)?.getTime()??null,i=Oe(e,{caseSensitive:t.caseSensitive,wholeWord:t.wholeWord});return e=>r!==null&&xV(e)<r?!1:i===null||[e.title,e.firstPrompt,e.lastPrompt,e.cwd,e.projectName,e.id].some(e=>typeof e==`string`&&(i.lastIndex=0,i.test(e)))}function CV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=dV(t.when,n);return{q:r,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function wV(e,t){let n=new Map;for(let t of e){let e=bV(t);n.set(e,e);for(let r of t.supersedes??[]){let i=bV({agentId:t.agentId,id:r});n.has(i)||n.set(i,e)}}let r=new Map;for(let e of t){let t=n.get(bV(e));if(!t)continue;let i=r.get(t);if(!i){r.set(t,{...e,snippets:e.snippets.slice(0,3)});continue}r.set(t,{...i,hits:i.hits+e.hits,...i.hitsCapped||e.hitsCapped?{hitsCapped:!0}:{},snippets:[...i.snippets,...e.snippets].slice(0,3)})}return r}var TV={new:`New`,imported:`Imported`,behind:`Imported · original moved on`,deleted:`You deleted it in OonaCode`,unavailable:`Cannot be imported yet`};function EV(e){return e.alreadyImported?e.upToDate===!1?`behind`:`imported`:e.deletedHere===!0?`deleted`:DV(e)?`unavailable`:`new`}function DV(e){return typeof e.unavailable==`string`&&e.unavailable.length>0}function OV(e){if(DV(e))return!1;let t=EV(e);return t===`new`||t===`behind`}function kV(e){return EV(e)===`new`}function AV(e,t){return new Set(t?e.filter(kV).map(e=>e.id):[])}function jV(e){if(!e.some(e=>e.projectName))return e;let t=[],n=new Map;for(let r of e){let e=r.projectName??``,i=n.get(e);i||(i=[],n.set(e,i),t.push(e)),i.push(r)}return t.flatMap(e=>n.get(e)??[])}function MV(){return{new:0,imported:0,behind:0,deleted:0,unavailable:0}}function NV(e){let t=new Map;for(let n of e){let e=n.agentId??`claude-code`,r=t.get(e);r||(r={key:e,name:n.agentName??`Claude Code`,rows:[],counts:MV()},t.set(e,r)),r.rows.push(n),r.counts[EV(n)]+=1}for(let e of t.values())e.rows=jV([...e.rows].sort((e,t)=>xV(t)-xV(e)));return[...t.values()]}function PV(e,t){let n=0,r=0,i=0;for(let a of e){let e=t.has(a.id);e&&(n+=1),OV(a)&&(r+=1,e&&(i+=1))}return n===0?`none`:r>0&&i===r?`all`:`some`}function FV(e,t){let n=new Set(t),r=e.filter(OV);if(PV(e,t)===`all`||r.length===0)for(let t of e)n.delete(t.id);else for(let e of r)n.add(e.id);return n}function IV(e,t){let n=0;if(t)for(let r of e)t.has(r)||(n+=1);return{total:e.size,notShown:n}}var LV={names:`Names & folders`,conversations:`Whole conversations`,namesHint:`A chat’s name, its first and last message, and the folder it ran in.`,conversationsHint:`Every message of every chat listed here, read from the other apps’ own files. Pick whose words to look in.`},RV=`Ticks the chats with something to bring in — new ones, and imported ones whose original moved on. An imported chat that is up to date, or one you deleted in OonaCode, is ticked on its own row.`;function zV(e){return e.partial===`time`?`Stopped after ${Math.round(e.elapsedMs/1e3)} s — these are the chats found until then. A longer phrase narrows it.`:e.partial===`chats`?`Stopped at ${e.chats.length} chats — a longer phrase narrows it.`:null}function BV(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).length<=2?e:`…${e.slice(-40)}`:`no folder recorded`}function VV(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function HV(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}var UV=(e,t,n)=>`${e} ${e===1?t:n}`;function WV({open:e,onClose:t,autoOffer:n=!1}){let{state:r,actions:i}=K(),a=r.importProgress,[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(new Set),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(null),x=(0,v.useMemo)(()=>f??[],[f]),S=(0,v.useMemo)(()=>NV(x),[x]),C=(0,v.useMemo)(()=>{let e={new:0,imported:0,behind:0,deleted:0,unavailable:0};for(let t of S)for(let n of Object.keys(e))e[n]+=t.counts[n];return e},[S]),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(cV),[O,k]=(0,v.useState)(!1),A=(0,v.useRef)(null),j=w.trim()!==``,M=E.mode===`conversations`,[N,ee]=(0,v.useState)(new Set);(0,v.useEffect)(()=>ee(new Set),[w,E]);let te=(0,v.useMemo)(()=>M?CV(w,E):null,[M,w,E]),P=te?JSON.stringify(te):``,[F,ne]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e||!te)return;let t=new AbortController,n=!0,r=setTimeout(()=>{i.searchImportChats(te,t.signal).then(e=>{n&&ne({key:P,res:e})})},350);return()=>{n=!1,clearTimeout(r),t.abort()}},[e,P,i]);let re=F&&F.key===P?F:null,ie=(0,v.useMemo)(()=>re?.res?wV(x,re.res.chats):null,[re,x]),I=(0,v.useMemo)(()=>j?M?ie?x.filter(e=>ie.has(bV(e))):[]:x.filter(SV(w,E)):null,[j,M,x,w,E,ie]),L=(0,v.useMemo)(()=>I?new Set(I):null,[I]),R=(0,v.useMemo)(()=>I?new Set(I.map(e=>e.id)):null,[I]),ae=I??x,oe=(0,v.useMemo)(()=>j?{query:w,options:E,litNames:!M}:null,[j,w,E,M]),se=(0,v.useMemo)(()=>x.filter(e=>e.alreadyImported&&m.has(e.id)),[x,m]),ce=(0,v.useMemo)(()=>IV(m,R),[m,R]),le=S.length===1?S[0].name:`coding-agent`;(0,v.useEffect)(()=>{if(!e)return;d(null),b(null),_(new Set),h(new Set),T(``),ne(null),k(!1),s(!0);let t=n;i.scanClaudeSessions().then(e=>{p(e.sessions),h(AV(e.sessions,t))}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>s(!1))},[e]);let ue=(0,v.useCallback)(e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),de=r.prefs.claudeImportOffered,fe=(0,v.useCallback)(()=>{de||i.savePrefs({claudeImportOffered:!0}),t()},[de,i,t]),pe=async()=>{l(!0),d(null);try{let e=await i.importClaudeSessions([...m],se.length>0);b({imported:e.imported.length,replaced:e.replaced?.length??0,entries:e.imported.reduce((e,t)=>e+t.entries,0)+(e.replaced??[]).reduce((e,t)=>e+t.entries,0),failed:e.failed.length,filed:e.filed?.length??0,projectsMade:(e.projects??[]).filter(e=>e.created).map(e=>e.name),warnings:e.warnings??[]}),r.prefs.claudeImportOffered||i.savePrefs({claudeImportOffered:!0}),await i.refreshSessions()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},me=C.imported+C.behind;return(0,G.jsx)(Vy,{open:e,title:`Import your ${le} chats`,onClose:fe,wide:!0,footer:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 text-[11px] text-fg-faint`,children:[!y&&ce.notShown>0?(0,G.jsxs)(`span`,{className:`block text-fg-muted`,"data-testid":`import-claude-ticked-hidden`,children:[ce.total,` ticked · `,ce.notShown,` not shown by the search`]}):null,se.length>0?(0,G.jsxs)(`span`,{className:`block text-warn`,children:[se.length,` already-imported `,se.length===1?`chat`:`chats`,` `,`will be REPLACED — the OonaCode copy is rebuilt from the original, and anything added here is lost.`]}):(0,G.jsx)(`span`,{className:`block`,children:`Your other apps stay exactly as they are — this copies, it never moves or deletes.`})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,G.jsx)(Y,{onClick:fe,"data-testid":`import-claude-close`,children:y?`Done`:`Not now`}),y?null:(0,G.jsxs)(Y,{variant:`primary`,busy:c,disabled:ce.total===0,onClick:()=>void pe(),"data-testid":`import-claude-run`,children:[`Import `,UV(ce.total,`chat`,`chats`)]})]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`import-claude-body`,children:[o?(0,G.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Looking for chats on this PC…`}):null,a&&!y?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`import-claude-progress`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,G.jsxs)(`span`,{children:[`Importing `,(0,G.jsx)(`strong`,{children:a.done}),` of `,(0,G.jsx)(`strong`,{children:a.total}),`…`]}),(0,G.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[Math.round(a.done/Math.max(a.total,1)*100),`%`]})]}),(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-surface-2`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-[width] duration-200`,style:{width:`${Math.round(a.done/Math.max(a.total,1)*100)}%`}})}),a.current?(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,title:a.current,children:[`reading: `,a.current]}):null,(0,G.jsxs)(`div`,{className:`flex gap-3 text-[11px] text-fg-faint`,children:[(0,G.jsxs)(`span`,{children:[a.imported,` imported`]}),a.skipped>0?(0,G.jsxs)(`span`,{children:[a.skipped,` already in`]}):null,a.failed>0?(0,G.jsxs)(`span`,{className:`text-warn`,children:[a.failed,` could not be read`]}):null]}),(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`A big chat takes a moment — the largest here are over 100 MB. Your Claude Code is only being read.`})]}):null,u?(0,G.jsx)(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger`,children:u}):null,y?(0,G.jsxs)(`div`,{className:`text-sm`,"data-testid":`import-claude-done`,children:[(0,G.jsxs)(`p`,{children:[`Imported `,(0,G.jsx)(`strong`,{children:y.imported}),` `,y.imported===1?`chat`:`chats`,y.replaced>0?(0,G.jsxs)(G.Fragment,{children:[` and rebuilt `,(0,G.jsx)(`strong`,{children:y.replaced}),` that `,y.replaced===1?`was`:`were`,` already here`]}):null,` `,`(`,y.entries.toLocaleString(),` entries). They are in your sessions list now, and you can carry on typing in them.`]}),y.projectsMade.length>0?(0,G.jsxs)(`p`,{className:`mt-1`,"data-testid":`import-claude-projects-made`,children:[y.projectsMade.length===1?`Created the project `:`Created the projects `,y.projectsMade.map((e,t)=>(0,G.jsxs)(`span`,{children:[t>0?`, `:``,(0,G.jsx)(`strong`,{children:e})]},e)),` `,`and filed `,y.projectsMade.length===1?`its`:`their`,` chats under`,` `,y.projectsMade.length===1?`it`:`them`,`.`]}):null,y.filed>0?(0,G.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`import-claude-filed`,children:[y.filed,` `,y.filed===1?`chat that was`:`chats that were`,` already here`,` `,y.filed===1?`is`:`are`,` now filed under`,` `,y.filed===1?`its`:`their`,` project.`]}):null,y.failed>0?(0,G.jsxs)(`p`,{className:`mt-1 text-warn`,children:[y.failed,` could not be read and were left alone.`]}):null,y.warnings.map(e=>(0,G.jsx)(`p`,{className:`mt-1 text-warn`,children:e},e))]}):null,!o&&!y&&!a&&f!==null&&f.length>0?(0,G.jsxs)(`div`,{className:`space-y-0.5 text-sm`,"data-testid":`import-claude-tally`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:f.length}),` `,f.length===1?`chat`:`chats`,` on this PC`,S.length>0?` — `:``,S.map((e,t)=>(0,G.jsxs)(`span`,{children:[t>0?`, `:``,(0,G.jsx)(`strong`,{children:e.rows.length}),` `,e.name]},e.key))]}),(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.new}),` new`,me>0?` · ${me} already imported`:``,C.behind>0?` (${C.behind} behind their original)`:``,C.deleted>0?` · ${C.deleted} you deleted in OonaCode`:``]})]}):null,!o&&!y&&!a&&f!==null&&C.new===0&&!j?(0,G.jsx)(`div`,{className:`text-sm text-fg-muted`,"data-testid":`import-claude-empty`,children:f.length===0?`No chats from a coding agent were found on this PC.`:`Nothing new to import. Every chat is listed below — tick one to import it again.`}):null,!y&&!a&&x.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Every chat the coding agents on this PC have, newest first. Importing copies them into OonaCode so you can read them here — and continue them, in the folder each one ran in.`,n&&C.new>0?` The new ones are ticked.`:` Tick the ones you want.`]}),(0,G.jsxs)(`div`,{className:`relative`,"data-testid":`import-search`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(J.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`input`,{ref:A,"aria-label":`Search the chats to import`,className:W(Z,`pl-7`),placeholder:M?`Search inside every conversation`:`Search by name, message or folder`,value:w,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(w!==``||O)&&(e.preventDefault(),e.stopPropagation(),O?k(!1):T(``))},"data-testid":`import-search-input`})]}),(0,G.jsxs)(X,{label:O?`Hide search options`:`Search options`,className:W(`relative`,O&&`text-accent`),"aria-pressed":O,onMouseDown:e=>e.preventDefault(),onClick:()=>k(e=>!e),"data-testid":`import-search-options-toggle`,children:[(0,G.jsx)(J.Sliders,{}),uV(E)?(0,G.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`import-search-options-dot`}):null]}),j?(0,G.jsx)(X,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:()=>{T(``),A.current?.focus()},"data-testid":`import-search-clear`,children:(0,G.jsx)(J.X,{})}):null]}),O?(0,G.jsx)(_V,{options:E,onChange:D,words:LV,onClose:()=>{k(!1),A.current?.focus()}}):null]}),j?(0,G.jsx)(QV,{query:w,conversations:M,request:te!==null,answer:re,matches:I?.length??0,messages:[...ie?.values()??[]].reduce((e,t)=>e+t.hits,0),capped:[...ie?.values()??[]].some(e=>e.hitsCapped)}):null,(0,G.jsx)(`div`,{className:`max-h-96 space-y-3 overflow-y-auto`,"data-testid":`import-claude-list`,children:S.map(e=>{let t=L?e.rows.filter(e=>L.has(e)):e.rows;if(t.length===0)return null;let n=L?!N.has(e.key):!g.has(e.key),r=L?ee:_;return(0,G.jsxs)(`div`,{className:`rounded border border-border`,"data-testid":`import-group-${e.key}`,children:[(0,G.jsx)(qV,{section:e,rows:t,searching:L!==null,open:n,chosen:m,onFold:()=>r(t=>GV(t,e.key)),onTicks:h}),n?t.map(e=>(0,G.jsx)(YV,{row:e,checked:m.has(e.id),onToggle:ue,phrase:oe,hit:ie?.get(bV(e))},bV(e))):null]},e.key)})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`button`,{type:`button`,className:`underline`,title:RV,onClick:()=>h(e=>{let t=new Set(e);for(let e of ae)OV(e)&&t.add(e.id);return t}),"data-testid":`import-claude-select-all`,children:I===null?`Select all`:`Select all matches`}),(0,G.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>h(e=>{if(I===null)return new Set;let t=new Set(e);for(let e of ae)t.delete(e.id);return t}),"data-testid":`import-claude-select-none`,children:I===null?`Select none`:`Unselect matches`})]})]}):null]})})}function GV(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function KV({state:e,disabled:t,onToggle:n,label:r,title:i,testId:a}){let o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{o.current&&(o.current.indeterminate=e===`some`)}),(0,G.jsx)(`input`,{ref:o,type:`checkbox`,className:`shrink-0`,checked:e===`all`,disabled:t,onChange:n,"aria-label":r,title:i,"data-state":e,"data-testid":a})}function qV({section:e,rows:t,searching:n,open:r,chosen:i,onFold:a,onTicks:o}){let s=PV(t,i),c=t.filter(OV).length,l=e.rows.filter(e=>i.has(e.id)).length,u=e.counts,d=u.imported+u.behind===e.rows.length,f=n?`the ${e.name} matches`:`${e.name}`,p=s===`all`?`Untick every chat in ${f}`:c===0&&s===`none`?`Nothing new here — tick a chat on its own row to import it again.`:c===0?`Untick every chat in ${f}`:RV;return(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-surface-2 px-2 py-1.5`,children:[(0,G.jsx)(KV,{state:s,disabled:c===0&&s===`none`,onToggle:()=>o(e=>FV(t,e)),label:s===`all`?`Untick every chat in ${f}`:`Tick the chats in ${f}`,title:p,testId:`import-group-check-${e.key}`}),(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-xs font-medium`,onClick:a,"aria-expanded":r,title:r?`Fold ${e.name}`:`Open ${e.name}`,"data-testid":`import-group-header-${e.key}`,children:[(0,G.jsx)(J.Chevron,{open:r,className:`w-3 h-3 shrink-0`}),e.name,(0,G.jsxs)(`span`,{className:`truncate font-normal text-fg-faint`,children:[UV(e.rows.length,`chat`,`chats`),n?` · ${UV(t.length,`match`,`matches`)}`:``,u.new>0?` · ${u.new} new`:d?` · all imported`:``,u.behind>0?` · ${u.behind} behind`:``,u.deleted>0?` · ${u.deleted} you deleted`:``,l>0?` · ${l} ticked`:``]})]})]})}function JV({row:e,status:t}){let n=TV[t],r={"data-testid":`import-status-${e.id}`,"data-status":t};switch(t){case`new`:return(0,G.jsx)(`span`,{className:`font-medium text-accent`,...r,children:n});case`imported`:case`behind`:return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-fg-muted`,title:t===`behind`?`The original has newer messages than the OonaCode copy — importing again brings them in (and replaces the copy).`:`Already in OonaCode. Ticking it rebuilds the OonaCode copy from the original, which replaces it.`,...r,children:[(0,G.jsx)(J.Check,{className:`w-3 h-3 text-ok`}),n,t===`behind`?(0,G.jsxs)(`span`,{className:`ml-0.5 inline-flex shrink-0 items-center gap-0.5 rounded bg-warn-soft px-1 text-[10px] font-medium leading-4 text-warn`,"data-testid":`import-behind-${e.id}`,"aria-label":`behind its original`,children:[(0,G.jsx)(J.ArrowDown,{className:`w-2.5 h-2.5`}),`behind`]}):null]});case`deleted`:return(0,G.jsx)(`span`,{className:`text-fg-faint`,title:`You imported this chat and deleted it in OonaCode; its original is still on this PC. Tick it to bring it back.`,...r,children:n});case`unavailable`:return(0,G.jsx)(`span`,{className:`text-warn`,...r,children:n})}}var YV=(0,v.memo)(function({row:e,checked:t,onToggle:n,phrase:r,hit:i}){let a=DV(e),o=e=>r?.litNames?lV(e,r.query,r.options).map((e,t)=>e.hit?(0,G.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,G.jsx)(`span`,{children:e.text},t)):e;return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 border-b border-border p-2 last:border-b-0 ${a?`cursor-default opacity-60`:`cursor-pointer hover:bg-surface-2`}`,"data-testid":`import-row-${e.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:t,disabled:a,onChange:()=>n(e.id),"aria-label":e.title??e.firstPrompt??e.id}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-sm`,children:e.title||e.firstPrompt?o(e.title||e.firstPrompt||``):(0,G.jsx)(`span`,{className:`text-fg-faint`,children:`(no prompt)`})}),(0,G.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-fg-faint`,children:[e.projectName?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,G.jsx)(J.Project,{className:`w-3 h-3`}),o(e.projectName)]}):(0,G.jsxs)(G.Fragment,{children:[e.cwd?(0,G.jsx)(`span`,{title:e.cwd,children:o(BV(e.cwd))}):BV(e.cwd),e.cwd&&!e.cwdExists?` · folder is gone`:``]}),` `,`· `,e.entryCount,` entries`,e.bytes>0?` · ${VV(e.bytes)}`:``,e.model?` · ${e.model}`:``]}),e.unavailable||e.note?(0,G.jsx)(`span`,{className:`mt-0.5 block text-[11px] ${e.unavailable?`text-warn`:`text-fg-faint`}`,"data-testid":`import-row-note-${e.id}`,children:e.unavailable??e.note}):null,i&&r?(0,G.jsx)(ZV,{hit:i,query:r.query,options:r.options,testId:`import-row-hits-${e.id}`}):null]}),e.supersedes&&e.supersedes.length>0?(0,G.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded bg-surface-2 px-1 text-[11px] text-fg-faint`,title:`Rewound — replaces ${e.supersedes.length} earlier ${e.supersedes.length===1?`branch`:`branches`} of this chat`,children:`rewound`}):null,(0,G.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 flex-col items-end gap-0.5 text-right text-[11px]`,children:[(0,G.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:HV(e.lastEntryAt??e.updatedAt)}),(0,G.jsx)(`span`,{className:`whitespace-nowrap`,children:(0,G.jsx)(JV,{row:e,status:EV(e)})})]})]})});function XV(e){let t=e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`;return e.subagent?`${t} (subagent)`:t}function ZV({hit:e,query:t,options:n,testId:r}){return(0,G.jsxs)(`span`,{className:`mt-1 block space-y-0.5`,"data-testid":r,children:[(0,G.jsxs)(`span`,{className:`block text-[11px] font-medium text-fg-muted`,children:[e.hits,e.hitsCapped?`+`:``,` `,e.hits===1&&!e.hitsCapped?`message says`:`messages say`,` it`]}),e.snippets.map((e,r)=>(0,G.jsxs)(`span`,{className:`block line-clamp-2 text-[11px] text-fg-muted`,"data-testid":`import-row-snippet`,children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg-faint`,children:[XV(e),`:`]}),` `,lV(e.snippet,t,n).map((e,t)=>e.hit?(0,G.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,G.jsx)(`span`,{children:e.text},t))]},r))]})}function QV({query:e,conversations:t,request:n,answer:r,matches:i,messages:a,capped:o}){let s=(e,t,n=`text-fg-muted`)=>(0,G.jsx)(`p`,{className:`text-[11px] ${n}`,"data-testid":t,children:e});if(!t)return i===0?s(`No chat’s name, message or folder says “${e.trim()}”. Whole conversations, in the search options, looks inside them.`,`import-search-none`):s(`${i} ${i===1?`chat matches`:`chats match`}`,`import-search-count`);if(!n)return s(e.trim().length<2?`Type at least two characters to search inside the conversations.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`,`import-search-idle`);if(!r)return s(`Searching every conversation on this PC…`,`import-search-busy`);if(r.res===null)return s(`This PC could not search its conversations. Try again, or update OonaCode.`,`import-search-failed`,`text-danger`);let c=r.res,l=zV(c),u=c.sources.filter(e=>e.note).map(e=>`${e.agentName}: ${e.note}`);return(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[i===0?s(c.partial===`aborted`?`The search was stopped.`:`No conversation on this PC says that.`,`import-search-none`):s(`${i} ${i===1?`chat says`:`chats say`} it · ${a}${o?`+`:``} ${a===1&&!o?`message`:`messages`}`,`import-search-count`),l?s(l,`import-search-partial`,`text-warn`):null,u.map(e=>(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`import-search-source-note`,children:e},e))]})}var $V={model:null,previousModel:null,costUsd:0,inputTokens:0,outputTokens:0,turns:0,durationMs:0,contextTokens:null,contextWindow:null,contextUsed:null,costSource:`engine`,credits:null,resetAtIndex:null,didReset:!1,countedResults:0};function eH(e,t){let n=t?Bs(t):null,r=null,i=null;for(let t=0;t<e.length;t++){let a=e[t];if(!a||a.kind!==`assistant`||!L(a.model))continue;let o=Bs(a.model);n!==null&&o!==n&&(r=t,i=n),n=o}return{index:r,from:i,to:n}}function tH(e){let{items:t,session:n=null,initModel:r=null,boundary:i=null,models:a}=e,o=e.contextTokens!=null&&e.contextTokens>0?e.contextTokens:null;if(t.length===0&&!n)return $V;let s=eH(t,r),c=i&&i.index>=0?Math.min(i.index,t.length):null,l=null,u=null;s.index!==null&&(c===null||s.index>=c)?(l=s.index,u=s.from):c!==null&&(l=c,u=i?.from??s.from);let d=l??0,f=0,p=0,m=0,h=0,g=0,_=0;for(let e=d;e<t.length;e++){let n=t[e];!n||n.kind!==`result`||(_+=1,f+=n.costUsd,p+=n.inputTokens,m+=n.outputTokens,h+=n.numTurns,g+=n.durationMs)}_===0&&l===null&&n&&(f=n.totalCostUsd,p=n.inputTokens,m=n.outputTokens);let v=`engine`,y=null;n&&n.providerId===`oonacode`&&(f=n.totalCostUsd,y=n.poolCredits??null,v=`gateway`);let b=r?Bs(r):null,x=i&&c!==null&&l===c?i.to:s.to??n?.model??b??null,S=[x,n?.model??null,b].filter(e=>typeof e==`string`&&e.length>0),C=(a?S.map(e=>a.find(t=>t.id===e)).find(e=>e?.contextWindow!=null):void 0)?.contextWindow??null;return{model:x,previousModel:u,costUsd:f,inputTokens:p,outputTokens:m,turns:h,durationMs:g,contextTokens:o,contextWindow:C,contextUsed:C&&C>0&&o!==null?Math.min(1,o/C):null,resetAtIndex:l,didReset:l!==null,countedResults:_,costSource:v,credits:y}}var nH=[...gu.what,...gu.when,...gu.who,...gu.yours,...gu.where];function rH({sessionId:e,entryCount:t}){let{state:n,actions:r}=K(),i=n.chatAboutsChange,a=ql(n.settings??{}),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),C=(0,v.useRef)(i.seq),w=(0,v.useRef)(!0);(0,v.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let T=(0,v.useCallback)(async()=>{let t=await r.getChatAbout(e);if(w.current){if(t===`unsupported`){l(!0);return}t!==null&&(l(!1),s(t))}},[r,e]);if((0,v.useEffect)(()=>{T()},[T]),(0,v.useEffect)(()=>{i.seq!==C.current&&(C.current=i.seq,au(i,e)&&T())},[i,e,T]),c||o===null)return null;let E=()=>{p(o.about??``),d(!0),S(null),b(null)},D=async()=>{if(mu(f))return;let t=f.trim()===``;h(!0);try{let n=await r.updateChatAbout(e,t?null:f);if(!w.current||!n)return;s(n),d(!1),S(t?a.enabled?`Cleared. The housekeeper writes a new about at the chat’s next change.`:`Cleared. None is written while chat abouts are off.`:null)}finally{w.current&&h(!1)}},O=async()=>{_(!0),b(null),S(null);try{let t=await r.regenerateChatAbout(e);if(!w.current)return;t.about&&s(t.about),t.ok||b(t.error??`The about could not be written.`)}finally{w.current&&_(!1)}},k=hu(f,a.maxWords),A=mu(f),j=ou(o);return(0,G.jsxs)(`div`,{className:`mb-2`,"data-testid":`session-about`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:(0,G.jsx)(J.Info,{className:`w-3.5 h-3.5`})}),`About`,(0,G.jsx)(Ly,{label:`About`,details:(0,G.jsx)(Ry,{items:nH})}),o.stale&&o.about?(0,G.jsx)(`span`,{title:gu.stale,"data-testid":`session-about-stale`,children:(0,G.jsx)(Q,{tone:`warn`,children:`stale`})}):null]}),u?(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`textarea`,{className:W(Z,`min-h-[7rem] resize-y text-xs`),value:f,onChange:e=>p(e.target.value),"aria-label":`This chat’s about`,placeholder:`What this chat works on, for your other chats to read`,autoFocus:!0,"data-testid":`session-about-input`}),(0,G.jsxs)(`div`,{className:W(`text-[11px]`,k.overChars?`text-danger`:k.overWords?`text-warn`:`text-fg-faint`),"data-testid":`session-about-count`,children:[k.words,` / `,a.maxWords,` words · `,k.chars.toLocaleString(`en-US`),` /`,` `,Gl.userChars.toLocaleString(`en-US`),` characters`]}),A?(0,G.jsx)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-problem`,children:A}):k.overWords?(0,G.jsxs)(`div`,{className:`text-[11px] text-warn`,children:[`Longer than the `,a.maxWords,` words the housekeeper writes; your other chats read all of it.`]}):null,(0,G.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Saved empty, it is cleared, and the housekeeper writes one again at the chat’s next change.`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>void D(),busy:m,disabled:A!==null,"data-testid":`session-about-save`,children:`Save`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>d(!1),disabled:m,"data-testid":`session-about-cancel`,children:`Cancel`})]})]}):(0,G.jsxs)(G.Fragment,{children:[o.about?(0,G.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-fg`,"data-testid":`session-about-text`,children:o.about}):(0,G.jsxs)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`session-about-missing`,children:[`No about yet. `,fu(o,{enabled:a.enabled,entryCount:t})]}),o.about&&o.aboutAt?(0,G.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:ng(o.aboutAt),"data-testid":`session-about-written`,children:[`Written `,eg(o.aboutAt),j?` by ${j}`:``]}):null,o.about&&o.pending?(0,G.jsx)(`div`,{className:`text-[11px] text-accent`,children:`Being written again now…`}):null,o.about&&o.lastError?(0,G.jsxs)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-last-error`,children:[`The last attempt failed: `,o.lastError]}):null,(0,G.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:o.route?`Paid by ${su[o.route]}`:void 0,"data-testid":`session-about-spend`,children:[`Cost so far: `,uu(o.spend,o.route)]}),x?(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-muted`,"data-testid":`session-about-note`,children:x}):null,y?(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] text-danger`,role:`alert`,"data-testid":`session-about-regen-error`,children:y}):null,(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,G.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:E,disabled:g,title:gu.edit,"data-testid":`session-about-edit`,children:[(0,G.jsx)(J.Edit,{className:`h-3 w-3`}),` Edit`]}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>void O(),disabled:!a.enabled||g,title:a.enabled?gu.regenerate:gu.regenerateOff,"data-testid":`session-about-regenerate`,children:g?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(J.Spinner,{className:`h-3 w-3`}),` Writing…`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(J.Refresh,{className:`h-3 w-3`}),` Regenerate`]})})]}),a.enabled?null:(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,"data-testid":`session-about-off`,children:`Regenerate is unavailable: chat abouts are off.`})]})]})}function iH({view:e}){let t=(0,v.useMemo)(()=>FB(e.request??``),[e.request]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:e.truncated?`Cut at the size the host keeps.`:`As agy sent it.`}),(0,G.jsx)(qM,{text:t})]}),(0,G.jsx)(`pre`,{className:`mt-0.5 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md border border-border bg-code-bg p-2 font-mono text-[11px] leading-snug text-fg`,"data-testid":`agy-request-json`,children:t})]})}function aH({sessionId:e,running:t}){let{api:n}=K(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)({}),h=(0,v.useRef)(!0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=(0,v.useCallback)(async()=>{if(!n.listAgyRequests){o(!0);return}c(!0);try{let t=await n.listAgyRequests(e);if(!h.current)return;o(!1),i(t.requests)}catch(e){if(!h.current)return;gm(e)&&o(!0)}finally{h.current&&c(!1)}},[n,e]);(0,v.useEffect)(()=>{g()},[g]);let _=(0,v.useRef)(t);(0,v.useEffect)(()=>{_.current&&!t&&g(),_.current=t},[t,g]);let{main:y,background:b}=(0,v.useMemo)(()=>OB(r??[]),[r]),x=async t=>{if(p[t.id]){m(e=>{let{[t.id]:n,...r}=e;return r});return}m(e=>({...e,[t.id]:{phase:`loading`}}));let r=e=>{h.current&&m(n=>n[t.id]?{...n,[t.id]:e}:n)};if(!n.getAgyRequestBody)return r({phase:`gone`});try{let i=await n.getAgyRequestBody(e,t.id);r(i.request===null?{phase:`gone`}:{phase:`ready`,view:i})}catch(e){r(gm(e)?{phase:`gone`}:{phase:`failed`,message:lg(e)})}};if(a||r===null)return null;let S=e=>{let{title:t,detail:n}=kB(e),r=jB(e),i=NB(e.usage),a=p[e.id],o=[n,e.ms===null?`running…`:Qh(e.ms),i].filter(e=>!!e),s=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-faint`,title:ng(e.at),children:PB(e.at)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,children:t}),(0,G.jsx)(`span`,{className:W(`shrink-0 text-[11px] font-medium`,r.tone===`danger`?`text-danger`:`text-fg-muted`),"data-tone":r.tone,"data-testid":`agy-request-status-${e.id}`,children:r.text})]}),(0,G.jsx)(`span`,{className:`block break-words text-[11px] text-fg-faint`,children:o.join(` · `)}),e.error?(0,G.jsx)(`span`,{className:`block break-words text-[11px] text-danger`,children:e.error}):null]});return(0,G.jsxs)(`li`,{className:`rounded-md border border-border px-2 py-1`,"data-testid":`agy-request-${e.id}`,"data-kind":e.kind,children:[e.hasBody?(0,G.jsx)(`button`,{type:`button`,className:`block w-full text-left`,"aria-expanded":a!==void 0,title:`${AB(e)} — show the request`,onClick:()=>void x(e),"data-testid":`agy-request-open-${e.id}`,children:s}):(0,G.jsx)(`div`,{title:AB(e),children:s}),a?(0,G.jsx)(`div`,{className:`mt-1`,"data-testid":`agy-request-body-${e.id}`,children:a.phase===`loading`?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-fg-muted`,children:[(0,G.jsx)(J.Spinner,{className:`h-3 w-3`}),` Loading the request…`]}):a.phase===`gone`?(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-request-body-gone`,children:`This request’s body is no longer kept on this PC.`}):a.phase===`failed`?(0,G.jsxs)(`div`,{className:`text-[11px] text-danger`,role:`alert`,children:[`Could not read it: `,a.message]}):(0,G.jsx)(iH,{view:a.view})}):null]},e.id)};return(0,G.jsxs)(`div`,{className:`mb-2`,"data-testid":`agy-requests`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:text-fg-muted`,"aria-expanded":l,onClick:()=>u(e=>!e),"data-testid":`agy-requests-toggle`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:(0,G.jsx)(J.Chevron,{className:`h-3 w-3`,open:l})}),`Google agy requests`,(0,G.jsx)(`span`,{className:`font-mono normal-case tracking-normal`,"data-testid":`agy-requests-count`,children:r.length})]}),(0,G.jsx)(X,{label:`Refresh agy requests`,className:`p-1`,disabled:s,onClick:()=>void g(),"data-testid":`agy-requests-refresh`,children:s?(0,G.jsx)(J.Spinner,{className:`h-3 w-3`}):(0,G.jsx)(J.Refresh,{className:`h-3 w-3`})})]}),(0,G.jsx)(`p`,{className:`mb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`agy-requests-privacy`,children:TB}),l?(0,G.jsxs)(G.Fragment,{children:[y.length===0?(0,G.jsx)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-requests-empty`,children:`No model calls yet — they appear here as agy talks to Google.`}):(0,G.jsx)(`ul`,{className:`max-h-72 space-y-1 overflow-y-auto`,"data-testid":`agy-requests-main`,children:y.map(S)}),b.length>0?(0,G.jsxs)(`div`,{className:`mt-1.5`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-accent hover:underline`,"aria-expanded":d,onClick:()=>f(e=>!e),"data-testid":`agy-background-toggle`,children:[(0,G.jsx)(J.Chevron,{className:`h-3 w-3`,open:d}),`background calls (`,b.length,`)`]}),d?(0,G.jsx)(`ul`,{className:`mt-1 max-h-72 space-y-1 overflow-y-auto opacity-70`,"data-testid":`agy-requests-background`,children:b.map(S)}):null]}):null]}):null]})}function oH({label:e,icon:t,children:n}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-faint`,children:[t?(0,G.jsx)(`span`,{className:`shrink-0 text-fg-faint`,"aria-hidden":`true`,children:t}):null,e]}),(0,G.jsx)(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-fg`,children:n})]})}function sH({label:e,icon:t}){return(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:t}),e]})}var cH={provider:(0,G.jsx)(J.Plug,{className:`w-3.5 h-3.5`}),route:(0,G.jsx)(J.Globe,{className:`w-3.5 h-3.5`}),model:(0,G.jsx)(J.Bot,{className:`w-3.5 h-3.5`}),permission:(0,G.jsx)(J.Shield,{className:`w-3.5 h-3.5`}),context:(0,G.jsx)(J.Brain,{className:`w-3.5 h-3.5`}),window:(0,G.jsx)(J.Panel,{className:`w-3.5 h-3.5`}),compactions:(0,G.jsx)(J.CollapseAll,{className:`w-3.5 h-3.5`}),usage:(0,G.jsx)(J.Coins,{className:`w-3.5 h-3.5`}),tokensIn:(0,G.jsx)(J.Download,{className:`w-3.5 h-3.5`}),tokensOut:(0,G.jsx)(J.Upload,{className:`w-3.5 h-3.5`}),duration:(0,G.jsx)(J.Clock,{className:`w-3.5 h-3.5`}),turns:(0,G.jsx)(J.Send,{className:`w-3.5 h-3.5`}),session:(0,G.jsx)(J.Info,{className:`w-3.5 h-3.5`}),status:(0,G.jsx)(J.Monitor,{className:`w-3.5 h-3.5`}),updated:(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`}),entries:(0,G.jsx)(J.Menu,{className:`w-3.5 h-3.5`}),project:(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5`}),folder:(0,G.jsx)(J.Folder,{className:`w-3.5 h-3.5`})};function lH({used:e}){let t=Math.round(e*100);return(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Context used`,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,t>=90?`bg-danger`:t>=70?`bg-warn`:`bg-accent`),style:{width:`${t}%`}})})}function uH(){let{state:e,actions:t}=K(),n=Ty(),r=n?e.remote.tabs[n.id]!==void 0:!1,i=n?e.drafts[n.id]!==void 0:!1,a=wy(),o=e.currentSessionId,s=n?.projectId?e.vaultProjects.find(e=>e.id===n.projectId):void 0,c=s?.instructions.trim()??``,l=n?.providerId??e.activeProviderId,u=e.providers.find(e=>e.definition.id===l),d=u?.definition.models??(l?e.models[l]?.models:void 0),f=(0,v.useMemo)(()=>{let e=u?.definition;return e?js(e,{credentialClass:(u.credentials.find(e=>e.variantId===n?.variantId)??u.credentials[0])?.class??null}):null},[u,n?.variantId]),p=(0,v.useMemo)(()=>tH({items:a?.items??[],session:n,initModel:a?.init?.model??null,boundary:o?e.modelBoundaries[o]??null:null,models:d,contextTokens:a?.contextTokens??null}),[a?.items,a?.init?.model,a?.contextTokens,n,o,e.modelBoundaries,d]),m=(0,v.useMemo)(()=>(a?.items??[]).filter(e=>e.kind===`user`&&e.compactSummary).length,[a?.items]),h=n?Yp(n.providerId)&&!r&&!i:!1,g=a?.status===`running`||a?.status===`waiting_permission`;return(0,G.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border bg-surface`,"aria-label":`Session info`,"data-testid":`session-panel`,children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,G.jsx)(J.Info,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:`Session info`}),(0,G.jsx)(X,{label:`Hide session info`,className:`p-1`,onClick:()=>void t.savePrefs({sessionPanelOpen:!1}),children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]}),n?(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:[p.didReset?(0,G.jsxs)(`div`,{className:`mb-2 rounded-md bg-accent-soft px-2 py-1.5 text-[11px] text-accent`,"data-testid":`stats-reset`,children:[`Statistics restarted at the model change`,p.previousModel?` (was ${p.previousModel})`:``,`.`]}):null,!r&&!i?(0,G.jsx)(rH,{sessionId:n.id,entryCount:n.entryCount??null},n.id):null,(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(sH,{label:`Model`,icon:cH.model}),(0,G.jsx)(oH,{label:`Provider`,icon:cH.provider,children:u?.definition.displayName??l??`—`}),(0,G.jsx)(oH,{label:`Route`,icon:cH.route,children:f?(0,G.jsx)(Q,{tone:f.viaGateway?`accent`:`ok`,children:f.badge}):`—`}),f?(0,G.jsx)(`div`,{className:`pb-1 text-[11px] leading-snug text-fg-faint`,children:f.detail}):null,(0,G.jsx)(oH,{label:`Model`,icon:cH.model,children:p.model??n.model??`—`}),(0,G.jsxs)(oH,{label:`Permission mode`,icon:cH.permission,children:[(0,G.jsx)(Q,{children:te(ne(n))}),` `,(0,G.jsx)(Q,{children:n.permissionMode})]})]}),(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(sH,{label:`Context`,icon:cH.context}),p.contextUsed!==null&&p.contextTokens!==null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(lH,{used:p.contextUsed}),(0,G.jsxs)(`div`,{className:`mt-1 text-[11px] text-fg-muted`,"data-testid":`context-used`,children:[$h(p.contextTokens),` / `,$h(p.contextWindow??0),` `,`tokens (`,Math.round(p.contextUsed*100),`%)`]})]}):(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`context-used`,children:p.contextTokens===null?`Measured at the next reply`:`${$h(p.contextTokens)} tokens (window unknown)`}),(0,G.jsx)(oH,{label:`Context window`,icon:cH.window,children:(0,G.jsx)(`span`,{"data-testid":`context-window`,children:p.contextWindow?`${$h(p.contextWindow)} tokens`:`unknown`})}),(0,G.jsx)(oH,{label:`Compactions`,icon:cH.compactions,children:(0,G.jsx)(`span`,{"data-testid":`compaction-count`,children:m})})]}),(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(sH,{label:`Usage`,icon:cH.usage}),(0,G.jsx)(oH,{label:`Tokens in`,icon:cH.tokensIn,children:$h(p.inputTokens)}),(0,G.jsx)(oH,{label:`Tokens out`,icon:cH.tokensOut,children:$h(p.outputTokens)}),p.credits===null?null:(0,G.jsx)(oH,{label:`Credits used`,icon:cH.usage,children:p.credits.toLocaleString(`en-US`,{maximumFractionDigits:2})}),(0,G.jsx)(oH,{label:`Duration`,icon:cH.duration,children:p.countedResults>0&&Qh(p.durationMs)||`—`}),(0,G.jsx)(oH,{label:`Turns`,icon:cH.turns,children:p.countedResults>0?p.turns:`—`})]}),(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(sH,{label:`Session`,icon:cH.session}),(0,G.jsx)(oH,{label:`Status`,icon:cH.status,children:(0,G.jsx)(Q,{tone:a?.status===`error`?`danger`:a?.status===`running`?`accent`:a?.status===`waiting_permission`?`warn`:`neutral`,children:a?.status??n.status})}),(0,G.jsx)(oH,{label:`Updated`,icon:cH.updated,children:eg(n.updatedAt)}),(0,G.jsx)(oH,{label:`Entries`,icon:cH.entries,children:n.entryCount}),(0,G.jsx)(oH,{label:`Project`,icon:cH.project,children:(0,G.jsx)(`span`,{"data-testid":`session-project`,children:s?s.name:`—`})}),c?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words pb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`session-project-instructions`,children:c.length>300?`${c.slice(0,300)}\u2026`:c}):null,r?null:(0,G.jsx)(`button`,{type:`button`,className:`text-[11px] text-accent hover:underline`,onClick:()=>t.openAssignProject(n.id),"data-testid":`session-change-project`,children:s?`Move to another project…`:`Move to a project…`}),(0,G.jsx)(oH,{label:`Folder`,icon:cH.folder,children:n.projectDir?`project`:`own workspace`}),(0,G.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-fg-faint`,"data-testid":`session-folder`,children:n.cwd}),r?null:(0,G.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-accent hover:underline`,onClick:()=>t.openDialog(`project`),"data-testid":`session-change-folder`,children:`Change folder…`})]}),h?(0,G.jsx)(aH,{sessionId:n.id,running:g},n.id):null,r?null:(0,G.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`session-scheduled-tasks`,children:[(0,G.jsx)(sH,{label:`Scheduled tasks`,icon:cH.session}),(0,G.jsx)(BN,{sessionId:n.id})]}),a?.init?(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[`engine `,a.init.claudeCodeVersion,` · `,a.init.tools.length,` tools`]}):null]}):(0,G.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,children:`Open a chat to see its statistics.`})]})}function dH(e){let t=e=>e.type===`dir`?0:1;return[...e].sort((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name))}function fH(e){let t=[];return e.target.type===`file`&&t.push({key:`open`,label:`Open`,icon:(0,G.jsx)(J.File,{className:`w-3.5 h-3.5`}),onSelect:e.onOpen,testId:`files-menu-open`}),t.push({key:`copy-path`,label:`Copy path`,icon:(0,G.jsx)(J.Copy,{className:`w-3.5 h-3.5`}),disabled:!e.canCopyPath,onSelect:e.onCopyPath,testId:`files-menu-copy-path`},{key:`copy-relative-path`,label:`Copy relative path`,icon:(0,G.jsx)(J.Copy,{className:`w-3.5 h-3.5`}),onSelect:e.onCopyRelativePath,testId:`files-menu-copy-relative-path`}),!e.remote&&e.canDelete&&t.push({key:`delete`,label:`Delete…`,icon:(0,G.jsx)(J.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:e.onDelete,testId:`files-menu-delete`}),t}function pH(e,t){return t instanceof fm&&t.status===404&&/^no route for /.test(t.message)?`This host is too old to delete files — update it from the title bar.`:`Could not delete ${lj(e.path)}: ${t instanceof Error?t.message:String(t)}`}function mH(){let{state:e,dispatch:t,actions:n,api:r}=K(),i=Ty(),a=wy(),o=i?.id??null,s=o?e.remote.tabs[o]!==void 0:!1,c=a?.status===`running`||a?.status===`waiting_permission`,l=o?e.files[o]?.active??null:null,u=e.info?.platform??null,d=i?.cwd??``,[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(()=>new Set),[g,_]=(0,v.useState)(!1),y=(0,v.useRef)(f);y.current=f;let b=(0,v.useRef)(m);b.current=m;let x=(0,v.useRef)(o);x.current=o;let S=(0,v.useRef)(e.files);S.current=e.files;let[C,w]=(0,v.useState)(null),T=(0,v.useCallback)(()=>w(null),[]),E=(0,v.useCallback)((e,t,n)=>w({target:e,at:t,el:n}),[]),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(()=>O(null),[]),M=(0,v.useCallback)(async e=>{if(!o||!r.listSessionFiles)return;let t=o;p(t=>({...t,[e]:{...t[e]??{entries:null},loading:!0,error:null}}));try{let n=await r.listSessionFiles(t,e);if(x.current!==t)return;_(!1),p(t=>({...t,[e]:{entries:dH(n.entries),loading:!1,error:null}}))}catch(n){if(x.current!==t)return;gm(n)&&_(!0);let r=n instanceof Error?n.message:String(n);p(t=>({...t,[e]:{entries:t[e]?.entries??null,loading:!1,error:r}}))}},[r,o]);(0,v.useEffect)(()=>{p({}),h(new Set),_(!1),w(null),O(null),o&&!s&&M(``)},[o,s,M]);let N=(0,v.useRef)(c);(0,v.useEffect)(()=>{if(N.current&&!c&&o&&!s)for(let e of Object.keys(y.current))(e===``||b.current.has(e))&&M(e);N.current=c},[c,o,s,M]);let ee=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),y.current[e]?.entries||M(e)),n})},te=()=>{if(o){M(``);for(let e of m)M(e)}},P=(e,t)=>{KM(e).then(e=>n.toast(e?`success`:`error`,e?t:`Could not copy to the clipboard`))},F=async()=>{let e=D,i=o;if(!(!e||!i||!r.deleteSessionFile)){A(!0);try{await r.deleteSessionFile(i,e.path);for(let n of S.current[i]?.open??[])fj(n,e.path)&&t({type:`file_close`,sessionId:i,path:n});x.current===i&&(h(t=>new Set([...t].filter(t=>!fj(t,e.path)))),p(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!fj(t,e.path)))),M(dj(e.path))),n.toast(`success`,`Deleted ${lj(e.path)}`)}catch(t){n.toast(`error`,pH(e,t)),x.current===i&&M(dj(e.path))}finally{A(!1),O(null)}}},ne=C?fH({target:C.target,remote:s,canDelete:typeof r.deleteSessionFile==`function`,canCopyPath:d!==``,onOpen:()=>n.openFile(C.target.path),onCopyPath:()=>P(hj(d,C.target.path,u),`Path copied`),onCopyRelativePath:()=>P(mj(C.target.path,pj(d,u)),`Relative path copied`),onDelete:()=>O(C.target)}):[],re=()=>void n.savePrefs({explorerOpen:!1}),ie=i?.cwd?lj(i.cwd)||i.cwd:`Files`,I=f[``],L=C?.target.path??null,R=(0,v.useMemo)(()=>o?s?(0,G.jsx)(gH,{children:`This chat runs on another PC; its files can be browsed there.`}):g?(0,G.jsx)(gH,{children:`This host is too old to list files — update it from the title bar.`}):I?.error&&!I.entries?(0,G.jsx)(gH,{tone:`danger`,children:I.error}):I?.entries?I.entries.length===0?(0,G.jsx)(gH,{children:`The folder is empty.`}):(0,G.jsx)(`ul`,{role:`tree`,"aria-label":`Workspace files`,className:`py-1`,children:(0,G.jsx)(yH,{rel:``,depth:0,tree:f,expanded:m,activeFile:l,menuPath:L,onToggle:ee,onOpen:e=>n.openFile(e),onMenu:E})}):(0,G.jsx)(gH,{children:`Listing…`}):(0,G.jsx)(gH,{children:`Open a chat to browse the folder it works in.`}),[o,s,g,I,f,m,l,L,n]);return(0,G.jsxs)(`aside`,{className:`flex w-64 shrink-0 flex-col border-r border-border bg-surface`,"aria-label":`Files`,"data-testid":`file-explorer`,children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,G.jsx)(J.Folder,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,title:i?.cwd??void 0,children:ie}),(0,G.jsx)(X,{label:`Refresh files`,className:`p-1`,onClick:te,disabled:!o||s,"data-testid":`file-explorer-refresh`,children:(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(X,{label:`Hide files`,className:`p-1`,onClick:re,children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:R}),(0,G.jsx)(Zb,{open:C!==null,at:C?.at??{x:0,y:0},anchorEl:C?.el??null,label:`File actions`,testId:`files-context-menu`,onClose:T,items:ne}),(0,G.jsx)(hH,{target:D,absolute:D?d?hj(d,D.path,u):D.path:``,platform:u,busy:k,onConfirm:()=>void F(),onClose:j})]})}function hH({target:e,absolute:t,platform:n,busy:r,onConfirm:i,onClose:a}){let o=e?.type===`dir`;return(0,G.jsx)(Vy,{open:e!==null,title:o?`Delete this folder?`:`Delete this file?`,onClose:a,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:a,disabled:r,"data-testid":`files-delete-cancel`,children:`Cancel`}),(0,G.jsx)(Y,{variant:`danger`,busy:r,onClick:i,"data-testid":`files-delete-confirm`,children:`Delete permanently`})]}),children:(0,G.jsxs)(`div`,{className:`space-y-2 text-sm text-fg-muted`,"data-testid":`files-delete-dialog`,children:[(0,G.jsx)(`p`,{className:`break-all rounded bg-surface-2 px-2 py-1 font-mono text-xs text-fg`,children:t}),(0,G.jsxs)(`p`,{children:[o?`This folder and everything inside it will be deleted from the disk permanently.`:`This file will be deleted from the disk permanently.`,` `,`It does not go to the `,n===`win32`?`Recycle Bin`:`Trash`,`, and it cannot be undone.`]})]})})}function gH({children:e,tone:t}){return(0,G.jsx)(`div`,{className:W(`p-4 text-xs`,t===`danger`?`text-danger`:`text-fg-faint`),children:e})}function _H(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function vH(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?_H(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,_H(n.currentTarget),n.currentTarget))}}}function yH({rel:e,depth:t,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c}){let l=n[e];return l?l.error&&!l.entries?(0,G.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-danger`,style:{paddingLeft:`${.5+t*.75}rem`},children:l.error}):l.entries?(0,G.jsx)(G.Fragment,{children:l.entries.map(l=>{let u=uj(e,l.name),d=a===u;if(l.type===`dir`){let e=r.has(u);return(0,G.jsxs)(`li`,{role:`treeitem`,"aria-expanded":e,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(u),...vH({path:u,type:`dir`},c),"data-testid":`explorer-dir-${u}`,className:W(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs text-fg hover:bg-surface-2`,d&&`bg-surface-2`),style:{paddingLeft:`${.5+t*.75}rem`},children:[(0,G.jsx)(J.ChevronRight,{className:W(`w-3 h-3 shrink-0 text-fg-faint transition-transform`,e&&`rotate-90`)}),(0,G.jsx)(J.Folder,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,G.jsx)(`span`,{className:`truncate`,children:l.name})]}),e?(0,G.jsx)(`ul`,{role:`group`,children:(0,G.jsx)(yH,{rel:u,depth:t+1,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c})}):null]},u)}let f=i===u;return(0,G.jsx)(`li`,{role:`treeitem`,"aria-selected":f,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(u),...vH({path:u,type:l.type},c),disabled:l.type!==`file`,"data-testid":`explorer-file-${u}`,title:`${u} · ${Pj(l.size)}`,className:W(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs hover:bg-surface-2 disabled:opacity-50`,f?`bg-accent-soft text-accent`:d?`bg-surface-2 text-fg`:`text-fg`),style:{paddingLeft:`${.5+t*.75+.9}rem`},children:[(0,G.jsx)(J.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.name}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-faint`,children:Pj(l.size)})]})},u)})}):(0,G.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-fg-faint`,style:{paddingLeft:`${.5+t*.75}rem`},children:`Listing…`}):null}var bH={autoAccept:{hint:`Allow every tool the agent wants to use, without asking you. Off by default.`,details:[`Answered by this PC itself, so it covers EVERY chat running here — started in this app, the oona terminal, your phone, Telegram, the website or another PC.`,`The agent’s questions to you (its multiple-choice cards) still wait for your answer.`,`A chat set to Ask first in the composer still asks you before each tool — that is what Ask first means.`,`Subagents never ask: their tool requests are always allowed.`,`Takes effect at the next tool request, even in a chat that is already working.`,`What a chat may attempt at all is still its own Build / Plan / Ask first / Autonomous choice in the composer; this only answers the prompts it would have shown you.`]},reasoning:{hint:`Show the model’s thinking between its messages.`,details:[`Display only — the model thinks the same either way.`,`Hidden thinking is also left out of chat search (Ctrl+F).`,`For the windows this PC serves (this app, the local web UI). The phone has its own switch.`]},colourScheme:{hint:`System follows your desktop’s light or dark setting.`,details:[`Also colours this window’s title bar and menu.`,`Your own colours per element are under Theme.`]},notifications:{hint:`Desktop notifications from this app while its window is not in front.`,details:[`Nothing pops up while you are looking at the window.`,`Your phone’s push notifications are separate: the phone buzzes only while no window on this PC is open.`]},notifyFinished:{hint:`When a chat’s turn ends — finished, or failed.`,details:[`Named after the chat; clicking the notification opens it.`]},notifyWaiting:{hint:`When a chat waits for you: a permission, or one of the agent’s questions.`,details:[`With auto-accept on, only the agent’s questions still wait for you, so only they notify.`]},notifyError:{hint:`When a chat stops on an error.`,details:[`The error itself is also written into the chat.`]},transcriptWindow:{hint:`How many messages and tool cards of a chat stay drawn; older ones leave the top like a stack and come back when you scroll up.`,details:[`Only what is DRAWN: the whole chat is still kept, and still searched.`,`Smaller is faster on long agentic chats; larger keeps more on screen.`]},defaultCwd:{hint:`The folder a new chat runs in when it is not given one. Empty: each chat gets its own private folder.`,details:[`A folder here becomes each new chat’s project: its CLAUDE.md, .claude settings, hooks and skills load. Your home folder and drive roots never load as a project.`,`Empty is the safe default: the agent then works only inside that chat’s own folder under OonaCode’s data directory.`,`Used by chats started in this app. A project’s own folder (Projects → New chats) wins over it; the oona terminal always uses the folder you run it in.`]},remoteAccess:{hint:`Let your phone, Telegram, the website and your other PCs reach this PC.`,details:[`This PC keeps one outbound, end-to-end encrypted channel to your OonaCode server; every other device reaches it through that channel alone.`,`It is also how they read this PC’s chats: the chats are kept only here, never on our server, so they can be read while this PC is on and reachable.`,`Off: they still see this PC online, marked “remote access off”, and cannot list or open its chats, send prompts, unlock it remotely or delete its chats. This PC also cannot open chats on your other PCs.`,`Takes effect immediately.`]},imageRetention:{hint:`Pictures in this PC’s chat history older than this are replaced with a short note. 0 keeps them forever. Default: a year.`,details:[`Replaced: the pictures stored in this PC’s chats — screenshots and other pictures a tool returned, and pictures you pasted into a message — once they are older than this.`,`Each becomes a one-line note saying a picture was there, why and when it went, e.g. “[Picture removed after 365 days to save space — picture from a tool (PNG), 412 KB]”.`,`Not affected: the words of every chat, and the files on your disk. The chat continues normally — the model no longer needs pictures that old.`,`Runs by itself: a few minutes after this PC’s OonaCode starts, then once a day, in small steps that never hold up a chat. A chat that is working, or was in the last hour, is done at the next run.`,`The database file stops growing from pictures; it does not shrink. The space is reused for new chats.`,`Only this PC holds its chats, so this is every copy there is.`]},chatAbout:{hint:`A short note per chat saying what it works on, which your other chats read through “Talk to other chats”. On by default.`,details:[`Written in the background by each chat’s housekeeper — the cheap helper model of the chat’s own provider — after a turn ends, only when the chat changed since, and at most once per interval below.`,`The same switch covers Regenerate (in a chat’s session info) and “Generate for all chats now” (View → What chats are about…). Off stops all three, so nothing is spent on abouts.`,`Paid by the chat’s own route: an OonaCode pool chat spends credits, your own API key is billed by your provider, and your own subscription’s plan covers it.`,`An about is part of its chat and stays on this PC: it is never uploaded to our server, and your other devices read it from this PC, like the chat.`]},chatAboutInterval:{hint:`At most one background about per chat in this many minutes.`,details:[`Only the background job waits for it: Regenerate and “Generate for all chats now” write at once.`,`A background about is written only after a turn ends and only when the chat changed, so a chat nobody uses costs nothing, whatever this says.`,`Shorter keeps abouts fresher and makes more calls.`]},chatAboutMaxWords:{hint:`The longest about the housekeeper may write.`,details:[`A longer answer is cut at this many words.`,`Applies to every about the housekeeper writes: in the background, by Regenerate and by “Generate for all chats now”. An about you write yourself may be longer (up to 2,000 characters).`,`A longer about costs a few more output tokens, and a chat that lists your chats reads every one of them.`]},chatAboutInputChars:{hint:`How much of a chat the housekeeper reads to write its about.`,details:[`Taken from the chat’s title, project and folder, its previous about, your first message, the newest summary of the earlier conversation, your latest messages and the agent’s last answer — each with a share, so no part crowds out the others.`,`Applies to the background job, Regenerate and “Generate for all chats now”.`,`Most of what a call costs: roughly a quarter as many tokens as characters. More gives a better-informed about and costs more.`]},keepUnlocked:{hint:`Leave your vault unlocked when you close or quit the app.`,details:[`Off (default): closing the window — to the tray too — or quitting stops the chats that are running and locks this PC until you unlock it. Your phone and other devices cannot use it meanwhile.`,`On: chats keep running and your other devices keep working after the window is closed. Choose it on a PC only you use.`]},server:{hint:`Your account’s OonaCode server.`,details:[`Where your account lives: sign-in, OonaCode-pool models and credits, your encrypted vault and chat history, remote access, and app updates.`,`Your own API keys and subscriptions never go through it — this PC calls those providers directly.`,`Set by signing in. (Developers point a build at another server with OONACODE_GATEWAY_URL.)`]},diagnostics:{hint:`While you are signed in, this PC sends OonaCode its warnings and errors, and a short report of any turn that fails.`,details:[`A report names the error, the model and the provider — never the content of your chats.`,`It is how bugs you never reported get fixed. There is no usage tracking.`]},allowDebugging:{hint:`Let a debugger attach to this app’s windows, to see and control them while fixing a bug. Off by default. Takes effect when OonaCode restarts.`,details:[`For finding bugs together: DevTools (chrome://inspect), Playwright or another Chrome DevTools Protocol client attaches to every window of this app — reads what it shows, clicks, types and runs code in it.`,`The risk: while it is on, ANY program on this PC can do the same — read your chats on screen and act as you in OonaCode, with no prompt. Turn it on only while you need it.`,`Only on this PC: the port is opened on 127.0.0.1, never on the network, and web pages in your browser cannot connect to it.`,`Desktop app only, this PC only: the local web UI in a browser, the phone, Telegram and your other PCs are not affected.`,`Read when the app starts, so a change applies at the next start (Restart now). The host service and your chats keep running through the restart.`,`While it is on, every window shows a red “Debugging on” badge and says so in its title.`]},debugPort:{hint:`The port on 127.0.0.1 a debugger connects to.`,details:[`Connect with http://127.0.0.1:<port> — e.g. chrome://inspect → Configure… → localhost:<port>, or Playwright’s connectOverCDP.`,`A port another program already uses is refused when you save.`,`With “Also debug the main process”, the next port is taken too.`]},debugMainProcess:{hint:`Also open Node’s inspector for the app’s main process, on the next port.`,details:[`For bugs in the desktop shell itself (windows, menus, updates, the tray), not in a window’s page.`,`Gives full control of the main process — it can run any program as you. Off unless you choose it.`,`Applies only while “Allow debugging” is on, at the next start.`]}};function xH(e){if(!bc(e))return`Off in this run: no debugging port is open.`;let t=[];return e.port!==null&&t.push(e.listening?`On in this run: windows on 127.0.0.1:${e.port}${e.fromCommandLine?` (from the command line)`:``}.`:`Port ${e.port} could not be opened — another program may be using it.`),e.inspectPort!==null&&t.push(e.inspectProblem?`Main-process inspector: ${e.inspectProblem}`:`Main process on 127.0.0.1:${e.inspectPort}.`),t.join(` `)}function SH(e){return xc(e.saved,e.running)}function CH(e){return`Debugging is on: ${Sc(e)}. While it is on, any program on this PC can read and control OonaCode. Click to change it in Settings → Developer.`}function wH({providerId:e,configured:t}){let{api:n,state:r,actions:i}=K(),[a,o]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(t||!n.getAgyStatus)return;let e=!0;return n.getAgyStatus().then(t=>{e&&o({state:t.state,install:t.install})},()=>{e&&o(null)}),()=>{e=!1}},[n,t,r.providers]),(0,G.jsx)(Y,{size:`sm`,variant:t?`secondary`:`primary`,onClick:()=>i.openProviderConnect(e),"data-testid":`agy-provider-button`,children:JB(t,a)})}function TH(){let{actions:e}=K(),[t,n]=(0,v.useState)(void 0),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null),s=(0,v.useCallback)(async()=>{n(await e.listSkills())},[e]);return(0,v.useEffect)(()=>{s()},[s]),t===`unsupported`?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`This PC’s OonaCode is older than skills — update it to manage them here.`}):r?(0,G.jsx)(EH,{onDone:()=>{i(!1),iF(),uN(),s()}}):(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-section`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Skills every chat on this PC gets — type `,(0,G.jsx)(`span`,{className:`font-mono`,children:`/`}),` in the message box to use one for that message. They work with every model. A change applies from a chat’s next start (a new chat, or one idle for ten minutes).`]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-per-chat-note`,children:[`The model is not shown them on its own: each chat chooses which skills the model may use by itself, in the `,(0,G.jsx)(`span`,{className:`font-medium`,children:`Skills`}),` menu under its message box — only those cost tokens on every message of that chat.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Y,{size:`sm`,onClick:()=>i(!0),"data-testid":`skills-import-open`,children:[(0,G.jsx)(J.Download,{className:`h-3.5 w-3.5`}),` Import from Claude Code…`]}),t?(0,G.jsx)(`span`,{className:`truncate text-[11px] text-fg-faint`,title:t.dir,children:t.dir}):null]}),t===void 0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t===null?(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not list the skills right now.`}):t.skills.length===0?(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-empty`,children:[`No skills of your own yet. Import them from Claude Code, or put a folder with a`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:`SKILL.md`}),` in the folder above.`]}):(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.skills.map(t=>(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2 text-sm`,"data-testid":`skill-row`,"data-name":t.name,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,t.name]}),t.argumentHint?(0,G.jsx)(`span`,{className:`font-mono text-xs text-fg-faint`,children:t.argumentHint}):null,t.broken?(0,G.jsx)(Q,{tone:`warn`,children:`no SKILL.md`}):null]}),t.description?(0,G.jsx)(`div`,{className:`line-clamp-2 text-xs text-fg-muted`,title:t.description,children:t.description}):null,(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[Pj(t.bytes),` · `,t.files,` file`,t.files===1?``:`s`,t.importedFrom?(0,G.jsxs)(G.Fragment,{children:[` `,`· imported `,t.importedAt?eg(t.importedAt):``,` from`,` `,(0,G.jsx)(`span`,{title:t.importedFrom,children:t.importedFrom})]}):null]})]}),(0,G.jsxs)(Y,{size:`sm`,variant:`ghost`,busy:a===t.name,"aria-label":`Remove ${t.name}`,onClick:async()=>{o(t.name);let n=await e.removeSkill(t.name);o(null),n&&(iF(),uN(),await s())},"data-testid":`skill-remove`,children:[(0,G.jsx)(J.Trash,{className:`h-3.5 w-3.5`}),` Remove`]})]},t.name))})]})}function EH({onDone:e}){let{actions:t}=K(),[n,r]=(0,v.useState)(void 0),[i,a]=(0,v.useState)(()=>new Set),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!0;return t.scanClaudeSkills().then(t=>{e&&r(t)}),()=>{e=!1}},[t]);let f=(0,v.useMemo)(()=>{let e=new Map;for(let t of n?.skills??[]){let n=t.origin===`plugin`?`Plugin: ${t.plugin??`?`}`:`Your skills`;e.set(n,[...e.get(n)??[],t])}return[...e.entries()]},[n]),p=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-import`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:e,children:`← Back`}),(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Import skills from Claude Code`})]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick the skills to copy into OonaCode. Your Claude Code install is only read — nothing in it is changed.`,n?.roots.length?(0,G.jsxs)(G.Fragment,{children:[` `,`Read from `,(0,G.jsx)(`span`,{className:`font-mono`,children:n.roots.join(`, `)}),`.`]}):null]}),n===void 0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Looking…`}):n===null?(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not read Claude Code’s skills.`}):n.skills.length===0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-import-empty`,children:`No skills found in Claude Code on this PC.`}):f.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-fg-faint`,children:e}),(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>{let t=!!e.unavailable||e.alreadyInOonaCode&&!o;return(0,G.jsx)(`li`,{className:`px-3 py-1.5 text-sm`,children:(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i.has(e.key)&&!t,disabled:t,onChange:()=>p(e.key),"data-testid":`skills-import-pick`,"data-name":e.name}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,e.name]}),` `,e.alreadyInOonaCode?(0,G.jsx)(Q,{children:`already in OonaCode`}):null,` `,e.unavailable?(0,G.jsx)(Q,{tone:`warn`,children:e.unavailable}):null,e.description?(0,G.jsx)(`span`,{className:`line-clamp-2 block text-xs text-fg-muted`,children:e.description}):null,e.note?(0,G.jsx)(`span`,{className:`block text-[11px] text-warn`,children:e.note}):null,(0,G.jsxs)(`span`,{className:`block text-[11px] text-fg-faint`,children:[Pj(e.bytes),` · `,e.path]})]})]})},e.key)})})]},e)),n&&n.skills.some(e=>e.alreadyInOonaCode)?(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Replace the ones already in OonaCode`]}):null,u?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,"data-testid":`skills-import-outcome`,children:u}):null,(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(Y,{variant:`primary`,size:`sm`,busy:c,disabled:i.size===0,"data-testid":`skills-import-go`,onClick:async()=>{l(!0);let n=await t.importClaudeSkills([...i],o);if(l(!1),!n)return;let r=n.skipped.map(e=>`${e.name||e.key}: ${e.reason}`);d(`Imported ${n.imported.length}`+(r.length>0?` · skipped ${r.join(`; `)}`:``)),n.skipped.length===0&&e()},children:[`Import `,i.size>0?i.size:``]}),(0,G.jsx)(Y,{size:`sm`,onClick:e,children:`Cancel`})]})]})}var DH=[{id:`general`,label:`General`,icon:J.Settings},{id:`theme`,label:`Theme`,icon:J.Palette},{id:`advanced`,label:`Advanced`,icon:J.Sliders},{id:`skills`,label:`Skills`,icon:J.Tool},{id:`providers`,label:`Providers`,icon:J.Plug},{id:`devices`,label:`Devices`,icon:J.Monitor},{id:`host`,label:`This PC`,icon:J.Stethoscope},{id:`developer`,label:`Developer`,icon:J.Bug}];function OH(){let e=typeof window<`u`?window.oonacode:void 0;return e?.getDebugging&&e.setDebugging?e:null}function kH(){let{state:e,actions:t}=K(),n=e.prefs,r=e.settings?.theme??`system`;return(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(Hy,{label:`Auto-accept permissions`,hint:bH.autoAccept.hint,details:bH.autoAccept.details,checked:n.autoAcceptPermissions,onChange:e=>void t.savePrefs({autoAcceptPermissions:e}),testId:`settings-auto-accept`}),(0,G.jsx)(Hy,{label:`Show reasoning in the timeline`,hint:bH.reasoning.hint,details:bH.reasoning.details,checked:n.showReasoningSummaries,onChange:e=>void t.savePrefs({showReasoningSummaries:e})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border py-3`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Colour scheme`,(0,G.jsx)(Ly,{label:`Colour scheme`,details:(0,G.jsx)(Ry,{items:bH.colourScheme.details})})]}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-faint`,children:bH.colourScheme.hint})]}),(0,G.jsx)(Uy,{label:`Colour scheme`,value:r,options:[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],onChange:e=>void t.saveSettings({theme:e})})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,G.jsx)(J.Bell,{className:`w-3 h-3`}),` Notifications`,(0,G.jsx)(Ly,{label:`Notifications`,details:(0,G.jsx)(Ry,{items:bH.notifications.details})})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-faint`,children:bH.notifications.hint}),(0,G.jsx)(Hy,{label:`Agent finished or needs attention`,hint:bH.notifyFinished.hint,details:bH.notifyFinished.details,checked:n.notifications.agentFinished,onChange:e=>void t.savePrefs({notifications:{...n.notifications,agentFinished:e}})}),(0,G.jsx)(Hy,{label:`Permission or question waiting for you`,hint:bH.notifyWaiting.hint,details:bH.notifyWaiting.details,checked:n.notifications.permissionRequired,onChange:e=>void t.savePrefs({notifications:{...n.notifications,permissionRequired:e}})}),(0,G.jsx)(Hy,{label:`Error occurred`,hint:bH.notifyError.hint,details:bH.notifyError.details,checked:n.notifications.errorOccurred,onChange:e=>void t.savePrefs({notifications:{...n.notifications,errorOccurred:e}})})]}),e.prefsBackend===`local`?(0,G.jsx)(`div`,{className:`mt-2 rounded-md bg-warn-soft px-3 py-2 text-xs text-warn`,children:`This host does not store UI preferences yet, so they are kept on this device only.`}):null]})}function AH(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function jH(e){let t={};if(typeof document>`u`||typeof getComputedStyle!=`function`)return t;let n=document.documentElement,r=n.getAttribute(`data-theme`),i=[];for(let e of Mc){let t=n.style.getPropertyValue(`--${e}`);t&&i.push([e,t]),n.style.removeProperty(`--${e}`)}n.setAttribute(`data-theme`,e);let a=getComputedStyle(n);for(let e of Mc){let n=a.getPropertyValue(`--${e}`).trim();t[e]=/^#[0-9a-fA-F]{6}$/.test(n)?n.toLowerCase():`#808080`}r===null?n.removeAttribute(`data-theme`):n.setAttribute(`data-theme`,r);for(let[e,t]of i)n.style.setProperty(`--${e}`,t);return t}function MH(){let{state:e,actions:t}=K(),n=e.prefs,[r,i]=(0,v.useState)(`dark`),a=(0,v.useMemo)(()=>jH(r),[r]),[o,s]=(0,v.useState)({}),c=(0,v.useRef)(o);c.current=o;let l=(0,v.useRef)(n.themeColors);l.current=n.themeColors;let u=(0,v.useRef)(null),d=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)};(0,v.useEffect)(()=>d,[]);let f=e=>{d();let n=c.current;Object.keys(n).length!==0&&(s({}),t.savePrefs({themeColors:{...l.current,[e]:{...l.current[e],...n}}}))},p=(e,t)=>{s(n=>({...n,[e]:t})),c.current={...c.current,[e]:t},d(),u.current=window.setTimeout(()=>f(r),300)},m={...l.current[r],...o},h=Object.keys(m).length,g=e=>{d(),s({});let n={...m};delete n[e],t.savePrefs({themeColors:{...l.current,[r]:n}})};return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Theme colours`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-faint`,children:`Choose any colour for any element. A colour you do not choose keeps the theme's own value. Your colours follow your account to every PC.`})]}),(0,G.jsx)(Uy,{label:`Edit colour scheme`,value:r,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:e=>{f(r),i(e)}})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-x-4 sm:grid-cols-2`,children:Mc.map(e=>{let t=m[e]!==void 0,n=m[e]??a[e]??`#808080`;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5`,"data-testid":`theme-color-row-${r}-${e}`,children:[(0,G.jsx)(`input`,{type:`color`,className:`h-6 w-9 shrink-0 cursor-pointer rounded border border-border bg-transparent p-0.5`,value:n,onChange:t=>p(e,t.target.value),"aria-label":`${AH(e)} colour (${r} scheme)`,"data-testid":`theme-color-${r}-${e}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:AH(e)}),(0,G.jsx)(`span`,{className:`w-16 shrink-0 text-right font-mono text-[10px] text-fg-faint`,children:t?m[e]:`default`}),t?(0,G.jsx)(X,{label:`Reset ${AH(e)} to the theme colour`,className:`p-0.5`,"data-testid":`theme-color-clear-${r}-${e}`,onClick:()=>g(e),children:(0,G.jsx)(J.Refresh,{className:`w-3 h-3`})}):null]},e)})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border pt-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`theme-colors-count`,children:h===0?`No custom colours in the ${r} scheme.`:`${h} custom colour${h===1?``:`s`} in the ${r} scheme.`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{d(),s({}),t.savePrefs({themeColors:{...l.current,[r]:{}}})},disabled:h===0,"data-testid":`theme-reset-${r}`,children:`Reset all`})]})]})}function NH(){let{state:e,actions:t}=K(),n=e.prefs,[r,i]=(0,v.useState)(String(n.transcriptWindowSize));return(0,v.useEffect)(()=>i(String(n.transcriptWindowSize)),[n.transcriptWindowSize]),(0,G.jsx)(`div`,{className:`space-y-1`,children:(0,G.jsx)(zy,{label:`Transcript window size`,hint:`${bH.transcriptWindow.hint} Scrolling to the top brings back 100 more. 100–${Ac}, default 500.`,details:bH.transcriptWindow.details,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`w-32`),type:`number`,min:100,max:Ac,step:100,value:r,onChange:e=>i(e.target.value),onBlur:()=>{let e=Number.parseInt(r,10);Number.isFinite(e)&&t.savePrefs({transcriptWindowSize:e})},"aria-label":`Transcript window size`}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:`messages and tool cards`})]})})})}function PH(){let{state:e,actions:t}=K(),n=(0,v.useMemo)(()=>ks(e.providers),[e.providers]);return(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[n.length===0?(0,G.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No providers in the registry.`}):null,n.map(n=>{let r=n.definition,i=e.activeProviderId===r.id,a=Os(e.providers,r.id),o=a.some(e=>e.configured),s=[...new Set(a.flatMap(e=>(e.credentials??[]).map(e=>e.class)))].filter(e=>e!==`none`);return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`provider-${r.id}`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:r.displayName}),i?(0,G.jsx)(Q,{tone:`accent`,children:`active`}):null,r.route===`direct`?(0,G.jsx)(Q,{tone:`ok`,children:`direct`}):null,s.length>0?s.map(e=>(0,G.jsxs)(Q,{tone:`ok`,children:[e===`subscription`?`subscription`:`API key`,` connected`]},e)):o?(0,G.jsx)(Q,{tone:`ok`,children:`connected`}):(0,G.jsx)(Q,{tone:`warn`,children:`not connected`})]}),(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[r.models.length,` model`,r.models.length===1?``:`s`,r.credentialVariants?.length?` · ${r.credentialVariants.map(e=>e.label).join(` / `)}`:``]})]}),r.engine===`agy`?(0,G.jsx)(wH,{providerId:r.id,configured:o}):(0,G.jsxs)(Y,{size:`sm`,variant:o?`secondary`:`primary`,onClick:()=>t.openProviderConnect(r.id),children:[(0,G.jsx)(J.Plus,{className:`w-3 h-3`}),` `,o?`Manage…`:`Connect`]})]},r.id)}),(0,G.jsx)(`div`,{className:`pt-3`,children:(0,G.jsx)(DR,{})})]})}function FH(){let{state:e,actions:t}=K(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``);return(0,v.useEffect)(()=>{t.refreshHosts()},[t]),e.account?.loggedIn?e.remote.supported?(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[e.remote.loading?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,G.jsx)(J.Spinner,{}),` Loading devices…`]}):null,e.remote.hosts.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,children:[(0,G.jsx)(J.Monitor,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:n===e.hostId?(0,G.jsx)(`input`,{className:Z,value:i,autoFocus:!0,"aria-label":`Label for ${e.hostName}`,onChange:e=>a(e.target.value),onKeyDown:n=>{n.key===`Enter`&&i.trim()?(t.renameHost(e.hostId,i.trim()),r(null)):n.key===`Escape`&&r(null)}}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[e.label||e.hostName,e.isSelf?(0,G.jsx)(Q,{tone:`accent`,children:`this PC`}):null,(0,G.jsx)(Q,{tone:e.online?`ok`:`neutral`,children:e.online?`online`:`offline`}),e.remoteAccessOff?(0,G.jsx)(Q,{tone:`warn`,children:`remote access off`}):null]}),(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[e.platform,e.appVersion?` · v${e.appVersion}`:``,e.lastSeenAt?` · seen ${eg(e.lastSeenAt)}`:``]})]})}),n===e.hostId?(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>{i.trim()&&t.renameHost(e.hostId,i.trim()),r(null)},children:`Save`}):(0,G.jsxs)(Y,{size:`sm`,onClick:()=>{r(e.hostId),a(e.label||e.hostName)},children:[(0,G.jsx)(J.Edit,{className:`w-3 h-3`}),` Rename`]})]},e.hostId)),!e.remote.loading&&e.remote.hosts.length===0?(0,G.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No devices reported yet.`}):null]}):(0,G.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-3 text-sm text-fg-muted`,children:[`This host build cannot list your account's devices yet (the relay lands with the server phase). This PC is `,(0,G.jsx)(`strong`,{children:e.connection.hostName??`unknown`}),`.`]}):(0,G.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`Sign in to see the devices on your account.`})}function IH(e,t,n=Date.now()){if(e===0)return`Off — pictures are kept forever.`;if(!t)return`Not run yet — it runs a few minutes after OonaCode starts, then daily.`;let r=eg(t.finishedAt,n);return t.pictures===0?`Last run: nothing to replace, ${r}.`:`Last run: ${t.pictures.toLocaleString(`en-US`)} ${t.pictures===1?`picture`:`pictures`}, ${Pj(t.bytesFreed)}, ${r}.`}function LH({days:e,lastRun:t,onSave:n}){let[r,i]=(0,v.useState)(String(e));(0,v.useEffect)(()=>i(String(e)),[e]);let a=()=>{let t=Number.parseInt(r,10);if(!Number.isFinite(t)){i(String(e));return}let a=t<=0?0:Math.min(Xc,Math.max(1,t));i(String(a)),a!==e&&n(a)};return(0,G.jsxs)(zy,{label:`Replace pictures older than`,hint:bH.imageRetention.hint,details:bH.imageRetention.details,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`w-24`),type:`number`,min:0,max:Xc,step:1,value:r,onChange:e=>i(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a()},"aria-label":`Replace pictures older than (days)`,"data-testid":`settings-image-retention`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`days`,e===365?` (a year)`:``]})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`settings-image-retention-status`,children:IH(e,t)})]})}function RH(e,t,n){let r=e.trim(),i=Number(r);return!/^\d+$/.test(r)||i<t||i>n?`A whole number from ${t.toLocaleString(`en-US`)} to ${n.toLocaleString(`en-US`)}.`:null}function zH({label:e,unit:t,hint:n,details:r,value:i,min:a,max:o,defaultValue:s,onSave:c,testId:l}){let[u,d]=(0,v.useState)(String(i)),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{d(String(i)),p(null)},[i]);let m=()=>{let e=RH(u,a,o);if(p(e),e)return;let t=Number(u.trim());t!==i&&c(t)},h=e=>e.toLocaleString(`en-US`);return(0,G.jsxs)(zy,{label:e,hint:`${n} ${h(a)}–${h(o)}, default ${h(s)}.`,details:r,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`w-28`,f&&`border-danger`),type:`number`,min:a,max:o,step:1,value:u,onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m()},"aria-label":e,"aria-invalid":f!==null,"data-testid":l}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:t})]}),f?(0,G.jsx)(`span`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`${l}-problem`,children:f}):null]})}function BH({settings:e}){let{actions:t}=K(),n=Wl,r=Ul;return(0,G.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`settings-chat-abouts`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Chat abouts`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>t.openChatAbouts(),"data-testid":`settings-open-chat-abouts`,children:`What your chats are about…`})]}),e.chatAboutEnabled===void 0?null:(0,G.jsx)(Hy,{label:`Write an about for every chat`,hint:bH.chatAbout.hint,details:bH.chatAbout.details,checked:e.chatAboutEnabled,onChange:e=>void t.saveSettings({chatAboutEnabled:e}),testId:`settings-chat-about-enabled`}),(0,G.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[e.chatAboutIntervalMinutes===void 0?null:(0,G.jsx)(zH,{label:`Minutes between background abouts`,unit:`minutes`,hint:bH.chatAboutInterval.hint,details:bH.chatAboutInterval.details,value:e.chatAboutIntervalMinutes,min:n.intervalMinutes.min,max:n.intervalMinutes.max,defaultValue:r.intervalMinutes,onSave:e=>void t.saveSettings({chatAboutIntervalMinutes:e}),testId:`settings-chat-about-interval`}),e.chatAboutMaxWords===void 0?null:(0,G.jsx)(zH,{label:`Longest about`,unit:`words`,hint:bH.chatAboutMaxWords.hint,details:bH.chatAboutMaxWords.details,value:e.chatAboutMaxWords,min:n.maxWords.min,max:n.maxWords.max,defaultValue:r.maxWords,onSave:e=>void t.saveSettings({chatAboutMaxWords:e}),testId:`settings-chat-about-max-words`}),e.chatAboutInputChars===void 0?null:(0,G.jsx)(zH,{label:`How much of a chat is read`,unit:`characters`,hint:bH.chatAboutInputChars.hint,details:bH.chatAboutInputChars.details,value:e.chatAboutInputChars,min:n.inputChars.min,max:n.inputChars.max,defaultValue:r.inputChars,onSave:e=>void t.saveSettings({chatAboutInputChars:e}),testId:`settings-chat-about-input-chars`})]})]})}function VH(){let{state:e,actions:t}=K(),n=e.settings,[r,i]=(0,v.useState)(n?.defaultCwd??``);if((0,v.useEffect)(()=>i(n?.defaultCwd??``),[n?.defaultCwd]),(0,v.useEffect)(()=>{t.refreshSettings()},[t]),!n)return(0,G.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading settings…`});let a=e.account?.gatewayUrl??n.gatewayUrl??x,o=e=>{let r=e.trim()?e.trim():null;r!==(n.defaultCwd??null)&&t.saveSettings({defaultCwd:r})},s=async()=>{let e=await window.oonacode?.pickDirectory?.({title:`The folder new chats run in`,...r?{defaultPath:r}:{}});e&&(i(e),o(e))};return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(zy,{label:`Default working directory`,hint:bH.defaultCwd.hint,details:bH.defaultCwd.details,children:(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`flex-1 font-mono text-xs`),value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),placeholder:`Empty — each chat gets its own folder`,spellCheck:!1,"data-testid":`settings-default-cwd`}),window.oonacode?.pickDirectory?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>void s(),children:`Choose…`}):null,r?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{i(``),o(``)},children:`Clear`}):null]})}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-1`,children:[(0,G.jsx)(Hy,{label:`Remote access`,hint:bH.remoteAccess.hint,details:bH.remoteAccess.details,checked:n.relayEnabled??!0,onChange:e=>void t.saveSettings({relayEnabled:e}),testId:`settings-relay`}),(0,G.jsx)(Hy,{label:`Keep the vault unlocked when the app closes`,hint:bH.keepUnlocked.hint,details:bH.keepUnlocked.details,checked:n.keepUnlockedOnExit??!1,onChange:e=>void t.saveSettings({keepUnlockedOnExit:e}),testId:`settings-keep-unlocked-exit`})]}),n.imageRetentionDays===void 0?null:(0,G.jsx)(`div`,{className:`border-t border-border pt-3`,children:(0,G.jsx)(LH,{days:n.imageRetentionDays,lastRun:n.imageRetentionLastRun??null,onSave:e=>void t.saveSettings({imageRetentionDays:e})})}),n.chatAboutEnabled!==void 0||n.chatAboutIntervalMinutes!==void 0||n.chatAboutMaxWords!==void 0||n.chatAboutInputChars!==void 0?(0,G.jsx)(BH,{settings:n}):null,(0,G.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Server`,(0,G.jsx)(Ly,{label:`Server`,details:(0,G.jsx)(Ry,{items:bH.server.details})})]}),(0,G.jsx)(`span`,{className:`block text-fg-faint`,children:bH.server.hint})]}),(0,G.jsx)(`span`,{className:`break-all font-mono text-fg-muted`,"data-testid":`settings-server`,children:a})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Diagnostics`,(0,G.jsx)(Ly,{label:`Diagnostics`,details:(0,G.jsx)(Ry,{items:bH.diagnostics.details})})]}),(0,G.jsx)(`span`,{className:`block text-fg-faint`,children:bH.diagnostics.hint})]})]})]})}function HH(e){return e instanceof Error?e.message:String(e)}function UH(){let e=OH(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),l=(0,v.useRef)(Promise.resolve());if((0,v.useEffect)(()=>{if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&(n(e),o(String(e.saved.port)))},e=>{t&&i(HH(e))}),()=>{t=!1}},[e]),!e)return(0,G.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Debugging is a setting of the OonaCode desktop app.`});if(!t)return r?(0,G.jsx)(`div`,{className:`py-6 text-sm text-danger`,role:`alert`,children:r}):(0,G.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading…`});let u=t=>{l.current=l.current.then(async()=>{try{let r=await e.setDebugging(t);n(r.state),i(r.ok?null:r.problem??`Not saved.`),r.ok&&o(String(r.state.saved.port))}catch(e){i(HH(e))}})},d=()=>{let e=a.trim(),n=/^\d+$/.test(e)?Number(e):NaN,r=yc(n);if(r){i(r);return}if(n===t.saved.port){i(null);return}u({port:n})},f=async()=>{try{let t=await e.relaunchApp();t.started?c(t.message||`OonaCode is restarting…`):i(t.message||`OonaCode could not restart.`)}catch(e){i(HH(e))}},p=SH(t),m=r!==null&&/^(The port|Ports?) /.test(r);return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`settings-developer`,children:[(0,G.jsx)(Hy,{label:`Allow debugging`,hint:bH.allowDebugging.hint,details:bH.allowDebugging.details,checked:t.saved.enabled,onChange:e=>u({enabled:e}),testId:`settings-allow-debugging`}),(0,G.jsx)(zy,{label:`Debugging port`,hint:`${bH.debugPort.hint} ${mc}–${hc}, default ${pc}.`,details:bH.debugPort.details,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`max-w-28`,m&&`border-danger`),type:`number`,min:mc,max:hc,step:1,value:a,onChange:e=>o(e.target.value),onBlur:d,onKeyDown:e=>{e.key===`Enter`&&d()},"aria-label":`Debugging port`,"aria-invalid":m,"data-testid":`settings-debug-port`}),(0,G.jsx)(`span`,{className:`whitespace-nowrap text-xs text-fg-faint`,children:`on 127.0.0.1`})]})}),(0,G.jsx)(Hy,{label:`Also debug the main process`,hint:bH.debugMainProcess.hint,details:bH.debugMainProcess.details,checked:t.saved.inspectMain,disabled:!t.saved.enabled,onChange:e=>u({inspectMain:e}),testId:`settings-debug-main`}),r?(0,G.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`settings-debugging-problem`,children:r}):null,(0,G.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`settings-debugging-status`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:xH(t.running)}),p?(0,G.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-warn`,"data-testid":`settings-debugging-restart-note`,children:`Takes effect when OonaCode restarts. The host service and your chats keep running.`}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>void f(),disabled:s!==null||!e.relaunchApp,"data-testid":`settings-debugging-restart`,children:`Restart now`})]}):null,s?(0,G.jsx)(`div`,{className:`mt-1 text-fg-faint`,children:s}):null]})]})}function WH({open:e,onClose:t}){let{state:n,actions:r}=K(),[i,a]=(0,v.useState)(`general`),o=n.ui.settingsSection;(0,v.useEffect)(()=>{e&&o&&a(o)},[e,o]),(0,v.useEffect)(()=>{e&&!n.settings&&r.refreshSettings()},[e,n.settings,r]);let s=OH()!==null,c=s?DH:DH.filter(e=>e.id!==`developer`);return(0,G.jsx)(Vy,{open:e,title:`Settings`,onClose:t,wide:!0,footer:(0,G.jsx)(Y,{onClick:t,children:`Done`}),children:(0,G.jsxs)(`div`,{className:`flex min-h-[22rem] gap-4`,children:[(0,G.jsxs)(`nav`,{className:`w-36 shrink-0 space-y-0.5`,"aria-label":`Settings sections`,children:[c.map(e=>{let t=e.icon;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-current":i===e.id?`true`:void 0,className:W(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,i===e.id?`bg-accent-soft font-medium text-accent`:`text-fg-muted hover:bg-surface-2`),children:[(0,G.jsx)(t,{className:`w-3.5 h-3.5`}),e.label]},e.id)}),(0,G.jsxs)(`div`,{className:`pt-3 text-[11px] text-fg-faint`,children:[`OonaCode Desktop v`,Bv(typeof window<`u`&&window.oonacode?.appVersion||n.connection.appVersion||`0.0.0`,zv({bridge:typeof window<`u`?window.oonacode:void 0,info:n.info}))]})]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===`general`?(0,G.jsx)(kH,{}):null,i===`theme`?(0,G.jsx)(MH,{}):null,i===`advanced`?(0,G.jsx)(NH,{}):null,i===`skills`?(0,G.jsx)(TH,{}):null,i===`providers`?(0,G.jsx)(PH,{}):null,i===`devices`?(0,G.jsx)(FH,{}):null,i===`host`?(0,G.jsx)(VH,{}):null,i===`developer`&&s?(0,G.jsx)(UH,{}):null]})]})})}function GH({toast:e}){let{actions:t}=K();(0,v.useEffect)(()=>{let n=setTimeout(()=>t.dismissToast(e.id),e.kind===`error`?9e3:5e3);return()=>clearTimeout(n)},[e.id,e.kind,t]);let n=e.kind===`error`?`border-danger/50 bg-danger-soft text-danger`:e.kind===`success`?`border-ok/50 bg-ok-soft text-ok`:`border-border bg-surface text-fg`;return(0,G.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:W(`pointer-events-auto flex max-w-sm items-start gap-2 rounded-md border px-3 py-2 text-sm shadow-md`,n),children:[e.kind===`error`?(0,G.jsx)(J.Alert,{className:`mt-0.5 w-4 h-4`}):e.kind===`success`?(0,G.jsx)(J.Check,{className:`mt-0.5 w-4 h-4`}):null,(0,G.jsx)(`div`,{className:`pre-wrap min-w-0 flex-1`,children:e.text}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,className:`opacity-60 hover:opacity-100`,onClick:()=>t.dismissToast(e.id),children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]})}function KH(){let{state:e}=K();return e.toasts.length===0?null:(0,G.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.toasts.map(e=>(0,G.jsx)(GH,{toast:e},e.id))})}var qH=2e3;function JH(e){if(!YH(e))return;let t=typeof window<`u`?window.oonacode:void 0;if(t?.openExternal){t.openExternal(e).catch(()=>void 0);return}typeof window<`u`&&window.open(e,`_blank`,`noopener,noreferrer`)}function YH(e){if(typeof e!=`string`||e===``)return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function XH(e){if(e.message)return e.message;switch(e.status){case`denied`:return`That request was denied in the browser. Start again if it was you.`;case`expired`:return`The code expired before it was approved. Start again for a fresh one.`;default:return`The sign-in could not be started. Check that this PC can reach the gateway.`}}function ZH({children:e,testId:t}){let{state:n}=K(),r=n.connection.hostName??n.info?.hostName??null;return(0,G.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,"data-testid":t,children:[(0,G.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,G.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-fg-faint`,children:`/`}),(0,G.jsx)(`span`,{className:`truncate text-sm text-fg-muted`,"data-testid":`frame-host-name`,children:r})]}):null]}),(0,G.jsx)(`main`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto p-6`,children:(0,G.jsx)(`div`,{className:`w-full max-w-md py-6`,children:e})}),(0,G.jsx)(KH,{})]})}function QH(){return(0,G.jsx)(ZH,{testId:`account-loading`,children:(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(J.Spinner,{className:`w-4 h-4`}),(0,G.jsx)(`span`,{children:`Checking your account…`})]})})}function $H({link:e}){let{actions:t}=K(),[n,r]=(0,v.useState)(!1),i=e.verificationUrl??``,a=e.verificationUrlComplete??i,o=YH(a),s=t.refreshAccountLink;return(0,v.useEffect)(()=>{let e=setInterval(()=>void s(),qH);return()=>clearInterval(e)},[s]),(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`link-waiting`,children:[(0,G.jsxs)(`ol`,{className:`space-y-2 text-sm`,children:[(0,G.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`1. Open`}),o?(0,G.jsx)(`a`,{className:`break-all font-medium text-accent underline`,href:a,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`link-url`,onClick:e=>{window.oonacode?.openExternal&&(e.preventDefault(),JH(a))},children:i}):(0,G.jsx)(`span`,{className:`break-all font-medium`,"data-testid":`link-url`,children:i})]}),(0,G.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`2. Enter`}),(0,G.jsx)(`span`,{className:`select-all rounded-md border border-border bg-surface-2 px-2.5 py-1 font-mono text-base tracking-widest`,"data-testid":`link-user-code`,children:e.userCode})]})]}),(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-fg-muted`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{children:`Waiting for approval in your browser…`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`Approve this code only if you are looking at it on your own screen right now. It is good for a few minutes and can be used once.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,G.jsxs)(Y,{size:`sm`,onClick:()=>JH(a),"data-testid":`link-reopen`,children:[(0,G.jsx)(J.LogIn,{className:`w-3.5 h-3.5`}),` Open the browser again`]}):null,(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,busy:n,"data-testid":`link-cancel`,onClick:()=>{r(!0),t.cancelAccountLink().finally(()=>r(!1))},children:`Cancel`})]})]})}function eU(e){if(typeof e!=`string`||e===``)return null;try{let t=new URL(e).hostname;if(!t)return null;let n=/^api(?:-([a-z0-9-]+))?.(.+)$/i.exec(t),r=n?.[2];return n&&r?n[1]?n[1]+`.`+r:r:t}catch{return null}}function tU(){let{state:e,actions:t}=K(),n=e.accountLink,r=eU(n?.verificationUrl??e.settings?.gatewayUrl??e.account?.gatewayUrl??null),[i,a]=(0,v.useState)(!1),o=(0,v.useCallback)(async()=>{a(!0);try{let e=await t.startAccountLink();e?.status===`waiting`&&JH(e.verificationUrlComplete??e.verificationUrl??``)}finally{a(!1)}},[t]);if(n?.status===`waiting`)return(0,G.jsx)($H,{link:n});let s=n&&(n.status===`denied`||n.status===`expired`);return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[s?(0,G.jsx)(`p`,{role:`status`,"data-testid":`link-refused`,className:`rounded-md border border-warn/50 bg-warn-soft px-3 py-2 text-xs text-fg`,children:XH(n)}):null,(0,G.jsxs)(Y,{variant:`primary`,busy:i,onClick:()=>void o(),"data-testid":`link-start`,className:`w-full justify-center`,children:[(0,G.jsx)(J.LogIn,{className:`w-3.5 h-3.5`}),s?`Try again in your browser`:`Sign in with your browser`]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`link-site-note`,children:[`Opens `,r??`your account page`,` and shows a short code to confirm. Your password is never typed on this machine, and this PC never sees anyone else's.`]})]})}function nU(){let{state:e}=K(),[t,n]=(0,v.useState)(!1),r=t||e.emailVerification!==null;return(0,G.jsx)(ZH,{testId:`sign-in-view`,children:(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Sign in to use OonaCode`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`OonaCode runs the agent on this PC, with your own providers — but it needs an OonaCode account. There is no guest mode.`})]}),(0,G.jsx)(tU,{}),(0,G.jsx)(`div`,{className:W(`space-y-3 border-t border-border pt-4`,r?``:`text-center`),children:r?(0,G.jsx)(Hb,{}):(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,"data-testid":`use-password`,onClick:()=>n(!0),children:`Use an email and password instead`})})]})})}function rU(){let{state:e,actions:t}=K(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=()=>u.current?.focus();e();let t=setTimeout(e,60);return()=>clearTimeout(t)},[]),(0,G.jsxs)(`div`,{className:`flex min-h-screen items-center justify-center bg-surface-1 p-6`,"data-testid":`locked-view`,onMouseDown:()=>u.current?.focus(),children:[(0,G.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),!n||o)return;s(!0),l(null);let a=null;t.unlock(n,{keepUnlocked:i,onError:e=>{a=e}}).then(e=>{s(!1),e?r(``):l(a??`Wrong password — the vault stays locked.`)})},className:`w-full max-w-sm space-y-4 text-center`,children:[(0,G.jsx)(J.Lock,{className:`mx-auto h-10 w-10 text-fg-faint`}),(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`This device is locked`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`The vault, your keys and every session on this PC stay unreadable until you unlock — with your account password here, or remotely from another of your devices.`}),(0,G.jsx)(`input`,{ref:u,type:`password`,className:Z,value:n,onChange:e=>r(e.target.value),onMouseDown:e=>e.stopPropagation(),placeholder:`Account password`,autoFocus:!0,"data-testid":`locked-password`}),(0,G.jsxs)(`label`,{className:`flex items-start justify-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`locked-keep-unlocked`}),(0,G.jsx)(`span`,{children:`Keep me unlocked on this PC`})]}),c?(0,G.jsx)(`div`,{className:`text-sm text-danger`,"data-testid":`locked-error`,children:c}):null,(0,G.jsx)(Y,{type:`submit`,variant:`primary`,busy:o,disabled:!n,children:`Unlock`}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[`Signed in as `,e.account?.email??`this account`,` ·`,` `,(0,G.jsx)(`button`,{type:`button`,className:`underline hover:text-fg`,onClick:()=>void t.logout(),children:`Sign out`})]})]}),(0,G.jsx)(KH,{})]})}function iU(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function aU(e,t,n){let r=iU(n),i=e.filter(e=>!t.has(e.id)).sort((e,t)=>t.mtime-e.mtime),a=[],o=[];for(let e of i)(e.mtime>=r?a:o).push(e);return{today:a,older:o}}function oU(e,t){let n=t.trim().toLowerCase();return n===``||e.toLowerCase().includes(n)}var sU=`flex w-full items-center gap-1 rounded px-2 py-1 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:bg-surface-2`,cU=`flex items-center gap-1 px-2 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,lU=`flex w-full items-center gap-1.5 rounded border-l-2 border-project/70 bg-surface-2/40 px-2 py-1.5 text-left text-[13px] font-semibold tracking-normal text-fg hover:bg-surface-2`,uU=`flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-2`;function dU(){let{state:e,actions:t}=K(),n=e.ui.sidebarPinnedOverride??e.prefs.sidebarPinned,[r,i]=(0,v.useState)(cV),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(!1),l=PF(),[u,d]=(0,v.useState)(null),f=(0,v.useCallback)(()=>d(null),[]),p=vU(),m=UF(),h=iU(m),g=e.prefs.sidebarView,_=e.prefs.pinned,y=e=>o(t=>({...t,[e]:t[e]!==!0})),b=e=>a[e]===!0,x=e.prefs.collapsedProjects,S=e=>x.includes(e),C=e=>{let n=S(e)?x.filter(t=>t!==e):[...x,e];t.savePrefs({collapsedProjects:n})},w=(0,v.useCallback)(e=>{t.selectSession(e),window.innerWidth<768&&t.setSidebar(!1)},[t]),T=(0,v.useCallback)(e=>{t.openPage({kind:`project`,projectId:e}),window.innerWidth<768&&t.setSidebar(!1)},[t]),E=e.search.trim()!==``,D=(0,v.useMemo)(()=>{let t=e.sessions.filter(t=>!e.remote.tabs[t.id]);if(!E)return t;let n=Date.now();return t.filter(t=>fV(t,e.search,r,n))},[e.sessions,e.remote.tabs,e.search,E,r]),O=(0,v.useMemo)(()=>{let t=new Map(D.map(e=>[e.id,e])),n=[];for(let r of _)if(r.kind===`chat`){let i=t.get(r.id)??(E?void 0:e.pinnedRows[r.id]);i&&!e.remote.tabs[i.id]&&n.push({kind:`chat`,session:i})}else{let t=e.vaultProjects.find(e=>e.id===r.id);if(!t||!oU(t.name,E?e.search:``))continue;let i=e.sessions.filter(e=>e.projectId===t.id);n.push({kind:`project`,project:t,sessions:i})}return n},[_,D,E,e.search,e.pinnedRows,e.remote.tabs,e.vaultProjects,e.sessions]),k=(0,v.useMemo)(()=>new Set(_.filter(e=>e.kind===`chat`).map(e=>e.id)),[_]),A=(0,v.useMemo)(()=>g===`recent`?aU(D,k,h):null,[g,D,k,h]),j=(0,v.useMemo)(()=>new Map(e.vaultProjects.map(e=>[e.id,e.name])),[e.vaultProjects]),M=(0,v.useMemo)(()=>{if(g!==`projects`)return[];let t=new Map;for(let n of e.vaultProjects)t.set(n.id,{name:n.name,sessions:[]});let n=[];for(let e of D){let r=e.projectId?t.get(e.projectId):void 0;r?r.sessions.push(e):n.push(e)}let r=[...t.entries()].map(([e,t])=>({key:e,name:t.name,projectId:e,sessions:t.sessions.slice().sort((e,t)=>t.mtime-e.mtime)}));return r.sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),(n.length>0||r.length===0)&&r.push({key:`none`,name:`No project`,projectId:null,sessions:n.slice().sort((e,t)=>t.mtime-e.mtime)}),E?r.filter(e=>e.sessions.length>0):r},[g,e.vaultProjects,D,E]),N=e=>{t.savePrefs({collapsedProjects:e?M.map(e=>e.key):[]})},ee=(0,v.useMemo)(()=>e.remote.hosts.filter(e=>!e.isSelf),[e.remote.hosts]),te=()=>{let e=b(`remote`);y(`remote`),e&&t.refreshHosts()},P=e=>{t.setSearch(e),t.refreshSessions(e)},[F,ne]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(0),I=(0,v.useRef)(null),[L,R]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(``),se=r.mode===`conversations`,ce=se?ae:e.search,le=F||ce!==``||L;(0,v.useEffect)(()=>{F&&I.current?.focus()},[F,re]),(0,v.useEffect)(()=>{let e=e=>{!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey||(e.key===`k`||e.key===`K`)&&window.oonacode?.host!==`vscode`&&(e.preventDefault(),ne(!0),ie(e=>e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let ue=()=>{e.search!==``&&P(``),oe(``),R(!1),ne(!1)},de=t=>{t.mode!==r.mode&&(t.mode===`conversations`?(oe(e.search),e.search!==``&&P(``)):(ae!==``&&P(ae),oe(``))),i(t)},fe=D.length,pe=e=>{e!==g&&t.savePrefs({sidebarView:e})},me=e.page,he={onOpen:w,onMenu:l.openMenu,clock:m},ge=!e.sessionsLoading&&fe===0&&!e.sessionsError?(0,G.jsx)(`div`,{className:`px-3 py-3 text-center text-xs text-fg-faint`,"data-testid":`sessions-empty`,children:E?`No sessions match.`:`No sessions yet — press + to start one.`}):null;return(0,G.jsxs)(`nav`,{className:`flex h-full w-full flex-col bg-surface`,"aria-label":`Sessions`,children:[(0,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center justify-end gap-x-2 gap-y-1 border-b border-border p-2`,children:[(0,G.jsx)(X,{label:`Search chats (Ctrl+K)`,onClick:()=>{ne(!0),ie(e=>e+1)},"data-testid":`open-search`,children:(0,G.jsx)(J.Search,{})}),(0,G.jsx)(`span`,{className:`flex-1`}),le?(0,G.jsxs)(`div`,{className:`absolute inset-0 z-10 flex items-center gap-1 bg-surface px-2`,"data-testid":`sidebar-search`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(J.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`input`,{ref:I,"aria-label":`Search sessions`,className:W(Z,`pl-7`),placeholder:se?`Search every chat`:`Search chats`,value:ce,onChange:e=>se?oe(e.target.value):P(e.target.value),onBlur:()=>{ce===``&&!L&&ne(!1)},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ue())}})]}),(0,G.jsxs)(X,{label:L?`Hide search options`:`Search options`,className:W(`relative`,L&&`text-accent`),"aria-pressed":L,onMouseDown:e=>e.preventDefault(),onClick:()=>R(e=>!e),"data-testid":`search-options-toggle`,children:[(0,G.jsx)(J.Sliders,{}),uV(r)?(0,G.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`search-options-dot`}):null]}),(0,G.jsx)(X,{label:`Close search`,onMouseDown:e=>e.preventDefault(),onClick:ue,"data-testid":`close-search`,children:(0,G.jsx)(J.X,{})})]}):null,le&&L?(0,G.jsx)(_V,{options:r,onChange:de,projects:e.vaultProjects,onClose:()=>{R(!1),I.current?.focus()}}):null,(0,G.jsx)(X,{label:`Refresh sessions`,onClick:()=>{t.refreshSessions(),t.refreshHosts()},children:(0,G.jsx)(J.Refresh,{className:e.sessionsLoading?`spin`:``})}),e.account?.loggedIn?(0,G.jsx)(X,{label:`Import chats from your other coding agents`,onClick:()=>t.openDialog(`import-claude`),"data-testid":`open-import-claude`,children:(0,G.jsx)(J.Download,{})}):null,e.account?.loggedIn?(0,G.jsx)(X,{label:`Export my chats`,onClick:()=>t.openDialog(`export-chats`),"data-testid":`open-export-chats`,children:(0,G.jsx)(J.Upload,{})}):null,g===`projects`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(X,{label:`Collapse all projects`,onClick:()=>N(!0),"data-testid":`projects-collapse-all`,children:(0,G.jsx)(J.CollapseAll,{})}),(0,G.jsx)(X,{label:`Expand all projects`,onClick:()=>N(!1),"data-testid":`projects-expand-all`,children:(0,G.jsx)(J.ExpandAll,{})})]}):null,(0,G.jsx)(X,{label:`Conversations — what your chats send each other`,onClick:()=>t.openConversations(),"data-testid":`open-conversations`,children:(0,G.jsx)(J.Chats,{})}),(0,G.jsx)(X,{label:`What your chats are about — each chat’s about and what it cost`,onClick:()=>t.openChatAbouts(),"data-testid":`open-chat-abouts`,children:(0,G.jsx)(J.Info,{})}),(0,G.jsx)(X,{label:n?`Hide the session list — it slides in when the pointer reaches the left edge`:`Pin the session list beside the chat`,className:W(`hidden md:inline-flex`,n?`text-accent`:`text-fg-muted`),"aria-pressed":n,onClick:()=>t.toggleSidebarPinned(),"data-testid":`sidebar-pin`,children:(0,G.jsx)(J.Pin,{})})]}),(0,G.jsx)(fU,{clock:m}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:se&&ae.trim()!==``?(0,G.jsx)(yV,{query:ae,options:r}):(0,G.jsxs)(G.Fragment,{children:[O.length>0?(0,G.jsxs)(`div`,{className:`mb-1`,"data-testid":`section-pinned`,children:[(0,G.jsx)(`div`,{className:cU,children:(0,G.jsx)(`span`,{children:`Pinned`})}),O.map(t=>t.kind===`chat`?(0,G.jsx)(MF,{session:t.session,active:t.session.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.session.id]??null,menuOpen:l.menuFor===t.session.id,kindIcon:!0,testIdPrefix:`pinned-session`,...he},`chat:${t.session.id}`):(0,G.jsx)(hU,{project:t.project,sessions:t.sessions,active:me?.kind===`project`&&me.projectId===t.project.id,onOpen:T,onMenu:(e,n)=>d({target:{projectId:t.project.id,foldKey:null},at:e,el:n})},`project:${t.project.id}`))]}):null,(0,G.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-local`,children:[e.sessionsError?(0,G.jsx)(`div`,{className:`px-2 py-2 text-xs text-danger`,children:e.sessionsError}):null,A?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{"data-testid":`section-today`,children:[(0,G.jsxs)(`div`,{className:cU,children:[(0,G.jsx)(`span`,{children:`Today`}),(0,G.jsx)(`span`,{className:`font-normal normal-case`,children:A.today.length||``}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(mU,{view:g,onChange:pe})]}),ge??(A.today.length===0?(0,G.jsx)(`div`,{className:`px-3 py-1 text-xs text-fg-faint`,"data-testid":`today-empty`,children:E?`Nothing from today matches.`:`Nothing yet today.`}):A.today.map(t=>(0,G.jsx)(MF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id)))]}),A.older.length>0?(0,G.jsxs)(`div`,{"data-testid":`section-older`,children:[(0,G.jsxs)(`div`,{className:cU,children:[(0,G.jsx)(`span`,{children:`Older`}),(0,G.jsx)(`span`,{className:`font-normal normal-case`,children:A.older.length})]}),A.older.map(t=>(0,G.jsx)(MF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id))]}):null]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:cU,"data-testid":`section-by-project`,children:[(0,G.jsx)(`span`,{children:`By project`}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(mU,{view:g,onChange:pe})]}),ge,M.map(n=>{let r=`local:${n.key}`;return(0,G.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`project-group-${n.key}`,children:[(0,G.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,G.jsx)(yU,{group:n,collapsed:S(n.key),onToggle:()=>C(n.key),onMenu:(e,t)=>d({target:{projectId:n.projectId,foldKey:n.key},at:e,el:t}),menuOpen:u?.target.foldKey===n.key}),n.projectId?(0,G.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,G.jsx)(X,{label:`Settings of ${n.name}`,className:`p-1`,"data-testid":`project-settings-${n.key}`,onClick:e=>{e.stopPropagation(),t.openProjectSettings(n.projectId)},children:(0,G.jsx)(J.Settings,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(X,{label:`New chat in ${n.name}`,className:`p-1`,"data-testid":`project-new-chat-${n.key}`,onClick:e=>{e.stopPropagation(),t.newTab({projectId:n.projectId})},children:(0,G.jsx)(J.Plus,{className:`w-3.5 h-3.5`})})]}):null]}),S(n.key)?null:n.sessions.map(t=>(0,G.jsx)(MF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,...he},t.id))]},r)})]})]}),(0,G.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-remote`,children:[(0,G.jsxs)(`button`,{type:`button`,className:sU,onClick:te,"aria-expanded":!b(`remote`),children:[(0,G.jsx)(J.Chevron,{open:!b(`remote`),className:`w-3 h-3`}),(0,G.jsx)(J.Globe,{className:`w-3 h-3`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Remote`}),(0,G.jsx)(`span`,{className:`ml-auto font-normal`,children:ee.length})]}),b(`remote`)?null:(0,G.jsxs)(G.Fragment,{children:[!e.remote.supported||e.remote.reason===`logged_out`?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:`Sign in to see the sessions of your other devices.`}):ee.length===0?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:e.remote.loading?`Looking for your other devices…`:`No other devices yet.`}):null,ee.map(e=>(0,G.jsx)(gU,{host:e,collapsed:b(`host:${e.hostId}`)||a[`host:${e.hostId}`]===void 0,onToggle:()=>{let n=`host:${e.hostId}`,r=a[n]===void 0||a[n]===!0;o(e=>({...e,[n]:!r})),r&&t.refreshHostSessions(e.hostId)}},e.hostId))]})]})]})}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border px-3 py-2 text-[11px] text-fg-faint`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`app-version`,title:`What's new in this version`,className:`truncate hover:text-fg hover:underline`,onClick:()=>t.openDialog(`whats-new`),children:[`OonaCode Desktop v`,p]}),(0,G.jsx)(X,{label:`Lock this device — vault and sessions`,className:`p-1`,"data-testid":`lock-device`,onClick:()=>c(!0),children:(0,G.jsx)(J.Lock,{className:`h-3.5 w-3.5`})})]})}),(0,G.jsx)(Zb,{open:u!==null,at:u?.at??{x:0,y:0},anchorEl:u?.el??null,label:`Project actions`,testId:`project-context-menu`,onClose:f,items:u?FF({projectId:u.target.projectId,pinned:u.target.projectId!==null&&qc(_,`project`,u.target.projectId),fold:u.target.foldKey===null?null:{collapsed:S(u.target.foldKey),onToggle:()=>C(u.target.foldKey)},actions:t}):[]}),l.element,(0,G.jsx)(Gy,{open:s,title:`Lock this device?`,confirmLabel:`Lock`,message:`Every chat closes and nothing on this PC can be read or run until you unlock — here with your password, or remotely from another device.`,onConfirm:()=>void t.lockDevice(),onClose:()=>c(!1)})]})}function fU({clock:e}){let{state:t,actions:n}=K(),[r,i]=(0,v.useState)(null),a=(0,v.useCallback)(()=>i(null),[]),o=t.page,s=()=>{window.innerWidth<768&&n.setSidebar(!1)};return(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border px-1 py-1`,"data-testid":`sidebar-nav`,children:[(0,G.jsxs)(`div`,{className:`flex items-center rounded-md hover:bg-surface-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:W(uU,`flex-1 hover:bg-transparent`),title:`New chat (Ctrl+T)`,onClick:()=>{n.newTab(),s()},"data-testid":`sidebar-new`,children:[(0,G.jsx)(J.Edit,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,G.jsx)(`span`,{children:`New`})]}),(0,G.jsx)(X,{label:`Start a new chat or a new project`,className:`mr-1 p-1`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();i({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-new-menu`,children:(0,G.jsx)(J.Chevron,{open:!0,className:`w-3.5 h-3.5`})})]}),(0,G.jsxs)(`button`,{type:`button`,className:W(uU,`w-full`,o?.kind===`projects`||o?.kind===`project`?`bg-surface-2 font-medium`:``),"aria-current":o?.kind===`projects`?`page`:void 0,onClick:()=>{n.openPage({kind:`projects`}),s()},"data-testid":`open-projects`,children:[(0,G.jsx)(J.Project,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,G.jsx)(`span`,{children:`Projects`})]}),(0,G.jsx)(pU,{clock:e,active:o?.kind===`scheduled`,onOpen:()=>{n.openPage({kind:`scheduled`}),s()}}),(0,G.jsx)(Zb,{open:r!==null,at:r?.at??{x:0,y:0},anchorEl:r?.el??null,label:`New`,testId:`sidebar-new-context-menu`,onClose:a,items:[{key:`chat`,label:`New chat`,hint:`Ctrl+T`,icon:(0,G.jsx)(J.Chats,{className:`w-3.5 h-3.5`}),onSelect:()=>{n.newTab(),s()},testId:`sidebar-new-chat`},{key:`project`,label:`New project…`,icon:(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5`}),onSelect:()=>n.openNewProject(),testId:`sidebar-new-project`}]})]})}function pU({clock:e,active:t,onOpen:n}){let{tasks:r}=HF(),i=(0,v.useMemo)(()=>r?QF(r,e):null,[r,e]);return(0,G.jsxs)(`button`,{type:`button`,className:W(uU,`w-full`,t?`bg-surface-2 font-medium`:``),"aria-current":t?`page`:void 0,onClick:n,title:i?.text??`Every scheduled task on this PC`,"data-testid":`open-scheduled`,children:[(0,G.jsx)(J.Clock,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,G.jsx)(`span`,{className:`flex-1`,children:`Scheduled`}),i?(0,G.jsx)(`span`,{className:W(`mr-1 inline-block h-2 w-2 shrink-0 rounded-full`,i.tone===`stuck`?`bg-warn`:`bg-accent`),"aria-label":i.text,"data-testid":`scheduled-dot`,"data-tone":i.tone}):null]})}function mU({view:e,onChange:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useCallback)(()=>r(null),[]),a=e=>e?(0,G.jsx)(J.Check,{className:`w-3.5 h-3.5 text-accent`}):(0,G.jsx)(`span`,{className:`w-3.5`});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(X,{label:`How the list is laid out`,className:`p-0.5 normal-case`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();r({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-view-options`,children:(0,G.jsx)(J.Sliders,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(Zb,{open:n!==null,at:n?.at??{x:0,y:0},anchorEl:n?.el??null,label:`How the list is laid out`,testId:`sidebar-view-menu`,onClose:i,items:[{key:`recent`,label:`Recent — Today, then Older`,icon:a(e===`recent`),onSelect:()=>t(`recent`),testId:`sidebar-view-recent`},{key:`projects`,label:`By project`,icon:a(e===`projects`),onSelect:()=>t(`projects`),testId:`sidebar-view-projects`}]})]})}function hU({project:e,sessions:t,active:n,onOpen:r,onMenu:i}){let a=(0,v.useRef)(null),o=e.sessionCount??t.length;return(0,G.jsxs)(`div`,{ref:a,className:W(`group relative flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),onContextMenu:e=>{e.preventDefault(),i({x:e.clientX,y:e.clientY},a.current)},children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 py-1.5 pl-2 pr-8 text-left`,"aria-current":n?`page`:void 0,title:`Open ${e.name}`,onClick:()=>r(e.id),"data-testid":`pinned-project-${e.id}`,children:[(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.name}),(0,G.jsx)(DF,{sessions:t,testId:`pinned-project-busy-${e.id}`}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold text-fg-muted`,children:o})]}),(0,G.jsx)(X,{label:`Project actions`,className:`pointer-events-none absolute right-1 bg-surface/90 p-1 opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`,"data-testid":`pinned-project-menu-${e.id}`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();i({x:t.left,y:t.bottom+2},a.current)},children:(0,G.jsx)(J.More,{className:`w-3.5 h-3.5`})})]})}function gU({host:e,collapsed:t,onToggle:n}){let{state:r,actions:i}=K(),a=e.label||e.hostName,o=r.remote.sessions[e.hostId],s=r.remote.unreachable[e.hostId],c=s?uf(s.reason,a,s.detail):null,[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=e.remoteAccessOff===!0;return(0,G.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`remote-host-${e.hostId}`,children:[(0,G.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,G.jsxs)(`button`,{type:`button`,className:sU,onClick:n,"aria-expanded":!t,title:e.online?`${a} — online`:`${a} — offline: its chats can be read while it is online`,children:[(0,G.jsx)(J.Chevron,{open:!t,className:`w-3 h-3`}),(0,G.jsx)(`span`,{className:W(`inline-block h-2 w-2 shrink-0 rounded-full`,e.online?`bg-ok`:`bg-fg-faint`),"aria-label":e.online?`online`:`offline`}),(0,G.jsx)(`span`,{className:`truncate normal-case`,children:a}),p?(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-warn-soft px-1.5 text-[10px] font-normal normal-case text-warn`,"data-testid":`remote-off-${e.hostId}`,children:`remote access off`}):null,(0,G.jsx)(`span`,{className:`ml-auto font-normal`,children:!p&&o?o.length:``})]}),(0,G.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,G.jsx)(X,{label:p?lf(a):e.online?`New chat on ${a}`:`${a} is offline — a new chat has to start on a PC that is awake`,className:`p-1`,disabled:!e.online||p,"data-testid":`remote-new-chat-${e.hostId}`,onClick:()=>void i.newRemoteTab(e.hostId),children:(0,G.jsx)(J.Plus,{className:`w-3 h-3`})}),(0,G.jsx)(X,{label:`Unlock this device`,className:`p-1`,disabled:p,"data-testid":`remote-unlock-${e.hostId}`,onClick:()=>u(`unlock`),children:(0,G.jsx)(J.Lock,{className:`w-3 h-3`})}),(0,G.jsx)(X,{label:`Rename device`,className:`p-1`,onClick:()=>u(`rename`),children:(0,G.jsx)(J.Edit,{className:`w-3 h-3`})})]}),(0,G.jsx)(Ky,{open:l===`unlock`,title:`Unlock "${a}" remotely`,label:`Your account password — it never leaves this PC: the keys are sealed to that device and the server cannot read them.`,password:!0,submitLabel:`Unlock`,onSubmit:t=>void i.remoteUnlockHost(e.hostId,t),onClose:()=>u(null)}),(0,G.jsx)(Ky,{open:l===`rename`,title:`Rename device`,label:`Device name`,initialValue:a,onSubmit:t=>{t!==a&&i.renameHost(e.hostId,t)},onClose:()=>u(null)})]}),!t&&p?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-off-note-${e.hostId}`,children:lf(a)}):t?null:o===void 0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`Loading…`}):o.length===0&&c?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-unreachable-${e.hostId}`,children:c}):o.length===0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`No sessions on this device.`}):o.map(t=>(0,G.jsx)(_U,{host:e,session:t,active:t.id===r.currentSessionId&&r.page===null,onConfirmDelete:()=>f(t)},t.id)),(0,G.jsx)(Gy,{open:d!==null,title:`Delete this chat?`,message:`It is deleted on ${e.hostName} — the only place it is kept — so it is gone from every device. Files, folders and code on that PC are not touched — only the chat is deleted.`,onConfirm:()=>{d&&i.deleteRemoteSession(e.hostId,d.id)},onClose:()=>f(null)})]})}function _U({host:e,session:t,active:n,onConfirmDelete:r}){let{actions:i}=K(),a=cg(t);return(0,G.jsxs)(`div`,{className:W(`group flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{i.openRemoteSession(e.hostId,t.id),window.innerWidth<768&&i.setSidebar(!1)},className:`flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left`,"aria-current":n?`true`:void 0,"data-testid":`remote-session-${t.id}`,title:e.online?void 0:`Read-only until that PC is online`,children:[(0,G.jsx)(TF,{status:t.status}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:W(`truncate text-sm`,n?`font-medium`:``),children:a}),(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[eg(t.updatedAt),t.model?` · ${t.model}`:``,e.online?``:` · read-only`]})]})]}),(0,G.jsx)(`div`,{className:`mr-1 hidden items-center gap-0.5 rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:(0,G.jsx)(X,{label:e.online?`Delete this chat`:`That PC is asleep — a chat can only be deleted while the PC that holds it is online`,className:`p-1 hover:text-danger disabled:opacity-40`,disabled:!e.online,"data-testid":`remote-session-delete-${t.id}`,onClick:()=>{r()},children:(0,G.jsx)(J.Trash,{className:`w-3.5 h-3.5`})})})]})}function vU(){let{state:e}=K(),t=typeof window<`u`?window.oonacode:void 0;return Bv(t?.appVersion??e.bundleAppVersion??e.connection.appVersion??e.info?.appVersion??`0.0.0`,zv({bridge:t,info:e.info}))}function yU({group:e,collapsed:t,onToggle:n,onMenu:r,menuOpen:i=!1}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(null),l=(0,v.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null),c(null)},[]),u=(0,v.useRef)(i);return u.current=i,(0,v.useEffect)(()=>{i&&l()},[i,l]),(0,v.useEffect)(()=>{if(s===null)return;let e=e=>{Yb(e.target,a.current)&&l()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[s,l]),(0,v.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{ref:a,type:`button`,className:lU,onClick:()=>{l(),n()},onMouseEnter:()=>{o.current!==null&&clearTimeout(o.current),!u.current&&(o.current=setTimeout(()=>{o.current=null,a.current&&!u.current&&c(a.current.getBoundingClientRect())},450))},onMouseLeave:l,onContextMenu:e=>{e.preventDefault(),l(),r({x:e.clientX,y:e.clientY},a.current)},"aria-expanded":!t,"data-testid":`project-header-${e.key}`,children:[(0,G.jsx)(J.Chevron,{open:!t,className:`w-3 h-3 shrink-0`}),(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name}),(0,G.jsx)(DF,{sessions:e.sessions,testId:`project-busy-${e.key}`}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold normal-case tracking-normal text-fg-muted`,"data-testid":`project-count-${e.key}`,children:e.sessions.length})]}),s===null?null:(0,G.jsx)(bU,{group:e,anchor:s})]})}function bU({group:e,anchor:t}){let{state:n}=K(),r=e.projectId?n.vaultProjects.find(t=>t.id===e.projectId):void 0,i=e.sessions.filter(e=>e.status===`running`||e.status===`waiting_permission`).length,a=e.sessions.reduce((e,t)=>e===null||t.updatedAt>e?t.updatedAt:e,null),o=[...new Set(e.sessions.map(e=>e.projectDir??e.cwd).filter(e=>typeof e==`string`&&e.length>0))],s=r?.instructions?.trim()??``,c=Math.max(8,Math.min(t.right+8,window.innerWidth-304-8)),l=Math.max(8,Math.min(t.top,window.innerHeight-320));return(0,My.createPortal)((0,G.jsxs)(`div`,{role:`tooltip`,"data-testid":`project-details-${e.key}`,className:`fixed z-50 max-h-[20rem] w-[19rem] overflow-y-auto rounded-lg border border-border bg-surface p-3 text-xs shadow-lg`,style:{left:c,top:l},children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(kF,{label:`Chats`,value:String(e.sessions.length)}),(0,G.jsx)(kF,{label:`Working now`,value:i>0?String(i):null}),(0,G.jsx)(kF,{label:`Last activity`,value:a?eg(a):null}),(0,G.jsx)(kF,{label:o.length>1?`Folders`:`Folder`,value:o.length>1?`${o.length} folders`:o[0]??null})]}),e.projectId?(0,G.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`Standing instructions`}),s?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-fg`,"data-testid":`project-instructions-${e.key}`,children:s.length>400?`${s.slice(0,400)}…`:s}):(0,G.jsx)(`div`,{className:`text-fg-faint`,children:`None — chats here start with nothing extra.`})]}):(0,G.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:`Chats filed under no project.`})]}),document.body)}function xU(){return Yv(typeof window<`u`?window.oonacode:void 0)}function SU(e){if(e.upToDate)return`Everything on this PC is up to date — the app, the host service and the oona CLI.`;let t=[];return e.terminal&&t.push(`OonaCode updates the oona CLI and the host service in place — the service restarts and your chats come back with it.`),e.desktop&&t.push(e.terminal?`Then it downloads the app, installs it and relaunches, restoring your open tabs.`:`OonaCode downloads the update, installs it and relaunches. Your open chat tabs are restored afterwards.`),t.length===0?t.push("This window cannot install updates by itself — run the installer again, or `oona update` in a terminal. Your open chat tabs are stored in the host and come back automatically."):e.manual.length>0&&t.push(e.manual.includes(`desktop`)?`The app itself needs the installer from the website.`:"The rest needs `oona update` in a terminal."),t.join(` `)}var CU=2*Math.PI*10;function wU(){return typeof window<`u`&&window.oonacode!==void 0}function TU(){let{state:e,actions:t}=K(),n=e.update,r=e.updateInstall,i=e.prefs.dismissedUpdateVersion,a=n.version!==``&&(e.updateDismissed===n.version||i===n.version);if(!wU())return null;let o=Wv({install:r,manifestAvailable:n.available&&!a}),s=e.terminalUpdate.running,c=e.updateChecking||r.phase===`checking`||s,l=n.components.length,u=Math.round(r.percent),d=s?`Updating the CLI and host service`:o===`ready`?`Restart to finish updating`:o===`downloading`?`Downloading update (${u}%)`:o===`available`?`Update available (${l})`:`Check for updates`,f=s?`Updating the oona CLI and the host service…`:o===`ready`?`An update is ready — restart to finish`:o===`downloading`?`Downloading OonaCode ${r.version||`update`} — ${u}%`:o===`available`?`${l} component${l===1?``:`s`} can be updated`:`Check for updates`;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{if(o===`idle`){t.checkUpdates(!0);return}if(o===`ready`){t.installUpdate();return}t.openDialog(`update`)},title:f,"aria-label":d,"aria-busy":c||void 0,"data-testid":`update-badge`,"data-state":o,className:W(`relative inline-flex h-7 w-7 items-center justify-center rounded-full border transition-transform hover:scale-105`,o===`idle`?`border-border bg-surface-2 text-fg-muted hover:text-fg`:`border-accent bg-accent-soft text-accent`),children:[o===`downloading`?(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,"data-testid":`update-badge-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u,className:`absolute inset-0 h-full w-full -rotate-90`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,className:`stroke-border`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:CU,strokeDashoffset:CU*(1-Math.max(0,Math.min(100,u))/100),className:`stroke-accent`})]}):null,c&&o!==`downloading`&&o!==`ready`?(0,G.jsx)(`span`,{"data-testid":`update-badge-checking`,className:`inline-flex`,children:(0,G.jsx)(J.Spinner,{className:`w-3.5 h-3.5`})}):o===`ready`?(0,G.jsx)(`span`,{"data-testid":`update-badge-ready`,className:`inline-flex`,children:(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`})}):o===`downloading`?(0,G.jsx)(`span`,{"data-testid":`update-badge-downloading`,className:`text-[9px] font-semibold`,children:u}):(0,G.jsx)(`span`,{"data-testid":o===`available`?`update-badge-available`:`update-badge-idle`,className:`inline-flex`,children:(0,G.jsx)(J.Download,{className:`w-3.5 h-3.5`})}),o===`available`?(0,G.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-accent`,"aria-hidden":!0}):null]})}function EU(){let{state:e,actions:t}=K(),n=e.updateInstall,r=Math.round(Math.max(0,Math.min(100,n.percent))),i=qv(n.bytesPerSecond);if(n.phase===`error`)return(0,G.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`update-error`,role:`alert`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(J.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`The update could not be downloaded.`}),(0,G.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.error})]})]}),(0,G.jsx)(`div`,{className:`mt-2`,children:(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`update-retry`,children:[(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]});let a=n.phase===`installing`;return(0,G.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`update-progress`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:a?`Installing and restarting…`:n.phase===`ready`?`Downloaded — restart to install`:`Downloading OonaCode ${n.version||``}`.trim()}),a?null:(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[r,`%`]})]}),n.notice?(0,G.jsx)(`div`,{className:`pre-wrap text-xs text-warn`,"data-testid":`update-notice`,role:`status`,children:n.notice}):null,(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-2`,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full bg-accent`,a&&`animate-pulse`),style:{width:`${a?100:r}%`},"data-testid":`update-progress-bar`})}),a?(0,G.jsx)(`div`,{className:`text-xs text-fg-faint`,children:`The host service stops for a few seconds while the installer runs, then OonaCode starts again with your chat tabs.`}):(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-faint`,children:[(0,G.jsxs)(`span`,{children:[Kv(n.transferred),n.total>0?` of ${Kv(n.total)}`:``]}),i?(0,G.jsx)(`span`,{children:i}):null]})]})}function DU(){let{state:e,actions:t}=K(),n=e.terminalUpdate;return n.running?(0,G.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border bg-surface-2 px-3 py-2 text-xs`,"data-testid":`terminal-update-running`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg`,children:`Updating the oona CLI and host service...`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-fg-faint`,children:`The host service stops for a few seconds while its installer runs. Your chats are in the database and come back with it.`})]})]}):n.failed?(0,G.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`terminal-update-error`,role:`alert`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(J.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`The CLI and host service could not be updated.`}),(0,G.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.message})]})]}),(0,G.jsx)(`div`,{className:`mt-2`,children:(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`terminal-update-retry`,children:[(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]}):null}function OU({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.update,a=n.updateInstall,o=r.checkUpdates,s=a.phase===`downloading`||a.phase===`installing`||a.phase===`ready`;(0,v.useEffect)(()=>{!e||s||o(!1)},[e,s,o]);let c=xU(),l=Xv(i.components.map(e=>e.component),c,{checked:i.version!==``,shellEngaged:a.phase!==`idle`&&a.phase!==`checking`}),u=i.version||a.version,d=a.phase===`ready`,f=a.phase===`downloading`||a.phase===`installing`||d||a.phase===`error`,p=n.terminalUpdate.running,m=n.updateChecking||a.phase===`checking`||p;return(0,G.jsx)(Vy,{open:e,title:`Update OonaCode`,onClose:t,footer:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:t,children:`Later`}),(0,G.jsxs)(Y,{variant:`primary`,onClick:()=>void r.installUpdate(),"data-testid":`update-restart`,children:[(0,G.jsx)(J.Refresh,{className:`w-4 h-4`}),`Restart and install`]})]}):f?(0,G.jsx)(Y,{onClick:t,children:`Close`}):l.upToDate?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Y,{onClick:()=>void r.checkUpdates(!0),busy:m,disabled:m,"data-testid":`update-check-again`,children:[(0,G.jsx)(J.Refresh,{className:`w-4 h-4`}),`Check again`]}),(0,G.jsx)(Y,{variant:`primary`,onClick:t,children:`Close`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:()=>r.dismissUpdate(),children:`Skip this version`}),(0,G.jsx)(Y,{onClick:t,children:`Later`}),(0,G.jsxs)(Y,{variant:`primary`,busy:m,disabled:m,onClick:()=>void r.installUpdate(),children:[(0,G.jsx)(J.Download,{className:`w-4 h-4`}),l.label]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[u?(0,G.jsxs)(`span`,{className:`font-medium`,children:[`Release `,u]}):null,i.channel?(0,G.jsx)(Q,{children:i.channel}):null,n.updateChecking?(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`update-rechecking`,children:`checking for a newer one…`}):null,i.publishedAt?(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`published `,new Date(i.publishedAt).toLocaleDateString()]}):null]}),f?(0,G.jsx)(EU,{}):null,(0,G.jsx)(DU,{}),i.components.length>0?(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.components.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2`,children:[(0,G.jsx)(J.Download,{className:`mt-0.5 w-3.5 h-3.5 shrink-0 text-accent`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.current,` → `,(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:e.latest})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`update-how-${e.component}`,children:Zv(e.component,c)}),e.notes?(0,G.jsx)(`div`,{className:`mt-0.5 pre-wrap text-xs text-fg-faint`,children:e.notes}):null]})]},e.component))}):null,i.notes?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Release notes`}),(0,G.jsx)(`div`,{className:`max-h-48 overflow-y-auto rounded-md bg-surface-2 px-3 py-2 pre-wrap text-xs text-fg-muted`,children:i.notes})]}):null,f?null:(0,G.jsx)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`update-plan-note`,children:SU(l)})]})})}function kU(e){switch(e){case`open`:return{cls:`bg-ok`,label:`Connected`};case`connecting`:case`reconnecting`:return{cls:`bg-warn animate-pulse`,label:e===`connecting`?`Connecting…`:`Reconnecting…`};case`unauthorized`:return{cls:`bg-danger`,label:`Unauthorized`};case`closed`:return{cls:`bg-danger`,label:`Disconnected`};default:return{cls:`bg-fg-faint`,label:`Idle`}}}function AU(){let{state:e,actions:t}=K(),n=kU(e.connection.status),r=e.account?.loggedIn===!0,i=typeof window<`u`&&window.oonacode?.host===`vscode`;return(0,G.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-2 sm:px-3`,children:[i?null:(0,G.jsx)(X,{label:`Toggle sidebar`,onClick:()=>{typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(min-width: 768px)`).matches?t.toggleSidebarPinned():t.setSidebar(!e.ui.sidebarOpen)},"data-testid":`toggle-sidebar`,children:(0,G.jsx)(J.PanelLeft,{})}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),(0,G.jsx)(`span`,{className:`hidden text-fg-faint sm:inline`,children:`/`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`session-picker`),title:`Open a session on this PC or another device`,className:`hidden min-w-0 truncate text-sm text-fg-muted hover:text-fg sm:inline`,"data-testid":`host-name`,children:e.connection.hostName??`host`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,title:e.connection.detail??n.label,"data-testid":`connection-status`,children:[(0,G.jsx)(`span`,{className:W(`inline-block h-2 w-2 rounded-full`,n.cls),"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(jU,{}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`bug-report`),title:`Bug Report...`,"aria-label":`Bug Report...`,"data-testid":`bug-report-button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-full border border-border bg-surface-2 text-fg-muted transition-transform hover:scale-105 hover:text-fg`,children:(0,G.jsx)(J.Bug,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(TU,{}),e.hostUpdatedTo?(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:()=>window.location.reload(),title:`This window still runs the previous version; the host is now v${e.hostUpdatedTo}`,"data-testid":`reload-for-update`,children:[`Reload for v`,e.hostUpdatedTo]}):null,r?null:(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),"data-testid":`sign-in`,children:[(0,G.jsx)(J.LogIn,{className:`w-3.5 h-3.5`}),` Sign in`]}),(0,G.jsx)(X,{label:e.prefs.explorerOpen?`Hide files`:`Show files`,onClick:()=>void t.savePrefs({explorerOpen:!e.prefs.explorerOpen}),className:e.prefs.explorerOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-explorer`,children:(0,G.jsx)(J.Folder,{})}),(0,G.jsx)(X,{label:e.prefs.sessionPanelOpen?`Hide session info`:`Show session info`,onClick:()=>void t.savePrefs({sessionPanelOpen:!e.prefs.sessionPanelOpen}),className:e.prefs.sessionPanelOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-session-panel`,children:(0,G.jsx)(J.Panel,{})}),(0,G.jsx)(X,{label:`Doctor`,onClick:()=>t.openDialog(`doctor`),children:(0,G.jsx)(J.Stethoscope,{})}),r?(0,G.jsx)(MU,{}):null,(0,G.jsx)(X,{label:`Account`,onClick:()=>t.openDialog(`account`),children:(0,G.jsxs)(`span`,{className:`relative`,children:[(0,G.jsx)(J.User,{}),r?(0,G.jsx)(`span`,{className:W(`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full`,e.account?.vaultUnlocked?`bg-ok`:`bg-warn`)}):null]})}),(0,G.jsx)(X,{label:`Settings`,onClick:()=>t.openDialog(`settings`),children:(0,G.jsx)(J.Settings,{})})]})]})}function jU(){let{actions:e}=K(),[t,n]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=typeof window<`u`?window.oonacode:void 0;if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&n(e.running)},()=>{}),()=>{t=!1}},[]),!t||!bc(t))return null;let r=CH(t);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>e.openSettings(`developer`),title:r,"aria-label":r,"data-testid":`debugging-badge`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-red-600 px-2.5 text-[11px] font-semibold text-white hover:bg-red-700`,children:[(0,G.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-white`,"aria-hidden":!0}),`Debugging on`]})}function MU(){let{state:e}=K(),[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=e.plan;(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]);let a=i?i.credits.balance:null,o=i?Sv(i):null,s=Tv(i),c=Ev;return(0,G.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,G.jsx)(X,{label:s?`Credits and plan — ${s.text}`:`Credits and plan`,onClick:()=>n(e=>!e),"data-testid":`balance-badge`,className:t?`bg-surface-2 text-fg`:void 0,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(J.Coins,{}),a===null?null:(0,G.jsx)(`span`,{className:W(`hidden text-xs tabular-nums sm:inline`,s?s.level===`empty`?`text-danger`:`text-warn`:void 0),"data-testid":`balance-credits`,"data-level":s?.level??`ok`,children:c(a)})]})}),t?(0,G.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-1 w-64 rounded-md border border-border bg-surface p-3 text-sm shadow-lg`,"data-testid":`balance-popover`,children:i===null||o===null?(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Balance is unavailable — the gateway can't be reached.`}):(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Plan`}),(0,G.jsxs)(`span`,{className:`font-medium`,children:[i.planName,i.status===`none`?` (lapsed)`:``]})]}),(0,G.jsx)(`div`,{className:`h-px bg-border`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Credits`}),(0,G.jsx)(`span`,{className:`font-semibold tabular-nums`,children:c(o.balance)})]}),s?(0,G.jsx)(`div`,{className:W(`rounded-sm px-2 py-1 text-[11px]`,s.level===`empty`?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),"data-testid":`balance-warning`,children:s.text}):null,o.hasSplit?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Plan credits`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:c(o.plan??0)})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Top-up credits`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:c(o.topup??0)})]})]}):null,(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[i.credits.monthlyGrant>0?`Plan credits top up to ${c(i.credits.monthlyGrant)} each 30-day period and expire with it; top-ups never do.`:`This plan pays no monthly credits — the signup gift and anything you buy never expire.`,` `,`Free models never draw on this balance.`]})]})}):null]})}function NU(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`could not read the file`)),r.onload=()=>{let e=typeof r.result==`string`?r.result:``,n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.readAsDataURL(e)})}function PU(e,t){let n=[],r=e.length,i=e.reduce((e,t)=>e+t.size,0);for(let e of t){if(r>=5)return{accepted:n,refused:`At most 5 files per report.`};if(e.size>5242880)return{accepted:n,refused:`${e.name} is ${Kv(e.size)}; a file may be at most ${Kv(Zs)}.`};if(i+e.size>12582912)return{accepted:n,refused:`All files together may be at most ${Kv(Qs)}.`};n.push(e),r+=1,i+=e.size}return{accepted:n,refused:null}}function FU(e){return e instanceof fm?e.code===`account_required`||e.status===401?`Sign in to OonaCode first — a report is filed under your account so we can answer it.`:gm(e)?`This host build cannot send bug reports yet — update OonaCode on this PC.`:e.status===429?`Too many reports in a minute — wait a moment and send again.`:e.status===413?`The attachments are too large for one report.`:e.message||`The report could not be sent.`:e instanceof Error&&e.message?e.message:`The report could not be sent.`}var IU=0;function LU({open:e,onClose:t}){let{state:n,actions:r,api:i}=K(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(o(``),c([]),u(!1),f(null))},[e]);let g=n.account?.loggedIn===!0,_=typeof i.sendBugReport==`function`,y=typeof window<`u`?window.oonacode:void 0,b=y?y.host===`vscode`?`vscode`:`desktop`:`browser`,x=n.currentSessionId?n.sessions.find(e=>e.id===n.currentSessionId)??null:null,S=(0,v.useCallback)(async e=>{let t=Array.from(e);if(t.length===0)return;let{accepted:n,refused:r}=PU(s,t);f(r);let i=t.filter(e=>n.includes(e));if(i.length!==0){m(!0);try{let e=[];for(let t of i){let n=await NU(t);if(!n)continue;let r=t.type||`application/octet-stream`;IU+=1,e.push({key:`f${IU}`,name:t.name,contentType:r,dataBase64:n,size:t.size,preview:r.startsWith(`image/`)?`data:${r};base64,${n}`:null})}c(t=>[...t,...e])}catch(e){f(e instanceof Error?e.message:`could not read the file`)}finally{m(!1)}}},[s]),C=e=>{let t=e.target.files;t&&S(t),e.target.value=``},w=e=>c(t=>t.filter(t=>t.key!==e)),T=async()=>{let e=a.trim();if(!e||l)return;if(!_){f(`This host build cannot send bug reports yet — update OonaCode on this PC.`);return}u(!0),f(null);let o={message:e.slice(0,Xs),...s.length>0?{attachments:s.map(({name:e,contentType:t,dataBase64:n})=>({name:e,contentType:t,dataBase64:n}))}:{},...n.currentSessionId?{sessionId:n.currentSessionId}:{},detail:{embedded:b,connection:n.connection.status,...y?.appVersion?{appVersion:y.appVersion}:{},...n.bundleAppVersion?{uiVersion:n.bundleAppVersion}:{},...n.info?.appVersion?{hostVersion:n.info.appVersion}:{},...n.info?.engine?.version?{engineVersion:n.info.engine.version}:{},...x?.status?{sessionStatus:x.status}:{}}};try{let e=await i.sendBugReport(o);r.toast(`success`,`Bug report #${e.id} sent — thank you.`),t()}catch(e){f(FU(e))}finally{u(!1)}},E=Xs-a.length;return(0,G.jsx)(Vy,{open:e,title:`Bug Report`,onClose:t,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:t,disabled:l,children:`Cancel`}),(0,G.jsxs)(Y,{variant:`primary`,busy:l,disabled:!a.trim()||p,onClick:()=>void T(),"data-testid":`bug-report-send`,children:[(0,G.jsx)(J.Bug,{className:`w-4 h-4`}),`Send report`]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`bug-report-dialog`,children:[(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`Tell us what went wrong and what you expected. Screenshots help. The report is filed under your account with this PC's versions`,x?` and the open chat’s model`:``,`; the chat itself is never sent.`]}),g?null:(0,G.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,children:`Sign in to OonaCode to send a report — it is filed under your account so we can answer it.`}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:`What happened?`}),(0,G.jsx)(`textarea`,{name:`message`,className:W(Z,`min-h-32 resize-y`),value:a,maxLength:Xs,placeholder:`The answer stopped after a few seconds with “API error”. I was using…`,onChange:e=>o(e.target.value),"data-testid":`bug-report-message`}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:E<500?`${E} characters left`:``})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{ref:h,type:`file`,multiple:!0,className:`hidden`,onChange:C,"data-testid":`bug-report-files`}),(0,G.jsxs)(Y,{size:`sm`,onClick:()=>h.current?.click(),disabled:l||p||s.length>=5,children:[(0,G.jsx)(J.Paperclip,{className:`w-3.5 h-3.5`}),`Attach files or pictures`]}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`up to `,5,` files,`,` `,Kv(Zs),` each`]})]}),s.length>0?(0,G.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"data-testid":`bug-report-attachments`,children:s.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2 py-1 text-xs`,children:[e.preview?(0,G.jsx)(`img`,{src:e.preview,alt:``,className:`h-8 w-8 rounded object-cover`,"aria-hidden":!0}):(0,G.jsx)(J.Paperclip,{className:`w-3.5 h-3.5 text-fg-muted`}),(0,G.jsx)(`span`,{className:`max-w-40 truncate`,title:e.name,children:e.name}),(0,G.jsx)(`span`,{className:`text-fg-faint`,children:Kv(e.size)}),(0,G.jsx)(X,{label:`Remove ${e.name}`,onClick:()=>w(e.key),children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]},e.key))}):null]}),d?(0,G.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`bug-report-error`,children:d}):null]})})}function RU(e){let t=Date.parse(`${e}T12:00:00`);return Number.isFinite(t)?new Date(t).toLocaleDateString(void 0,{dateStyle:`long`}):e}function zU({open:e,notes:t,onClose:n}){return(0,G.jsx)(Vy,{open:e,title:`What's new in OonaCode`,onClose:n,footer:(0,G.jsx)(Y,{variant:`primary`,onClick:n,children:`Got it`}),children:(0,G.jsx)(`div`,{className:`space-y-5 text-sm`,"data-testid":`whats-new`,children:t.map(e=>(0,G.jsxs)(`section`,{"data-version":e.version,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-2`,children:[(0,G.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Version `,e.version]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:RU(e.date)})]}),e.added.length>0?(0,G.jsx)(`ul`,{className:`space-y-1.5`,children:e.added.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(J.Plus,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent`}),(0,G.jsx)(`span`,{children:e})]},t))}):null,e.fixed.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`mb-1 mt-3 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:`Fixed`}),(0,G.jsx)(`ul`,{className:`space-y-1.5`,children:e.fixed.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(J.Check,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-ok`}),(0,G.jsx)(`span`,{children:e})]},t))})]}):null]},`${e.version}:${e.platforms?.join(`,`)??`all`}`))})})}function BU(){let{state:e,actions:t}=K(),n=im(e.account);return!n||e.ui.dialog===`account`?null:(0,G.jsxs)(`div`,{role:`status`,"data-testid":`vault-rekey-banner`,className:`flex items-center gap-2 bg-warn-soft px-3 py-1.5 text-xs text-warn`,children:[(0,G.jsx)(J.Alert,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`flex-1`,children:dm(n)}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),children:`Open Account`})]})}function VU({onReconnect:e}){let{state:t}=K(),n=t.connection.status;if(n===`open`||n===`idle`||n===`connecting`)return null;let r=n===`unauthorized`&&!window.oonacode;return(0,G.jsxs)(`div`,{role:`status`,className:W(`flex items-center gap-2 px-3 py-1.5 text-xs`,r?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),children:[r?(0,G.jsx)(J.Alert,{className:`w-3.5 h-3.5`}):(0,G.jsx)(J.Spinner,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`flex-1`,children:r?`The host rejected this connection${t.connection.detail?` (${t.connection.detail})`:``}. Re-open the UI from the desktop app or paste a fresh token.`:`Reconnecting to the host${t.connection.detail?` — ${t.connection.detail}`:``}…`}),r&&e?(0,G.jsx)(Y,{size:`sm`,variant:`danger`,onClick:e,children:`Enter token`}):null]})}function HU(){let{state:e,actions:t}=K(),n=(0,v.useRef)(1);n.current=Object.keys(e.layout.groups).length,(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{if(e.ctrlKey||e.metaKey){if(e.key===`Tab`){e.preventDefault(),t.cycleTab(e.shiftKey?-1:1);return}if(!(e.shiftKey||e.altKey)){if(e.key===`\\`||e.code===`Backslash`){e.preventDefault(),t.splitTab(`right`);return}if(/^[1-9]$/.test(e.key)){let r=Number(e.key)-1;if(r>=n.current)return;e.preventDefault(),t.focusGroupAt(r),UU(r)}}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function UU(e){let t=()=>{(document.querySelectorAll(`[data-editor-group]`)[e]?.querySelector(`[data-testid="composer"] textarea`))?.focus()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}function WU(){let{state:e,actions:t}=K(),n=(0,v.useRef)(!1),r=e.account?.loggedIn===!0,i=e.prefs.claudeImportOffered?3:e.prefs.claudeImportOffers,a=e.ui.dialog===`none`&&e.windowRole===`main`,o=e.settings!==null,s=(0,v.useRef)(e.ui.dialog);s.current=e.ui.dialog,(0,v.useEffect)(()=>{n.current||!o||i>=3||!r||!a||(n.current=!0,t.scanClaudeSessions().then(e=>{if(e.sessions.some(e=>!e.alreadyImported&&e.deletedHere!==!0&&!e.unavailable)){if(s.current!==`none`){n.current=!1;return}t.offerImport(),t.savePrefs({claudeImportOffers:i+1})}}).catch(()=>{}))},[t,a,r,i,o])}function GU(){let{state:e,actions:t}=K(),n=(0,v.useRef)(!1),[r,i]=(0,v.useState)(null),a=typeof window<`u`?window.oonacode:void 0,o=a?.appVersion??e.bundleAppVersion??null,s=e.settings!==null,c=e.prefs.lastSeenReleaseNotes,l=e.sessionListLoaded,u=e.sessionsTotal>0||e.sessions.length>0,d=e.settings?.uiPrefs,f=d!==void 0&&!(`lastSeenReleaseNotes`in d),p=e.ui.dialog===`none`&&e.windowRole===`main`,m=e.info?.platform??a?.platform??null;(0,v.useEffect)(()=>{if(n.current||!s||!o||!p||c===null&&!l||(n.current=!0,f))return;let{record:e,show:r}=tl(o,c,u,void 0,m);e!==null&&t.savePrefs({lastSeenReleaseNotes:e}),r.length!==0&&(i(r),t.openDialog(`whats-new`))},[t,f,p,o,c,m,l,s,u]);let h=e.ui.dialog===`whats-new`;return(0,v.useEffect)(()=>{!h&&r&&i(null)},[r,h]),r??(o?el(o,`0`,void 0,m):[])}function KU({onUnauthorized:e}){let{state:t,actions:n}=K(),r=(0,v.useCallback)(()=>n.openDialog(`none`),[n]),i=GU();WU();let a=typeof window<`u`&&window.oonacode?.host===`vscode`,o=t.ui.sidebarOpen&&!a;return HU(),(0,G.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,children:[(0,G.jsx)(AU,{}),(0,G.jsx)(VU,{onReconnect:e}),(0,G.jsx)(BU,{}),(0,G.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,G.jsx)(IR,{hidden:a,children:(0,G.jsx)(dU,{})}),o?(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>n.setSidebar(!1),"aria-hidden":!0}):null,t.prefs.explorerOpen?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>void n.savePrefs({explorerOpen:!1}),"aria-hidden":!0}),(0,G.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-30 flex max-w-[85vw] md:static md:z-auto md:max-w-none`,children:(0,G.jsx)(mH,{})})]}):null,(0,G.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,G.jsx)(rR,{})}),t.prefs.sessionPanelOpen?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 lg:hidden`,onClick:()=>void n.savePrefs({sessionPanelOpen:!1}),"aria-hidden":!0}),(0,G.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex max-w-[85vw] lg:static lg:z-auto lg:max-w-none`,children:(0,G.jsx)(uH,{})})]}):null]}),(0,G.jsx)(fR,{open:t.ui.dialog===`project`,onClose:r}),(0,G.jsx)(AR,{open:t.ui.dialog===`projects`,startNew:t.projectsStartNew,selectId:t.projectsSelectId,onClose:r}),(0,G.jsx)(yB,{open:t.ui.dialog===`assign-project`,onClose:r}),(0,G.jsx)(WH,{open:t.ui.dialog===`settings`,onClose:r}),(0,G.jsx)(Gb,{open:t.ui.dialog===`account`,onClose:r}),(0,G.jsx)(dR,{open:t.ui.dialog===`doctor`,onClose:r}),(0,G.jsx)(ex,{open:t.ui.dialog===`session-picker`,onClose:r}),(0,G.jsx)(OU,{open:t.ui.dialog===`update`,onClose:r}),(0,G.jsx)(LU,{open:t.ui.dialog===`bug-report`,onClose:r}),(0,G.jsx)(ER,{open:t.ui.dialog===`claude-login`,onClose:r}),(0,G.jsx)(oV,{open:t.ui.dialog===`oauth-login`,onClose:r}),(0,G.jsx)(sV,{open:t.ui.dialog===`manage-models`,onClose:r}),(0,G.jsx)(WV,{open:t.ui.dialog===`import-claude`,autoOffer:t.importOffered,onClose:r}),(0,G.jsx)(LR,{open:t.ui.dialog===`export-chats`,onClose:r}),(0,G.jsx)(az,{open:t.ui.dialog===`conversations`,selectId:t.conversationsSelectId,onClose:r}),(0,G.jsx)(gB,{open:t.ui.dialog===`chat-abouts`,onClose:r}),(0,G.jsx)(oB,{open:t.ui.dialog===`voice-summary`,onClose:r}),(0,G.jsx)(zU,{open:t.ui.dialog===`whats-new`,notes:i,onClose:r}),(0,G.jsx)(aV,{open:t.ui.connectProviderId!==null,providerId:t.ui.connectProviderId,onClose:()=>n.openProviderConnect(null)}),(0,G.jsx)(KH,{})]})}function qU({onUnauthorized:e}){let{state:t}=K(),n=t.account?.loggedIn===!0&&!t.account.vaultUnlocked;return(0,v.useEffect)(()=>{window.oonacode?.setVaultLocked?.(n)},[n]),t.accountLoaded?t.account?.loggedIn?!t.account.vaultUnlocked&&im(t.account)===null?(0,G.jsx)(rU,{}):(0,G.jsx)(KU,{onUnauthorized:e}):(0,G.jsx)(nU,{}):(0,G.jsx)(QH,{})}function JU({api:e,socket:t,relay:n,initialSessionId:r,onUnauthorized:i,reportError:a}){return(0,G.jsx)(jy,{api:e,socket:t,relay:n??null,initialSessionId:r??null,onUnauthorized:i,...a?{reportError:a}:{},children:(0,G.jsx)(qU,{onUnauthorized:i})})}var YU=`oonacode.host.connection`,XU=`session`;function ZU(e){let t=e.replace(/^#\/?\??/,``),n=new URLSearchParams(t),r=n.get(`token`),i=n.get(`host`)??n.get(`baseUrl`),a=n.get(XU);n.delete(`token`),n.delete(`host`),n.delete(`baseUrl`);let o=n.toString();return{token:r&&r.trim()?r.trim():null,baseUrl:i,sessionId:a,restHash:o?`#${o}`:``}}function QU(e){if(!e)return null;try{let t=e.getItem(YU);if(!t)return null;let n=JSON.parse(t);if(typeof n.baseUrl==`string`&&typeof n.token==`string`&&n.token)return{baseUrl:mm(n.baseUrl),token:n.token}}catch{}return null}function $U(e,t){if(e)try{t?e.setItem(YU,JSON.stringify(t)):e.removeItem(YU)}catch{}}async function eW(e){let t=ZU(e.location.hash);if(t.token){let n={baseUrl:mm(t.baseUrl??e.location.origin),token:t.token};$U(e.storage,n);let r=`${e.location.pathname}${e.location.search}${t.restHash}`;try{e.replaceUrl?.(r)}catch{}return{connection:n,source:`hash`,sessionId:t.sessionId}}if(e.bridge&&typeof e.bridge.getConnection==`function`)try{let n=await e.bridge.getConnection();if(n&&typeof n.token==`string`&&n.token&&typeof n.baseUrl==`string`){let r={baseUrl:mm(n.baseUrl),token:n.token};return $U(e.storage,r),{connection:r,source:`bridge`,sessionId:t.sessionId}}}catch{}let n=QU(e.storage);return n?{connection:n,source:`storage`,sessionId:t.sessionId}:{connection:null,source:`none`,sessionId:t.sessionId}}function tW(e=window){let t=null;try{t=e.sessionStorage}catch{t=null}return eW({location:e.location,storage:t,replaceUrl:t=>e.history.replaceState(null,``,t),bridge:e.oonacode})}var nW=1;function rW(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function iW(e,t){return`${mm(e).replace(/^http(s?):/i,`ws$1:`)}${b}?token=${encodeURIComponent(t)}`}var aW=class{clientId;opts;ws=null;_status=`idle`;attempts=0;preOpenFailures=0;epoch=0;reconnectTimer=null;pingTimer=null;manuallyClosed=!1;handlers=new Map;anyHandlers=new Set;statusHandlers=new Set;subscriptions=new Map;promptCounter=0;constructor(e){this.opts={clientKind:`web`,minBackoffMs:500,maxBackoffMs:15e3,pingIntervalMs:25e3,authProbeAfterFailures:2,...e,baseUrl:mm(e.baseUrl)},this.clientId=e.clientId??rW()}get status(){return this._status}connect(){this.manuallyClosed=!1,!(this.ws&&(this._status===`open`||this._status===`connecting`))&&this.open()}close(){this.manuallyClosed=!0,this.epoch+=1,this.clearTimers();let e=this.ws;if(this.ws=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`client closed`)}catch{}}this.setStatus(`closed`)}send(e){let t=this.ws;if(!t||t.readyState!==nW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}on(e,t){let n=this.handlers.get(e);n||(n=new Set,this.handlers.set(e,n));let r=t;return n.add(r),()=>{n?.delete(r)}}onAny(e){return this.anyHandlers.add(e),()=>{this.anyHandlers.delete(e)}}onStatus(e){return this.statusHandlers.add(e),e(this._status),()=>{this.statusHandlers.delete(e)}}subscribe(e,t){let n=this.subscriptions.get(e),r=t??n;this.subscriptions.set(e,r),this.send(r===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:r})}unsubscribe(e){this.subscriptions.delete(e),this.send({type:`unsubscribe`,sessionId:e})}noteSeq(e,t){if(t===null||!this.subscriptions.has(e))return;let n=this.subscriptions.get(e);(n===void 0||t>n)&&this.subscriptions.set(e,t)}prompt(e,t,n={}){let r=n.requestId??`req-${this.clientId.slice(0,8)}-${++this.promptCounter}`,i={type:`prompt`,sessionId:e,requestId:r,text:t};if(n.attachments&&n.attachments.length>0&&(i.attachments=n.attachments),n.options&&(i.options=n.options),!this.send(i))throw Error(`not connected`);return r}respondPermission(e,t,n){return this.send({type:`permission_response`,sessionId:e,requestId:t,decision:n})}interrupt(e){return this.send({type:`interrupt`,sessionId:e})}setModel(e,t){return this.send({type:`set_model`,sessionId:e,model:t})}setPermissionMode(e,t,n){return this.send({type:`set_permission_mode`,sessionId:e,mode:t,...n===void 0?{}:{posture:n}})}setEffort(e,t){return this.send({type:`set_effort`,sessionId:e,effort:t})}open(){this.clearTimers(),this.epoch+=1,this.setStatus(this.attempts===0?`connecting`:`reconnecting`);let e=iW(this.opts.baseUrl,this.opts.token),t=this.opts.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch(e){this.scheduleReconnect(String(e?.message??e));return}this.ws=n;let r=!1;n.onopen=()=>{if(this.ws===n){r=!0,this.attempts=0,this.preOpenFailures=0,this.setStatus(`open`),this.send({type:`hello`,protocolVersion:1,clientKind:this.opts.clientKind,clientId:this.clientId,...this.opts.clientVersion?{clientVersion:this.opts.clientVersion}:{}});for(let[e,t]of this.subscriptions)this.send(t===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:t});this.opts.pingIntervalMs>0&&(this.pingTimer=setInterval(()=>this.send({type:`ping`,ts:Date.now()}),this.opts.pingIntervalMs))}},n.onmessage=e=>{if(this.ws!==n)return;let t;try{t=typeof e.data==`string`?JSON.parse(e.data):null}catch{return}Pe(t)&&this.dispatch(t)},n.onerror=()=>{},n.onclose=e=>{if(this.ws!==n)return;if(this.ws=null,this.pingTimer&&=(clearInterval(this.pingTimer),null),this.manuallyClosed){this.setStatus(`closed`);return}if(e.code===4401||e.code===4403||e.code===1008){this.setStatus(`unauthorized`,e.reason||`host rejected the token or origin`);return}let t=e.reason||`closed (${e.code})`;if(this.preOpenFailures=r?0:this.preOpenFailures+1,!r&&this.opts.authProbeAfterFailures>0&&this.preOpenFailures>=this.opts.authProbeAfterFailures){this.probeAuthThenReconnect(t);return}this.scheduleReconnect(t)}}async probeAuthThenReconnect(e){let t=this.epoch;this.setStatus(`reconnecting`,e);let n=this.opts.fetchImpl??((e,t)=>fetch(e,t)),r=!1;try{let e=await n(`${this.opts.baseUrl}${z.health}`,{method:`GET`,headers:{authorization:`Bearer ${this.opts.token}`}});if(e.status===401||e.status===403)r=!0;else if(e.status===200){let t=await e.json().catch(()=>null);r=!(t&&typeof t==`object`&&typeof t.hostId==`string`)}}catch{}if(!(this.manuallyClosed||t!==this.epoch)){if(r){this.setStatus(`unauthorized`,`host rejected the token`);return}this.scheduleReconnect(e)}}dispatch(e){e.type===`agent`&&e.seq!==null&&this.noteSeq(e.sessionId,e.seq);let t=this.handlers.get(e.type);if(t)for(let n of[...t])oW(()=>n(e));for(let t of[...this.anyHandlers])oW(()=>t(e))}scheduleReconnect(e){this.attempts+=1;let t=Math.min(this.opts.maxBackoffMs,this.opts.minBackoffMs*2**Math.min(this.attempts-1,10)),n=Math.round(t*(.7+Math.random()*.6));this.setStatus(`reconnecting`,e);let r=this.opts.setTimeoutImpl??setTimeout;this.reconnectTimer=r(()=>{this.reconnectTimer=null,this.manuallyClosed||this.open()},n)}clearTimers(){this.reconnectTimer&&=((this.opts.clearTimeoutImpl??clearTimeout)(this.reconnectTimer),null),this.pingTimer&&=(clearInterval(this.pingTimer),null)}setStatus(e,t){this._status=e;for(let n of[...this.statusHandlers])oW(()=>n(e,t))}};function oW(e){try{e()}catch(e){console.error(`[HostSocket] handler failed`,e)}}var sW=/([?&#](?:token|access_token|key|api_key|secret|password)=)[^&#\s"']*/gi,cW=/\b(Bearer|Basic)\s+[A-Za-z0-9\-._~+/=]{8,}/g;function lW(e){return e.replace(sW,`$1[redacted]`).replace(cW,`$1 [redacted]`)}function uW(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function dW(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}function fW(e){if(dW(e)){let t=typeof e.name==`string`&&e.name?e.name:`Error`,n=typeof e.stack==`string`&&e.stack?e.stack:null;return{message:e.message||t,stack:n}}return typeof e==`string`?{message:uW(e,512),stack:null}:{message:`Unhandled rejection (${e===null?`null`:Array.isArray(e)?`array`:typeof e})`,stack:null}}function pW(e){return e?e.split(`
|
|
161
|
-
`).find(e=>/^\s+at\s/.test(e))?.trim()??``:``}function mW(e){let t=e.now??(()=>Date.now()),n=e.maxPerMinute??5,r=e.embedded??`browser`,i=[],a=new Map,o=(e,t)=>{for(;i.length>0&&(i[0]??0)<=t-6e4;)i.shift();for(let[e,n]of a)n<=t-6e4&&a.delete(e);return a.has(e)||i.length>=n?!1:(i.push(t),a.set(e,t),!0)},s=async(n,i={})=>{try{let a=e.api.reportError;if(typeof a!=`function`)return!1;let{message:s,stack:c}=fW(n),l=t();if(!o(`${s}\n${pW(c)}`,l))return!1;let u={client:`web-ui`,message:uW(lW(s),Js),detail:{source:`manual`,...i,embedded:r},at:new Date(l).toISOString()};return c&&(u.stack=uW(lW(c),Ys)),e.appVersion&&(u.appVersion=e.appVersion),e.platform&&(u.platform=e.platform),await a.call(e.api,u),!0}catch{return!1}},c=e=>{if(typeof e?.message!=`string`)return;let t=e.error??null;if(t===null&&!e.message)return;let n={source:`window.onerror`};typeof e.filename==`string`&&e.filename&&(n.filename=e.filename),typeof e.lineno==`number`&&e.lineno>0&&(n.lineno=e.lineno),typeof e.colno==`number`&&e.colno>0&&(n.colno=e.colno),s(t??e.message,n)},l=e=>{s(e?.reason,{source:`unhandledrejection`})};return{install:t=>{if(typeof e.api.reportError!=`function`)return()=>{};let n=e=>c(e),r=e=>l(e);return t.addEventListener(`error`,n),t.addEventListener(`unhandledrejection`,r),()=>{t.removeEventListener(`error`,n),t.removeEventListener(`unhandledrejection`,r)}},report:s,handleErrorEvent:c,handleRejectionEvent:l}}var hW=1;function gW(e,t){return`${mm(e).replace(/^http(s?):/i,`ws$1:`)}${z.remoteWs}?token=${encodeURIComponent(t)}`}function _W(e){return`tab-${e}-${Math.random().toString(36).slice(2,10)}`}var vW=class{#e;#t=new Map;#n=new Set;#r=null;#i=`idle`;#a=null;#o=0;#s=!1;#c=0;#l=null;constructor(e){this.#e=e}get status(){return this.#i}get pairingCount(){return this.#t.size}onStatus(e){return this.#n.add(e),e(this.#i),()=>{this.#n.delete(e)}}connect(){if(this.#r||this.#i===`connecting`)return;this.#s=!1,this.#d(`connecting`);let e=gW(this.#e.baseUrl,this.#e.token),t=this.#e.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch{this.#d(`closed`),this.#u();return}this.#r=n,n.onopen=()=>{if(this.#r===n){this.#o=0,this.#d(`open`),this.#f({type:`remote_hello`,protocolVersion:1,clientId:this.#e.clientId??`web-ui`,...this.#e.clientVersion?{clientVersion:this.#e.clientVersion}:{}});for(let e of this.#t.values())this.#p(e)}},n.onmessage=e=>{this.#r===n&&this.#h(e.data)},n.onerror=()=>void 0,n.onclose=()=>{if(this.#r===n){this.#r=null;for(let e of this.#t.values())this.#m(e,{state:`host_offline`,online:!1,detail:`reconnecting to this PC…`});this.#i!==`unavailable`&&this.#d(`closed`),this.#u()}}}close(){this.#s=!0,this.#l=null,this.#a&&(this.#e.clearTimeoutImpl??clearTimeout)(this.#a),this.#a=null,this.#t.clear();let e=this.#r;if(this.#r=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`closed`)}catch{}}this.#d(`idle`)}#u(){let e=this.#e.reconnectDelayMs??1e3;if(this.#s||e<=0||this.#a||this.#t.size===0)return;let t=this.#e.maxReconnectDelayMs??2e4;this.#o+=1;let n=Math.min(e*2**Math.min(this.#o-1,5),t),r=this.#e.setTimeoutImpl??setTimeout;this.#a=r(()=>{this.#a=null,this.#s||this.connect()},n)}#d(e,t){if(this.#i!==e){this.#i=e;for(let n of[...this.#n])n(e,t)}}#f(e){let t=this.#r;if(!t||t.readyState!==hW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}attach(e){this.#c+=1;let t=_W(this.#c),n={pairingId:t,hostId:e.hostId,sessionId:e.sessionId,state:`unavailable`,online:!1,detail:null,onFrame:e.onFrame,onState:e.onState};return this.#t.set(t,n),this.#r&&this.#r.readyState===hW?(this.#l!==null&&this.#m(n,{detail:this.#l}),this.#p(n)):this.connect(),{pairingId:t,hostId:e.hostId,sessionId:e.sessionId,send:e=>this.send(t,e),detach:()=>this.detach(t)}}detach(e){this.#t.get(e)&&(this.#t.delete(e),this.#f({type:`remote_detach`,pairingId:e}),this.#t.size===0&&this.close())}send(e,t){let n=this.#t.get(e);return!n||!n.online?!1:this.#f({type:`remote_send`,pairingId:e,frame:t})}#p(e){this.#f({type:`remote_attach`,pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId})}#m(e,t){Object.assign(e,t),e.onState({pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId,state:e.state,online:e.online,detail:e.detail})}#h(e){let t;try{let n=JSON.parse(typeof e==`string`?e:String(e));if(!Re(n))return;t=n}catch{return}switch(t.type){case`remote_welcome`:if(!t.canRelay){let e=t.reason??`this PC cannot reach your other devices right now`;this.#l=e,this.#d(`unavailable`,e);for(let t of this.#t.values())this.#m(t,{state:`unavailable`,online:!1,detail:e});return}this.#l=null,this.#i===`unavailable`&&this.#d(`open`);for(let e of this.#t.values())e.online||this.#p(e);return;case`remote_status`:{let e=this.#t.get(t.pairingId);if(!e)return;this.#m(e,{state:t.state,online:ze(t.state),detail:t.detail??null});return}case`remote_frame`:this.#t.get(t.pairingId)?.onFrame(t.frame);return;case`remote_error`:{let e=t.pairingId?this.#t.get(t.pairingId):void 0;e&&this.#m(e,{state:`error`,online:!1,detail:t.message});return}default:return}}};function yW({defaultBaseUrl:e,error:t,onConnect:n}){let[r,i]=(0,v.useState)(e),[a,o]=(0,v.useState)(``),s=r.trim().length>0&&a.trim().length>0;return(0,G.jsx)(`div`,{className:`flex min-h-full items-center justify-center bg-bg p-4`,children:(0,G.jsxs)(`form`,{className:`w-full max-w-md space-y-4 rounded-xl border border-border bg-surface p-6 shadow-md`,onSubmit:e=>{e.preventDefault(),s&&n({baseUrl:r.trim(),token:a.trim()})},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Connect to your OonaCode host`}),(0,G.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[`This page needs the host's access token. It is normally passed automatically when you open the UI from the desktop app or run`,` `,(0,G.jsx)(`code`,{className:`rounded bg-surface-2 px-1 font-mono`,children:`oona web`}),`.`]})]}),t?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:t}):null,(0,G.jsx)(zy,{label:`Host URL`,children:(0,G.jsx)(`input`,{className:Z,value:r,onChange:e=>i(e.target.value),placeholder:`http://127.0.0.1:41317`,spellCheck:!1,autoComplete:`url`})}),(0,G.jsx)(zy,{label:`Host token`,hint:'Found in host/host.json ("token") in the OonaCode folder of the PC running the host — %LOCALAPPDATA%\\OonaCode on Windows, ~/Library/Application Support/OonaCode on macOS, ~/.oonacode on Linux — printed by `oona serve --show-token`, or embedded in the URL printed by `oona web --print`.',children:(0,G.jsx)(`input`,{className:Z,type:`password`,value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0})}),(0,G.jsx)(Y,{type:`submit`,variant:`primary`,className:`w-full justify-center`,disabled:!s,children:`Connect`})]})})}function bW(e){return!!e&&e.platform===`linux`&&e.host!==`vscode`&&!!e.onMenuModel}var xW=e=>!!e&&e.type!==`separator`&&e.enabled;function SW(e,t,n){let r=e.length;for(let i=1;i<=r;i+=1){let a=((t+n*i)%r+r)%r;if(xW(e[a]))return a}return-1}function CW({label:e,mnemonic:t,show:n}){let r=n&&t?e.toLowerCase().indexOf(t):-1;return r<0?e:(0,G.jsxs)(G.Fragment,{children:[e.slice(0,r),(0,G.jsx)(`span`,{className:`underline underline-offset-2`,children:e[r]}),e.slice(r+1)]})}function wW({bridge:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(-1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null);(0,v.useEffect)(()=>e.onMenuModel?.(e=>{n(e),i(null),o(-1),c(null)}),[e]);let f=t?.items??[],p=(0,v.useCallback)(e=>e===null?[]:f[e]?.submenu??[],[f]),m=(0,v.useCallback)(()=>{i(null),o(-1),c(null)},[]),h=(0,v.useCallback)((e,t)=>{i(e);let n=p(e);o(t?SW(n,-1,1):-1),t&&c(e)},[p]),g=(0,v.useCallback)(t=>{!t||!xW(t)||t.type===`submenu`||(m(),e.invokeMenuItem?.(t.id))},[e,m]);if((0,v.useEffect)(()=>{if(f.length===0)return;let e=!1,t=()=>r!==null||s!==null,n=e=>{e.preventDefault(),e.stopPropagation()},l=l=>{if(l.key===`Alt`){e=!l.repeat,u(!0);return}e=!1;let d=!l.ctrlKey&&!l.metaKey&&!l.shiftKey;if(!t()){if(l.key===`F10`&&d&&!l.altKey){n(l),c(0);return}if(l.altKey&&d&&l.key.length===1){let e=f.findIndex(e=>e.mnemonic===l.key.toLowerCase());e>=0&&(n(l),h(e,!0))}return}let _=p(r),v=s??r??0,y=e=>{let t=(v+e+f.length)%f.length;r===null?c(t):h(t,!0)};switch(l.key){case`Escape`:n(l),r!==null&&s!==null?(i(null),o(-1)):m();return;case`ArrowLeft`:n(l),y(-1);return;case`ArrowRight`:n(l),y(1);return;case`ArrowDown`:n(l),r===null?h(v,!0):o(SW(_,a,1));return;case`ArrowUp`:n(l),r===null?(h(v,!0),o(SW(p(v),0,-1))):o(SW(_,a<0?0:a,-1));return;case`Home`:n(l),r!==null&&o(SW(_,-1,1));return;case`End`:n(l),r!==null&&o(SW(_,0,-1));return;case`Enter`:case` `:n(l),r===null?h(v,!0):g(_[a]);return;case`Tab`:m();return}if(l.key.length===1&&!l.ctrlKey&&!l.metaKey){n(l);let e=l.key.toLowerCase();if(r!==null)g(_.find(t=>t.mnemonic===e&&xW(t)));else{let t=f.findIndex(t=>t.mnemonic===e);t>=0&&h(t,!0)}return}m()},_=n=>{n.key===`Alt`&&(u(!1),e&&(e=!1,t()?m():c(0)))},v=()=>{e=!1,u(!1),m()},y=e=>{(r!==null||s!==null)&&(d.current&&e.target instanceof Node&&d.current.contains(e.target)||m())};return window.addEventListener(`keydown`,l,!0),window.addEventListener(`keyup`,_,!0),window.addEventListener(`blur`,v),document.addEventListener(`mousedown`,y,!0),()=>{window.removeEventListener(`keydown`,l,!0),window.removeEventListener(`keyup`,_,!0),window.removeEventListener(`blur`,v),document.removeEventListener(`mousedown`,y,!0)}},[f,r,s,a,p,h,g,m]),!t||f.length===0)return null;let _=l||s!==null;return(0,G.jsx)(`div`,{ref:d,role:`menubar`,"aria-label":`Application menu`,className:`flex h-7 shrink-0 items-stretch gap-px border-b border-border bg-surface px-1 text-[13px] text-fg select-none`,children:f.map((e,t)=>{let n=r===t;return(0,G.jsxs)(`div`,{className:`relative flex`,children:[(0,G.jsx)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":n,tabIndex:-1,disabled:!e.enabled,"data-menu-top":e.id,onMouseDown:e=>{e.preventDefault(),n?m():h(t,!1)},onMouseEnter:()=>{r!==null&&r!==t&&h(t,!1)},className:W(`my-0.5 rounded-sm px-2.5`,n||s===t?`bg-surface-3`:`hover:bg-surface-2`,!e.enabled&&`text-fg-faint`),children:(0,G.jsx)(CW,{label:e.label,mnemonic:e.mnemonic,show:_})}),n&&e.submenu?(0,G.jsx)(TW,{entries:e.submenu,active:a,showMnemonics:_,onHover:o,onRun:g}):null]},e.id)})})}function TW({entries:e,active:t,showMnemonics:n,onHover:r,onRun:i,nested:a=!1}){let[o,s]=(0,v.useState)(null);return(0,G.jsx)(`div`,{role:`menu`,className:W(`absolute z-[70] min-w-[15rem] rounded-md border border-border bg-surface py-1 text-fg shadow-lg`,a?`top-0 left-full -mt-1 ml-px`:`top-full left-0 mt-px`),children:e.map((e,a)=>{if(e.type===`separator`)return(0,G.jsx)(`div`,{role:`separator`,className:`my-1 border-t border-border`},e.id);let c=e.type===`checkbox`?`menuitemcheckbox`:e.type===`radio`?`menuitemradio`:`menuitem`,l=e.type===`checkbox`||e.type===`radio`;return(0,G.jsxs)(`div`,{role:c,"aria-disabled":!e.enabled||void 0,"aria-checked":l?e.checked:void 0,"aria-haspopup":e.type===`submenu`?`menu`:void 0,"data-menu-entry":e.id,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>{r(a),s(e.type===`submenu`?a:null)},onClick:()=>i(e),className:W(`relative flex cursor-default items-center gap-2 px-3 py-1`,a===t&&e.enabled&&`bg-surface-2`,!e.enabled&&`text-fg-faint`),children:[(0,G.jsx)(`span`,{className:`w-4 shrink-0 text-center`,"aria-hidden":!0,children:l&&e.checked?e.type===`radio`?`•`:`✓`:``}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,G.jsx)(CW,{label:e.label,mnemonic:e.mnemonic,show:n})}),e.accelerator?(0,G.jsx)(`span`,{className:`shrink-0 pl-6 text-xs text-fg-faint`,children:e.accelerator}):null,e.type===`submenu`?(0,G.jsx)(`span`,{className:`shrink-0 pl-4 text-fg-faint`,"aria-hidden":!0,children:`›`}):null,e.type===`submenu`&&o===a&&e.submenu?(0,G.jsx)(TW,{entries:e.submenu,active:-1,showMnemonics:n,onHover:()=>{},onRun:i,nested:!0}):null]},e.id)})})}function EW(e){return!!e&&typeof e==`object`&&typeof e.hostId==`string`}function DW(e){return Math.min(5e3,500*2**Math.max(0,e))}async function OW(e){let t=e.sleep??(e=>new Promise(t=>setTimeout(t,e)));for(let n=0;;n++){if(e.cancelled?.())return null;try{let t=await e.getConnection();if(t&&typeof t.token==`string`&&t.token&&typeof t.baseUrl==`string`&&await e.accepts(t).catch(()=>!1))return t}catch{}await t(DW(n))}}function kW(){let[e,t]=(0,v.useState)(void 0),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(!1),l=(0,v.useRef)(!1);(0,v.useEffect)(()=>()=>{l.current=!0},[]);let u=(0,v.useCallback)(()=>{let e=window.oonacode;return!e||typeof e.getConnection!=`function`?!1:c.current?!0:(c.current=!0,OW({getConnection:()=>e.getConnection(),accepts:e=>hm(e).health().then(e=>EW(e),()=>!1),cancelled:()=>l.current}).then(e=>{c.current=!1,e&&($U(window.sessionStorage,e),s(e=>e+1),t({baseUrl:e.baseUrl,token:e.token}))}),!0)},[]);(0,v.useEffect)(()=>{tW().then(e=>{r(e.sessionId),!(!e.connection&&u())&&t(e.connection)})},[u]),(0,v.useEffect)(()=>{e!==void 0&&document.getElementById(`oona-splash`)?.remove()},[e]);let d=(0,v.useCallback)(()=>{$U(window.sessionStorage,null),!u()&&(a(`The host rejected the token. Paste a current one from the host.`),t(null))},[u]),f=(0,v.useMemo)(()=>{if(!e)return null;let t=hm(e),n=window.oonacode?.window?.id;return{api:t,socket:new aW({baseUrl:e.baseUrl,token:e.token,clientKind:window.oonacode?`desktop`:`web`,clientVersion:window.oonacode?.appVersion,...n?{clientId:`${n.slice(0,16)}-${rW()}`}:{}}),relay:new vW({baseUrl:e.baseUrl,token:e.token,clientId:window.oonacode?`desktop`:`web-ui`,...window.oonacode?.appVersion?{clientVersion:window.oonacode.appVersion}:{}})}},[e]),p=(0,v.useMemo)(()=>f?mW({api:f.api,appVersion:window.oonacode?.appVersion??null,platform:window.oonacode?.platform??null,embedded:window.oonacode?`desktop`:`browser`}):null,[f]);return(0,v.useEffect)(()=>p?.install(window),[p]),e===void 0?null:!e||!f?(0,G.jsx)(yW,{defaultBaseUrl:window.location.origin,error:i,onConnect:e=>{$U(window.sessionStorage,e),a(null),t(e)}}):(0,G.jsx)(JU,{api:f.api,socket:f.socket,relay:f.relay,initialSessionId:n,onUnauthorized:d,...p?{reportError:p.report}:{}},o)}function AW({children:e}){let t=typeof window>`u`?void 0:window.oonacode;return bW(t)?(0,G.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,G.jsx)(wW,{bridge:t}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):(0,G.jsx)(G.Fragment,{children:e})}var jW=document.getElementById(`root`);(0,y.createRoot)(jW).render((0,G.jsx)(v.StrictMode,{children:(0,G.jsx)(AW,{children:(0,G.jsx)(kW,{})})}));
|
|
160
|
+
`),i=e.state===`missing`||e.left;return(0,G.jsxs)(`g`,{role:t?`button`:void 0,tabIndex:t?0:void 0,"aria-label":t?`Open chat ${e.title}`:void 0,className:W(t?`cursor-pointer`:`cursor-default`,`outline-none`),opacity:i?.5:1,onClick:t?()=>a(e.sessionId):void 0,onKeyDown:t?nz(()=>a(e.sessionId)):void 0,"data-testid":`map-chat-${e.sessionId}`,"data-state":e.state,children:[(0,G.jsx)(`title`,{children:r}),(0,G.jsx)(`circle`,{cx:e.x,cy:e.y,r:9,className:ez[e.state],strokeWidth:2,strokeDasharray:e.state===`missing`?`3 2`:void 0}),(0,G.jsx)(`text`,{x:e.labelX,y:e.labelY,textAnchor:e.anchor,className:`fill-fg text-[11px]`,children:e.label})]},e.sessionId)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border px-3 py-1.5 text-[11px] text-fg-muted`,"data-testid":`conversation-map-legend`,children:[(0,G.jsx)(iz,{dot:`bg-accent animate-pulse`,children:`working`}),(0,G.jsx)(iz,{dot:`bg-accent-soft border border-accent`,children:`idle`}),(0,G.jsx)(iz,{dot:`bg-surface-3 border border-fg-faint`,children:`asleep`}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-ok`}),`active`]}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`inline-block h-3 w-3 rounded-full border-2 border-dashed border-warn`}),`paused`]}),(0,G.jsx)(`span`,{children:`dashed spoke: left`}),f.length>0?(0,G.jsx)(`span`,{className:`text-accent`,children:`arrows: the newest message`}):null,c.hiddenClosed>0?(0,G.jsxs)(`span`,{className:`text-fg-faint`,children:[c.hiddenClosed,` closed hidden`]}):null]})]})}function iz({dot:e,children:t}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:W(`inline-block h-2.5 w-2.5 rounded-full`,e)}),t]})}function az({open:e,selectId:t=null,onClose:n}){let{state:r,actions:i}=K(),a=r.conversationsChange,[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(`list`),[C,w]=(0,v.useState)(!1),T=(0,v.useRef)(null);T.current=f;let E=(0,v.useRef)(-1),D=(0,v.useCallback)(async()=>{let e=await i.listConversations();if(e===`unsupported`){l(!0);return}if(e===null){d(!0);return}l(!1),d(!1),s(e)},[i]),O=(0,v.useCallback)(async e=>{let t=await i.conversationHistory(e);t&&T.current===e&&h(t)},[i]);(0,v.useEffect)(()=>{e&&(E.current=a.seq,_(!1),p(t??null),D())},[e]),(0,v.useEffect)(()=>{!e||f!==null||!o||o.length===0||p(o[0].id)},[e,o,f]),(0,v.useEffect)(()=>{if(!e||!f){h(null);return}h(e=>e?.conversation.id===f?e:null),O(f)},[e,f,O]),(0,v.useEffect)(()=>{if(!e||a.seq===E.current)return;E.current=a.seq,D();let t=T.current;t&&(a.conversationIds===null||a.conversationIds.includes(t))&&O(t)},[e,a,D,O]);let k=e=>{s(t=>t?.map(t=>t.id===e.id?e:t)??t),h(t=>t&&t.conversation.id===e.id?{...t,conversation:e}:t)},A=async(e,t,n)=>{let r=await i.conversationAction(e,t,n);return r&&k(r),r!==null},j=async()=>{b(!0);try{await i.stopAllConversations()}finally{b(!1),_(!1)}D(),T.current&&O(T.current)},M=async e=>{await i.cancelChatMessage(e.id),T.current&&O(T.current)},N=(0,v.useCallback)((e,t,n=[])=>{if(!e)return t??`OonaCode`;let i=n.find(t=>t.sessionId===e);if(i?.title)return i.title;if(t)return t;let a=r.sessions.find(t=>t.id===e);return a?cg(a):`a chat`},[r.sessions]),ee=m&&m.conversation.id===f?m.conversation:o?.find(e=>e.id===f)??null;return(0,G.jsxs)(Vy,{open:e,title:`Conversations`,onClose:n,wide:!0,footer:(0,G.jsx)(Y,{variant:`ghost`,onClick:n,children:`Close`}),children:[(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`p`,{className:`min-w-0 flex-1 text-xs text-fg-muted`,children:[`Messages and tasks your chats send each other, on this PC.`,` `,(0,G.jsx)(Ly,{label:`Conversations`,details:U.window})]}),c?null:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsxs)(Y,{variant:`danger`,size:`sm`,onClick:()=>_(!0),disabled:g||y,title:U.stopAll,"data-testid":`conversations-stop-all`,children:[(0,G.jsx)(J.Stop,{className:`h-3 w-3`}),` Stop all conversations`]}),(0,G.jsx)(Ly,{label:`Stop all conversations`,details:U.stopAll})]})]}),g?(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alertdialog`,"aria-label":`Stop all conversations?`,"data-testid":`conversations-stop-confirm`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Pause every conversation and stop the turns they are running now? Nothing is deleted; you can resume each one.`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,G.jsx)(Y,{size:`sm`,variant:`danger`,busy:y,onClick:()=>void j(),"data-testid":`conversations-stop-confirm-yes`,children:`Stop all`})]}):null,!c&&o!==null?(0,G.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border border-border text-xs`,role:`group`,"aria-label":`View`,children:[`list`,`map`].map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":x===e,onClick:()=>S(e),className:W(`px-3 py-1`,x===e?`bg-accent text-accent-fg`:`text-fg-muted hover:bg-surface-2`),title:e===`list`?U.listView:U.mapView,"data-testid":`conversations-view-${e}`,children:e===`list`?`List`:`Map`},e))}),x===`map`?(0,G.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-muted`,title:U.showClosed,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked),"data-testid":`conversation-map-show-closed`}),`Show closed`]}):null,(0,G.jsx)(Ly,{label:`Map`,details:U.mapView})]}):null,c?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-unsupported`,children:`OonaCode on this PC is too old for conversations between chats. Update it, then open this window again.`}):o===null?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`conversations-loading`,children:u?`Could not read the conversations from this PC right now. They show here as soon as it answers.`:`Loading…`}):x===`map`?(0,G.jsx)(rz,{list:o,showClosed:C,selectedId:f,messages:m&&m.conversation.id===f?m.messages:null,onSelectConversation:e=>{p(e),S(`list`)},onOpenChat:e=>{n(),i.selectSession(e)},canOpenChat:e=>r.sessions.some(t=>t.id===e)}):o.length===0?(0,G.jsxs)(`div`,{className:`space-y-1 text-sm text-fg-muted`,"data-testid":`conversations-empty`,children:[(0,G.jsx)(`p`,{children:`No conversations yet.`}),(0,G.jsx)(`p`,{className:`text-xs`,children:`To start one, turn on "Talk to other chats" in the Tools menu of two chats, then ask one of them to send the other a message or a task.`})]}):(0,G.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-[260px_1fr]`,children:[(0,G.jsx)(`ul`,{className:`flex max-h-[65vh] flex-col gap-1 overflow-y-auto pr-1`,"data-testid":`conversations-list`,children:o.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(cz,{c:e,selected:e.id===f,onSelect:()=>p(e.id)})},e.id))}),(0,G.jsx)(`div`,{className:`max-h-[65vh] min-w-0 overflow-y-auto pr-1`,children:ee?(0,G.jsx)(fz,{c:ee,messages:m&&m.conversation.id===ee.id?m.messages:null,titleOf:N,onAction:(e,t)=>A(ee.id,e,t),onWithdraw:e=>void M(e),onOpenChat:e=>{n(),i.selectSession(e)},isLocalChat:e=>r.sessions.some(t=>t.id===e)},ee.id):(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose a conversation.`})})]})]})}function oz({c:e}){return(0,G.jsx)(`span`,{title:U.status,"data-testid":`conversation-status`,children:(0,G.jsx)(Q,{tone:Od(e.status),children:Dd[e.status]})})}function sz({label:e,used:t,budget:n,format:r=e=>e.toLocaleString()}){let i=Rd(t,n),a=i>=1?`bg-danger`:i>=.8?`bg-warn`:`bg-accent`;return(0,G.jsxs)(`div`,{className:`mt-1`,"data-testid":`usage-${e.toLowerCase()}`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsxs)(`span`,{"data-testid":`usage-numbers`,children:[r(t),` of `,r(n)]})]}),(0,G.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e} used`,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":t,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,a),style:{width:`${Math.round(i*100)}%`}})})]})}function cz({c:e,selected:t,onSelect:n}){let r=e.members.filter(e=>e.leftAt===null);return(0,G.jsxs)(`button`,{type:`button`,onClick:n,"aria-pressed":t,className:W(`w-full rounded-md border px-2.5 py-2 text-left text-xs`,t?`border-accent bg-accent-soft`:`border-border hover:bg-surface-2`),"data-testid":`conversation-row-${e.id}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:Cd(e)}),(0,G.jsx)(oz,{c:e})]}),(0,G.jsxs)(`div`,{className:`mt-0.5 truncate text-fg-muted`,"data-testid":`conversation-members`,children:[r.length,` chat`,r.length===1?``:`s`,e.title?`: ${r.map(e=>e.title).join(`, `)}`:``]}),e.status!==`active`&&e.pausedReason?(0,G.jsx)(`div`,{className:`mt-0.5 text-warn`,"data-testid":`conversation-paused-reason`,children:e.pausedReason}):null,(0,G.jsx)(sz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,G.jsx)(sz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:$h}),(0,G.jsxs)(`div`,{className:`mt-1 flex justify-between gap-2 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`span`,{"data-testid":`conversation-cost`,children:Vd(e.used.credits)}),(0,G.jsx)(`span`,{title:ng(e.lastActivityAt),children:eg(e.lastActivityAt)})]})]})}function lz({title:e,help:t,children:n}){return(0,G.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3 first:border-t-0 first:pt-0`,children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[e,t?(0,G.jsx)(Ly,{label:e,details:t}):null]}),n]})}var uz={working:`working`,idle:`idle`,asleep:`asleep`,missing:`gone`},dz={working:`This chat is working on a turn right now.`,idle:`This chat is open and waiting.`,asleep:`This chat is not running; a message wakes it from its saved history.`,missing:`This chat is not on this PC any more (deleted).`};function fz({c:e,messages:t,titleOf:n,onAction:r,onWithdraw:i,onOpenChat:a,isLocalChat:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(String(e.budget.messages)),[h,g]=(0,v.useState)(String(e.budget.tokens));(0,v.useEffect)(()=>{m(String(e.budget.messages)),g(String(e.budget.tokens))},[e.budget.messages,e.budget.tokens]);let _=async(e,t,n)=>{c(e);try{return await r(t,n)}finally{c(null)}},y=p.trim()!==String(e.budget.messages)||h.trim()!==String(e.budget.tokens),b=y?Bd(p,h):null,x=()=>{if(!y||Bd(p,h))return;let t={},n=Number(p.trim()),r=Number(h.trim());n!==e.budget.messages&&(t.messages=n),r!==e.budget.tokens&&(t.tokens=r),_(`budget`,`budget`,t)},S=e.status===`closed`,C=(0,v.useMemo)(()=>[...e.members].sort((e,t)=>(e.leftAt===null?0:1)-(t.leftAt===null?0:1)),[e.members]);return(0,G.jsxs)(`div`,{className:`space-y-4`,"data-testid":`conversation-detail`,"data-id":e.id,children:[(0,G.jsxs)(lz,{title:`Conversation`,help:U.status,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`min-w-0 text-base font-semibold text-fg`,children:Cd(e)}),(0,G.jsx)(oz,{c:e})]}),e.pausedReason&&!S?(0,G.jsxs)(`p`,{className:`text-xs text-warn`,"data-testid":`conversation-detail-reason`,children:[`Paused: `,e.pausedReason]}):e.pausedReason&&S?(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Closed: `,e.pausedReason]}):null,(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Started `,ng(e.createdAt),` · last activity`,` `,(0,G.jsx)(`span`,{title:ng(e.lastActivityAt),children:eg(e.lastActivityAt)}),e.waiting>0?` · ${e.waiting} waiting to be delivered`:``]}),S?null:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.status===`active`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,onClick:()=>void _(`pause`,`pause`),busy:s===`pause`,title:U.pause,"data-testid":`conversation-pause`,children:`Pause`}),(0,G.jsx)(Ly,{label:`Pause`,details:U.pause})]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>void _(`resume`,`resume`),busy:s===`resume`,title:U.resume,"data-testid":`conversation-resume`,children:`Resume`}),(0,G.jsx)(Ly,{label:`Resume`,details:U.resume})]}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,variant:l?`danger`:`ghost`,busy:s===`close`,title:U.close,onClick:()=>{if(!l){u(!0);return}u(!1),_(`close`,`close`)},"data-testid":`conversation-close`,children:l?`Close it for good?`:`Close`}),(0,G.jsx)(Ly,{label:`Close`,details:U.close})]})]})]}),(0,G.jsxs)(lz,{title:`Budget`,help:U.budget,children:[(0,G.jsx)(sz,{label:`Messages`,used:e.used.messages,budget:e.budget.messages}),(0,G.jsx)(sz,{label:`Tokens`,used:e.used.tokens,budget:e.budget.tokens,format:$h}),(0,G.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,G.jsxs)(`span`,{"data-testid":`conversation-detail-cost`,children:[`Cost so far `,Vd(e.used.credits),` · `,$h(e.used.tokens),` `,`new tokens`]}),(0,G.jsx)(Ly,{label:`Cost`,details:U.cost})]}),S?null:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Messages`,(0,G.jsx)(`input`,{className:W(Z,`w-24`),inputMode:`numeric`,value:p,onChange:e=>m(e.target.value),"data-testid":`conversation-budget-messages`})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[`Tokens`,(0,G.jsx)(`input`,{className:W(Z,`w-32`),inputMode:`numeric`,value:h,onChange:e=>g(e.target.value),"data-testid":`conversation-budget-tokens`})]}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:x,disabled:!y||b!==null,busy:s===`budget`,title:U.budget,"data-testid":`conversation-budget-save`,children:`Save budget`}),b?(0,G.jsx)(`span`,{className:`text-xs text-danger`,"data-testid":`conversation-budget-problem`,children:b}):null]})]}),(0,G.jsx)(lz,{title:`Chats`,help:U.removeMember,children:(0,G.jsx)(`ul`,{className:`space-y-1`,"data-testid":`conversation-members-list`,children:C.map(e=>{let t=`${e.hostId}:${e.sessionId}`,n=e.leftAt!==null;return(0,G.jsxs)(`li`,{className:W(`flex flex-wrap items-center gap-2 rounded-md border border-border px-2.5 py-1.5 text-xs`,n&&`opacity-60`),"data-testid":`conversation-member-${e.sessionId}`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-fg`,children:e.title}),(0,G.jsx)(`span`,{title:dz[e.state],children:(0,G.jsx)(Q,{tone:e.state===`working`?`accent`:`neutral`,children:uz[e.state]})}),e.talkOn===!1?(0,G.jsx)(`span`,{className:`text-fg-faint`,title:`Its "Talk to other chats" switch is off: it cannot message other chats. It still answers a chat that messages it, and only that chat, when asked; what it sent before, and answers to what it asked, wait until it is on again.`,children:`answers only`}):null,n?(0,G.jsx)(`span`,{className:`text-fg-faint`,title:ng(e.leftAt),children:`left`}):null,e.state!==`missing`&&o(e.sessionId)?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>a(e.sessionId),title:U.openChat,"data-testid":`conversation-member-open`,children:`Open chat`}):null,!n&&!S?(0,G.jsx)(Y,{size:`sm`,variant:d===t?`danger`:`ghost`,busy:s===`remove:${t}`,title:U.removeMember,onClick:()=>{if(d!==t){f(t);return}f(null),_(`remove:${t}`,`remove-member`,{sessionId:e.sessionId,hostId:e.hostId})},"data-testid":`conversation-member-remove`,children:d===t?`Remove?`:`Remove`}):null]},t)})})}),(0,G.jsx)(lz,{title:`History`,help:U.history,children:t===null?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t.length===0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Nothing has been sent yet.`}):(0,G.jsx)(`ol`,{className:`space-y-2`,"data-testid":`conversation-history`,children:t.map(t=>(0,G.jsx)(pz,{m:t,from:t.kind===`notice`?`OonaCode`:n(t.fromSession,t.fromTitle,e.members),to:n(t.toSession,t.toTitle,e.members),onWithdraw:()=>i(t)},t.id))})})]})}function pz({m:e,from:t,to:n,onWithdraw:r}){let i=Md(e),a=zd(i),o=Fd(e),s=Id(e),[c,l]=(0,v.useState)(!1),u=e.kind===`reply`?J.Reply:e.kind===`notice`?J.Alert:e.kind===`continue`?J.Refresh:J.Mail;return(0,G.jsxs)(`li`,{className:W(`rounded-md border px-2.5 py-2 text-xs`,e.kind===`notice`?`border-warn/40 bg-warn-soft/40`:`border-border`),"data-testid":`conversation-message-${e.id}`,"data-kind":e.kind,"data-status":e.status,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,G.jsx)(u,{className:W(`h-3.5 w-3.5`,e.kind===`notice`?`text-warn`:`text-accent`)}),(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:kd[e.kind]}),(0,G.jsxs)(`span`,{className:`min-w-0 truncate text-fg-muted`,"data-testid":`conversation-message-route`,children:[t,` → `,n]}),(0,G.jsx)(`span`,{className:`text-fg-faint`,title:ng(e.createdAt),children:rg(e.createdAt)}),(0,G.jsx)(`span`,{className:`flex-1`}),e.kind===`notice`?null:(0,G.jsx)(`span`,{title:Ad[e.status],children:(0,G.jsx)(Q,{tone:jd(e.status),children:(0,G.jsx)(`span`,{"data-testid":`conversation-message-status`,children:e.status})})})]}),o||s||e.continued||e.stalled?(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-x-2 text-fg-muted`,children:[o?(0,G.jsx)(`span`,{title:o.help,"data-testid":`conversation-message-reply`,children:o.text}):null,s?(0,G.jsx)(`span`,{"data-testid":`conversation-message-batch`,children:s}):null,e.continued?(0,G.jsx)(`span`,{children:`continued after an OonaCode restart`}):null,e.stalled?(0,G.jsxs)(`span`,{className:`text-warn`,children:[`waiting for your permission to use `,e.stalled]}):null]}):null,e.error?(0,G.jsx)(`div`,{className:W(`mt-0.5`,e.status===`failed`?`text-danger`:`text-fg-muted`),"data-testid":`conversation-message-error`,children:e.error}):null,e.tokens>0||(e.credits??0)>0?(0,G.jsxs)(`div`,{className:`mt-0.5 text-fg-faint`,"data-testid":`conversation-message-usage`,children:[`The turn it caused: `,Hd(e,$h(e.tokens))]}):null,(0,G.jsx)(`div`,{className:W(`mt-1.5 text-fg`,a&&!c&&`max-h-24 overflow-hidden [mask-image:linear-gradient(to_bottom,black_60%,transparent)]`),"data-testid":`conversation-message-body`,"data-collapsed":a&&!c?`true`:void 0,children:(0,G.jsx)(tN,{text:i})}),(0,G.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[a?(0,G.jsx)(`button`,{type:`button`,className:`text-accent hover:underline`,onClick:()=>l(e=>!e),"aria-expanded":c,"data-testid":`conversation-message-expand`,children:c?`Show less`:`Show all`}):null,(0,G.jsx)(`span`,{className:`flex-1`}),Ld(e)?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:r,title:U.withdraw,"data-testid":`conversation-message-withdraw`,children:`Withdraw`}):null]})]})}var mz={language:`en`,localVoice:{},speed:1,words:Au.words},hz=`oonacode.voiceSummary.v1`;function gz(e){let t=e&&typeof e==`object`?e:{},n=mz,r={};if(t.localVoice&&typeof t.localVoice==`object`)for(let[e,n]of Object.entries(t.localVoice))typeof n==`string`&&n.length<300&&Ou(e)&&(r[e]=n);return{language:typeof t.language==`string`&&Ou(t.language)?Ou(t.language).code:n.language,localVoice:r,speed:Nu(t.speed),words:Mu(t.words)}}function _z(e=yz()){try{let t=e?.getItem(hz);return gz(t?JSON.parse(t):null)}catch{return{...mz}}}function vz(e,t=yz()){try{t?.setItem(hz,JSON.stringify(e))}catch{}}function yz(){try{return typeof window<`u`?window.localStorage:null}catch{return null}}function bz(e){return e.kind===`system`?null:e.key.slice(e.key.indexOf(`:`)+1)}var xz={zh:[`cmn`]};function Sz(e){return e.toLowerCase().replace(/_/g,`-`)}function Cz(e,t){let n=Sz(e);return[t.code,...xz[t.code]??[]].some(e=>n===e||n.startsWith(`${e}-`))}function wz(e,t){let n=Sz(e);return n===Sz(t.bcp47)?0:n===t.code||(xz[t.code]??[]).includes(n)?1:2}function Tz(e){let t=new Set(e.map(e=>e.name));return e.filter(e=>{let n=e.name.indexOf(`+`);if(n<=0)return!0;let r=e.name.lastIndexOf(` `),i=r>n?e.name.slice(r+1):``,a=i?`${e.name.slice(0,n)} ${i}`:e.name.slice(0,n);return!t.has(a)})}function Ez(e,t,n){let r=t.filter(t=>t.language===e.code||(t.locale?Cz(t.locale,e):!1)),i=r.filter(e=>e.engine!==`espeak`).map(e=>({key:`sherpa:${e.id}`,label:e.label,kind:`sherpa`})),a=r.filter(e=>e.engine===`espeak`).slice(0,1).map(e=>({key:`espeak:${e.id}`,label:e.label||`eSpeak (robotic)`,kind:`espeak`})),o=Tz(n.filter(t=>Cz(t.lang,e)&&t.localService!==!1)).map((t,n)=>({v:t,i:n,fit:wz(t.lang,e)})).sort((e,t)=>e.fit-t.fit||e.i-t.i).map(({v:e})=>({key:`system:${e.voiceURI}`,label:`${e.name} (system)`,kind:`system`}));return[...i,...o,...a]}function Dz(e,t){return e.find(e=>e.key===t)??e[0]??null}function Oz(e,t){if(e===`win32`||e===`linux`||e===`darwin`)return e;let n=t??``;return/Windows|Win32|Win64/i.test(n)?`win32`:/Android|CrOS/i.test(n)?null:/Linux|X11/i.test(n)?`linux`:/Mac OS X|Macintosh/i.test(n)?`darwin`:null}function kz(e,t,n=null,r=!1){let i=t?``:` The OonaCode desktop app comes with its own Armenian voices, and eSpeak for every other language.`,a=`No local voice for ${e.name} on this PC.`;return t&&n===`win32`&&r?`${a} The app’s own eSpeak voice, which speaks every language here, could not start — usually because Microsoft’s Visual C++ Redistributable (x64) is not installed: https://aka.ms/vs/17/release/vc_redist.x64.exe. Install it, then open this window again.`:n===`linux`?`${a} Install speech-dispatcher and espeak-ng from your distribution (Debian, Ubuntu, Mint: sudo apt install speech-dispatcher espeak-ng · Fedora: sudo dnf install speech-dispatcher espeak-ng · Arch: sudo pacman -S speech-dispatcher espeak-ng), then restart OonaCode.${i}`:n===`darwin`?`${a} Add a ${e.name} voice in System Settings → Accessibility → Spoken Content → System voice → Manage Voices, then open this window again.${i}`:n===`win32`?`${a} Add a ${e.name} voice in Settings → Time & language → Speech → Add voices, if Windows offers one for ${e.name}, then open this window again.${i}`:`${a} Add a ${e.name} voice in the system's speech settings (Windows: Settings → Time & language → Speech), then open this window again.${i}`}function Az(e){return e===`linux`?`whole`:`sentences`}var jz=75;function Mz(e,t){return Math.round(3e3+e.length*120/Nu(t))}async function Nz(e,t,n,r){let{signal:i,onItem:a}=r,o=e.getVoices().find(e=>e.voiceURI===r.voiceURI)??null;e.cancel();let s=r.mode===`whole`?[n.join(` `)]:[...n];for(let c=0;c<s.length;c+=1){if(i.aborted)return;let l=s[c],u=await new Promise((s,u)=>{let d=[],f=!1,p=()=>!f&&(f=!0,d.forEach(e=>clearTimeout(e)),i.removeEventListener(`abort`,m),!0),m=()=>{p()&&(e.cancel(),s(`stopped`))},h=t(l);o&&(h.voice=o),h.lang=o?.lang??r.bcp47,h.rate=r.rate,h.onstart=()=>{if(f)return;if(r.mode===`sentences`){a(c);return}a(0);let e=0;for(let t=1;t<n.length;t+=1)e+=(n[t-1].length+1)*jz/Nu(r.rate),d.push(setTimeout(()=>!f&&a(t),e))},h.onend=()=>{p()&&s(`ended`)},h.onerror=e=>{p()&&(i.aborted||e.error===`interrupted`||e.error===`canceled`?s(`stopped`):u(Error(`The system voice failed: ${e.error??`unknown error`}`)))},i.addEventListener(`abort`,m),d.push(setTimeout(()=>{p()&&s(`lost`)},Mz(l,r.rate))),e.speak(h)});if(u===`stopped`)return;u===`lost`&&e.cancel()}}function Pz(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Fz(e,t){let n=new DataView(new ArrayBuffer(44)),r=(e,t)=>{for(let r=0;r<t.length;r+=1)n.setUint8(e+r,t.charCodeAt(r))};return r(0,`RIFF`),n.setUint32(4,36+e,!0),r(8,`WAVE`),r(12,`fmt `),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,1,!0),n.setUint32(24,t,!0),n.setUint32(28,t*2,!0),n.setUint16(32,2,!0),n.setUint16(34,16,!0),r(36,`data`),n.setUint32(40,e,!0),n}function Iz(e,t){let n=new Uint8Array(44+e.length);return n.set(new Uint8Array(Fz(e.length,t).buffer),0),n.set(e,44),n.buffer}function Lz(e,t){let n=new DataView(new ArrayBuffer(e.length*2));for(let t=0;t<e.length;t+=1){let r=Math.max(-1,Math.min(1,e[t]));n.setInt16(t*2,Math.round(r*32767),!0)}return Iz(new Uint8Array(n.buffer),t)}function Rz(){let e=null,t=()=>{if(!e)return;let t=e;e=null,URL.revokeObjectURL(t.url),t.done()};return{play(n,r){return t(),new Promise(i=>{let a=URL.createObjectURL(new Blob([n],{type:`audio/wav`})),o=new Audio(a);o.preservesPitch=!0,o.playbackRate=r,e={audio:o,url:a,done:i},o.onended=t,o.onerror=t,o.play().catch(t)})},stop(){e&&e.audio.pause(),t()}}}var zz=Rz;async function Bz(e,t,n,r){if(e.length===0)return;let i=t(e[0],0);for(let a=0;a<e.length;a+=1){if(r.signal.aborted)return;let o=await i;if(r.signal.aborted)return;i=a+1<e.length?t(e[a+1],a+1):null,i?.catch(()=>void 0),r.onItem?.(a),await n.play(o,r.playbackRate??1)}}var Vz={range:`all`,from:``,to:``},Hz=`oonacode.aboutBriefing.v1`,Uz=/^\d{4}-\d{2}-\d{2}$/;function Wz(e){let t=e&&typeof e==`object`?e:{};return{range:yu(t.range)?t.range:Vz.range,from:typeof t.from==`string`&&Uz.test(t.from)?t.from:``,to:typeof t.to==`string`&&Uz.test(t.to)?t.to:``}}function Gz(){try{let e=window.localStorage.getItem(Hz);return Wz(e?JSON.parse(e):null)}catch{return{...Vz}}}function Kz(e){try{window.localStorage.setItem(Hz,JSON.stringify(e))}catch{}}function qz(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t.has(r)&&(n+=1);return n===0?`none`:n===e.length?`all`:`some`}function Jz(e,t){let n=new Set(t);if(qz(e,t)===`all`)for(let t of e)n.delete(t);else for(let t of e)n.add(t);return n}function Yz(e,t){let n=new Set(t),r=!1;for(let t of e)n.has(t)||(r=!0);return r?new Set([...e].filter(e=>n.has(e))):e}function Xz(e,t){let n=[];if(e>0&&n.push(`${e} of the picked chats ${e===1?`has`:`have`} no about yet`),t>0){let r=e>0?`${t}`:`${t} of the picked chats`;n.push(`${r} ${t===1?`has an about`:`have abouts`} older than the chat’s last change`)}let r=[e>0?`a chat with no about is announced by its name and “no summary yet”`:null,t>0?`an older about is read as it is`:null].filter(Boolean).join(`, and `);return`${n.join(`; `)}. Writing them is one housekeeper call per chat, paid by the chat’s own route — credits for an OonaCode pool chat. Until then ${r}.`}var Zz={status:`idle`,index:-1,total:0,sessionId:null,title:null,part:0,error:null,playlist:[]};function Qz(e){return e.status===`preparing`||e.status===`speaking`||e.status===`paused`}var $z={afterNameMs:_u.afterNameMs,betweenChatsMs:_u.betweenChatsMs};function eB(e,t){return new Promise(n=>{if(t.aborted||e<=0){n();return}let r=()=>{clearTimeout(i),t.removeEventListener(`abort`,r),n()},i=setTimeout(r,e);t.addEventListener(`abort`,r,{once:!0})})}function tB(e,t){return t.aborted?Promise.reject(Error(`stopped`)):new Promise((n,r)=>{let i=()=>r(Error(`stopped`));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}var nB=class{#e;#t=[];#n=Zz;#r=null;#i=new Map;#a=new AbortController;constructor(e){this.#e=e}get state(){return this.#n}start(e,t=0){if(this.#t=[...e],this.#i.clear(),this.#t.length===0){this.#o(),this.#s({...Zz});return}this.#l(Math.max(0,Math.min(t,this.#t.length-1)),0)}pause(){(this.#n.status===`preparing`||this.#n.status===`speaking`)&&(this.#o(),this.#s({status:`paused`}))}resume(){let e=this.#n;e.index<0||this.#t.length===0||(e.status===`paused`?this.#l(e.index,e.part):e.status===`error`&&this.#l(e.index,0))}stop(){this.#o(),this.#n.status!==`idle`&&this.#n.status!==`stopped`&&this.#s({status:`stopped`,index:-1,part:0,error:null})}reset(){this.#o(),this.#t=[],this.#i.clear(),this.#n!==Zz&&(this.#n=Zz,this.#e.onState(Zz))}next(){if(this.#t.length===0||this.#n.index<0)return;let e=this.#n.index+1;if(e>=this.#t.length){this.#o(),this.#s({status:`done`,part:0});return}this.#l(e,0)}previous(){this.#t.length===0||this.#n.index<0||this.#l(Math.max(0,this.#n.index-1),0)}jumpTo(e){let t=this.#t.findIndex(t=>t.sessionId===e);t>=0&&this.#l(t,0)}resetWords(){this.#i.clear()}dispose(){this.reset(),this.#a.abort()}#o(){let e=this.#r;if(this.#r=null,e){e.abort();try{this.#e.silence()}catch{}}}#s(e){let t={...this.#n,...e},n=t.index>=0?this.#t[t.index]:void 0;t.total=this.#t.length,t.sessionId=n?.sessionId??null,t.title=n?.title??null,t.playlist=t.playlist.length===this.#t.length&&t.playlist.every((e,t)=>e===this.#t[t].sessionId)?t.playlist:this.#t.map(e=>e.sessionId),this.#n=t,this.#e.onState(t)}#c(e){let t=this.#t[e],n=this.#i.get(t.sessionId);if(n)return n;let r=this.#e.words(t,this.#a.signal);return this.#i.set(t.sessionId,r),r.catch(()=>{this.#i.get(t.sessionId)===r&&this.#i.delete(t.sessionId)}),r}#l(e,t){this.#o();let n=new AbortController;this.#r=n,this.#u(e,t,n.signal)}async#u(e,t,n){let r=this.#e.sleep??eB,i=this.#e.afterNameMs??$z.afterNameMs,a=this.#e.betweenChatsMs??$z.betweenChatsMs,o=e;try{for(;o<this.#t.length;o+=1){let s=o===e?t:0;this.#s({status:`preparing`,index:o,part:s,error:null});let c=await tB(this.#c(o),n);if(n.aborted)return;o+1<this.#t.length&&this.#c(o+1).catch(()=>void 0);let l=+!!c.name;if(c.name&&s===0&&(this.#s({status:`speaking`,part:0}),await this.#e.speak([c.name],{signal:n,onItem:()=>void 0}),n.aborted||(c.body.length>0&&await r(i,n),n.aborted)))return;let u=Math.max(0,s-l),d=c.body.slice(u);if(d.length>0&&(this.#s({status:`speaking`,part:l+u}),await this.#e.speak(d,{signal:n,onItem:e=>{n.aborted||this.#s({status:`speaking`,part:l+u+e})}}),n.aborted)||o+1<this.#t.length&&(await r(a,n),n.aborted))return}this.#r?.signal===n&&(this.#r=null),this.#s({status:`done`,index:this.#t.length-1,part:0})}catch(e){if(n.aborted)return;this.#r?.signal===n&&(this.#r=null);try{this.#e.silence()}catch{}let t=this.#t[o]?.title??`a chat`,r=e instanceof Error?e.message:String(e);this.#s({status:`error`,index:Math.min(o,this.#t.length-1),part:0,error:`${t}: ${r}`})}}};async function rB(e,t){let{voice:n,language:r,speed:i,tts:a,signal:o,onItem:s}=t,c=n?bz(n):null;if(c&&a){await Bz(e,async e=>{let n=await a.speak({voiceId:c,text:t.prepare(e,r.code),speed:i});return Lz(n.samples,n.sampleRate)},t.player,{signal:o,onItem:s});return}if(n?.kind===`system`){if(!t.synth)throw Error(`This window has no system speech.`);await Nz(t.synth,t.makeUtterance,e,{voiceURI:n.key.slice(7),bcp47:r.bcp47,rate:i,mode:Az(t.platform),signal:o,onItem:s});return}throw Error(kz(r,!!a,t.platform,t.espeakMissing))}function iB(e){let[t,n]=(0,v.useState)([]);return(0,v.useEffect)(()=>{if(!e||typeof window>`u`||!window.speechSynthesis)return;let t=window.speechSynthesis,r=()=>n(t.getVoices());return r(),t.addEventListener?.(`voiceschanged`,r),()=>t.removeEventListener?.(`voiceschanged`,r)},[e]),t}function aB(e){let t=e instanceof Error?e.message:String(e);return/no route for|not_found|404/i.test(t)&&/voice/i.test(t)?`This PC’s OonaCode host does not know "Listen" yet — update OonaCode.`:t}function oB({open:e,onClose:t}){let{state:n,api:r}=K(),i=n.voiceSummarySessionId,a=(0,v.useMemo)(()=>n.sessions.find(e=>e.id===i)??null,[n.sessions,i]),o=typeof window<`u`?window.oonacode?.tts:void 0,s=Oz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[c,l]=(0,v.useState)(()=>_z()),[u,d]=(0,v.useState)(null),f=iB(e),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)({kind:`idle`}),[S,C]=(0,v.useState)(null),w=(0,v.useRef)(null),T=Ou(c.language)??Ou(`en`),E=(0,v.useCallback)(e=>{l(t=>{let n={...t,...e};return vz(n),n})},[]),D=p?.summaries??[],O=D.find(e=>e.id===_)??D[0]??null,k=(0,v.useCallback)(async()=>{if(!i||!r.listVoiceSummaries)return null;try{let e=await r.listVoiceSummaries(i);return m(e),g(null),e}catch(e){return g(aB(e)),null}},[r,i]);(0,v.useEffect)(()=>{e&&(m(null),y(null),C(null),x({kind:`idle`}),k(),o?(d(null),o.listVoices().then(d,()=>d([]))):d([]))},[e,k,o]);let A=a?`${a.entryCount}:${a.mtime}`:null,j=(0,v.useRef)(null),M=(0,v.useRef)(null);(0,v.useEffect)(()=>{if(!e){j.current=null;return}if(j.current===null){j.current=A;return}A!==j.current&&(j.current=A,!M.current&&(M.current=setTimeout(()=>{M.current=null,k()},800)))},[e,A,k]),(0,v.useEffect)(()=>()=>{M.current&&clearTimeout(M.current),M.current=null},[]);let N=(0,v.useCallback)(()=>{let e=w.current;w.current=null,e&&(e.abort.abort(),e.stop())},[]);(0,v.useEffect)(()=>{e||N()},[e,N]),(0,v.useEffect)(()=>()=>N(),[N]);let ee=(0,v.useMemo)(()=>Ez(T,u??[],f),[T,u,f]),te=Dz(ee,c.localVoice[T.code]),P=!!(o&&u&&!u.some(e=>e.engine===`espeak`)),F=b.kind===`summarising`||b.kind===`translating`||b.kind===`speaking`,ne=!!(r.listVoiceSummaries&&r.createVoiceSummary),re=async()=>{if(!i||!r.createVoiceSummary)return null;x({kind:`summarising`});let e=await r.createVoiceSummary(i,{words:c.words});return C(e.created?null:yd.unchanged(Pz(e.summary.createdAt))),y(e.summary.id),await k(),e.summary},ie=async()=>{if(!i)return;N();let e=new AbortController,t=zz(),n=()=>{try{window.speechSynthesis?.cancel()}catch{}};w.current={abort:e,stop:()=>{t.stop(),n()}};let a=e.signal;try{let e=md(p,_)?await re():O;if(a.aborted)return;if(!e)throw Error(`There is no summary to play.`);let n=gd(e,T.code);if(n===null){if(!r.translateVoiceSummary)throw Error(`This host cannot translate yet.`);x({kind:`translating`});let t=await r.translateVoiceSummary(i,e.id,{language:T.code});if(m(n=>sB(n,e.id,t.translation)),a.aborted)return;n=t.translation.text,k()}let l=Yu(n);if(l.length===0)throw Error(`There was nothing to read.`);let u=e=>x({kind:`speaking`,index:e+1,total:l.length}),d=te?bz(te):null;if(d&&o)await Bz(l,async e=>{let t=await o.speak({voiceId:d,text:pd(e,T.code),speed:c.speed});return Lz(t.samples,t.sampleRate)},t,{signal:a,onItem:u});else if(te?.kind===`system`){let e=typeof window<`u`?window.speechSynthesis:void 0;if(!e)throw Error(`This window has no system speech.`);await Nz(e,e=>new SpeechSynthesisUtterance(e),l,{voiceURI:te.key.slice(7),bcp47:T.bcp47,rate:c.speed,mode:Az(s),signal:a,onItem:u})}else throw Error(kz(T,!!o,s,P));if(a.aborted)return;x({kind:`done`})}catch(e){if(a.aborted)return;x({kind:`error`,message:aB(e)})}finally{w.current?.abort===e&&(w.current=null)}},I=()=>{N(),x({kind:`stopped`})},L=async e=>{if(!(!i||!r.deleteVoiceSummary))try{await r.deleteVoiceSummary(i,e),_===e&&y(null),await k()}catch(e){x({kind:`error`,message:aB(e)})}};if(!e)return null;let R=a?Rl(a):`this chat`,ae=O?gd(O,T.code):null,oe=O?new Set(hd(O)):new Set;return(0,G.jsx)(Vy,{open:e,title:`Listen to this chat`,onClose:t,wide:!0,footer:(0,G.jsxs)(G.Fragment,{children:[F?(0,G.jsxs)(Y,{onClick:I,"data-testid":`voice-stop`,children:[(0,G.jsx)(J.Stop,{className:`h-4 w-4`}),` Stop`]}):null,(0,G.jsxs)(Y,{variant:`primary`,onClick:()=>void ie(),disabled:F||!ne||!i,"data-testid":`voice-play`,children:[(0,G.jsx)(J.Play,{className:`h-4 w-4`}),` Play`]}),(0,G.jsx)(Y,{onClick:t,children:`Close`})]}),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm`,children:[(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`A spoken summary of `,(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:R}),` — its goal, what was done, where it stands and what is pending — written by the chat’s own model, in English. Other languages are translated once by `,ku.label,` on your OonaCode credits and kept with the summary.`]}),ne?null:(0,G.jsx)(`p`,{className:`text-danger`,children:`This version of the host cannot make voice summaries.`}),(0,G.jsxs)(`section`,{"data-testid":`voice-summaries`,children:[(0,G.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Summaries`}),h?(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:h}):null,p&&D.length===0?(0,G.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-no-summaries`,children:yd.noSummaries}):null,D.length>0&&md(p,_)?(0,G.jsx)(`p`,{className:`mb-1 text-xs text-fg-muted`,"data-testid":`voice-changed`,children:yd.changedSinceNewest}):null,(0,G.jsx)(`ul`,{className:`flex max-h-56 flex-col gap-1 overflow-y-auto`,children:D.map(e=>{let t=O?.id===e.id;return(0,G.jsxs)(`li`,{"data-testid":`voice-summary-row`,className:W(`flex items-start gap-2 rounded-md border px-2 py-1.5`,t?`border-accent bg-accent/10`:`border-border`),children:[(0,G.jsx)(`input`,{type:`radio`,name:`voice-summary`,className:`mt-1`,"aria-label":`Summary of ${Pz(e.createdAt)}`,checked:t,disabled:F,onChange:()=>y(e.id)}),(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 flex-col items-start text-left`,disabled:F,onClick:()=>y(e.id),children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[Pz(e.createdAt),e.current?(0,G.jsx)(`span`,{className:`ml-2 rounded-full bg-accent/15 px-1.5 text-xs text-accent`,children:`current`}):null]}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[e.words,` words · about `,_d(e.seconds),` ·`,` `,hd(e).map(e=>e.toUpperCase()).join(` `),` `,`· `,e.cost.model??`the chat’s model`,` · `,vd(e.cost)]})]}),(0,G.jsx)(Y,{size:`sm`,onClick:()=>void L(e.id),disabled:F,"aria-label":`Delete the summary of ${Pz(e.createdAt)}`,"data-testid":`voice-summary-delete`,children:(0,G.jsx)(J.Trash,{className:`h-3.5 w-3.5`})})]},e.id)})}),S?(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,"data-testid":`voice-notice`,children:S}):null]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,G.jsx)(zy,{label:`Language`,children:(0,G.jsx)(`select`,{"aria-label":`Language`,className:By,value:T.code,disabled:F,onChange:e=>E({language:e.target.value}),children:Du.map(e=>{let t=e.name===e.native?e.name:`${e.name} — ${e.native}`;return(0,G.jsx)(`option`,{value:e.code,children:oe.has(e.code)?`${t} ✓`:t},e.code)})})}),o&&u===null?(0,G.jsx)(`p`,{className:`px-1 py-2 text-fg-muted`,"data-testid":`voice-loading`,children:`Looking for this PC’s voices…`}):ee.length>0?(0,G.jsx)(zy,{label:`Voice`,children:(0,G.jsx)(`select`,{"aria-label":`Voice`,className:By,value:te?.key??``,disabled:F,onChange:e=>E({localVoice:{...c.localVoice,[T.code]:e.target.value}}),children:ee.map(e=>(0,G.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,G.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-3 py-2 text-fg-muted`,"data-testid":`no-local-voice`,children:kz(T,!!o,s,P)}),(0,G.jsx)(zy,{label:`Speed ×${c.speed.toFixed(2)}`,children:(0,G.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:ju.speed.min,max:ju.speed.max,step:.05,value:c.speed,disabled:F,onChange:e=>E({speed:Number(e.target.value)})})}),(0,G.jsx)(zy,{label:`Length of a new summary`,children:(0,G.jsxs)(`select`,{"aria-label":`Length of a new summary`,className:By,value:String(c.words),disabled:F,onChange:e=>E({words:Number(e.target.value)}),children:[(0,G.jsx)(`option`,{value:`120`,children:`Short — about 120 words`}),(0,G.jsx)(`option`,{value:`200`,children:`Normal — about 200 words`}),(0,G.jsx)(`option`,{value:`300`,children:`Long — about 300 words`}),[120,200,300].includes(c.words)?null:(0,G.jsxs)(`option`,{value:String(c.words),children:[c.words,` words`]})]})})]}),(0,G.jsx)(cB,{stage:b}),O?(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h3`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:yd.heading(T,ae!==null)}),(0,G.jsx)(`p`,{className:`whitespace-pre-wrap rounded-md border border-border bg-surface-2 px-3 py-2`,"data-testid":`voice-summary-text`,dir:ae!==null&&T.rtl?`rtl`:`ltr`,lang:ae===null?`en-US`:T.bcp47,children:ae??O.text})]}):null]})})}function sB(e,t,n){return e&&{...e,summaries:e.summaries.map(e=>e.id===t?{...e,translations:[...e.translations.filter(e=>e.language!==n.language),n]}:e)}}function cB({stage:e}){let t=[{key:`summarising`,label:yd.generating},{key:`translating`,label:yd.translating},{key:`speaking`,label:`Speaking`}];if(e.kind===`idle`)return null;if(e.kind===`error`)return(0,G.jsx)(`p`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-danger`,role:`alert`,"data-testid":`voice-stage`,children:e.message});if(e.kind===`stopped`||e.kind===`done`)return(0,G.jsx)(`p`,{className:`text-fg-muted`,"data-testid":`voice-stage`,children:e.kind===`stopped`?`Stopped.`:`Done.`});let n=t.findIndex(t=>t.key===e.kind);return(0,G.jsx)(`ol`,{className:`flex flex-wrap items-center gap-2 text-xs`,"data-testid":`voice-stage`,"aria-live":`polite`,children:t.map((t,r)=>(0,G.jsx)(`li`,{className:W(`rounded-full px-2 py-0.5`,r===n?`bg-accent/15 font-medium text-accent`:r<n?`text-fg-muted line-through`:`text-fg-faint`),children:t.key===`speaking`&&e.kind===`speaking`?`Speaking ${e.index} of ${e.total}`:t.label},t.key))})}function lB(e){return Ku(e).replace(/\n+/g,` `).trim()||e.trim()}function uB(e){let t=e instanceof Error?e.message:String(e);return/no route for|404/i.test(t)&&/about/i.test(t)?`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`:t}function dB(e){return{sessionId:e.sessionId,title:e.title.trim()||`Untitled chat`,about:e.about}}function fB(e){return e.filter(e=>!e.pending&&e.source!==`user`&&(!e.about||e.stale))}function pB({open:e,picked:t}){let{api:n}=K(),r=(0,v.useRef)(n);r.current=n;let i=typeof window<`u`?window.oonacode?.tts:void 0,a=Oz(typeof window<`u`?window.oonacode?.platform:null,typeof navigator<`u`?navigator.userAgent:null),[o,s]=(0,v.useState)(()=>_z()),[c,l]=(0,v.useState)(null),u=iB(e),d=Ou(o.language)??Ou(`en`),f=(0,v.useMemo)(()=>Ez(d,c??[],u),[d,c,u]),p=Dz(f,o.localVoice[d.code]),m=!!(i&&c&&!c.some(e=>e.engine===`espeak`)),[h,g]=(0,v.useState)(Zz),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(0),[S,C]=(0,v.useState)(!1),w=(0,v.useRef)({lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i});w.current={lang:d,voice:p,speed:o.speed,espeakMissing:m,platform:a,tts:i};let T=(0,v.useCallback)(e=>{s(t=>{let n={...t,...e};return vz(n),n})},[]),E=(0,v.useMemo)(()=>{let e=zz();return new nB({words:async e=>{let{lang:t}=w.current;if(!e.about)return{name:lB(e.title),body:[wu(t.code)]};if(t.code===`en`)return{name:lB(e.title),body:Yu(Ku(e.about))};let n=r.current.translateChatAbout;if(!n)throw Error(`This PC’s OonaCode host cannot read the abouts in other languages yet — update OonaCode. English plays.`);try{let r=await n(e.sessionId,{language:t.code});return r.created&&x(e=>e+1),{name:r.translation.name?lB(r.translation.name):null,body:Yu(r.translation.text)}}catch(e){throw Error(`could not translate it: ${uB(e)}`)}},speak:(t,{signal:n,onItem:r})=>{let i=w.current;return rB(t,{voice:i.voice,language:i.lang,speed:i.speed,tts:i.tts,player:e,synth:typeof window<`u`?window.speechSynthesis:void 0,makeUtterance:e=>new SpeechSynthesisUtterance(e),platform:i.platform,espeakMissing:i.espeakMissing,prepare:pd,signal:n,onItem:r})},silence:()=>{e.stop();try{typeof window<`u`&&window.speechSynthesis?.cancel()}catch{}},onState:g})},[]);(0,v.useEffect)(()=>{if(!e){E.reset();return}s(_z()),i?(l(null),i.listVoices().then(l,()=>l([]))):l([])},[e,i,E]),(0,v.useEffect)(()=>()=>E.dispose(),[E]),(0,v.useEffect)(()=>{E.resetWords()},[d.code,E]);let D=t.map(e=>`${e.sessionId}\u0000${e.title}\u0000${e.about??``}`).join(``);(0,v.useEffect)(()=>{C(!1)},[D,d.code]),(0,v.useEffect)(()=>{let r=n.planChatAboutTranslations;if(!e||d.code===`en`||t.length===0||!r){y(null);return}let i=!0;return r({language:d.code,sessionIds:t.map(e=>e.sessionId)}).then(e=>i&&y(e),()=>i&&y(null)),()=>{i=!1}},[e,d.code,D,b,n]);let O=h.status===`preparing`||h.status===`speaking`,k=d.code!==`en`&&_!==null&&_.language===d.code&&_.needed>_u.confirmAbove,A=(0,v.useCallback)(()=>{C(!1),E.start(t.map(dB),0)},[E,t]),j=(0,v.useCallback)(()=>{if(t.length!==0){if(k&&!S){C(!0);return}A()}},[t.length,k,S,A]);return{prefs:o,update:T,lang:d,options:f,voice:p,espeakMissing:m,voicesLoading:!!i&&c===null,desktop:!!i,platform:a,state:h,busy:O,active:Qz(h),plan:_&&_.language===d.code?_:null,confirming:S,play:j,start:A,cancelConfirm:()=>C(!1),pause:()=>E.pause(),resume:()=>E.resume(),stop:()=>E.stop(),next:()=>E.next(),previous:()=>E.previous(),jumpTo:e=>E.jumpTo(e),pickedCount:t.length}}function mB({b:e,picked:t,enabled:n,generateAll:r,onGenerated:i}){let{api:a}=K(),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=fB(t),d=u.filter(e=>!e.about).length,f=u.length-d,p=r?.running===!0,m=async()=>{if(a.generateChatAbouts){s(!0),l(null);try{i((await a.generateChatAbouts({sessionIds:u.map(e=>e.sessionId)})).generateAll)}catch(e){l(uB(e))}finally{s(!1)}}},h=e.busy;return(0,G.jsxs)(`section`,{className:`space-y-2 rounded-md border border-border px-3 py-2`,"data-testid":`briefing-panel`,"aria-label":`Listen to the picked chats`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Listen to the picked chats`}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick chats below, then Play: each chat’s name, then its about, one after another. Another language is translated once by `,ku.label,` on your OonaCode credits and kept, so playing it again costs nothing.`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[(0,G.jsx)(zy,{label:`Language`,children:(0,G.jsx)(`select`,{"aria-label":`Language`,className:By,value:e.lang.code,disabled:h,onChange:t=>e.update({language:t.target.value}),"data-testid":`briefing-language`,children:Du.map(e=>(0,G.jsx)(`option`,{value:e.code,children:e.name===e.native?e.name:`${e.name} — ${e.native}`},e.code))})}),e.voicesLoading?(0,G.jsx)(`p`,{className:`px-1 py-2 text-xs text-fg-muted`,"data-testid":`briefing-voices-loading`,children:`Looking for this PC’s voices…`}):e.options.length>0?(0,G.jsx)(zy,{label:`Voice`,children:(0,G.jsx)(`select`,{"aria-label":`Voice`,className:By,value:e.voice?.key??``,disabled:h,onChange:t=>e.update({localVoice:{...e.prefs.localVoice,[e.lang.code]:t.target.value}}),"data-testid":`briefing-voice`,children:e.options.map(e=>(0,G.jsx)(`option`,{value:e.key,children:e.label},e.key))})}):(0,G.jsx)(`p`,{className:`rounded-md border border-border bg-surface-2 px-2 py-1.5 text-xs text-fg-muted sm:col-span-2`,"data-testid":`briefing-no-voice`,children:kz(e.lang,e.desktop,e.platform,e.espeakMissing)}),(0,G.jsx)(zy,{label:`Speed ×${e.prefs.speed.toFixed(2)}`,children:(0,G.jsx)(`input`,{"aria-label":`Speed`,type:`range`,min:ju.speed.min,max:ju.speed.max,step:.05,value:e.prefs.speed,disabled:h,onChange:t=>e.update({speed:Number(t.target.value)})})})]}),e.plan&&t.length>0?(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`briefing-cost`,children:[Eu(e.plan,e.lang.name),e.plan.needed>0?` — paid once, then kept.`:``]}):null,e.confirming&&e.plan?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-warn/50 bg-warn-soft px-2 py-1.5 text-xs text-fg`,role:`alert`,"data-testid":`briefing-confirm`,children:[(0,G.jsxs)(`p`,{className:`basis-full`,children:[`Before playing: `,Eu(e.plan,e.lang.name),` — paid once from your OonaCode credits, then kept.`]}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:e.start,"data-testid":`briefing-confirm-play`,children:`Translate and play`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:e.cancelConfirm,children:`Cancel`})]}):null,u.length>0&&a.generateChatAbouts?(0,G.jsxs)(`div`,{className:`space-y-1.5 text-xs`,"data-testid":`briefing-need-about`,children:[(0,G.jsx)(`p`,{className:`text-fg-muted`,children:Xz(d,f)}),(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void m(),busy:o,disabled:!n||p||e.busy,title:n?void 0:`Chat abouts are off — turn them on above.`,"data-testid":`briefing-write-first`,children:[(0,G.jsx)(J.Refresh,{className:`h-3 w-3`}),` Write abouts for these first`]})]}):null,c?(0,G.jsx)(`p`,{className:`text-xs text-danger`,"data-testid":`briefing-write-error`,children:c}):null]})}function hB({b:e}){let t=e.state,n=t.index>=0?` (${t.index+1} of ${t.total})`:``,r=null;return t.status===`preparing`?r=`Now: ${t.title??``}${n} — ${e.lang.code===`en`?`getting ready…`:`translating…`}`:t.status===`speaking`?r=`Now: ${t.title??``}${n}`:t.status===`paused`?r=`Paused: ${t.title??``}${n}`:t.status===`done`?r=`Finished — ${t.total} chat${t.total===1?``:`s`} read.`:t.status===`stopped`?r=`Stopped.`:t.status===`error`&&(r=t.error),(0,G.jsxs)(G.Fragment,{children:[r?(0,G.jsx)(`p`,{className:W(`mr-auto min-w-0 basis-full truncate text-xs sm:basis-auto sm:flex-1`,t.status===`error`?`text-danger`:`text-fg-muted`),title:r,"aria-live":`polite`,"data-testid":`briefing-now`,children:r}):null,e.active||t.status===`error`?(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,onClick:e.previous,disabled:t.status===`error`,"aria-label":`Previous chat`,title:`Previous chat`,"data-testid":`briefing-previous`,children:(0,G.jsx)(J.SkipBack,{className:`h-3.5 w-3.5`})}),t.status===`paused`||t.status===`error`?(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:e.resume,"data-testid":`briefing-resume`,children:[(0,G.jsx)(J.Play,{className:`h-3.5 w-3.5`}),` `,t.status===`error`?`Try again`:`Resume`]}):(0,G.jsxs)(Y,{size:`sm`,onClick:e.pause,"data-testid":`briefing-pause`,children:[(0,G.jsx)(J.Pause,{className:`h-3.5 w-3.5`}),` Pause`]}),(0,G.jsxs)(Y,{size:`sm`,onClick:e.stop,"data-testid":`briefing-stop`,children:[(0,G.jsx)(J.Stop,{className:`h-3.5 w-3.5`}),` Stop`]}),(0,G.jsx)(Y,{size:`sm`,onClick:e.next,disabled:t.status===`error`,"aria-label":`Next chat`,title:`Next chat`,"data-testid":`briefing-next`,children:(0,G.jsx)(J.SkipForward,{className:`h-3.5 w-3.5`})})]}):(0,G.jsxs)(Y,{variant:`primary`,onClick:e.play,disabled:e.pickedCount===0||e.voice===null||e.voicesLoading,title:e.pickedCount===0?`Tick the chats to hear first`:void 0,"data-testid":`briefing-play`,children:[(0,G.jsx)(J.Play,{className:`h-4 w-4`}),` Play `,e.pickedCount,` picked`]})]})}function gB({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.chatAboutsChange,[a,o]=(0,v.useState)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(!1),S=(0,v.useRef)(-1),[C,w]=(0,v.useState)(()=>Gz()),[T,E]=(0,v.useState)(()=>new Set),[D,O]=(0,v.useState)(()=>Date.now()),k=(0,v.useCallback)(async()=>{let e=await r.listChatAbouts();if(e===`unsupported`){c(!0);return}if(e===null){u(!0);return}c(!1),u(!1),o(e),f(e.generateAll)},[r]);(0,v.useEffect)(()=>{e&&(S.current=i.seq,O(Date.now()),k())},[e]);let A=e=>{w(t=>{let n={...t,...e};return Kz(n),n}),O(Date.now())};(0,v.useEffect)(()=>{!e||i.seq===S.current||(S.current=i.seq,i.generateAll!==void 0&&f(i.generateAll),k())},[e,i,k]);let j=n.settings?.chatAboutEnabled??a?.settings.enabled??Ul.enabled,M=async e=>{x(!0);try{await r.saveSettings({chatAboutEnabled:e})}finally{x(!1)}k()},N=async()=>{g(!0);try{let e=await r.generateAllChatAbouts();e&&f(e.generateAll)}finally{g(!1)}},ee=async()=>{y(!0);try{let e=await r.stopGenerateAllChatAbouts();e&&f(e.generateAll)}finally{y(!1)}},te=(0,v.useMemo)(()=>xu(C.range,D,{from:C.from,to:C.to}),[C,D]),P=(0,v.useMemo)(()=>{let e=(a?.chats??[]).filter(e=>Su(e.updatedAt,te)),t=e=>{let t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0};return[...e].sort((e,n)=>t(n)-t(e))},[a,te]),F=(0,v.useMemo)(()=>{let e=p.trim().toLowerCase();return e?P.filter(t=>t.title.toLowerCase().includes(e)||(t.about??``).toLowerCase().includes(e)):P},[P,p]),ne=(0,v.useMemo)(()=>F.map(e=>e.sessionId),[F]),re=ne.join(`,`);(0,v.useEffect)(()=>{E(e=>Yz(e,ne))},[re]);let ie=(0,v.useMemo)(()=>F.filter(e=>T.has(e.sessionId)),[F,T]),I=qz(ne,T),L=(0,v.useRef)(null);(0,v.useEffect)(()=>{L.current&&(L.current.indeterminate=I===`some`)});let R=pB({open:e,picked:ie}),ae=R.active||R.state.status===`error`,oe=(0,v.useMemo)(()=>new Set(R.state.playlist),[R.state.playlist]),se=ae?R.state.sessionId:null,ce=e=>E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),le=vu.find(e=>e.id===C.range)?.label??``,ue=(0,v.useCallback)(e=>n.sessions.find(t=>t.id===e)?.entryCount??null,[n.sessions]),de=a?du(a.totals):null,fe=d?.running===!0;return(0,G.jsxs)(Vy,{open:e,title:`What your chats are about`,onClose:t,wide:!0,footer:(0,G.jsxs)(G.Fragment,{children:[a!==null&&!s?(0,G.jsx)(hB,{b:R}):null,(0,G.jsx)(Y,{variant:`ghost`,onClick:t,children:`Close`})]}),children:[(0,G.jsxs)(`p`,{className:`mb-3 flex items-center gap-1.5 text-xs text-fg-muted`,children:[(0,G.jsx)(`span`,{className:`min-w-0`,children:`A short note per chat on this PC saying what it works on, so your other chats can tell which one to ask.`}),(0,G.jsx)(Ly,{label:`What your chats are about`,details:(0,G.jsx)(Ry,{items:[...gu.what,...gu.when,...gu.who,...gu.yours,...gu.where]})})]}),s?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-unsupported`,children:`OonaCode on this PC is too old for chat abouts. Update it, then open this window again.`}):a===null?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-loading`,children:l?`Could not read the abouts from this PC right now. They show here as soon as it answers.`:`Loading…`}):(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`div`,{className:`rounded-md border border-border px-3`,children:(0,G.jsx)(Hy,{label:`Write an about for every chat`,hint:j?`On: each chat’s housekeeper model writes its about in the background.`:`Off: nothing is written and nothing is spent. Regenerate and “Generate for all chats now” are unavailable.`,details:[gu.switch,...gu.who],checked:j,disabled:b,onChange:e=>void M(e),testId:`chat-abouts-switch`})}),de?(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,"data-testid":`chat-abouts-totals`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:`All about calls so far: `}),(0,G.jsx)(`span`,{"data-testid":`chat-abouts-totals-line`,children:de.line}),de.unpriced?(0,G.jsx)(`span`,{className:`block text-fg-faint`,"data-testid":`chat-abouts-totals-unpriced`,children:de.unpriced}):null]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:()=>void N(),busy:h,disabled:!j||fe,title:j?gu.generateAll:gu.regenerateOff,"data-testid":`chat-abouts-generate-all`,children:[(0,G.jsx)(J.Refresh,{className:`h-3 w-3`}),` Generate for all chats now`]}),(0,G.jsx)(Ly,{label:`Generate for all chats now`,details:gu.generateAll})]}),fe?(0,G.jsxs)(Y,{size:`sm`,variant:`danger`,onClick:()=>void ee(),busy:_,title:gu.stop,"data-testid":`chat-abouts-stop`,children:[(0,G.jsx)(J.Stop,{className:`h-3 w-3`}),` Stop`]}):null]}),d?(0,G.jsx)(_B,{g:d}):null,(0,G.jsx)(mB,{b:R,picked:ie,enabled:j,generateAll:d,onGenerated:f}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`Last active`,(0,G.jsx)(`select`,{"aria-label":`Last active`,className:W(By,`text-xs`),value:C.range,onChange:e=>A({range:e.target.value}),"data-testid":`chat-abouts-range`,children:vu.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),C.range===`custom`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`From`,(0,G.jsx)(`input`,{type:`date`,"aria-label":`From`,className:W(Z,`text-xs`),value:C.from,onChange:e=>A({from:e.target.value}),"data-testid":`chat-abouts-from`})]}),(0,G.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1 text-xs font-medium text-fg`,children:[`To`,(0,G.jsx)(`input`,{type:`date`,"aria-label":`To`,className:W(Z,`text-xs`),value:C.to,onChange:e=>A({to:e.target.value}),"data-testid":`chat-abouts-to`})]})]}):null,(0,G.jsx)(`input`,{className:W(Z,`min-w-[10rem] flex-1 basis-40 text-xs`),type:`search`,value:p,onChange:e=>m(e.target.value),placeholder:`Find a chat by its title or its about`,"aria-label":`Find a chat by its title or its about`,"data-testid":`chat-abouts-filter`})]}),F.length>0?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,G.jsxs)(`label`,{className:`inline-flex items-center gap-2 font-medium text-fg`,children:[(0,G.jsx)(`input`,{ref:L,type:`checkbox`,checked:I===`all`,"aria-checked":I===`some`?`mixed`:I===`all`,onChange:()=>E(e=>Jz(ne,e)),"data-testid":`chat-abouts-select-all`}),`Select all`]}),(0,G.jsxs)(`span`,{className:`text-fg-muted`,"data-testid":`chat-abouts-count`,children:[F.length,` chat`,F.length===1?``:`s`,ie.length>0?` · ${ie.length} picked`:``]})]}):null,a.chats.length===0?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-empty`,children:`No chats on this PC yet.`}):F.length===0?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,"data-testid":`chat-abouts-no-match`,children:p.trim()?`No chat matches “${p.trim()}”${C.range===`all`?``:` in ${le.toLowerCase()}`}.`:`No chat was active in ${C.range===`custom`?`that range`:le.toLowerCase()}.`}):(0,G.jsx)(`ul`,{className:`space-y-2`,"data-testid":`chat-abouts-list`,children:F.map(e=>(0,G.jsx)(vB,{row:e,enabled:j,entryCount:ue(e.sessionId),checked:T.has(e.sessionId),onToggle:()=>ce(e.sessionId),playing:se===e.sessionId,onJump:ae&&oe.has(e.sessionId)?()=>R.jumpTo(e.sessionId):null,onOpen:()=>{r.selectSession(e.sessionId)}},e.sessionId))})]})]})}function _B({g:e}){let t=e.total>0?Math.round(Math.min(e.done,e.total)/e.total*100):100;return(0,G.jsxs)(`div`,{className:`space-y-1 text-xs`,"data-testid":`chat-abouts-progress`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,"data-testid":`chat-abouts-progress-line`,children:pu(e)}),(0,G.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Generate for all chats now`,"aria-valuemin":0,"aria-valuemax":e.total,"aria-valuenow":e.done,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,e.running?`bg-accent`:`bg-fg-faint`),style:{width:`${t}%`}})}),!e.running&&e.stoppedReason?(0,G.jsxs)(`div`,{className:`text-warn`,"data-testid":`chat-abouts-stopped-reason`,children:[`Stopped: `,e.stoppedReason]}):null]})}function vB({row:e,enabled:t,entryCount:n,checked:r,onToggle:i,playing:a,onJump:o,onOpen:s}){let c=e.title.trim()||`Untitled chat`,l=ou(e),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{a&&u.current?.scrollIntoView?.({block:`nearest`})},[a]),(0,G.jsxs)(`li`,{ref:u,className:W(`rounded-md border px-3 py-2 text-xs`,a?`border-accent bg-accent/10`:`border-border`,o?`cursor-pointer hover:border-accent`:``),onClick:o??void 0,title:o&&!a?`Play from this chat`:void 0,"aria-current":a?`true`:void 0,"data-testid":`chat-about-row-${e.sessionId}`,"data-playing":a?`true`:void 0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`shrink-0`,checked:r,onChange:i,onClick:e=>e.stopPropagation(),"aria-label":`Pick ${c}`,"data-testid":`chat-about-pick`}),a?(0,G.jsx)(J.Speaker,{className:`h-3.5 w-3.5 text-accent`,title:`Playing`}):null,(0,G.jsx)(`button`,{type:`button`,className:`min-w-0 max-w-full truncate text-left text-sm font-medium text-fg hover:text-accent hover:underline`,onClick:e=>{e.stopPropagation(),s()},title:`Open this chat`,"data-testid":`chat-about-open`,children:c}),e.source===`user`?(0,G.jsx)(`span`,{title:gu.yours[0],children:(0,G.jsx)(Q,{tone:`accent`,children:`yours`})}):null,e.stale&&e.about?(0,G.jsx)(`span`,{title:gu.stale,"data-testid":`chat-about-stale`,children:(0,G.jsx)(Q,{tone:`warn`,children:`stale`})}):null,e.pending?(0,G.jsx)(`span`,{"data-testid":`chat-about-pending`,children:(0,G.jsx)(Q,{tone:`accent`,children:`writing…`})}):null]}),e.about?(0,G.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-fg`,"data-testid":`chat-about-text`,children:e.about}):null,e.about&&e.stale?(0,G.jsx)(`p`,{className:`mt-0.5 text-warn`,"data-testid":`chat-about-stale-note`,children:`The chat has moved on since this about was written.`}):null,e.about?null:(0,G.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`chat-about-missing`,children:[`No about yet. `,fu(e,{enabled:t,entryCount:n})]}),e.about&&e.lastError?(0,G.jsxs)(`p`,{className:`mt-0.5 text-danger`,"data-testid":`chat-about-error`,children:[`The last attempt failed: `,e.lastError]}):null,(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap justify-between gap-x-3 gap-y-0.5 text-[11px] text-fg-faint`,children:[(0,G.jsxs)(`span`,{title:ng(e.updatedAt),"data-testid":`chat-about-active`,children:[`Active `,eg(e.updatedAt)]}),e.about&&e.aboutAt?(0,G.jsxs)(`span`,{title:ng(e.aboutAt),"data-testid":`chat-about-written`,children:[`Written `,eg(e.aboutAt),l?` by ${l}`:``]}):(0,G.jsx)(`span`,{}),(0,G.jsx)(`span`,{title:e.route?`Paid by ${su[e.route]}`:void 0,"data-testid":`chat-about-spend`,children:uu(e.spend,e.route)})]})]})}function yB({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.assignProjectSessionId,a=i?n.sessions.find(e=>e.id===i)??null:null,o=i?n.drafts[i]??null:null,s=a?.projectId??o?.projectId??null,[c,l]=(0,v.useState)(s),[u,d]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&l(s)},[e,s]);let f=a?.status===`running`||a?.status===`waiting_permission`,p=sg(a?cg(a):o?.title??`New chat`);async function m(){if(i){d(!0);try{await r.setSessionProject(i,c)&&t()}finally{d(!1)}}}return(0,G.jsxs)(Vy,{open:e,title:`Move “${p}” to a project`,onClose:t,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{variant:`ghost`,onClick:()=>{t(),r.openDialog(`projects`)},children:`Manage projects…`}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(Y,{variant:`ghost`,onClick:t,children:`Cancel`}),(0,G.jsx)(Y,{variant:`primary`,onClick:m,disabled:u||c===s,"data-testid":`assign-project-apply`,children:`Apply`})]}),children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5`,role:`radiogroup`,"aria-label":`Project`,children:[(0,G.jsx)(bB,{selected:c===null,onSelect:()=>l(null),label:`No project`,testId:`assign-project-none`}),n.vaultProjects.map(e=>(0,G.jsx)(bB,{selected:c===e.id,onSelect:()=>l(e.id),label:e.name,hint:e.instructions.trim()?`has instructions`:void 0,testId:`assign-project-${e.id}`},e.id)),n.vaultProjects.length===0?(0,G.jsxs)(`p`,{className:`px-2 py-2 text-xs text-fg-muted`,children:[`No projects yet — create one under `,(0,G.jsx)(`em`,{children:`Manage projects…`}),`.`]}):null]}),f?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,"data-testid":`assign-project-busy`,children:`This chat is mid-turn — it moves now and the turn is left alone. The project's instructions reach the agent at your next message.`}):(0,G.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:`The project's instructions reach the agent on the chat's next start — nothing in the conversation is lost.`})]})}function bB({selected:e,onSelect:t,label:n,hint:r,disabled:i=!1,testId:a}){return(0,G.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e,onClick:t,disabled:i,className:W(`flex items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,e?`bg-accent-soft text-fg`:`hover:bg-surface-2 text-fg`,i&&`cursor-not-allowed opacity-50`),"data-testid":a,children:[(0,G.jsx)(`span`,{className:W(`inline-block h-3 w-3 rounded-full border`,e?`border-accent bg-accent`:`border-border`)}),(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),r?(0,G.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:r}):null]})}var xB=`Install Google’s agy`,SB=`OonaCode downloads Google’s own agy release (about 200 MB) and checks its checksum before it uses it. Nothing from Google is bundled inside OonaCode.`,CB=`Sign in with Google`,wB=`This PC’s OonaCode is too old to run chats on Google’s agy — update it from the title bar.`,TB=`Kept on this PC only, in memory: it is gone when OonaCode stops, and it is never synced or sent anywhere.`,EB=new Set([`loadCodeAssist`,`fetchAdminControls`,`retrieveUserQuotaSummary`,`fetchUserInfo`,`fetchAvailableModels`,`listExperiments`,`writeTrajectoryAcls`,`recordTrajectoryAnalytics`]);function DB(e){return e.kind===`tunnel`||e.method!==null&&EB.has(e.method)}function OB(e){let t=[],n=[];for(let r of e)(DB(r)?n:t).push(r);return{main:t,background:n}}function kB(e){if(e.kind===`tunnel`)return{title:e.host??`tunnel`,detail:null};let t=[e.model,e.requestType===`checkpoint`?`checkpoint`:null].filter(e=>!!e).join(` · `);return{title:e.method??`Code Assist call`,detail:t||null}}function AB(e){let{title:t,detail:n}=kB(e);return n?`${t} · ${n}`:t}function jB(e){let t=e.denied||e.error!==null||e.status!==null&&e.status>=400?`danger`:`neutral`;return e.denied?{text:`denied`,tone:t}:e.status===null?e.error===null?{text:`pending`,tone:t}:{text:`error`,tone:t}:{text:String(e.status),tone:t}}var MB=e=>e.toLocaleString(`en-US`);function NB(e){if(!e)return null;let t=e.cached>0?` (${MB(e.cached)} cached)`:``;return`in ${MB(e.input)}${t} · out ${MB(e.output)}`}function PB(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}):``}function FB(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function IB(e){switch(e){case`ready`:return{label:`Ready`,tone:`ok`};case`not_installed`:return{label:`agy is not installed`,tone:`warn`};case`not_signed_in`:return{label:`Not signed in to agy`,tone:`warn`};default:return{label:`agy did not answer`,tone:`danger`}}}function LB(e){return e.newerThanTested?`This agy is newer than the version OonaCode was tested with (${e.testedVersion}). It usually keeps working; if chats on it start failing, look for an OonaCode update.`:null}function RB(e){let t=e.remainingPercent,n=t!==null&&Number.isFinite(t),r=ng(e.resetsAt);return{remaining:n?`${Math.round(Math.min(100,Math.max(0,t)))}% left`:`unknown`,tone:ic(t),resets:r?`resets ${r}`:null}}var zB=1e3,BB=2e3;function VB(e){if(!e)return null;if(e.install.state===`working`)return zB;switch(e.login.phase){case`starting`:case`verifying`:return zB;case`awaiting_code`:return BB;default:return null}}function HB(e){if(!e)return!1;if(e.install.state===`working`)return!0;let t=e.login.phase;return t===`starting`||t===`awaiting_code`||t===`verifying`}function UB(e){switch(e){case`manifest`:return`Looking up Google’s latest release…`;case`download`:return`Downloading agy…`;case`verify`:return`Checking the download…`;case`place`:return`Finishing up…`;default:return`Starting the install…`}}function WB(e){let{received:t,total:n}=e;return n===null||!Number.isFinite(n)||n<=0?null:Math.min(100,Math.max(0,Math.floor(t/n*100)))}function GB(e){let{received:t,total:n}=e;return n!==null&&n>0?`${Pj(t)} of ${Pj(n)}`:t>0?Pj(t):null}function KB(e){if(!e)return null;try{return new URL(e).protocol===`https:`?e:null}catch{return null}}function qB(e,t){return t?e.split(t).join(`…`):e}function JB(e,t){return e?`Status…`:t?t.state===`not_installed`?t.install.supported?`Install…`:`Status…`:t.state===`not_signed_in`?`Sign in…`:`Status…`:`Set up…`}var YB=15,XB=2e4,ZB=5e3,QB=null;function $B(e){let[t,n]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function eV({install:e,busy:t,onInstall:n,onCancel:r}){if(e.state===`working`){let n=WB(e),i=GB(e);return(0,G.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`agy-install`,"data-install-state":`working`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg`,role:`status`,"data-testid":`agy-install-phase`,"data-phase":e.phase??void 0,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),(0,G.jsxs)(`span`,{className:`min-w-0`,children:[UB(e.phase),e.version?` (agy ${e.version})`:``]})]}),(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`Installing agy`,"aria-valuemin":0,"aria-valuemax":100,...n===null?{}:{"aria-valuenow":n},"data-indeterminate":n===null?`true`:void 0,"data-testid":`agy-install-bar`,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full bg-accent`,n===null?`w-1/3 animate-pulse`:void 0),style:n===null?void 0:{width:`${n}%`}})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-install-bytes`,children:i??``}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:t,onClick:r,"data-testid":`agy-install-cancel`,children:`Cancel`})]})]})}return e.supported?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-install`,"data-install-state":e.state,children:[e.state===`failed`?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-install-failed`,children:e.error??`The install did not finish.`}):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-install-explanation`,children:SB}),(0,G.jsxs)(Y,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":e.state===`failed`?`agy-install-retry`:`agy-install-button`,children:[(0,G.jsx)(J.Download,{className:`h-4 w-4`}),` `,e.state===`failed`?`Try again`:xB]})]}):null}function tV({login:e,busy:t,onStart:n,onRestart:r,onCancel:i,onSubmit:a}){let[o,s]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null);(0,v.useEffect)(()=>()=>{u.current&&clearTimeout(u.current)},[]),(0,v.useEffect)(()=>{e.phase!==`awaiting_code`&&s(``)},[e.phase]);let d=(0,v.useRef)(null),f=e.phase===`awaiting_code`,p=f?KB(e.url):null,m=f&&e.expiresAt?Date.parse(e.expiresAt):NaN,h=Number.isFinite(m),g=$B(f&&h),_=h?Math.max(0,Math.ceil((m-g)/1e3)):null,y=_===0;(0,v.useEffect)(()=>{y&&s(``)},[y]);let b=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(e.phase===`starting`&&(b.current=!0),!f||!p||!e.startedAt||QB===e.startedAt)return;let t=h?Date.now()-(m-6e4):1/0;if(!(!b.current&&t>ZB)){QB=e.startedAt;try{TR(p)}catch{}}},[e.phase,p,e.startedAt]),(0,v.useEffect)(()=>{f&&NP(d.current)},[f]);let[x,S]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(e.phase!==`verifying`){S(!1);return}let t=setTimeout(()=>S(!0),XB);return()=>clearTimeout(t)},[e.phase]);let C=o.trim(),w=tm(C),T=()=>{!w||t||(s(``),a(C))},E=()=>{p&&KM(p).then(e=>{e&&(l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500))})},D=(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,disabled:t,onClick:i,"data-testid":`agy-login-cancel`,children:`Cancel`});return(0,G.jsxs)(`div`,{ref:d,className:`space-y-2`,"data-testid":`agy-sign-in`,"data-login-phase":e.phase,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`agy-sign-in-explanation`,children:em}),e.phase===`starting`?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-starting`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Starting Google’s sign-in…`]}),(0,G.jsx)(`span`,{className:`flex-1`}),D]}):e.phase===`awaiting_code`?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-awaiting`,children:[y?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-expired`,children:[(0,G.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,role:`alert`,children:`Time ran out — Google’s agy only waits a minute. Press Sign in again.`}),(0,G.jsxs)(Y,{variant:`primary`,busy:t,disabled:t,onClick:r,"data-testid":`agy-login-expired-restart`,children:[(0,G.jsx)(J.LogIn,{className:`h-4 w-4`}),` Sign in again`]})]}):(0,G.jsxs)(G.Fragment,{children:[e.message?(0,G.jsx)(`p`,{className:`text-xs text-fg`,children:e.message}):null,p?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-xs font-medium text-accent underline`,href:p,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),TR(p)},"data-testid":`agy-login-link`,children:[(0,G.jsx)(J.ExternalLink,{className:`h-3.5 w-3.5`}),` Open Google’s sign-in page`]}),(0,G.jsxs)(Y,{size:`sm`,onClick:E,"data-testid":`agy-login-copy-link`,children:[(0,G.jsx)(J.Copy,{className:`h-3.5 w-3.5`}),` `,c?`Copied`:`Copy link`]})]}):null,(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs font-medium text-fg`,children:[(0,G.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2`,children:[`Code from Google`,_===null?null:(0,G.jsxs)(`span`,{role:`timer`,className:W(`font-normal tabular-nums`,_<YB?`font-medium text-warn`:`text-fg-faint`),"data-tone":_<YB?`warn`:`neutral`,"data-testid":`agy-login-countdown`,children:[_,` s left to finish`]})]}),(0,G.jsx)(`input`,{className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 font-mono text-xs text-fg placeholder:text-fg-faint focus:border-accent focus:outline-none`,type:`text`,value:o,placeholder:`Paste the code Google shows you`,autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"data-1p-ignore":`true`,"data-lpignore":`true`,"data-form-type":`other`,"data-autofocus":!0,onChange:e=>s(e.target.value),onPaste:e=>{let n=e.clipboardData?.getData(`text`).trim()??``;tm(n)&&(e.preventDefault(),!t&&(s(``),a(n)))},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())},"data-testid":`agy-login-code`})]}),C&&!w?(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-login-code-hint`,children:`Paste the code exactly as Google shows it — one line, no spaces.`}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Y,{variant:`primary`,size:`sm`,disabled:!w||t,onClick:T,"data-testid":`agy-login-continue`,children:`Continue`}),D]})]}),y?(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:D}):null]}):e.phase===`verifying`?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`agy-login-verifying`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-fg`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5 shrink-0`}),e.message??`Checking the code with Google…`]}),(0,G.jsx)(`span`,{className:`flex-1`}),D,x?(0,G.jsx)(`p`,{className:`w-full text-[11px] text-fg-faint`,"data-testid":`agy-login-verifying-slow`,children:`Still waiting for Google…`}):null]}):e.phase===`failed`?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`agy-login-failed`,children:[(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,children:e.message??`The sign-in did not finish.`}),(0,G.jsxs)(Y,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-restart`,children:[(0,G.jsx)(J.LogIn,{className:`h-4 w-4`}),` Start again`]})]}):(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[e.phase===`done`&&e.message?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.message}):null,(0,G.jsxs)(Y,{variant:`primary`,busy:t,disabled:t,onClick:n,"data-testid":`agy-sign-in-button`,children:[(0,G.jsx)(J.LogIn,{className:`h-4 w-4`}),` `,CB]})]})]})}var nV={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,neutral:`bg-surface-3`},rV={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,neutral:`text-fg-muted`};function iV({label:e,testid:t,children:n}){return(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 py-0.5 text-xs`,children:[(0,G.jsx)(`dt`,{className:`shrink-0 text-fg-faint`,children:e}),(0,G.jsx)(`dd`,{className:`min-w-0 text-right font-medium text-fg`,"data-testid":t,children:n})]})}function aV({definition:e}){let{api:t,socket:n}=K(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(0),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(!0),g=(0,v.useRef)(0),_=(0,v.useRef)(0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let y=(0,v.useCallback)(async(e,n=!1)=>{let r=++g.current;if(!t.getAgyStatus){o(!0);return}_.current+=1,n||u(e=>e+1);try{let n=await t.getAgyStatus(e?{refresh:!0}:void 0);if(!h.current||r!==g.current)return;i(n),c(null),o(!1)}catch(e){if(!h.current||r!==g.current)return;gm(e)?o(!0):c(lg(e))}finally{--_.current,!n&&h.current&&u(e=>e-1)}},[t]),b=(0,v.useCallback)(async(e,t,n=``)=>{g.current+=1,f(e),m(null);try{let e=await t();if(!h.current)return;g.current+=1,i(e),c(null),o(!1)}catch(e){if(!h.current)return;gm(e)?o(!0):(m(qB(lg(e),n)),y(!1,!0))}finally{h.current&&f(null)}},[y]);(0,v.useEffect)(()=>{y(!1)},[y]);let x=VB(r);(0,v.useEffect)(()=>{if(x===null)return;let e=setInterval(()=>{_.current===0&&y(!1,!0)},x);return()=>clearInterval(e)},[x,y]),(0,v.useEffect)(()=>n.on(`account_changed`,e=>{e.reason===`provider`&&y(!1,!0)}),[n,y]);let S=js(e);if(a)return(0,G.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,"data-testid":`agy-unsupported`,children:wB});let C=r===null&&s===null,w=l>0,T=HB(r),E=r?.install.state===`working`,D=(0,G.jsx)(Y,{variant:`primary`,size:`sm`,busy:w||C,disabled:w||C||T,onClick:()=>void y(!0),"data-testid":`agy-check-again`,children:w||C?`Checking…`:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(J.Refresh,{className:`h-3.5 w-3.5`}),` Check again`]})}),O=r?E?{label:`Installing agy…`,tone:`accent`}:IB(r.state):null;return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`agy-card`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsx)(Q,{tone:`ok`,children:S.badge}),(0,G.jsx)(Q,{children:e.kind})]}),(0,G.jsx)(`div`,{className:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`agy-route`,children:S.detail}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[O?(0,G.jsx)(`span`,{"data-testid":`agy-state`,"data-state":r?.state,children:(0,G.jsx)(Q,{tone:O.tone,children:O.label})}):C?(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-fg-muted`,"data-testid":`agy-checking`,children:[(0,G.jsx)(J.Spinner,{className:`h-3.5 w-3.5`}),` Asking agy…`]}):null,(0,G.jsx)(`span`,{className:`flex-1`}),D]}),w&&r?(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`agy-busy-note`,children:`Asking agy again — this takes a few seconds.`}):null,s?(0,G.jsxs)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-failed`,children:[`The host could not check agy: `,s]}):null,r?(0,G.jsxs)(G.Fragment,{children:[r.state!==`ready`&&r.message&&!T?(0,G.jsx)(`p`,{className:`text-xs text-fg`,"data-testid":`agy-message`,children:r.message}):null,r.state===`not_installed`?(0,G.jsx)(eV,{install:r.install,busy:d===`install`||d===`cancel_install`,onInstall:()=>{t.agyInstall?b(`install`,()=>t.agyInstall()):o(!0)},onCancel:()=>{t.cancelAgyInstall&&b(`cancel_install`,()=>t.cancelAgyInstall())}}):null,r.state===`not_signed_in`?(0,G.jsx)(tV,{login:r.login,busy:d===`login`||d===`cancel_login`||d===`code`,onStart:()=>{t.agyLogin?b(`login`,()=>t.agyLogin()):o(!0)},onRestart:()=>{(async()=>{t.cancelAgyLogin&&await b(`cancel_login`,()=>t.cancelAgyLogin()),t.agyLogin?await b(`login`,()=>t.agyLogin()):o(!0)})()},onCancel:()=>{t.cancelAgyLogin&&b(`cancel_login`,()=>t.cancelAgyLogin())},onSubmit:e=>{t.submitAgyLoginCode?b(`code`,()=>t.submitAgyLoginCode(e),e):o(!0)}}):null,p?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,role:`alert`,"data-testid":`agy-action-error`,children:p}):null,(0,G.jsxs)(`dl`,{className:`rounded-md border border-border px-3 py-1.5`,"data-testid":`agy-facts`,children:[(0,G.jsx)(iV,{label:`Installed`,testid:`agy-installed`,children:r.installed?`Yes`:`No`}),r.path?(0,G.jsx)(iV,{label:`Path`,testid:`agy-path`,children:(0,G.jsx)(`span`,{className:`break-all font-mono text-[11px]`,children:r.path})}):null,r.version?(0,G.jsx)(iV,{label:`Version`,testid:`agy-version`,children:r.version}):null,(0,G.jsx)(iV,{label:`Signed in`,testid:`agy-signed-in`,children:r.signedIn===null?r.installed?`Unknown`:`—`:r.signedIn?`Yes`:`No`}),(0,G.jsx)(iV,{label:`Checked`,testid:`agy-checked`,children:(0,G.jsx)(`span`,{title:ng(r.checkedAt),children:eg(r.checkedAt)})})]}),LB(r)?(0,G.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,"data-testid":`agy-newer-note`,children:[(0,G.jsx)(J.Info,{className:`mt-px h-3.5 w-3.5 shrink-0`}),LB(r)]}):null,r.models.length>0?(0,G.jsxs)(`div`,{"data-testid":`agy-models`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Models agy offers`}),(0,G.jsx)(`ul`,{className:`space-y-0.5`,children:r.models.map(e=>(0,G.jsxs)(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,"data-testid":`agy-model-${e.id}`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.displayName}),(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-fg-faint`,children:e.id})]},e.id))})]}):null,r.usage.length>0?(0,G.jsxs)(`div`,{"data-testid":`agy-usage`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-muted`,children:`Your plan’s usage`}),(0,G.jsx)(`ul`,{className:`space-y-2`,children:r.usage.map((e,t)=>{let n=RB(e),r=e.remainingPercent;return(0,G.jsxs)(`li`,{"data-testid":`agy-usage-row-${t}`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 truncate text-fg`,children:[e.group,` · `,e.window]}),(0,G.jsx)(`span`,{className:W(`shrink-0 font-medium`,rV[n.tone]),"data-tone":n.tone,"data-testid":`agy-usage-remaining-${t}`,children:n.remaining})]}),(0,G.jsx)(`div`,{className:`mt-0.5 h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-label":`${e.group} ${e.window}: ${n.remaining}`,"aria-valuemin":0,"aria-valuemax":100,...r!==null&&Number.isFinite(r)?{"aria-valuenow":Math.round(r)}:{},children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,nV[n.tone]),style:{width:`${r!==null&&Number.isFinite(r)?Math.min(100,Math.max(0,r)):0}%`}})}),n.resets?(0,G.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:n.resets}):null]},`${e.group}-${e.window}-${t}`)})})]}):null]}):null]})}function oV(e,t){let n=e.definition.displayName;return!t||t.id===`payg`||t.id===`api-key`?[`Sign in to the ${n} console.`,`Create an API key (or copy an existing one).`,`Paste it below — OonaCode encrypts it into your vault before it leaves this PC.`]:[`Open the ${n} console and pick the ${t.label} plan.`,t.notes??`Complete the provider’s subscription/token flow in the browser.`,`Copy the token it issues${t.keyFormat?` (looks like ${t.keyFormat})`:``} and paste it below.`]}function sV(e,t){let n=e.find(e=>e.definition.id===t);if(!n)return[];let r=n.definition.clientGroup??n.definition.id,i=e.find(e=>e.definition.id===r);return i?[i,...e.filter(e=>e.definition.clientGroup===r)]:[n]}function cV(e){let t=[];for(let n of e){let e=n.definition,r=Es(e),i=e.credentialClass===`subscription`;if(r.length>1)for(let i of r)t.push({key:`${e.id}:${i.id}`,label:i.id===`token-plan`?`Subscription`:i.id===`payg`?`API`:i.label,provider:n,variantId:i.id,variant:i,isSubscription:!1,hasLoginFlow:!1,loginKind:null,keyFormat:i.keyFormat??e.keyFormat});else t.push({key:e.id,label:e.recordLabel??(i?`Subscription`:`API`),provider:n,variantId:r[0]?.id??null,variant:r[0]??null,isSubscription:i,hasLoginFlow:i&&e.route===`direct`,loginKind:i&&e.route===`direct`?e.subscriptionLogin?`oauth`:`claude`:null,keyFormat:r[0]?.keyFormat??e.keyFormat})}return t}function lV(e){let t=(e.provider.credentials??[]).filter(e=>e.class!==`none`);return(e.variantId?t.filter(t=>(t.variantId??`payg`)===e.variantId):t).slice(0,1)}function uV({open:e,providerId:t,onClose:n}){let{state:r,actions:i}=K(),a=(0,v.useMemo)(()=>t?sV(r.providers,t):[],[r.providers,t]),o=(0,v.useMemo)(()=>cV(a),[a]),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),b=o.find(e=>e.key===s)??o[0]??null;if((0,v.useEffect)(()=>{if(!e)return;let n=o.find(e=>e.provider.definition.id===t);c((n??o[0])?.key??``),u(``),m(``),y(null)},[e,t,o]),(0,v.useEffect)(()=>{if(!e||!b)return;let t=b.provider.definition;f(t.userBaseUrl?b.variant?.baseUrl??t.baseUrl:``)},[e,b,b?.key]),!b)return null;let x=b.provider.definition,S=a[0]?.definition?.displayName??x.displayName;if(x.engine===`agy`)return(0,G.jsx)(Vy,{open:e,title:S,onClose:n,footer:(0,G.jsx)(Y,{onClick:n,children:`Close`}),children:(0,G.jsx)(aV,{definition:x})});let C=lV(b),w=a.some(e=>(e.credentials??[]).some(e=>e.class!==`none`)),T=x.credentialClass!==`none`,E=js(x,{credentialClass:b.isSubscription?`subscription`:x.credentialClass,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}}),D=!h&&(!T||l.trim().length>0),O=async()=>{g(!0),y(null);try{if(!T){await i.setActiveProvider(x.id),n();return}let e=await i.probeCredential(x.id,{secret:l.trim(),variantId:b.variantId,...x.userBaseUrl&&d.trim()?{baseUrl:d.trim()}:{}});if(!e.ok){y(e.error??`${S} rejected this key — check it and try again.`);return}let t={};b.variantId&&(t.variant=b.variantId),x.userBaseUrl&&d.trim()&&(t.baseUrl=d.trim()),await i.addCredential({class:b.isSubscription?`subscription`:`api_key`,providerId:x.id,secret:l.trim(),...p.trim()?{label:p.trim()}:{},...Object.keys(t).length>0?{meta:t}:{}})&&(u(``),n())}finally{g(!1)}};return(0,G.jsx)(Vy,{open:e,title:`${w?`Manage`:`Connect`} ${S}`,onClose:n,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:n,children:`Cancel`}),b.loginKind===`oauth`?(0,G.jsxs)(Y,{onClick:()=>i.openOauthLogin(b.provider.definition.id),"data-testid":`connect-oauth-signin`,children:[(0,G.jsx)(J.LogIn,{className:`w-4 h-4`}),` `,b.provider.definition.subscriptionLogin?.signInLabel??`Sign in instead`]}):b.loginKind===`claude`?(0,G.jsxs)(Y,{onClick:()=>i.openClaudeLogin(null),"data-testid":`connect-claude-signin`,children:[(0,G.jsx)(J.LogIn,{className:`w-4 h-4`}),` Sign in instead`]}):null,(0,G.jsx)(Y,{variant:`primary`,busy:h,disabled:!D,onClick:()=>void O(),children:h?`Checking…`:T?`Save key`:`Use this provider`})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[o.length>1?(0,G.jsx)(`div`,{className:`flex gap-1 border-b border-border`,role:`tablist`,children:o.map(e=>{let t=lV(e)[0];return(0,G.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===b.key,"data-testid":`record-tab-${e.key}`,onClick:()=>c(e.key),className:e.key===b.key?`rounded-t-md border border-b-0 border-border bg-surface-2 px-3 py-1.5 text-sm font-medium`:`px-3 py-1.5 text-sm text-fg-muted hover:text-fg`,children:[e.label,t?(0,G.jsx)(`span`,{className:`ml-1.5 font-mono text-[11px] text-ok`,children:t.masked}):null]},e.key)})}):null,C.length>0?(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:`Connected`}),C.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border px-2.5 py-1.5`,"data-testid":`stored-credential-${e.id}`,children:[(0,G.jsx)(Q,{tone:e.class===`subscription`?`accent`:`ok`,children:b.label}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:e.masked}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-fg-faint`,children:e.label}),(0,G.jsx)(Y,{size:`sm`,onClick:()=>void i.testCredential(e.id),children:`Test`}),(0,G.jsx)(Y,{size:`sm`,variant:`danger`,onClick:()=>void i.deleteCredential(e.id),children:`Remove`})]},e.id))]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,G.jsx)(Q,{tone:E.viaGateway?`accent`:`ok`,children:E.badge}),(0,G.jsx)(Q,{children:x.kind}),b.keyFormat?(0,G.jsxs)(`span`,{className:`text-fg-faint`,children:[`key format `,b.keyFormat]}):null]}),(0,G.jsxs)(`div`,{className:E.viaGateway?`rounded-md border border-border bg-surface-2 px-3 py-2 text-xs text-fg-muted`:`rounded-md border border-ok/40 bg-ok-soft px-3 py-2 text-xs text-ok`,"data-testid":`connect-route`,children:[E.detail,T&&!E.viaGateway?` The key is stored in your zero-knowledge vault.`:null]}),T?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`ol`,{className:`ml-4 list-decimal space-y-1 text-xs text-fg-muted`,children:b.loginKind===`oauth`?[`Press “${b.provider.definition.subscriptionLogin?.signInLabel??`Sign in`}”: a short code opens in your browser, you approve it, and the subscription is stored by itself — nothing to paste.`,`The token refreshes on its own; sign in again only if the provider says it expired.`,`Or paste an access token below, if you have one from elsewhere.`].map((e,t)=>(0,G.jsx)(`li`,{children:e},t)):b.hasLoginFlow?[`Press “Sign in instead” to get a token through the genuine engine — the fastest way.`,"Or run `claude setup-token` yourself and complete the sign-in in your browser.",`Paste the token it prints below (it looks like sk-ant-oat01-…).`].map((e,t)=>(0,G.jsx)(`li`,{children:e},t)):oV(b.provider,b.variant).map((e,t)=>(0,G.jsx)(`li`,{children:e},t))}),(0,G.jsx)(zy,{label:b.isSubscription?`Subscription token`:`API key`,hint:`Tried against the provider before it is saved, then encrypted on this PC with your vault key.`,children:(0,G.jsx)(`input`,{className:Z,type:`password`,autoComplete:`off`,spellCheck:!1,value:l,placeholder:b.keyFormat??`sk-…`,onChange:e=>{u(e.target.value),y(null)}})}),_?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`connect-probe-error`,children:_}):null,x.userBaseUrl?(0,G.jsx)(zy,{label:`Base URL`,hint:`Point this at your own server if it is not the default. Each record has its own endpoint.`,children:(0,G.jsx)(`input`,{className:Z,value:d,spellCheck:!1,onChange:e=>f(e.target.value),placeholder:b.variant?.baseUrl??x.baseUrl})}):null,(0,G.jsx)(zy,{label:`Label (optional)`,children:(0,G.jsx)(`input`,{className:Z,value:p,onChange:e=>m(e.target.value),placeholder:`${S} ${b.label.toLowerCase()} key`})})]}):(0,G.jsxs)(`div`,{className:`rounded-md bg-surface-2 px-3 py-2 text-xs text-fg-muted`,children:[x.displayName,` needs no credential.`]})]})})}function dV({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.ui.oauthLoginProviderId,a=i?n.providers.find(e=>e.definition.id===i)??null:null,o=n.oauthLogin&&n.oauthLogin.providerId===i?n.oauthLogin:null,[s,c]=(0,v.useState)(0),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null),f=a?.definition.displayName??i??`the provider`,p=a?.definition.subscriptionLogin?.signInLabel??`Sign in to ${f}`,m=o?.phase===`awaiting_approval`,h=m?o?.verificationUriComplete??o?.verificationUri??null:null;(0,v.useEffect)(()=>{if(!e||!i)return;d.current=null,r.startOauthLogin(i);let t=setInterval(()=>void r.refreshOauthLogin(i),2e3);return()=>clearInterval(t)},[e,i,s,r]),(0,v.useEffect)(()=>{!e||!h||!o?.id||d.current===o.id||(d.current=o.id,TR(h))},[e,h,o?.id]),(0,v.useEffect)(()=>{e&&o?.phase===`connected`&&r.refreshCredentials()},[e,o?.phase,r]);let g=e=>{if(!navigator.clipboard){r.toast(`error`,`Could not copy — select it and copy by hand`);return}navigator.clipboard.writeText(e).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}).catch(()=>r.toast(`error`,`Could not copy`))},_=o?.phase===`connected`||o?.phase===`failed`||o?.phase===`expired`||o?.phase===`cancelled`;return(0,G.jsx)(Vy,{open:e,title:p,onClose:t,footer:(0,G.jsxs)(G.Fragment,{children:[m?(0,G.jsx)(Y,{onClick:()=>i&&void r.cancelOauthLogin(i),"data-testid":`oauth-login-cancel`,children:`Cancel sign-in`}):null,_&&o?.phase!==`connected`?(0,G.jsx)(Y,{onClick:()=>c(e=>e+1),"data-testid":`oauth-login-retry`,children:`Try again`}):null,(0,G.jsx)(Y,{variant:`primary`,onClick:t,children:o?.phase===`connected`?`Done`:`Close`})]}),children:(0,G.jsx)(`div`,{className:`space-y-3 text-sm`,"data-testid":`oauth-login-dialog`,children:m&&o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{children:[`A sign-in page for `,f,` opened in your browser. If it did not, open the link below on any device and enter this code:`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`text-lg font-mono px-2 py-1 rounded border border-border`,"data-testid":`oauth-user-code`,children:o.userCode}),(0,G.jsxs)(Y,{onClick:()=>o.userCode&&g(o.userCode),children:[(0,G.jsx)(J.Copy,{className:`w-4 h-4`}),` `,l?`Copied`:`Copy code`]})]}),h?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 break-all`,children:[(0,G.jsx)(`a`,{className:`underline`,href:h,onClick:e=>{e.preventDefault(),TR(h)},children:h}),(0,G.jsxs)(Y,{onClick:()=>g(h),children:[(0,G.jsx)(J.Copy,{className:`w-4 h-4`}),` Copy link`]})]}):null,(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`Waiting for your approval… the code expires`,o.expiresAt?` at ${new Date(o.expiresAt).toLocaleTimeString()}`:` soon`,`. The subscription is stored in your vault the moment `,f,` confirms it.`]})]}):o?.phase===`connected`?(0,G.jsxs)(`p`,{"data-testid":`oauth-login-connected`,children:[`Signed in. Your `,f,` subscription is stored in your vault and synced to your other machines; chats on it run from this PC straight to the provider.`]}):_?(0,G.jsx)(`p`,{className:`text-danger`,"data-testid":`oauth-login-ended`,children:o?.message??`The sign-in did not complete.`}):(0,G.jsx)(`p`,{children:`Starting the sign-in…`})})})}function fV({open:e,onClose:t}){let{state:n,actions:r}=K(),i=(0,v.useMemo)(()=>nf(n.providers),[n.providers]),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1);(0,v.useEffect)(()=>{e&&(o({...n.settings?.modelVisibility??{}}),c(``))},[e]);let d=(e,t)=>a[e]??t,f=(e,t,n)=>d(e,n).includes(t),p=(e,t,n)=>{o(r=>{let i=r[e]??n,a=i.includes(t)?i.filter(e=>e!==t):n.filter(e=>e===t||i.includes(e));return{...r,[e]:a}})},m=(e,t,n)=>{o(r=>({...r,[e]:t?[...n]:[]}))},h=async()=>{u(!0);try{let e={};for(let t of i){let n=t.definition.models.map(e=>e.id),r=a[t.definition.id];r&&r.length!==n.length&&(e[t.definition.id]=r)}await r.saveSettings({modelVisibility:e}),t()}finally{u(!1)}},g=s.trim().toLowerCase();return(0,G.jsx)(Vy,{open:e,title:`Manage models`,onClose:t,wide:!0,footer:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,G.jsxs)(Y,{onClick:()=>{t(),r.openSettings(`providers`)},"data-testid":`manage-models-add-provider`,children:[(0,G.jsx)(J.Plus,{className:`w-3.5 h-3.5`}),` Add provider`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Y,{onClick:t,children:`Cancel`}),(0,G.jsx)(Y,{variant:`primary`,busy:l,onClick:()=>void h(),"data-testid":`manage-models-save`,children:`Save`})]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Choose which models the chat's picker offers. A provider with every model checked shows all of them — including ones it adds later.`}),(0,G.jsx)(`input`,{className:Z,value:s,onChange:e=>c(e.target.value),placeholder:`Filter models…`,"data-testid":`manage-models-filter`}),i.length===0?(0,G.jsxs)(`div`,{className:`text-sm text-fg-faint`,children:[`No provider is connected yet — use `,(0,G.jsx)(`strong`,{children:`Add provider`}),` below to connect one.`]}):null,i.map(e=>{let t=e.definition.models.map(e=>e.id),n=e.definition.models.filter(e=>!g||e.id.toLowerCase().includes(g)||(e.displayName??``).toLowerCase().includes(g)),r=d(e.definition.id,t).length;return(0,G.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`manage-models-${e.definition.id}`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.definition.displayName}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[r===t.length?`all`:r,` of `,t.length,` shown`]}),(0,G.jsxs)(`span`,{className:`ml-auto flex gap-1`,children:[(0,G.jsx)(Y,{size:`sm`,onClick:()=>m(e.definition.id,!0,t),children:`All`}),(0,G.jsx)(Y,{size:`sm`,onClick:()=>m(e.definition.id,!1,t),children:`None`})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-2`,children:[n.map(n=>(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:f(e.definition.id,n.id,t),onChange:()=>p(e.definition.id,n.id,t),"data-testid":`manage-model-${n.id}`}),(0,G.jsxs)(`span`,{className:`truncate`,title:n.id,children:[n.displayName??n.id,n.displayName&&n.displayName!==n.id?(0,G.jsxs)(`span`,{className:`text-fg-faint`,children:[` · `,n.id]}):null]})]},n.id)),n.length===0?(0,G.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[(0,G.jsx)(J.Info,{className:`mr-1 inline w-3 h-3`}),` No model matches the filter.`]}):null]})]},e.definition.id)})]})})}var pV={mode:`names`,mine:!0,model:!0,tools:!1,subagents:!1,projectId:null,when:`any`,caseSensitive:!1,wholeWord:!1};function mV(e,t,n){let r=Oe(t,{caseSensitive:n.caseSensitive,wholeWord:n.wholeWord});if(!r)return[{text:e,hit:!1}];let i=[],a=0;for(let t of e.matchAll(r)){let n=t.index??0;t[0].length!==0&&(n>a&&i.push({text:e.slice(a,n),hit:!1}),i.push({text:t[0],hit:!0}),a=n+t[0].length)}return a<e.length&&i.push({text:e.slice(a),hit:!1}),i}function hV(e){return Object.keys(pV).some(t=>e[t]!==pV[t])}function gV(e,t=Date.now()){if(e===`any`)return null;if(e===`today`){let e=new Date(t);return e.setHours(0,0,0,0),e}return new Date(t-(e===`week`?7:30)*24*60*60*1e3)}function _V(e,t,n,r=Date.now()){if(n.projectId!==null&&e.projectId!==n.projectId)return!1;let i=gV(n.when,r);if(i&&e.mtime<i.getTime())return!1;if((n.caseSensitive||n.wholeWord)&&t.trim()!==``){let r=[e.title,e.firstPrompt,e.lastPrompt,e.projectDir],i={caseSensitive:n.caseSensitive,wholeWord:n.wholeWord};if(!r.some(e=>typeof e==`string`&&ke(e,t,i)))return!1}return!0}function vV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=gV(t.when,n);return{q:r,limit:200,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},...t.projectId?{projectId:t.projectId}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function yV({label:e,hint:t,checked:n,onChange:r,testId:i}){return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5 text-xs`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-0.5`,checked:n,onChange:e=>r(e.target.checked),"data-testid":i}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`text-fg`,children:e}),t?(0,G.jsx)(`span`,{className:`block text-[11px] text-fg-faint`,children:t}):null]})]})}var bV=`w-full rounded-md border border-border bg-surface px-2 py-1 text-xs text-fg focus:outline-none`,xV={names:`Names & prompts`,conversations:`Whole chats`,namesHint:`A chat’s name, its first and last message, and its folder.`,conversationsHint:`Every message of every chat on this PC. Pick whose words to look in.`};function SV({options:e,onChange:t,projects:n,onClose:r,words:i=xV}){let a=(n,r)=>t({...e,[n]:r}),o=e.mode===`conversations`,s=o&&!e.mine&&!e.model&&!e.tools;return(0,G.jsxs)(`div`,{className:`absolute left-2 right-2 top-full z-30 mt-1 space-y-3 rounded-lg border border-border bg-surface p-3 shadow-xl`,onMouseDown:e=>{!(e.target instanceof HTMLSelectElement)&&!(e.target instanceof HTMLInputElement)&&e.preventDefault()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),r())},"data-testid":`search-options`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:`Search in`}),(0,G.jsx)(Uy,{label:`Search in`,value:e.mode,options:[{value:`names`,label:i.names},{value:`conversations`,label:i.conversations}],onChange:e=>a(`mode`,e)}),(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`search-mode-hint`,children:o?i.conversationsHint:i.namesHint})]}),o?(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(yV,{label:`My messages`,checked:e.mine,onChange:e=>a(`mine`,e),testId:`search-opt-mine`}),(0,G.jsx)(yV,{label:`Model replies`,checked:e.model,onChange:e=>a(`model`,e),testId:`search-opt-model`}),(0,G.jsx)(yV,{label:`Tool calls & output`,hint:`Commands, file paths and what the tools answered.`,checked:e.tools,onChange:e=>a(`tools`,e),testId:`search-opt-tools`}),(0,G.jsx)(yV,{label:`Subagents’ conversations`,checked:e.subagents,onChange:e=>a(`subagents`,e),testId:`search-opt-subagents`}),s?(0,G.jsx)(`p`,{className:`text-[11px] text-warn`,children:`Tick at least one to search.`}):null]}):null,(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[n?(0,G.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`span`,{children:`Project`}),(0,G.jsxs)(`select`,{className:bV,value:e.projectId??``,onChange:e=>a(`projectId`,e.target.value||null),"data-testid":`search-opt-project`,children:[(0,G.jsx)(`option`,{value:``,children:`All projects`}),n.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}):null,(0,G.jsxs)(`label`,{className:`space-y-1 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`span`,{children:`When`}),(0,G.jsxs)(`select`,{className:bV,value:e.when,onChange:e=>a(`when`,e.target.value),"data-testid":`search-opt-when`,children:[(0,G.jsx)(`option`,{value:`any`,children:`Any time`}),(0,G.jsx)(`option`,{value:`today`,children:`Today`}),(0,G.jsx)(`option`,{value:`week`,children:`Last 7 days`}),(0,G.jsx)(`option`,{value:`month`,children:`Last 30 days`})]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-x-4`,children:[(0,G.jsx)(yV,{label:`Match case`,checked:e.caseSensitive,onChange:e=>a(`caseSensitive`,e),testId:`search-opt-case`}),(0,G.jsx)(yV,{label:`Whole words`,checked:e.wholeWord,onChange:e=>a(`wholeWord`,e),testId:`search-opt-word`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border pt-2`,children:[(0,G.jsx)(`button`,{type:`button`,className:W(`text-xs`,hV(e)?`text-accent hover:underline`:`text-fg-faint`),disabled:!hV(e),onClick:()=>t(pV),"data-testid":`search-opt-reset`,children:`Reset`}),(0,G.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-2 px-2 py-1 text-xs text-fg hover:bg-surface-3`,onClick:r,"data-testid":`search-opt-done`,children:`Done`})]})]})}function CV(e){return e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`}function wV({query:e,options:t}){let{state:n,actions:r}=K(),i=(0,v.useMemo)(()=>vV(e,t),[e,t]),[a,o]=(0,v.useState)(null),s=i?JSON.stringify(i):``;(0,v.useEffect)(()=>{if(!i)return;let e=!0,t=setTimeout(()=>{r.searchTranscripts(i).then(t=>{e&&o({key:s,res:t})})},350);return()=>{e=!1,clearTimeout(t)}},[s,r]);let c=a&&a.key===s?a:null,l=(0,v.useMemo)(()=>{let e=new Map;for(let t of c?.res?.hits??[]){let r=n.sessions.find(e=>e.id===t.sessionId)?.title||t.title||`Untitled chat`,i=e.get(t.sessionId)??{title:r,hits:[]};i.hits.push(t),e.set(t.sessionId,i)}return[...e.entries()]},[c,n.sessions]);if(!i)return(0,G.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-idle`,children:e.trim().length<2?`Type at least two characters to search every chat.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`});if(!c)return(0,G.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-fg-faint`,"data-testid":`transcript-search-busy`,children:`Searching every chat…`});if(c.res===null)return(0,G.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-danger`,"data-testid":`transcript-search-failed`,children:`This PC could not search its chats. Try again, or update OonaCode.`});let u=c.res.hits.length;return(0,G.jsxs)(`div`,{className:`pb-2`,"data-testid":`transcript-search-results`,children:[(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-fg-faint`,children:u===0?`No message on this PC says that.`:`${u}${c.res.truncated?`+`:``} ${u===1?`message`:`messages`} in ${l.length} ${l.length===1?`chat`:`chats`}`}),l.map(([n,i])=>(0,G.jsxs)(`div`,{className:`mb-1.5`,"data-testid":`transcript-search-chat-${n}`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-[13px] font-semibold text-fg hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:i.title}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 text-[10px] font-semibold text-fg-muted`,children:i.hits.length})]}),i.hits.map(i=>(0,G.jsxs)(`button`,{type:`button`,className:`block w-full rounded px-2 py-1 pl-4 text-left text-xs hover:bg-surface-2`,onClick:()=>r.openChatWithSearch(n,e.trim()),"data-testid":`transcript-search-hit`,children:[(0,G.jsxs)(`span`,{className:`mb-0.5 flex items-center gap-1.5 text-[10px] text-fg-faint`,children:[i.kind===`tool`?(0,G.jsx)(J.Tool,{className:`h-3 w-3`}):i.role===`assistant`?(0,G.jsx)(J.Bot,{className:`h-3 w-3`}):(0,G.jsx)(J.User,{className:`h-3 w-3`}),(0,G.jsx)(`span`,{className:`font-medium text-fg-muted`,children:CV(i)}),i.subpath?(0,G.jsx)(`span`,{children:`· subagent`}):null,i.timestamp?(0,G.jsx)(`span`,{className:`ml-auto`,children:eg(i.timestamp)}):null]}),(0,G.jsx)(`span`,{className:`line-clamp-3 text-fg-muted`,children:mV(i.snippet,e,t).map((e,t)=>e.hit?(0,G.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,G.jsx)(`span`,{children:e.text},t))})]},`${i.seq}`))]},n))]})}function TV(e){return`${e.agentId??`claude-code`}:${e.id}`}function EV(e){let t=Date.parse(e.lastEntryAt??e.updatedAt);return Number.isFinite(t)?t:0}function DV(e,t,n=Date.now()){let r=gV(t.when,n)?.getTime()??null,i=Oe(e,{caseSensitive:t.caseSensitive,wholeWord:t.wholeWord});return e=>r!==null&&EV(e)<r?!1:i===null||[e.title,e.firstPrompt,e.lastPrompt,e.cwd,e.projectName,e.id].some(e=>typeof e==`string`&&(i.lastIndex=0,i.test(e)))}function OV(e,t,n=Date.now()){let r=e.trim();if(r.length<2||!t.mine&&!t.model&&!t.tools)return null;let i=gV(t.when,n);return{q:r,from:t.mine&&t.model?`both`:t.mine?`user`:t.model?`assistant`:`none`,tools:t.tools,subagents:t.subagents,...i?{since:i.toISOString()}:{},caseSensitive:t.caseSensitive,wholeWord:t.wholeWord}}function kV(e,t){let n=new Map;for(let t of e){let e=TV(t);n.set(e,e);for(let r of t.supersedes??[]){let i=TV({agentId:t.agentId,id:r});n.has(i)||n.set(i,e)}}let r=new Map;for(let e of t){let t=n.get(TV(e));if(!t)continue;let i=r.get(t);if(!i){r.set(t,{...e,snippets:e.snippets.slice(0,3)});continue}r.set(t,{...i,hits:i.hits+e.hits,...i.hitsCapped||e.hitsCapped?{hitsCapped:!0}:{},snippets:[...i.snippets,...e.snippets].slice(0,3)})}return r}var AV={new:`New`,imported:`Imported`,behind:`Imported · original moved on`,deleted:`You deleted it in OonaCode`,unavailable:`Cannot be imported yet`};function jV(e){return e.alreadyImported?e.upToDate===!1?`behind`:`imported`:e.deletedHere===!0?`deleted`:MV(e)?`unavailable`:`new`}function MV(e){return typeof e.unavailable==`string`&&e.unavailable.length>0}function NV(e){if(MV(e))return!1;let t=jV(e);return t===`new`||t===`behind`}function PV(e){return jV(e)===`new`}function FV(e,t){return new Set(t?e.filter(PV).map(e=>e.id):[])}function IV(e){if(!e.some(e=>e.projectName))return e;let t=[],n=new Map;for(let r of e){let e=r.projectName??``,i=n.get(e);i||(i=[],n.set(e,i),t.push(e)),i.push(r)}return t.flatMap(e=>n.get(e)??[])}function LV(){return{new:0,imported:0,behind:0,deleted:0,unavailable:0}}function RV(e){let t=new Map;for(let n of e){let e=n.agentId??`claude-code`,r=t.get(e);r||(r={key:e,name:n.agentName??`Claude Code`,rows:[],counts:LV()},t.set(e,r)),r.rows.push(n),r.counts[jV(n)]+=1}for(let e of t.values())e.rows=IV([...e.rows].sort((e,t)=>EV(t)-EV(e)));return[...t.values()]}function zV(e,t){let n=0,r=0,i=0;for(let a of e){let e=t.has(a.id);e&&(n+=1),NV(a)&&(r+=1,e&&(i+=1))}return n===0?`none`:r>0&&i===r?`all`:`some`}function BV(e,t){let n=new Set(t),r=e.filter(NV);if(zV(e,t)===`all`||r.length===0)for(let t of e)n.delete(t.id);else for(let e of r)n.add(e.id);return n}function VV(e,t){let n=0;if(t)for(let r of e)t.has(r)||(n+=1);return{total:e.size,notShown:n}}var HV={names:`Names & folders`,conversations:`Whole conversations`,namesHint:`A chat’s name, its first and last message, and the folder it ran in.`,conversationsHint:`Every message of every chat listed here, read from the other apps’ own files. Pick whose words to look in.`},UV=`Ticks the chats with something to bring in — new ones, and imported ones whose original moved on. An imported chat that is up to date, or one you deleted in OonaCode, is ticked on its own row.`;function WV(e){return e.partial===`time`?`Stopped after ${Math.round(e.elapsedMs/1e3)} s — these are the chats found until then. A longer phrase narrows it.`:e.partial===`chats`?`Stopped at ${e.chats.length} chats — a longer phrase narrows it.`:null}function GV(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).length<=2?e:`…${e.slice(-40)}`:`no folder recorded`}function KV(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1048576).toFixed(1)} MB`}function qV(e){let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}var JV=(e,t,n)=>`${e} ${e===1?t:n}`;function YV({open:e,onClose:t,autoOffer:n=!1}){let{state:r,actions:i}=K(),a=r.importProgress,[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(new Set),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(null),x=(0,v.useMemo)(()=>f??[],[f]),S=(0,v.useMemo)(()=>RV(x),[x]),C=(0,v.useMemo)(()=>{let e={new:0,imported:0,behind:0,deleted:0,unavailable:0};for(let t of S)for(let n of Object.keys(e))e[n]+=t.counts[n];return e},[S]),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(pV),[O,k]=(0,v.useState)(!1),A=(0,v.useRef)(null),j=w.trim()!==``,M=E.mode===`conversations`,[N,ee]=(0,v.useState)(new Set);(0,v.useEffect)(()=>ee(new Set),[w,E]);let te=(0,v.useMemo)(()=>M?OV(w,E):null,[M,w,E]),P=te?JSON.stringify(te):``,[F,ne]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e||!te)return;let t=new AbortController,n=!0,r=setTimeout(()=>{i.searchImportChats(te,t.signal).then(e=>{n&&ne({key:P,res:e})})},350);return()=>{n=!1,clearTimeout(r),t.abort()}},[e,P,i]);let re=F&&F.key===P?F:null,ie=(0,v.useMemo)(()=>re?.res?kV(x,re.res.chats):null,[re,x]),I=(0,v.useMemo)(()=>j?M?ie?x.filter(e=>ie.has(TV(e))):[]:x.filter(DV(w,E)):null,[j,M,x,w,E,ie]),L=(0,v.useMemo)(()=>I?new Set(I):null,[I]),R=(0,v.useMemo)(()=>I?new Set(I.map(e=>e.id)):null,[I]),ae=I??x,oe=(0,v.useMemo)(()=>j?{query:w,options:E,litNames:!M}:null,[j,w,E,M]),se=(0,v.useMemo)(()=>x.filter(e=>e.alreadyImported&&m.has(e.id)),[x,m]),ce=(0,v.useMemo)(()=>VV(m,R),[m,R]),le=S.length===1?S[0].name:`coding-agent`;(0,v.useEffect)(()=>{if(!e)return;d(null),b(null),_(new Set),h(new Set),T(``),ne(null),k(!1),s(!0);let t=n;i.scanClaudeSessions().then(e=>{p(e.sessions),h(FV(e.sessions,t))}).catch(e=>d(e instanceof Error?e.message:String(e))).finally(()=>s(!1))},[e]);let ue=(0,v.useCallback)(e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),de=r.prefs.claudeImportOffered,fe=(0,v.useCallback)(()=>{de||i.savePrefs({claudeImportOffered:!0}),t()},[de,i,t]),pe=async()=>{l(!0),d(null);try{let e=await i.importClaudeSessions([...m],se.length>0);b({imported:e.imported.length,replaced:e.replaced?.length??0,entries:e.imported.reduce((e,t)=>e+t.entries,0)+(e.replaced??[]).reduce((e,t)=>e+t.entries,0),failed:e.failed.length,filed:e.filed?.length??0,projectsMade:(e.projects??[]).filter(e=>e.created).map(e=>e.name),warnings:e.warnings??[]}),r.prefs.claudeImportOffered||i.savePrefs({claudeImportOffered:!0}),await i.refreshSessions()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}},me=C.imported+C.behind;return(0,G.jsx)(Vy,{open:e,title:`Import your ${le} chats`,onClose:fe,wide:!0,footer:(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 text-[11px] text-fg-faint`,children:[!y&&ce.notShown>0?(0,G.jsxs)(`span`,{className:`block text-fg-muted`,"data-testid":`import-claude-ticked-hidden`,children:[ce.total,` ticked · `,ce.notShown,` not shown by the search`]}):null,se.length>0?(0,G.jsxs)(`span`,{className:`block text-warn`,children:[se.length,` already-imported `,se.length===1?`chat`:`chats`,` `,`will be REPLACED — the OonaCode copy is rebuilt from the original, and anything added here is lost.`]}):(0,G.jsx)(`span`,{className:`block`,children:`Your other apps stay exactly as they are — this copies, it never moves or deletes.`})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,G.jsx)(Y,{onClick:fe,"data-testid":`import-claude-close`,children:y?`Done`:`Not now`}),y?null:(0,G.jsxs)(Y,{variant:`primary`,busy:c,disabled:ce.total===0,onClick:()=>void pe(),"data-testid":`import-claude-run`,children:[`Import `,JV(ce.total,`chat`,`chats`)]})]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`import-claude-body`,children:[o?(0,G.jsx)(`div`,{className:`text-sm text-fg-muted`,children:`Looking for chats on this PC…`}):null,a&&!y?(0,G.jsxs)(`div`,{className:`space-y-2`,"data-testid":`import-claude-progress`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,G.jsxs)(`span`,{children:[`Importing `,(0,G.jsx)(`strong`,{children:a.done}),` of `,(0,G.jsx)(`strong`,{children:a.total}),`…`]}),(0,G.jsxs)(`span`,{className:`text-[11px] text-fg-faint`,children:[Math.round(a.done/Math.max(a.total,1)*100),`%`]})]}),(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-surface-2`,children:(0,G.jsx)(`div`,{className:`h-full bg-accent transition-[width] duration-200`,style:{width:`${Math.round(a.done/Math.max(a.total,1)*100)}%`}})}),a.current?(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,title:a.current,children:[`reading: `,a.current]}):null,(0,G.jsxs)(`div`,{className:`flex gap-3 text-[11px] text-fg-faint`,children:[(0,G.jsxs)(`span`,{children:[a.imported,` imported`]}),a.skipped>0?(0,G.jsxs)(`span`,{children:[a.skipped,` already in`]}):null,a.failed>0?(0,G.jsxs)(`span`,{className:`text-warn`,children:[a.failed,` could not be read`]}):null]}),(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,children:`A big chat takes a moment — the largest here are over 100 MB. Your Claude Code is only being read.`})]}):null,u?(0,G.jsx)(`div`,{className:`rounded border border-danger/40 bg-danger/10 p-2 text-sm text-danger`,children:u}):null,y?(0,G.jsxs)(`div`,{className:`text-sm`,"data-testid":`import-claude-done`,children:[(0,G.jsxs)(`p`,{children:[`Imported `,(0,G.jsx)(`strong`,{children:y.imported}),` `,y.imported===1?`chat`:`chats`,y.replaced>0?(0,G.jsxs)(G.Fragment,{children:[` and rebuilt `,(0,G.jsx)(`strong`,{children:y.replaced}),` that `,y.replaced===1?`was`:`were`,` already here`]}):null,` `,`(`,y.entries.toLocaleString(),` entries). They are in your sessions list now, and you can carry on typing in them.`]}),y.projectsMade.length>0?(0,G.jsxs)(`p`,{className:`mt-1`,"data-testid":`import-claude-projects-made`,children:[y.projectsMade.length===1?`Created the project `:`Created the projects `,y.projectsMade.map((e,t)=>(0,G.jsxs)(`span`,{children:[t>0?`, `:``,(0,G.jsx)(`strong`,{children:e})]},e)),` `,`and filed `,y.projectsMade.length===1?`its`:`their`,` chats under`,` `,y.projectsMade.length===1?`it`:`them`,`.`]}):null,y.filed>0?(0,G.jsxs)(`p`,{className:`mt-1 text-fg-muted`,"data-testid":`import-claude-filed`,children:[y.filed,` `,y.filed===1?`chat that was`:`chats that were`,` already here`,` `,y.filed===1?`is`:`are`,` now filed under`,` `,y.filed===1?`its`:`their`,` project.`]}):null,y.failed>0?(0,G.jsxs)(`p`,{className:`mt-1 text-warn`,children:[y.failed,` could not be read and were left alone.`]}):null,y.warnings.map(e=>(0,G.jsx)(`p`,{className:`mt-1 text-warn`,children:e},e))]}):null,!o&&!y&&!a&&f!==null&&f.length>0?(0,G.jsxs)(`div`,{className:`space-y-0.5 text-sm`,"data-testid":`import-claude-tally`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`strong`,{children:f.length}),` `,f.length===1?`chat`:`chats`,` on this PC`,S.length>0?` — `:``,S.map((e,t)=>(0,G.jsxs)(`span`,{children:[t>0?`, `:``,(0,G.jsx)(`strong`,{children:e.rows.length}),` `,e.name]},e.key))]}),(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[(0,G.jsx)(`strong`,{className:`text-fg`,children:C.new}),` new`,me>0?` · ${me} already imported`:``,C.behind>0?` (${C.behind} behind their original)`:``,C.deleted>0?` · ${C.deleted} you deleted in OonaCode`:``]})]}):null,!o&&!y&&!a&&f!==null&&C.new===0&&!j?(0,G.jsx)(`div`,{className:`text-sm text-fg-muted`,"data-testid":`import-claude-empty`,children:f.length===0?`No chats from a coding agent were found on this PC.`:`Nothing new to import. Every chat is listed below — tick one to import it again.`}):null,!y&&!a&&x.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Every chat the coding agents on this PC have, newest first. Importing copies them into OonaCode so you can read them here — and continue them, in the folder each one ran in.`,n&&C.new>0?` The new ones are ticked.`:` Tick the ones you want.`]}),(0,G.jsxs)(`div`,{className:`relative`,"data-testid":`import-search`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(J.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`input`,{ref:A,"aria-label":`Search the chats to import`,className:W(Z,`pl-7`),placeholder:M?`Search inside every conversation`:`Search by name, message or folder`,value:w,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(w!==``||O)&&(e.preventDefault(),e.stopPropagation(),O?k(!1):T(``))},"data-testid":`import-search-input`})]}),(0,G.jsxs)(X,{label:O?`Hide search options`:`Search options`,className:W(`relative`,O&&`text-accent`),"aria-pressed":O,onMouseDown:e=>e.preventDefault(),onClick:()=>k(e=>!e),"data-testid":`import-search-options-toggle`,children:[(0,G.jsx)(J.Sliders,{}),hV(E)?(0,G.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`import-search-options-dot`}):null]}),j?(0,G.jsx)(X,{label:`Clear search`,onMouseDown:e=>e.preventDefault(),onClick:()=>{T(``),A.current?.focus()},"data-testid":`import-search-clear`,children:(0,G.jsx)(J.X,{})}):null]}),O?(0,G.jsx)(SV,{options:E,onChange:D,words:HV,onClose:()=>{k(!1),A.current?.focus()}}):null]}),j?(0,G.jsx)(rH,{query:w,conversations:M,request:te!==null,answer:re,matches:I?.length??0,messages:[...ie?.values()??[]].reduce((e,t)=>e+t.hits,0),capped:[...ie?.values()??[]].some(e=>e.hitsCapped)}):null,(0,G.jsx)(`div`,{className:`max-h-96 space-y-3 overflow-y-auto`,"data-testid":`import-claude-list`,children:S.map(e=>{let t=L?e.rows.filter(e=>L.has(e)):e.rows;if(t.length===0)return null;let n=L?!N.has(e.key):!g.has(e.key),r=L?ee:_;return(0,G.jsxs)(`div`,{className:`rounded border border-border`,"data-testid":`import-group-${e.key}`,children:[(0,G.jsx)(QV,{section:e,rows:t,searching:L!==null,open:n,chosen:m,onFold:()=>r(t=>XV(t,e.key)),onTicks:h}),n?t.map(e=>(0,G.jsx)(eH,{row:e,checked:m.has(e.id),onToggle:ue,phrase:oe,hit:ie?.get(TV(e))},TV(e))):null]},e.key)})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-fg-faint`,children:[(0,G.jsx)(`button`,{type:`button`,className:`underline`,title:UV,onClick:()=>h(e=>{let t=new Set(e);for(let e of ae)NV(e)&&t.add(e.id);return t}),"data-testid":`import-claude-select-all`,children:I===null?`Select all`:`Select all matches`}),(0,G.jsx)(`button`,{type:`button`,className:`underline`,onClick:()=>h(e=>{if(I===null)return new Set;let t=new Set(e);for(let e of ae)t.delete(e.id);return t}),"data-testid":`import-claude-select-none`,children:I===null?`Select none`:`Unselect matches`})]})]}):null]})})}function XV(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function ZV({state:e,disabled:t,onToggle:n,label:r,title:i,testId:a}){let o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{o.current&&(o.current.indeterminate=e===`some`)}),(0,G.jsx)(`input`,{ref:o,type:`checkbox`,className:`shrink-0`,checked:e===`all`,disabled:t,onChange:n,"aria-label":r,title:i,"data-state":e,"data-testid":a})}function QV({section:e,rows:t,searching:n,open:r,chosen:i,onFold:a,onTicks:o}){let s=zV(t,i),c=t.filter(NV).length,l=e.rows.filter(e=>i.has(e.id)).length,u=e.counts,d=u.imported+u.behind===e.rows.length,f=n?`the ${e.name} matches`:`${e.name}`,p=s===`all`?`Untick every chat in ${f}`:c===0&&s===`none`?`Nothing new here — tick a chat on its own row to import it again.`:c===0?`Untick every chat in ${f}`:UV;return(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-surface-2 px-2 py-1.5`,children:[(0,G.jsx)(ZV,{state:s,disabled:c===0&&s===`none`,onToggle:()=>o(e=>BV(t,e)),label:s===`all`?`Untick every chat in ${f}`:`Tick the chats in ${f}`,title:p,testId:`import-group-check-${e.key}`}),(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-xs font-medium`,onClick:a,"aria-expanded":r,title:r?`Fold ${e.name}`:`Open ${e.name}`,"data-testid":`import-group-header-${e.key}`,children:[(0,G.jsx)(J.Chevron,{open:r,className:`w-3 h-3 shrink-0`}),e.name,(0,G.jsxs)(`span`,{className:`truncate font-normal text-fg-faint`,children:[JV(e.rows.length,`chat`,`chats`),n?` · ${JV(t.length,`match`,`matches`)}`:``,u.new>0?` · ${u.new} new`:d?` · all imported`:``,u.behind>0?` · ${u.behind} behind`:``,u.deleted>0?` · ${u.deleted} you deleted`:``,l>0?` · ${l} ticked`:``]})]})]})}function $V({row:e,status:t}){let n=AV[t],r={"data-testid":`import-status-${e.id}`,"data-status":t};switch(t){case`new`:return(0,G.jsx)(`span`,{className:`font-medium text-accent`,...r,children:n});case`imported`:case`behind`:return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-fg-muted`,title:t===`behind`?`The original has newer messages than the OonaCode copy — importing again brings them in (and replaces the copy).`:`Already in OonaCode. Ticking it rebuilds the OonaCode copy from the original, which replaces it.`,...r,children:[(0,G.jsx)(J.Check,{className:`w-3 h-3 text-ok`}),n,t===`behind`?(0,G.jsxs)(`span`,{className:`ml-0.5 inline-flex shrink-0 items-center gap-0.5 rounded bg-warn-soft px-1 text-[10px] font-medium leading-4 text-warn`,"data-testid":`import-behind-${e.id}`,"aria-label":`behind its original`,children:[(0,G.jsx)(J.ArrowDown,{className:`w-2.5 h-2.5`}),`behind`]}):null]});case`deleted`:return(0,G.jsx)(`span`,{className:`text-fg-faint`,title:`You imported this chat and deleted it in OonaCode; its original is still on this PC. Tick it to bring it back.`,...r,children:n});case`unavailable`:return(0,G.jsx)(`span`,{className:`text-warn`,...r,children:n})}}var eH=(0,v.memo)(function({row:e,checked:t,onToggle:n,phrase:r,hit:i}){let a=MV(e),o=e=>r?.litNames?mV(e,r.query,r.options).map((e,t)=>e.hit?(0,G.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,G.jsx)(`span`,{children:e.text},t)):e;return(0,G.jsxs)(`label`,{className:`flex items-start gap-2 border-b border-border p-2 last:border-b-0 ${a?`cursor-default opacity-60`:`cursor-pointer hover:bg-surface-2`}`,"data-testid":`import-row-${e.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:t,disabled:a,onChange:()=>n(e.id),"aria-label":e.title??e.firstPrompt??e.id}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-sm`,children:e.title||e.firstPrompt?o(e.title||e.firstPrompt||``):(0,G.jsx)(`span`,{className:`text-fg-faint`,children:`(no prompt)`})}),(0,G.jsxs)(`span`,{className:`mt-0.5 block truncate text-[11px] text-fg-faint`,children:[e.projectName?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,G.jsx)(J.Project,{className:`w-3 h-3`}),o(e.projectName)]}):(0,G.jsxs)(G.Fragment,{children:[e.cwd?(0,G.jsx)(`span`,{title:e.cwd,children:o(GV(e.cwd))}):GV(e.cwd),e.cwd&&!e.cwdExists?` · folder is gone`:``]}),` `,`· `,e.entryCount,` entries`,e.bytes>0?` · ${KV(e.bytes)}`:``,e.model?` · ${e.model}`:``]}),e.unavailable||e.note?(0,G.jsx)(`span`,{className:`mt-0.5 block text-[11px] ${e.unavailable?`text-warn`:`text-fg-faint`}`,"data-testid":`import-row-note-${e.id}`,children:e.unavailable??e.note}):null,i&&r?(0,G.jsx)(nH,{hit:i,query:r.query,options:r.options,testId:`import-row-hits-${e.id}`}):null]}),e.supersedes&&e.supersedes.length>0?(0,G.jsx)(`span`,{className:`mt-0.5 shrink-0 rounded bg-surface-2 px-1 text-[11px] text-fg-faint`,title:`Rewound — replaces ${e.supersedes.length} earlier ${e.supersedes.length===1?`branch`:`branches`} of this chat`,children:`rewound`}):null,(0,G.jsxs)(`span`,{className:`mt-0.5 flex shrink-0 flex-col items-end gap-0.5 text-right text-[11px]`,children:[(0,G.jsx)(`span`,{className:`whitespace-nowrap text-fg-faint`,children:qV(e.lastEntryAt??e.updatedAt)}),(0,G.jsx)(`span`,{className:`whitespace-nowrap`,children:(0,G.jsx)($V,{row:e,status:jV(e)})})]})]})});function tH(e){let t=e.kind===`tool`?e.tool??`Tool`:e.role===`assistant`?`Model`:`You`;return e.subagent?`${t} (subagent)`:t}function nH({hit:e,query:t,options:n,testId:r}){return(0,G.jsxs)(`span`,{className:`mt-1 block space-y-0.5`,"data-testid":r,children:[(0,G.jsxs)(`span`,{className:`block text-[11px] font-medium text-fg-muted`,children:[e.hits,e.hitsCapped?`+`:``,` `,e.hits===1&&!e.hitsCapped?`message says`:`messages say`,` it`]}),e.snippets.map((e,r)=>(0,G.jsxs)(`span`,{className:`block line-clamp-2 text-[11px] text-fg-muted`,"data-testid":`import-row-snippet`,children:[(0,G.jsxs)(`span`,{className:`font-medium text-fg-faint`,children:[tH(e),`:`]}),` `,mV(e.snippet,t,n).map((e,t)=>e.hit?(0,G.jsx)(`mark`,{className:`rounded bg-warn-soft px-0.5 text-fg`,children:e.text},t):(0,G.jsx)(`span`,{children:e.text},t))]},r))]})}function rH({query:e,conversations:t,request:n,answer:r,matches:i,messages:a,capped:o}){let s=(e,t,n=`text-fg-muted`)=>(0,G.jsx)(`p`,{className:`text-[11px] ${n}`,"data-testid":t,children:e});if(!t)return i===0?s(`No chat’s name, message or folder says “${e.trim()}”. Whole conversations, in the search options, looks inside them.`,`import-search-none`):s(`${i} ${i===1?`chat matches`:`chats match`}`,`import-search-count`);if(!n)return s(e.trim().length<2?`Type at least two characters to search inside the conversations.`:`Tick what to look in — your messages, the model’s replies or the tools’ side.`,`import-search-idle`);if(!r)return s(`Searching every conversation on this PC…`,`import-search-busy`);if(r.res===null)return s(`This PC could not search its conversations. Try again, or update OonaCode.`,`import-search-failed`,`text-danger`);let c=r.res,l=WV(c),u=c.sources.filter(e=>e.note).map(e=>`${e.agentName}: ${e.note}`);return(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[i===0?s(c.partial===`aborted`?`The search was stopped.`:`No conversation on this PC says that.`,`import-search-none`):s(`${i} ${i===1?`chat says`:`chats say`} it · ${a}${o?`+`:``} ${a===1&&!o?`message`:`messages`}`,`import-search-count`),l?s(l,`import-search-partial`,`text-warn`):null,u.map(e=>(0,G.jsx)(`p`,{className:`text-[11px] text-fg-faint`,"data-testid":`import-search-source-note`,children:e},e))]})}var iH={model:null,previousModel:null,costUsd:0,inputTokens:0,outputTokens:0,turns:0,durationMs:0,contextTokens:null,contextWindow:null,contextUsed:null,costSource:`engine`,credits:null,resetAtIndex:null,didReset:!1,countedResults:0};function aH(e,t){let n=t?Bs(t):null,r=null,i=null;for(let t=0;t<e.length;t++){let a=e[t];if(!a||a.kind!==`assistant`||!L(a.model))continue;let o=Bs(a.model);n!==null&&o!==n&&(r=t,i=n),n=o}return{index:r,from:i,to:n}}function oH(e){let{items:t,session:n=null,initModel:r=null,boundary:i=null,models:a}=e,o=e.contextTokens!=null&&e.contextTokens>0?e.contextTokens:null;if(t.length===0&&!n)return iH;let s=aH(t,r),c=i&&i.index>=0?Math.min(i.index,t.length):null,l=null,u=null;s.index!==null&&(c===null||s.index>=c)?(l=s.index,u=s.from):c!==null&&(l=c,u=i?.from??s.from);let d=l??0,f=0,p=0,m=0,h=0,g=0,_=0;for(let e=d;e<t.length;e++){let n=t[e];!n||n.kind!==`result`||(_+=1,f+=n.costUsd,p+=n.inputTokens,m+=n.outputTokens,h+=n.numTurns,g+=n.durationMs)}_===0&&l===null&&n&&(f=n.totalCostUsd,p=n.inputTokens,m=n.outputTokens);let v=`engine`,y=null;n&&n.providerId===`oonacode`&&(f=n.totalCostUsd,y=n.poolCredits??null,v=`gateway`);let b=r?Bs(r):null,x=i&&c!==null&&l===c?i.to:s.to??n?.model??b??null,S=[x,n?.model??null,b].filter(e=>typeof e==`string`&&e.length>0),C=(a?S.map(e=>a.find(t=>t.id===e)).find(e=>e?.contextWindow!=null):void 0)?.contextWindow??null;return{model:x,previousModel:u,costUsd:f,inputTokens:p,outputTokens:m,turns:h,durationMs:g,contextTokens:o,contextWindow:C,contextUsed:C&&C>0&&o!==null?Math.min(1,o/C):null,resetAtIndex:l,didReset:l!==null,countedResults:_,costSource:v,credits:y}}var sH=[...gu.what,...gu.when,...gu.who,...gu.yours,...gu.where];function cH({sessionId:e,entryCount:t}){let{state:n,actions:r}=K(),i=n.chatAboutsChange,a=ql(n.settings??{}),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(!1),[y,b]=(0,v.useState)(null),[x,S]=(0,v.useState)(null),C=(0,v.useRef)(i.seq),w=(0,v.useRef)(!0);(0,v.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let T=(0,v.useCallback)(async()=>{let t=await r.getChatAbout(e);if(w.current){if(t===`unsupported`){l(!0);return}t!==null&&(l(!1),s(t))}},[r,e]);if((0,v.useEffect)(()=>{T()},[T]),(0,v.useEffect)(()=>{i.seq!==C.current&&(C.current=i.seq,au(i,e)&&T())},[i,e,T]),c||o===null)return null;let E=()=>{p(o.about??``),d(!0),S(null),b(null)},D=async()=>{if(mu(f))return;let t=f.trim()===``;h(!0);try{let n=await r.updateChatAbout(e,t?null:f);if(!w.current||!n)return;s(n),d(!1),S(t?a.enabled?`Cleared. The housekeeper writes a new about at the chat’s next change.`:`Cleared. None is written while chat abouts are off.`:null)}finally{w.current&&h(!1)}},O=async()=>{_(!0),b(null),S(null);try{let t=await r.regenerateChatAbout(e);if(!w.current)return;t.about&&s(t.about),t.ok||b(t.error??`The about could not be written.`)}finally{w.current&&_(!1)}},k=hu(f,a.maxWords),A=mu(f),j=ou(o);return(0,G.jsxs)(`div`,{className:`mb-2`,"data-testid":`session-about`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:(0,G.jsx)(J.Info,{className:`w-3.5 h-3.5`})}),`About`,(0,G.jsx)(Ly,{label:`About`,details:(0,G.jsx)(Ry,{items:sH})}),o.stale&&o.about?(0,G.jsx)(`span`,{title:gu.stale,"data-testid":`session-about-stale`,children:(0,G.jsx)(Q,{tone:`warn`,children:`stale`})}):null]}),u?(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`textarea`,{className:W(Z,`min-h-[7rem] resize-y text-xs`),value:f,onChange:e=>p(e.target.value),"aria-label":`This chat’s about`,placeholder:`What this chat works on, for your other chats to read`,autoFocus:!0,"data-testid":`session-about-input`}),(0,G.jsxs)(`div`,{className:W(`text-[11px]`,k.overChars?`text-danger`:k.overWords?`text-warn`:`text-fg-faint`),"data-testid":`session-about-count`,children:[k.words,` / `,a.maxWords,` words · `,k.chars.toLocaleString(`en-US`),` /`,` `,Gl.userChars.toLocaleString(`en-US`),` characters`]}),A?(0,G.jsx)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-problem`,children:A}):k.overWords?(0,G.jsxs)(`div`,{className:`text-[11px] text-warn`,children:[`Longer than the `,a.maxWords,` words the housekeeper writes; your other chats read all of it.`]}):null,(0,G.jsx)(`div`,{className:`text-[11px] text-fg-faint`,children:`Saved empty, it is cleared, and the housekeeper writes one again at the chat’s next change.`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>void D(),busy:m,disabled:A!==null,"data-testid":`session-about-save`,children:`Save`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>d(!1),disabled:m,"data-testid":`session-about-cancel`,children:`Cancel`})]})]}):(0,G.jsxs)(G.Fragment,{children:[o.about?(0,G.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-fg`,"data-testid":`session-about-text`,children:o.about}):(0,G.jsxs)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`session-about-missing`,children:[`No about yet. `,fu(o,{enabled:a.enabled,entryCount:t})]}),o.about&&o.aboutAt?(0,G.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:ng(o.aboutAt),"data-testid":`session-about-written`,children:[`Written `,eg(o.aboutAt),j?` by ${j}`:``]}):null,o.about&&o.pending?(0,G.jsx)(`div`,{className:`text-[11px] text-accent`,children:`Being written again now…`}):null,o.about&&o.lastError?(0,G.jsxs)(`div`,{className:`text-[11px] text-danger`,"data-testid":`session-about-last-error`,children:[`The last attempt failed: `,o.lastError]}):null,(0,G.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,title:o.route?`Paid by ${su[o.route]}`:void 0,"data-testid":`session-about-spend`,children:[`Cost so far: `,uu(o.spend,o.route)]}),x?(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-muted`,"data-testid":`session-about-note`,children:x}):null,y?(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] text-danger`,role:`alert`,"data-testid":`session-about-regen-error`,children:y}):null,(0,G.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5`,children:[(0,G.jsxs)(Y,{size:`sm`,variant:`ghost`,onClick:E,disabled:g,title:gu.edit,"data-testid":`session-about-edit`,children:[(0,G.jsx)(J.Edit,{className:`h-3 w-3`}),` Edit`]}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>void O(),disabled:!a.enabled||g,title:a.enabled?gu.regenerate:gu.regenerateOff,"data-testid":`session-about-regenerate`,children:g?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(J.Spinner,{className:`h-3 w-3`}),` Writing…`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(J.Refresh,{className:`h-3 w-3`}),` Regenerate`]})})]}),a.enabled?null:(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] text-fg-faint`,"data-testid":`session-about-off`,children:`Regenerate is unavailable: chat abouts are off.`})]})]})}function lH({view:e}){let t=(0,v.useMemo)(()=>FB(e.request??``),[e.request]);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[11px] text-fg-faint`,children:e.truncated?`Cut at the size the host keeps.`:`As agy sent it.`}),(0,G.jsx)(qM,{text:t})]}),(0,G.jsx)(`pre`,{className:`mt-0.5 max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md border border-border bg-code-bg p-2 font-mono text-[11px] leading-snug text-fg`,"data-testid":`agy-request-json`,children:t})]})}function uH({sessionId:e,running:t}){let{api:n}=K(),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(!1),[p,m]=(0,v.useState)({}),h=(0,v.useRef)(!0);(0,v.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=(0,v.useCallback)(async()=>{if(!n.listAgyRequests){o(!0);return}c(!0);try{let t=await n.listAgyRequests(e);if(!h.current)return;o(!1),i(t.requests)}catch(e){if(!h.current)return;gm(e)&&o(!0)}finally{h.current&&c(!1)}},[n,e]);(0,v.useEffect)(()=>{g()},[g]);let _=(0,v.useRef)(t);(0,v.useEffect)(()=>{_.current&&!t&&g(),_.current=t},[t,g]);let{main:y,background:b}=(0,v.useMemo)(()=>OB(r??[]),[r]),x=async t=>{if(p[t.id]){m(e=>{let{[t.id]:n,...r}=e;return r});return}m(e=>({...e,[t.id]:{phase:`loading`}}));let r=e=>{h.current&&m(n=>n[t.id]?{...n,[t.id]:e}:n)};if(!n.getAgyRequestBody)return r({phase:`gone`});try{let i=await n.getAgyRequestBody(e,t.id);r(i.request===null?{phase:`gone`}:{phase:`ready`,view:i})}catch(e){r(gm(e)?{phase:`gone`}:{phase:`failed`,message:lg(e)})}};if(a||r===null)return null;let S=e=>{let{title:t,detail:n}=kB(e),r=jB(e),i=NB(e.usage),a=p[e.id],o=[n,e.ms===null?`running…`:Qh(e.ms),i].filter(e=>!!e),s=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-fg-faint`,title:ng(e.at),children:PB(e.at)}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-fg`,children:t}),(0,G.jsx)(`span`,{className:W(`shrink-0 text-[11px] font-medium`,r.tone===`danger`?`text-danger`:`text-fg-muted`),"data-tone":r.tone,"data-testid":`agy-request-status-${e.id}`,children:r.text})]}),(0,G.jsx)(`span`,{className:`block break-words text-[11px] text-fg-faint`,children:o.join(` · `)}),e.error?(0,G.jsx)(`span`,{className:`block break-words text-[11px] text-danger`,children:e.error}):null]});return(0,G.jsxs)(`li`,{className:`rounded-md border border-border px-2 py-1`,"data-testid":`agy-request-${e.id}`,"data-kind":e.kind,children:[e.hasBody?(0,G.jsx)(`button`,{type:`button`,className:`block w-full text-left`,"aria-expanded":a!==void 0,title:`${AB(e)} — show the request`,onClick:()=>void x(e),"data-testid":`agy-request-open-${e.id}`,children:s}):(0,G.jsx)(`div`,{title:AB(e),children:s}),a?(0,G.jsx)(`div`,{className:`mt-1`,"data-testid":`agy-request-body-${e.id}`,children:a.phase===`loading`?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-fg-muted`,children:[(0,G.jsx)(J.Spinner,{className:`h-3 w-3`}),` Loading the request…`]}):a.phase===`gone`?(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-request-body-gone`,children:`This request’s body is no longer kept on this PC.`}):a.phase===`failed`?(0,G.jsxs)(`div`,{className:`text-[11px] text-danger`,role:`alert`,children:[`Could not read it: `,a.message]}):(0,G.jsx)(lH,{view:a.view})}):null]},e.id)};return(0,G.jsxs)(`div`,{className:`mb-2`,"data-testid":`agy-requests`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:text-fg-muted`,"aria-expanded":l,onClick:()=>u(e=>!e),"data-testid":`agy-requests-toggle`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:(0,G.jsx)(J.Chevron,{className:`h-3 w-3`,open:l})}),`Google agy requests`,(0,G.jsx)(`span`,{className:`font-mono normal-case tracking-normal`,"data-testid":`agy-requests-count`,children:r.length})]}),(0,G.jsx)(X,{label:`Refresh agy requests`,className:`p-1`,disabled:s,onClick:()=>void g(),"data-testid":`agy-requests-refresh`,children:s?(0,G.jsx)(J.Spinner,{className:`h-3 w-3`}):(0,G.jsx)(J.Refresh,{className:`h-3 w-3`})})]}),(0,G.jsx)(`p`,{className:`mb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`agy-requests-privacy`,children:TB}),l?(0,G.jsxs)(G.Fragment,{children:[y.length===0?(0,G.jsx)(`p`,{className:`text-[11px] text-fg-muted`,"data-testid":`agy-requests-empty`,children:`No model calls yet — they appear here as agy talks to Google.`}):(0,G.jsx)(`ul`,{className:`max-h-72 space-y-1 overflow-y-auto`,"data-testid":`agy-requests-main`,children:y.map(S)}),b.length>0?(0,G.jsxs)(`div`,{className:`mt-1.5`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-[11px] text-accent hover:underline`,"aria-expanded":d,onClick:()=>f(e=>!e),"data-testid":`agy-background-toggle`,children:[(0,G.jsx)(J.Chevron,{className:`h-3 w-3`,open:d}),`background calls (`,b.length,`)`]}),d?(0,G.jsx)(`ul`,{className:`mt-1 max-h-72 space-y-1 overflow-y-auto opacity-70`,"data-testid":`agy-requests-background`,children:b.map(S)}):null]}):null]}):null]})}function dH({label:e,icon:t,children:n}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-faint`,children:[t?(0,G.jsx)(`span`,{className:`shrink-0 text-fg-faint`,"aria-hidden":`true`,children:t}):null,e]}),(0,G.jsx)(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-fg`,children:n})]})}function fH({label:e,icon:t}){return(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:t}),e]})}var pH={provider:(0,G.jsx)(J.Plug,{className:`w-3.5 h-3.5`}),route:(0,G.jsx)(J.Globe,{className:`w-3.5 h-3.5`}),model:(0,G.jsx)(J.Bot,{className:`w-3.5 h-3.5`}),permission:(0,G.jsx)(J.Shield,{className:`w-3.5 h-3.5`}),context:(0,G.jsx)(J.Brain,{className:`w-3.5 h-3.5`}),window:(0,G.jsx)(J.Panel,{className:`w-3.5 h-3.5`}),compactions:(0,G.jsx)(J.CollapseAll,{className:`w-3.5 h-3.5`}),usage:(0,G.jsx)(J.Coins,{className:`w-3.5 h-3.5`}),tokensIn:(0,G.jsx)(J.Download,{className:`w-3.5 h-3.5`}),tokensOut:(0,G.jsx)(J.Upload,{className:`w-3.5 h-3.5`}),duration:(0,G.jsx)(J.Clock,{className:`w-3.5 h-3.5`}),turns:(0,G.jsx)(J.Send,{className:`w-3.5 h-3.5`}),session:(0,G.jsx)(J.Info,{className:`w-3.5 h-3.5`}),status:(0,G.jsx)(J.Monitor,{className:`w-3.5 h-3.5`}),updated:(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`}),entries:(0,G.jsx)(J.Menu,{className:`w-3.5 h-3.5`}),project:(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5`}),folder:(0,G.jsx)(J.Folder,{className:`w-3.5 h-3.5`})};function mH({used:e}){let t=Math.round(e*100);return(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-3`,role:`progressbar`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":`Context used`,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full`,t>=90?`bg-danger`:t>=70?`bg-warn`:`bg-accent`),style:{width:`${t}%`}})})}function hH(){let{state:e,actions:t}=K(),n=Ty(),r=n?e.remote.tabs[n.id]!==void 0:!1,i=n?e.drafts[n.id]!==void 0:!1,a=wy(),o=e.currentSessionId,s=n?.projectId?e.vaultProjects.find(e=>e.id===n.projectId):void 0,c=s?.instructions.trim()??``,l=n?.providerId??e.activeProviderId,u=e.providers.find(e=>e.definition.id===l),d=u?.definition.models??(l?e.models[l]?.models:void 0),f=(0,v.useMemo)(()=>{let e=u?.definition;return e?js(e,{credentialClass:(u.credentials.find(e=>e.variantId===n?.variantId)??u.credentials[0])?.class??null}):null},[u,n?.variantId]),p=(0,v.useMemo)(()=>oH({items:a?.items??[],session:n,initModel:a?.init?.model??null,boundary:o?e.modelBoundaries[o]??null:null,models:d,contextTokens:a?.contextTokens??null}),[a?.items,a?.init?.model,a?.contextTokens,n,o,e.modelBoundaries,d]),m=(0,v.useMemo)(()=>(a?.items??[]).filter(e=>e.kind===`user`&&e.compactSummary).length,[a?.items]),h=n?Yp(n.providerId)&&!r&&!i:!1,g=a?.status===`running`||a?.status===`waiting_permission`;return(0,G.jsxs)(`aside`,{className:`flex w-72 shrink-0 flex-col border-l border-border bg-surface`,"aria-label":`Session info`,"data-testid":`session-panel`,children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,G.jsx)(J.Info,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`span`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:`Session info`}),(0,G.jsx)(X,{label:`Hide session info`,className:`p-1`,onClick:()=>void t.savePrefs({sessionPanelOpen:!1}),children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]}),n?(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 py-2`,children:[p.didReset?(0,G.jsxs)(`div`,{className:`mb-2 rounded-md bg-accent-soft px-2 py-1.5 text-[11px] text-accent`,"data-testid":`stats-reset`,children:[`Statistics restarted at the model change`,p.previousModel?` (was ${p.previousModel})`:``,`.`]}):null,!r&&!i?(0,G.jsx)(cH,{sessionId:n.id,entryCount:n.entryCount??null},n.id):null,(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(fH,{label:`Model`,icon:pH.model}),(0,G.jsx)(dH,{label:`Provider`,icon:pH.provider,children:u?.definition.displayName??l??`—`}),(0,G.jsx)(dH,{label:`Route`,icon:pH.route,children:f?(0,G.jsx)(Q,{tone:f.viaGateway?`accent`:`ok`,children:f.badge}):`—`}),f?(0,G.jsx)(`div`,{className:`pb-1 text-[11px] leading-snug text-fg-faint`,children:f.detail}):null,(0,G.jsx)(dH,{label:`Model`,icon:pH.model,children:p.model??n.model??`—`}),(0,G.jsxs)(dH,{label:`Permission mode`,icon:pH.permission,children:[(0,G.jsx)(Q,{children:te(ne(n))}),` `,(0,G.jsx)(Q,{children:n.permissionMode})]})]}),(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(fH,{label:`Context`,icon:pH.context}),p.contextUsed!==null&&p.contextTokens!==null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(mH,{used:p.contextUsed}),(0,G.jsxs)(`div`,{className:`mt-1 text-[11px] text-fg-muted`,"data-testid":`context-used`,children:[$h(p.contextTokens),` / `,$h(p.contextWindow??0),` `,`tokens (`,Math.round(p.contextUsed*100),`%)`]})]}):(0,G.jsx)(`div`,{className:`text-[11px] text-fg-muted`,"data-testid":`context-used`,children:p.contextTokens===null?`Measured at the next reply`:`${$h(p.contextTokens)} tokens (window unknown)`}),(0,G.jsx)(dH,{label:`Context window`,icon:pH.window,children:(0,G.jsx)(`span`,{"data-testid":`context-window`,children:p.contextWindow?`${$h(p.contextWindow)} tokens`:`unknown`})}),(0,G.jsx)(dH,{label:`Compactions`,icon:pH.compactions,children:(0,G.jsx)(`span`,{"data-testid":`compaction-count`,children:m})})]}),(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(fH,{label:`Usage`,icon:pH.usage}),(0,G.jsx)(dH,{label:`Tokens in`,icon:pH.tokensIn,children:$h(p.inputTokens)}),(0,G.jsx)(dH,{label:`Tokens out`,icon:pH.tokensOut,children:$h(p.outputTokens)}),p.credits===null?null:(0,G.jsx)(dH,{label:`Credits used`,icon:pH.usage,children:p.credits.toLocaleString(`en-US`,{maximumFractionDigits:2})}),(0,G.jsx)(dH,{label:`Duration`,icon:pH.duration,children:p.countedResults>0&&Qh(p.durationMs)||`—`}),(0,G.jsx)(dH,{label:`Turns`,icon:pH.turns,children:p.countedResults>0?p.turns:`—`})]}),(0,G.jsxs)(`div`,{className:`mb-2`,children:[(0,G.jsx)(fH,{label:`Session`,icon:pH.session}),(0,G.jsx)(dH,{label:`Status`,icon:pH.status,children:(0,G.jsx)(Q,{tone:a?.status===`error`?`danger`:a?.status===`running`?`accent`:a?.status===`waiting_permission`?`warn`:`neutral`,children:a?.status??n.status})}),(0,G.jsx)(dH,{label:`Updated`,icon:pH.updated,children:eg(n.updatedAt)}),(0,G.jsx)(dH,{label:`Entries`,icon:pH.entries,children:n.entryCount}),(0,G.jsx)(dH,{label:`Project`,icon:pH.project,children:(0,G.jsx)(`span`,{"data-testid":`session-project`,children:s?s.name:`—`})}),c?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words pb-1 text-[11px] leading-snug text-fg-faint`,"data-testid":`session-project-instructions`,children:c.length>300?`${c.slice(0,300)}\u2026`:c}):null,r?null:(0,G.jsx)(`button`,{type:`button`,className:`text-[11px] text-accent hover:underline`,onClick:()=>t.openAssignProject(n.id),"data-testid":`session-change-project`,children:s?`Move to another project…`:`Move to a project…`}),(0,G.jsx)(dH,{label:`Folder`,icon:pH.folder,children:n.projectDir?`project`:`own workspace`}),(0,G.jsx)(`div`,{className:`mt-1 break-all font-mono text-[10px] text-fg-faint`,"data-testid":`session-folder`,children:n.cwd}),r?null:(0,G.jsx)(`button`,{type:`button`,className:`mt-1 text-[11px] text-accent hover:underline`,onClick:()=>t.openDialog(`project`),"data-testid":`session-change-folder`,children:`Change folder…`})]}),h?(0,G.jsx)(uH,{sessionId:n.id,running:g},n.id):null,r?null:(0,G.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`session-scheduled-tasks`,children:[(0,G.jsx)(fH,{label:`Scheduled tasks`,icon:pH.session}),(0,G.jsx)(BN,{sessionId:n.id})]}),a?.init?(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[`engine `,a.init.claudeCodeVersion,` · `,a.init.tools.length,` tools`]}):null]}):(0,G.jsx)(`div`,{className:`p-4 text-xs text-fg-faint`,children:`Open a chat to see its statistics.`})]})}function gH(e){let t=e=>e.type===`dir`?0:1;return[...e].sort((e,n)=>t(e)-t(n)||e.name.localeCompare(n.name))}function _H(e){let t=[];return e.target.type===`file`&&t.push({key:`open`,label:`Open`,icon:(0,G.jsx)(J.File,{className:`w-3.5 h-3.5`}),onSelect:e.onOpen,testId:`files-menu-open`}),t.push({key:`copy-path`,label:`Copy path`,icon:(0,G.jsx)(J.Copy,{className:`w-3.5 h-3.5`}),disabled:!e.canCopyPath,onSelect:e.onCopyPath,testId:`files-menu-copy-path`},{key:`copy-relative-path`,label:`Copy relative path`,icon:(0,G.jsx)(J.Copy,{className:`w-3.5 h-3.5`}),onSelect:e.onCopyRelativePath,testId:`files-menu-copy-relative-path`}),!e.remote&&e.canDelete&&t.push({key:`delete`,label:`Delete…`,icon:(0,G.jsx)(J.Trash,{className:`w-3.5 h-3.5`}),danger:!0,separated:!0,onSelect:e.onDelete,testId:`files-menu-delete`}),t}function vH(e,t){return t instanceof fm&&t.status===404&&/^no route for /.test(t.message)?`This host is too old to delete files — update it from the title bar.`:`Could not delete ${lj(e.path)}: ${t instanceof Error?t.message:String(t)}`}function yH(){let{state:e,dispatch:t,actions:n,api:r}=K(),i=Ty(),a=wy(),o=i?.id??null,s=o?e.remote.tabs[o]!==void 0:!1,c=a?.status===`running`||a?.status===`waiting_permission`,l=o?e.files[o]?.active??null:null,u=e.info?.platform??null,d=i?.cwd??``,[f,p]=(0,v.useState)({}),[m,h]=(0,v.useState)(()=>new Set),[g,_]=(0,v.useState)(!1),y=(0,v.useRef)(f);y.current=f;let b=(0,v.useRef)(m);b.current=m;let x=(0,v.useRef)(o);x.current=o;let S=(0,v.useRef)(e.files);S.current=e.files;let[C,w]=(0,v.useState)(null),T=(0,v.useCallback)(()=>w(null),[]),E=(0,v.useCallback)((e,t,n)=>w({target:e,at:t,el:n}),[]),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(!1),j=(0,v.useCallback)(()=>O(null),[]),M=(0,v.useCallback)(async e=>{if(!o||!r.listSessionFiles)return;let t=o;p(t=>({...t,[e]:{...t[e]??{entries:null},loading:!0,error:null}}));try{let n=await r.listSessionFiles(t,e);if(x.current!==t)return;_(!1),p(t=>({...t,[e]:{entries:gH(n.entries),loading:!1,error:null}}))}catch(n){if(x.current!==t)return;gm(n)&&_(!0);let r=n instanceof Error?n.message:String(n);p(t=>({...t,[e]:{entries:t[e]?.entries??null,loading:!1,error:r}}))}},[r,o]);(0,v.useEffect)(()=>{p({}),h(new Set),_(!1),w(null),O(null),o&&!s&&M(``)},[o,s,M]);let N=(0,v.useRef)(c);(0,v.useEffect)(()=>{if(N.current&&!c&&o&&!s)for(let e of Object.keys(y.current))(e===``||b.current.has(e))&&M(e);N.current=c},[c,o,s,M]);let ee=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),y.current[e]?.entries||M(e)),n})},te=()=>{if(o){M(``);for(let e of m)M(e)}},P=(e,t)=>{KM(e).then(e=>n.toast(e?`success`:`error`,e?t:`Could not copy to the clipboard`))},F=async()=>{let e=D,i=o;if(!(!e||!i||!r.deleteSessionFile)){A(!0);try{await r.deleteSessionFile(i,e.path);for(let n of S.current[i]?.open??[])fj(n,e.path)&&t({type:`file_close`,sessionId:i,path:n});x.current===i&&(h(t=>new Set([...t].filter(t=>!fj(t,e.path)))),p(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!fj(t,e.path)))),M(dj(e.path))),n.toast(`success`,`Deleted ${lj(e.path)}`)}catch(t){n.toast(`error`,vH(e,t)),x.current===i&&M(dj(e.path))}finally{A(!1),O(null)}}},ne=C?_H({target:C.target,remote:s,canDelete:typeof r.deleteSessionFile==`function`,canCopyPath:d!==``,onOpen:()=>n.openFile(C.target.path),onCopyPath:()=>P(hj(d,C.target.path,u),`Path copied`),onCopyRelativePath:()=>P(mj(C.target.path,pj(d,u)),`Relative path copied`),onDelete:()=>O(C.target)}):[],re=()=>void n.savePrefs({explorerOpen:!1}),ie=i?.cwd?lj(i.cwd)||i.cwd:`Files`,I=f[``],L=C?.target.path??null,R=(0,v.useMemo)(()=>o?s?(0,G.jsx)(xH,{children:`This chat runs on another PC; its files can be browsed there.`}):g?(0,G.jsx)(xH,{children:`This host is too old to list files — update it from the title bar.`}):I?.error&&!I.entries?(0,G.jsx)(xH,{tone:`danger`,children:I.error}):I?.entries?I.entries.length===0?(0,G.jsx)(xH,{children:`The folder is empty.`}):(0,G.jsx)(`ul`,{role:`tree`,"aria-label":`Workspace files`,className:`py-1`,children:(0,G.jsx)(wH,{rel:``,depth:0,tree:f,expanded:m,activeFile:l,menuPath:L,onToggle:ee,onOpen:e=>n.openFile(e),onMenu:E})}):(0,G.jsx)(xH,{children:`Listing…`}):(0,G.jsx)(xH,{children:`Open a chat to browse the folder it works in.`}),[o,s,g,I,f,m,l,L,n]);return(0,G.jsxs)(`aside`,{className:`flex w-64 shrink-0 flex-col border-r border-border bg-surface`,"aria-label":`Files`,"data-testid":`file-explorer`,children:[(0,G.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,G.jsx)(J.Folder,{className:`w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-semibold uppercase tracking-wide text-fg-muted`,title:i?.cwd??void 0,children:ie}),(0,G.jsx)(X,{label:`Refresh files`,className:`p-1`,onClick:te,disabled:!o||s,"data-testid":`file-explorer-refresh`,children:(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(X,{label:`Hide files`,className:`p-1`,onClick:re,children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:R}),(0,G.jsx)(Zb,{open:C!==null,at:C?.at??{x:0,y:0},anchorEl:C?.el??null,label:`File actions`,testId:`files-context-menu`,onClose:T,items:ne}),(0,G.jsx)(bH,{target:D,absolute:D?d?hj(d,D.path,u):D.path:``,platform:u,busy:k,onConfirm:()=>void F(),onClose:j})]})}function bH({target:e,absolute:t,platform:n,busy:r,onConfirm:i,onClose:a}){let o=e?.type===`dir`;return(0,G.jsx)(Vy,{open:e!==null,title:o?`Delete this folder?`:`Delete this file?`,onClose:a,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:a,disabled:r,"data-testid":`files-delete-cancel`,children:`Cancel`}),(0,G.jsx)(Y,{variant:`danger`,busy:r,onClick:i,"data-testid":`files-delete-confirm`,children:`Delete permanently`})]}),children:(0,G.jsxs)(`div`,{className:`space-y-2 text-sm text-fg-muted`,"data-testid":`files-delete-dialog`,children:[(0,G.jsx)(`p`,{className:`break-all rounded bg-surface-2 px-2 py-1 font-mono text-xs text-fg`,children:t}),(0,G.jsxs)(`p`,{children:[o?`This folder and everything inside it will be deleted from the disk permanently.`:`This file will be deleted from the disk permanently.`,` `,`It does not go to the `,n===`win32`?`Recycle Bin`:`Trash`,`, and it cannot be undone.`]})]})})}function xH({children:e,tone:t}){return(0,G.jsx)(`div`,{className:W(`p-4 text-xs`,t===`danger`?`text-danger`:`text-fg-faint`),children:e})}function SH(e){let t=e.getBoundingClientRect();return{x:t.left+24,y:t.bottom}}function CH(e,t){return{onContextMenu:n=>{n.preventDefault();let r=n.currentTarget;t(e,n.clientX===0&&n.clientY===0?SH(r):{x:n.clientX,y:n.clientY},r)},onKeyDown:n=>{(n.key===`ContextMenu`||n.shiftKey&&n.key===`F10`)&&(n.preventDefault(),t(e,SH(n.currentTarget),n.currentTarget))}}}function wH({rel:e,depth:t,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c}){let l=n[e];return l?l.error&&!l.entries?(0,G.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-danger`,style:{paddingLeft:`${.5+t*.75}rem`},children:l.error}):l.entries?(0,G.jsx)(G.Fragment,{children:l.entries.map(l=>{let u=uj(e,l.name),d=a===u;if(l.type===`dir`){let e=r.has(u);return(0,G.jsxs)(`li`,{role:`treeitem`,"aria-expanded":e,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(u),...CH({path:u,type:`dir`},c),"data-testid":`explorer-dir-${u}`,className:W(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs text-fg hover:bg-surface-2`,d&&`bg-surface-2`),style:{paddingLeft:`${.5+t*.75}rem`},children:[(0,G.jsx)(J.ChevronRight,{className:W(`w-3 h-3 shrink-0 text-fg-faint transition-transform`,e&&`rotate-90`)}),(0,G.jsx)(J.Folder,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,G.jsx)(`span`,{className:`truncate`,children:l.name})]}),e?(0,G.jsx)(`ul`,{role:`group`,children:(0,G.jsx)(wH,{rel:u,depth:t+1,tree:n,expanded:r,activeFile:i,menuPath:a,onToggle:o,onOpen:s,onMenu:c})}):null]},u)}let f=i===u;return(0,G.jsx)(`li`,{role:`treeitem`,"aria-selected":f,children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>s(u),...CH({path:u,type:l.type},c),disabled:l.type!==`file`,"data-testid":`explorer-file-${u}`,title:`${u} · ${Pj(l.size)}`,className:W(`flex w-full items-center gap-1 py-0.5 pr-2 text-left text-xs hover:bg-surface-2 disabled:opacity-50`,f?`bg-accent-soft text-accent`:d?`bg-surface-2 text-fg`:`text-fg`),style:{paddingLeft:`${.5+t*.75+.9}rem`},children:[(0,G.jsx)(J.File,{className:`w-3.5 h-3.5 shrink-0 text-fg-faint`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:l.name}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-faint`,children:Pj(l.size)})]})},u)})}):(0,G.jsx)(`li`,{className:`px-2 py-1 text-[11px] text-fg-faint`,style:{paddingLeft:`${.5+t*.75}rem`},children:`Listing…`}):null}var TH={autoAccept:{hint:`Allow every tool the agent wants to use, without asking you. Off by default.`,details:[`Answered by this PC itself, so it covers EVERY chat running here — started in this app, the oona terminal, your phone, Telegram, the website or another PC.`,`The agent’s questions to you (its multiple-choice cards) still wait for your answer.`,`A chat set to Ask first in the composer still asks you before each tool — that is what Ask first means.`,`Subagents never ask: their tool requests are always allowed.`,`Takes effect at the next tool request, even in a chat that is already working.`,`What a chat may attempt at all is still its own Build / Plan / Ask first / Autonomous choice in the composer; this only answers the prompts it would have shown you.`]},reasoning:{hint:`Show the model’s thinking between its messages.`,details:[`Display only — the model thinks the same either way.`,`Hidden thinking is also left out of chat search (Ctrl+F).`,`For the windows this PC serves (this app, the local web UI). The phone has its own switch.`]},colourScheme:{hint:`System follows your desktop’s light or dark setting.`,details:[`Also colours this window’s title bar and menu.`,`Your own colours per element are under Theme.`]},notifications:{hint:`Desktop notifications from this app while its window is not in front.`,details:[`Nothing pops up while you are looking at the window.`,`Your phone’s push notifications are separate: the phone buzzes only while no window on this PC is open.`]},notifyFinished:{hint:`When a chat’s turn ends — finished, or failed.`,details:[`Named after the chat; clicking the notification opens it.`]},notifyWaiting:{hint:`When a chat waits for you: a permission, or one of the agent’s questions.`,details:[`With auto-accept on, only the agent’s questions still wait for you, so only they notify.`]},notifyError:{hint:`When a chat stops on an error.`,details:[`The error itself is also written into the chat.`]},transcriptWindow:{hint:`How many messages and tool cards of a chat stay drawn; older ones leave the top like a stack and come back when you scroll up.`,details:[`Only what is DRAWN: the whole chat is still kept, and still searched.`,`Smaller is faster on long agentic chats; larger keeps more on screen.`]},defaultCwd:{hint:`The folder a new chat runs in when it is not given one. Empty: each chat gets its own private folder.`,details:[`A folder here becomes each new chat’s project: its CLAUDE.md, .claude settings, hooks and skills load. Your home folder and drive roots never load as a project.`,`Empty is the safe default: the agent then works only inside that chat’s own folder under OonaCode’s data directory.`,`Used by chats started in this app. A project’s own folder (Projects → New chats) wins over it; the oona terminal always uses the folder you run it in.`]},remoteAccess:{hint:`Let your phone, Telegram, the website and your other PCs reach this PC.`,details:[`This PC keeps one outbound, end-to-end encrypted channel to your OonaCode server; every other device reaches it through that channel alone.`,`It is also how they read this PC’s chats: the chats are kept only here, never on our server, so they can be read while this PC is on and reachable.`,`Off: they still see this PC online, marked “remote access off”, and cannot list or open its chats, send prompts, unlock it remotely or delete its chats. This PC also cannot open chats on your other PCs.`,`Takes effect immediately.`]},imageRetention:{hint:`Pictures in this PC’s chat history older than this are replaced with a short note. 0 keeps them forever. Default: a year.`,details:[`Replaced: the pictures stored in this PC’s chats — screenshots and other pictures a tool returned, and pictures you pasted into a message — once they are older than this.`,`Each becomes a one-line note saying a picture was there, why and when it went, e.g. “[Picture removed after 365 days to save space — picture from a tool (PNG), 412 KB]”.`,`Not affected: the words of every chat, and the files on your disk. The chat continues normally — the model no longer needs pictures that old.`,`Runs by itself: a few minutes after this PC’s OonaCode starts, then once a day, in small steps that never hold up a chat. A chat that is working, or was in the last hour, is done at the next run.`,`The database file stops growing from pictures; it does not shrink. The space is reused for new chats.`,`Only this PC holds its chats, so this is every copy there is.`]},chatAbout:{hint:`A short note per chat saying what it works on, which your other chats read through “Talk to other chats”. On by default.`,details:[`Written in the background by each chat’s housekeeper — the cheap helper model of the chat’s own provider — after a turn ends, only when the chat changed since, and at most once per interval below.`,`The same switch covers Regenerate (in a chat’s session info) and “Generate for all chats now” (View → What chats are about…). Off stops all three, so nothing is spent on abouts.`,`Paid by the chat’s own route: an OonaCode pool chat spends credits, your own API key is billed by your provider, and your own subscription’s plan covers it.`,`An about is part of its chat and stays on this PC: it is never uploaded to our server, and your other devices read it from this PC, like the chat.`]},chatAboutInterval:{hint:`At most one background about per chat in this many minutes.`,details:[`Only the background job waits for it: Regenerate and “Generate for all chats now” write at once.`,`A background about is written only after a turn ends and only when the chat changed, so a chat nobody uses costs nothing, whatever this says.`,`Shorter keeps abouts fresher and makes more calls.`]},chatAboutMaxWords:{hint:`The longest about the housekeeper may write.`,details:[`A longer answer is cut at this many words.`,`Applies to every about the housekeeper writes: in the background, by Regenerate and by “Generate for all chats now”. An about you write yourself may be longer (up to 2,000 characters).`,`A longer about costs a few more output tokens, and a chat that lists your chats reads every one of them.`]},chatAboutInputChars:{hint:`How much of a chat the housekeeper reads to write its about.`,details:[`Taken from the chat’s title, project and folder, its previous about, your first message, the newest summary of the earlier conversation, your latest messages and the agent’s last answer — each with a share, so no part crowds out the others.`,`Applies to the background job, Regenerate and “Generate for all chats now”.`,`Most of what a call costs: roughly a quarter as many tokens as characters. More gives a better-informed about and costs more.`]},keepUnlocked:{hint:`Leave your vault unlocked when you close or quit the app.`,details:[`Off (default): closing the window — to the tray too — or quitting stops the chats that are running and locks this PC until you unlock it. Your phone and other devices cannot use it meanwhile.`,`On: chats keep running and your other devices keep working after the window is closed. Choose it on a PC only you use.`]},server:{hint:`Your account’s OonaCode server.`,details:[`Where your account lives: sign-in, OonaCode-pool models and credits, your encrypted vault and chat history, remote access, and app updates.`,`Your own API keys and subscriptions never go through it — this PC calls those providers directly.`,`Set by signing in. (Developers point a build at another server with OONACODE_GATEWAY_URL.)`]},diagnostics:{hint:`While you are signed in, this PC sends OonaCode its warnings and errors, and a short report of any turn that fails.`,details:[`A report names the error, the model and the provider — never the content of your chats.`,`It is how bugs you never reported get fixed. There is no usage tracking.`]},allowDebugging:{hint:`Let a debugger attach to this app’s windows, to see and control them while fixing a bug. Off by default. Takes effect when OonaCode restarts.`,details:[`For finding bugs together: DevTools (chrome://inspect), Playwright or another Chrome DevTools Protocol client attaches to every window of this app — reads what it shows, clicks, types and runs code in it.`,`The risk: while it is on, ANY program on this PC can do the same — read your chats on screen and act as you in OonaCode, with no prompt. Turn it on only while you need it.`,`Only on this PC: the port is opened on 127.0.0.1, never on the network, and web pages in your browser cannot connect to it.`,`Desktop app only, this PC only: the local web UI in a browser, the phone, Telegram and your other PCs are not affected.`,`Read when the app starts, so a change applies at the next start (Restart now). The host service and your chats keep running through the restart.`,`While it is on, every window shows a red “Debugging on” badge and says so in its title.`]},debugPort:{hint:`The port on 127.0.0.1 a debugger connects to.`,details:[`Connect with http://127.0.0.1:<port> — e.g. chrome://inspect → Configure… → localhost:<port>, or Playwright’s connectOverCDP.`,`A port another program already uses is refused when you save.`,`With “Also debug the main process”, the next port is taken too.`]},debugMainProcess:{hint:`Also open Node’s inspector for the app’s main process, on the next port.`,details:[`For bugs in the desktop shell itself (windows, menus, updates, the tray), not in a window’s page.`,`Gives full control of the main process — it can run any program as you. Off unless you choose it.`,`Applies only while “Allow debugging” is on, at the next start.`]}};function EH(e){if(!bc(e))return`Off in this run: no debugging port is open.`;let t=[];return e.port!==null&&t.push(e.listening?`On in this run: windows on 127.0.0.1:${e.port}${e.fromCommandLine?` (from the command line)`:``}.`:`Port ${e.port} could not be opened — another program may be using it.`),e.inspectPort!==null&&t.push(e.inspectProblem?`Main-process inspector: ${e.inspectProblem}`:`Main process on 127.0.0.1:${e.inspectPort}.`),t.join(` `)}function DH(e){return xc(e.saved,e.running)}function OH(e){return`Debugging is on: ${Sc(e)}. While it is on, any program on this PC can read and control OonaCode. Click to change it in Settings → Developer.`}function kH({providerId:e,configured:t}){let{api:n,state:r,actions:i}=K(),[a,o]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(t||!n.getAgyStatus)return;let e=!0;return n.getAgyStatus().then(t=>{e&&o({state:t.state,install:t.install})},()=>{e&&o(null)}),()=>{e=!1}},[n,t,r.providers]),(0,G.jsx)(Y,{size:`sm`,variant:t?`secondary`:`primary`,onClick:()=>i.openProviderConnect(e),"data-testid":`agy-provider-button`,children:JB(t,a)})}function AH(){let{actions:e}=K(),[t,n]=(0,v.useState)(void 0),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(null),s=(0,v.useCallback)(async()=>{n(await e.listSkills())},[e]);return(0,v.useEffect)(()=>{s()},[s]),t===`unsupported`?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`This PC’s OonaCode is older than skills — update it to manage them here.`}):r?(0,G.jsx)(jH,{onDone:()=>{i(!1),iF(),uN(),s()}}):(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-section`,children:[(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Skills every chat on this PC gets — type `,(0,G.jsx)(`span`,{className:`font-mono`,children:`/`}),` in the message box to use one for that message. They work with every model. A change applies from a chat’s next start (a new chat, or one idle for ten minutes).`]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-per-chat-note`,children:[`The model is not shown them on its own: each chat chooses which skills the model may use by itself, in the `,(0,G.jsx)(`span`,{className:`font-medium`,children:`Skills`}),` menu under its message box — only those cost tokens on every message of that chat.`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Y,{size:`sm`,onClick:()=>i(!0),"data-testid":`skills-import-open`,children:[(0,G.jsx)(J.Download,{className:`h-3.5 w-3.5`}),` Import from Claude Code…`]}),t?(0,G.jsx)(`span`,{className:`truncate text-[11px] text-fg-faint`,title:t.dir,children:t.dir}):null]}),t===void 0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Loading…`}):t===null?(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not list the skills right now.`}):t.skills.length===0?(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-empty`,children:[`No skills of your own yet. Import them from Claude Code, or put a folder with a`,` `,(0,G.jsx)(`span`,{className:`font-mono`,children:`SKILL.md`}),` in the folder above.`]}):(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.skills.map(t=>(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2 text-sm`,"data-testid":`skill-row`,"data-name":t.name,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,t.name]}),t.argumentHint?(0,G.jsx)(`span`,{className:`font-mono text-xs text-fg-faint`,children:t.argumentHint}):null,t.broken?(0,G.jsx)(Q,{tone:`warn`,children:`no SKILL.md`}):null]}),t.description?(0,G.jsx)(`div`,{className:`line-clamp-2 text-xs text-fg-muted`,title:t.description,children:t.description}):null,(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[Pj(t.bytes),` · `,t.files,` file`,t.files===1?``:`s`,t.importedFrom?(0,G.jsxs)(G.Fragment,{children:[` `,`· imported `,t.importedAt?eg(t.importedAt):``,` from`,` `,(0,G.jsx)(`span`,{title:t.importedFrom,children:t.importedFrom})]}):null]})]}),(0,G.jsxs)(Y,{size:`sm`,variant:`ghost`,busy:a===t.name,"aria-label":`Remove ${t.name}`,onClick:async()=>{o(t.name);let n=await e.removeSkill(t.name);o(null),n&&(iF(),uN(),await s())},"data-testid":`skill-remove`,children:[(0,G.jsx)(J.Trash,{className:`h-3.5 w-3.5`}),` Remove`]})]},t.name))})]})}function jH({onDone:e}){let{actions:t}=K(),[n,r]=(0,v.useState)(void 0),[i,a]=(0,v.useState)(()=>new Set),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=!0;return t.scanClaudeSkills().then(t=>{e&&r(t)}),()=>{e=!1}},[t]);let f=(0,v.useMemo)(()=>{let e=new Map;for(let t of n?.skills??[]){let n=t.origin===`plugin`?`Plugin: ${t.plugin??`?`}`:`Your skills`;e.set(n,[...e.get(n)??[],t])}return[...e.entries()]},[n]),p=e=>a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`skills-import`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:e,children:`← Back`}),(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:`Import skills from Claude Code`})]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Tick the skills to copy into OonaCode. Your Claude Code install is only read — nothing in it is changed.`,n?.roots.length?(0,G.jsxs)(G.Fragment,{children:[` `,`Read from `,(0,G.jsx)(`span`,{className:`font-mono`,children:n.roots.join(`, `)}),`.`]}):null]}),n===void 0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Looking…`}):n===null?(0,G.jsx)(`p`,{className:`text-xs text-danger`,children:`The host could not read Claude Code’s skills.`}):n.skills.length===0?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,"data-testid":`skills-import-empty`,children:`No skills found in Claude Code on this PC.`}):f.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-fg-faint`,children:e}),(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>{let t=!!e.unavailable||e.alreadyInOonaCode&&!o;return(0,G.jsx)(`li`,{className:`px-3 py-1.5 text-sm`,children:(0,G.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i.has(e.key)&&!t,disabled:t,onChange:()=>p(e.key),"data-testid":`skills-import-pick`,"data-name":e.name}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`span`,{className:`font-mono font-medium`,children:[`/`,e.name]}),` `,e.alreadyInOonaCode?(0,G.jsx)(Q,{children:`already in OonaCode`}):null,` `,e.unavailable?(0,G.jsx)(Q,{tone:`warn`,children:e.unavailable}):null,e.description?(0,G.jsx)(`span`,{className:`line-clamp-2 block text-xs text-fg-muted`,children:e.description}):null,e.note?(0,G.jsx)(`span`,{className:`block text-[11px] text-warn`,children:e.note}):null,(0,G.jsxs)(`span`,{className:`block text-[11px] text-fg-faint`,children:[Pj(e.bytes),` · `,e.path]})]})]})},e.key)})})]},e)),n&&n.skills.some(e=>e.alreadyInOonaCode)?(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Replace the ones already in OonaCode`]}):null,u?(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,"data-testid":`skills-import-outcome`,children:u}):null,(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(Y,{variant:`primary`,size:`sm`,busy:c,disabled:i.size===0,"data-testid":`skills-import-go`,onClick:async()=>{l(!0);let n=await t.importClaudeSkills([...i],o);if(l(!1),!n)return;let r=n.skipped.map(e=>`${e.name||e.key}: ${e.reason}`);d(`Imported ${n.imported.length}`+(r.length>0?` · skipped ${r.join(`; `)}`:``)),n.skipped.length===0&&e()},children:[`Import `,i.size>0?i.size:``]}),(0,G.jsx)(Y,{size:`sm`,onClick:e,children:`Cancel`})]})]})}var MH=[{id:`general`,label:`General`,icon:J.Settings},{id:`theme`,label:`Theme`,icon:J.Palette},{id:`advanced`,label:`Advanced`,icon:J.Sliders},{id:`skills`,label:`Skills`,icon:J.Tool},{id:`providers`,label:`Providers`,icon:J.Plug},{id:`devices`,label:`Devices`,icon:J.Monitor},{id:`host`,label:`This PC`,icon:J.Stethoscope},{id:`developer`,label:`Developer`,icon:J.Bug}];function NH(){let e=typeof window<`u`?window.oonacode:void 0;return e?.getDebugging&&e.setDebugging?e:null}function PH(){let{state:e,actions:t}=K(),n=e.prefs,r=e.settings?.theme??`system`;return(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(Hy,{label:`Auto-accept permissions`,hint:TH.autoAccept.hint,details:TH.autoAccept.details,checked:n.autoAcceptPermissions,onChange:e=>void t.savePrefs({autoAcceptPermissions:e}),testId:`settings-auto-accept`}),(0,G.jsx)(Hy,{label:`Show reasoning in the timeline`,hint:TH.reasoning.hint,details:TH.reasoning.details,checked:n.showReasoningSummaries,onChange:e=>void t.savePrefs({showReasoningSummaries:e})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border py-3`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Colour scheme`,(0,G.jsx)(Ly,{label:`Colour scheme`,details:(0,G.jsx)(Ry,{items:TH.colourScheme.details})})]}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-faint`,children:TH.colourScheme.hint})]}),(0,G.jsx)(Uy,{label:`Colour scheme`,value:r,options:[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}],onChange:e=>void t.saveSettings({theme:e})})]}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-2`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:[(0,G.jsx)(J.Bell,{className:`w-3 h-3`}),` Notifications`,(0,G.jsx)(Ly,{label:`Notifications`,details:(0,G.jsx)(Ry,{items:TH.notifications.details})})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-faint`,children:TH.notifications.hint}),(0,G.jsx)(Hy,{label:`Agent finished or needs attention`,hint:TH.notifyFinished.hint,details:TH.notifyFinished.details,checked:n.notifications.agentFinished,onChange:e=>void t.savePrefs({notifications:{...n.notifications,agentFinished:e}})}),(0,G.jsx)(Hy,{label:`Permission or question waiting for you`,hint:TH.notifyWaiting.hint,details:TH.notifyWaiting.details,checked:n.notifications.permissionRequired,onChange:e=>void t.savePrefs({notifications:{...n.notifications,permissionRequired:e}})}),(0,G.jsx)(Hy,{label:`Error occurred`,hint:TH.notifyError.hint,details:TH.notifyError.details,checked:n.notifications.errorOccurred,onChange:e=>void t.savePrefs({notifications:{...n.notifications,errorOccurred:e}})})]}),e.prefsBackend===`local`?(0,G.jsx)(`div`,{className:`mt-2 rounded-md bg-warn-soft px-3 py-2 text-xs text-warn`,children:`This host does not store UI preferences yet, so they are kept on this device only.`}):null]})}function FH(e){let t=e.replace(/-/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function IH(e){let t={};if(typeof document>`u`||typeof getComputedStyle!=`function`)return t;let n=document.documentElement,r=n.getAttribute(`data-theme`),i=[];for(let e of Mc){let t=n.style.getPropertyValue(`--${e}`);t&&i.push([e,t]),n.style.removeProperty(`--${e}`)}n.setAttribute(`data-theme`,e);let a=getComputedStyle(n);for(let e of Mc){let n=a.getPropertyValue(`--${e}`).trim();t[e]=/^#[0-9a-fA-F]{6}$/.test(n)?n.toLowerCase():`#808080`}r===null?n.removeAttribute(`data-theme`):n.setAttribute(`data-theme`,r);for(let[e,t]of i)n.style.setProperty(`--${e}`,t);return t}function LH(){let{state:e,actions:t}=K(),n=e.prefs,[r,i]=(0,v.useState)(`dark`),a=(0,v.useMemo)(()=>IH(r),[r]),[o,s]=(0,v.useState)({}),c=(0,v.useRef)(o);c.current=o;let l=(0,v.useRef)(n.themeColors);l.current=n.themeColors;let u=(0,v.useRef)(null),d=()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)};(0,v.useEffect)(()=>d,[]);let f=e=>{d();let n=c.current;Object.keys(n).length!==0&&(s({}),t.savePrefs({themeColors:{...l.current,[e]:{...l.current[e],...n}}}))},p=(e,t)=>{s(n=>({...n,[e]:t})),c.current={...c.current,[e]:t},d(),u.current=window.setTimeout(()=>f(r),300)},m={...l.current[r],...o},h=Object.keys(m).length,g=e=>{d(),s({});let n={...m};delete n[e],t.savePrefs({themeColors:{...l.current,[r]:n}})};return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:`Theme colours`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-faint`,children:`Choose any colour for any element. A colour you do not choose keeps the theme's own value. Your colours follow your account to every PC.`})]}),(0,G.jsx)(Uy,{label:`Edit colour scheme`,value:r,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:e=>{f(r),i(e)}})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-x-4 sm:grid-cols-2`,children:Mc.map(e=>{let t=m[e]!==void 0,n=m[e]??a[e]??`#808080`;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border py-1.5`,"data-testid":`theme-color-row-${r}-${e}`,children:[(0,G.jsx)(`input`,{type:`color`,className:`h-6 w-9 shrink-0 cursor-pointer rounded border border-border bg-transparent p-0.5`,value:n,onChange:t=>p(e,t.target.value),"aria-label":`${FH(e)} colour (${r} scheme)`,"data-testid":`theme-color-${r}-${e}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:FH(e)}),(0,G.jsx)(`span`,{className:`w-16 shrink-0 text-right font-mono text-[10px] text-fg-faint`,children:t?m[e]:`default`}),t?(0,G.jsx)(X,{label:`Reset ${FH(e)} to the theme colour`,className:`p-0.5`,"data-testid":`theme-color-clear-${r}-${e}`,onClick:()=>g(e),children:(0,G.jsx)(J.Refresh,{className:`w-3 h-3`})}):null]},e)})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border pt-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`theme-colors-count`,children:h===0?`No custom colours in the ${r} scheme.`:`${h} custom colour${h===1?``:`s`} in the ${r} scheme.`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{d(),s({}),t.savePrefs({themeColors:{...l.current,[r]:{}}})},disabled:h===0,"data-testid":`theme-reset-${r}`,children:`Reset all`})]})]})}function RH(){let{state:e,actions:t}=K(),n=e.prefs,[r,i]=(0,v.useState)(String(n.transcriptWindowSize));return(0,v.useEffect)(()=>i(String(n.transcriptWindowSize)),[n.transcriptWindowSize]),(0,G.jsx)(`div`,{className:`space-y-1`,children:(0,G.jsx)(zy,{label:`Transcript window size`,hint:`${TH.transcriptWindow.hint} Scrolling to the top brings back 100 more. 100–${Ac}, default 500.`,details:TH.transcriptWindow.details,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`w-32`),type:`number`,min:100,max:Ac,step:100,value:r,onChange:e=>i(e.target.value),onBlur:()=>{let e=Number.parseInt(r,10);Number.isFinite(e)&&t.savePrefs({transcriptWindowSize:e})},"aria-label":`Transcript window size`}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:`messages and tool cards`})]})})})}function zH(){let{state:e,actions:t}=K(),n=(0,v.useMemo)(()=>ks(e.providers),[e.providers]);return(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[n.length===0?(0,G.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No providers in the registry.`}):null,n.map(n=>{let r=n.definition,i=e.activeProviderId===r.id,a=Os(e.providers,r.id),o=a.some(e=>e.configured),s=[...new Set(a.flatMap(e=>(e.credentials??[]).map(e=>e.class)))].filter(e=>e!==`none`);return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,"data-testid":`provider-${r.id}`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:r.displayName}),i?(0,G.jsx)(Q,{tone:`accent`,children:`active`}):null,r.route===`direct`?(0,G.jsx)(Q,{tone:`ok`,children:`direct`}):null,s.length>0?s.map(e=>(0,G.jsxs)(Q,{tone:`ok`,children:[e===`subscription`?`subscription`:`API key`,` connected`]},e)):o?(0,G.jsx)(Q,{tone:`ok`,children:`connected`}):(0,G.jsx)(Q,{tone:`warn`,children:`not connected`})]}),(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[r.models.length,` model`,r.models.length===1?``:`s`,r.credentialVariants?.length?` · ${r.credentialVariants.map(e=>e.label).join(` / `)}`:``]})]}),r.engine===`agy`?(0,G.jsx)(kH,{providerId:r.id,configured:o}):(0,G.jsxs)(Y,{size:`sm`,variant:o?`secondary`:`primary`,onClick:()=>t.openProviderConnect(r.id),children:[(0,G.jsx)(J.Plus,{className:`w-3 h-3`}),` `,o?`Manage…`:`Connect`]})]},r.id)}),(0,G.jsx)(`div`,{className:`pt-3`,children:(0,G.jsx)(DR,{})})]})}function BH(){let{state:e,actions:t}=K(),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(``);return(0,v.useEffect)(()=>{t.refreshHosts()},[t]),e.account?.loggedIn?e.remote.supported?(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[e.remote.loading?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-4 text-sm text-fg-muted`,children:[(0,G.jsx)(J.Spinner,{}),` Loading devices…`]}):null,e.remote.hosts.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border px-3 py-2`,children:[(0,G.jsx)(J.Monitor,{className:`w-4 h-4 shrink-0 text-fg-faint`}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:n===e.hostId?(0,G.jsx)(`input`,{className:Z,value:i,autoFocus:!0,"aria-label":`Label for ${e.hostName}`,onChange:e=>a(e.target.value),onKeyDown:n=>{n.key===`Enter`&&i.trim()?(t.renameHost(e.hostId,i.trim()),r(null)):n.key===`Escape`&&r(null)}}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[e.label||e.hostName,e.isSelf?(0,G.jsx)(Q,{tone:`accent`,children:`this PC`}):null,(0,G.jsx)(Q,{tone:e.online?`ok`:`neutral`,children:e.online?`online`:`offline`}),e.remoteAccessOff?(0,G.jsx)(Q,{tone:`warn`,children:`remote access off`}):null]}),(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[e.platform,e.appVersion?` · v${e.appVersion}`:``,e.lastSeenAt?` · seen ${eg(e.lastSeenAt)}`:``]})]})}),n===e.hostId?(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>{i.trim()&&t.renameHost(e.hostId,i.trim()),r(null)},children:`Save`}):(0,G.jsxs)(Y,{size:`sm`,onClick:()=>{r(e.hostId),a(e.label||e.hostName)},children:[(0,G.jsx)(J.Edit,{className:`w-3 h-3`}),` Rename`]})]},e.hostId)),!e.remote.loading&&e.remote.hosts.length===0?(0,G.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`No devices reported yet.`}):null]}):(0,G.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-3 text-sm text-fg-muted`,children:[`This host build cannot list your account's devices yet (the relay lands with the server phase). This PC is `,(0,G.jsx)(`strong`,{children:e.connection.hostName??`unknown`}),`.`]}):(0,G.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-muted`,children:`Sign in to see the devices on your account.`})}function VH(e,t,n=Date.now()){if(e===0)return`Off — pictures are kept forever.`;if(!t)return`Not run yet — it runs a few minutes after OonaCode starts, then daily.`;let r=eg(t.finishedAt,n);return t.pictures===0?`Last run: nothing to replace, ${r}.`:`Last run: ${t.pictures.toLocaleString(`en-US`)} ${t.pictures===1?`picture`:`pictures`}, ${Pj(t.bytesFreed)}, ${r}.`}function HH({days:e,lastRun:t,onSave:n}){let[r,i]=(0,v.useState)(String(e));(0,v.useEffect)(()=>i(String(e)),[e]);let a=()=>{let t=Number.parseInt(r,10);if(!Number.isFinite(t)){i(String(e));return}let a=t<=0?0:Math.min(Xc,Math.max(1,t));i(String(a)),a!==e&&n(a)};return(0,G.jsxs)(zy,{label:`Replace pictures older than`,hint:TH.imageRetention.hint,details:TH.imageRetention.details,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`w-24`),type:`number`,min:0,max:Xc,step:1,value:r,onChange:e=>i(e.target.value),onBlur:a,onKeyDown:e=>{e.key===`Enter`&&a()},"aria-label":`Replace pictures older than (days)`,"data-testid":`settings-image-retention`}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`days`,e===365?` (a year)`:``]})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,"data-testid":`settings-image-retention-status`,children:VH(e,t)})]})}function UH(e,t,n){let r=e.trim(),i=Number(r);return!/^\d+$/.test(r)||i<t||i>n?`A whole number from ${t.toLocaleString(`en-US`)} to ${n.toLocaleString(`en-US`)}.`:null}function WH({label:e,unit:t,hint:n,details:r,value:i,min:a,max:o,defaultValue:s,onSave:c,testId:l}){let[u,d]=(0,v.useState)(String(i)),[f,p]=(0,v.useState)(null);(0,v.useEffect)(()=>{d(String(i)),p(null)},[i]);let m=()=>{let e=UH(u,a,o);if(p(e),e)return;let t=Number(u.trim());t!==i&&c(t)},h=e=>e.toLocaleString(`en-US`);return(0,G.jsxs)(zy,{label:e,hint:`${n} ${h(a)}–${h(o)}, default ${h(s)}.`,details:r,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`w-28`,f&&`border-danger`),type:`number`,min:a,max:o,step:1,value:u,onChange:e=>d(e.target.value),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&m()},"aria-label":e,"aria-invalid":f!==null,"data-testid":l}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:t})]}),f?(0,G.jsx)(`span`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`${l}-problem`,children:f}):null]})}function GH({settings:e}){let{actions:t}=K(),n=Wl,r=Ul;return(0,G.jsxs)(`div`,{className:`border-t border-border pt-3`,"data-testid":`settings-chat-abouts`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Chat abouts`}),(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>t.openChatAbouts(),"data-testid":`settings-open-chat-abouts`,children:`What your chats are about…`})]}),e.chatAboutEnabled===void 0?null:(0,G.jsx)(Hy,{label:`Write an about for every chat`,hint:TH.chatAbout.hint,details:TH.chatAbout.details,checked:e.chatAboutEnabled,onChange:e=>void t.saveSettings({chatAboutEnabled:e}),testId:`settings-chat-about-enabled`}),(0,G.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[e.chatAboutIntervalMinutes===void 0?null:(0,G.jsx)(WH,{label:`Minutes between background abouts`,unit:`minutes`,hint:TH.chatAboutInterval.hint,details:TH.chatAboutInterval.details,value:e.chatAboutIntervalMinutes,min:n.intervalMinutes.min,max:n.intervalMinutes.max,defaultValue:r.intervalMinutes,onSave:e=>void t.saveSettings({chatAboutIntervalMinutes:e}),testId:`settings-chat-about-interval`}),e.chatAboutMaxWords===void 0?null:(0,G.jsx)(WH,{label:`Longest about`,unit:`words`,hint:TH.chatAboutMaxWords.hint,details:TH.chatAboutMaxWords.details,value:e.chatAboutMaxWords,min:n.maxWords.min,max:n.maxWords.max,defaultValue:r.maxWords,onSave:e=>void t.saveSettings({chatAboutMaxWords:e}),testId:`settings-chat-about-max-words`}),e.chatAboutInputChars===void 0?null:(0,G.jsx)(WH,{label:`How much of a chat is read`,unit:`characters`,hint:TH.chatAboutInputChars.hint,details:TH.chatAboutInputChars.details,value:e.chatAboutInputChars,min:n.inputChars.min,max:n.inputChars.max,defaultValue:r.inputChars,onSave:e=>void t.saveSettings({chatAboutInputChars:e}),testId:`settings-chat-about-input-chars`})]})]})}function KH(){let{state:e,actions:t}=K(),n=e.settings,[r,i]=(0,v.useState)(n?.defaultCwd??``);if((0,v.useEffect)(()=>i(n?.defaultCwd??``),[n?.defaultCwd]),(0,v.useEffect)(()=>{t.refreshSettings()},[t]),!n)return(0,G.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading settings…`});let a=e.account?.gatewayUrl??n.gatewayUrl??x,o=e=>{let r=e.trim()?e.trim():null;r!==(n.defaultCwd??null)&&t.saveSettings({defaultCwd:r})},s=async()=>{let e=await window.oonacode?.pickDirectory?.({title:`The folder new chats run in`,...r?{defaultPath:r}:{}});e&&(i(e),o(e))};return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(zy,{label:`Default working directory`,hint:TH.defaultCwd.hint,details:TH.defaultCwd.details,children:(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`flex-1 font-mono text-xs`),value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),placeholder:`Empty — each chat gets its own folder`,spellCheck:!1,"data-testid":`settings-default-cwd`}),window.oonacode?.pickDirectory?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>void s(),children:`Choose…`}):null,r?(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>{i(``),o(``)},children:`Clear`}):null]})}),(0,G.jsxs)(`div`,{className:`border-t border-border pt-1`,children:[(0,G.jsx)(Hy,{label:`Remote access`,hint:TH.remoteAccess.hint,details:TH.remoteAccess.details,checked:n.relayEnabled??!0,onChange:e=>void t.saveSettings({relayEnabled:e}),testId:`settings-relay`}),(0,G.jsx)(Hy,{label:`Keep the vault unlocked when the app closes`,hint:TH.keepUnlocked.hint,details:TH.keepUnlocked.details,checked:n.keepUnlockedOnExit??!1,onChange:e=>void t.saveSettings({keepUnlockedOnExit:e}),testId:`settings-keep-unlocked-exit`})]}),n.imageRetentionDays===void 0?null:(0,G.jsx)(`div`,{className:`border-t border-border pt-3`,children:(0,G.jsx)(HH,{days:n.imageRetentionDays,lastRun:n.imageRetentionLastRun??null,onSave:e=>void t.saveSettings({imageRetentionDays:e})})}),n.chatAboutEnabled!==void 0||n.chatAboutIntervalMinutes!==void 0||n.chatAboutMaxWords!==void 0||n.chatAboutInputChars!==void 0?(0,G.jsx)(GH,{settings:n}):null,(0,G.jsxs)(`div`,{className:`space-y-2 border-t border-border pt-3 text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Server`,(0,G.jsx)(Ly,{label:`Server`,details:(0,G.jsx)(Ry,{items:TH.server.details})})]}),(0,G.jsx)(`span`,{className:`block text-fg-faint`,children:TH.server.hint})]}),(0,G.jsx)(`span`,{className:`break-all font-mono text-fg-muted`,"data-testid":`settings-server`,children:a})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[`Diagnostics`,(0,G.jsx)(Ly,{label:`Diagnostics`,details:(0,G.jsx)(Ry,{items:TH.diagnostics.details})})]}),(0,G.jsx)(`span`,{className:`block text-fg-faint`,children:TH.diagnostics.hint})]})]})]})}function qH(e){return e instanceof Error?e.message:String(e)}function JH(){let e=NH(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),l=(0,v.useRef)(Promise.resolve());if((0,v.useEffect)(()=>{if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&(n(e),o(String(e.saved.port)))},e=>{t&&i(qH(e))}),()=>{t=!1}},[e]),!e)return(0,G.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Debugging is a setting of the OonaCode desktop app.`});if(!t)return r?(0,G.jsx)(`div`,{className:`py-6 text-sm text-danger`,role:`alert`,children:r}):(0,G.jsx)(`div`,{className:`py-6 text-sm text-fg-muted`,children:`Loading…`});let u=t=>{l.current=l.current.then(async()=>{try{let r=await e.setDebugging(t);n(r.state),i(r.ok?null:r.problem??`Not saved.`),r.ok&&o(String(r.state.saved.port))}catch(e){i(qH(e))}})},d=()=>{let e=a.trim(),n=/^\d+$/.test(e)?Number(e):NaN,r=yc(n);if(r){i(r);return}if(n===t.saved.port){i(null);return}u({port:n})},f=async()=>{try{let t=await e.relaunchApp();t.started?c(t.message||`OonaCode is restarting…`):i(t.message||`OonaCode could not restart.`)}catch(e){i(qH(e))}},p=DH(t),m=r!==null&&/^(The port|Ports?) /.test(r);return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`settings-developer`,children:[(0,G.jsx)(Hy,{label:`Allow debugging`,hint:TH.allowDebugging.hint,details:TH.allowDebugging.details,checked:t.saved.enabled,onChange:e=>u({enabled:e}),testId:`settings-allow-debugging`}),(0,G.jsx)(zy,{label:`Debugging port`,hint:`${TH.debugPort.hint} ${mc}–${hc}, default ${pc}.`,details:TH.debugPort.details,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:W(Z,`max-w-28`,m&&`border-danger`),type:`number`,min:mc,max:hc,step:1,value:a,onChange:e=>o(e.target.value),onBlur:d,onKeyDown:e=>{e.key===`Enter`&&d()},"aria-label":`Debugging port`,"aria-invalid":m,"data-testid":`settings-debug-port`}),(0,G.jsx)(`span`,{className:`whitespace-nowrap text-xs text-fg-faint`,children:`on 127.0.0.1`})]})}),(0,G.jsx)(Hy,{label:`Also debug the main process`,hint:TH.debugMainProcess.hint,details:TH.debugMainProcess.details,checked:t.saved.inspectMain,disabled:!t.saved.enabled,onChange:e=>u({inspectMain:e}),testId:`settings-debug-main`}),r?(0,G.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`settings-debugging-problem`,children:r}):null,(0,G.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-2 text-xs`,"data-testid":`settings-debugging-status`,children:[(0,G.jsx)(`div`,{className:`text-fg-muted`,children:EH(t.running)}),p?(0,G.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-warn`,"data-testid":`settings-debugging-restart-note`,children:`Takes effect when OonaCode restarts. The host service and your chats keep running.`}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>void f(),disabled:s!==null||!e.relaunchApp,"data-testid":`settings-debugging-restart`,children:`Restart now`})]}):null,s?(0,G.jsx)(`div`,{className:`mt-1 text-fg-faint`,children:s}):null]})]})}function YH({open:e,onClose:t}){let{state:n,actions:r}=K(),[i,a]=(0,v.useState)(`general`),o=n.ui.settingsSection;(0,v.useEffect)(()=>{e&&o&&a(o)},[e,o]),(0,v.useEffect)(()=>{e&&!n.settings&&r.refreshSettings()},[e,n.settings,r]);let s=NH()!==null,c=s?MH:MH.filter(e=>e.id!==`developer`);return(0,G.jsx)(Vy,{open:e,title:`Settings`,onClose:t,wide:!0,footer:(0,G.jsx)(Y,{onClick:t,children:`Done`}),children:(0,G.jsxs)(`div`,{className:`flex min-h-[22rem] gap-4`,children:[(0,G.jsxs)(`nav`,{className:`w-36 shrink-0 space-y-0.5`,"aria-label":`Settings sections`,children:[c.map(e=>{let t=e.icon;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>a(e.id),"aria-current":i===e.id?`true`:void 0,className:W(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm`,i===e.id?`bg-accent-soft font-medium text-accent`:`text-fg-muted hover:bg-surface-2`),children:[(0,G.jsx)(t,{className:`w-3.5 h-3.5`}),e.label]},e.id)}),(0,G.jsxs)(`div`,{className:`pt-3 text-[11px] text-fg-faint`,children:[`OonaCode Desktop v`,Bv(typeof window<`u`&&window.oonacode?.appVersion||n.connection.appVersion||`0.0.0`,zv({bridge:typeof window<`u`?window.oonacode:void 0,info:n.info}))]})]}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===`general`?(0,G.jsx)(PH,{}):null,i===`theme`?(0,G.jsx)(LH,{}):null,i===`advanced`?(0,G.jsx)(RH,{}):null,i===`skills`?(0,G.jsx)(AH,{}):null,i===`providers`?(0,G.jsx)(zH,{}):null,i===`devices`?(0,G.jsx)(BH,{}):null,i===`host`?(0,G.jsx)(KH,{}):null,i===`developer`&&s?(0,G.jsx)(JH,{}):null]})]})})}function XH({toast:e}){let{actions:t}=K();(0,v.useEffect)(()=>{let n=setTimeout(()=>t.dismissToast(e.id),e.kind===`error`?9e3:5e3);return()=>clearTimeout(n)},[e.id,e.kind,t]);let n=e.kind===`error`?`border-danger/50 bg-danger-soft text-danger`:e.kind===`success`?`border-ok/50 bg-ok-soft text-ok`:`border-border bg-surface text-fg`;return(0,G.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:W(`pointer-events-auto flex max-w-sm items-start gap-2 rounded-md border px-3 py-2 text-sm shadow-md`,n),children:[e.kind===`error`?(0,G.jsx)(J.Alert,{className:`mt-0.5 w-4 h-4`}):e.kind===`success`?(0,G.jsx)(J.Check,{className:`mt-0.5 w-4 h-4`}):null,(0,G.jsx)(`div`,{className:`pre-wrap min-w-0 flex-1`,children:e.text}),(0,G.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,className:`opacity-60 hover:opacity-100`,onClick:()=>t.dismissToast(e.id),children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]})}function ZH(){let{state:e}=K();return e.toasts.length===0?null:(0,G.jsx)(`div`,{className:`pointer-events-none fixed bottom-4 right-4 z-50 flex flex-col gap-2`,children:e.toasts.map(e=>(0,G.jsx)(XH,{toast:e},e.id))})}var QH=2e3;function $H(e){if(!eU(e))return;let t=typeof window<`u`?window.oonacode:void 0;if(t?.openExternal){t.openExternal(e).catch(()=>void 0);return}typeof window<`u`&&window.open(e,`_blank`,`noopener,noreferrer`)}function eU(e){if(typeof e!=`string`||e===``)return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function tU(e){if(e.message)return e.message;switch(e.status){case`denied`:return`That request was denied in the browser. Start again if it was you.`;case`expired`:return`The code expired before it was approved. Start again for a fresh one.`;default:return`The sign-in could not be started. Check that this PC can reach the gateway.`}}function nU({children:e,testId:t}){let{state:n}=K(),r=n.connection.hostName??n.info?.hostName??null;return(0,G.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,"data-testid":t,children:[(0,G.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-3`,children:[(0,G.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-fg-faint`,children:`/`}),(0,G.jsx)(`span`,{className:`truncate text-sm text-fg-muted`,"data-testid":`frame-host-name`,children:r})]}):null]}),(0,G.jsx)(`main`,{className:`flex min-h-0 flex-1 items-start justify-center overflow-y-auto p-6`,children:(0,G.jsx)(`div`,{className:`w-full max-w-md py-6`,children:e})}),(0,G.jsx)(ZH,{})]})}function rU(){return(0,G.jsx)(nU,{testId:`account-loading`,children:(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(J.Spinner,{className:`w-4 h-4`}),(0,G.jsx)(`span`,{children:`Checking your account…`})]})})}function iU({link:e}){let{actions:t}=K(),[n,r]=(0,v.useState)(!1),i=e.verificationUrl??``,a=e.verificationUrlComplete??i,o=eU(a),s=t.refreshAccountLink;return(0,v.useEffect)(()=>{let e=setInterval(()=>void s(),QH);return()=>clearInterval(e)},[s]),(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`link-waiting`,children:[(0,G.jsxs)(`ol`,{className:`space-y-2 text-sm`,children:[(0,G.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`1. Open`}),o?(0,G.jsx)(`a`,{className:`break-all font-medium text-accent underline`,href:a,target:`_blank`,rel:`noopener noreferrer`,"data-testid":`link-url`,onClick:e=>{window.oonacode?.openExternal&&(e.preventDefault(),$H(a))},children:i}):(0,G.jsx)(`span`,{className:`break-all font-medium`,"data-testid":`link-url`,children:i})]}),(0,G.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`2. Enter`}),(0,G.jsx)(`span`,{className:`select-all rounded-md border border-border bg-surface-2 px-2.5 py-1 font-mono text-base tracking-widest`,"data-testid":`link-user-code`,children:e.userCode})]})]}),(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-fg-muted`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{children:`Waiting for approval in your browser…`})]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-faint`,children:`Approve this code only if you are looking at it on your own screen right now. It is good for a few minutes and can be used once.`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o?(0,G.jsxs)(Y,{size:`sm`,onClick:()=>$H(a),"data-testid":`link-reopen`,children:[(0,G.jsx)(J.LogIn,{className:`w-3.5 h-3.5`}),` Open the browser again`]}):null,(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,busy:n,"data-testid":`link-cancel`,onClick:()=>{r(!0),t.cancelAccountLink().finally(()=>r(!1))},children:`Cancel`})]})]})}function aU(e){if(typeof e!=`string`||e===``)return null;try{let t=new URL(e).hostname;if(!t)return null;let n=/^api(?:-([a-z0-9-]+))?.(.+)$/i.exec(t),r=n?.[2];return n&&r?n[1]?n[1]+`.`+r:r:t}catch{return null}}function oU(){let{state:e,actions:t}=K(),n=e.accountLink,r=aU(n?.verificationUrl??e.settings?.gatewayUrl??e.account?.gatewayUrl??null),[i,a]=(0,v.useState)(!1),o=(0,v.useCallback)(async()=>{a(!0);try{let e=await t.startAccountLink();e?.status===`waiting`&&$H(e.verificationUrlComplete??e.verificationUrl??``)}finally{a(!1)}},[t]);if(n?.status===`waiting`)return(0,G.jsx)(iU,{link:n});let s=n&&(n.status===`denied`||n.status===`expired`);return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[s?(0,G.jsx)(`p`,{role:`status`,"data-testid":`link-refused`,className:`rounded-md border border-warn/50 bg-warn-soft px-3 py-2 text-xs text-fg`,children:tU(n)}):null,(0,G.jsxs)(Y,{variant:`primary`,busy:i,onClick:()=>void o(),"data-testid":`link-start`,className:`w-full justify-center`,children:[(0,G.jsx)(J.LogIn,{className:`w-3.5 h-3.5`}),s?`Try again in your browser`:`Sign in with your browser`]}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`link-site-note`,children:[`Opens `,r??`your account page`,` and shows a short code to confirm. Your password is never typed on this machine, and this PC never sees anyone else's.`]})]})}function sU(){let{state:e}=K(),[t,n]=(0,v.useState)(!1),r=t||e.emailVerification!==null;return(0,G.jsx)(nU,{testId:`sign-in-view`,children:(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Sign in to use OonaCode`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`OonaCode runs the agent on this PC, with your own providers — but it needs an OonaCode account. There is no guest mode.`})]}),(0,G.jsx)(oU,{}),(0,G.jsx)(`div`,{className:W(`space-y-3 border-t border-border pt-4`,r?``:`text-center`),children:r?(0,G.jsx)(Hb,{}):(0,G.jsx)(Y,{size:`sm`,variant:`ghost`,"data-testid":`use-password`,onClick:()=>n(!0),children:`Use an email and password instead`})})]})})}function cU(){let{state:e,actions:t}=K(),[n,r]=(0,v.useState)(``),[i,a]=(0,v.useState)(!0),[o,s]=(0,v.useState)(!1),[c,l]=(0,v.useState)(null),u=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let e=()=>u.current?.focus();e();let t=setTimeout(e,60);return()=>clearTimeout(t)},[]),(0,G.jsxs)(`div`,{className:`flex min-h-screen items-center justify-center bg-surface-1 p-6`,"data-testid":`locked-view`,onMouseDown:()=>u.current?.focus(),children:[(0,G.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),!n||o)return;s(!0),l(null);let a=null;t.unlock(n,{keepUnlocked:i,onError:e=>{a=e}}).then(e=>{s(!1),e?r(``):l(a??`Wrong password — the vault stays locked.`)})},className:`w-full max-w-sm space-y-4 text-center`,children:[(0,G.jsx)(J.Lock,{className:`mx-auto h-10 w-10 text-fg-faint`}),(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`This device is locked`}),(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`The vault, your keys and every session on this PC stay unreadable until you unlock — with your account password here, or remotely from another of your devices.`}),(0,G.jsx)(`input`,{ref:u,type:`password`,className:Z,value:n,onChange:e=>r(e.target.value),onMouseDown:e=>e.stopPropagation(),placeholder:`Account password`,autoFocus:!0,"data-testid":`locked-password`}),(0,G.jsxs)(`label`,{className:`flex items-start justify-center gap-2 text-sm text-fg-muted`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`mt-1`,checked:i,onChange:e=>a(e.target.checked),"data-testid":`locked-keep-unlocked`}),(0,G.jsx)(`span`,{children:`Keep me unlocked on this PC`})]}),c?(0,G.jsx)(`div`,{className:`text-sm text-danger`,"data-testid":`locked-error`,children:c}):null,(0,G.jsx)(Y,{type:`submit`,variant:`primary`,busy:o,disabled:!n,children:`Unlock`}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-faint`,children:[`Signed in as `,e.account?.email??`this account`,` ·`,` `,(0,G.jsx)(`button`,{type:`button`,className:`underline hover:text-fg`,onClick:()=>void t.logout(),children:`Sign out`})]})]}),(0,G.jsx)(ZH,{})]})}function lU(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function uU(e,t,n){let r=lU(n),i=e.filter(e=>!t.has(e.id)).sort((e,t)=>t.mtime-e.mtime),a=[],o=[];for(let e of i)(e.mtime>=r?a:o).push(e);return{today:a,older:o}}function dU(e,t){let n=t.trim().toLowerCase();return n===``||e.toLowerCase().includes(n)}var fU=`flex w-full items-center gap-1 rounded px-2 py-1 text-left text-[11px] font-semibold uppercase tracking-wide text-fg-faint hover:bg-surface-2`,pU=`flex items-center gap-1 px-2 pb-0.5 pt-2 text-[11px] font-semibold uppercase tracking-wide text-fg-faint`,mU=`flex w-full items-center gap-1.5 rounded border-l-2 border-project/70 bg-surface-2/40 px-2 py-1.5 text-left text-[13px] font-semibold tracking-normal text-fg hover:bg-surface-2`,hU=`flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-fg hover:bg-surface-2`;function gU(){let{state:e,actions:t}=K(),n=e.ui.sidebarPinnedOverride??e.prefs.sidebarPinned,[r,i]=(0,v.useState)(pV),[a,o]=(0,v.useState)({}),[s,c]=(0,v.useState)(!1),l=PF(),[u,d]=(0,v.useState)(null),f=(0,v.useCallback)(()=>d(null),[]),p=CU(),m=UF(),h=lU(m),g=e.prefs.sidebarView,_=e.prefs.pinned,y=e=>o(t=>({...t,[e]:t[e]!==!0})),b=e=>a[e]===!0,x=e.prefs.collapsedProjects,S=e=>x.includes(e),C=e=>{let n=S(e)?x.filter(t=>t!==e):[...x,e];t.savePrefs({collapsedProjects:n})},w=(0,v.useCallback)(e=>{t.selectSession(e),window.innerWidth<768&&t.setSidebar(!1)},[t]),T=(0,v.useCallback)(e=>{t.openPage({kind:`project`,projectId:e}),window.innerWidth<768&&t.setSidebar(!1)},[t]),E=e.search.trim()!==``,D=(0,v.useMemo)(()=>{let t=e.sessions.filter(t=>!e.remote.tabs[t.id]);if(!E)return t;let n=Date.now();return t.filter(t=>_V(t,e.search,r,n))},[e.sessions,e.remote.tabs,e.search,E,r]),O=(0,v.useMemo)(()=>{let t=new Map(D.map(e=>[e.id,e])),n=[];for(let r of _)if(r.kind===`chat`){let i=t.get(r.id)??(E?void 0:e.pinnedRows[r.id]);i&&!e.remote.tabs[i.id]&&n.push({kind:`chat`,session:i})}else{let t=e.vaultProjects.find(e=>e.id===r.id);if(!t||!dU(t.name,E?e.search:``))continue;let i=e.sessions.filter(e=>e.projectId===t.id);n.push({kind:`project`,project:t,sessions:i})}return n},[_,D,E,e.search,e.pinnedRows,e.remote.tabs,e.vaultProjects,e.sessions]),k=(0,v.useMemo)(()=>new Set(_.filter(e=>e.kind===`chat`).map(e=>e.id)),[_]),A=(0,v.useMemo)(()=>g===`recent`?uU(D,k,h):null,[g,D,k,h]),j=(0,v.useMemo)(()=>new Map(e.vaultProjects.map(e=>[e.id,e.name])),[e.vaultProjects]),M=(0,v.useMemo)(()=>{if(g!==`projects`)return[];let t=new Map;for(let n of e.vaultProjects)t.set(n.id,{name:n.name,sessions:[]});let n=[];for(let e of D){let r=e.projectId?t.get(e.projectId):void 0;r?r.sessions.push(e):n.push(e)}let r=[...t.entries()].map(([e,t])=>({key:e,name:t.name,projectId:e,sessions:t.sessions.slice().sort((e,t)=>t.mtime-e.mtime)}));return r.sort((e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:`base`})),(n.length>0||r.length===0)&&r.push({key:`none`,name:`No project`,projectId:null,sessions:n.slice().sort((e,t)=>t.mtime-e.mtime)}),E?r.filter(e=>e.sessions.length>0):r},[g,e.vaultProjects,D,E]),N=e=>{t.savePrefs({collapsedProjects:e?M.map(e=>e.key):[]})},ee=(0,v.useMemo)(()=>e.remote.hosts.filter(e=>!e.isSelf),[e.remote.hosts]),te=()=>{let e=b(`remote`);y(`remote`),e&&t.refreshHosts()},P=e=>{t.setSearch(e),t.refreshSessions(e)},[F,ne]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(0),I=(0,v.useRef)(null),[L,R]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(``),se=r.mode===`conversations`,ce=se?ae:e.search,le=F||ce!==``||L;(0,v.useEffect)(()=>{F&&I.current?.focus()},[F,re]),(0,v.useEffect)(()=>{let e=e=>{!(e.ctrlKey||e.metaKey)||e.shiftKey||e.altKey||(e.key===`k`||e.key===`K`)&&window.oonacode?.host!==`vscode`&&(e.preventDefault(),ne(!0),ie(e=>e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let ue=()=>{e.search!==``&&P(``),oe(``),R(!1),ne(!1)},de=t=>{t.mode!==r.mode&&(t.mode===`conversations`?(oe(e.search),e.search!==``&&P(``)):(ae!==``&&P(ae),oe(``))),i(t)},fe=D.length,pe=e=>{e!==g&&t.savePrefs({sidebarView:e})},me=e.page,he={onOpen:w,onMenu:l.openMenu,clock:m},ge=!e.sessionsLoading&&fe===0&&!e.sessionsError?(0,G.jsx)(`div`,{className:`px-3 py-3 text-center text-xs text-fg-faint`,"data-testid":`sessions-empty`,children:E?`No sessions match.`:`No sessions yet — press + to start one.`}):null;return(0,G.jsxs)(`nav`,{className:`flex h-full w-full flex-col bg-surface`,"aria-label":`Sessions`,children:[(0,G.jsxs)(`div`,{className:`relative flex flex-wrap items-center justify-end gap-x-2 gap-y-1 border-b border-border p-2`,children:[(0,G.jsx)(X,{label:`Search chats (Ctrl+K)`,onClick:()=>{ne(!0),ie(e=>e+1)},"data-testid":`open-search`,children:(0,G.jsx)(J.Search,{})}),(0,G.jsx)(`span`,{className:`flex-1`}),le?(0,G.jsxs)(`div`,{className:`absolute inset-0 z-10 flex items-center gap-1 bg-surface px-2`,"data-testid":`sidebar-search`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(J.Search,{className:`pointer-events-none absolute left-2 top-2 w-3.5 h-3.5 text-fg-faint`}),(0,G.jsx)(`input`,{ref:I,"aria-label":`Search sessions`,className:W(Z,`pl-7`),placeholder:se?`Search every chat`:`Search chats`,value:ce,onChange:e=>se?oe(e.target.value):P(e.target.value),onBlur:()=>{ce===``&&!L&&ne(!1)},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ue())}})]}),(0,G.jsxs)(X,{label:L?`Hide search options`:`Search options`,className:W(`relative`,L&&`text-accent`),"aria-pressed":L,onMouseDown:e=>e.preventDefault(),onClick:()=>R(e=>!e),"data-testid":`search-options-toggle`,children:[(0,G.jsx)(J.Sliders,{}),hV(r)?(0,G.jsx)(`span`,{className:`absolute right-0.5 top-0.5 h-1.5 w-1.5 rounded-full bg-accent`,"data-testid":`search-options-dot`}):null]}),(0,G.jsx)(X,{label:`Close search`,onMouseDown:e=>e.preventDefault(),onClick:ue,"data-testid":`close-search`,children:(0,G.jsx)(J.X,{})})]}):null,le&&L?(0,G.jsx)(SV,{options:r,onChange:de,projects:e.vaultProjects,onClose:()=>{R(!1),I.current?.focus()}}):null,(0,G.jsx)(X,{label:`Refresh sessions`,onClick:()=>{t.refreshSessions(),t.refreshHosts()},children:(0,G.jsx)(J.Refresh,{className:e.sessionsLoading?`spin`:``})}),e.account?.loggedIn?(0,G.jsx)(X,{label:`Import chats from your other coding agents`,onClick:()=>t.openDialog(`import-claude`),"data-testid":`open-import-claude`,children:(0,G.jsx)(J.Download,{})}):null,e.account?.loggedIn?(0,G.jsx)(X,{label:`Export my chats`,onClick:()=>t.openDialog(`export-chats`),"data-testid":`open-export-chats`,children:(0,G.jsx)(J.Upload,{})}):null,g===`projects`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(X,{label:`Collapse all projects`,onClick:()=>N(!0),"data-testid":`projects-collapse-all`,children:(0,G.jsx)(J.CollapseAll,{})}),(0,G.jsx)(X,{label:`Expand all projects`,onClick:()=>N(!1),"data-testid":`projects-expand-all`,children:(0,G.jsx)(J.ExpandAll,{})})]}):null,(0,G.jsx)(X,{label:`Conversations — what your chats send each other`,onClick:()=>t.openConversations(),"data-testid":`open-conversations`,children:(0,G.jsx)(J.Chats,{})}),(0,G.jsx)(X,{label:`What your chats are about — each chat’s about and what it cost`,onClick:()=>t.openChatAbouts(),"data-testid":`open-chat-abouts`,children:(0,G.jsx)(J.Info,{})}),(0,G.jsx)(X,{label:n?`Hide the session list — it slides in when the pointer reaches the left edge`:`Pin the session list beside the chat`,className:W(`hidden md:inline-flex`,n?`text-accent`:`text-fg-muted`),"aria-pressed":n,onClick:()=>t.toggleSidebarPinned(),"data-testid":`sidebar-pin`,children:(0,G.jsx)(J.Pin,{})})]}),(0,G.jsx)(_U,{clock:m}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-1 pb-2`,children:se&&ae.trim()!==``?(0,G.jsx)(wV,{query:ae,options:r}):(0,G.jsxs)(G.Fragment,{children:[O.length>0?(0,G.jsxs)(`div`,{className:`mb-1`,"data-testid":`section-pinned`,children:[(0,G.jsx)(`div`,{className:pU,children:(0,G.jsx)(`span`,{children:`Pinned`})}),O.map(t=>t.kind===`chat`?(0,G.jsx)(MF,{session:t.session,active:t.session.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.session.id]??null,menuOpen:l.menuFor===t.session.id,kindIcon:!0,testIdPrefix:`pinned-session`,...he},`chat:${t.session.id}`):(0,G.jsx)(bU,{project:t.project,sessions:t.sessions,active:me?.kind===`project`&&me.projectId===t.project.id,onOpen:T,onMenu:(e,n)=>d({target:{projectId:t.project.id,foldKey:null},at:e,el:n})},`project:${t.project.id}`))]}):null,(0,G.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-local`,children:[e.sessionsError?(0,G.jsx)(`div`,{className:`px-2 py-2 text-xs text-danger`,children:e.sessionsError}):null,A?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{"data-testid":`section-today`,children:[(0,G.jsxs)(`div`,{className:pU,children:[(0,G.jsx)(`span`,{children:`Today`}),(0,G.jsx)(`span`,{className:`font-normal normal-case`,children:A.today.length||``}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(yU,{view:g,onChange:pe})]}),ge??(A.today.length===0?(0,G.jsx)(`div`,{className:`px-3 py-1 text-xs text-fg-faint`,"data-testid":`today-empty`,children:E?`Nothing from today matches.`:`Nothing yet today.`}):A.today.map(t=>(0,G.jsx)(MF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id)))]}),A.older.length>0?(0,G.jsxs)(`div`,{"data-testid":`section-older`,children:[(0,G.jsxs)(`div`,{className:pU,children:[(0,G.jsx)(`span`,{children:`Older`}),(0,G.jsx)(`span`,{className:`font-normal normal-case`,children:A.older.length})]}),A.older.map(t=>(0,G.jsx)(MF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,projectName:t.projectId?j.get(t.projectId)??null:null,...he},t.id))]}):null]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:pU,"data-testid":`section-by-project`,children:[(0,G.jsx)(`span`,{children:`By project`}),(0,G.jsx)(`span`,{className:`flex-1`}),(0,G.jsx)(yU,{view:g,onChange:pe})]}),ge,M.map(n=>{let r=`local:${n.key}`;return(0,G.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`project-group-${n.key}`,children:[(0,G.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,G.jsx)(wU,{group:n,collapsed:S(n.key),onToggle:()=>C(n.key),onMenu:(e,t)=>d({target:{projectId:n.projectId,foldKey:n.key},at:e,el:t}),menuOpen:u?.target.foldKey===n.key}),n.projectId?(0,G.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,G.jsx)(X,{label:`Settings of ${n.name}`,className:`p-1`,"data-testid":`project-settings-${n.key}`,onClick:e=>{e.stopPropagation(),t.openProjectSettings(n.projectId)},children:(0,G.jsx)(J.Settings,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(X,{label:`New chat in ${n.name}`,className:`p-1`,"data-testid":`project-new-chat-${n.key}`,onClick:e=>{e.stopPropagation(),t.newTab({projectId:n.projectId})},children:(0,G.jsx)(J.Plus,{className:`w-3.5 h-3.5`})})]}):null]}),S(n.key)?null:n.sessions.map(t=>(0,G.jsx)(MF,{session:t,active:t.id===e.currentSessionId&&me===null,link:e.sessionLinks[t.id]??null,menuOpen:l.menuFor===t.id,...he},t.id))]},r)})]})]}),(0,G.jsxs)(`div`,{className:`mb-1`,"data-testid":`sessions-remote`,children:[(0,G.jsxs)(`button`,{type:`button`,className:fU,onClick:te,"aria-expanded":!b(`remote`),children:[(0,G.jsx)(J.Chevron,{open:!b(`remote`),className:`w-3 h-3`}),(0,G.jsx)(J.Globe,{className:`w-3 h-3`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Remote`}),(0,G.jsx)(`span`,{className:`ml-auto font-normal`,children:ee.length})]}),b(`remote`)?null:(0,G.jsxs)(G.Fragment,{children:[!e.remote.supported||e.remote.reason===`logged_out`?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:`Sign in to see the sessions of your other devices.`}):ee.length===0?(0,G.jsx)(`div`,{className:`px-3 py-3 text-xs text-fg-faint`,children:e.remote.loading?`Looking for your other devices…`:`No other devices yet.`}):null,ee.map(e=>(0,G.jsx)(xU,{host:e,collapsed:b(`host:${e.hostId}`)||a[`host:${e.hostId}`]===void 0,onToggle:()=>{let n=`host:${e.hostId}`,r=a[n]===void 0||a[n]===!0;o(e=>({...e,[n]:!r})),r&&t.refreshHostSessions(e.hostId)}},e.hostId))]})]})]})}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border px-3 py-2 text-[11px] text-fg-faint`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`app-version`,title:`What's new in this version`,className:`truncate hover:text-fg hover:underline`,onClick:()=>t.openDialog(`whats-new`),children:[`OonaCode Desktop v`,p]}),(0,G.jsx)(X,{label:`Lock this device — vault and sessions`,className:`p-1`,"data-testid":`lock-device`,onClick:()=>c(!0),children:(0,G.jsx)(J.Lock,{className:`h-3.5 w-3.5`})})]})}),(0,G.jsx)(Zb,{open:u!==null,at:u?.at??{x:0,y:0},anchorEl:u?.el??null,label:`Project actions`,testId:`project-context-menu`,onClose:f,items:u?FF({projectId:u.target.projectId,pinned:u.target.projectId!==null&&qc(_,`project`,u.target.projectId),fold:u.target.foldKey===null?null:{collapsed:S(u.target.foldKey),onToggle:()=>C(u.target.foldKey)},actions:t}):[]}),l.element,(0,G.jsx)(Gy,{open:s,title:`Lock this device?`,confirmLabel:`Lock`,message:`Every chat closes and nothing on this PC can be read or run until you unlock — here with your password, or remotely from another device.`,onConfirm:()=>void t.lockDevice(),onClose:()=>c(!1)})]})}function _U({clock:e}){let{state:t,actions:n}=K(),[r,i]=(0,v.useState)(null),a=(0,v.useCallback)(()=>i(null),[]),o=t.page,s=()=>{window.innerWidth<768&&n.setSidebar(!1)};return(0,G.jsxs)(`div`,{className:`shrink-0 border-b border-border px-1 py-1`,"data-testid":`sidebar-nav`,children:[(0,G.jsxs)(`div`,{className:`flex items-center rounded-md hover:bg-surface-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:W(hU,`flex-1 hover:bg-transparent`),title:`New chat (Ctrl+T)`,onClick:()=>{n.newTab(),s()},"data-testid":`sidebar-new`,children:[(0,G.jsx)(J.Edit,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,G.jsx)(`span`,{children:`New`})]}),(0,G.jsx)(X,{label:`Start a new chat or a new project`,className:`mr-1 p-1`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();i({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-new-menu`,children:(0,G.jsx)(J.Chevron,{open:!0,className:`w-3.5 h-3.5`})})]}),(0,G.jsxs)(`button`,{type:`button`,className:W(hU,`w-full`,o?.kind===`projects`||o?.kind===`project`?`bg-surface-2 font-medium`:``),"aria-current":o?.kind===`projects`?`page`:void 0,onClick:()=>{n.openPage({kind:`projects`}),s()},"data-testid":`open-projects`,children:[(0,G.jsx)(J.Project,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,G.jsx)(`span`,{children:`Projects`})]}),(0,G.jsx)(vU,{clock:e,active:o?.kind===`scheduled`,onOpen:()=>{n.openPage({kind:`scheduled`}),s()}}),(0,G.jsx)(Zb,{open:r!==null,at:r?.at??{x:0,y:0},anchorEl:r?.el??null,label:`New`,testId:`sidebar-new-context-menu`,onClose:a,items:[{key:`chat`,label:`New chat`,hint:`Ctrl+T`,icon:(0,G.jsx)(J.Chats,{className:`w-3.5 h-3.5`}),onSelect:()=>{n.newTab(),s()},testId:`sidebar-new-chat`},{key:`project`,label:`New project…`,icon:(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5`}),onSelect:()=>n.openNewProject(),testId:`sidebar-new-project`}]})]})}function vU({clock:e,active:t,onOpen:n}){let{tasks:r}=HF(),i=(0,v.useMemo)(()=>r?QF(r,e):null,[r,e]);return(0,G.jsxs)(`button`,{type:`button`,className:W(hU,`w-full`,t?`bg-surface-2 font-medium`:``),"aria-current":t?`page`:void 0,onClick:n,title:i?.text??`Every scheduled task on this PC`,"data-testid":`open-scheduled`,children:[(0,G.jsx)(J.Clock,{className:`w-4 h-4 shrink-0 text-fg-muted`}),(0,G.jsx)(`span`,{className:`flex-1`,children:`Scheduled`}),i?(0,G.jsx)(`span`,{className:W(`mr-1 inline-block h-2 w-2 shrink-0 rounded-full`,i.tone===`stuck`?`bg-warn`:`bg-accent`),"aria-label":i.text,"data-testid":`scheduled-dot`,"data-tone":i.tone}):null]})}function yU({view:e,onChange:t}){let[n,r]=(0,v.useState)(null),i=(0,v.useCallback)(()=>r(null),[]),a=e=>e?(0,G.jsx)(J.Check,{className:`w-3.5 h-3.5 text-accent`}):(0,G.jsx)(`span`,{className:`w-3.5`});return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(X,{label:`How the list is laid out`,className:`p-0.5 normal-case`,"aria-haspopup":`menu`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();r({at:{x:t.left,y:t.bottom+2},el:e.currentTarget})},"data-testid":`sidebar-view-options`,children:(0,G.jsx)(J.Sliders,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(Zb,{open:n!==null,at:n?.at??{x:0,y:0},anchorEl:n?.el??null,label:`How the list is laid out`,testId:`sidebar-view-menu`,onClose:i,items:[{key:`recent`,label:`Recent — Today, then Older`,icon:a(e===`recent`),onSelect:()=>t(`recent`),testId:`sidebar-view-recent`},{key:`projects`,label:`By project`,icon:a(e===`projects`),onSelect:()=>t(`projects`),testId:`sidebar-view-projects`}]})]})}function bU({project:e,sessions:t,active:n,onOpen:r,onMenu:i}){let a=(0,v.useRef)(null),o=e.sessionCount??t.length;return(0,G.jsxs)(`div`,{ref:a,className:W(`group relative flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),onContextMenu:e=>{e.preventDefault(),i({x:e.clientX,y:e.clientY},a.current)},children:[(0,G.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 py-1.5 pl-2 pr-8 text-left`,"aria-current":n?`page`:void 0,title:`Open ${e.name}`,onClick:()=>r(e.id),"data-testid":`pinned-project-${e.id}`,children:[(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.name}),(0,G.jsx)(DF,{sessions:t,testId:`pinned-project-busy-${e.id}`}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold text-fg-muted`,children:o})]}),(0,G.jsx)(X,{label:`Project actions`,className:`pointer-events-none absolute right-1 bg-surface/90 p-1 opacity-0 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100`,"data-testid":`pinned-project-menu-${e.id}`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();i({x:t.left,y:t.bottom+2},a.current)},children:(0,G.jsx)(J.More,{className:`w-3.5 h-3.5`})})]})}function xU({host:e,collapsed:t,onToggle:n}){let{state:r,actions:i}=K(),a=e.label||e.hostName,o=r.remote.sessions[e.hostId],s=r.remote.unreachable[e.hostId],c=s?uf(s.reason,a,s.detail):null,[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=e.remoteAccessOff===!0;return(0,G.jsxs)(`div`,{className:`mb-1 pl-2`,"data-testid":`remote-host-${e.hostId}`,children:[(0,G.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,G.jsxs)(`button`,{type:`button`,className:fU,onClick:n,"aria-expanded":!t,title:e.online?`${a} — online`:`${a} — offline: its chats can be read while it is online`,children:[(0,G.jsx)(J.Chevron,{open:!t,className:`w-3 h-3`}),(0,G.jsx)(`span`,{className:W(`inline-block h-2 w-2 shrink-0 rounded-full`,e.online?`bg-ok`:`bg-fg-faint`),"aria-label":e.online?`online`:`offline`}),(0,G.jsx)(`span`,{className:`truncate normal-case`,children:a}),p?(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-warn-soft px-1.5 text-[10px] font-normal normal-case text-warn`,"data-testid":`remote-off-${e.hostId}`,children:`remote access off`}):null,(0,G.jsx)(`span`,{className:`ml-auto font-normal`,children:!p&&o?o.length:``})]}),(0,G.jsxs)(`div`,{className:`absolute right-1 hidden items-center rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:[(0,G.jsx)(X,{label:p?lf(a):e.online?`New chat on ${a}`:`${a} is offline — a new chat has to start on a PC that is awake`,className:`p-1`,disabled:!e.online||p,"data-testid":`remote-new-chat-${e.hostId}`,onClick:()=>void i.newRemoteTab(e.hostId),children:(0,G.jsx)(J.Plus,{className:`w-3 h-3`})}),(0,G.jsx)(X,{label:`Unlock this device`,className:`p-1`,disabled:p,"data-testid":`remote-unlock-${e.hostId}`,onClick:()=>u(`unlock`),children:(0,G.jsx)(J.Lock,{className:`w-3 h-3`})}),(0,G.jsx)(X,{label:`Rename device`,className:`p-1`,onClick:()=>u(`rename`),children:(0,G.jsx)(J.Edit,{className:`w-3 h-3`})})]}),(0,G.jsx)(Ky,{open:l===`unlock`,title:`Unlock "${a}" remotely`,label:`Your account password — it never leaves this PC: the keys are sealed to that device and the server cannot read them.`,password:!0,submitLabel:`Unlock`,onSubmit:t=>void i.remoteUnlockHost(e.hostId,t),onClose:()=>u(null)}),(0,G.jsx)(Ky,{open:l===`rename`,title:`Rename device`,label:`Device name`,initialValue:a,onSubmit:t=>{t!==a&&i.renameHost(e.hostId,t)},onClose:()=>u(null)})]}),!t&&p?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-off-note-${e.hostId}`,children:lf(a)}):t?null:o===void 0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`Loading…`}):o.length===0&&c?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-warn`,"data-testid":`remote-unreachable-${e.hostId}`,children:c}):o.length===0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-faint`,children:`No sessions on this device.`}):o.map(t=>(0,G.jsx)(SU,{host:e,session:t,active:t.id===r.currentSessionId&&r.page===null,onConfirmDelete:()=>f(t)},t.id)),(0,G.jsx)(Gy,{open:d!==null,title:`Delete this chat?`,message:`It is deleted on ${e.hostName} — the only place it is kept — so it is gone from every device. Files, folders and code on that PC are not touched — only the chat is deleted.`,onConfirm:()=>{d&&i.deleteRemoteSession(e.hostId,d.id)},onClose:()=>f(null)})]})}function SU({host:e,session:t,active:n,onConfirmDelete:r}){let{actions:i}=K(),a=cg(t);return(0,G.jsxs)(`div`,{className:W(`group flex items-center rounded-md`,n?`bg-accent-soft`:`hover:bg-surface-2`),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{i.openRemoteSession(e.hostId,t.id),window.innerWidth<768&&i.setSidebar(!1)},className:`flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left`,"aria-current":n?`true`:void 0,"data-testid":`remote-session-${t.id}`,title:e.online?void 0:`Read-only until that PC is online`,children:[(0,G.jsx)(TF,{status:t.status}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:W(`truncate text-sm`,n?`font-medium`:``),children:a}),(0,G.jsxs)(`div`,{className:`truncate text-[11px] text-fg-faint`,children:[eg(t.updatedAt),t.model?` · ${t.model}`:``,e.online?``:` · read-only`]})]})]}),(0,G.jsx)(`div`,{className:`mr-1 hidden items-center gap-0.5 rounded bg-surface/90 group-hover:flex group-focus-within:flex`,children:(0,G.jsx)(X,{label:e.online?`Delete this chat`:`That PC is asleep — a chat can only be deleted while the PC that holds it is online`,className:`p-1 hover:text-danger disabled:opacity-40`,disabled:!e.online,"data-testid":`remote-session-delete-${t.id}`,onClick:()=>{r()},children:(0,G.jsx)(J.Trash,{className:`w-3.5 h-3.5`})})})]})}function CU(){let{state:e}=K(),t=typeof window<`u`?window.oonacode:void 0;return Bv(t?.appVersion??e.bundleAppVersion??e.connection.appVersion??e.info?.appVersion??`0.0.0`,zv({bridge:t,info:e.info}))}function wU({group:e,collapsed:t,onToggle:n,onMenu:r,menuOpen:i=!1}){let a=(0,v.useRef)(null),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(null),l=(0,v.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null),c(null)},[]),u=(0,v.useRef)(i);return u.current=i,(0,v.useEffect)(()=>{i&&l()},[i,l]),(0,v.useEffect)(()=>{if(s===null)return;let e=e=>{Yb(e.target,a.current)&&l()};return window.addEventListener(`scroll`,e,!0),()=>window.removeEventListener(`scroll`,e,!0)},[s,l]),(0,v.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{ref:a,type:`button`,className:mU,onClick:()=>{l(),n()},onMouseEnter:()=>{o.current!==null&&clearTimeout(o.current),!u.current&&(o.current=setTimeout(()=>{o.current=null,a.current&&!u.current&&c(a.current.getBoundingClientRect())},450))},onMouseLeave:l,onContextMenu:e=>{e.preventDefault(),l(),r({x:e.clientX,y:e.clientY},a.current)},"aria-expanded":!t,"data-testid":`project-header-${e.key}`,children:[(0,G.jsx)(J.Chevron,{open:!t,className:`w-3 h-3 shrink-0`}),(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name}),(0,G.jsx)(DF,{sessions:e.sessions,testId:`project-busy-${e.key}`}),(0,G.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full bg-surface-3 px-1.5 py-px text-[10px] font-semibold normal-case tracking-normal text-fg-muted`,"data-testid":`project-count-${e.key}`,children:e.sessions.length})]}),s===null?null:(0,G.jsx)(TU,{group:e,anchor:s})]})}function TU({group:e,anchor:t}){let{state:n}=K(),r=e.projectId?n.vaultProjects.find(t=>t.id===e.projectId):void 0,i=e.sessions.filter(e=>e.status===`running`||e.status===`waiting_permission`).length,a=e.sessions.reduce((e,t)=>e===null||t.updatedAt>e?t.updatedAt:e,null),o=[...new Set(e.sessions.map(e=>e.projectDir??e.cwd).filter(e=>typeof e==`string`&&e.length>0))],s=r?.instructions?.trim()??``,c=Math.max(8,Math.min(t.right+8,window.innerWidth-304-8)),l=Math.max(8,Math.min(t.top,window.innerHeight-320));return(0,My.createPortal)((0,G.jsxs)(`div`,{role:`tooltip`,"data-testid":`project-details-${e.key}`,className:`fixed z-50 max-h-[20rem] w-[19rem] overflow-y-auto rounded-lg border border-border bg-surface p-3 text-xs shadow-lg`,style:{left:c,top:l},children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5`,children:[(0,G.jsx)(J.Project,{className:`w-3.5 h-3.5 shrink-0 text-project`}),(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(kF,{label:`Chats`,value:String(e.sessions.length)}),(0,G.jsx)(kF,{label:`Working now`,value:i>0?String(i):null}),(0,G.jsx)(kF,{label:`Last activity`,value:a?eg(a):null}),(0,G.jsx)(kF,{label:o.length>1?`Folders`:`Folder`,value:o.length>1?`${o.length} folders`:o[0]??null})]}),e.projectId?(0,G.jsxs)(`div`,{className:`mt-2 border-t border-border pt-2`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-fg-faint`,children:`Standing instructions`}),s?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-fg`,"data-testid":`project-instructions-${e.key}`,children:s.length>400?`${s.slice(0,400)}…`:s}):(0,G.jsx)(`div`,{className:`text-fg-faint`,children:`None — chats here start with nothing extra.`})]}):(0,G.jsx)(`div`,{className:`mt-2 border-t border-border pt-2 text-fg-faint`,children:`Chats filed under no project.`})]}),document.body)}function EU(){return Yv(typeof window<`u`?window.oonacode:void 0)}function DU(e){if(e.upToDate)return`Everything on this PC is up to date — the app, the host service and the oona CLI.`;let t=[];return e.terminal&&t.push(`OonaCode updates the oona CLI and the host service in place — the service restarts and your chats come back with it.`),e.desktop&&t.push(e.terminal?`Then it downloads the app, installs it and relaunches, restoring your open tabs.`:`OonaCode downloads the update, installs it and relaunches. Your open chat tabs are restored afterwards.`),t.length===0?t.push("This window cannot install updates by itself — run the installer again, or `oona update` in a terminal. Your open chat tabs are stored in the host and come back automatically."):e.manual.length>0&&t.push(e.manual.includes(`desktop`)?`The app itself needs the installer from the website.`:"The rest needs `oona update` in a terminal."),t.join(` `)}var OU=2*Math.PI*10;function kU(){return typeof window<`u`&&window.oonacode!==void 0}function AU(){let{state:e,actions:t}=K(),n=e.update,r=e.updateInstall,i=e.prefs.dismissedUpdateVersion,a=n.version!==``&&(e.updateDismissed===n.version||i===n.version);if(!kU())return null;let o=Wv({install:r,manifestAvailable:n.available&&!a}),s=e.terminalUpdate.running,c=e.updateChecking||r.phase===`checking`||s,l=n.components.length,u=Math.round(r.percent),d=s?`Updating the CLI and host service`:o===`ready`?`Restart to finish updating`:o===`downloading`?`Downloading update (${u}%)`:o===`available`?`Update available (${l})`:`Check for updates`,f=s?`Updating the oona CLI and the host service…`:o===`ready`?`An update is ready — restart to finish`:o===`downloading`?`Downloading OonaCode ${r.version||`update`} — ${u}%`:o===`available`?`${l} component${l===1?``:`s`} can be updated`:`Check for updates`;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{if(o===`idle`){t.checkUpdates(!0);return}if(o===`ready`){t.installUpdate();return}t.openDialog(`update`)},title:f,"aria-label":d,"aria-busy":c||void 0,"data-testid":`update-badge`,"data-state":o,className:W(`relative inline-flex h-7 w-7 items-center justify-center rounded-full border transition-transform hover:scale-105`,o===`idle`?`border-border bg-surface-2 text-fg-muted hover:text-fg`:`border-accent bg-accent-soft text-accent`),children:[o===`downloading`?(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,"data-testid":`update-badge-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":u,className:`absolute inset-0 h-full w-full -rotate-90`,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,className:`stroke-border`}),(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:OU,strokeDashoffset:OU*(1-Math.max(0,Math.min(100,u))/100),className:`stroke-accent`})]}):null,c&&o!==`downloading`&&o!==`ready`?(0,G.jsx)(`span`,{"data-testid":`update-badge-checking`,className:`inline-flex`,children:(0,G.jsx)(J.Spinner,{className:`w-3.5 h-3.5`})}):o===`ready`?(0,G.jsx)(`span`,{"data-testid":`update-badge-ready`,className:`inline-flex`,children:(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`})}):o===`downloading`?(0,G.jsx)(`span`,{"data-testid":`update-badge-downloading`,className:`text-[9px] font-semibold`,children:u}):(0,G.jsx)(`span`,{"data-testid":o===`available`?`update-badge-available`:`update-badge-idle`,className:`inline-flex`,children:(0,G.jsx)(J.Download,{className:`w-3.5 h-3.5`})}),o===`available`?(0,G.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-accent`,"aria-hidden":!0}):null]})}function jU(){let{state:e,actions:t}=K(),n=e.updateInstall,r=Math.round(Math.max(0,Math.min(100,n.percent))),i=qv(n.bytesPerSecond);if(n.phase===`error`)return(0,G.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`update-error`,role:`alert`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(J.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`The update could not be downloaded.`}),(0,G.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.error})]})]}),(0,G.jsx)(`div`,{className:`mt-2`,children:(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`update-retry`,children:[(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]});let a=n.phase===`installing`;return(0,G.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`update-progress`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:a?`Installing and restarting…`:n.phase===`ready`?`Downloaded — restart to install`:`Downloading OonaCode ${n.version||``}`.trim()}),a?null:(0,G.jsxs)(`span`,{className:`text-fg-muted`,children:[r,`%`]})]}),n.notice?(0,G.jsx)(`div`,{className:`pre-wrap text-xs text-warn`,"data-testid":`update-notice`,role:`status`,children:n.notice}):null,(0,G.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-2`,children:(0,G.jsx)(`div`,{className:W(`h-full rounded-full bg-accent`,a&&`animate-pulse`),style:{width:`${a?100:r}%`},"data-testid":`update-progress-bar`})}),a?(0,G.jsx)(`div`,{className:`text-xs text-fg-faint`,children:`The host service stops for a few seconds while the installer runs, then OonaCode starts again with your chat tabs.`}):(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-fg-faint`,children:[(0,G.jsxs)(`span`,{children:[Kv(n.transferred),n.total>0?` of ${Kv(n.total)}`:``]}),i?(0,G.jsx)(`span`,{children:i}):null]})]})}function MU(){let{state:e,actions:t}=K(),n=e.terminalUpdate;return n.running?(0,G.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-border bg-surface-2 px-3 py-2 text-xs`,"data-testid":`terminal-update-running`,role:`status`,children:[(0,G.jsx)(J.Spinner,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium text-fg`,children:`Updating the oona CLI and host service...`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-fg-faint`,children:`The host service stops for a few seconds while its installer runs. Your chats are in the database and come back with it.`})]})]}):n.failed?(0,G.jsxs)(`div`,{className:`rounded-md border border-danger-soft bg-danger-soft px-3 py-2 text-xs text-danger`,"data-testid":`terminal-update-error`,role:`alert`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(J.Alert,{className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:`The CLI and host service could not be updated.`}),(0,G.jsx)(`div`,{className:`mt-0.5 pre-wrap break-words`,children:n.message})]})]}),(0,G.jsx)(`div`,{className:`mt-2`,children:(0,G.jsxs)(Y,{size:`sm`,onClick:()=>void t.installUpdate(),"data-testid":`terminal-update-retry`,children:[(0,G.jsx)(J.Refresh,{className:`w-3.5 h-3.5`}),` Try again`]})})]}):null}function NU({open:e,onClose:t}){let{state:n,actions:r}=K(),i=n.update,a=n.updateInstall,o=r.checkUpdates,s=a.phase===`downloading`||a.phase===`installing`||a.phase===`ready`;(0,v.useEffect)(()=>{!e||s||o(!1)},[e,s,o]);let c=EU(),l=Xv(i.components.map(e=>e.component),c,{checked:i.version!==``,shellEngaged:a.phase!==`idle`&&a.phase!==`checking`}),u=i.version||a.version,d=a.phase===`ready`,f=a.phase===`downloading`||a.phase===`installing`||d||a.phase===`error`,p=n.terminalUpdate.running,m=n.updateChecking||a.phase===`checking`||p;return(0,G.jsx)(Vy,{open:e,title:`Update OonaCode`,onClose:t,footer:d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:t,children:`Later`}),(0,G.jsxs)(Y,{variant:`primary`,onClick:()=>void r.installUpdate(),"data-testid":`update-restart`,children:[(0,G.jsx)(J.Refresh,{className:`w-4 h-4`}),`Restart and install`]})]}):f?(0,G.jsx)(Y,{onClick:t,children:`Close`}):l.upToDate?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Y,{onClick:()=>void r.checkUpdates(!0),busy:m,disabled:m,"data-testid":`update-check-again`,children:[(0,G.jsx)(J.Refresh,{className:`w-4 h-4`}),`Check again`]}),(0,G.jsx)(Y,{variant:`primary`,onClick:t,children:`Close`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:()=>r.dismissUpdate(),children:`Skip this version`}),(0,G.jsx)(Y,{onClick:t,children:`Later`}),(0,G.jsxs)(Y,{variant:`primary`,busy:m,disabled:m,onClick:()=>void r.installUpdate(),children:[(0,G.jsx)(J.Download,{className:`w-4 h-4`}),l.label]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[u?(0,G.jsxs)(`span`,{className:`font-medium`,children:[`Release `,u]}):null,i.channel?(0,G.jsx)(Q,{children:i.channel}):null,n.updateChecking?(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,"data-testid":`update-rechecking`,children:`checking for a newer one…`}):null,i.publishedAt?(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`published `,new Date(i.publishedAt).toLocaleDateString()]}):null]}),f?(0,G.jsx)(jU,{}):null,(0,G.jsx)(MU,{}),i.components.length>0?(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.components.map(e=>(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2`,children:[(0,G.jsx)(J.Download,{className:`mt-0.5 w-3.5 h-3.5 shrink-0 text-accent`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[e.current,` → `,(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:e.latest})]}),(0,G.jsx)(`div`,{className:`text-xs text-fg-faint`,"data-testid":`update-how-${e.component}`,children:Zv(e.component,c)}),e.notes?(0,G.jsx)(`div`,{className:`mt-0.5 pre-wrap text-xs text-fg-faint`,children:e.notes}):null]})]},e.component))}):null,i.notes?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-xs font-semibold uppercase tracking-wide text-fg-faint`,children:`Release notes`}),(0,G.jsx)(`div`,{className:`max-h-48 overflow-y-auto rounded-md bg-surface-2 px-3 py-2 pre-wrap text-xs text-fg-muted`,children:i.notes})]}):null,f?null:(0,G.jsx)(`p`,{className:`text-xs text-fg-faint`,"data-testid":`update-plan-note`,children:DU(l)})]})})}function PU(e){switch(e){case`open`:return{cls:`bg-ok`,label:`Connected`};case`connecting`:case`reconnecting`:return{cls:`bg-warn animate-pulse`,label:e===`connecting`?`Connecting…`:`Reconnecting…`};case`unauthorized`:return{cls:`bg-danger`,label:`Unauthorized`};case`closed`:return{cls:`bg-danger`,label:`Disconnected`};default:return{cls:`bg-fg-faint`,label:`Idle`}}}function FU(){let{state:e,actions:t}=K(),n=PU(e.connection.status),r=e.account?.loggedIn===!0,i=typeof window<`u`&&window.oonacode?.host===`vscode`;return(0,G.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b border-border bg-surface px-2 sm:px-3`,children:[i?null:(0,G.jsx)(X,{label:`Toggle sidebar`,onClick:()=>{typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(min-width: 768px)`).matches?t.toggleSidebarPinned():t.setSidebar(!e.ui.sidebarOpen)},"data-testid":`toggle-sidebar`,children:(0,G.jsx)(J.PanelLeft,{})}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`font-semibold tracking-tight`,children:`OonaCode`}),(0,G.jsx)(`span`,{className:`hidden text-fg-faint sm:inline`,children:`/`})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`session-picker`),title:`Open a session on this PC or another device`,className:`hidden min-w-0 truncate text-sm text-fg-muted hover:text-fg sm:inline`,"data-testid":`host-name`,children:e.connection.hostName??`host`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-muted`,title:e.connection.detail??n.label,"data-testid":`connection-status`,children:[(0,G.jsx)(`span`,{className:W(`inline-block h-2 w-2 rounded-full`,n.cls),"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})]}),(0,G.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,G.jsx)(IU,{}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>t.openDialog(`bug-report`),title:`Bug Report...`,"aria-label":`Bug Report...`,"data-testid":`bug-report-button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-full border border-border bg-surface-2 text-fg-muted transition-transform hover:scale-105 hover:text-fg`,children:(0,G.jsx)(J.Bug,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(AU,{}),e.hostUpdatedTo?(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:()=>window.location.reload(),title:`This window still runs the previous version; the host is now v${e.hostUpdatedTo}`,"data-testid":`reload-for-update`,children:[`Reload for v`,e.hostUpdatedTo]}):null,r?null:(0,G.jsxs)(Y,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),"data-testid":`sign-in`,children:[(0,G.jsx)(J.LogIn,{className:`w-3.5 h-3.5`}),` Sign in`]}),(0,G.jsx)(X,{label:e.prefs.explorerOpen?`Hide files`:`Show files`,onClick:()=>void t.savePrefs({explorerOpen:!e.prefs.explorerOpen}),className:e.prefs.explorerOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-explorer`,children:(0,G.jsx)(J.Folder,{})}),(0,G.jsx)(X,{label:e.prefs.sessionPanelOpen?`Hide session info`:`Show session info`,onClick:()=>void t.savePrefs({sessionPanelOpen:!e.prefs.sessionPanelOpen}),className:e.prefs.sessionPanelOpen?`bg-surface-2 text-fg`:void 0,"data-testid":`toggle-session-panel`,children:(0,G.jsx)(J.Panel,{})}),(0,G.jsx)(X,{label:`Doctor`,onClick:()=>t.openDialog(`doctor`),children:(0,G.jsx)(J.Stethoscope,{})}),r?(0,G.jsx)(LU,{}):null,(0,G.jsx)(X,{label:`Account`,onClick:()=>t.openDialog(`account`),children:(0,G.jsxs)(`span`,{className:`relative`,children:[(0,G.jsx)(J.User,{}),r?(0,G.jsx)(`span`,{className:W(`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full`,e.account?.vaultUnlocked?`bg-ok`:`bg-warn`)}):null]})}),(0,G.jsx)(X,{label:`Settings`,onClick:()=>t.openDialog(`settings`),children:(0,G.jsx)(J.Settings,{})})]})]})}function IU(){let{actions:e}=K(),[t,n]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=typeof window<`u`?window.oonacode:void 0;if(!e?.getDebugging)return;let t=!0;return e.getDebugging().then(e=>{t&&n(e.running)},()=>{}),()=>{t=!1}},[]),!t||!bc(t))return null;let r=OH(t);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>e.openSettings(`developer`),title:r,"aria-label":r,"data-testid":`debugging-badge`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full bg-red-600 px-2.5 text-[11px] font-semibold text-white hover:bg-red-700`,children:[(0,G.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-white`,"aria-hidden":!0}),`Debugging on`]})}function LU(){let{state:e}=K(),[t,n]=(0,v.useState)(!1),r=(0,v.useRef)(null),i=e.plan;(0,v.useEffect)(()=>{if(!t)return;let e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]);let a=i?i.credits.balance:null,o=i?Sv(i):null,s=Tv(i),c=Ev;return(0,G.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,G.jsx)(X,{label:s?`Credits and plan — ${s.text}`:`Credits and plan`,onClick:()=>n(e=>!e),"data-testid":`balance-badge`,className:t?`bg-surface-2 text-fg`:void 0,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(J.Coins,{}),a===null?null:(0,G.jsx)(`span`,{className:W(`hidden text-xs tabular-nums sm:inline`,s?s.level===`empty`?`text-danger`:`text-warn`:void 0),"data-testid":`balance-credits`,"data-level":s?.level??`ok`,children:c(a)})]})}),t?(0,G.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-1 w-64 rounded-md border border-border bg-surface p-3 text-sm shadow-lg`,"data-testid":`balance-popover`,children:i===null||o===null?(0,G.jsx)(`div`,{className:`text-fg-muted`,children:`Balance is unavailable — the gateway can't be reached.`}):(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Plan`}),(0,G.jsxs)(`span`,{className:`font-medium`,children:[i.planName,i.status===`none`?` (lapsed)`:``]})]}),(0,G.jsx)(`div`,{className:`h-px bg-border`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Credits`}),(0,G.jsx)(`span`,{className:`font-semibold tabular-nums`,children:c(o.balance)})]}),s?(0,G.jsx)(`div`,{className:W(`rounded-sm px-2 py-1 text-[11px]`,s.level===`empty`?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),"data-testid":`balance-warning`,children:s.text}):null,o.hasSplit?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Plan credits`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:c(o.plan??0)})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-fg-muted`,children:`Top-up credits`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:c(o.topup??0)})]})]}):null,(0,G.jsxs)(`div`,{className:`text-[11px] text-fg-faint`,children:[i.credits.monthlyGrant>0?`Plan credits top up to ${c(i.credits.monthlyGrant)} each 30-day period and expire with it; top-ups never do.`:`This plan pays no monthly credits — the signup gift and anything you buy never expire.`,` `,`Free models never draw on this balance.`]})]})}):null]})}function RU(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`could not read the file`)),r.onload=()=>{let e=typeof r.result==`string`?r.result:``,n=e.indexOf(`,`);t(n>=0?e.slice(n+1):``)},r.readAsDataURL(e)})}function zU(e,t){let n=[],r=e.length,i=e.reduce((e,t)=>e+t.size,0);for(let e of t){if(r>=5)return{accepted:n,refused:`At most 5 files per report.`};if(e.size>5242880)return{accepted:n,refused:`${e.name} is ${Kv(e.size)}; a file may be at most ${Kv(Zs)}.`};if(i+e.size>12582912)return{accepted:n,refused:`All files together may be at most ${Kv(Qs)}.`};n.push(e),r+=1,i+=e.size}return{accepted:n,refused:null}}function BU(e){return e instanceof fm?e.code===`account_required`||e.status===401?`Sign in to OonaCode first — a report is filed under your account so we can answer it.`:gm(e)?`This host build cannot send bug reports yet — update OonaCode on this PC.`:e.status===429?`Too many reports in a minute — wait a moment and send again.`:e.status===413?`The attachments are too large for one report.`:e.message||`The report could not be sent.`:e instanceof Error&&e.message?e.message:`The report could not be sent.`}var VU=0;function HU({open:e,onClose:t}){let{state:n,actions:r,api:i}=K(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),h=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(o(``),c([]),u(!1),f(null))},[e]);let g=n.account?.loggedIn===!0,_=typeof i.sendBugReport==`function`,y=typeof window<`u`?window.oonacode:void 0,b=y?y.host===`vscode`?`vscode`:`desktop`:`browser`,x=n.currentSessionId?n.sessions.find(e=>e.id===n.currentSessionId)??null:null,S=(0,v.useCallback)(async e=>{let t=Array.from(e);if(t.length===0)return;let{accepted:n,refused:r}=zU(s,t);f(r);let i=t.filter(e=>n.includes(e));if(i.length!==0){m(!0);try{let e=[];for(let t of i){let n=await RU(t);if(!n)continue;let r=t.type||`application/octet-stream`;VU+=1,e.push({key:`f${VU}`,name:t.name,contentType:r,dataBase64:n,size:t.size,preview:r.startsWith(`image/`)?`data:${r};base64,${n}`:null})}c(t=>[...t,...e])}catch(e){f(e instanceof Error?e.message:`could not read the file`)}finally{m(!1)}}},[s]),C=e=>{let t=e.target.files;t&&S(t),e.target.value=``},w=e=>c(t=>t.filter(t=>t.key!==e)),T=async()=>{let e=a.trim();if(!e||l)return;if(!_){f(`This host build cannot send bug reports yet — update OonaCode on this PC.`);return}u(!0),f(null);let o={message:e.slice(0,Xs),...s.length>0?{attachments:s.map(({name:e,contentType:t,dataBase64:n})=>({name:e,contentType:t,dataBase64:n}))}:{},...n.currentSessionId?{sessionId:n.currentSessionId}:{},detail:{embedded:b,connection:n.connection.status,...y?.appVersion?{appVersion:y.appVersion}:{},...n.bundleAppVersion?{uiVersion:n.bundleAppVersion}:{},...n.info?.appVersion?{hostVersion:n.info.appVersion}:{},...n.info?.engine?.version?{engineVersion:n.info.engine.version}:{},...x?.status?{sessionStatus:x.status}:{}}};try{let e=await i.sendBugReport(o);r.toast(`success`,`Bug report #${e.id} sent — thank you.`),t()}catch(e){f(BU(e))}finally{u(!1)}},E=Xs-a.length;return(0,G.jsx)(Vy,{open:e,title:`Bug Report`,onClose:t,footer:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{onClick:t,disabled:l,children:`Cancel`}),(0,G.jsxs)(Y,{variant:`primary`,busy:l,disabled:!a.trim()||p,onClick:()=>void T(),"data-testid":`bug-report-send`,children:[(0,G.jsx)(J.Bug,{className:`w-4 h-4`}),`Send report`]})]}),children:(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,"data-testid":`bug-report-dialog`,children:[(0,G.jsxs)(`p`,{className:`text-fg-muted`,children:[`Tell us what went wrong and what you expected. Screenshots help. The report is filed under your account with this PC's versions`,x?` and the open chat’s model`:``,`; the chat itself is never sent.`]}),g?null:(0,G.jsx)(`div`,{className:`rounded-md border border-warn/40 bg-warn-soft px-3 py-2 text-xs text-warn`,children:`Sign in to OonaCode to send a report — it is filed under your account so we can answer it.`}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`font-medium text-fg`,children:`What happened?`}),(0,G.jsx)(`textarea`,{name:`message`,className:W(Z,`min-h-32 resize-y`),value:a,maxLength:Xs,placeholder:`The answer stopped after a few seconds with “API error”. I was using…`,onChange:e=>o(e.target.value),"data-testid":`bug-report-message`}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:E<500?`${E} characters left`:``})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{ref:h,type:`file`,multiple:!0,className:`hidden`,onChange:C,"data-testid":`bug-report-files`}),(0,G.jsxs)(Y,{size:`sm`,onClick:()=>h.current?.click(),disabled:l||p||s.length>=5,children:[(0,G.jsx)(J.Paperclip,{className:`w-3.5 h-3.5`}),`Attach files or pictures`]}),(0,G.jsxs)(`span`,{className:`text-xs text-fg-faint`,children:[`up to `,5,` files,`,` `,Kv(Zs),` each`]})]}),s.length>0?(0,G.jsx)(`ul`,{className:`flex flex-wrap gap-2`,"data-testid":`bug-report-attachments`,children:s.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2 py-1 text-xs`,children:[e.preview?(0,G.jsx)(`img`,{src:e.preview,alt:``,className:`h-8 w-8 rounded object-cover`,"aria-hidden":!0}):(0,G.jsx)(J.Paperclip,{className:`w-3.5 h-3.5 text-fg-muted`}),(0,G.jsx)(`span`,{className:`max-w-40 truncate`,title:e.name,children:e.name}),(0,G.jsx)(`span`,{className:`text-fg-faint`,children:Kv(e.size)}),(0,G.jsx)(X,{label:`Remove ${e.name}`,onClick:()=>w(e.key),children:(0,G.jsx)(J.X,{className:`w-3.5 h-3.5`})})]},e.key))}):null]}),d?(0,G.jsx)(`div`,{className:`text-xs text-danger`,role:`alert`,"data-testid":`bug-report-error`,children:d}):null]})})}function UU(e){let t=Date.parse(`${e}T12:00:00`);return Number.isFinite(t)?new Date(t).toLocaleDateString(void 0,{dateStyle:`long`}):e}function WU({open:e,notes:t,onClose:n}){return(0,G.jsx)(Vy,{open:e,title:`What's new in OonaCode`,onClose:n,footer:(0,G.jsx)(Y,{variant:`primary`,onClick:n,children:`Got it`}),children:(0,G.jsx)(`div`,{className:`space-y-5 text-sm`,"data-testid":`whats-new`,children:t.map(e=>(0,G.jsxs)(`section`,{"data-version":e.version,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-baseline gap-2`,children:[(0,G.jsxs)(`h3`,{className:`text-base font-semibold`,children:[`Version `,e.version]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-faint`,children:UU(e.date)})]}),e.added.length>0?(0,G.jsx)(`ul`,{className:`space-y-1.5`,children:e.added.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(J.Plus,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent`}),(0,G.jsx)(`span`,{children:e})]},t))}):null,e.fixed.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`mb-1 mt-3 text-xs font-medium uppercase tracking-wide text-fg-faint`,children:`Fixed`}),(0,G.jsx)(`ul`,{className:`space-y-1.5`,children:e.fixed.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(J.Check,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-ok`}),(0,G.jsx)(`span`,{children:e})]},t))})]}):null]},`${e.version}:${e.platforms?.join(`,`)??`all`}`))})})}function GU(){let{state:e,actions:t}=K(),n=im(e.account);return!n||e.ui.dialog===`account`?null:(0,G.jsxs)(`div`,{role:`status`,"data-testid":`vault-rekey-banner`,className:`flex items-center gap-2 bg-warn-soft px-3 py-1.5 text-xs text-warn`,children:[(0,G.jsx)(J.Alert,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`flex-1`,children:dm(n)}),(0,G.jsx)(Y,{size:`sm`,variant:`primary`,onClick:()=>t.openDialog(`account`),children:`Open Account`})]})}function KU({onReconnect:e}){let{state:t}=K(),n=t.connection.status;if(n===`open`||n===`idle`||n===`connecting`)return null;let r=n===`unauthorized`&&!window.oonacode;return(0,G.jsxs)(`div`,{role:`status`,className:W(`flex items-center gap-2 px-3 py-1.5 text-xs`,r?`bg-danger-soft text-danger`:`bg-warn-soft text-warn`),children:[r?(0,G.jsx)(J.Alert,{className:`w-3.5 h-3.5`}):(0,G.jsx)(J.Spinner,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`flex-1`,children:r?`The host rejected this connection${t.connection.detail?` (${t.connection.detail})`:``}. Re-open the UI from the desktop app or paste a fresh token.`:`Reconnecting to the host${t.connection.detail?` — ${t.connection.detail}`:``}…`}),r&&e?(0,G.jsx)(Y,{size:`sm`,variant:`danger`,onClick:e,children:`Enter token`}):null]})}function qU(){let{state:e,actions:t}=K(),n=(0,v.useRef)(1);n.current=Object.keys(e.layout.groups).length,(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{if(e.ctrlKey||e.metaKey){if(e.key===`Tab`){e.preventDefault(),t.cycleTab(e.shiftKey?-1:1);return}if(!(e.shiftKey||e.altKey)){if(e.key===`\\`||e.code===`Backslash`){e.preventDefault(),t.splitTab(`right`);return}if(/^[1-9]$/.test(e.key)){let r=Number(e.key)-1;if(r>=n.current)return;e.preventDefault(),t.focusGroupAt(r),JU(r)}}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t])}function JU(e){let t=()=>{(document.querySelectorAll(`[data-editor-group]`)[e]?.querySelector(`[data-testid="composer"] textarea`))?.focus()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,0)}function YU(){let{state:e,actions:t}=K(),n=(0,v.useRef)(!1),r=e.account?.loggedIn===!0,i=e.prefs.claudeImportOffered?3:e.prefs.claudeImportOffers,a=e.ui.dialog===`none`&&e.windowRole===`main`,o=e.settings!==null,s=(0,v.useRef)(e.ui.dialog);s.current=e.ui.dialog,(0,v.useEffect)(()=>{n.current||!o||i>=3||!r||!a||(n.current=!0,t.scanClaudeSessions().then(e=>{if(e.sessions.some(e=>!e.alreadyImported&&e.deletedHere!==!0&&!e.unavailable)){if(s.current!==`none`){n.current=!1;return}t.offerImport(),t.savePrefs({claudeImportOffers:i+1})}}).catch(()=>{}))},[t,a,r,i,o])}function XU(){let{state:e,actions:t}=K(),n=(0,v.useRef)(!1),[r,i]=(0,v.useState)(null),a=typeof window<`u`?window.oonacode:void 0,o=a?.appVersion??e.bundleAppVersion??null,s=e.settings!==null,c=e.prefs.lastSeenReleaseNotes,l=e.sessionListLoaded,u=e.sessionsTotal>0||e.sessions.length>0,d=e.settings?.uiPrefs,f=d!==void 0&&!(`lastSeenReleaseNotes`in d),p=e.ui.dialog===`none`&&e.windowRole===`main`,m=e.info?.platform??a?.platform??null;(0,v.useEffect)(()=>{if(n.current||!s||!o||!p||c===null&&!l||(n.current=!0,f))return;let{record:e,show:r}=tl(o,c,u,void 0,m);e!==null&&t.savePrefs({lastSeenReleaseNotes:e}),r.length!==0&&(i(r),t.openDialog(`whats-new`))},[t,f,p,o,c,m,l,s,u]);let h=e.ui.dialog===`whats-new`;return(0,v.useEffect)(()=>{!h&&r&&i(null)},[r,h]),r??(o?el(o,`0`,void 0,m):[])}function ZU({onUnauthorized:e}){let{state:t,actions:n}=K(),r=(0,v.useCallback)(()=>n.openDialog(`none`),[n]),i=XU();YU();let a=typeof window<`u`&&window.oonacode?.host===`vscode`,o=t.ui.sidebarOpen&&!a;return qU(),(0,G.jsxs)(`div`,{className:`flex h-full flex-col bg-bg text-fg`,children:[(0,G.jsx)(FU,{}),(0,G.jsx)(KU,{onReconnect:e}),(0,G.jsx)(GU,{}),(0,G.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[(0,G.jsx)(IR,{hidden:a,children:(0,G.jsx)(gU,{})}),o?(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>n.setSidebar(!1),"aria-hidden":!0}):null,t.prefs.explorerOpen?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 md:hidden`,onClick:()=>void n.savePrefs({explorerOpen:!1}),"aria-hidden":!0}),(0,G.jsx)(`div`,{className:`absolute inset-y-0 left-0 z-30 flex max-w-[85vw] md:static md:z-auto md:max-w-none`,children:(0,G.jsx)(yH,{})})]}):null,(0,G.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,G.jsx)(rR,{})}),t.prefs.sessionPanelOpen?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`absolute inset-0 z-20 bg-black/30 lg:hidden`,onClick:()=>void n.savePrefs({sessionPanelOpen:!1}),"aria-hidden":!0}),(0,G.jsx)(`div`,{className:`absolute inset-y-0 right-0 z-30 flex max-w-[85vw] lg:static lg:z-auto lg:max-w-none`,children:(0,G.jsx)(hH,{})})]}):null]}),(0,G.jsx)(fR,{open:t.ui.dialog===`project`,onClose:r}),(0,G.jsx)(AR,{open:t.ui.dialog===`projects`,startNew:t.projectsStartNew,selectId:t.projectsSelectId,onClose:r}),(0,G.jsx)(yB,{open:t.ui.dialog===`assign-project`,onClose:r}),(0,G.jsx)(YH,{open:t.ui.dialog===`settings`,onClose:r}),(0,G.jsx)(Gb,{open:t.ui.dialog===`account`,onClose:r}),(0,G.jsx)(dR,{open:t.ui.dialog===`doctor`,onClose:r}),(0,G.jsx)(ex,{open:t.ui.dialog===`session-picker`,onClose:r}),(0,G.jsx)(NU,{open:t.ui.dialog===`update`,onClose:r}),(0,G.jsx)(HU,{open:t.ui.dialog===`bug-report`,onClose:r}),(0,G.jsx)(ER,{open:t.ui.dialog===`claude-login`,onClose:r}),(0,G.jsx)(dV,{open:t.ui.dialog===`oauth-login`,onClose:r}),(0,G.jsx)(fV,{open:t.ui.dialog===`manage-models`,onClose:r}),(0,G.jsx)(YV,{open:t.ui.dialog===`import-claude`,autoOffer:t.importOffered,onClose:r}),(0,G.jsx)(LR,{open:t.ui.dialog===`export-chats`,onClose:r}),(0,G.jsx)(az,{open:t.ui.dialog===`conversations`,selectId:t.conversationsSelectId,onClose:r}),(0,G.jsx)(gB,{open:t.ui.dialog===`chat-abouts`,onClose:r}),(0,G.jsx)(oB,{open:t.ui.dialog===`voice-summary`,onClose:r}),(0,G.jsx)(WU,{open:t.ui.dialog===`whats-new`,notes:i,onClose:r}),(0,G.jsx)(uV,{open:t.ui.connectProviderId!==null,providerId:t.ui.connectProviderId,onClose:()=>n.openProviderConnect(null)}),(0,G.jsx)(ZH,{})]})}function QU({onUnauthorized:e}){let{state:t}=K(),n=t.account?.loggedIn===!0&&!t.account.vaultUnlocked;return(0,v.useEffect)(()=>{window.oonacode?.setVaultLocked?.(n)},[n]),t.accountLoaded?t.account?.loggedIn?!t.account.vaultUnlocked&&im(t.account)===null?(0,G.jsx)(cU,{}):(0,G.jsx)(ZU,{onUnauthorized:e}):(0,G.jsx)(sU,{}):(0,G.jsx)(rU,{})}function $U({api:e,socket:t,relay:n,initialSessionId:r,onUnauthorized:i,reportError:a}){return(0,G.jsx)(jy,{api:e,socket:t,relay:n??null,initialSessionId:r??null,onUnauthorized:i,...a?{reportError:a}:{},children:(0,G.jsx)(QU,{onUnauthorized:i})})}var eW=`oonacode.host.connection`,tW=`session`;function nW(e){let t=e.replace(/^#\/?\??/,``),n=new URLSearchParams(t),r=n.get(`token`),i=n.get(`host`)??n.get(`baseUrl`),a=n.get(tW);n.delete(`token`),n.delete(`host`),n.delete(`baseUrl`);let o=n.toString();return{token:r&&r.trim()?r.trim():null,baseUrl:i,sessionId:a,restHash:o?`#${o}`:``}}function rW(e){if(!e)return null;try{let t=e.getItem(eW);if(!t)return null;let n=JSON.parse(t);if(typeof n.baseUrl==`string`&&typeof n.token==`string`&&n.token)return{baseUrl:mm(n.baseUrl),token:n.token}}catch{}return null}function iW(e,t){if(e)try{t?e.setItem(eW,JSON.stringify(t)):e.removeItem(eW)}catch{}}async function aW(e){let t=nW(e.location.hash);if(t.token){let n={baseUrl:mm(t.baseUrl??e.location.origin),token:t.token};iW(e.storage,n);let r=`${e.location.pathname}${e.location.search}${t.restHash}`;try{e.replaceUrl?.(r)}catch{}return{connection:n,source:`hash`,sessionId:t.sessionId}}if(e.bridge&&typeof e.bridge.getConnection==`function`)try{let n=await e.bridge.getConnection();if(n&&typeof n.token==`string`&&n.token&&typeof n.baseUrl==`string`){let r={baseUrl:mm(n.baseUrl),token:n.token};return iW(e.storage,r),{connection:r,source:`bridge`,sessionId:t.sessionId}}}catch{}let n=rW(e.storage);return n?{connection:n,source:`storage`,sessionId:t.sessionId}:{connection:null,source:`none`,sessionId:t.sessionId}}function oW(e=window){let t=null;try{t=e.sessionStorage}catch{t=null}return aW({location:e.location,storage:t,replaceUrl:t=>e.history.replaceState(null,``,t),bridge:e.oonacode})}var sW=1;function cW(){let e=globalThis.crypto;return e&&typeof e.randomUUID==`function`?e.randomUUID():`c-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function lW(e,t){return`${mm(e).replace(/^http(s?):/i,`ws$1:`)}${b}?token=${encodeURIComponent(t)}`}var uW=class{clientId;opts;ws=null;_status=`idle`;attempts=0;preOpenFailures=0;epoch=0;reconnectTimer=null;pingTimer=null;manuallyClosed=!1;handlers=new Map;anyHandlers=new Set;statusHandlers=new Set;subscriptions=new Map;promptCounter=0;constructor(e){this.opts={clientKind:`web`,minBackoffMs:500,maxBackoffMs:15e3,pingIntervalMs:25e3,authProbeAfterFailures:2,...e,baseUrl:mm(e.baseUrl)},this.clientId=e.clientId??cW()}get status(){return this._status}connect(){this.manuallyClosed=!1,!(this.ws&&(this._status===`open`||this._status===`connecting`))&&this.open()}close(){this.manuallyClosed=!0,this.epoch+=1,this.clearTimers();let e=this.ws;if(this.ws=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`client closed`)}catch{}}this.setStatus(`closed`)}send(e){let t=this.ws;if(!t||t.readyState!==sW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}on(e,t){let n=this.handlers.get(e);n||(n=new Set,this.handlers.set(e,n));let r=t;return n.add(r),()=>{n?.delete(r)}}onAny(e){return this.anyHandlers.add(e),()=>{this.anyHandlers.delete(e)}}onStatus(e){return this.statusHandlers.add(e),e(this._status),()=>{this.statusHandlers.delete(e)}}subscribe(e,t){let n=this.subscriptions.get(e),r=t??n;this.subscriptions.set(e,r),this.send(r===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:r})}unsubscribe(e){this.subscriptions.delete(e),this.send({type:`unsubscribe`,sessionId:e})}noteSeq(e,t){if(t===null||!this.subscriptions.has(e))return;let n=this.subscriptions.get(e);(n===void 0||t>n)&&this.subscriptions.set(e,t)}prompt(e,t,n={}){let r=n.requestId??`req-${this.clientId.slice(0,8)}-${++this.promptCounter}`,i={type:`prompt`,sessionId:e,requestId:r,text:t};if(n.attachments&&n.attachments.length>0&&(i.attachments=n.attachments),n.options&&(i.options=n.options),!this.send(i))throw Error(`not connected`);return r}respondPermission(e,t,n){return this.send({type:`permission_response`,sessionId:e,requestId:t,decision:n})}interrupt(e){return this.send({type:`interrupt`,sessionId:e})}setModel(e,t){return this.send({type:`set_model`,sessionId:e,model:t})}setPermissionMode(e,t,n){return this.send({type:`set_permission_mode`,sessionId:e,mode:t,...n===void 0?{}:{posture:n}})}setEffort(e,t){return this.send({type:`set_effort`,sessionId:e,effort:t})}open(){this.clearTimers(),this.epoch+=1,this.setStatus(this.attempts===0?`connecting`:`reconnecting`);let e=lW(this.opts.baseUrl,this.opts.token),t=this.opts.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch(e){this.scheduleReconnect(String(e?.message??e));return}this.ws=n;let r=!1;n.onopen=()=>{if(this.ws===n){r=!0,this.attempts=0,this.preOpenFailures=0,this.setStatus(`open`),this.send({type:`hello`,protocolVersion:1,clientKind:this.opts.clientKind,clientId:this.clientId,...this.opts.clientVersion?{clientVersion:this.opts.clientVersion}:{}});for(let[e,t]of this.subscriptions)this.send(t===void 0?{type:`subscribe`,sessionId:e}:{type:`subscribe`,sessionId:e,afterSeq:t});this.opts.pingIntervalMs>0&&(this.pingTimer=setInterval(()=>this.send({type:`ping`,ts:Date.now()}),this.opts.pingIntervalMs))}},n.onmessage=e=>{if(this.ws!==n)return;let t;try{t=typeof e.data==`string`?JSON.parse(e.data):null}catch{return}Pe(t)&&this.dispatch(t)},n.onerror=()=>{},n.onclose=e=>{if(this.ws!==n)return;if(this.ws=null,this.pingTimer&&=(clearInterval(this.pingTimer),null),this.manuallyClosed){this.setStatus(`closed`);return}if(e.code===4401||e.code===4403||e.code===1008){this.setStatus(`unauthorized`,e.reason||`host rejected the token or origin`);return}let t=e.reason||`closed (${e.code})`;if(this.preOpenFailures=r?0:this.preOpenFailures+1,!r&&this.opts.authProbeAfterFailures>0&&this.preOpenFailures>=this.opts.authProbeAfterFailures){this.probeAuthThenReconnect(t);return}this.scheduleReconnect(t)}}async probeAuthThenReconnect(e){let t=this.epoch;this.setStatus(`reconnecting`,e);let n=this.opts.fetchImpl??((e,t)=>fetch(e,t)),r=!1;try{let e=await n(`${this.opts.baseUrl}${z.health}`,{method:`GET`,headers:{authorization:`Bearer ${this.opts.token}`}});if(e.status===401||e.status===403)r=!0;else if(e.status===200){let t=await e.json().catch(()=>null);r=!(t&&typeof t==`object`&&typeof t.hostId==`string`)}}catch{}if(!(this.manuallyClosed||t!==this.epoch)){if(r){this.setStatus(`unauthorized`,`host rejected the token`);return}this.scheduleReconnect(e)}}dispatch(e){e.type===`agent`&&e.seq!==null&&this.noteSeq(e.sessionId,e.seq);let t=this.handlers.get(e.type);if(t)for(let n of[...t])dW(()=>n(e));for(let t of[...this.anyHandlers])dW(()=>t(e))}scheduleReconnect(e){this.attempts+=1;let t=Math.min(this.opts.maxBackoffMs,this.opts.minBackoffMs*2**Math.min(this.attempts-1,10)),n=Math.round(t*(.7+Math.random()*.6));this.setStatus(`reconnecting`,e);let r=this.opts.setTimeoutImpl??setTimeout;this.reconnectTimer=r(()=>{this.reconnectTimer=null,this.manuallyClosed||this.open()},n)}clearTimers(){this.reconnectTimer&&=((this.opts.clearTimeoutImpl??clearTimeout)(this.reconnectTimer),null),this.pingTimer&&=(clearInterval(this.pingTimer),null)}setStatus(e,t){this._status=e;for(let n of[...this.statusHandlers])dW(()=>n(e,t))}};function dW(e){try{e()}catch(e){console.error(`[HostSocket] handler failed`,e)}}var fW=/([?&#](?:token|access_token|key|api_key|secret|password)=)[^&#\s"']*/gi,pW=/\b(Bearer|Basic)\s+[A-Za-z0-9\-._~+/=]{8,}/g;function mW(e){return e.replace(fW,`$1[redacted]`).replace(pW,`$1 [redacted]`)}function hW(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function gW(e){return typeof e==`object`&&!!e&&typeof e.message==`string`}function _W(e){if(gW(e)){let t=typeof e.name==`string`&&e.name?e.name:`Error`,n=typeof e.stack==`string`&&e.stack?e.stack:null;return{message:e.message||t,stack:n}}return typeof e==`string`?{message:hW(e,512),stack:null}:{message:`Unhandled rejection (${e===null?`null`:Array.isArray(e)?`array`:typeof e})`,stack:null}}function vW(e){return e?e.split(`
|
|
161
|
+
`).find(e=>/^\s+at\s/.test(e))?.trim()??``:``}function yW(e){let t=e.now??(()=>Date.now()),n=e.maxPerMinute??5,r=e.embedded??`browser`,i=[],a=new Map,o=(e,t)=>{for(;i.length>0&&(i[0]??0)<=t-6e4;)i.shift();for(let[e,n]of a)n<=t-6e4&&a.delete(e);return a.has(e)||i.length>=n?!1:(i.push(t),a.set(e,t),!0)},s=async(n,i={})=>{try{let a=e.api.reportError;if(typeof a!=`function`)return!1;let{message:s,stack:c}=_W(n),l=t();if(!o(`${s}\n${vW(c)}`,l))return!1;let u={client:`web-ui`,message:hW(mW(s),Js),detail:{source:`manual`,...i,embedded:r},at:new Date(l).toISOString()};return c&&(u.stack=hW(mW(c),Ys)),e.appVersion&&(u.appVersion=e.appVersion),e.platform&&(u.platform=e.platform),await a.call(e.api,u),!0}catch{return!1}},c=e=>{if(typeof e?.message!=`string`)return;let t=e.error??null;if(t===null&&!e.message)return;let n={source:`window.onerror`};typeof e.filename==`string`&&e.filename&&(n.filename=e.filename),typeof e.lineno==`number`&&e.lineno>0&&(n.lineno=e.lineno),typeof e.colno==`number`&&e.colno>0&&(n.colno=e.colno),s(t??e.message,n)},l=e=>{s(e?.reason,{source:`unhandledrejection`})};return{install:t=>{if(typeof e.api.reportError!=`function`)return()=>{};let n=e=>c(e),r=e=>l(e);return t.addEventListener(`error`,n),t.addEventListener(`unhandledrejection`,r),()=>{t.removeEventListener(`error`,n),t.removeEventListener(`unhandledrejection`,r)}},report:s,handleErrorEvent:c,handleRejectionEvent:l}}var bW=1;function xW(e,t){return`${mm(e).replace(/^http(s?):/i,`ws$1:`)}${z.remoteWs}?token=${encodeURIComponent(t)}`}function SW(e){return`tab-${e}-${Math.random().toString(36).slice(2,10)}`}var CW=class{#e;#t=new Map;#n=new Set;#r=null;#i=`idle`;#a=null;#o=0;#s=!1;#c=0;#l=null;constructor(e){this.#e=e}get status(){return this.#i}get pairingCount(){return this.#t.size}onStatus(e){return this.#n.add(e),e(this.#i),()=>{this.#n.delete(e)}}connect(){if(this.#r||this.#i===`connecting`)return;this.#s=!1,this.#d(`connecting`);let e=xW(this.#e.baseUrl,this.#e.token),t=this.#e.createWebSocket??(e=>new WebSocket(e)),n;try{n=t(e)}catch{this.#d(`closed`),this.#u();return}this.#r=n,n.onopen=()=>{if(this.#r===n){this.#o=0,this.#d(`open`),this.#f({type:`remote_hello`,protocolVersion:1,clientId:this.#e.clientId??`web-ui`,...this.#e.clientVersion?{clientVersion:this.#e.clientVersion}:{}});for(let e of this.#t.values())this.#p(e)}},n.onmessage=e=>{this.#r===n&&this.#h(e.data)},n.onerror=()=>void 0,n.onclose=()=>{if(this.#r===n){this.#r=null;for(let e of this.#t.values())this.#m(e,{state:`host_offline`,online:!1,detail:`reconnecting to this PC…`});this.#i!==`unavailable`&&this.#d(`closed`),this.#u()}}}close(){this.#s=!0,this.#l=null,this.#a&&(this.#e.clearTimeoutImpl??clearTimeout)(this.#a),this.#a=null,this.#t.clear();let e=this.#r;if(this.#r=null,e){e.onopen=e.onclose=e.onerror=e.onmessage=null;try{e.close(1e3,`closed`)}catch{}}this.#d(`idle`)}#u(){let e=this.#e.reconnectDelayMs??1e3;if(this.#s||e<=0||this.#a||this.#t.size===0)return;let t=this.#e.maxReconnectDelayMs??2e4;this.#o+=1;let n=Math.min(e*2**Math.min(this.#o-1,5),t),r=this.#e.setTimeoutImpl??setTimeout;this.#a=r(()=>{this.#a=null,this.#s||this.connect()},n)}#d(e,t){if(this.#i!==e){this.#i=e;for(let n of[...this.#n])n(e,t)}}#f(e){let t=this.#r;if(!t||t.readyState!==bW)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}attach(e){this.#c+=1;let t=SW(this.#c),n={pairingId:t,hostId:e.hostId,sessionId:e.sessionId,state:`unavailable`,online:!1,detail:null,onFrame:e.onFrame,onState:e.onState};return this.#t.set(t,n),this.#r&&this.#r.readyState===bW?(this.#l!==null&&this.#m(n,{detail:this.#l}),this.#p(n)):this.connect(),{pairingId:t,hostId:e.hostId,sessionId:e.sessionId,send:e=>this.send(t,e),detach:()=>this.detach(t)}}detach(e){this.#t.get(e)&&(this.#t.delete(e),this.#f({type:`remote_detach`,pairingId:e}),this.#t.size===0&&this.close())}send(e,t){let n=this.#t.get(e);return!n||!n.online?!1:this.#f({type:`remote_send`,pairingId:e,frame:t})}#p(e){this.#f({type:`remote_attach`,pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId})}#m(e,t){Object.assign(e,t),e.onState({pairingId:e.pairingId,hostId:e.hostId,sessionId:e.sessionId,state:e.state,online:e.online,detail:e.detail})}#h(e){let t;try{let n=JSON.parse(typeof e==`string`?e:String(e));if(!Re(n))return;t=n}catch{return}switch(t.type){case`remote_welcome`:if(!t.canRelay){let e=t.reason??`this PC cannot reach your other devices right now`;this.#l=e,this.#d(`unavailable`,e);for(let t of this.#t.values())this.#m(t,{state:`unavailable`,online:!1,detail:e});return}this.#l=null,this.#i===`unavailable`&&this.#d(`open`);for(let e of this.#t.values())e.online||this.#p(e);return;case`remote_status`:{let e=this.#t.get(t.pairingId);if(!e)return;this.#m(e,{state:t.state,online:ze(t.state),detail:t.detail??null});return}case`remote_frame`:this.#t.get(t.pairingId)?.onFrame(t.frame);return;case`remote_error`:{let e=t.pairingId?this.#t.get(t.pairingId):void 0;e&&this.#m(e,{state:`error`,online:!1,detail:t.message});return}default:return}}};function wW({defaultBaseUrl:e,error:t,onConnect:n}){let[r,i]=(0,v.useState)(e),[a,o]=(0,v.useState)(``),s=r.trim().length>0&&a.trim().length>0;return(0,G.jsx)(`div`,{className:`flex min-h-full items-center justify-center bg-bg p-4`,children:(0,G.jsxs)(`form`,{className:`w-full max-w-md space-y-4 rounded-xl border border-border bg-surface p-6 shadow-md`,onSubmit:e=>{e.preventDefault(),s&&n({baseUrl:r.trim(),token:a.trim()})},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Connect to your OonaCode host`}),(0,G.jsxs)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:[`This page needs the host's access token. It is normally passed automatically when you open the UI from the desktop app or run`,` `,(0,G.jsx)(`code`,{className:`rounded bg-surface-2 px-1 font-mono`,children:`oona web`}),`.`]})]}),t?(0,G.jsx)(`div`,{className:`rounded-md border border-danger/40 bg-danger-soft px-3 py-2 text-sm text-danger`,role:`alert`,children:t}):null,(0,G.jsx)(zy,{label:`Host URL`,children:(0,G.jsx)(`input`,{className:Z,value:r,onChange:e=>i(e.target.value),placeholder:`http://127.0.0.1:41317`,spellCheck:!1,autoComplete:`url`})}),(0,G.jsx)(zy,{label:`Host token`,hint:'Found in host/host.json ("token") in the OonaCode folder of the PC running the host — %LOCALAPPDATA%\\OonaCode on Windows, ~/Library/Application Support/OonaCode on macOS, ~/.oonacode on Linux — printed by `oona serve --show-token`, or embedded in the URL printed by `oona web --print`.',children:(0,G.jsx)(`input`,{className:Z,type:`password`,value:a,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1,autoFocus:!0})}),(0,G.jsx)(Y,{type:`submit`,variant:`primary`,className:`w-full justify-center`,disabled:!s,children:`Connect`})]})})}function TW(e){return!!e&&e.platform===`linux`&&e.host!==`vscode`&&!!e.onMenuModel}var EW=e=>!!e&&e.type!==`separator`&&e.enabled;function DW(e,t,n){let r=e.length;for(let i=1;i<=r;i+=1){let a=((t+n*i)%r+r)%r;if(EW(e[a]))return a}return-1}function OW({label:e,mnemonic:t,show:n}){let r=n&&t?e.toLowerCase().indexOf(t):-1;return r<0?e:(0,G.jsxs)(G.Fragment,{children:[e.slice(0,r),(0,G.jsx)(`span`,{className:`underline underline-offset-2`,children:e[r]}),e.slice(r+1)]})}function kW({bridge:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(-1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=(0,v.useRef)(null);(0,v.useEffect)(()=>e.onMenuModel?.(e=>{n(e),i(null),o(-1),c(null)}),[e]);let f=t?.items??[],p=(0,v.useCallback)(e=>e===null?[]:f[e]?.submenu??[],[f]),m=(0,v.useCallback)(()=>{i(null),o(-1),c(null)},[]),h=(0,v.useCallback)((e,t)=>{i(e);let n=p(e);o(t?DW(n,-1,1):-1),t&&c(e)},[p]),g=(0,v.useCallback)(t=>{!t||!EW(t)||t.type===`submenu`||(m(),e.invokeMenuItem?.(t.id))},[e,m]);if((0,v.useEffect)(()=>{if(f.length===0)return;let e=!1,t=()=>r!==null||s!==null,n=e=>{e.preventDefault(),e.stopPropagation()},l=l=>{if(l.key===`Alt`){e=!l.repeat,u(!0);return}e=!1;let d=!l.ctrlKey&&!l.metaKey&&!l.shiftKey;if(!t()){if(l.key===`F10`&&d&&!l.altKey){n(l),c(0);return}if(l.altKey&&d&&l.key.length===1){let e=f.findIndex(e=>e.mnemonic===l.key.toLowerCase());e>=0&&(n(l),h(e,!0))}return}let _=p(r),v=s??r??0,y=e=>{let t=(v+e+f.length)%f.length;r===null?c(t):h(t,!0)};switch(l.key){case`Escape`:n(l),r!==null&&s!==null?(i(null),o(-1)):m();return;case`ArrowLeft`:n(l),y(-1);return;case`ArrowRight`:n(l),y(1);return;case`ArrowDown`:n(l),r===null?h(v,!0):o(DW(_,a,1));return;case`ArrowUp`:n(l),r===null?(h(v,!0),o(DW(p(v),0,-1))):o(DW(_,a<0?0:a,-1));return;case`Home`:n(l),r!==null&&o(DW(_,-1,1));return;case`End`:n(l),r!==null&&o(DW(_,0,-1));return;case`Enter`:case` `:n(l),r===null?h(v,!0):g(_[a]);return;case`Tab`:m();return}if(l.key.length===1&&!l.ctrlKey&&!l.metaKey){n(l);let e=l.key.toLowerCase();if(r!==null)g(_.find(t=>t.mnemonic===e&&EW(t)));else{let t=f.findIndex(t=>t.mnemonic===e);t>=0&&h(t,!0)}return}m()},_=n=>{n.key===`Alt`&&(u(!1),e&&(e=!1,t()?m():c(0)))},v=()=>{e=!1,u(!1),m()},y=e=>{(r!==null||s!==null)&&(d.current&&e.target instanceof Node&&d.current.contains(e.target)||m())};return window.addEventListener(`keydown`,l,!0),window.addEventListener(`keyup`,_,!0),window.addEventListener(`blur`,v),document.addEventListener(`mousedown`,y,!0),()=>{window.removeEventListener(`keydown`,l,!0),window.removeEventListener(`keyup`,_,!0),window.removeEventListener(`blur`,v),document.removeEventListener(`mousedown`,y,!0)}},[f,r,s,a,p,h,g,m]),!t||f.length===0)return null;let _=l||s!==null;return(0,G.jsx)(`div`,{ref:d,role:`menubar`,"aria-label":`Application menu`,className:`flex h-7 shrink-0 items-stretch gap-px border-b border-border bg-surface px-1 text-[13px] text-fg select-none`,children:f.map((e,t)=>{let n=r===t;return(0,G.jsxs)(`div`,{className:`relative flex`,children:[(0,G.jsx)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":n,tabIndex:-1,disabled:!e.enabled,"data-menu-top":e.id,onMouseDown:e=>{e.preventDefault(),n?m():h(t,!1)},onMouseEnter:()=>{r!==null&&r!==t&&h(t,!1)},className:W(`my-0.5 rounded-sm px-2.5`,n||s===t?`bg-surface-3`:`hover:bg-surface-2`,!e.enabled&&`text-fg-faint`),children:(0,G.jsx)(OW,{label:e.label,mnemonic:e.mnemonic,show:_})}),n&&e.submenu?(0,G.jsx)(AW,{entries:e.submenu,active:a,showMnemonics:_,onHover:o,onRun:g}):null]},e.id)})})}function AW({entries:e,active:t,showMnemonics:n,onHover:r,onRun:i,nested:a=!1}){let[o,s]=(0,v.useState)(null);return(0,G.jsx)(`div`,{role:`menu`,className:W(`absolute z-[70] min-w-[15rem] rounded-md border border-border bg-surface py-1 text-fg shadow-lg`,a?`top-0 left-full -mt-1 ml-px`:`top-full left-0 mt-px`),children:e.map((e,a)=>{if(e.type===`separator`)return(0,G.jsx)(`div`,{role:`separator`,className:`my-1 border-t border-border`},e.id);let c=e.type===`checkbox`?`menuitemcheckbox`:e.type===`radio`?`menuitemradio`:`menuitem`,l=e.type===`checkbox`||e.type===`radio`;return(0,G.jsxs)(`div`,{role:c,"aria-disabled":!e.enabled||void 0,"aria-checked":l?e.checked:void 0,"aria-haspopup":e.type===`submenu`?`menu`:void 0,"data-menu-entry":e.id,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>{r(a),s(e.type===`submenu`?a:null)},onClick:()=>i(e),className:W(`relative flex cursor-default items-center gap-2 px-3 py-1`,a===t&&e.enabled&&`bg-surface-2`,!e.enabled&&`text-fg-faint`),children:[(0,G.jsx)(`span`,{className:`w-4 shrink-0 text-center`,"aria-hidden":!0,children:l&&e.checked?e.type===`radio`?`•`:`✓`:``}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:(0,G.jsx)(OW,{label:e.label,mnemonic:e.mnemonic,show:n})}),e.accelerator?(0,G.jsx)(`span`,{className:`shrink-0 pl-6 text-xs text-fg-faint`,children:e.accelerator}):null,e.type===`submenu`?(0,G.jsx)(`span`,{className:`shrink-0 pl-4 text-fg-faint`,"aria-hidden":!0,children:`›`}):null,e.type===`submenu`&&o===a&&e.submenu?(0,G.jsx)(AW,{entries:e.submenu,active:-1,showMnemonics:n,onHover:()=>{},onRun:i,nested:!0}):null]},e.id)})})}function jW(e){return!!e&&typeof e==`object`&&typeof e.hostId==`string`}function MW(e){return Math.min(5e3,500*2**Math.max(0,e))}async function NW(e){let t=e.sleep??(e=>new Promise(t=>setTimeout(t,e)));for(let n=0;;n++){if(e.cancelled?.())return null;try{let t=await e.getConnection();if(t&&typeof t.token==`string`&&t.token&&typeof t.baseUrl==`string`&&await e.accepts(t).catch(()=>!1))return t}catch{}await t(MW(n))}}function PW(){let[e,t]=(0,v.useState)(void 0),[n,r]=(0,v.useState)(null),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(!1),l=(0,v.useRef)(!1);(0,v.useEffect)(()=>()=>{l.current=!0},[]);let u=(0,v.useCallback)(()=>{let e=window.oonacode;return!e||typeof e.getConnection!=`function`?!1:c.current?!0:(c.current=!0,NW({getConnection:()=>e.getConnection(),accepts:e=>hm(e).health().then(e=>jW(e),()=>!1),cancelled:()=>l.current}).then(e=>{c.current=!1,e&&(iW(window.sessionStorage,e),s(e=>e+1),t({baseUrl:e.baseUrl,token:e.token}))}),!0)},[]);(0,v.useEffect)(()=>{oW().then(e=>{r(e.sessionId),!(!e.connection&&u())&&t(e.connection)})},[u]),(0,v.useEffect)(()=>{e!==void 0&&document.getElementById(`oona-splash`)?.remove()},[e]);let d=(0,v.useCallback)(()=>{iW(window.sessionStorage,null),!u()&&(a(`The host rejected the token. Paste a current one from the host.`),t(null))},[u]),f=(0,v.useMemo)(()=>{if(!e)return null;let t=hm(e),n=window.oonacode?.window?.id;return{api:t,socket:new uW({baseUrl:e.baseUrl,token:e.token,clientKind:window.oonacode?`desktop`:`web`,clientVersion:window.oonacode?.appVersion,...n?{clientId:`${n.slice(0,16)}-${cW()}`}:{}}),relay:new CW({baseUrl:e.baseUrl,token:e.token,clientId:window.oonacode?`desktop`:`web-ui`,...window.oonacode?.appVersion?{clientVersion:window.oonacode.appVersion}:{}})}},[e]),p=(0,v.useMemo)(()=>f?yW({api:f.api,appVersion:window.oonacode?.appVersion??null,platform:window.oonacode?.platform??null,embedded:window.oonacode?`desktop`:`browser`}):null,[f]);return(0,v.useEffect)(()=>p?.install(window),[p]),e===void 0?null:!e||!f?(0,G.jsx)(wW,{defaultBaseUrl:window.location.origin,error:i,onConnect:e=>{iW(window.sessionStorage,e),a(null),t(e)}}):(0,G.jsx)($U,{api:f.api,socket:f.socket,relay:f.relay,initialSessionId:n,onUnauthorized:d,...p?{reportError:p.report}:{}},o)}function FW({children:e}){let t=typeof window>`u`?void 0:window.oonacode;return TW(t)?(0,G.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,G.jsx)(kW,{bridge:t}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:e})]}):(0,G.jsx)(G.Fragment,{children:e})}var IW=document.getElementById(`root`);(0,y.createRoot)(IW).render((0,G.jsx)(v.StrictMode,{children:(0,G.jsx)(FW,{children:(0,G.jsx)(PW,{})})}));
|