@pi-chamber/web 1.0.8-rc.2 → 1.0.8-rc.3

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.
Files changed (68) hide show
  1. package/dist/assets/{AgentsSurface-CcWBqAWV.js → AgentsSurface-wsW9VCRp.js} +1 -1
  2. package/dist/assets/{ChoicesArtifact-Kk-qvrSB.js → ChoicesArtifact-EwCf4Yxu.js} +1 -1
  3. package/dist/assets/{DiagramView-DZUBo1uP.js → DiagramView-BX6N99cQ.js} +1 -1
  4. package/dist/assets/{DiffView-CiZy4jFA.js → DiffView-CI0eSnPP.js} +1 -1
  5. package/dist/assets/{FileSaveConflictDialog-DZ9NDwOO.js → FileSaveConflictDialog-GLj2W7VE.js} +1 -1
  6. package/dist/assets/{FilesView-DqiZ9kw9.js → FilesView-CI0tfZQL.js} +1 -1
  7. package/dist/assets/{GitHubDetailScaffold-DM2DH7o8.js → GitHubDetailScaffold-B85tZ9m7.js} +1 -1
  8. package/dist/assets/{GitHubLinkPicker-ChB8NZ1h.js → GitHubLinkPicker-Y6AuNiGl.js} +1 -1
  9. package/dist/assets/{GitHubListPrimitives-CibDiJGq.js → GitHubListPrimitives-BJHBud6i.js} +1 -1
  10. package/dist/assets/{GitView--EaZQrBr.js → GitView-DueE69kW.js} +3 -3
  11. package/dist/assets/{IssuesSurface-CySTpaD1.js → IssuesSurface-Cg-xkdIu.js} +2 -2
  12. package/dist/assets/{JsonTreeView-_yMHKKQZ.js → JsonTreeView-Cvg6lc40.js} +1 -1
  13. package/dist/assets/{MarkdownRendererImpl-D_-2fQw0.js → MarkdownRendererImpl-DExPx-QM.js} +1 -1
  14. package/dist/assets/{PatchDiff-bHObDlhD.js → PatchDiff-_c3HZ34I.js} +1 -1
  15. package/dist/assets/{PierreDiffViewer-UY7Cse-s.js → PierreDiffViewer-CZnaqO-_.js} +1 -1
  16. package/dist/assets/{PullRequestsSurface-iXy6chwc.js → PullRequestsSurface-C9AYPiwo.js} +2 -2
  17. package/dist/assets/{SessionSwitcherContent-DJGCa_wN.js → SessionSwitcherContent-DOpnN-8S.js} +1 -1
  18. package/dist/assets/{SessionSwitcherDropdown-CDOX-5Y2.js → SessionSwitcherDropdown-CmHMPZ69.js} +2 -2
  19. package/dist/assets/{SessionUnreadDot-Dwc3MdvA.js → SessionUnreadDot-CZCQ4t1J.js} +1 -1
  20. package/dist/assets/SettingsView-D5PO5M3z.js +11 -0
  21. package/dist/assets/{SettingsWindow-CUg49Mfh.js → SettingsWindow-DXV5UOE8.js} +1 -1
  22. package/dist/assets/{SubagentsArtifact-DUZX9tDe.js → SubagentsArtifact-CO1ZiI1x.js} +1 -1
  23. package/dist/assets/{ToolOutputDialog-BuZZaRw4.js → ToolOutputDialog-GOwNLj-y.js} +1 -1
  24. package/dist/assets/{ToolPartDiffPreview-CKncG6i2.js → ToolPartDiffPreview-BoaiZji6.js} +1 -1
  25. package/dist/assets/{VirtualizedFileDiff-BGZiLPe_.js → VirtualizedFileDiff-Chq1X8nw.js} +1 -1
  26. package/dist/assets/VisualFrame-u7aRcX7O.js +22 -0
  27. package/dist/assets/{VisualsArtifact-Bq0vMO-i.js → VisualsArtifact-D9vPjihW.js} +1 -1
  28. package/dist/assets/{collapsible-Bro9KrfM.js → collapsible-BjpDEohv.js} +1 -1
  29. package/dist/assets/{computeVirtualFileMetrics-DJQqK49u.js → computeVirtualFileMetrics-DmPCxbok.js} +1 -1
  30. package/dist/assets/{contextFileOpenGuard-ByWK3Sru.js → contextFileOpenGuard-CukNcUeY.js} +1 -1
  31. package/dist/assets/{fileTreeStatus-CyJ3TOYD.js → fileTreeStatus-CDyfNPYO.js} +1 -1
  32. package/dist/assets/{gitStatusPredicates-BsXrwngT.js → gitStatusPredicates-uI7Y7L5k.js} +1 -1
  33. package/dist/assets/{githubLink-g2bmC0qi.js → githubLink-B9Mxac4R.js} +1 -1
  34. package/dist/assets/{index-C9rUUQ_Y.js → index-BWq2ibCw.js} +1 -1
  35. package/dist/assets/{index-CKKWVoND.js → index-BxKPJ9uG.js} +9 -9
  36. package/dist/assets/index-C5JgjS20.css +1 -0
  37. package/dist/assets/{main-DsLMU9CT.js → main-CWfC-9xT.js} +4 -4
  38. package/dist/assets/{main-DT-4_fhe.js → main-ckQ0ciIN.js} +2 -2
  39. package/dist/assets/{markdownCore-QmM_aOnZ.js → markdownCore-p2q2Kxwo.js} +1 -1
  40. package/dist/assets/{miniChat-BqGslD2z.js → miniChat-x2TrwRYA.js} +2 -2
  41. package/dist/assets/{mobile-C5JOcDIC.js → mobile-B0x2G8h1.js} +2 -2
  42. package/dist/assets/{nativeFileSave-DSMsJqXM.js → nativeFileSave-D542OJlG.js} +1 -1
  43. package/dist/assets/{pi-session-focus-preference-Cc_S4zi1.js → pi-session-focus-preference-Q_RZUCnt.js} +1 -1
  44. package/dist/assets/{renderDiffWithHighlighter-BXhnIAHg.js → renderDiffWithHighlighter-CSFGSknx.js} +1 -1
  45. package/dist/assets/{renderElectronMiniChatApp-CiSkecEE.js → renderElectronMiniChatApp-CFIdesZT.js} +2 -2
  46. package/dist/assets/{renderFileWithHighlighter-CK29YZtC.js → renderFileWithHighlighter-C5JE0mRX.js} +1 -1
  47. package/dist/assets/{renderMobileApp-C4JuoxsZ.js → renderMobileApp-B1ybjcGM.js} +3 -3
  48. package/dist/assets/{runtimeEndpointReset-Dwj-jCDS.js → runtimeEndpointReset-DyZSKCYM.js} +7 -7
  49. package/dist/assets/{runtimeSurface-0K7vuUpd.js → runtimeSurface-BR_dhe7_.js} +1 -1
  50. package/dist/assets/{selection-CnYkEsu_.js → selection-CfOpW4rA.js} +1 -1
  51. package/dist/assets/{useAppFontEffects-CV5UyTRw.js → useAppFontEffects-COMvkffC.js} +97 -97
  52. package/dist/assets/{useGitHubRemoteSearch-CgP-zEBj.js → useGitHubRemoteSearch-M1AE2YuX.js} +1 -1
  53. package/dist/assets/{useSwitcherItems-C8G5F0hs.js → useSwitcherItems-D0i2BYYP.js} +1 -1
  54. package/dist/assets/{web-components-BpncHjnV.js → web-components-wOQkOurQ.js} +1 -1
  55. package/dist/index.html +4 -4
  56. package/dist/mini-chat.html +3 -3
  57. package/dist/mobile.html +3 -3
  58. package/package.json +1 -1
  59. package/plugins/visuals/extension.js +2 -2
  60. package/server/index.js +4 -0
  61. package/server/lib/pi/ui-settings-store.js +2 -1
  62. package/server/lib/wallpaper/DOCUMENTATION.md +25 -0
  63. package/server/lib/wallpaper/routes.js +63 -0
  64. package/server/lib/wallpaper/routes.test.js +109 -0
  65. package/server/lib/wallpaper/store.js +87 -0
  66. package/dist/assets/SettingsView-DA-U9lsj.js +0 -11
  67. package/dist/assets/VisualFrame-DBZkHFnG.js +0 -22
  68. package/dist/assets/index-B_L9GVYw.css +0 -1
@@ -1,11 +1,11 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/nativeFileSave-DSMsJqXM.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js"])))=>i.map(i=>d[i]);
2
- import{c as Ir,d as _r,p as ea}from"./vendor-zustand-CXhN0IMY.js";import{_ as xc}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as Oc}from"./vendor-clsx-B-dksMZM.js";import{t as Nc}from"./vendor-tailwind-merge-BKkUfl9q.js";import{e as Vs}from"./vendor-fuse.js-t_7AcMTv.js";import{R as qa}from"./vendor-react-Bz1tRBxM.js";const yr=1,Lc="pichamber-relay-v1",Js=1,Ys=12,br=1+Ys,vr=64*1024,kr=5,fo=128,Xs=0,Qs=1,qt=4,Uc=1+qt,ln=vr-kr-Uc,O={HttpRequest:1,HttpBody:2,HttpResponse:3,StreamEnd:4,StreamAbort:5,WsOpen:6,WsOpened:7,WsText:8,WsBinary:9,WsClose:10,Ping:11,Pong:12},Hc=new Set(Object.values(O)),Kc=e=>Hc.has(e),Et={DuplicateClient:4002,AuthFailed:4010,LimitExceeded:4029,ChannelFailure:1011},je=globalThis.crypto.subtle,Zs={name:"ECDH",namedCurve:"P-256"},ei=16,Ho=32,jc=16,un=4,ti=8;class tt extends Error{constructor(t){super(t),this.name="RelayCryptoError"}}const $c=()=>je.generateKey(Zs,!0,["deriveBits"]),zc=async e=>{const t=await je.exportKey("jwk",e);return{kty:t.kty,crv:t.crv,x:t.x,y:t.y}},qc=async e=>{if(e.kty!=="EC"||e.crv!=="P-256"||typeof e.x!="string"||typeof e.y!="string")throw new tt("invalid ECDH public key JWK");try{return await je.importKey("jwk",{kty:e.kty,crv:e.crv,x:e.x,y:e.y,ext:!0},Zs,!0,[])}catch{throw new tt("invalid ECDH public key JWK")}},Gc=()=>{const e=new Uint8Array(ei);return globalThis.crypto.getRandomValues(e),e},Wc=async(e,t,r)=>{if(r.length!==ei)throw new tt("invalid handshake nonce length");const o=await je.deriveBits({name:"ECDH",public:t},e,256),n=await je.importKey("raw",o,"HKDF",!1,["deriveBits"]),a=new Uint8Array(await je.deriveBits({name:"HKDF",hash:"SHA-256",salt:r,info:new TextEncoder().encode(Lc)},n,Ho*2*8)),s=(i,c)=>je.importKey("raw",i,{name:"AES-GCM"},!1,c);return{clientToHost:await s(a.slice(0,Ho),["encrypt","decrypt"]),hostToClient:await s(a.slice(Ho),["encrypt","decrypt"])}},Vc=(e,t,r)=>{for(let o=ti-1;o>=0;o-=1)e[t+o]=Number(r&0xffn),r>>=8n},Jc=(e,t)=>{let r=0n;for(let o=0;o<ti;o+=1)r=r<<8n|BigInt(e[t+o]);return r},Yc=e=>{const t=new Uint8Array(un);globalThis.crypto.getRandomValues(t);let r=0n;return{async encrypt(o){if(o.length>vr)throw new tt("plaintext frame exceeds maximum size");r+=1n;const n=new Uint8Array(Ys);n.set(t,0),Vc(n,un,r);const a=new Uint8Array(await je.encrypt({name:"AES-GCM",iv:n},e,o)),s=new Uint8Array(br+a.length);return s[0]=Js,s.set(n,1),s.set(a,br),s}}},Xc=e=>{let t=0n;return{async decrypt(r){if(r.length<br+jc)throw new tt("encrypted frame too short");if(r[0]!==Js)throw new tt("unsupported encrypted frame version");const o=r.slice(1,br),n=Jc(o,un);if(n<=t)throw new tt("frame counter regression");let a;try{a=await je.decrypt({name:"AES-GCM",iv:o},e,r.slice(br))}catch{throw new tt("frame decryption failed")}return t=n,new Uint8Array(a)}}},zr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Qc=e=>{let t="";for(let r=0;r<e.length;r+=3){const o=e[r],n=r+1<e.length?e[r+1]:void 0,a=r+2<e.length?e[r+2]:void 0;t+=zr[o>>2],t+=zr[(o&3)<<4|(n??0)>>4],n!==void 0&&(t+=zr[(n&15)<<2|(a??0)>>6]),a!==void 0&&(t+=zr[a&63])}return t},Ga=e=>{let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null)return null;const r=t;if(r.v!==yr)return null;const o=r.batch===!0;return r.t==="ready"?{t:"ready",v:yr,batch:o}:r.t==="hello"&&typeof r.nonce=="string"&&typeof r.clientPubJwk=="object"&&r.clientPubJwk!==null?{t:"hello",v:yr,clientPubJwk:r.clientPubJwk,nonce:r.nonce,batch:o}:null},Zc=e=>({type:"fail",closeCode:Et.ChannelFailure,reason:e}),ed=async(e,t={})=>{const r=t.batch!==!1,o=await qc(e),n=await $c(),a=Gc(),s={t:"hello",v:yr,clientPubJwk:await zc(n.publicKey),nonce:Qc(a),...r?{batch:!0}:{}};let i=!1;return{helloText:JSON.stringify(s),get established(){return i},async handleText(c){if(i)return Ga(c)?.t==="ready"?{type:"ignore"}:Zc("plaintext frame on established channel");const d=Ga(c);if(d?.t!=="ready")return{type:"ignore"};const l=await Wc(n.privateKey,o,a);return i=!0,{type:"established",batch:r&&d.batch===!0,channel:{encryptor:Yc(l.clientToHost),decryptor:Xc(l.hostToClient)}}}}},ri=4294967295;class ne extends Error{constructor(t){super(t),this.name="TunnelCodecError"}}const Pe=(e,t,r,o=!1)=>{if(!Number.isInteger(t)||t<0||t>ri)throw new ne("invalid stream id");if(r.length>ln)throw new ne("tunnel payload exceeds maximum size");const n=new Uint8Array(kr+r.length);return n[0]=o?e|fo:e,n[1]=t>>>24&255,n[2]=t>>>16&255,n[3]=t>>>8&255,n[4]=t&255,n.set(r,kr),n},td=e=>{if(e.length<kr)throw new ne("tunnel frame too short");const t=e[0],r=(t&fo)!==0,o=t&~fo;if(!Kc(o))throw new ne(`unknown tunnel frame type ${o}`);const n=(e[1]<<24|e[2]<<16|e[3]<<8|e[4])>>>0;return{frameType:o,streamId:n,payload:e.slice(kr),hasMoreFragments:r}},rd=new TextEncoder,od=new TextDecoder,mo=e=>rd.encode(JSON.stringify(e)),go=(e,t)=>{let r;try{r=JSON.parse(od.decode(e))}catch{throw new ne("malformed JSON tunnel payload")}if(!t(r))throw new ne("unexpected JSON tunnel payload shape");return r},oi=(e,t=ln)=>{if(t<=0||t>ln)throw new ne("invalid chunk size");if(e.length===0)return[new Uint8Array(0)];const r=[];for(let o=0;o<e.length;o+=t)r.push(e.slice(o,o+t));return r},Wa=(e,t,r)=>{const o=oi(r);return o.map((n,a)=>Pe(e,t,n,a<o.length-1))},nd=(e=16*1024*1024)=>{const t=new Map;return{push(r){const o=`${r.streamId}:${r.frameType}`,n=t.get(o);if(!r.hasMoreFragments&&!n)return r.payload;const a=n?.chunks??[],s=(n?.totalBytes??0)+r.payload.length;if(s>e)throw t.delete(o),new ne("fragmented message exceeds maximum size");if(a.push(r.payload),r.hasMoreFragments)return t.set(o,{chunks:a,totalBytes:s}),null;t.delete(o);const i=new Uint8Array(s);let c=0;for(const d of a)i.set(d,c),c+=d.length;return i},dropStream(r){for(const o of t.keys())o.startsWith(`${r}:`)&&t.delete(o)}}},ad=e=>{if(e.length===0)throw new ne("cannot encode an empty frame batch");if(e.length===1){const n=e[0],a=new Uint8Array(1+n.length);if(a[0]=Xs,a.set(n,1),a.length>vr)throw new ne("frame batch exceeds maximum plaintext size");return a}let t=1;for(const n of e)t+=qt+n.length;if(t>vr)throw new ne("frame batch exceeds maximum plaintext size");const r=new Uint8Array(t);r[0]=Qs;let o=1;for(const n of e)r[o]=n.length>>>24&255,r[o+1]=n.length>>>16&255,r[o+2]=n.length>>>8&255,r[o+3]=n.length&255,o+=qt,r.set(n,o),o+=n.length;return r},sd=e=>{if(e.length<1)throw new ne("empty batch plaintext");const t=e[0];if(t===Xs)return[e.slice(1)];if(t!==Qs)throw new ne(`unknown batch container tag ${t}`);const r=[];let o=1;for(;o<e.length;){if(o+qt>e.length)throw new ne("truncated batch frame length");const n=(e[o]<<24|e[o+1]<<16|e[o+2]<<8|e[o+3])>>>0;if(o+=qt,o+n>e.length)throw new ne("truncated batch frame body");r.push(e.slice(o,o+n)),o+=n}if(r.length===0)throw new ne("empty frame batch");return r},id=new Set([O.HttpBody,O.WsText,O.WsBinary]),ni=150,cd=24*1024,dd=32,ld=e=>{const t=e.windowMs??ni,r=e.maxBatchBytes??cd,o=e.maxBatchFrames??dd,n=e.now??(()=>Date.now()),a=e.setTimer??((h,p)=>setTimeout(h,p)),s=e.clearTimer??(h=>clearTimeout(h));let i=[],c=0,d=null,l=0,u=!1;const f=()=>{d!==null&&(s(d),d=null)},m=()=>{if(f(),i.length===0)return;const h=i;i=[],c=0,l=n(),e.sendBatch(ad(h))};return{enqueue:h=>{if(u)return;const p=h[0]&~fo;if(!id.has(p)){i.push(h),m();return}const k=n();if(i.length===0&&k-l>=t){i.push(h),m();return}const A=qt+h.length;if(i.length>0&&1+c+A>vr&&m(),i.push(h),c+=A,c>=r||i.length>=o){m();return}d===null&&(d=a(m,t))},flush:m,dispose(){u=!0,f(),i=[],c=0}}},ud=()=>{let e=1;return{next(){if(e>ri)throw new ne("stream id space exhausted");const t=e;return e+=2,t}}},fd=e=>{e.binaryType="arraybuffer";const t={get readyState(){return e.readyState},send(r){e.send(r)},close(r,o){e.close(r,o)},onopen:null,onmessage:null,onclose:null,onerror:null};return e.onopen=()=>t.onopen?.(),e.onmessage=r=>t.onmessage?.({data:r.data}),e.onclose=r=>t.onclose?.({code:r.code,reason:r.reason}),e.onerror=()=>t.onerror?.(),t},md=e=>{const t={get readyState(){return e.readyState},get binaryType(){return e.binaryType},set binaryType(r){r&&(e.binaryType=r)},onopen:null,onmessage:null,onerror:null,onclose:null,send(r){e.send(r)},close(r,o){e.close(r,o)}};return e.onopen=()=>t.onopen?.(),e.onmessage=r=>{const o=r.data;(typeof o=="string"||o instanceof ArrayBuffer)&&t.onmessage?.({data:o})},e.onerror=()=>t.onerror?.(),e.onclose=r=>t.onclose?.({code:r.code,reason:r.reason}),t},Va=0,Ko=1,Ja=2,Ya=3,gd=new Set([Et.AuthFailed,Et.DuplicateClient,Et.LimitExceeded]),pd={[Et.AuthFailed]:"relay authentication failed",[Et.DuplicateClient]:"relay connection replaced by another client",[Et.LimitExceeded]:"relay connection limit reached"},Mo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),hd=e=>Mo(e)&&Object.values(e).every(t=>typeof t=="string"),Fd=e=>Mo(e)&&typeof e.status=="number"&&hd(e.headers),ai=e=>Mo(e)&&typeof e.reason=="string",yd=e=>Mo(e)&&typeof e.code=="number"&&typeof e.reason=="string",si=/^[a-z][a-z\d+.-]*:\/\//i,ta="http://tunnel.invalid",bd=e=>{try{const t=si.test(e)?new URL(e):new URL(e,ta);return`${t.pathname}${t.search}`}catch{return e}},qr=e=>({async*[Symbol.asyncIterator](){yield e}}),Ad=e=>({async*[Symbol.asyncIterator](){const t=e.getReader();try{for(;;){const{done:r,value:o}=await t.read();if(r)return;o&&(yield o)}}finally{t.releaseLock()}}}),Ed=e=>{const t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t},wd=async e=>{if(e==null)return{body:null};if(e instanceof ReadableStream)return{body:Ad(e)};if(typeof e=="string")return{body:qr(new TextEncoder().encode(e))};if(e instanceof ArrayBuffer)return{body:qr(new Uint8Array(e.slice(0)))};if(ArrayBuffer.isView(e))return{body:qr(Ed(e))};const t=new Response(e),r=t.headers.get("content-type")??void 0,o=new Uint8Array(await t.arrayBuffer());return{body:qr(o),contentType:r}},Bd=async(e,t)=>{let r;const o=new Headers;let n="GET",a=null,s;e instanceof Request?(r=e.url,n=e.method,e.headers.forEach((u,f)=>o.set(f,u)),s=e.signal,a=e.body):r=e.toString(),t&&(t.method&&(n=t.method),t.headers&&new Headers(t.headers).forEach((u,f)=>o.set(f,u)),t.body!==void 0&&(a=t.body),t.signal&&(s=t.signal));const i=si.test(r)?new URL(r):new URL(r,ta),{body:c,contentType:d}=await wd(a);d&&!o.has("content-type")&&o.set("content-type",d);const l={};return o.forEach((u,f)=>{l[f]=u}),{method:n.toUpperCase(),path:i.pathname,query:i.search.startsWith("?")?i.search.slice(1):i.search,headers:l,body:c,signal:s}},Cd="__pichamberAmbiguousTransport",vd=e=>(Object.defineProperty(e,Cd,{value:!0,enumerable:!1,configurable:!0}),e),kd=new Uint8Array(0),Dd=new TextEncoder,Sd=new TextDecoder,fn=e=>e instanceof Error?e:new Error(String(e)),Xa=()=>new DOMException("The operation was aborted.","AbortError"),Md=async(e,t,r)=>{const o=await Bd(t,r),n=o.signal;if(n?.aborted)throw Xa();const a=await e(n),s=a.nextStreamId();return await new Promise((i,c)=>{let d=!1,l=!1,u=null,f=null;const m=()=>{a.streams.delete(s),a.assembler.dropStream(s),f&&n&&n.removeEventListener("abort",f)},g=A=>{if(!l){if(l=!0,m(),!d){c(A);return}try{u?.error(A)}catch{}}},h=A=>{a.dead||a.send(Pe(O.StreamAbort,s,mo({reason:A})))},p=A=>vd(new Error(A));f=()=>{h("aborted"),g(Xa())},a.streams.set(s,{handleFrame(A,C){if(A===O.HttpResponse){if(d||l)return;let w;try{w=go(C,Fd)}catch(ee){h("malformed response head"),g(p(fn(ee).message));return}const B=w.status===204||w.status===205||w.status===304;let P=null;B||(P=new ReadableStream({start(ee){u=ee},cancel(){l||(l=!0,m(),h("response body cancelled"))}})),d=!0,i(new Response(P,{status:w.status,headers:w.headers})),B&&(l=!0,m());return}if(A===O.HttpBody){if(!d||l)return;try{u?.enqueue(C)}catch{}return}if(A===O.StreamEnd){if(l)return;if(!d){g(p("tunnel stream ended before response head"));return}l=!0,m();try{u?.close()}catch{}return}if(A===O.StreamAbort){let w="stream aborted by host";try{w=go(C,ai).reason}catch{}g(p(w))}},fail(A){g(p(A.message))}}),n&&n.addEventListener("abort",f,{once:!0});const k={method:o.method,path:o.path,query:o.query,headers:o.headers};a.send(Pe(O.HttpRequest,s,mo(k))),(async()=>{try{if(o.body)for await(const A of o.body){if(l||a.dead)return;for(const C of oi(A))a.send(Pe(O.HttpBody,s,C))}!l&&!a.dead&&a.send(Pe(O.StreamEnd,s,kd))}catch(A){h("request body failed"),g(p(fn(A).message))}})()})},Td=e=>{const t=e.indexOf("?");return t===-1?{path:e,query:""}:{path:e.slice(0,t),query:e.slice(t+1)}},Pd=(e,t,r)=>{let o=Va,n=null,a=0,s=!1;const i={get readyState(){return o},onopen:null,onmessage:null,onerror:null,onclose:null,send(d){if(o!==Ko||!n||n.dead)throw new Error("relay tunnel socket is not open");if(typeof d=="string"){for(const u of Wa(O.WsText,a,Dd.encode(d)))n.send(u);return}const l=d instanceof ArrayBuffer?new Uint8Array(d.slice(0)):(()=>{const u=new Uint8Array(d.byteLength);return u.set(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)),u})();for(const u of Wa(O.WsBinary,a,l))n.send(u)},close(d=1e3,l=""){o===Ya||o===Ja||(o===Ko&&n&&!n.dead&&(o=Ja,n.send(Pe(O.WsClose,a,mo({code:d,reason:l})))),c(d,l))}},c=(d,l,u=!1)=>{if(!s){if(s=!0,n&&(n.streams.delete(a),n.assembler.dropStream(a)),o=Ya,u)try{i.onerror?.()}catch{}try{i.onclose?.({code:d,reason:l})}catch{}}};return(async()=>{let d;try{d=await e()}catch(m){c(1006,fn(m).message,!0);return}if(s)return;n=d,a=d.nextStreamId(),d.streams.set(a,{handleFrame(m,g){if(m===O.WsOpened){if(o===Va){o=Ko;try{i.onopen?.()}catch{}}return}if(m===O.WsText){try{i.onmessage?.({data:Sd.decode(g)})}catch{}return}if(m===O.WsBinary){const h=new ArrayBuffer(g.byteLength);new Uint8Array(h).set(g);try{i.onmessage?.({data:h})}catch{}return}if(m===O.WsClose){let h=1e3,p="";try{const k=go(g,yd);h=k.code,p=k.reason}catch{}c(h,p);return}if(m===O.StreamAbort){let h="stream aborted";try{h=go(g,ai).reason}catch{}c(1006,h,!0)}},fail(m){c(1012,m.message,!0)}});const{path:l,query:u}=Td(t),f=r&&r.length>0?{path:l,query:u,protocols:r}:{path:l,query:u};d.send(Pe(O.WsOpen,a,mo(f)))})(),i},jo=new Uint8Array(0),Le=e=>e instanceof Error?e:new Error(String(e)),Qa=()=>new DOMException("The operation was aborted.","AbortError"),Za=()=>{const e=typeof navigator<"u"&&navigator.onLine===!1,t=typeof document<"u"&&document.visibilityState==="hidden";return e||t},ra=e=>{const t=e.helloRetryMs??1e3,r=e.helloTimeoutMs??3e4,o=e.pingIntervalMs??3e4,n=e.pingTimeoutMs??15e3,a=e.resumeProbeTimeoutMs??5e3,s=e.batchWindowMs??ni,i=e.batch!==!1,c=e.reconnectBaseDelayMs??1e3,d=e.reconnectMaxDelayMs??3e4,l=e.hiddenOrOfflineMaxDelayMs??6e4,u=e.createWireSocket??(v=>fd(new WebSocket(v)));let f=!1,m={state:"idle"};const g=new Set;let h=null,p=null,k=null,A=null,C=0,w=0,B=null,P=[];const ee=v=>{if(!(m.state===v.state&&m.lastError===v.lastError)){m=v;for(const U of g)try{U(m)}catch{}}},Be=v=>{const U=P;P=[];for(const N of U)N.reject(v)},se=v=>{const U=P;P=[];for(const N of U)N.resolve(v)},Ge=(v,U)=>{v.dead=!0;const N=Array.from(v.streams.values());v.streams.clear();for(const $ of N)try{$.fail(U)}catch{}},Ce=()=>{B!==null&&(clearTimeout(B),B=null)},te=()=>{if(!(f||Za())){if(B!==null){Ce(),Oe();return}m.state==="connecting"||m.state==="reconnecting"||h&&!h.dead&&A?.()}},Mt=()=>{typeof document<"u"&&document.addEventListener("visibilitychange",te),typeof window<"u"&&(window.addEventListener("online",te),window.addEventListener("pichamber:system-resume",te))},rr=()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",te),typeof window<"u"&&(window.removeEventListener("online",te),window.removeEventListener("pichamber:system-resume",te))},$r=()=>{if(f||B!==null)return;const v=c*Math.pow(1.5,Math.min(w,8)),U=Math.random()*.3*v,N=Math.min(d,Math.round(v+U)),$=Za()?Math.max(N,l):N;B=setTimeout(()=>{B=null,Oe()},$)},or=()=>{const v=new URL(e.relayUrl);return v.searchParams.set("v",String(yr)),v.searchParams.set("role","client"),v.searchParams.set("serverId",e.serverId),e.grant&&v.searchParams.set("grant",e.grant),v.toString()},Oe=async()=>{if(f)return;const v=++C;Ce(),k?.(),k=null,ee({state:w===0?"connecting":"reconnecting"});let U;try{U=await ed(e.hostEncPubJwk,{batch:i})}catch(I){sr(v,Le(I),!0);return}if(f||v!==C)return;let N;try{N=u(or())}catch(I){sr(v,Le(I));return}p=N;let $=null,W=null,de=null,ae=null,dt=!1,Tt=null,Fe=!1,le=null,We=null,lt=Date.now(),ut=!1,E=Promise.resolve();const R=()=>{A===z&&(A=null),dt=!1,$!==null&&(clearInterval($),$=null),W!==null&&(clearTimeout(W),W=null),de!==null&&(clearInterval(de),de=null),ae!==null&&(clearTimeout(ae),ae=null),Tt?.dispose(),Tt=null};k=R;const T=(I,J={})=>{const{terminal:V=!1,asErrorState:q=!1}=J;if(!(Fe||v!==C)){Fe=!0,R(),k===R&&(k=null),le&&Ge(le,I),h===le&&(h=null);try{N.close()}catch{}if(p===N&&(p=null),V){f=!0,Be(I),ee({state:"error",lastError:I.message});return}sr(v,I,q)}},z=()=>{Fe||v!==C||!le||le.dead||dt||(dt=!0,lt=Date.now(),ae!==null&&(clearTimeout(ae),ae=null),le.send(Pe(O.Ping,0,jo)),ae=setTimeout(()=>{ae=null,T(new Error("relay resume probe timeout"))},a))},ue=()=>{if(N.readyState===1)try{N.send(U.helloText)}catch(I){T(Le(I))}},ve=(I,J)=>{We=I,ut=J,$!==null&&(clearInterval($),$=null),W!==null&&(clearTimeout(W),W=null),w=0;const V=new Map,q=ud(),ft=nd();let me=Promise.resolve();const Ne=cr=>{me=me.then(async()=>{if(ir.dead)return;const _c=await I.encryptor.encrypt(cr);N.send(_c)}).catch(()=>{})},mt=J?ld({windowMs:s,sendBatch:Ne}):null;Tt=mt;const ir={streams:V,assembler:ft,nextStreamId:()=>q.next(),send:cr=>{if(lt=Date.now(),mt){mt.enqueue(cr);return}Ne(cr)},dead:!1};le=ir,h=ir,A=z,ee({state:"connected"}),se(ir),de=setInterval(()=>{Date.now()-lt<o||(ir.send(Pe(O.Ping,0,jo)),ae===null&&(ae=setTimeout(()=>{ae=null,T(new Error("relay keepalive timeout"))},n)))},o)},ar=(I,J)=>{let V;try{V=td(J)}catch(me){T(Le(me));return}if(ae!==null&&(clearTimeout(ae),ae=null),dt=!1,V.frameType===O.Ping){I.send(Pe(O.Pong,V.streamId,jo));return}if(V.frameType===O.Pong)return;lt=Date.now();let q=V.payload;if(V.frameType===O.WsText||V.frameType===O.WsBinary){let me;try{me=I.assembler.push(V)}catch(Ne){T(Le(Ne));return}if(me===null)return;q=me}else if(V.hasMoreFragments){T(new Error("unexpected fragmented tunnel frame"));return}const ft=I.streams.get(V.streamId);ft&&ft.handleFrame(V.frameType,q)};N.onopen=()=>{Fe||v!==C||(ue(),$=setInterval(ue,t))},N.onmessage=I=>{if(Fe||v!==C)return;const J=I.data;if(typeof J=="string"){E=E.then(async()=>{if(Fe||v!==C)return;const q=await U.handleText(J);if(q.type==="established"){if(We)return;ve(q.channel,q.batch)}else q.type==="fail"&&T(new Error(`relay handshake failed: ${q.reason}`))}).catch(q=>{T(Le(q))});return}const V=J instanceof ArrayBuffer?new Uint8Array(J):J instanceof Uint8Array?J:null;V&&(E=E.then(async()=>{if(Fe||v!==C)return;const q=le,ft=We;if(!q||!ft){T(new Error("encrypted frame before handshake completed"));return}let me;try{me=await ft.decryptor.decrypt(V)}catch(Ne){T(Le(Ne));return}if(ut){let Ne;try{Ne=sd(me)}catch(mt){T(Le(mt));return}for(const mt of Ne){if(Fe||v!==C||q.dead)return;ar(q,mt)}return}ar(q,me)}).catch(q=>{T(Le(q))}))},N.onclose=I=>{const J=gd.has(I.code);T(new Error(pd[I.code]??`relay socket closed (code ${I.code})`),{terminal:J,asErrorState:J})},N.onerror=()=>{},W=setTimeout(()=>{W=null,T(new Error("relay handshake timeout"),{asErrorState:!0})},r);function sr(I,J,V=!1){I!==C||f||(Be(J),w+=1,ee({state:V?"error":"reconnecting",lastError:J.message}),$r())}},nr=v=>f?Promise.reject(new Error("relay tunnel closed")):v?.aborted?Promise.reject(Qa()):h&&!h.dead?Promise.resolve(h):new Promise((U,N)=>{let $=null;const W={resolve(de){$&&v&&v.removeEventListener("abort",$),U(de)},reject(de){$&&v&&v.removeEventListener("abort",$),N(de)}};v&&($=()=>{P=P.filter(de=>de!==W),N(Qa())},v.addEventListener("abort",$,{once:!0})),P.push(W)}),Uo=()=>{if(f)return;f=!0,C+=1,Ce(),rr(),k?.(),k=null;const v=h;h=null;const U=new Error("relay tunnel closed");v&&Ge(v,U),Be(U);try{p?.close()}catch{}p=null,ee({state:"idle"})};return Mt(),Oe(),{fetch:(v,U)=>Md(nr,v,U),openWebSocket:(v,U)=>Pd(()=>nr(),v,U),getStatus:()=>m,subscribeStatus(v){return g.add(v),()=>{g.delete(v)}},close:Uo}};let pe=null,Ar=null;const Rd=(e,t)=>e.relayUrl===t.relayUrl&&e.serverId===t.serverId&&e.grant===t.grant&&JSON.stringify(e.hostEncPubJwk)===JSON.stringify(t.hostEncPubJwk),xr=()=>pe,Xt=()=>pe!==null,mn=new Set,wy=e=>(mn.add(e),()=>{mn.delete(e)}),oa=e=>{if(e!==Xt())for(const t of[...mn])t()},Id=e=>{if(pe&&Ar&&Rd(Ar,e))return pe;const t=Xt();return pe?.close(),Ar=e,pe=ra(e),oa(t),pe},By=(e,t)=>{if(pe===t)return;const r=Xt();pe?.close(),Ar=e,pe=t,oa(r)},_d=()=>{const e=Xt();pe?.close(),pe=null,Ar=null,oa(e)};let ii=()=>null,ci="",po={},at="",Dr=0,Ft=null,Ht="",Sr=0,Bt="",yt=null,Qe="",ro=0,oo=0;const na=1e4,xd=e=>e.toLowerCase()==="authorization",di=e=>{const t={};for(const[r,o]of Object.entries(e||{})){const n=r.trim(),a=o.trim();n&&a&&!xd(n)&&(t[n]=a)}return t},Od=(e,t)=>{const r=Object.entries(e);return r.length!==Object.keys(t).length?!1:r.every(([o,n])=>t[o]===n)},Or=e=>typeof e!="string"?"":e.trim(),Nd=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_CLIENT_TOKEN__;return Or(e)},Ld=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_API_BASE_URL__;return typeof e=="string"?e.trim():""},li=(e,t)=>{const r=typeof e=="string"&&e.trim()?e.trim():Ld();if(!r)return t;try{return new URL(t,`${r.replace(/\/+$/,"")}/`).toString()}catch{return t}},aa=e=>{try{return new URL(e).origin}catch{return""}},ui=()=>{Ht="",Sr=0,Bt="",yt=null,Qe="",ro+=1},Nr=e=>{e!==void 0&&Or(e)!==at||(at="",Dr=0,ui())},fi=()=>{oo+=1,Ft=null,Nr(),ia()},mi=e=>{const t=Or(e);ci=t,fi(),ii=()=>t?{type:"bearer",token:t}:null},gi=e=>{const t=di(e);Od(po,t)||(po=t,fi())},sa=()=>{if(Object.keys(po).length>0)return po;if(typeof window>"u")return{};const e=window.__PICHAMBER_RUNTIME_HEADERS__;return e&&typeof e=="object"?di(e):{}},To=()=>ci||Nd(),Ud=(e,t)=>{const r=Or(e);if(!r||typeof t!="number"||!Number.isFinite(t)){Nr();return}const o=at;at=r,Dr=t,o&&o!==r&&qd()},pi=()=>!at||Dr<=Date.now()+na?(Nr(),""):at,Hd=e=>{const t=aa(e);return!t||Bt!==t?"":!Ht||Sr<=Date.now()+na?(Ht="",Sr=0,Bt="",""):Ht},Kd=()=>{const e=pi();return!e&&(To()||typeof window<"u")&&Lr().catch(()=>{}),e},hi=async()=>{const e=await ii(),t=e?.type==="bearer"?Or(e.token):To();return t?{type:"bearer",token:t}:null},Fi=e=>{if(Ft)return Ft;const t=oo,o=(async()=>{const n=await hi(),a=new Headers;for(const[u,f]of Object.entries(sa()))a.set(u,f);n?.type==="bearer"&&a.set("Authorization",`Bearer ${n.token}`);const s=xr(),i=s?await s.fetch("/auth/url-token",{method:"POST",headers:a}):await fetch(li(e,"/auth/url-token"),{method:"POST",headers:a,credentials:"include"});if(!i.ok)throw t===oo&&Nr(),new Error(`Failed to mint runtime URL auth token (${i.status})`);const c=await i.json().catch(()=>null),d=typeof c?.token=="string"?c.token.trim():"",l=typeof c?.expiresAt=="number"?c.expiresAt:0;if(t!==oo)throw new Error("Runtime URL auth token response is stale");if(Ud(d,l),!at)throw new Error("Runtime URL auth token response was invalid");return at})().finally(()=>{Ft===o&&(Ft=null)});return Ft=o,Ft},jd=e=>{const t=aa(e);if(!t)return Promise.reject(new Error("Local runtime URL auth origin was invalid"));if(yt&&Qe===t)return yt;const r=ro,n=(async()=>{const a=await fetch(li(t,"/auth/url-token"),{method:"POST",credentials:"include"});if(!a.ok)throw r===ro&&t===Qe&&(Ht="",Sr=0,Bt=""),new Error(`Failed to mint local runtime URL auth token (${a.status})`);const s=await a.json().catch(()=>null),i=typeof s?.token=="string"?s.token.trim():"",c=typeof s?.expiresAt=="number"?s.expiresAt:0;if(!i||!Number.isFinite(c))throw new Error("Local runtime URL auth token response was invalid");if(r!==ro||t!==Qe)throw new Error("Local runtime URL auth token response is stale");return Ht=i,Sr=c,Bt=t,i})().finally(()=>{yt===n&&(yt=null,Qe="")});return yt=n,Qe=t,yt},Lr=async e=>{const t=pi();return t||Fi(e)},$d=async e=>{const t=aa(e);if(!t)throw new Error("Local runtime URL auth origin was invalid");const r=Hd(t);return r||((Bt&&Bt!==t||Qe&&Qe!==t)&&ui(),jd(t))};let xt=0,Er=null,yi=null;const gn=new Set,zd=5e3,qd=()=>{for(const e of gn)try{e()}catch{}},bi=()=>{Er!==null&&(clearTimeout(Er),Er=null)},ia=()=>{if(bi(),xt<=0||typeof window>"u")return;const e=Dr-na-zd,t=Dr>0?Math.max(0,e-Date.now()):0;Er=setTimeout(()=>{Er=null,!(xt<=0)&&Fi(yi).catch(()=>{}).finally(()=>{ia()})},t)},Cy=e=>{typeof e=="string"&&e.trim()&&(yi=e.trim()),xt+=1,ia();let t=!1;return()=>{t||(t=!0,xt=Math.max(0,xt-1),xt===0&&bi())}},vy=e=>(gn.add(e),()=>{gn.delete(e)}),Gd=async e=>{const t=new Headers(e);for(const[o,n]of Object.entries(sa()))t.has(o)||t.set(o,n);if(t.has("Authorization"))return t;const r=await hi();return r?.type==="bearer"&&t.set("Authorization",`Bearer ${r.token}`),t},pn="pichamber:auth-expired",ky=()=>{typeof window>"u"||window.dispatchEvent(new Event(pn))},Dy=e=>typeof window>"u"?()=>{}:(window.addEventListener(pn,e),()=>{window.removeEventListener(pn,e)}),Sy=async(e,t,r)=>{if(e.length===0)return[];const o=Math.max(1,Math.min(t,e.length)),n=new Array(e.length);let a=0;const s=async()=>{for(;;){const i=a;if(a+=1,i>=e.length)return;n[i]=await r(e[i])}};return await Promise.all(Array.from({length:o},()=>s())),n},es=e=>{if(e instanceof Error)return e;if(typeof DOMException<"u")return new DOMException(typeof e=="string"?e:"The operation was aborted.","AbortError");const t=new Error(typeof e=="string"?e:"The operation was aborted.");return t.name="AbortError",t},Ai=(e,t)=>t?t.aborted?Promise.reject(es(t.reason)):new Promise((r,o)=>{let n=!1;const a=()=>{n||(n=!0,o(es(t.reason)))};t.addEventListener("abort",a,{once:!0}),e().then(s=>{n||(n=!0,t.removeEventListener("abort",a),r(s))},s=>{n||(n=!0,t.removeEventListener("abort",a),o(s))})}):e(),Wd=["local","remote",null],Vd=["ok","not-configured","unreachable","incompatible","wrong-service","missing"];function Ei(e){if(!e||typeof e!="object")return{valid:!1};const t=e,r=t.localAvailable===!1?{localAvailable:!1}:{},o=t.target,n=t.status;if(o!==null&&(typeof o!="string"||!Wd.includes(o)))return{valid:!1};if(typeof n!="string"||!Vd.includes(n))return{valid:!1};if(o==="remote"||o==="local"){if(n==="ok"&&o==="local")return{valid:!0,outcome:{target:"local",status:"ok",...r}};if(n==="ok"&&o==="remote")return typeof t.hostId!="string"||typeof t.url!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:"ok",hostId:t.hostId,url:t.url,...r}};if(n==="unreachable")return o==="local"?{valid:!0,outcome:{target:"local",status:"unreachable",...r}}:typeof t.hostId!="string"||typeof t.url!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:"unreachable",hostId:t.hostId,url:t.url,...r}};if(n==="incompatible"||n==="wrong-service")return o!=="remote"?{valid:!1}:typeof t.hostId!="string"||typeof t.url!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:n,hostId:t.hostId,url:t.url,...r}};if(n==="missing")return o!=="remote"?{valid:!1}:typeof t.hostId!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:"missing",hostId:t.hostId,...r}}}if(o===null){if(n==="not-configured")return{valid:!0,outcome:{target:null,status:"not-configured",...r}};if(n==="missing")return{valid:!1}}return{valid:!1}}function Jd(){if(Yd()!=="valid")return null;const t=window.__PICHAMBER_DESKTOP_BOOT_OUTCOME__,r=Ei(t);return r.valid?r.outcome:null}function Yd(){if(typeof window>"u")return"not-injected";const e=window.__PICHAMBER_DESKTOP_BOOT_OUTCOME__;return e==null?"not-injected":Ei(e).valid?"valid":"malformed"}const ho=/^[a-z][a-z\d+.-]*:\/\//i,Xd=e=>{const t=e.trim();return t?t.startsWith("/")?t:`/${t}`:"/"},hn=e=>typeof e!="string"?"":e.trim().replace(/\/+$/,""),Qd=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_API_BASE_URL__;return hn(e)},Zd=e=>{const t=e.currentHref?.();return t||(typeof window<"u"?window.location.href||window.location.origin:"")},Fn=(e,t)=>{if(!t)return;const r=t instanceof URLSearchParams?Array.from(t.entries()):Object.entries(t);for(const[o,n]of r)n!=null&&e.searchParams.set(o,String(n))},el=(e,t)=>{if(!t)return e;const r=new URLSearchParams;Fn({searchParams:r},t);const o=r.toString();return o?e.includes("?")?`${e}&${o}`:`${e}?${o}`:e},ts=(e,t,r)=>{if(ho.test(t)){const a=new URL(t);return Fn(a,r),a.toString()}const o=Xd(t);if(!e)return el(o,r);const n=new URL(o,`${e}/`);return Fn(n,r),n.toString()},$o=(e,t)=>{const r=t===void 0?Kd():t;if(!r)return e;const o=ho.test(e)?new URL(e):new URL(e,"http://pichamber.local");return o.searchParams.set("oc_url_token",r),ho.test(e)?o.toString():`${o.pathname}${o.search}${o.hash}`},tl=(e,t)=>{const r=ho.test(e)?new URL(e):new URL(e,Zd(t));return r.protocol==="ws:"||r.protocol==="wss:"||(r.protocol=r.protocol==="https:"?"wss:":"ws:"),r.toString()},ca=(e={})=>{const t=hn(e.apiBaseUrl),r=hn(e.realtimeBaseUrl),o=()=>t||Qd(),n=()=>r||o(),a=(i,c)=>ts(o(),i,c),s=(i,c)=>ts(n(),i,c);return{api:a,authenticatedAsset:(i,c)=>$o(a(i,c)),auth:a,health:i=>a("/health",i),rawFile:(i,c)=>a("/api/fs/raw",{path:i,download:c?.download===!0?!0:void 0,allowOutsideWorkspace:c?.allowOutsideWorkspace===!0?!0:void 0,outsideFileGrant:c?.outsideFileGrant}),sse:(i,c)=>$o(s(i,c)),websocket:(i,c,d)=>tl($o(s(i,c),d),e)}};let Fo=ca();const Ie=()=>Fo,rl=e=>{Fo=e},da=e=>(Fo=ca(e),Fo);let zo=null,qo=null,Go=null;const rs=new Set;let os=!1;const wi=e=>{if(rs.add(e),os||typeof window>"u")return;os=!0;const t=()=>{for(const r of rs)r()};try{window.addEventListener("pagehide",t,{capture:!0}),window.addEventListener("beforeunload",t,{capture:!0}),typeof document<"u"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&t()}),document.addEventListener("freeze",t))}catch{}},ol=(e,t)=>{let r;try{r=e()}catch{return}const o=new Map,n=new Set;let a;const s=()=>{if(a=void 0,o.size===0&&n.size===0)return;const c=Array.from(o.entries()),d=Array.from(n);o.clear(),n.clear();for(const[l,u]of c)try{r.setItem(l,JSON.stringify(u,t?.replacer))}catch(f){console.error("Failed to persist deferred storage value",f),!o.has(l)&&!n.has(l)&&o.set(l,u)}for(const l of d)try{r.removeItem(l)}catch(u){console.error("Failed to remove deferred storage value",u),o.has(l)||n.add(l)}},i=()=>{a===void 0&&(a=setTimeout(s,0))};return wi(s),{getItem:c=>{if(o.has(c))return o.get(c)??null;if(n.has(c))return null;const d=u=>{if(u===null)return null;try{return JSON.parse(u,t?.reviver)}catch{try{r.removeItem(c)}catch{}return null}},l=r.getItem(c);return l instanceof Promise?l.then(d):d(l)},setItem:(c,d)=>{o.set(c,d),n.delete(c),i()},removeItem:c=>{o.delete(c),n.add(c),i()}}},la=e=>ol(()=>vi(),e),nl=e=>{const t=new Map,r=new Set;let o;const n=()=>{if(o=void 0,t.size===0&&r.size===0)return;const s=Array.from(t.entries()),i=Array.from(r);t.clear(),r.clear();for(const[c,d]of s)try{e.setItem(c,d)}catch(l){console.error("Failed to persist deferred storage value",l),!t.has(c)&&!r.has(c)&&t.set(c,d)}for(const c of i)try{e.removeItem(c)}catch(d){console.error("Failed to remove deferred storage value",d),t.has(c)||r.add(c)}},a=()=>{o===void 0&&(o=setTimeout(n,0))};return wi(n),{getItem:s=>t.has(s)?t.get(s)??null:r.has(s)?null:e.getItem(s),setItem:(s,i)=>{t.set(s,i),r.delete(s),a()},removeItem:s=>{t.delete(s),r.add(s),a()},clear:()=>{t.clear(),r.clear(),o!==void 0&&(clearTimeout(o),o=void 0),e.clear()},key:s=>e.key(s),get length(){return e.length}}},Bi=e=>{if(typeof window>"u")return null;try{return window[e]??null}catch{return null}},ua=()=>{const e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,r)=>{e.set(t,r)},removeItem:t=>{e.delete(t)},clear:()=>{e.clear()},key:t=>Array.from(e.keys())[t]??null,get length(){return e.size}}},Ci=e=>{const t=ua(),r=new Set,o=new Set,n=d=>{if(o.has(d))return null;if(r.has(d))return t.getItem(d);try{return e.getItem(d)}catch{return null}},a=(d,l)=>{try{e.setItem(d,l),t.removeItem(d),r.delete(d),o.delete(d);return}catch{try{e.removeItem(d)}catch{}}t.setItem(d,l),r.add(d),o.delete(d)},s=d=>{try{e.removeItem(d),o.delete(d)}catch{o.add(d)}t.removeItem(d),r.delete(d)},i=()=>{const d=[];try{for(let l=0;l<e.length;l+=1){const u=e.key(l);u&&d.push(u)}}catch{}try{e.clear(),o.clear()}catch{for(const l of d)o.add(l)}t.clear(),r.clear()},c=()=>{const d=new Set;try{for(let l=0;l<e.length;l+=1){const u=e.key(l);u&&!o.has(u)&&!r.has(u)&&d.add(u)}}catch{}for(const l of r)d.add(l);return[...d]};return{getItem:n,setItem:a,removeItem:s,clear:i,key:d=>c()[d]??null,get length(){return c().length}}},al=()=>{const e=Bi("localStorage");return e?Ci(e):ua()},vi=()=>(zo||(zo=al()),zo),Ur=()=>(Go||(Go=nl(vi())),Go),sl=()=>{const e=Bi("sessionStorage");return e?Ci(e):ua()},My=()=>(qo||(qo=sl()),qo),yn="pichamber:runtime-endpoint-changed",bn="pichamber:runtime-endpoint-will-change";let st="",Ct="",ki=0;const Ty=()=>(Po(),ki),An="pichamber:lastRuntimeEndpoint.v1",il=()=>{try{const e=Ur().getItem(An);if(!e)return null;const t=JSON.parse(e),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl.trim():"",o=typeof t.runtimeKey=="string"?t.runtimeKey.trim():"";return!r||!o||o==="mobile-disconnected"?null:{apiBaseUrl:r,runtimeKey:o}}catch{return null}},cl=(e,t)=>{try{const r=Ur();if(t==="mobile-disconnected"||!e){r.removeItem(An);return}r.setItem(An,JSON.stringify({apiBaseUrl:e,runtimeKey:t}))}catch{}},Po=()=>{if(st||Ct||typeof window>"u")return;const e=il();if(e){st=e.apiBaseUrl,Ct=e.runtimeKey;try{window.__PICHAMBER_API_BASE_URL__=e.apiBaseUrl}catch{}da({apiBaseUrl:e.apiBaseUrl,realtimeBaseUrl:e.apiBaseUrl})}},Wo=(e,t,r)=>{try{e[t]=r}catch{}},fa=e=>{try{const t=new URL(e);return t.hash="",t.search="",t.pathname=t.pathname.replace(/\/+$/,"")||"/",`url:${t.toString().replace(/\/+$/,"")}`}catch{return`url:${e.trim().replace(/\/+$/,"")||"default"}`}},Di=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_API_BASE_URL__;return typeof e=="string"?e.trim():""},Si=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_LOCAL_ORIGIN__;return typeof e=="string"?e.trim():""},Mi=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},ze=()=>(Po(),st||Di());let Vo="",ns=null,as,ss;const is=e=>{if(typeof window>"u")return;const t=window[e];return typeof t=="string"?t:void 0},D=()=>{if(Po(),Ct)return Ct;const e=is("__PICHAMBER_API_BASE_URL__"),t=is("__PICHAMBER_LOCAL_ORIGIN__");if(ns===st&&as===e&&ss===t)return Vo;const r=ze();return Vo=Mi(r,Si())?"local":fa(r),ns=st,as=e,ss=t,Vo},dl=(e={})=>{if(Po(),st||Ct)return;const t=e.apiBaseUrl?.trim()||Di();t&&(st=t,Ct=e.runtimeKey?.trim()||(Mi(t,Si())?"local":fa(t)))},Kt=e=>{const t=e.apiBaseUrl.trim(),r=ze(),o=D(),n=e.runtimeKey?.trim()||fa(t);ki+=1,cl(t,n);const a={apiBaseUrl:t,previousApiBaseUrl:r,runtimeKey:n,previousRuntimeKey:o};if(typeof window<"u"&&window.dispatchEvent(new CustomEvent(bn,{detail:a})),st=t,Ct=n,typeof window<"u"){const s=window;Wo(s,"__PICHAMBER_API_BASE_URL__",t),Wo(s,"__PICHAMBER_CLIENT_TOKEN__",e.clientToken||void 0),Wo(s,"__PICHAMBER_RUNTIME_HEADERS__",e.requestHeaders||void 0)}da({apiBaseUrl:t,realtimeBaseUrl:t}),gi(e.requestHeaders||null),mi(e.clientToken||null),e.relay?Id(e.relay):_d(),Lr(t).catch(()=>{}),typeof window<"u"&&window.dispatchEvent(new CustomEvent(yn,{detail:a}))},ll=e=>{if(typeof window>"u")return()=>{};const t=r=>{e(r.detail)};return window.addEventListener(bn,t),()=>window.removeEventListener(bn,t)},Ti=e=>{if(typeof window>"u")return()=>{};const t=r=>{e(r.detail)};return window.addEventListener(yn,t),()=>window.removeEventListener(yn,t)};let En=null;const ul=e=>{En=e},ma=()=>En||(typeof window>"u"?null:window.__PICHAMBER_RUNTIME_APIS__??null),Py=Object.freeze(Object.defineProperty({__proto__:null,getRegisteredRuntimeAPIs:ma,registerRuntimeAPIs:ul},Symbol.toStringTag,{value:"Module"})),fl=()=>typeof window>"u"?null:window.__PICHAMBER_ELECTRON__??null,Qt=()=>typeof window>"u"?null:window.__PICHAMBER_DESKTOP__??null,Ro=()=>fl()?.runtime==="electron",Ry=()=>{if(typeof window>"u")return null;const e=window.__PICHAMBER_PLATFORM__;return typeof e=="string"?e:null},Z=()=>typeof Qt()?.invoke=="function",xe=()=>Ro()&&Z(),j=async(e,t)=>{const r=Qt();return typeof r?.invoke!="function"?null:r.invoke(e,t??{})},cs=e=>{const t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith("/")?t:`${t}/`).origin}catch{return null}}},Jo=e=>{const t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith("/")?t:`${t}/`)}catch{return null}}},ml=e=>e.replace(/^\[|\]$/g,"").toLowerCase(),dr=e=>{const t=ml(e);return t==="localhost"||t==="127.0.0.1"||t==="::1"},we=()=>typeof window>"u"?!1:Ro(),ce=()=>{if(typeof window>"u"||!we())return!1;if(D()==="local")return!0;const e=typeof window.__PICHAMBER_LOCAL_ORIGIN__=="string"?window.__PICHAMBER_LOCAL_ORIGIN__:"",t=Jo(e),r=Jo(ze());if(!r&&t&&Jd()?.target==="local")return!0;if(t&&r){if(t.origin===r.origin)return!0;const s=t.port||(t.protocol==="https:"?"443":"80"),i=r.port||(r.protocol==="https:"?"443":"80");return t.protocol===r.protocol&&s===i&&dr(t.hostname)&&dr(r.hostname)}const o=Jo(window.location.origin);if(t&&o){if(t.origin===o.origin)return!0;const s=t.port||(t.protocol==="https:"?"443":"80"),i=o.port||(o.protocol==="https:"?"443":"80");return t.protocol===o.protocol&&s===i&&dr(t.hostname)&&dr(o.hostname)}const n=cs(e),a=cs(window.location.origin)||window.location.origin;return n&&a&&n===a?!0:!!(o&&dr(o.hostname))},Iy=()=>{const t=ma()?.runtime?.platform;return t==="web"?!0:t!=="desktop"},_y=(e,t=we())=>e==="web"&&!t,xy=async()=>{if(!xe())return null;try{const e=await j("desktop_get_launch_at_login");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"?null:e}catch(e){return console.warn("Failed to get launch at login status",e),null}},Oy=async e=>{if(!xe())return null;try{const t=await j("desktop_set_launch_at_login",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"?null:t}catch(t){return console.warn("Failed to set launch at login status",t),null}},Ny=async()=>{if(!xe())return null;try{const e=await j("desktop_get_minimize_to_tray");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"?null:e}catch(e){return console.warn("Failed to get minimize to tray status",e),null}},Ly=async e=>{if(!xe())return null;try{const t=await j("desktop_set_minimize_to_tray",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"?null:t}catch(t){return console.warn("Failed to set minimize to tray status",t),null}},Uy=async()=>{if(!xe())return null;try{const e=await j("desktop_get_close_to_tray");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"?null:e}catch(e){return console.warn("Failed to get close to tray status",e),null}},Hy=async e=>{if(!xe())return null;try{const t=await j("desktop_set_close_to_tray",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"?null:t}catch(t){return console.warn("Failed to set close to tray status",t),null}},Ky=async()=>{if(!xe())return null;try{const e=await j("desktop_get_keep_awake");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"||typeof e.active!="boolean"?null:e}catch(e){return console.warn("Failed to get keep awake status",e),null}},jy=async e=>{if(!xe())return null;try{const t=await j("desktop_set_keep_awake",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"||typeof t.active!="boolean"?null:t}catch(t){return console.warn("Failed to set keep awake status",t),null}},$y=async()=>{if(!xe())return null;try{const e=await j("desktop_get_process_performance_recording");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"||typeof e.active!="boolean"?null:e}catch(e){return console.warn("Failed to get process performance recording status",e),null}},zy=async e=>{if(!xe())return null;try{const t=await j("desktop_set_process_performance_recording",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"||typeof t.active!="boolean"?null:t}catch(t){return console.warn("Failed to set process performance recording status",t),null}},gl=()=>we()&&Z()&&ce(),pl=async()=>{if(typeof window<"u"){const e=window.__PICHAMBER_HOME__;if(e&&e.length>0)return e}return null},qy=async e=>{if(gl())try{const t=await Qt()?.openDialog?.({directory:!0,multiple:!1,title:"Select working directory",...e?{defaultPath:e}:{}});return!t||typeof t!="string"?{success:!1,error:"Directory selection cancelled"}:{success:!0,path:t}}catch(t){return console.warn("Failed to request directory access",t),{success:!1,error:t instanceof Error?t.message:String(t)}}return{success:!1,error:"Native directory picker not available"}},Pi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Gy=async e=>{if(Z()&&ce())try{const t=await Qt()?.openDialog?.({directory:!1,multiple:!1,title:"Select file",returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:"File selection cancelled"};if(typeof t=="string")return{success:!0,path:t};if(!Pi(t))return{success:!1,error:"File selection cancelled"};const r=typeof t.path=="string"?t.path:"";return r?{success:!0,path:r,outsideFileGrant:typeof t.outsideFileGrant=="string"?t.outsideFileGrant:void 0}:{success:!1,error:"File selection cancelled"}}catch(t){return console.warn("Failed to request file access",t),{success:!1,error:t instanceof Error?t.message:String(t)}}return{success:!1,error:"Native file picker not available"}},Wy=async e=>{const t=typeof e=="string"?e.trim():"";if(!t)return{success:!1,error:"Path is required"};if(!Z()||!ce())return{success:!1,error:"Native file access not available"};try{const r=await Qt()?.grantFileAccess?.(t);if(!Pi(r))return{success:!1,error:"File access was not granted"};const o=typeof r.path=="string"?r.path:"",n=typeof r.outsideFileGrant=="string"?r.outsideFileGrant:"";return!o||!n?{success:!1,error:"File access was not granted"}:{success:!0,path:o,outsideFileGrant:n}}catch(r){return console.warn("Failed to request existing file access",r),{success:!1,error:r instanceof Error?r.message:String(r)}}},Vy=async e=>({success:!0}),Jy=async e=>({success:!0}),Yy=async()=>Z()&&await j("desktop_get_update_channel")==="rc"?"rc":"stable",Xy=async e=>{if(!Z())throw new Error("Desktop update settings are unavailable.");const t=await j("desktop_set_update_channel",{channel:e});if(t!=="stable"&&t!=="rc")throw new Error("Unable to save the desktop update channel.");return t},Qy=async()=>Z()?await j("desktop_check_for_updates"):null,Zy=async e=>{if(!Z())return!1;const t=Qt();let r=null,o=0,n;try{return typeof e=="function"&&t?.listen&&(r=await t.listen("pichamber:update-progress",a=>{const s=a?.payload;if(!s||typeof s!="object")return;const i=s,c=typeof i.event=="string"?i.event:null,d=i.data&&typeof i.data=="object"?i.data:null;if(c==="Started"){o=0,n=typeof d?.contentLength=="number"?d.contentLength:void 0,e({downloaded:o,total:n});return}if(c==="Progress"){const l=d?.downloaded,u=d?.total;typeof l=="number"&&(o=l),typeof u=="number"&&(n=u),e({downloaded:o,total:n});return}c==="Finished"&&e({downloaded:o,total:n})})),await j("desktop_download_and_install_update"),!0}catch(a){throw a instanceof Error?a:new Error(String(a))}finally{if(r)try{const a=r();a instanceof Promise&&await a}catch{}}},hl=async()=>{if(!Z())return!1;try{return await j("desktop_restart"),!0}catch(e){return console.warn("Failed to restart desktop app",e),!1}},eb=async()=>Z()?hl():!1,tb=async()=>{if(!Z()||!ce())return null;try{const e=await j("desktop_get_lan_address");return typeof e=="string"&&e.trim().length>0?e.trim():null}catch(e){return console.warn("Failed to get desktop LAN address",e),null}},Fl=async(e,t)=>{if(!Z()||!ce())return!1;const r=e?.trim();if(!r)return!1;try{return await j("desktop_open_path",{path:r,app:typeof t=="string"&&t.trim().length>0?t.trim():void 0}),!0}catch(o){return console.warn("Failed to open path",o),!1}},rb=async e=>{if(!Z()||!ce())return!1;const t=e?.trim();if(!t)return!1;try{return await j("desktop_reveal_path",{path:t}),!0}catch{return Fl(t)}},ob=async(e,t)=>{if(!Z()||!ce())return null;const r=e?.trim();if(!r)return null;try{const o=await j("desktop_save_markdown_file",{defaultFileName:r,content:t});return typeof o=="string"&&o.trim().length>0?o:null}catch(o){return console.warn("Failed to save markdown file",o),null}},nb=async(e,t,r)=>{if(!Z()||!ce())return!1;const o=e?.trim(),n=t?.trim(),a=r?.trim();if(!o||!n||!a)return!1;try{return await j("desktop_open_in_app",{projectPath:o,appId:n,appName:a}),!0}catch(s){return console.warn("Failed to open project in app",s),!1}},ab=async(e,t,r)=>{if(!Z()||!ce())return!1;const o=e?.trim(),n=t?.trim(),a=r?.trim();if(!o||!n||!a)return!1;try{return await j("desktop_open_file_in_app",{filePath:o,appId:n,appName:a}),!0}catch(s){return console.warn("Failed to open file in app",s),!1}},sb=async(e,t)=>{if(!Z()||!ce())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};const r=Array.isArray(e)?e.filter(o=>typeof o=="string"):[];if(r.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{const o=await j("desktop_get_installed_apps",{apps:r,force:t===!0?!0:void 0});if(!o||typeof o!="object")return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};const n=o;return n.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(n.apps)?{apps:n.apps.filter(s=>s&&typeof s=="object").map(s=>{const i=s;return{name:typeof i.name=="string"?i.name:"",iconDataUrl:typeof i.iconDataUrl=="string"?i.iconDataUrl:null}}).filter(s=>s.name.length>0),success:!0,hasCache:n.hasCache===!0,isCacheStale:n.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(o){return console.warn("Failed to fetch installed apps",o),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}},Zt=()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location?.protocol==="capacitor:",ib=()=>{if(typeof window>"u"||!Zt()||yl()!=="ios")return!1;const e=navigator.userAgent||"",t=navigator.maxTouchPoints??0;return/iPad/i.test(e)||/Macintosh|MacIntel/i.test(e)&&t>1},yl=()=>{if(typeof window<"u"){const t=window.Capacitor?.getPlatform?.();if(t==="ios"||t==="android")return t}return we()?"desktop":"web"},cb=()=>{if(typeof navigator>"u")return!1;const e=navigator.platform||"",t=navigator.userAgent||"";return/Win/i.test(e)&&/ARM|aarch64/i.test(t)},vt=e=>e.startsWith("/api/")||e==="/api"||e.startsWith("/auth/")||e==="/auth"||e==="/health",bl=()=>typeof window>"u"?"":window.location.origin||"",ga=e=>{if(typeof window>"u")return!1;const t=bl();if(t&&e.origin===t)return!0;try{const r=new URL(window.location.href||t);return e.protocol===r.protocol&&e.host===r.host}catch{return!1}},pa=e=>/^[a-z][a-z\d+.-]*:\/\//i.test(e),ha=(e,t)=>{if(!t)return;const r=t instanceof URLSearchParams?Array.from(t.entries()):Object.entries(t);for(const[o,n]of r)n!=null&&e.searchParams.set(o,String(n))},no=e=>{try{const t=Ie().api("/api");if(!/^[a-z][a-z\d+.-]*:\/\//i.test(t))return!1;const r=new URL(t);return e.origin!==r.origin?!1:vt(e.pathname)}catch{return!1}},Yo=e=>{if(vt(e))return!0;if(!/^[a-z][a-z\d+.-]*:\/\//i.test(e))return!1;try{const t=new URL(e);return ga(t)&&vt(t.pathname)}catch{return!1}},Al=(e,t)=>{try{const r=new URL(e);if(!ga(r))return e;const o=wt(`${r.pathname}${r.search}`,t);return!pa(o)&&(r.protocol==="http:"||r.protocol==="https:")?(ha(r,t),r.toString()):r.hash?`${o}${r.hash}`:o}catch{return e}},wt=(e,t)=>e==="/health"?Ie().health(t):e.startsWith("/auth/")||e==="/auth"?Ie().auth(e,t):vt(e)?Ie().api(e,t):/^[a-z][a-z\d+.-]*:\/\//i.test(e)?Al(e,t):e,El=e=>{const t=e instanceof Request?e.url:e.toString();if(!pa(t))return vt(t);try{return no(new URL(t))}catch{return!1}},wl=e=>{for(let t=0;t<e.length;t+=1)if(e.charCodeAt(t)>255)return!1;return!0},Bl=(e,t)=>!wl(t),ds=e=>{if(!e)return;const t=e instanceof Headers?Array.from(e.entries()):Array.isArray(e)?e:Object.entries(e);if(t.length===0)return;const r=[];let o=!1;for(const[n,a]of t)Bl(n,a)?(r.push([n,encodeURIComponent(a)]),o=!0):r.push([n,a]);return o?r:void 0},Ue=async(e,t,r=!0)=>{const o=new Headers(ds(e)??e);return t&&new Headers(ds(t)??t).forEach((n,a)=>o.set(a,n)),r?Gd(o):o},Cl=(e,t)=>{if(!t)return e;const r=new URL(e,ta);return ha(r,t),`${r.pathname}${r.search}`},Ri=(e,t)=>{const r=e instanceof Request?e.url:e.toString();if(!pa(r))return vt(r)?Cl(r,t):null;try{const o=new URL(r);return!ga(o)||!vt(o.pathname)?null:(ha(o,t),`${o.pathname}${o.search}`)}catch{return null}},vl=async(e,t,r)=>{const o=xr();if(!o)return null;const n=Ri(e,r);if(n===null)return null;const a=e instanceof Request?e.headers:void 0,s=await Ue(a,t.headers,!0);return e instanceof Request?o.fetch(e,{...t,headers:s}):o.fetch(n,{...t,headers:s})},kl=(e,t)=>{if(typeof e=="string")return wt(e,t);if(e instanceof URL)return wt(e.toString(),t);const r=wt(e.url,t);return r===e.url?e:new Request(r,e)},Dl=/\/api\/pi\/(health|projects|sessions|providers|resources|runtime|settings)(\b|\/|\?|$)/,Gr=new Map,Sl=(e,t,r)=>r||e!=="GET"||t.includes("/event")||!Dl.test(t)?null:`GET ${t}`,b=async(e,t={})=>{const{query:r,...o}=t,n=xr(),a=n?Ri(e,r):null,s=o.signal??(e instanceof Request?e.signal:void 0);let i,c,d;if(n&&a!==null){const g=e instanceof Request?e.headers:void 0,h=await Ue(g,o.headers,!0);i=e instanceof Request?()=>n.fetch(e,{...o,headers:h}):()=>n.fetch(a,{...o,headers:h}),c=a,d=String(o.method??(e instanceof Request?e.method:"GET")).toUpperCase()}else{const g=kl(e,r),h=g instanceof Request?g.headers:void 0,p=await Ue(h,o.headers,El(g));let k=g instanceof Request?()=>fetch(new Request(g,{...o,headers:p})):()=>fetch(g,{...o,headers:p});if(Zt()&&s){const A=k;k=()=>Ai(A,s)}i=k,c=g instanceof Request?g.url:g instanceof URL?g.toString():String(g),d=String(o.method??(g instanceof Request?g.method:"GET")).toUpperCase()}const l=o.signal!=null||e instanceof Request,u=Sl(d,c,l);if(!u)return i();const f=Gr.get(u);if(f)return f.then(g=>g.clone());const m=i();return Gr.set(u,m),m.then(()=>Gr.delete(u),()=>Gr.delete(u)),m.then(g=>g.clone())};let ls=!1;const Ml=()=>{if(ls||typeof window>"u")return;ls=!0;const e=window.fetch.bind(window);window.fetch=async(t,r)=>{const o=await vl(t,r??{});if(o)return o;if(typeof t=="string"){if(!Yo(t)){try{const a=new URL(t);if(no(a)){const s=await Ue(void 0,r?.headers);return e(t,{...r,headers:s})}}catch{}return e(t,r)}const n=await Ue(void 0,r?.headers);return e(wt(t),{...r,headers:n})}if(t instanceof URL){const n=t.toString();if(!Yo(n)){if(no(t)){const s=await Ue(void 0,r?.headers);return e(t,{...r,headers:s})}return e(t,r)}const a=await Ue(void 0,r?.headers);return e(wt(n),{...r,headers:a})}if(t instanceof Request){if(!Yo(t.url)){try{const i=new URL(t.url);if(no(i)){const c=await Ue(t.headers,r?.headers);return e(new Request(t,{...r,headers:c}))}}catch{}return e(t,r)}const n=await Ue(t.headers,r?.headers),a=wt(t.url),s=a===t.url?t:new Request(a,t);return e(new Request(s,{...r,headers:n}))}return e(t,r)}},jt=16384,yo=globalThis,Tl=e=>{if(yo.Buffer)return yo.Buffer.from(e,"utf8").toString("base64url");const t=new TextEncoder().encode(e);let r="";for(let o=0;o<t.length;o+=32768)r+=String.fromCharCode(...t.slice(o,o+32768));return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},Ii=e=>{try{if(yo.Buffer)return yo.Buffer.from(e,"base64url").toString("utf8");const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"="),r=atob(t),o=new Uint8Array(r.length);for(let n=0;n<r.length;n+=1)o[n]=r.charCodeAt(n);return new TextDecoder().decode(o)}catch{return null}},Pl=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const r=new URL(t);return r.protocol!=="http:"&&r.protocol!=="https:"?null:(r.hash="",r.toString().replace(/\/+$/g,""))}catch{return null}},Rl=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const r=new URL(t);return r.protocol!=="ws:"&&r.protocol!=="wss:"?null:(r.hash="",r.toString())}catch{return null}},us=e=>typeof e=="string"&&e.length>0,Il=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return t.kty!=="EC"||t.crv!=="P-256"||!us(t.x)||!us(t.y)?null:{kty:"EC",crv:"P-256",x:t.x,y:t.y}},_l=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,xl=e=>{if(!e||typeof e!="object")return null;const t=e,r=_l(t.priority);if(t.type==="lan"||t.type==="tunnel"||t.type==="tailscale"){const o=Pl(t.url);if(!o)return null;const n=t.type==="tailscale"&&(t.mode==="private"||t.mode==="public")?t.mode:void 0;return{type:t.type,url:o,...n?{mode:n}:{},...r===void 0?{}:{priority:r}}}if(t.type==="relay"){const o=Rl(t.relayUrl);if(!o)return null;const n=typeof t.serverId=="string"?t.serverId.trim():"";if(!n)return null;const a=Il(t.hostEncPubJwk);if(!a)return null;const s=typeof t.grant=="string"&&t.grant.trim()?t.grant.trim():void 0;return{type:"relay",relayUrl:o,serverId:n,hostEncPubJwk:a,...s?{grant:s}:{},...r===void 0?{}:{priority:r}}}return null},Fa=e=>{if(!e||typeof e!="object")return null;const t=e;if(t.v!==2)return null;const r=typeof t.pairingId=="string"?t.pairingId.trim():"",o=typeof t.secret=="string"?t.secret.trim():"";if(!r||!o)return null;const n=Array.isArray(t.candidates)?t.candidates.map(xl).filter(c=>!!c):[];if(n.length===0)return null;const a=typeof t.expiresAt=="string"&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){const c=Date.parse(a);if(!Number.isFinite(c)||c<=Date.now())return null}const s=typeof t.label=="string"&&t.label.trim()?t.label.trim():void 0,i=typeof t.fingerprint=="string"&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:r,secret:o,...s?{label:s}:{},...i?{fingerprint:i}:{},...a?{expiresAt:a}:{},candidates:n}},db=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),lb=e=>{const t=Fa(e);if(!t)throw new Error("Invalid pairing connection payload");const r=new URLSearchParams;return r.set("v","2"),r.set("p",Tl(JSON.stringify(t))),`pichamber://connect?${r.toString()}`},Ol=e=>{const t=e.trim();if(!t||t.length>jt)return null;try{const r=new URL(t);if(r.protocol!=="pichamber:"||r.hostname!=="connect"||r.searchParams.get("v")!=="2")return null;const o=r.searchParams.get("p")||"";if(!o||o.length>jt)return null;const n=Ii(o);return!n||n.length>jt?null:Fa(JSON.parse(n))}catch{return null}},ub=e=>{const t=e.trim();if(!t||t.length>jt)return null;const r=t.indexOf("?");if(r===-1||!/^pichamber:\/\/connect\/?$/i.test(t.slice(0,r)))return null;let o=null,n=null;for(const s of t.slice(r+1).split("&")){const i=s.indexOf("=");if(i===-1)continue;const c=s.slice(0,i),d=s.slice(i+1);c==="v"?o=d:c==="p"&&(n=d)}if(o!=="2"||!n||n.length>jt)return null;const a=Ii(n);if(!a||a.length>jt)return null;try{return Fa(JSON.parse(a))}catch{return null}},Gt=e=>typeof e=="object"&&e!==null,Nl=e=>e.trim().toLowerCase()==="authorization",Ll=e=>{if(!Gt(e))return;const t={};for(const[r,o]of Object.entries(e)){const n=r.trim(),a=typeof o=="string"?o.trim():"";!n||!a||/[\r\n:]/.test(n)||/[\r\n]/.test(a)||Nl(n)||(t[n]=a)}return Object.keys(t).length>0?t:void 0},_i=e=>`relay://${e}`,Ul=e=>{if(!Gt(e))return null;const t=Y(e,"relayUrl")||Y(e,"relay_url"),r=Y(e,"serverId")||Y(e,"server_id"),o=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!r||!Gt(o)?null:{relayUrl:t,serverId:r,hostEncPubJwk:o}},Hl=()=>{if(typeof navigator>"u")return;const e=navigator.userAgent;if(/Macintosh|Mac OS X/i.test(e))return"macos";if(/Windows/i.test(e))return"windows";if(/Linux/i.test(e))return"linux"},xi=5e3,Kl=async(e,t,r)=>{const o=Ol(e);if(!o)throw new Error("invalid-connect-link");const n=await Li().catch(()=>""),a={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({pairingId:o.pairingId,secret:o.secret,clientLabel:o.label||"PiChamber Desktop",clientKind:"desktop",deviceName:"PiChamber Desktop",devicePlatform:Hl(),...n?{dedupeKey:`desktop:${n}`}:{}})},s=async w=>{if(!w.ok)return null;const B=await w.json().catch(()=>null);return(typeof B?.clientToken=="string"?B.clientToken.trim():"")||null};let i=null;const c=[...o.candidates].sort((w,B)=>(w.type==="relay"?1:0)-(B.type==="relay"?1:0));for(const w of c){if(w.type==="relay"){const P=ra({relayUrl:w.relayUrl,serverId:w.serverId,hostEncPubJwk:w.hostEncPubJwk,...w.grant?{grant:w.grant}:{}});try{const ee=await s(await P.fetch("/api/client-auth/pairing/redeem",a));if(ee){i={relay:{relayUrl:w.relayUrl,serverId:w.serverId,hostEncPubJwk:w.hostEncPubJwk},token:ee};break}}catch{}finally{P.close()}continue}const B=X(w.url);if(B)try{const P=await s(await fetch(`${B}/api/client-auth/pairing/redeem`,a));if(P){i={directUrl:B,token:P};break}}catch{}}if(!i)throw new Error("pairing-redeem-failed");const d=o.candidates.find(w=>w.type==="relay"),l=i.relay||(d?{relayUrl:d.relayUrl,serverId:d.serverId,hostEncPubJwk:d.hostEncPubJwk}:void 0),u=o.candidates.filter(w=>w.type!=="relay").map(w=>X(w.url)).find(w=>!!w),f=i.directUrl||u,m=f||(l?_i(l.serverId):null);if(!m)throw new Error("pairing-missing-transport");let g=null;if(i.directUrl){const w=r?.healthTimeoutMs??xi,B=new AbortController,P=setTimeout(()=>B.abort(),w);try{const ee=await fetch(`${i.directUrl}/health`,{headers:{Accept:"application/json"},signal:B.signal,credentials:"omit"});if(ee.ok){const Be=await ee.json().catch(()=>null),se=typeof Be?.serverId=="string"?Be.serverId.trim():"";se&&(g=se)}}catch{}finally{clearTimeout(P)}}const h=new Set;l?.serverId&&h.add(l.serverId),g&&h.add(g);const p=w=>{for(const B of h)if(w.serverId===B||w.relay?.serverId===B)return!0;return!1},k=t.find(w=>{if(l){if(w.relay?.serverId===l.serverId)return!0}else if(!w.relay&&X(w.apiUrl||w.url)===m)return!(w.serverId&&g&&w.serverId!==g);return p(w)}),A=k?.id||(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`),C={...k||{},id:A,label:o.label||k?.label||ya(m),url:m,apiUrl:f,clientToken:i.token,...l?{relay:l}:{}};return k?.serverId?C.serverId=k.serverId:g&&(C.serverId=g),{hostId:A,hosts:k?t.map(w=>w.id===A?C:w):[C,...t]}},jl=/^(t|.*(?:token|auth|secret|api).*)$/i,X=e=>{const t=e.trim();if(!t)return null;try{const r=new URL(t);return r.protocol!=="http:"&&r.protocol!=="https:"?null:t.split("#")[0]||null}catch{return null}},$l=e=>{const t=X(e);if(!t)return null;try{const r=new URL(t);if((r.pathname.replace(/\/+$/,"")||"/")==="/connect"&&r.searchParams.has("t"))return{persistedUrl:r.origin,redeemUrl:r.toString(),kind:"tunnel-connect-link"}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:"normal-host"}},ya=e=>{const t=X(e);if(!t)return e;try{const r=new URL(t);(r.username||r.password)&&(r.username="",r.password="");const o=Array.from(new Set(Array.from(r.searchParams.keys())));for(const n of o)jl.test(n)&&r.searchParams.set(n,"[REDACTED]");return r.toString()}catch{return t}},rt=(e,t)=>{const r=X(e),o=X(t);if(!r||!o)return!1;try{const n=new URL(r),a=new URL(o);if(n.origin!==a.origin||a.search&&n.search!==a.search)return!1;const s=a.pathname.length>1?a.pathname.replace(/\/+$/,""):a.pathname,i=n.pathname.length>1?n.pathname.replace(/\/+$/,""):n.pathname;return s==="/"?!0:i===s||i.startsWith(`${s}/`)}catch{return!1}},Y=(e,t)=>{const r=e[t];return typeof r=="string"?r:null},fs=(e,t)=>{const r=e[t];return typeof r=="number"&&Number.isFinite(r)?r:null},zl=e=>{if(!Gt(e))return null;const t=Y(e,"id"),r=Y(e,"label"),o=Y(e,"url"),n=Y(e,"apiUrl")||Y(e,"api_url"),a=Y(e,"clientToken")||Y(e,"client_token"),s=Ll(e.requestHeaders),i=Ul(e.relay),c=Y(e,"serverId")||Y(e,"server_id");return!t||!r||!o?null:{id:t,label:r,url:o,...n?{apiUrl:n}:{},...a?{clientToken:a}:{},...s?{requestHeaders:s}:{},...i?{relay:i}:{},...c?.trim()?{serverId:c.trim()}:{}}},_e=e=>X(e.apiUrl||e.url)||e.apiUrl||e.url,ql=(e,t)=>{const r={...e,url:t,apiUrl:t};return X(_e(e))!==X(t)&&delete r.serverId,r},Dt=()=>Z()?(e,t)=>j(e,t):null,ba=async()=>{const e=Dt();if(!e)return{hosts:[],defaultHostId:"local",initialHostChoiceCompleted:!1};const t=await e("desktop_hosts_get");if(!Gt(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};const r=t.hosts,o=Array.isArray(r)?r.map(zl).filter(i=>!!i):[],n=Y(t,"defaultHostId")||Y(t,"default_host_id")||Y(t,"defaultHostID"),a=t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,s=Y(t,"localOrigin")||Y(t,"local_origin");return{hosts:o,defaultHostId:n,initialHostChoiceCompleted:a,localOrigin:s}},Oi=async e=>{const t=Dt();if(!t)return;const r={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(r.localClientToken=e.localClientToken),await t("desktop_hosts_set",{input:r})},Ni=async()=>{const e=Dt();if(!e)return"";const t=await e("desktop_local_client_token_get").catch(()=>null);return typeof t=="string"?t.trim():""},Li=async()=>{const e=Dt();if(!e)return"";const t=await e("desktop_install_id_get").catch(()=>null);return typeof t=="string"?t.trim():""},Gl=8e3,ms=async(e,t,r)=>{const o=new AbortController,n=window.setTimeout(()=>o.abort(),Gl);try{return await e.fetch(t,{...r,signal:o.signal})}finally{window.clearTimeout(n)}},Wl=async(e,t)=>{const r=ra({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),o=Date.now();let n=!1;try{if(!(await ms(r,"/health")).ok)return{status:"unreachable",latencyMs:0};const s=new Headers({Accept:"application/json"});for(const[d,l]of Object.entries(t?.requestHeaders||{}))d.toLowerCase()!=="authorization"&&s.set(d,l);const i=t?.clientToken?.trim();i&&s.set("Authorization",`Bearer ${i}`);const c=await ms(r,"/auth/session",{headers:s});return c.status===401||c.status===403?{status:"auth",latencyMs:Math.max(0,Date.now()-o)}:c.ok?(n=t?.keepTunnel===!0,{status:"ok",latencyMs:Math.max(0,Date.now()-o),...n?{tunnel:r}:{}}):{status:"unreachable",latencyMs:0}}catch{return{status:"unreachable",latencyMs:0}}finally{n||r.close()}},Aa=async(e,t)=>{const r=Dt();if(!r)return{status:"unreachable",latencyMs:0};const o=await r("desktop_host_probe",{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!Gt(o))return{status:"unreachable",latencyMs:0};const n=o.status,a=n==="ok"||n==="auth"||n==="update-recommended"||n==="incompatible"||n==="wrong-service"||n==="unreachable"?n:"unreachable",s=fs(o,"latencyMs")??fs(o,"latency_ms")??0,i=Y(o,"reportedServerId");return{status:a,latencyMs:s,...i?.trim()?{reportedServerId:i.trim()}:{}}},Vl=async(e,t)=>{const r=Dt();r&&await r("desktop_new_window_at_url",{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},Jl=async e=>{const t=Dt();t&&await t("desktop_new_window_for_host",{hostId:e})},fb=Object.freeze(Object.defineProperty({__proto__:null,DESKTOP_HOST_HEALTH_PIN_TIMEOUT_MS:xi,desktopHostProbe:Aa,desktopHostsGet:ba,desktopHostsSet:Oi,desktopInstallIdGet:Li,desktopLocalClientTokenGet:Ni,desktopOpenNewWindowAtUrl:Vl,desktopOpenNewWindowForHost:Jl,getDesktopHostApiUrl:_e,importDesktopHostPairing:Kl,locationMatchesHost:rt,normalizeHostUrl:X,probeRelayDesktopHost:Wl,redactSensitiveUrl:ya,relayHostDisplayUrl:_i,resolveDesktopHostUrl:$l,withEditedDesktopHostUrl:ql},Symbol.toStringTag,{value:"Module"})),ot="local",Yl=e=>({id:ot,label:"Local",url:e||Ea()}),Ea=()=>typeof window>"u"?"":window.__PICHAMBER_LOCAL_ORIGIN__||window.location.origin,wa=e=>e.id===ot?"local":`host:${e.id}`,gs="host:",Ui=e=>{const t=e.runtimeKey.trim();if(t===ot)return{kind:"local"};if(t.startsWith(gs)){const o=t.slice(gs.length),n=e.hosts.find(a=>a.id===o);if(n)return{kind:"host",host:n}}const r=e.hosts.find(o=>e.apiBaseUrl?rt(e.apiBaseUrl,_e(o)):!1);return r?{kind:"host",host:r}:e.localOrigin&&e.apiBaseUrl&&rt(e.apiBaseUrl,e.localOrigin)?{kind:"local"}:null},Xl=e=>{const t=typeof window>"u"?"":window.location.href,r=e.find(l=>l.id===ot)?.url||Ea(),o=ze(),n=X(r)||r,a=X(t)||t,s=D(),i=e.find(l=>l.relay&&wa(l)===s);if(i)return{id:i.id,label:i.label,url:i.url};if(o&&rt(o,r))return{id:ot,label:"Local",url:n};const c=e.find(l=>o?rt(o,_e(l)):!1);if(c)return{id:c.id,label:c.label,url:X(_e(c))||_e(c)};if(t&&rt(t,r))return{id:ot,label:"Local",url:n};const d=e.find(l=>t?rt(t,l.url):!1);return d?{id:d.id,label:d.label,url:X(d.url)||d.url}:t.startsWith("pichamber-ui://")?{id:ot,label:"Local",url:n}:{id:"custom",label:ya(a||"Instance"),url:a}},mb=Object.freeze(Object.defineProperty({__proto__:null,LOCAL_HOST_ID:ot,buildLocalDesktopHost:Yl,getLocalDesktopOrigin:Ea,resolveCurrentDesktopHost:Xl,resolveDesktopHostIdentity:Ui,runtimeKeyForDesktopHost:wa},Symbol.toStringTag,{value:"Module"})),Ql=5e3,Zl=1500;let Xo=!1;const eu=async e=>{if(!Ro()||Xo)return;const t=`host:${e}`;if(D()===t){Xo=!0;try{const r=await ba().catch(()=>null),o=r?.hosts.find(m=>m.id===e);if(!r||!o?.relay)return;const n=o.apiUrl?X(o.apiUrl):null;if(n&&n.startsWith("https://"))return;const a=await b("/api/client-auth/connection/candidates").catch(()=>null);if(!a?.ok)return;const s=await a.json().catch(()=>null);if(!s||s.serverId!==o.relay.serverId)return;const i=Array.isArray(s.candidates)?s.candidates:[],c=[],d=[];for(const m of i){if(!m||typeof m!="object")continue;const g=m;if(g.type!=="lan"&&g.type!=="tailscale"||typeof g.url!="string")continue;const h=X(g.url),p=g.type==="tailscale"?d:c;h&&!p.includes(h)&&p.push(h)}const l=c.length>0?c:d;if(l.length===0)return;const u=n&&l.includes(n)?n:l[0];u!==n&&await Oi({hosts:r.hosts.map(m=>m.id===e?{...m,apiUrl:u}:m),defaultHostId:r.defaultHostId,initialHostChoiceCompleted:r.initialHostChoiceCompleted}).catch(()=>{});const f=await Aa(u,{clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,expectedServerId:o.serverId??o.relay.serverId}).catch(()=>({status:"unreachable",latencyMs:0}));if(f.status==="unreachable"||f.status==="wrong-service"||f.status==="incompatible"||D()!==t)return;Kt({apiBaseUrl:u,clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,runtimeKey:t})}finally{Xo=!1}}},tu=e=>{typeof window>"u"||window.setTimeout(()=>{eu(e).catch(()=>{})},Ql)},ru=(e,t)=>{if(t){const o=e.hosts.find(n=>n.id===t);return o?{kind:"host",host:o}:null}const r=Ui({runtimeKey:D(),apiBaseUrl:ze(),hosts:e.hosts,localOrigin:e.localOrigin});if(r)return r;if(e.defaultHostId&&e.defaultHostId!=="local"){const o=e.hosts.find(n=>n.id===e.defaultHostId);if(o)return{kind:"host",host:o}}return{kind:"local"}},ou=(e,t)=>{const r=e.clientToken||"";!r||To()===r||Kt({apiBaseUrl:ze()||_e(e),clientToken:r,requestHeaders:e.requestHeaders||null,runtimeKey:t,relay:Xt()?e.relay:void 0})},nu=async e=>{if(!Ro())return;const t=await ba().catch(()=>null);if(!t)return;const r=ru(t,e);if(!r)return;if(r.kind==="local"){const u=await Ni();if(!u)return;const f=t.localOrigin||ze();if(!f||D()==="local"&&To()===u)return;Kt({apiBaseUrl:f,clientToken:u,runtimeKey:"local"});return}const o=r.host,n=wa(o),a=u=>{Kt({apiBaseUrl:u,clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,runtimeKey:n})},s=()=>{Kt({apiBaseUrl:typeof window<"u"?window.location.origin:"",clientToken:o.clientToken||null,runtimeKey:n,relay:o.relay??void 0}),tu(o.id)};if(D()===n){const u=o.apiUrl?X(_e(o)):"";if(!!(u&&rt(ze(),u))||!o.relay){ou(o,n);return}s();return}if(!o.relay){const u=_e(o);if(!u)return;a(u);return}const i=o.apiUrl?X(_e(o)):null;if(!i){s();return}const c=u=>u.status!=="unreachable"&&u.status!=="wrong-service"&&u.status!=="incompatible",d=Aa(i,{clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,expectedServerId:o.serverId??o.relay.serverId}).catch(()=>({status:"unreachable",latencyMs:0})),l=await Promise.race([d,new Promise(u=>setTimeout(()=>u(null),Zl))]);if(l){if(c(l)){a(i);return}s();return}s(),d.then(u=>{c(u)&&D()===n&&a(i)})},au=64*1024,su=(e,t,r)=>{let o=0;return new ReadableStream({async pull(n){if(t?.aborted){n.error(new DOMException("The operation was aborted.","AbortError"));return}if(o>=e.size){n.close();return}const a=Math.min(o+au,e.size),s=new Uint8Array(await e.slice(o,a).arrayBuffer());o=a,n.enqueue(s),r?.({loaded:o,total:e.size})}})},iu=(e,t)=>!Zt()||e instanceof File?e:new File([e],t.filename,{type:t.mime||e.type}),cu=async(e,t,r)=>{const o=!!xr();o||r.onProgress?.({loaded:0,total:t.size});const n={method:"POST",headers:{Accept:"application/json","Content-Type":"application/octet-stream","X-PiChamber-Filename":encodeURIComponent(r.filename),"X-PiChamber-Mime":r.mime},body:o?su(t,r.signal,r.onProgress):iu(t,r),signal:r.signal,...o?{duplex:"half"}:{}},a=await b(e,n);return!o&&a.ok&&r.onProgress?.({loaded:t.size,total:t.size}),a},It=1,du="events.streamEpoch",lu=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return Number.isSafeInteger(t.count)&&t.count>=1&&t.count<=99&&(t.kind==="input"||t.kind==="approval")&&typeof t.since=="number"&&Number.isFinite(t.since)&&t.since>0},gb="pichamber.bash",pb=64*1024,ps=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>0,Hi=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return!(t.snoozedUntil!==void 0&&(!ps(t.snoozedUntil)||!ps(t.snoozedAt)))},uu=e=>{if(!e||typeof e!="object")return!1;const t=e.sessions;return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(Hi)},fu=["session.snapshot","session.lifecycle","session.deleted","session.updated","session.tree.updated","session.input","session.bash","session.bash.output","session.bash.recorded","assistant.message.start","assistant.message.delta","assistant.message.end","assistant.thinking.delta","session.tool.start","session.tool.update","session.tool.end","session.queue","session.model","session.thinking","session.compaction","session.error","session.interrupted","session.openUrl","session.archive","session.moved","extension.entry","extension.message","extension.notify","extension.catalog","extension.editor","extension.title","extension.status","extension.control","extension.widget","extension.dialog","extension.dialog.dismiss","extension.ui","extension.app","extension.working","extension.editor.track","extension.custom","extension.custom.frame","extension.custom.dismiss","extension.error"],wn=e=>{if(!e||typeof e!="object")return!1;const t=e;return t.protocolVersion===It&&t.kind==="event"&&typeof t.name=="string"&&Number.isSafeInteger(t.sequence)&&t.sequence>=0&&typeof t.sessionId=="string"&&t.sessionId.length>0&&typeof t.directory=="string"&&t.directory.length>0&&!!(t.payload&&typeof t.payload=="object"&&!Array.isArray(t.payload))&&fu.includes(t.name)},Ki=(e,t)=>{const r=xr();return r?r.openWebSocket(bd(e),t):md(new WebSocket(e))},ji="pichamber.mobile.diagnostics.v1",Ba=300,mu=240,gu=1e3;let Wt=[],hs=!1,$t=null,Qo=!1;const Ot=e=>e==null?void 0:String(e).replace(/(?:authorization|proxy-authorization)\s*:\s*bearer\s+[^\s,;]+/gi,"authorization=[redacted]").replace(/\b(bearer|token|password|secret|api[-_]?key)\b(?:\s*[:=]\s*|\s+)[^\s,;]+/gi,"$1=[redacted]").replace(/(?:https?|wss?):\/\/[^\s"'`]+/gi,"[url]").replace(/(?:[A-Za-z]:[\\/]|\/(?:home|Users|data|storage|private|var)\/)[^\s"'`]+/g,"[path]").replace(/\s+/g," ").trim().slice(0,mu)||void 0,pu=e=>{if(!e||typeof e!="object")return{detail:Ot(e)};const t=e;return{...typeof t.code=="string"?{code:Ot(t.code)}:{},...typeof t.status=="number"&&Number.isFinite(t.status)?{status:t.status}:{},...t.message!==void 0?{detail:Ot(t.message)}:typeof t.name=="string"?{detail:Ot(t.name)}:{}}},$i=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}},Io=()=>{if(hs)return;hs=!0;const e=$i();if(e)try{const t=e.getItem(ji);if(!t)return;const r=JSON.parse(t);if(!Array.isArray(r))return;const o=[];for(const n of r){if(!n||typeof n!="object")continue;const a=n,s=typeof a.at=="string"?a.at:null,i=typeof a.category=="string"?a.category:null;if(!s||!i)continue;const c={at:s,category:i,...typeof a.code=="string"?{code:a.code}:{},...typeof a.status=="number"&&Number.isFinite(a.status)?{status:a.status}:{},...typeof a.detail=="string"?{detail:a.detail}:{}};o.push(c)}Wt=[...o,...Wt].slice(-Ba)}catch{}},hu=()=>{$t!==null&&(clearTimeout($t),$t=null)},Fu=()=>{$t===null&&($t=setTimeout(()=>{$t=null,ao()},gu))},ao=()=>{hu();const e=$i();if(e)try{Io(),e.setItem(ji,JSON.stringify(Wt.slice(-Ba)))}catch{}},G=(e,t={})=>{if(!Zt())return;Io();const r={at:new Date().toISOString(),category:e.trim().slice(0,80)||"unknown",...t.code?{code:Ot(t.code)}:{},...typeof t.status=="number"&&Number.isFinite(t.status)?{status:t.status}:{},...t.detail!==void 0?{detail:Ot(t.detail)}:{}};Wt=[...Wt,r].slice(-Ba),Fu()},yu=(e,t)=>{G(e,pu(t))},bu=()=>(Io(),JSON.stringify({format:"pichamber-mobile-diagnostics-v1",generatedAt:new Date().toISOString(),platform:typeof navigator>"u"?"unknown":navigator.userAgent,entries:Wt},null,2)),hb=async()=>{const e=bu(),{isShareCancelledError:t,saveOrShareFile:r}=await xc(async()=>{const{isShareCancelledError:n,saveOrShareFile:a}=await import("./nativeFileSave-DSMsJqXM.js");return{isShareCancelledError:n,saveOrShareFile:a}},__vite__mapDeps([0,1,2,3,4,5,6,7]));if(typeof navigator<"u"&&typeof navigator.share=="function")try{return await navigator.share({title:"PiChamber mobile diagnostics",text:e}),"shared"}catch(n){if(t(n))throw new Error("Diagnostics export was cancelled")}if(window.Capacitor?.getPlatform?.()==="android")try{return await r({filename:"pichamber-mobile-diagnostics.json",mimeType:"application/json",data:e}),"shared"}catch{}if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),"copied";if(typeof document<"u"){const n=new Blob([e],{type:"application/json"}),a=URL.createObjectURL(n),s=document.createElement("a");return s.href=a,s.download="pichamber-mobile-diagnostics.json",document.body.appendChild(s),s.click(),s.remove(),window.setTimeout(()=>URL.revokeObjectURL(a),0),"downloaded"}throw new Error("No mobile export method is available")},Fb=()=>{if(!Zt()||typeof window>"u"||Qo)return()=>{};Qo=!0,Io(),G("app-launch",{code:"start"});const e=n=>{G("window-error",{code:n.error?.name,detail:n.message})},t=n=>{yu("unhandled-rejection",n.reason)},r=()=>{ao()},o=()=>{document.visibilityState==="hidden"&&ao()};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",t),window.addEventListener("pagehide",r),document.addEventListener("visibilitychange",o),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",t),window.removeEventListener("pagehide",r),document.removeEventListener("visibilitychange",o),ao(),Qo=!1}},Au=3e4,Eu=250,wu=5e3,Bu=6e4,Cu=8,vu=2e3,ku=1e4,Du=5e3,Su=3e4,Mu=5e3,_t=new Map,Tu=8,Pu=(e,t)=>{if(!(!e||!t||t.length>128))for(_t.delete(e),_t.set(e,t);_t.size>Tu;){const r=_t.keys().next();if(r.done)break;_t.delete(r.value)}};let wr=null;const yb=e=>(wr=e,()=>{wr===e&&(wr=null)}),Ze=(e=D(),t)=>{if(t&&wr){const r=wr(e,t);if(r!==void 0)return r??void 0}return _t.get(e)},zi=e=>{const t={};return typeof e.fromSequence=="number"&&Number.isFinite(e.fromSequence)&&(t.fromSequence=String(Math.max(0,Math.floor(e.fromSequence)))),typeof e.sessionId=="string"&&e.sessionId.length>0&&(t.sessionId=e.sessionId),typeof e.streamEpoch=="string"&&e.streamEpoch.length>0&&(t.streamEpoch=e.streamEpoch),typeof e.cursor=="string"&&e.cursor.length>0&&(t.cursor=e.cursor),t.capabilities=du,t},Fs=(e,t,r)=>{const o=Ie(),n=zi(t);return e==="ws"?o.websocket("/api/pi/events",n,r):o.sse("/api/pi/events",n)},Ru=()=>"/api/pi/runtime",so=()=>Zt()&&!Xt()&&typeof EventSource<"u",Iu=3e3;let Bn=null,hr=null;const bb=()=>{Bn=null,hr=null},_u=1e4,Wr=e=>({...e,capabilities:[...e.capabilities]}),bo=async(e,t,r)=>{const o=t??D();if(!r?.fresh){const s=Bn;if(s&&s.runtimeKey===o&&s.runtimeKey===D()&&Date.now()<s.expiresAt)return Wr(s.result)}const n=!r?.fresh&&!e;if(n){const s=hr;if(s&&s.runtimeKey===o&&s.runtimeKey===D())return s.promise.then(Wr)}const a=async()=>{const s=r?.timeoutMs??_u,i=new AbortController,c=()=>i.abort(),d=setTimeout(()=>i.abort(),s);e&&(e.aborted?i.abort():e.addEventListener("abort",c,{once:!0}));try{const l=await b(Ru(),{signal:i.signal});if(o!==D())return{state:"unavailable",protocolVersion:It,capabilities:[],error:{code:"DAEMON_UNAVAILABLE",message:"Runtime changed during request"}};if(!l.ok)return G("runtime-health",{status:l.status,code:l.status===401||l.status===403?"auth":"http-error"}),{state:"unavailable",protocolVersion:It,capabilities:[],error:{code:l.status===401||l.status===403?"DAEMON_AUTH_FAILED":"DAEMON_UNAVAILABLE"}};const f=await Ai(()=>l.json(),i.signal).catch(p=>{if((p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p;return null});if(!f||typeof f!="object")return{state:"unavailable",protocolVersion:It,capabilities:[],error:{code:"DAEMON_PROTOCOL_MISMATCH"}};const m=typeof f.error?.code=="string"?f.error.code:void 0,g=typeof f.streamEpoch=="string"&&f.streamEpoch.length>0&&f.streamEpoch.length<=128?f.streamEpoch:void 0;f.state==="ready"&&g&&Pu(o,g);const h={state:f.state==="ready"?"ready":"unavailable",protocolVersion:typeof f.protocolVersion=="number"?f.protocolVersion:It,capabilities:Array.isArray(f.capabilities)?f.capabilities.filter(p=>typeof p=="string"):[],...g?{streamEpoch:g}:{},...m?{error:{code:m,...typeof f.error?.message=="string"?{message:f.error.message}:{}}}:{}};return!r?.fresh&&h.state==="ready"&&o===D()&&(Bn={runtimeKey:o,result:Wr(h),expiresAt:Date.now()+Iu}),h}catch(l){const u=(l instanceof DOMException||l instanceof Error)&&l.name==="AbortError";return G("runtime-health",{code:u?"timeout":"unreachable"}),{state:"unavailable",protocolVersion:It,capabilities:[],error:{code:u?"DAEMON_TIMEOUT":"DAEMON_UNAVAILABLE"}}}finally{clearTimeout(d),e&&e.removeEventListener("abort",c)}};if(n){const s=a().finally(()=>{hr?.promise===s&&(hr=null)});return hr={runtimeKey:o,promise:s},s.then(Wr)}return a()},xu=async(e,t,r)=>{const o=new AbortController,n=()=>o.abort(),a=setTimeout(n,t);r.aborted?o.abort():r.addEventListener("abort",n,{once:!0});try{const s=await bo(o.signal,e,{fresh:!0});return s.state==="unavailable"&&s.error?.code==="DAEMON_AUTH_FAILED"?"auth":"transient"}catch{return"transient"}finally{clearTimeout(a),r.removeEventListener("abort",n)}},Ou=(e,t,r,o,n,a,s)=>{if(so()){const f=new EventSource(Ie().sse("/api/pi/events",e)),m=new AbortController;let g=!1,h=!1,p=setTimeout(()=>{p=null,!(h||g)&&(G("stream-connect",{code:"setup-timeout"}),C(),a("sse-setup-timeout"))},s.setupTimeoutMs);const k=()=>{p&&clearTimeout(p),p=null},A=()=>{g||o()},C=()=>{k(),m.abort(),!g&&(g=!0,f.removeEventListener("heartbeat",A),f.close(),t.removeEventListener("abort",C))},w=B=>{try{const P=JSON.parse(B);wn(P)&&n(P)}catch{G("stream-frame",{code:"bad-sse-frame"})}};return f.onopen=()=>{g||(h=!0,k(),r())},f.onmessage=B=>{g||(o(),typeof B.data=="string"&&B.data.trim()&&w(B.data))},f.onerror=()=>{if(g)return;k(),f.removeEventListener("heartbeat",A),f.close(),t.removeEventListener("abort",C),g=!0,G("stream-disconnect",{code:"sse-error"});const B=s.classifySourceError;if(!B){a("sse-error");return}B(m.signal).then(P=>{m.signal.aborted||a(P==="auth"?"sse-auth-probe":"sse-error")})},f.addEventListener("heartbeat",A),t.aborted?C():t.addEventListener("abort",C,{once:!0}),C}const i=new AbortController,c=()=>i.abort();t.aborted?i.abort():t.addEventListener("abort",c,{once:!0});let d=!1,l=setTimeout(()=>{l=null,!(d||i.signal.aborted)&&(G("stream-connect",{code:"setup-timeout"}),a("sse-setup-timeout"),c())},s.setupTimeoutMs);const u=()=>{l&&clearTimeout(l),l=null};return b("/api/pi/events",{headers:{Accept:"text/event-stream"},query:e,signal:i.signal}).then(async f=>{if(!f.ok||!f.body){if(G("stream-connect",{status:f.status,code:f.body?"http-error":"missing-stream-body"}),f.status===401||f.status===403){u(),a(`sse-auth-${f.status}`);return}a(`sse-status-${f.status}`);return}d=!0,u(),r();const m=f.body.getReader(),g=new TextDecoder;let h="",p=[];const k=()=>{if(p.length===0)return;const A=p.join(`
3
- `).trim();if(p=[],!!A)try{const C=JSON.parse(A);wn(C)&&n(C)}catch{}};for(;;){const{value:A,done:C}=await m.read();if(C){k(),u(),a("sse-eof");return}o(),h+=g.decode(A,{stream:!0});let w=h.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/nativeFileSave-D542OJlG.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js"])))=>i.map(i=>d[i]);
2
+ import{c as xr,d as Or,p as aa}from"./vendor-zustand-CXhN0IMY.js";import{_ as qc}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as Wc}from"./vendor-clsx-B-dksMZM.js";import{t as Gc}from"./vendor-tailwind-merge-BKkUfl9q.js";import{e as ri}from"./vendor-fuse.js-t_7AcMTv.js";import{R as Xa}from"./vendor-react-Bz1tRBxM.js";const br=1,Vc="pichamber-relay-v1",oi=1,ni=12,Ar=1+ni,Dr=64*1024,Sr=5,go=128,ai=0,si=1,Wt=4,Jc=1+Wt,gn=Dr-Sr-Jc,O={HttpRequest:1,HttpBody:2,HttpResponse:3,StreamEnd:4,StreamAbort:5,WsOpen:6,WsOpened:7,WsText:8,WsBinary:9,WsClose:10,Ping:11,Pong:12},Yc=new Set(Object.values(O)),Xc=e=>Yc.has(e),wt={DuplicateClient:4002,AuthFailed:4010,LimitExceeded:4029,ChannelFailure:1011},je=globalThis.crypto.subtle,ii={name:"ECDH",namedCurve:"P-256"},ci=16,zo=32,Qc=16,pn=4,di=8;class tt extends Error{constructor(t){super(t),this.name="RelayCryptoError"}}const Zc=()=>je.generateKey(ii,!0,["deriveBits"]),ed=async e=>{const t=await je.exportKey("jwk",e);return{kty:t.kty,crv:t.crv,x:t.x,y:t.y}},td=async e=>{if(e.kty!=="EC"||e.crv!=="P-256"||typeof e.x!="string"||typeof e.y!="string")throw new tt("invalid ECDH public key JWK");try{return await je.importKey("jwk",{kty:e.kty,crv:e.crv,x:e.x,y:e.y,ext:!0},ii,!0,[])}catch{throw new tt("invalid ECDH public key JWK")}},rd=()=>{const e=new Uint8Array(ci);return globalThis.crypto.getRandomValues(e),e},od=async(e,t,r)=>{if(r.length!==ci)throw new tt("invalid handshake nonce length");const o=await je.deriveBits({name:"ECDH",public:t},e,256),n=await je.importKey("raw",o,"HKDF",!1,["deriveBits"]),a=new Uint8Array(await je.deriveBits({name:"HKDF",hash:"SHA-256",salt:r,info:new TextEncoder().encode(Vc)},n,zo*2*8)),s=(i,c)=>je.importKey("raw",i,{name:"AES-GCM"},!1,c);return{clientToHost:await s(a.slice(0,zo),["encrypt","decrypt"]),hostToClient:await s(a.slice(zo),["encrypt","decrypt"])}},nd=(e,t,r)=>{for(let o=di-1;o>=0;o-=1)e[t+o]=Number(r&0xffn),r>>=8n},ad=(e,t)=>{let r=0n;for(let o=0;o<di;o+=1)r=r<<8n|BigInt(e[t+o]);return r},sd=e=>{const t=new Uint8Array(pn);globalThis.crypto.getRandomValues(t);let r=0n;return{async encrypt(o){if(o.length>Dr)throw new tt("plaintext frame exceeds maximum size");r+=1n;const n=new Uint8Array(ni);n.set(t,0),nd(n,pn,r);const a=new Uint8Array(await je.encrypt({name:"AES-GCM",iv:n},e,o)),s=new Uint8Array(Ar+a.length);return s[0]=oi,s.set(n,1),s.set(a,Ar),s}}},id=e=>{let t=0n;return{async decrypt(r){if(r.length<Ar+Qc)throw new tt("encrypted frame too short");if(r[0]!==oi)throw new tt("unsupported encrypted frame version");const o=r.slice(1,Ar),n=ad(o,pn);if(n<=t)throw new tt("frame counter regression");let a;try{a=await je.decrypt({name:"AES-GCM",iv:o},e,r.slice(Ar))}catch{throw new tt("frame decryption failed")}return t=n,new Uint8Array(a)}}},Wr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",cd=e=>{let t="";for(let r=0;r<e.length;r+=3){const o=e[r],n=r+1<e.length?e[r+1]:void 0,a=r+2<e.length?e[r+2]:void 0;t+=Wr[o>>2],t+=Wr[(o&3)<<4|(n??0)>>4],n!==void 0&&(t+=Wr[(n&15)<<2|(a??0)>>6]),a!==void 0&&(t+=Wr[a&63])}return t},Qa=e=>{let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null)return null;const r=t;if(r.v!==br)return null;const o=r.batch===!0;return r.t==="ready"?{t:"ready",v:br,batch:o}:r.t==="hello"&&typeof r.nonce=="string"&&typeof r.clientPubJwk=="object"&&r.clientPubJwk!==null?{t:"hello",v:br,clientPubJwk:r.clientPubJwk,nonce:r.nonce,batch:o}:null},dd=e=>({type:"fail",closeCode:wt.ChannelFailure,reason:e}),ld=async(e,t={})=>{const r=t.batch!==!1,o=await td(e),n=await Zc(),a=rd(),s={t:"hello",v:br,clientPubJwk:await ed(n.publicKey),nonce:cd(a),...r?{batch:!0}:{}};let i=!1;return{helloText:JSON.stringify(s),get established(){return i},async handleText(c){if(i)return Qa(c)?.t==="ready"?{type:"ignore"}:dd("plaintext frame on established channel");const d=Qa(c);if(d?.t!=="ready")return{type:"ignore"};const l=await od(n.privateKey,o,a);return i=!0,{type:"established",batch:r&&d.batch===!0,channel:{encryptor:sd(l.clientToHost),decryptor:id(l.hostToClient)}}}}},li=4294967295;class ne extends Error{constructor(t){super(t),this.name="TunnelCodecError"}}const Pe=(e,t,r,o=!1)=>{if(!Number.isInteger(t)||t<0||t>li)throw new ne("invalid stream id");if(r.length>gn)throw new ne("tunnel payload exceeds maximum size");const n=new Uint8Array(Sr+r.length);return n[0]=o?e|go:e,n[1]=t>>>24&255,n[2]=t>>>16&255,n[3]=t>>>8&255,n[4]=t&255,n.set(r,Sr),n},ud=e=>{if(e.length<Sr)throw new ne("tunnel frame too short");const t=e[0],r=(t&go)!==0,o=t&~go;if(!Xc(o))throw new ne(`unknown tunnel frame type ${o}`);const n=(e[1]<<24|e[2]<<16|e[3]<<8|e[4])>>>0;return{frameType:o,streamId:n,payload:e.slice(Sr),hasMoreFragments:r}},fd=new TextEncoder,md=new TextDecoder,po=e=>fd.encode(JSON.stringify(e)),ho=(e,t)=>{let r;try{r=JSON.parse(md.decode(e))}catch{throw new ne("malformed JSON tunnel payload")}if(!t(r))throw new ne("unexpected JSON tunnel payload shape");return r},ui=(e,t=gn)=>{if(t<=0||t>gn)throw new ne("invalid chunk size");if(e.length===0)return[new Uint8Array(0)];const r=[];for(let o=0;o<e.length;o+=t)r.push(e.slice(o,o+t));return r},Za=(e,t,r)=>{const o=ui(r);return o.map((n,a)=>Pe(e,t,n,a<o.length-1))},gd=(e=16*1024*1024)=>{const t=new Map;return{push(r){const o=`${r.streamId}:${r.frameType}`,n=t.get(o);if(!r.hasMoreFragments&&!n)return r.payload;const a=n?.chunks??[],s=(n?.totalBytes??0)+r.payload.length;if(s>e)throw t.delete(o),new ne("fragmented message exceeds maximum size");if(a.push(r.payload),r.hasMoreFragments)return t.set(o,{chunks:a,totalBytes:s}),null;t.delete(o);const i=new Uint8Array(s);let c=0;for(const d of a)i.set(d,c),c+=d.length;return i},dropStream(r){for(const o of t.keys())o.startsWith(`${r}:`)&&t.delete(o)}}},pd=e=>{if(e.length===0)throw new ne("cannot encode an empty frame batch");if(e.length===1){const n=e[0],a=new Uint8Array(1+n.length);if(a[0]=ai,a.set(n,1),a.length>Dr)throw new ne("frame batch exceeds maximum plaintext size");return a}let t=1;for(const n of e)t+=Wt+n.length;if(t>Dr)throw new ne("frame batch exceeds maximum plaintext size");const r=new Uint8Array(t);r[0]=si;let o=1;for(const n of e)r[o]=n.length>>>24&255,r[o+1]=n.length>>>16&255,r[o+2]=n.length>>>8&255,r[o+3]=n.length&255,o+=Wt,r.set(n,o),o+=n.length;return r},hd=e=>{if(e.length<1)throw new ne("empty batch plaintext");const t=e[0];if(t===ai)return[e.slice(1)];if(t!==si)throw new ne(`unknown batch container tag ${t}`);const r=[];let o=1;for(;o<e.length;){if(o+Wt>e.length)throw new ne("truncated batch frame length");const n=(e[o]<<24|e[o+1]<<16|e[o+2]<<8|e[o+3])>>>0;if(o+=Wt,o+n>e.length)throw new ne("truncated batch frame body");r.push(e.slice(o,o+n)),o+=n}if(r.length===0)throw new ne("empty frame batch");return r},Fd=new Set([O.HttpBody,O.WsText,O.WsBinary]),fi=150,yd=24*1024,bd=32,Ad=e=>{const t=e.windowMs??fi,r=e.maxBatchBytes??yd,o=e.maxBatchFrames??bd,n=e.now??(()=>Date.now()),a=e.setTimer??((h,p)=>setTimeout(h,p)),s=e.clearTimer??(h=>clearTimeout(h));let i=[],c=0,d=null,l=0,u=!1;const f=()=>{d!==null&&(s(d),d=null)},m=()=>{if(f(),i.length===0)return;const h=i;i=[],c=0,l=n(),e.sendBatch(pd(h))};return{enqueue:h=>{if(u)return;const p=h[0]&~go;if(!Fd.has(p)){i.push(h),m();return}const k=n();if(i.length===0&&k-l>=t){i.push(h),m();return}const A=Wt+h.length;if(i.length>0&&1+c+A>Dr&&m(),i.push(h),c+=A,c>=r||i.length>=o){m();return}d===null&&(d=a(m,t))},flush:m,dispose(){u=!0,f(),i=[],c=0}}},Ed=()=>{let e=1;return{next(){if(e>li)throw new ne("stream id space exhausted");const t=e;return e+=2,t}}},wd=e=>{e.binaryType="arraybuffer";const t={get readyState(){return e.readyState},send(r){e.send(r)},close(r,o){e.close(r,o)},onopen:null,onmessage:null,onclose:null,onerror:null};return e.onopen=()=>t.onopen?.(),e.onmessage=r=>t.onmessage?.({data:r.data}),e.onclose=r=>t.onclose?.({code:r.code,reason:r.reason}),e.onerror=()=>t.onerror?.(),t},Bd=e=>{const t={get readyState(){return e.readyState},get binaryType(){return e.binaryType},set binaryType(r){r&&(e.binaryType=r)},onopen:null,onmessage:null,onerror:null,onclose:null,send(r){e.send(r)},close(r,o){e.close(r,o)}};return e.onopen=()=>t.onopen?.(),e.onmessage=r=>{const o=r.data;(typeof o=="string"||o instanceof ArrayBuffer)&&t.onmessage?.({data:o})},e.onerror=()=>t.onerror?.(),e.onclose=r=>t.onclose?.({code:r.code,reason:r.reason}),t},es=0,qo=1,ts=2,rs=3,Cd=new Set([wt.AuthFailed,wt.DuplicateClient,wt.LimitExceeded]),vd={[wt.AuthFailed]:"relay authentication failed",[wt.DuplicateClient]:"relay connection replaced by another client",[wt.LimitExceeded]:"relay connection limit reached"},Po=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),kd=e=>Po(e)&&Object.values(e).every(t=>typeof t=="string"),Dd=e=>Po(e)&&typeof e.status=="number"&&kd(e.headers),mi=e=>Po(e)&&typeof e.reason=="string",Sd=e=>Po(e)&&typeof e.code=="number"&&typeof e.reason=="string",gi=/^[a-z][a-z\d+.-]*:\/\//i,sa="http://tunnel.invalid",Md=e=>{try{const t=gi.test(e)?new URL(e):new URL(e,sa);return`${t.pathname}${t.search}`}catch{return e}},Gr=e=>({async*[Symbol.asyncIterator](){yield e}}),Td=e=>({async*[Symbol.asyncIterator](){const t=e.getReader();try{for(;;){const{done:r,value:o}=await t.read();if(r)return;o&&(yield o)}}finally{t.releaseLock()}}}),Pd=e=>{const t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t},Rd=async e=>{if(e==null)return{body:null};if(e instanceof ReadableStream)return{body:Td(e)};if(typeof e=="string")return{body:Gr(new TextEncoder().encode(e))};if(e instanceof ArrayBuffer)return{body:Gr(new Uint8Array(e.slice(0)))};if(ArrayBuffer.isView(e))return{body:Gr(Pd(e))};const t=new Response(e),r=t.headers.get("content-type")??void 0,o=new Uint8Array(await t.arrayBuffer());return{body:Gr(o),contentType:r}},Id=async(e,t)=>{let r;const o=new Headers;let n="GET",a=null,s;e instanceof Request?(r=e.url,n=e.method,e.headers.forEach((u,f)=>o.set(f,u)),s=e.signal,a=e.body):r=e.toString(),t&&(t.method&&(n=t.method),t.headers&&new Headers(t.headers).forEach((u,f)=>o.set(f,u)),t.body!==void 0&&(a=t.body),t.signal&&(s=t.signal));const i=gi.test(r)?new URL(r):new URL(r,sa),{body:c,contentType:d}=await Rd(a);d&&!o.has("content-type")&&o.set("content-type",d);const l={};return o.forEach((u,f)=>{l[f]=u}),{method:n.toUpperCase(),path:i.pathname,query:i.search.startsWith("?")?i.search.slice(1):i.search,headers:l,body:c,signal:s}},_d="__pichamberAmbiguousTransport",xd=e=>(Object.defineProperty(e,_d,{value:!0,enumerable:!1,configurable:!0}),e),Od=new Uint8Array(0),Nd=new TextEncoder,Ld=new TextDecoder,hn=e=>e instanceof Error?e:new Error(String(e)),os=()=>new DOMException("The operation was aborted.","AbortError"),Ud=async(e,t,r)=>{const o=await Id(t,r),n=o.signal;if(n?.aborted)throw os();const a=await e(n),s=a.nextStreamId();return await new Promise((i,c)=>{let d=!1,l=!1,u=null,f=null;const m=()=>{a.streams.delete(s),a.assembler.dropStream(s),f&&n&&n.removeEventListener("abort",f)},g=A=>{if(!l){if(l=!0,m(),!d){c(A);return}try{u?.error(A)}catch{}}},h=A=>{a.dead||a.send(Pe(O.StreamAbort,s,po({reason:A})))},p=A=>xd(new Error(A));f=()=>{h("aborted"),g(os())},a.streams.set(s,{handleFrame(A,C){if(A===O.HttpResponse){if(d||l)return;let w;try{w=ho(C,Dd)}catch(ee){h("malformed response head"),g(p(hn(ee).message));return}const B=w.status===204||w.status===205||w.status===304;let P=null;B||(P=new ReadableStream({start(ee){u=ee},cancel(){l||(l=!0,m(),h("response body cancelled"))}})),d=!0,i(new Response(P,{status:w.status,headers:w.headers})),B&&(l=!0,m());return}if(A===O.HttpBody){if(!d||l)return;try{u?.enqueue(C)}catch{}return}if(A===O.StreamEnd){if(l)return;if(!d){g(p("tunnel stream ended before response head"));return}l=!0,m();try{u?.close()}catch{}return}if(A===O.StreamAbort){let w="stream aborted by host";try{w=ho(C,mi).reason}catch{}g(p(w))}},fail(A){g(p(A.message))}}),n&&n.addEventListener("abort",f,{once:!0});const k={method:o.method,path:o.path,query:o.query,headers:o.headers};a.send(Pe(O.HttpRequest,s,po(k))),(async()=>{try{if(o.body)for await(const A of o.body){if(l||a.dead)return;for(const C of ui(A))a.send(Pe(O.HttpBody,s,C))}!l&&!a.dead&&a.send(Pe(O.StreamEnd,s,Od))}catch(A){h("request body failed"),g(p(hn(A).message))}})()})},Hd=e=>{const t=e.indexOf("?");return t===-1?{path:e,query:""}:{path:e.slice(0,t),query:e.slice(t+1)}},Kd=(e,t,r)=>{let o=es,n=null,a=0,s=!1;const i={get readyState(){return o},onopen:null,onmessage:null,onerror:null,onclose:null,send(d){if(o!==qo||!n||n.dead)throw new Error("relay tunnel socket is not open");if(typeof d=="string"){for(const u of Za(O.WsText,a,Nd.encode(d)))n.send(u);return}const l=d instanceof ArrayBuffer?new Uint8Array(d.slice(0)):(()=>{const u=new Uint8Array(d.byteLength);return u.set(new Uint8Array(d.buffer,d.byteOffset,d.byteLength)),u})();for(const u of Za(O.WsBinary,a,l))n.send(u)},close(d=1e3,l=""){o===rs||o===ts||(o===qo&&n&&!n.dead&&(o=ts,n.send(Pe(O.WsClose,a,po({code:d,reason:l})))),c(d,l))}},c=(d,l,u=!1)=>{if(!s){if(s=!0,n&&(n.streams.delete(a),n.assembler.dropStream(a)),o=rs,u)try{i.onerror?.()}catch{}try{i.onclose?.({code:d,reason:l})}catch{}}};return(async()=>{let d;try{d=await e()}catch(m){c(1006,hn(m).message,!0);return}if(s)return;n=d,a=d.nextStreamId(),d.streams.set(a,{handleFrame(m,g){if(m===O.WsOpened){if(o===es){o=qo;try{i.onopen?.()}catch{}}return}if(m===O.WsText){try{i.onmessage?.({data:Ld.decode(g)})}catch{}return}if(m===O.WsBinary){const h=new ArrayBuffer(g.byteLength);new Uint8Array(h).set(g);try{i.onmessage?.({data:h})}catch{}return}if(m===O.WsClose){let h=1e3,p="";try{const k=ho(g,Sd);h=k.code,p=k.reason}catch{}c(h,p);return}if(m===O.StreamAbort){let h="stream aborted";try{h=ho(g,mi).reason}catch{}c(1006,h,!0)}},fail(m){c(1012,m.message,!0)}});const{path:l,query:u}=Hd(t),f=r&&r.length>0?{path:l,query:u,protocols:r}:{path:l,query:u};d.send(Pe(O.WsOpen,a,po(f)))})(),i},Wo=new Uint8Array(0),Le=e=>e instanceof Error?e:new Error(String(e)),ns=()=>new DOMException("The operation was aborted.","AbortError"),as=()=>{const e=typeof navigator<"u"&&navigator.onLine===!1,t=typeof document<"u"&&document.visibilityState==="hidden";return e||t},ia=e=>{const t=e.helloRetryMs??1e3,r=e.helloTimeoutMs??3e4,o=e.pingIntervalMs??3e4,n=e.pingTimeoutMs??15e3,a=e.resumeProbeTimeoutMs??5e3,s=e.batchWindowMs??fi,i=e.batch!==!1,c=e.reconnectBaseDelayMs??1e3,d=e.reconnectMaxDelayMs??3e4,l=e.hiddenOrOfflineMaxDelayMs??6e4,u=e.createWireSocket??(v=>wd(new WebSocket(v)));let f=!1,m={state:"idle"};const g=new Set;let h=null,p=null,k=null,A=null,C=0,w=0,B=null,P=[];const ee=v=>{if(!(m.state===v.state&&m.lastError===v.lastError)){m=v;for(const U of g)try{U(m)}catch{}}},Be=v=>{const U=P;P=[];for(const N of U)N.reject(v)},se=v=>{const U=P;P=[];for(const N of U)N.resolve(v)},We=(v,U)=>{v.dead=!0;const N=Array.from(v.streams.values());v.streams.clear();for(const $ of N)try{$.fail(U)}catch{}},Ce=()=>{B!==null&&(clearTimeout(B),B=null)},te=()=>{if(!(f||as())){if(B!==null){Ce(),Oe();return}m.state==="connecting"||m.state==="reconnecting"||h&&!h.dead&&A?.()}},Tt=()=>{typeof document<"u"&&document.addEventListener("visibilitychange",te),typeof window<"u"&&(window.addEventListener("online",te),window.addEventListener("pichamber:system-resume",te))},or=()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",te),typeof window<"u"&&(window.removeEventListener("online",te),window.removeEventListener("pichamber:system-resume",te))},qr=()=>{if(f||B!==null)return;const v=c*Math.pow(1.5,Math.min(w,8)),U=Math.random()*.3*v,N=Math.min(d,Math.round(v+U)),$=as()?Math.max(N,l):N;B=setTimeout(()=>{B=null,Oe()},$)},nr=()=>{const v=new URL(e.relayUrl);return v.searchParams.set("v",String(br)),v.searchParams.set("role","client"),v.searchParams.set("serverId",e.serverId),e.grant&&v.searchParams.set("grant",e.grant),v.toString()},Oe=async()=>{if(f)return;const v=++C;Ce(),k?.(),k=null,ee({state:w===0?"connecting":"reconnecting"});let U;try{U=await ld(e.hostEncPubJwk,{batch:i})}catch(I){ir(v,Le(I),!0);return}if(f||v!==C)return;let N;try{N=u(nr())}catch(I){ir(v,Le(I));return}p=N;let $=null,G=null,de=null,ae=null,dt=!1,Pt=null,Fe=!1,le=null,Ge=null,lt=Date.now(),ut=!1,E=Promise.resolve();const R=()=>{A===z&&(A=null),dt=!1,$!==null&&(clearInterval($),$=null),G!==null&&(clearTimeout(G),G=null),de!==null&&(clearInterval(de),de=null),ae!==null&&(clearTimeout(ae),ae=null),Pt?.dispose(),Pt=null};k=R;const T=(I,J={})=>{const{terminal:V=!1,asErrorState:q=!1}=J;if(!(Fe||v!==C)){Fe=!0,R(),k===R&&(k=null),le&&We(le,I),h===le&&(h=null);try{N.close()}catch{}if(p===N&&(p=null),V){f=!0,Be(I),ee({state:"error",lastError:I.message});return}ir(v,I,q)}},z=()=>{Fe||v!==C||!le||le.dead||dt||(dt=!0,lt=Date.now(),ae!==null&&(clearTimeout(ae),ae=null),le.send(Pe(O.Ping,0,Wo)),ae=setTimeout(()=>{ae=null,T(new Error("relay resume probe timeout"))},a))},ue=()=>{if(N.readyState===1)try{N.send(U.helloText)}catch(I){T(Le(I))}},ve=(I,J)=>{Ge=I,ut=J,$!==null&&(clearInterval($),$=null),G!==null&&(clearTimeout(G),G=null),w=0;const V=new Map,q=Ed(),ft=gd();let me=Promise.resolve();const Ne=dr=>{me=me.then(async()=>{if(cr.dead)return;const zc=await I.encryptor.encrypt(dr);N.send(zc)}).catch(()=>{})},mt=J?Ad({windowMs:s,sendBatch:Ne}):null;Pt=mt;const cr={streams:V,assembler:ft,nextStreamId:()=>q.next(),send:dr=>{if(lt=Date.now(),mt){mt.enqueue(dr);return}Ne(dr)},dead:!1};le=cr,h=cr,A=z,ee({state:"connected"}),se(cr),de=setInterval(()=>{Date.now()-lt<o||(cr.send(Pe(O.Ping,0,Wo)),ae===null&&(ae=setTimeout(()=>{ae=null,T(new Error("relay keepalive timeout"))},n)))},o)},sr=(I,J)=>{let V;try{V=ud(J)}catch(me){T(Le(me));return}if(ae!==null&&(clearTimeout(ae),ae=null),dt=!1,V.frameType===O.Ping){I.send(Pe(O.Pong,V.streamId,Wo));return}if(V.frameType===O.Pong)return;lt=Date.now();let q=V.payload;if(V.frameType===O.WsText||V.frameType===O.WsBinary){let me;try{me=I.assembler.push(V)}catch(Ne){T(Le(Ne));return}if(me===null)return;q=me}else if(V.hasMoreFragments){T(new Error("unexpected fragmented tunnel frame"));return}const ft=I.streams.get(V.streamId);ft&&ft.handleFrame(V.frameType,q)};N.onopen=()=>{Fe||v!==C||(ue(),$=setInterval(ue,t))},N.onmessage=I=>{if(Fe||v!==C)return;const J=I.data;if(typeof J=="string"){E=E.then(async()=>{if(Fe||v!==C)return;const q=await U.handleText(J);if(q.type==="established"){if(Ge)return;ve(q.channel,q.batch)}else q.type==="fail"&&T(new Error(`relay handshake failed: ${q.reason}`))}).catch(q=>{T(Le(q))});return}const V=J instanceof ArrayBuffer?new Uint8Array(J):J instanceof Uint8Array?J:null;V&&(E=E.then(async()=>{if(Fe||v!==C)return;const q=le,ft=Ge;if(!q||!ft){T(new Error("encrypted frame before handshake completed"));return}let me;try{me=await ft.decryptor.decrypt(V)}catch(Ne){T(Le(Ne));return}if(ut){let Ne;try{Ne=hd(me)}catch(mt){T(Le(mt));return}for(const mt of Ne){if(Fe||v!==C||q.dead)return;sr(q,mt)}return}sr(q,me)}).catch(q=>{T(Le(q))}))},N.onclose=I=>{const J=Cd.has(I.code);T(new Error(vd[I.code]??`relay socket closed (code ${I.code})`),{terminal:J,asErrorState:J})},N.onerror=()=>{},G=setTimeout(()=>{G=null,T(new Error("relay handshake timeout"),{asErrorState:!0})},r);function ir(I,J,V=!1){I!==C||f||(Be(J),w+=1,ee({state:V?"error":"reconnecting",lastError:J.message}),qr())}},ar=v=>f?Promise.reject(new Error("relay tunnel closed")):v?.aborted?Promise.reject(ns()):h&&!h.dead?Promise.resolve(h):new Promise((U,N)=>{let $=null;const G={resolve(de){$&&v&&v.removeEventListener("abort",$),U(de)},reject(de){$&&v&&v.removeEventListener("abort",$),N(de)}};v&&($=()=>{P=P.filter(de=>de!==G),N(ns())},v.addEventListener("abort",$,{once:!0})),P.push(G)}),$o=()=>{if(f)return;f=!0,C+=1,Ce(),or(),k?.(),k=null;const v=h;h=null;const U=new Error("relay tunnel closed");v&&We(v,U),Be(U);try{p?.close()}catch{}p=null,ee({state:"idle"})};return Tt(),Oe(),{fetch:(v,U)=>Ud(ar,v,U),openWebSocket:(v,U)=>Kd(()=>ar(),v,U),getStatus:()=>m,subscribeStatus(v){return g.add(v),()=>{g.delete(v)}},close:$o}};let pe=null,Er=null;const jd=(e,t)=>e.relayUrl===t.relayUrl&&e.serverId===t.serverId&&e.grant===t.grant&&JSON.stringify(e.hostEncPubJwk)===JSON.stringify(t.hostEncPubJwk),Nr=()=>pe,Qt=()=>pe!==null,Fn=new Set,Ky=e=>(Fn.add(e),()=>{Fn.delete(e)}),ca=e=>{if(e!==Qt())for(const t of[...Fn])t()},$d=e=>{if(pe&&Er&&jd(Er,e))return pe;const t=Qt();return pe?.close(),Er=e,pe=ia(e),ca(t),pe},jy=(e,t)=>{if(pe===t)return;const r=Qt();pe?.close(),Er=e,pe=t,ca(r)},zd=()=>{const e=Qt();pe?.close(),pe=null,Er=null,ca(e)};let pi=()=>null,hi="",Fo={},at="",Mr=0,Ft=null,Kt="",Tr=0,Ct="",yt=null,Qe="",no=0,ao=0;const da=1e4,qd=e=>e.toLowerCase()==="authorization",Fi=e=>{const t={};for(const[r,o]of Object.entries(e||{})){const n=r.trim(),a=o.trim();n&&a&&!qd(n)&&(t[n]=a)}return t},Wd=(e,t)=>{const r=Object.entries(e);return r.length!==Object.keys(t).length?!1:r.every(([o,n])=>t[o]===n)},Lr=e=>typeof e!="string"?"":e.trim(),Gd=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_CLIENT_TOKEN__;return Lr(e)},Vd=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_API_BASE_URL__;return typeof e=="string"?e.trim():""},yi=(e,t)=>{const r=typeof e=="string"&&e.trim()?e.trim():Vd();if(!r)return t;try{return new URL(t,`${r.replace(/\/+$/,"")}/`).toString()}catch{return t}},la=e=>{try{return new URL(e).origin}catch{return""}},bi=()=>{Kt="",Tr=0,Ct="",yt=null,Qe="",no+=1},Ur=e=>{e!==void 0&&Lr(e)!==at||(at="",Mr=0,bi())},Ai=()=>{ao+=1,Ft=null,Ur(),fa()},Ei=e=>{const t=Lr(e);hi=t,Ai(),pi=()=>t?{type:"bearer",token:t}:null},wi=e=>{const t=Fi(e);Wd(Fo,t)||(Fo=t,Ai())},ua=()=>{if(Object.keys(Fo).length>0)return Fo;if(typeof window>"u")return{};const e=window.__PICHAMBER_RUNTIME_HEADERS__;return e&&typeof e=="object"?Fi(e):{}},Ro=()=>hi||Gd(),Jd=(e,t)=>{const r=Lr(e);if(!r||typeof t!="number"||!Number.isFinite(t)){Ur();return}const o=at;at=r,Mr=t,o&&o!==r&&tl()},Bi=()=>!at||Mr<=Date.now()+da?(Ur(),""):at,Yd=e=>{const t=la(e);return!t||Ct!==t?"":!Kt||Tr<=Date.now()+da?(Kt="",Tr=0,Ct="",""):Kt},Xd=()=>{const e=Bi();return!e&&(Ro()||typeof window<"u")&&Hr().catch(()=>{}),e},Ci=async()=>{const e=await pi(),t=e?.type==="bearer"?Lr(e.token):Ro();return t?{type:"bearer",token:t}:null},vi=e=>{if(Ft)return Ft;const t=ao,o=(async()=>{const n=await Ci(),a=new Headers;for(const[u,f]of Object.entries(ua()))a.set(u,f);n?.type==="bearer"&&a.set("Authorization",`Bearer ${n.token}`);const s=Nr(),i=s?await s.fetch("/auth/url-token",{method:"POST",headers:a}):await fetch(yi(e,"/auth/url-token"),{method:"POST",headers:a,credentials:"include"});if(!i.ok)throw t===ao&&Ur(),new Error(`Failed to mint runtime URL auth token (${i.status})`);const c=await i.json().catch(()=>null),d=typeof c?.token=="string"?c.token.trim():"",l=typeof c?.expiresAt=="number"?c.expiresAt:0;if(t!==ao)throw new Error("Runtime URL auth token response is stale");if(Jd(d,l),!at)throw new Error("Runtime URL auth token response was invalid");return at})().finally(()=>{Ft===o&&(Ft=null)});return Ft=o,Ft},Qd=e=>{const t=la(e);if(!t)return Promise.reject(new Error("Local runtime URL auth origin was invalid"));if(yt&&Qe===t)return yt;const r=no,n=(async()=>{const a=await fetch(yi(t,"/auth/url-token"),{method:"POST",credentials:"include"});if(!a.ok)throw r===no&&t===Qe&&(Kt="",Tr=0,Ct=""),new Error(`Failed to mint local runtime URL auth token (${a.status})`);const s=await a.json().catch(()=>null),i=typeof s?.token=="string"?s.token.trim():"",c=typeof s?.expiresAt=="number"?s.expiresAt:0;if(!i||!Number.isFinite(c))throw new Error("Local runtime URL auth token response was invalid");if(r!==no||t!==Qe)throw new Error("Local runtime URL auth token response is stale");return Kt=i,Tr=c,Ct=t,i})().finally(()=>{yt===n&&(yt=null,Qe="")});return yt=n,Qe=t,yt},Hr=async e=>{const t=Bi();return t||vi(e)},Zd=async e=>{const t=la(e);if(!t)throw new Error("Local runtime URL auth origin was invalid");const r=Yd(t);return r||((Ct&&Ct!==t||Qe&&Qe!==t)&&bi(),Qd(t))};let Ot=0,wr=null,ki=null;const yn=new Set,el=5e3,tl=()=>{for(const e of yn)try{e()}catch{}},Di=()=>{wr!==null&&(clearTimeout(wr),wr=null)},fa=()=>{if(Di(),Ot<=0||typeof window>"u")return;const e=Mr-da-el,t=Mr>0?Math.max(0,e-Date.now()):0;wr=setTimeout(()=>{wr=null,!(Ot<=0)&&vi(ki).catch(()=>{}).finally(()=>{fa()})},t)},$y=e=>{typeof e=="string"&&e.trim()&&(ki=e.trim()),Ot+=1,fa();let t=!1;return()=>{t||(t=!0,Ot=Math.max(0,Ot-1),Ot===0&&Di())}},zy=e=>(yn.add(e),()=>{yn.delete(e)}),rl=async e=>{const t=new Headers(e);for(const[o,n]of Object.entries(ua()))t.has(o)||t.set(o,n);if(t.has("Authorization"))return t;const r=await Ci();return r?.type==="bearer"&&t.set("Authorization",`Bearer ${r.token}`),t},bn="pichamber:auth-expired",qy=()=>{typeof window>"u"||window.dispatchEvent(new Event(bn))},Wy=e=>typeof window>"u"?()=>{}:(window.addEventListener(bn,e),()=>{window.removeEventListener(bn,e)}),Gy=async(e,t,r)=>{if(e.length===0)return[];const o=Math.max(1,Math.min(t,e.length)),n=new Array(e.length);let a=0;const s=async()=>{for(;;){const i=a;if(a+=1,i>=e.length)return;n[i]=await r(e[i])}};return await Promise.all(Array.from({length:o},()=>s())),n},ss=e=>{if(e instanceof Error)return e;if(typeof DOMException<"u")return new DOMException(typeof e=="string"?e:"The operation was aborted.","AbortError");const t=new Error(typeof e=="string"?e:"The operation was aborted.");return t.name="AbortError",t},Si=(e,t)=>t?t.aborted?Promise.reject(ss(t.reason)):new Promise((r,o)=>{let n=!1;const a=()=>{n||(n=!0,o(ss(t.reason)))};t.addEventListener("abort",a,{once:!0}),e().then(s=>{n||(n=!0,t.removeEventListener("abort",a),r(s))},s=>{n||(n=!0,t.removeEventListener("abort",a),o(s))})}):e(),ol=["local","remote",null],nl=["ok","not-configured","unreachable","incompatible","wrong-service","missing"];function Mi(e){if(!e||typeof e!="object")return{valid:!1};const t=e,r=t.localAvailable===!1?{localAvailable:!1}:{},o=t.target,n=t.status;if(o!==null&&(typeof o!="string"||!ol.includes(o)))return{valid:!1};if(typeof n!="string"||!nl.includes(n))return{valid:!1};if(o==="remote"||o==="local"){if(n==="ok"&&o==="local")return{valid:!0,outcome:{target:"local",status:"ok",...r}};if(n==="ok"&&o==="remote")return typeof t.hostId!="string"||typeof t.url!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:"ok",hostId:t.hostId,url:t.url,...r}};if(n==="unreachable")return o==="local"?{valid:!0,outcome:{target:"local",status:"unreachable",...r}}:typeof t.hostId!="string"||typeof t.url!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:"unreachable",hostId:t.hostId,url:t.url,...r}};if(n==="incompatible"||n==="wrong-service")return o!=="remote"?{valid:!1}:typeof t.hostId!="string"||typeof t.url!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:n,hostId:t.hostId,url:t.url,...r}};if(n==="missing")return o!=="remote"?{valid:!1}:typeof t.hostId!="string"?{valid:!1}:{valid:!0,outcome:{target:"remote",status:"missing",hostId:t.hostId,...r}}}if(o===null){if(n==="not-configured")return{valid:!0,outcome:{target:null,status:"not-configured",...r}};if(n==="missing")return{valid:!1}}return{valid:!1}}function al(){if(sl()!=="valid")return null;const t=window.__PICHAMBER_DESKTOP_BOOT_OUTCOME__,r=Mi(t);return r.valid?r.outcome:null}function sl(){if(typeof window>"u")return"not-injected";const e=window.__PICHAMBER_DESKTOP_BOOT_OUTCOME__;return e==null?"not-injected":Mi(e).valid?"valid":"malformed"}const yo=/^[a-z][a-z\d+.-]*:\/\//i,il=e=>{const t=e.trim();return t?t.startsWith("/")?t:`/${t}`:"/"},An=e=>typeof e!="string"?"":e.trim().replace(/\/+$/,""),cl=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_API_BASE_URL__;return An(e)},dl=e=>{const t=e.currentHref?.();return t||(typeof window<"u"?window.location.href||window.location.origin:"")},En=(e,t)=>{if(!t)return;const r=t instanceof URLSearchParams?Array.from(t.entries()):Object.entries(t);for(const[o,n]of r)n!=null&&e.searchParams.set(o,String(n))},ll=(e,t)=>{if(!t)return e;const r=new URLSearchParams;En({searchParams:r},t);const o=r.toString();return o?e.includes("?")?`${e}&${o}`:`${e}?${o}`:e},is=(e,t,r)=>{if(yo.test(t)){const a=new URL(t);return En(a,r),a.toString()}const o=il(t);if(!e)return ll(o,r);const n=new URL(o,`${e}/`);return En(n,r),n.toString()},Go=(e,t)=>{const r=t===void 0?Xd():t;if(!r)return e;const o=yo.test(e)?new URL(e):new URL(e,"http://pichamber.local");return o.searchParams.set("oc_url_token",r),yo.test(e)?o.toString():`${o.pathname}${o.search}${o.hash}`},ul=(e,t)=>{const r=yo.test(e)?new URL(e):new URL(e,dl(t));return r.protocol==="ws:"||r.protocol==="wss:"||(r.protocol=r.protocol==="https:"?"wss:":"ws:"),r.toString()},ma=(e={})=>{const t=An(e.apiBaseUrl),r=An(e.realtimeBaseUrl),o=()=>t||cl(),n=()=>r||o(),a=(i,c)=>is(o(),i,c),s=(i,c)=>is(n(),i,c);return{api:a,authenticatedAsset:(i,c)=>Go(a(i,c)),auth:a,health:i=>a("/health",i),rawFile:(i,c)=>a("/api/fs/raw",{path:i,download:c?.download===!0?!0:void 0,allowOutsideWorkspace:c?.allowOutsideWorkspace===!0?!0:void 0,outsideFileGrant:c?.outsideFileGrant}),sse:(i,c)=>Go(s(i,c)),websocket:(i,c,d)=>ul(Go(s(i,c),d),e)}};let bo=ma();const Ie=()=>bo,fl=e=>{bo=e},ga=e=>(bo=ma(e),bo);let Vo=null,Jo=null,Yo=null;const cs=new Set;let ds=!1;const Ti=e=>{if(cs.add(e),ds||typeof window>"u")return;ds=!0;const t=()=>{for(const r of cs)r()};try{window.addEventListener("pagehide",t,{capture:!0}),window.addEventListener("beforeunload",t,{capture:!0}),typeof document<"u"&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&t()}),document.addEventListener("freeze",t))}catch{}},ml=(e,t)=>{let r;try{r=e()}catch{return}const o=new Map,n=new Set;let a;const s=()=>{if(a=void 0,o.size===0&&n.size===0)return;const c=Array.from(o.entries()),d=Array.from(n);o.clear(),n.clear();for(const[l,u]of c)try{r.setItem(l,JSON.stringify(u,t?.replacer))}catch(f){console.error("Failed to persist deferred storage value",f),!o.has(l)&&!n.has(l)&&o.set(l,u)}for(const l of d)try{r.removeItem(l)}catch(u){console.error("Failed to remove deferred storage value",u),o.has(l)||n.add(l)}},i=()=>{a===void 0&&(a=setTimeout(s,0))};return Ti(s),{getItem:c=>{if(o.has(c))return o.get(c)??null;if(n.has(c))return null;const d=u=>{if(u===null)return null;try{return JSON.parse(u,t?.reviver)}catch{try{r.removeItem(c)}catch{}return null}},l=r.getItem(c);return l instanceof Promise?l.then(d):d(l)},setItem:(c,d)=>{o.set(c,d),n.delete(c),i()},removeItem:c=>{o.delete(c),n.add(c),i()}}},pa=e=>ml(()=>Ii(),e),gl=e=>{const t=new Map,r=new Set;let o;const n=()=>{if(o=void 0,t.size===0&&r.size===0)return;const s=Array.from(t.entries()),i=Array.from(r);t.clear(),r.clear();for(const[c,d]of s)try{e.setItem(c,d)}catch(l){console.error("Failed to persist deferred storage value",l),!t.has(c)&&!r.has(c)&&t.set(c,d)}for(const c of i)try{e.removeItem(c)}catch(d){console.error("Failed to remove deferred storage value",d),t.has(c)||r.add(c)}},a=()=>{o===void 0&&(o=setTimeout(n,0))};return Ti(n),{getItem:s=>t.has(s)?t.get(s)??null:r.has(s)?null:e.getItem(s),setItem:(s,i)=>{t.set(s,i),r.delete(s),a()},removeItem:s=>{t.delete(s),r.add(s),a()},clear:()=>{t.clear(),r.clear(),o!==void 0&&(clearTimeout(o),o=void 0),e.clear()},key:s=>e.key(s),get length(){return e.length}}},Pi=e=>{if(typeof window>"u")return null;try{return window[e]??null}catch{return null}},ha=()=>{const e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,r)=>{e.set(t,r)},removeItem:t=>{e.delete(t)},clear:()=>{e.clear()},key:t=>Array.from(e.keys())[t]??null,get length(){return e.size}}},Ri=e=>{const t=ha(),r=new Set,o=new Set,n=d=>{if(o.has(d))return null;if(r.has(d))return t.getItem(d);try{return e.getItem(d)}catch{return null}},a=(d,l)=>{try{e.setItem(d,l),t.removeItem(d),r.delete(d),o.delete(d);return}catch{try{e.removeItem(d)}catch{}}t.setItem(d,l),r.add(d),o.delete(d)},s=d=>{try{e.removeItem(d),o.delete(d)}catch{o.add(d)}t.removeItem(d),r.delete(d)},i=()=>{const d=[];try{for(let l=0;l<e.length;l+=1){const u=e.key(l);u&&d.push(u)}}catch{}try{e.clear(),o.clear()}catch{for(const l of d)o.add(l)}t.clear(),r.clear()},c=()=>{const d=new Set;try{for(let l=0;l<e.length;l+=1){const u=e.key(l);u&&!o.has(u)&&!r.has(u)&&d.add(u)}}catch{}for(const l of r)d.add(l);return[...d]};return{getItem:n,setItem:a,removeItem:s,clear:i,key:d=>c()[d]??null,get length(){return c().length}}},pl=()=>{const e=Pi("localStorage");return e?Ri(e):ha()},Ii=()=>(Vo||(Vo=pl()),Vo),Kr=()=>(Yo||(Yo=gl(Ii())),Yo),hl=()=>{const e=Pi("sessionStorage");return e?Ri(e):ha()},Vy=()=>(Jo||(Jo=hl()),Jo),wn="pichamber:runtime-endpoint-changed",Bn="pichamber:runtime-endpoint-will-change";let st="",vt="",_i=0;const Jy=()=>(Io(),_i),Cn="pichamber:lastRuntimeEndpoint.v1",Fl=()=>{try{const e=Kr().getItem(Cn);if(!e)return null;const t=JSON.parse(e),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl.trim():"",o=typeof t.runtimeKey=="string"?t.runtimeKey.trim():"";return!r||!o||o==="mobile-disconnected"?null:{apiBaseUrl:r,runtimeKey:o}}catch{return null}},yl=(e,t)=>{try{const r=Kr();if(t==="mobile-disconnected"||!e){r.removeItem(Cn);return}r.setItem(Cn,JSON.stringify({apiBaseUrl:e,runtimeKey:t}))}catch{}},Io=()=>{if(st||vt||typeof window>"u")return;const e=Fl();if(e){st=e.apiBaseUrl,vt=e.runtimeKey;try{window.__PICHAMBER_API_BASE_URL__=e.apiBaseUrl}catch{}ga({apiBaseUrl:e.apiBaseUrl,realtimeBaseUrl:e.apiBaseUrl})}},Xo=(e,t,r)=>{try{e[t]=r}catch{}},Fa=e=>{try{const t=new URL(e);return t.hash="",t.search="",t.pathname=t.pathname.replace(/\/+$/,"")||"/",`url:${t.toString().replace(/\/+$/,"")}`}catch{return`url:${e.trim().replace(/\/+$/,"")||"default"}`}},xi=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_API_BASE_URL__;return typeof e=="string"?e.trim():""},Oi=()=>{if(typeof window>"u")return"";const e=window.__PICHAMBER_LOCAL_ORIGIN__;return typeof e=="string"?e.trim():""},Ni=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},ze=()=>(Io(),st||xi());let Qo="",ls=null,us,fs;const ms=e=>{if(typeof window>"u")return;const t=window[e];return typeof t=="string"?t:void 0},D=()=>{if(Io(),vt)return vt;const e=ms("__PICHAMBER_API_BASE_URL__"),t=ms("__PICHAMBER_LOCAL_ORIGIN__");if(ls===st&&us===e&&fs===t)return Qo;const r=ze();return Qo=Ni(r,Oi())?"local":Fa(r),ls=st,us=e,fs=t,Qo},bl=(e={})=>{if(Io(),st||vt)return;const t=e.apiBaseUrl?.trim()||xi();t&&(st=t,vt=e.runtimeKey?.trim()||(Ni(t,Oi())?"local":Fa(t)))},jt=e=>{const t=e.apiBaseUrl.trim(),r=ze(),o=D(),n=e.runtimeKey?.trim()||Fa(t);_i+=1,yl(t,n);const a={apiBaseUrl:t,previousApiBaseUrl:r,runtimeKey:n,previousRuntimeKey:o};if(typeof window<"u"&&window.dispatchEvent(new CustomEvent(Bn,{detail:a})),st=t,vt=n,typeof window<"u"){const s=window;Xo(s,"__PICHAMBER_API_BASE_URL__",t),Xo(s,"__PICHAMBER_CLIENT_TOKEN__",e.clientToken||void 0),Xo(s,"__PICHAMBER_RUNTIME_HEADERS__",e.requestHeaders||void 0)}ga({apiBaseUrl:t,realtimeBaseUrl:t}),wi(e.requestHeaders||null),Ei(e.clientToken||null),e.relay?$d(e.relay):zd(),Hr(t).catch(()=>{}),typeof window<"u"&&window.dispatchEvent(new CustomEvent(wn,{detail:a}))},Al=e=>{if(typeof window>"u")return()=>{};const t=r=>{e(r.detail)};return window.addEventListener(Bn,t),()=>window.removeEventListener(Bn,t)},Li=e=>{if(typeof window>"u")return()=>{};const t=r=>{e(r.detail)};return window.addEventListener(wn,t),()=>window.removeEventListener(wn,t)};let vn=null;const El=e=>{vn=e},ya=()=>vn||(typeof window>"u"?null:window.__PICHAMBER_RUNTIME_APIS__??null),Yy=Object.freeze(Object.defineProperty({__proto__:null,getRegisteredRuntimeAPIs:ya,registerRuntimeAPIs:El},Symbol.toStringTag,{value:"Module"})),wl=()=>typeof window>"u"?null:window.__PICHAMBER_ELECTRON__??null,Zt=()=>typeof window>"u"?null:window.__PICHAMBER_DESKTOP__??null,_o=()=>wl()?.runtime==="electron",Xy=()=>{if(typeof window>"u")return null;const e=window.__PICHAMBER_PLATFORM__;return typeof e=="string"?e:null},Z=()=>typeof Zt()?.invoke=="function",xe=()=>_o()&&Z(),j=async(e,t)=>{const r=Zt();return typeof r?.invoke!="function"?null:r.invoke(e,t??{})},gs=e=>{const t=e.trim();if(!t)return null;try{return new URL(t).origin}catch{try{return new URL(t.endsWith("/")?t:`${t}/`).origin}catch{return null}}},Zo=e=>{const t=e.trim();if(!t)return null;try{return new URL(t)}catch{try{return new URL(t.endsWith("/")?t:`${t}/`)}catch{return null}}},Bl=e=>e.replace(/^\[|\]$/g,"").toLowerCase(),lr=e=>{const t=Bl(e);return t==="localhost"||t==="127.0.0.1"||t==="::1"},we=()=>typeof window>"u"?!1:_o(),ce=()=>{if(typeof window>"u"||!we())return!1;if(D()==="local")return!0;const e=typeof window.__PICHAMBER_LOCAL_ORIGIN__=="string"?window.__PICHAMBER_LOCAL_ORIGIN__:"",t=Zo(e),r=Zo(ze());if(!r&&t&&al()?.target==="local")return!0;if(t&&r){if(t.origin===r.origin)return!0;const s=t.port||(t.protocol==="https:"?"443":"80"),i=r.port||(r.protocol==="https:"?"443":"80");return t.protocol===r.protocol&&s===i&&lr(t.hostname)&&lr(r.hostname)}const o=Zo(window.location.origin);if(t&&o){if(t.origin===o.origin)return!0;const s=t.port||(t.protocol==="https:"?"443":"80"),i=o.port||(o.protocol==="https:"?"443":"80");return t.protocol===o.protocol&&s===i&&lr(t.hostname)&&lr(o.hostname)}const n=gs(e),a=gs(window.location.origin)||window.location.origin;return n&&a&&n===a?!0:!!(o&&lr(o.hostname))},Qy=()=>{const t=ya()?.runtime?.platform;return t==="web"?!0:t!=="desktop"},Zy=(e,t=we())=>e==="web"&&!t,eb=async()=>{if(!xe())return null;try{const e=await j("desktop_get_launch_at_login");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"?null:e}catch(e){return console.warn("Failed to get launch at login status",e),null}},tb=async e=>{if(!xe())return null;try{const t=await j("desktop_set_launch_at_login",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"?null:t}catch(t){return console.warn("Failed to set launch at login status",t),null}},rb=async()=>{if(!xe())return null;try{const e=await j("desktop_get_minimize_to_tray");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"?null:e}catch(e){return console.warn("Failed to get minimize to tray status",e),null}},ob=async e=>{if(!xe())return null;try{const t=await j("desktop_set_minimize_to_tray",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"?null:t}catch(t){return console.warn("Failed to set minimize to tray status",t),null}},nb=async()=>{if(!xe())return null;try{const e=await j("desktop_get_close_to_tray");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"?null:e}catch(e){return console.warn("Failed to get close to tray status",e),null}},ab=async e=>{if(!xe())return null;try{const t=await j("desktop_set_close_to_tray",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"?null:t}catch(t){return console.warn("Failed to set close to tray status",t),null}},sb=async()=>{if(!xe())return null;try{const e=await j("desktop_get_keep_awake");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"||typeof e.active!="boolean"?null:e}catch(e){return console.warn("Failed to get keep awake status",e),null}},ib=async e=>{if(!xe())return null;try{const t=await j("desktop_set_keep_awake",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"||typeof t.active!="boolean"?null:t}catch(t){return console.warn("Failed to set keep awake status",t),null}},cb=async()=>{if(!xe())return null;try{const e=await j("desktop_get_process_performance_recording");return!e||typeof e.supported!="boolean"||typeof e.enabled!="boolean"||typeof e.active!="boolean"?null:e}catch(e){return console.warn("Failed to get process performance recording status",e),null}},db=async e=>{if(!xe())return null;try{const t=await j("desktop_set_process_performance_recording",{enabled:e});return!t||typeof t.supported!="boolean"||typeof t.enabled!="boolean"||typeof t.active!="boolean"?null:t}catch(t){return console.warn("Failed to set process performance recording status",t),null}},Cl=()=>we()&&Z()&&ce(),vl=async()=>{if(typeof window<"u"){const e=window.__PICHAMBER_HOME__;if(e&&e.length>0)return e}return null},lb=async e=>{if(Cl())try{const t=await Zt()?.openDialog?.({directory:!0,multiple:!1,title:"Select working directory",...e?{defaultPath:e}:{}});return!t||typeof t!="string"?{success:!1,error:"Directory selection cancelled"}:{success:!0,path:t}}catch(t){return console.warn("Failed to request directory access",t),{success:!1,error:t instanceof Error?t.message:String(t)}}return{success:!1,error:"Native directory picker not available"}},Ui=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ub=async e=>{if(Z()&&ce())try{const t=await Zt()?.openDialog?.({directory:!1,multiple:!1,title:"Select file",returnGrant:!0,...e?.filters?{filters:e.filters}:{},...e?.defaultPath?{defaultPath:e.defaultPath}:{}});if(!t)return{success:!1,error:"File selection cancelled"};if(typeof t=="string")return{success:!0,path:t};if(!Ui(t))return{success:!1,error:"File selection cancelled"};const r=typeof t.path=="string"?t.path:"";return r?{success:!0,path:r,outsideFileGrant:typeof t.outsideFileGrant=="string"?t.outsideFileGrant:void 0}:{success:!1,error:"File selection cancelled"}}catch(t){return console.warn("Failed to request file access",t),{success:!1,error:t instanceof Error?t.message:String(t)}}return{success:!1,error:"Native file picker not available"}},fb=async e=>{const t=typeof e=="string"?e.trim():"";if(!t)return{success:!1,error:"Path is required"};if(!Z()||!ce())return{success:!1,error:"Native file access not available"};try{const r=await Zt()?.grantFileAccess?.(t);if(!Ui(r))return{success:!1,error:"File access was not granted"};const o=typeof r.path=="string"?r.path:"",n=typeof r.outsideFileGrant=="string"?r.outsideFileGrant:"";return!o||!n?{success:!1,error:"File access was not granted"}:{success:!0,path:o,outsideFileGrant:n}}catch(r){return console.warn("Failed to request existing file access",r),{success:!1,error:r instanceof Error?r.message:String(r)}}},mb=async e=>({success:!0}),gb=async e=>({success:!0}),pb=async()=>Z()&&await j("desktop_get_update_channel")==="rc"?"rc":"stable",hb=async e=>{if(!Z())throw new Error("Desktop update settings are unavailable.");const t=await j("desktop_set_update_channel",{channel:e});if(t!=="stable"&&t!=="rc")throw new Error("Unable to save the desktop update channel.");return t},Fb=async()=>Z()?await j("desktop_check_for_updates"):null,yb=async e=>{if(!Z())return!1;const t=Zt();let r=null,o=0,n;try{return typeof e=="function"&&t?.listen&&(r=await t.listen("pichamber:update-progress",a=>{const s=a?.payload;if(!s||typeof s!="object")return;const i=s,c=typeof i.event=="string"?i.event:null,d=i.data&&typeof i.data=="object"?i.data:null;if(c==="Started"){o=0,n=typeof d?.contentLength=="number"?d.contentLength:void 0,e({downloaded:o,total:n});return}if(c==="Progress"){const l=d?.downloaded,u=d?.total;typeof l=="number"&&(o=l),typeof u=="number"&&(n=u),e({downloaded:o,total:n});return}c==="Finished"&&e({downloaded:o,total:n})})),await j("desktop_download_and_install_update"),!0}catch(a){throw a instanceof Error?a:new Error(String(a))}finally{if(r)try{const a=r();a instanceof Promise&&await a}catch{}}},kl=async()=>{if(!Z())return!1;try{return await j("desktop_restart"),!0}catch(e){return console.warn("Failed to restart desktop app",e),!1}},bb=async()=>Z()?kl():!1,Ab=async()=>{if(!Z()||!ce())return null;try{const e=await j("desktop_get_lan_address");return typeof e=="string"&&e.trim().length>0?e.trim():null}catch(e){return console.warn("Failed to get desktop LAN address",e),null}},Dl=async(e,t)=>{if(!Z()||!ce())return!1;const r=e?.trim();if(!r)return!1;try{return await j("desktop_open_path",{path:r,app:typeof t=="string"&&t.trim().length>0?t.trim():void 0}),!0}catch(o){return console.warn("Failed to open path",o),!1}},Eb=async e=>{if(!Z()||!ce())return!1;const t=e?.trim();if(!t)return!1;try{return await j("desktop_reveal_path",{path:t}),!0}catch{return Dl(t)}},wb=async(e,t)=>{if(!Z()||!ce())return null;const r=e?.trim();if(!r)return null;try{const o=await j("desktop_save_markdown_file",{defaultFileName:r,content:t});return typeof o=="string"&&o.trim().length>0?o:null}catch(o){return console.warn("Failed to save markdown file",o),null}},Bb=async(e,t,r)=>{if(!Z()||!ce())return!1;const o=e?.trim(),n=t?.trim(),a=r?.trim();if(!o||!n||!a)return!1;try{return await j("desktop_open_in_app",{projectPath:o,appId:n,appName:a}),!0}catch(s){return console.warn("Failed to open project in app",s),!1}},Cb=async(e,t,r)=>{if(!Z()||!ce())return!1;const o=e?.trim(),n=t?.trim(),a=r?.trim();if(!o||!n||!a)return!1;try{return await j("desktop_open_file_in_app",{filePath:o,appId:n,appName:a}),!0}catch(s){return console.warn("Failed to open file in app",s),!1}},vb=async(e,t)=>{if(!Z()||!ce())return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};const r=Array.isArray(e)?e.filter(o=>typeof o=="string"):[];if(r.length===0)return{apps:[],success:!0,hasCache:!1,isCacheStale:!1};try{const o=await j("desktop_get_installed_apps",{apps:r,force:t===!0?!0:void 0});if(!o||typeof o!="object")return{apps:[],success:!1,hasCache:!1,isCacheStale:!1};const n=o;return n.supported===!1?{apps:[],success:!0,hasCache:!1,isCacheStale:!1}:Array.isArray(n.apps)?{apps:n.apps.filter(s=>s&&typeof s=="object").map(s=>{const i=s;return{name:typeof i.name=="string"?i.name:"",iconDataUrl:typeof i.iconDataUrl=="string"?i.iconDataUrl:null}}).filter(s=>s.name.length>0),success:!0,hasCache:n.hasCache===!0,isCacheStale:n.isCacheStale===!0}:{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}catch(o){return console.warn("Failed to fetch installed apps",o),{apps:[],success:!1,hasCache:!1,isCacheStale:!1}}},er=()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location?.protocol==="capacitor:",kb=()=>{if(typeof window>"u"||!er()||Sl()!=="ios")return!1;const e=navigator.userAgent||"",t=navigator.maxTouchPoints??0;return/iPad/i.test(e)||/Macintosh|MacIntel/i.test(e)&&t>1},Sl=()=>{if(typeof window<"u"){const t=window.Capacitor?.getPlatform?.();if(t==="ios"||t==="android")return t}return we()?"desktop":"web"},Db=()=>{if(typeof navigator>"u")return!1;const e=navigator.platform||"",t=navigator.userAgent||"";return/Win/i.test(e)&&/ARM|aarch64/i.test(t)},kt=e=>e.startsWith("/api/")||e==="/api"||e.startsWith("/auth/")||e==="/auth"||e==="/health",Ml=()=>typeof window>"u"?"":window.location.origin||"",ba=e=>{if(typeof window>"u")return!1;const t=Ml();if(t&&e.origin===t)return!0;try{const r=new URL(window.location.href||t);return e.protocol===r.protocol&&e.host===r.host}catch{return!1}},Aa=e=>/^[a-z][a-z\d+.-]*:\/\//i.test(e),Ea=(e,t)=>{if(!t)return;const r=t instanceof URLSearchParams?Array.from(t.entries()):Object.entries(t);for(const[o,n]of r)n!=null&&e.searchParams.set(o,String(n))},so=e=>{try{const t=Ie().api("/api");if(!/^[a-z][a-z\d+.-]*:\/\//i.test(t))return!1;const r=new URL(t);return e.origin!==r.origin?!1:kt(e.pathname)}catch{return!1}},en=e=>{if(kt(e))return!0;if(!/^[a-z][a-z\d+.-]*:\/\//i.test(e))return!1;try{const t=new URL(e);return ba(t)&&kt(t.pathname)}catch{return!1}},Tl=(e,t)=>{try{const r=new URL(e);if(!ba(r))return e;const o=Bt(`${r.pathname}${r.search}`,t);return!Aa(o)&&(r.protocol==="http:"||r.protocol==="https:")?(Ea(r,t),r.toString()):r.hash?`${o}${r.hash}`:o}catch{return e}},Bt=(e,t)=>e==="/health"?Ie().health(t):e.startsWith("/auth/")||e==="/auth"?Ie().auth(e,t):kt(e)?Ie().api(e,t):/^[a-z][a-z\d+.-]*:\/\//i.test(e)?Tl(e,t):e,Pl=e=>{const t=e instanceof Request?e.url:e.toString();if(!Aa(t))return kt(t);try{return so(new URL(t))}catch{return!1}},Rl=e=>{for(let t=0;t<e.length;t+=1)if(e.charCodeAt(t)>255)return!1;return!0},Il=(e,t)=>!Rl(t),ps=e=>{if(!e)return;const t=e instanceof Headers?Array.from(e.entries()):Array.isArray(e)?e:Object.entries(e);if(t.length===0)return;const r=[];let o=!1;for(const[n,a]of t)Il(n,a)?(r.push([n,encodeURIComponent(a)]),o=!0):r.push([n,a]);return o?r:void 0},Ue=async(e,t,r=!0)=>{const o=new Headers(ps(e)??e);return t&&new Headers(ps(t)??t).forEach((n,a)=>o.set(a,n)),r?rl(o):o},_l=(e,t)=>{if(!t)return e;const r=new URL(e,sa);return Ea(r,t),`${r.pathname}${r.search}`},Hi=(e,t)=>{const r=e instanceof Request?e.url:e.toString();if(!Aa(r))return kt(r)?_l(r,t):null;try{const o=new URL(r);return!ba(o)||!kt(o.pathname)?null:(Ea(o,t),`${o.pathname}${o.search}`)}catch{return null}},xl=async(e,t,r)=>{const o=Nr();if(!o)return null;const n=Hi(e,r);if(n===null)return null;const a=e instanceof Request?e.headers:void 0,s=await Ue(a,t.headers,!0);return e instanceof Request?o.fetch(e,{...t,headers:s}):o.fetch(n,{...t,headers:s})},Ol=(e,t)=>{if(typeof e=="string")return Bt(e,t);if(e instanceof URL)return Bt(e.toString(),t);const r=Bt(e.url,t);return r===e.url?e:new Request(r,e)},Nl=/\/api\/pi\/(health|projects|sessions|providers|resources|runtime|settings)(\b|\/|\?|$)/,Vr=new Map,Ll=(e,t,r)=>r||e!=="GET"||t.includes("/event")||!Nl.test(t)?null:`GET ${t}`,b=async(e,t={})=>{const{query:r,...o}=t,n=Nr(),a=n?Hi(e,r):null,s=o.signal??(e instanceof Request?e.signal:void 0);let i,c,d;if(n&&a!==null){const g=e instanceof Request?e.headers:void 0,h=await Ue(g,o.headers,!0);i=e instanceof Request?()=>n.fetch(e,{...o,headers:h}):()=>n.fetch(a,{...o,headers:h}),c=a,d=String(o.method??(e instanceof Request?e.method:"GET")).toUpperCase()}else{const g=Ol(e,r),h=g instanceof Request?g.headers:void 0,p=await Ue(h,o.headers,Pl(g));let k=g instanceof Request?()=>fetch(new Request(g,{...o,headers:p})):()=>fetch(g,{...o,headers:p});if(er()&&s){const A=k;k=()=>Si(A,s)}i=k,c=g instanceof Request?g.url:g instanceof URL?g.toString():String(g),d=String(o.method??(g instanceof Request?g.method:"GET")).toUpperCase()}const l=o.signal!=null||e instanceof Request,u=Ll(d,c,l);if(!u)return i();const f=Vr.get(u);if(f)return f.then(g=>g.clone());const m=i();return Vr.set(u,m),m.then(()=>Vr.delete(u),()=>Vr.delete(u)),m.then(g=>g.clone())};let hs=!1;const Ul=()=>{if(hs||typeof window>"u")return;hs=!0;const e=window.fetch.bind(window);window.fetch=async(t,r)=>{const o=await xl(t,r??{});if(o)return o;if(typeof t=="string"){if(!en(t)){try{const a=new URL(t);if(so(a)){const s=await Ue(void 0,r?.headers);return e(t,{...r,headers:s})}}catch{}return e(t,r)}const n=await Ue(void 0,r?.headers);return e(Bt(t),{...r,headers:n})}if(t instanceof URL){const n=t.toString();if(!en(n)){if(so(t)){const s=await Ue(void 0,r?.headers);return e(t,{...r,headers:s})}return e(t,r)}const a=await Ue(void 0,r?.headers);return e(Bt(n),{...r,headers:a})}if(t instanceof Request){if(!en(t.url)){try{const i=new URL(t.url);if(so(i)){const c=await Ue(t.headers,r?.headers);return e(new Request(t,{...r,headers:c}))}}catch{}return e(t,r)}const n=await Ue(t.headers,r?.headers),a=Bt(t.url),s=a===t.url?t:new Request(a,t);return e(new Request(s,{...r,headers:n}))}return e(t,r)}},$t=16384,Ao=globalThis,Hl=e=>{if(Ao.Buffer)return Ao.Buffer.from(e,"utf8").toString("base64url");const t=new TextEncoder().encode(e);let r="";for(let o=0;o<t.length;o+=32768)r+=String.fromCharCode(...t.slice(o,o+32768));return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},Ki=e=>{try{if(Ao.Buffer)return Ao.Buffer.from(e,"base64url").toString("utf8");const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"="),r=atob(t),o=new Uint8Array(r.length);for(let n=0;n<r.length;n+=1)o[n]=r.charCodeAt(n);return new TextDecoder().decode(o)}catch{return null}},Kl=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const r=new URL(t);return r.protocol!=="http:"&&r.protocol!=="https:"?null:(r.hash="",r.toString().replace(/\/+$/g,""))}catch{return null}},jl=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const r=new URL(t);return r.protocol!=="ws:"&&r.protocol!=="wss:"?null:(r.hash="",r.toString())}catch{return null}},Fs=e=>typeof e=="string"&&e.length>0,$l=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;return t.kty!=="EC"||t.crv!=="P-256"||!Fs(t.x)||!Fs(t.y)?null:{kty:"EC",crv:"P-256",x:t.x,y:t.y}},zl=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,ql=e=>{if(!e||typeof e!="object")return null;const t=e,r=zl(t.priority);if(t.type==="lan"||t.type==="tunnel"||t.type==="tailscale"){const o=Kl(t.url);if(!o)return null;const n=t.type==="tailscale"&&(t.mode==="private"||t.mode==="public")?t.mode:void 0;return{type:t.type,url:o,...n?{mode:n}:{},...r===void 0?{}:{priority:r}}}if(t.type==="relay"){const o=jl(t.relayUrl);if(!o)return null;const n=typeof t.serverId=="string"?t.serverId.trim():"";if(!n)return null;const a=$l(t.hostEncPubJwk);if(!a)return null;const s=typeof t.grant=="string"&&t.grant.trim()?t.grant.trim():void 0;return{type:"relay",relayUrl:o,serverId:n,hostEncPubJwk:a,...s?{grant:s}:{},...r===void 0?{}:{priority:r}}}return null},wa=e=>{if(!e||typeof e!="object")return null;const t=e;if(t.v!==2)return null;const r=typeof t.pairingId=="string"?t.pairingId.trim():"",o=typeof t.secret=="string"?t.secret.trim():"";if(!r||!o)return null;const n=Array.isArray(t.candidates)?t.candidates.map(ql).filter(c=>!!c):[];if(n.length===0)return null;const a=typeof t.expiresAt=="string"&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){const c=Date.parse(a);if(!Number.isFinite(c)||c<=Date.now())return null}const s=typeof t.label=="string"&&t.label.trim()?t.label.trim():void 0,i=typeof t.fingerprint=="string"&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:r,secret:o,...s?{label:s}:{},...i?{fingerprint:i}:{},...a?{expiresAt:a}:{},candidates:n}},Sb=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Mb=e=>{const t=wa(e);if(!t)throw new Error("Invalid pairing connection payload");const r=new URLSearchParams;return r.set("v","2"),r.set("p",Hl(JSON.stringify(t))),`pichamber://connect?${r.toString()}`},Wl=e=>{const t=e.trim();if(!t||t.length>$t)return null;try{const r=new URL(t);if(r.protocol!=="pichamber:"||r.hostname!=="connect"||r.searchParams.get("v")!=="2")return null;const o=r.searchParams.get("p")||"";if(!o||o.length>$t)return null;const n=Ki(o);return!n||n.length>$t?null:wa(JSON.parse(n))}catch{return null}},Tb=e=>{const t=e.trim();if(!t||t.length>$t)return null;const r=t.indexOf("?");if(r===-1||!/^pichamber:\/\/connect\/?$/i.test(t.slice(0,r)))return null;let o=null,n=null;for(const s of t.slice(r+1).split("&")){const i=s.indexOf("=");if(i===-1)continue;const c=s.slice(0,i),d=s.slice(i+1);c==="v"?o=d:c==="p"&&(n=d)}if(o!=="2"||!n||n.length>$t)return null;const a=Ki(n);if(!a||a.length>$t)return null;try{return wa(JSON.parse(a))}catch{return null}},Gt=e=>typeof e=="object"&&e!==null,Gl=e=>e.trim().toLowerCase()==="authorization",Vl=e=>{if(!Gt(e))return;const t={};for(const[r,o]of Object.entries(e)){const n=r.trim(),a=typeof o=="string"?o.trim():"";!n||!a||/[\r\n:]/.test(n)||/[\r\n]/.test(a)||Gl(n)||(t[n]=a)}return Object.keys(t).length>0?t:void 0},ji=e=>`relay://${e}`,Jl=e=>{if(!Gt(e))return null;const t=Y(e,"relayUrl")||Y(e,"relay_url"),r=Y(e,"serverId")||Y(e,"server_id"),o=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!r||!Gt(o)?null:{relayUrl:t,serverId:r,hostEncPubJwk:o}},Yl=()=>{if(typeof navigator>"u")return;const e=navigator.userAgent;if(/Macintosh|Mac OS X/i.test(e))return"macos";if(/Windows/i.test(e))return"windows";if(/Linux/i.test(e))return"linux"},$i=5e3,Xl=async(e,t,r)=>{const o=Wl(e);if(!o)throw new Error("invalid-connect-link");const n=await Wi().catch(()=>""),a={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({pairingId:o.pairingId,secret:o.secret,clientLabel:o.label||"PiChamber Desktop",clientKind:"desktop",deviceName:"PiChamber Desktop",devicePlatform:Yl(),...n?{dedupeKey:`desktop:${n}`}:{}})},s=async w=>{if(!w.ok)return null;const B=await w.json().catch(()=>null);return(typeof B?.clientToken=="string"?B.clientToken.trim():"")||null};let i=null;const c=[...o.candidates].sort((w,B)=>(w.type==="relay"?1:0)-(B.type==="relay"?1:0));for(const w of c){if(w.type==="relay"){const P=ia({relayUrl:w.relayUrl,serverId:w.serverId,hostEncPubJwk:w.hostEncPubJwk,...w.grant?{grant:w.grant}:{}});try{const ee=await s(await P.fetch("/api/client-auth/pairing/redeem",a));if(ee){i={relay:{relayUrl:w.relayUrl,serverId:w.serverId,hostEncPubJwk:w.hostEncPubJwk},token:ee};break}}catch{}finally{P.close()}continue}const B=X(w.url);if(B)try{const P=await s(await fetch(`${B}/api/client-auth/pairing/redeem`,a));if(P){i={directUrl:B,token:P};break}}catch{}}if(!i)throw new Error("pairing-redeem-failed");const d=o.candidates.find(w=>w.type==="relay"),l=i.relay||(d?{relayUrl:d.relayUrl,serverId:d.serverId,hostEncPubJwk:d.hostEncPubJwk}:void 0),u=o.candidates.filter(w=>w.type!=="relay").map(w=>X(w.url)).find(w=>!!w),f=i.directUrl||u,m=f||(l?ji(l.serverId):null);if(!m)throw new Error("pairing-missing-transport");let g=null;if(i.directUrl){const w=r?.healthTimeoutMs??$i,B=new AbortController,P=setTimeout(()=>B.abort(),w);try{const ee=await fetch(`${i.directUrl}/health`,{headers:{Accept:"application/json"},signal:B.signal,credentials:"omit"});if(ee.ok){const Be=await ee.json().catch(()=>null),se=typeof Be?.serverId=="string"?Be.serverId.trim():"";se&&(g=se)}}catch{}finally{clearTimeout(P)}}const h=new Set;l?.serverId&&h.add(l.serverId),g&&h.add(g);const p=w=>{for(const B of h)if(w.serverId===B||w.relay?.serverId===B)return!0;return!1},k=t.find(w=>{if(l){if(w.relay?.serverId===l.serverId)return!0}else if(!w.relay&&X(w.apiUrl||w.url)===m)return!(w.serverId&&g&&w.serverId!==g);return p(w)}),A=k?.id||(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`),C={...k||{},id:A,label:o.label||k?.label||Ba(m),url:m,apiUrl:f,clientToken:i.token,...l?{relay:l}:{}};return k?.serverId?C.serverId=k.serverId:g&&(C.serverId=g),{hostId:A,hosts:k?t.map(w=>w.id===A?C:w):[C,...t]}},Ql=/^(t|.*(?:token|auth|secret|api).*)$/i,X=e=>{const t=e.trim();if(!t)return null;try{const r=new URL(t);return r.protocol!=="http:"&&r.protocol!=="https:"?null:t.split("#")[0]||null}catch{return null}},Zl=e=>{const t=X(e);if(!t)return null;try{const r=new URL(t);if((r.pathname.replace(/\/+$/,"")||"/")==="/connect"&&r.searchParams.has("t"))return{persistedUrl:r.origin,redeemUrl:r.toString(),kind:"tunnel-connect-link"}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:"normal-host"}},Ba=e=>{const t=X(e);if(!t)return e;try{const r=new URL(t);(r.username||r.password)&&(r.username="",r.password="");const o=Array.from(new Set(Array.from(r.searchParams.keys())));for(const n of o)Ql.test(n)&&r.searchParams.set(n,"[REDACTED]");return r.toString()}catch{return t}},rt=(e,t)=>{const r=X(e),o=X(t);if(!r||!o)return!1;try{const n=new URL(r),a=new URL(o);if(n.origin!==a.origin||a.search&&n.search!==a.search)return!1;const s=a.pathname.length>1?a.pathname.replace(/\/+$/,""):a.pathname,i=n.pathname.length>1?n.pathname.replace(/\/+$/,""):n.pathname;return s==="/"?!0:i===s||i.startsWith(`${s}/`)}catch{return!1}},Y=(e,t)=>{const r=e[t];return typeof r=="string"?r:null},ys=(e,t)=>{const r=e[t];return typeof r=="number"&&Number.isFinite(r)?r:null},eu=e=>{if(!Gt(e))return null;const t=Y(e,"id"),r=Y(e,"label"),o=Y(e,"url"),n=Y(e,"apiUrl")||Y(e,"api_url"),a=Y(e,"clientToken")||Y(e,"client_token"),s=Vl(e.requestHeaders),i=Jl(e.relay),c=Y(e,"serverId")||Y(e,"server_id");return!t||!r||!o?null:{id:t,label:r,url:o,...n?{apiUrl:n}:{},...a?{clientToken:a}:{},...s?{requestHeaders:s}:{},...i?{relay:i}:{},...c?.trim()?{serverId:c.trim()}:{}}},_e=e=>X(e.apiUrl||e.url)||e.apiUrl||e.url,tu=(e,t)=>{const r={...e,url:t,apiUrl:t};return X(_e(e))!==X(t)&&delete r.serverId,r},St=()=>Z()?(e,t)=>j(e,t):null,Ca=async()=>{const e=St();if(!e)return{hosts:[],defaultHostId:"local",initialHostChoiceCompleted:!1};const t=await e("desktop_hosts_get");if(!Gt(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};const r=t.hosts,o=Array.isArray(r)?r.map(eu).filter(i=>!!i):[],n=Y(t,"defaultHostId")||Y(t,"default_host_id")||Y(t,"defaultHostID"),a=t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,s=Y(t,"localOrigin")||Y(t,"local_origin");return{hosts:o,defaultHostId:n,initialHostChoiceCompleted:a,localOrigin:s}},zi=async e=>{const t=St();if(!t)return;const r={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(r.localClientToken=e.localClientToken),await t("desktop_hosts_set",{input:r})},qi=async()=>{const e=St();if(!e)return"";const t=await e("desktop_local_client_token_get").catch(()=>null);return typeof t=="string"?t.trim():""},Wi=async()=>{const e=St();if(!e)return"";const t=await e("desktop_install_id_get").catch(()=>null);return typeof t=="string"?t.trim():""},ru=8e3,bs=async(e,t,r)=>{const o=new AbortController,n=window.setTimeout(()=>o.abort(),ru);try{return await e.fetch(t,{...r,signal:o.signal})}finally{window.clearTimeout(n)}},ou=async(e,t)=>{const r=ia({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),o=Date.now();let n=!1;try{if(!(await bs(r,"/health")).ok)return{status:"unreachable",latencyMs:0};const s=new Headers({Accept:"application/json"});for(const[d,l]of Object.entries(t?.requestHeaders||{}))d.toLowerCase()!=="authorization"&&s.set(d,l);const i=t?.clientToken?.trim();i&&s.set("Authorization",`Bearer ${i}`);const c=await bs(r,"/auth/session",{headers:s});return c.status===401||c.status===403?{status:"auth",latencyMs:Math.max(0,Date.now()-o)}:c.ok?(n=t?.keepTunnel===!0,{status:"ok",latencyMs:Math.max(0,Date.now()-o),...n?{tunnel:r}:{}}):{status:"unreachable",latencyMs:0}}catch{return{status:"unreachable",latencyMs:0}}finally{n||r.close()}},va=async(e,t)=>{const r=St();if(!r)return{status:"unreachable",latencyMs:0};const o=await r("desktop_host_probe",{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!Gt(o))return{status:"unreachable",latencyMs:0};const n=o.status,a=n==="ok"||n==="auth"||n==="update-recommended"||n==="incompatible"||n==="wrong-service"||n==="unreachable"?n:"unreachable",s=ys(o,"latencyMs")??ys(o,"latency_ms")??0,i=Y(o,"reportedServerId");return{status:a,latencyMs:s,...i?.trim()?{reportedServerId:i.trim()}:{}}},nu=async(e,t)=>{const r=St();r&&await r("desktop_new_window_at_url",{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},au=async e=>{const t=St();t&&await t("desktop_new_window_for_host",{hostId:e})},Pb=Object.freeze(Object.defineProperty({__proto__:null,DESKTOP_HOST_HEALTH_PIN_TIMEOUT_MS:$i,desktopHostProbe:va,desktopHostsGet:Ca,desktopHostsSet:zi,desktopInstallIdGet:Wi,desktopLocalClientTokenGet:qi,desktopOpenNewWindowAtUrl:nu,desktopOpenNewWindowForHost:au,getDesktopHostApiUrl:_e,importDesktopHostPairing:Xl,locationMatchesHost:rt,normalizeHostUrl:X,probeRelayDesktopHost:ou,redactSensitiveUrl:Ba,relayHostDisplayUrl:ji,resolveDesktopHostUrl:Zl,withEditedDesktopHostUrl:tu},Symbol.toStringTag,{value:"Module"})),ot="local",su=e=>({id:ot,label:"Local",url:e||ka()}),ka=()=>typeof window>"u"?"":window.__PICHAMBER_LOCAL_ORIGIN__||window.location.origin,Da=e=>e.id===ot?"local":`host:${e.id}`,As="host:",Gi=e=>{const t=e.runtimeKey.trim();if(t===ot)return{kind:"local"};if(t.startsWith(As)){const o=t.slice(As.length),n=e.hosts.find(a=>a.id===o);if(n)return{kind:"host",host:n}}const r=e.hosts.find(o=>e.apiBaseUrl?rt(e.apiBaseUrl,_e(o)):!1);return r?{kind:"host",host:r}:e.localOrigin&&e.apiBaseUrl&&rt(e.apiBaseUrl,e.localOrigin)?{kind:"local"}:null},iu=e=>{const t=typeof window>"u"?"":window.location.href,r=e.find(l=>l.id===ot)?.url||ka(),o=ze(),n=X(r)||r,a=X(t)||t,s=D(),i=e.find(l=>l.relay&&Da(l)===s);if(i)return{id:i.id,label:i.label,url:i.url};if(o&&rt(o,r))return{id:ot,label:"Local",url:n};const c=e.find(l=>o?rt(o,_e(l)):!1);if(c)return{id:c.id,label:c.label,url:X(_e(c))||_e(c)};if(t&&rt(t,r))return{id:ot,label:"Local",url:n};const d=e.find(l=>t?rt(t,l.url):!1);return d?{id:d.id,label:d.label,url:X(d.url)||d.url}:t.startsWith("pichamber-ui://")?{id:ot,label:"Local",url:n}:{id:"custom",label:Ba(a||"Instance"),url:a}},Rb=Object.freeze(Object.defineProperty({__proto__:null,LOCAL_HOST_ID:ot,buildLocalDesktopHost:su,getLocalDesktopOrigin:ka,resolveCurrentDesktopHost:iu,resolveDesktopHostIdentity:Gi,runtimeKeyForDesktopHost:Da},Symbol.toStringTag,{value:"Module"})),cu=5e3,du=1500;let tn=!1;const lu=async e=>{if(!_o()||tn)return;const t=`host:${e}`;if(D()===t){tn=!0;try{const r=await Ca().catch(()=>null),o=r?.hosts.find(m=>m.id===e);if(!r||!o?.relay)return;const n=o.apiUrl?X(o.apiUrl):null;if(n&&n.startsWith("https://"))return;const a=await b("/api/client-auth/connection/candidates").catch(()=>null);if(!a?.ok)return;const s=await a.json().catch(()=>null);if(!s||s.serverId!==o.relay.serverId)return;const i=Array.isArray(s.candidates)?s.candidates:[],c=[],d=[];for(const m of i){if(!m||typeof m!="object")continue;const g=m;if(g.type!=="lan"&&g.type!=="tailscale"||typeof g.url!="string")continue;const h=X(g.url),p=g.type==="tailscale"?d:c;h&&!p.includes(h)&&p.push(h)}const l=c.length>0?c:d;if(l.length===0)return;const u=n&&l.includes(n)?n:l[0];u!==n&&await zi({hosts:r.hosts.map(m=>m.id===e?{...m,apiUrl:u}:m),defaultHostId:r.defaultHostId,initialHostChoiceCompleted:r.initialHostChoiceCompleted}).catch(()=>{});const f=await va(u,{clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,expectedServerId:o.serverId??o.relay.serverId}).catch(()=>({status:"unreachable",latencyMs:0}));if(f.status==="unreachable"||f.status==="wrong-service"||f.status==="incompatible"||D()!==t)return;jt({apiBaseUrl:u,clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,runtimeKey:t})}finally{tn=!1}}},uu=e=>{typeof window>"u"||window.setTimeout(()=>{lu(e).catch(()=>{})},cu)},fu=(e,t)=>{if(t){const o=e.hosts.find(n=>n.id===t);return o?{kind:"host",host:o}:null}const r=Gi({runtimeKey:D(),apiBaseUrl:ze(),hosts:e.hosts,localOrigin:e.localOrigin});if(r)return r;if(e.defaultHostId&&e.defaultHostId!=="local"){const o=e.hosts.find(n=>n.id===e.defaultHostId);if(o)return{kind:"host",host:o}}return{kind:"local"}},mu=(e,t)=>{const r=e.clientToken||"";!r||Ro()===r||jt({apiBaseUrl:ze()||_e(e),clientToken:r,requestHeaders:e.requestHeaders||null,runtimeKey:t,relay:Qt()?e.relay:void 0})},gu=async e=>{if(!_o())return;const t=await Ca().catch(()=>null);if(!t)return;const r=fu(t,e);if(!r)return;if(r.kind==="local"){const u=await qi();if(!u)return;const f=t.localOrigin||ze();if(!f||D()==="local"&&Ro()===u)return;jt({apiBaseUrl:f,clientToken:u,runtimeKey:"local"});return}const o=r.host,n=Da(o),a=u=>{jt({apiBaseUrl:u,clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,runtimeKey:n})},s=()=>{jt({apiBaseUrl:typeof window<"u"?window.location.origin:"",clientToken:o.clientToken||null,runtimeKey:n,relay:o.relay??void 0}),uu(o.id)};if(D()===n){const u=o.apiUrl?X(_e(o)):"";if(!!(u&&rt(ze(),u))||!o.relay){mu(o,n);return}s();return}if(!o.relay){const u=_e(o);if(!u)return;a(u);return}const i=o.apiUrl?X(_e(o)):null;if(!i){s();return}const c=u=>u.status!=="unreachable"&&u.status!=="wrong-service"&&u.status!=="incompatible",d=va(i,{clientToken:o.clientToken||null,requestHeaders:o.requestHeaders||null,expectedServerId:o.serverId??o.relay.serverId}).catch(()=>({status:"unreachable",latencyMs:0})),l=await Promise.race([d,new Promise(u=>setTimeout(()=>u(null),du))]);if(l){if(c(l)){a(i);return}s();return}s(),d.then(u=>{c(u)&&D()===n&&a(i)})},pu=64*1024,hu=(e,t,r)=>{let o=0;return new ReadableStream({async pull(n){if(t?.aborted){n.error(new DOMException("The operation was aborted.","AbortError"));return}if(o>=e.size){n.close();return}const a=Math.min(o+pu,e.size),s=new Uint8Array(await e.slice(o,a).arrayBuffer());o=a,n.enqueue(s),r?.({loaded:o,total:e.size})}})},Fu=(e,t)=>!er()||e instanceof File?e:new File([e],t.filename,{type:t.mime||e.type}),yu=async(e,t,r)=>{const o=!!Nr();o||r.onProgress?.({loaded:0,total:t.size});const n={method:"POST",headers:{Accept:"application/json","Content-Type":"application/octet-stream","X-PiChamber-Filename":encodeURIComponent(r.filename),"X-PiChamber-Mime":r.mime},body:o?hu(t,r.signal,r.onProgress):Fu(t,r),signal:r.signal,...o?{duplex:"half"}:{}},a=await b(e,n);return!o&&a.ok&&r.onProgress?.({loaded:t.size,total:t.size}),a},_t=1,bu="events.streamEpoch",Au=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return Number.isSafeInteger(t.count)&&t.count>=1&&t.count<=99&&(t.kind==="input"||t.kind==="approval")&&typeof t.since=="number"&&Number.isFinite(t.since)&&t.since>0},Ib="pichamber.bash",_b=64*1024,Es=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>0,Vi=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;return!(t.snoozedUntil!==void 0&&(!Es(t.snoozedUntil)||!Es(t.snoozedAt)))},Eu=e=>{if(!e||typeof e!="object")return!1;const t=e.sessions;return!t||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(Vi)},wu=["session.snapshot","session.lifecycle","session.deleted","session.updated","session.tree.updated","session.input","session.bash","session.bash.output","session.bash.recorded","assistant.message.start","assistant.message.delta","assistant.message.end","assistant.thinking.delta","session.tool.start","session.tool.update","session.tool.end","session.queue","session.model","session.thinking","session.compaction","session.error","session.interrupted","session.openUrl","session.archive","session.moved","extension.entry","extension.message","extension.notify","extension.catalog","extension.editor","extension.title","extension.status","extension.control","extension.widget","extension.dialog","extension.dialog.dismiss","extension.ui","extension.app","extension.working","extension.editor.track","extension.custom","extension.custom.frame","extension.custom.dismiss","extension.error"],kn=e=>{if(!e||typeof e!="object")return!1;const t=e;return t.protocolVersion===_t&&t.kind==="event"&&typeof t.name=="string"&&Number.isSafeInteger(t.sequence)&&t.sequence>=0&&typeof t.sessionId=="string"&&t.sessionId.length>0&&typeof t.directory=="string"&&t.directory.length>0&&!!(t.payload&&typeof t.payload=="object"&&!Array.isArray(t.payload))&&wu.includes(t.name)},Ji=(e,t)=>{const r=Nr();return r?r.openWebSocket(Md(e),t):Bd(new WebSocket(e))},Yi="pichamber.mobile.diagnostics.v1",Sa=300,Bu=240,Cu=1e3;let Vt=[],ws=!1,zt=null,rn=!1;const Nt=e=>e==null?void 0:String(e).replace(/(?:authorization|proxy-authorization)\s*:\s*bearer\s+[^\s,;]+/gi,"authorization=[redacted]").replace(/\b(bearer|token|password|secret|api[-_]?key)\b(?:\s*[:=]\s*|\s+)[^\s,;]+/gi,"$1=[redacted]").replace(/(?:https?|wss?):\/\/[^\s"'`]+/gi,"[url]").replace(/(?:[A-Za-z]:[\\/]|\/(?:home|Users|data|storage|private|var)\/)[^\s"'`]+/g,"[path]").replace(/\s+/g," ").trim().slice(0,Bu)||void 0,vu=e=>{if(!e||typeof e!="object")return{detail:Nt(e)};const t=e;return{...typeof t.code=="string"?{code:Nt(t.code)}:{},...typeof t.status=="number"&&Number.isFinite(t.status)?{status:t.status}:{},...t.message!==void 0?{detail:Nt(t.message)}:typeof t.name=="string"?{detail:Nt(t.name)}:{}}},Xi=()=>{try{return typeof localStorage>"u"?null:localStorage}catch{return null}},xo=()=>{if(ws)return;ws=!0;const e=Xi();if(e)try{const t=e.getItem(Yi);if(!t)return;const r=JSON.parse(t);if(!Array.isArray(r))return;const o=[];for(const n of r){if(!n||typeof n!="object")continue;const a=n,s=typeof a.at=="string"?a.at:null,i=typeof a.category=="string"?a.category:null;if(!s||!i)continue;const c={at:s,category:i,...typeof a.code=="string"?{code:a.code}:{},...typeof a.status=="number"&&Number.isFinite(a.status)?{status:a.status}:{},...typeof a.detail=="string"?{detail:a.detail}:{}};o.push(c)}Vt=[...o,...Vt].slice(-Sa)}catch{}},ku=()=>{zt!==null&&(clearTimeout(zt),zt=null)},Du=()=>{zt===null&&(zt=setTimeout(()=>{zt=null,io()},Cu))},io=()=>{ku();const e=Xi();if(e)try{xo(),e.setItem(Yi,JSON.stringify(Vt.slice(-Sa)))}catch{}},W=(e,t={})=>{if(!er())return;xo();const r={at:new Date().toISOString(),category:e.trim().slice(0,80)||"unknown",...t.code?{code:Nt(t.code)}:{},...typeof t.status=="number"&&Number.isFinite(t.status)?{status:t.status}:{},...t.detail!==void 0?{detail:Nt(t.detail)}:{}};Vt=[...Vt,r].slice(-Sa),Du()},Su=(e,t)=>{W(e,vu(t))},Mu=()=>(xo(),JSON.stringify({format:"pichamber-mobile-diagnostics-v1",generatedAt:new Date().toISOString(),platform:typeof navigator>"u"?"unknown":navigator.userAgent,entries:Vt},null,2)),xb=async()=>{const e=Mu(),{isShareCancelledError:t,saveOrShareFile:r}=await qc(async()=>{const{isShareCancelledError:n,saveOrShareFile:a}=await import("./nativeFileSave-D542OJlG.js");return{isShareCancelledError:n,saveOrShareFile:a}},__vite__mapDeps([0,1,2,3,4,5,6,7]));if(typeof navigator<"u"&&typeof navigator.share=="function")try{return await navigator.share({title:"PiChamber mobile diagnostics",text:e}),"shared"}catch(n){if(t(n))throw new Error("Diagnostics export was cancelled")}if(window.Capacitor?.getPlatform?.()==="android")try{return await r({filename:"pichamber-mobile-diagnostics.json",mimeType:"application/json",data:e}),"shared"}catch{}if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),"copied";if(typeof document<"u"){const n=new Blob([e],{type:"application/json"}),a=URL.createObjectURL(n),s=document.createElement("a");return s.href=a,s.download="pichamber-mobile-diagnostics.json",document.body.appendChild(s),s.click(),s.remove(),window.setTimeout(()=>URL.revokeObjectURL(a),0),"downloaded"}throw new Error("No mobile export method is available")},Ob=()=>{if(!er()||typeof window>"u"||rn)return()=>{};rn=!0,xo(),W("app-launch",{code:"start"});const e=n=>{W("window-error",{code:n.error?.name,detail:n.message})},t=n=>{Su("unhandled-rejection",n.reason)},r=()=>{io()},o=()=>{document.visibilityState==="hidden"&&io()};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",t),window.addEventListener("pagehide",r),document.addEventListener("visibilitychange",o),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",t),window.removeEventListener("pagehide",r),document.removeEventListener("visibilitychange",o),io(),rn=!1}},Tu=3e4,Pu=250,Ru=5e3,Iu=6e4,_u=8,xu=2e3,Ou=1e4,Nu=5e3,Lu=3e4,Uu=5e3,xt=new Map,Hu=8,Ku=(e,t)=>{if(!(!e||!t||t.length>128))for(xt.delete(e),xt.set(e,t);xt.size>Hu;){const r=xt.keys().next();if(r.done)break;xt.delete(r.value)}};let Br=null;const Nb=e=>(Br=e,()=>{Br===e&&(Br=null)}),Ze=(e=D(),t)=>{if(t&&Br){const r=Br(e,t);if(r!==void 0)return r??void 0}return xt.get(e)},Qi=e=>{const t={};return typeof e.fromSequence=="number"&&Number.isFinite(e.fromSequence)&&(t.fromSequence=String(Math.max(0,Math.floor(e.fromSequence)))),typeof e.sessionId=="string"&&e.sessionId.length>0&&(t.sessionId=e.sessionId),typeof e.streamEpoch=="string"&&e.streamEpoch.length>0&&(t.streamEpoch=e.streamEpoch),typeof e.cursor=="string"&&e.cursor.length>0&&(t.cursor=e.cursor),t.capabilities=bu,t},Bs=(e,t,r)=>{const o=Ie(),n=Qi(t);return e==="ws"?o.websocket("/api/pi/events",n,r):o.sse("/api/pi/events",n)},ju=()=>"/api/pi/runtime",co=()=>er()&&!Qt()&&typeof EventSource<"u",$u=3e3;let Dn=null,Fr=null;const Lb=()=>{Dn=null,Fr=null},zu=1e4,Jr=e=>({...e,capabilities:[...e.capabilities]}),Eo=async(e,t,r)=>{const o=t??D();if(!r?.fresh){const s=Dn;if(s&&s.runtimeKey===o&&s.runtimeKey===D()&&Date.now()<s.expiresAt)return Jr(s.result)}const n=!r?.fresh&&!e;if(n){const s=Fr;if(s&&s.runtimeKey===o&&s.runtimeKey===D())return s.promise.then(Jr)}const a=async()=>{const s=r?.timeoutMs??zu,i=new AbortController,c=()=>i.abort(),d=setTimeout(()=>i.abort(),s);e&&(e.aborted?i.abort():e.addEventListener("abort",c,{once:!0}));try{const l=await b(ju(),{signal:i.signal});if(o!==D())return{state:"unavailable",protocolVersion:_t,capabilities:[],error:{code:"DAEMON_UNAVAILABLE",message:"Runtime changed during request"}};if(!l.ok)return W("runtime-health",{status:l.status,code:l.status===401||l.status===403?"auth":"http-error"}),{state:"unavailable",protocolVersion:_t,capabilities:[],error:{code:l.status===401||l.status===403?"DAEMON_AUTH_FAILED":"DAEMON_UNAVAILABLE"}};const f=await Si(()=>l.json(),i.signal).catch(p=>{if((p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p;return null});if(!f||typeof f!="object")return{state:"unavailable",protocolVersion:_t,capabilities:[],error:{code:"DAEMON_PROTOCOL_MISMATCH"}};const m=typeof f.error?.code=="string"?f.error.code:void 0,g=typeof f.streamEpoch=="string"&&f.streamEpoch.length>0&&f.streamEpoch.length<=128?f.streamEpoch:void 0;f.state==="ready"&&g&&Ku(o,g);const h={state:f.state==="ready"?"ready":"unavailable",protocolVersion:typeof f.protocolVersion=="number"?f.protocolVersion:_t,capabilities:Array.isArray(f.capabilities)?f.capabilities.filter(p=>typeof p=="string"):[],...g?{streamEpoch:g}:{},...m?{error:{code:m,...typeof f.error?.message=="string"?{message:f.error.message}:{}}}:{}};return!r?.fresh&&h.state==="ready"&&o===D()&&(Dn={runtimeKey:o,result:Jr(h),expiresAt:Date.now()+$u}),h}catch(l){const u=(l instanceof DOMException||l instanceof Error)&&l.name==="AbortError";return W("runtime-health",{code:u?"timeout":"unreachable"}),{state:"unavailable",protocolVersion:_t,capabilities:[],error:{code:u?"DAEMON_TIMEOUT":"DAEMON_UNAVAILABLE"}}}finally{clearTimeout(d),e&&e.removeEventListener("abort",c)}};if(n){const s=a().finally(()=>{Fr?.promise===s&&(Fr=null)});return Fr={runtimeKey:o,promise:s},s.then(Jr)}return a()},qu=async(e,t,r)=>{const o=new AbortController,n=()=>o.abort(),a=setTimeout(n,t);r.aborted?o.abort():r.addEventListener("abort",n,{once:!0});try{const s=await Eo(o.signal,e,{fresh:!0});return s.state==="unavailable"&&s.error?.code==="DAEMON_AUTH_FAILED"?"auth":"transient"}catch{return"transient"}finally{clearTimeout(a),r.removeEventListener("abort",n)}},Wu=(e,t,r,o,n,a,s)=>{if(co()){const f=new EventSource(Ie().sse("/api/pi/events",e)),m=new AbortController;let g=!1,h=!1,p=setTimeout(()=>{p=null,!(h||g)&&(W("stream-connect",{code:"setup-timeout"}),C(),a("sse-setup-timeout"))},s.setupTimeoutMs);const k=()=>{p&&clearTimeout(p),p=null},A=()=>{g||o()},C=()=>{k(),m.abort(),!g&&(g=!0,f.removeEventListener("heartbeat",A),f.close(),t.removeEventListener("abort",C))},w=B=>{try{const P=JSON.parse(B);kn(P)&&n(P)}catch{W("stream-frame",{code:"bad-sse-frame"})}};return f.onopen=()=>{g||(h=!0,k(),r())},f.onmessage=B=>{g||(o(),typeof B.data=="string"&&B.data.trim()&&w(B.data))},f.onerror=()=>{if(g)return;k(),f.removeEventListener("heartbeat",A),f.close(),t.removeEventListener("abort",C),g=!0,W("stream-disconnect",{code:"sse-error"});const B=s.classifySourceError;if(!B){a("sse-error");return}B(m.signal).then(P=>{m.signal.aborted||a(P==="auth"?"sse-auth-probe":"sse-error")})},f.addEventListener("heartbeat",A),t.aborted?C():t.addEventListener("abort",C,{once:!0}),C}const i=new AbortController,c=()=>i.abort();t.aborted?i.abort():t.addEventListener("abort",c,{once:!0});let d=!1,l=setTimeout(()=>{l=null,!(d||i.signal.aborted)&&(W("stream-connect",{code:"setup-timeout"}),a("sse-setup-timeout"),c())},s.setupTimeoutMs);const u=()=>{l&&clearTimeout(l),l=null};return b("/api/pi/events",{headers:{Accept:"text/event-stream"},query:e,signal:i.signal}).then(async f=>{if(!f.ok||!f.body){if(W("stream-connect",{status:f.status,code:f.body?"http-error":"missing-stream-body"}),f.status===401||f.status===403){u(),a(`sse-auth-${f.status}`);return}a(`sse-status-${f.status}`);return}d=!0,u(),r();const m=f.body.getReader(),g=new TextDecoder;let h="",p=[];const k=()=>{if(p.length===0)return;const A=p.join(`
3
+ `).trim();if(p=[],!!A)try{const C=JSON.parse(A);kn(C)&&n(C)}catch{}};for(;;){const{value:A,done:C}=await m.read();if(C){k(),u(),a("sse-eof");return}o(),h+=g.decode(A,{stream:!0});let w=h.indexOf(`
4
4
  `);for(;w!==-1;){const B=h.slice(0,w).replace(/\r$/,"");h=h.slice(w+1),B.length===0?k():B.startsWith("data:")&&p.push(B.slice(5).replace(/^ /,"")),w=h.indexOf(`
5
- `)}}}).catch(f=>{if(i.signal.aborted)return;const m=f instanceof Error?f.message.slice(0,80):"fetch-failed";G("stream-connect",{code:"fetch-failed",detail:m}),a(`sse-error:${m}`)}).finally(()=>{u(),t.removeEventListener("abort",c)}),c},Nu=(e,t,r,o,n,a)=>{const s=Ki(e);let i=!1,c=!1,d=null;const l=()=>{if(!i){i=!0,d&&clearTimeout(d),d=null;try{s.close()}catch{}}};d=setTimeout(()=>{c||i||(n("ws-ready-timeout"),l())},a);const u=()=>l();return t.aborted?l():t.addEventListener("abort",u,{once:!0}),s.onopen=()=>{c=!0,d&&clearTimeout(d),d=null,r()},s.onmessage=f=>{const m=typeof f.data=="string"?f.data:void 0;if(m)try{const g=JSON.parse(m);wn(g)&&o(g)}catch{}},s.onerror=()=>{i||n("ws-error")},s.onclose=f=>{t.removeEventListener("abort",u),i||n(`ws-close-${f?.code??0}`)},l},ys=()=>typeof document>"u"||document.visibilityState==="visible",bs=()=>typeof navigator>"u"||navigator.onLine!==!1,Ab=(e,t={})=>{const r=new AbortController,o=t.signal,n=()=>r.abort();o&&(o.aborted?r.abort():o.addEventListener("abort",n,{once:!0}));const a=r.signal,s=t.runtimeKey,i=()=>!s||s===D();let c=!1,d=0;const l=typeof t.streamEpoch=="string"&&t.streamEpoch.length>0?t.streamEpoch:null;let u=typeof t.fromSequence=="number"&&Number.isFinite(t.fromSequence)?Math.max(0,Math.floor(t.fromSequence)):l?0:void 0,f=typeof t.cursor=="string"&&t.cursor.length>0?t.cursor:void 0,m=t.transport==="ws"?"ws":"sse",g=null,h=null,p=null,k=null,A=0,C=!1,w=!1;const B=t.setupTimeoutMs??ku,P=t.authTokenTimeoutMs??Du,ee=t.healthResetMs??Su,Be=t.epochProbeTimeoutMs??Mu;let se=null;const Ge=new Set;let Ce=!1,te=null,Mt=null,rr=null,$r=!1;const or=()=>{g&&clearTimeout(g),h&&clearTimeout(h),p&&clearTimeout(p),g=null,h=null,p=null},Oe=()=>{A+=1,k?.(),k=null,h&&clearTimeout(h),h=null,p&&clearTimeout(p),p=null},nr=E=>{h&&clearTimeout(h),h=setTimeout(()=>{E===A&&W("heartbeat-timeout",E)},t.heartbeatTimeoutMs??Au)},Uo=E=>{c||a.aborted||E!==A||(nr(E),$r&&dt(E),$r=!0)},v=E=>{if(c||a.aborted||E!==A)return;const R=!C;C=!0,w=!1,R&&(p&&clearTimeout(p),p=setTimeout(()=>{p=null,E===A&&C&&(d=0)},ee),G("stream-ready",{code:m}),e.onReconnect?.()),nr(E)},U=()=>{const E=ys()&&bs()?wu:Bu,R=Math.min(Cu,d),T=Math.min(E,Eu*2**R);return d===0&&t.reconnectDelayMs!==void 0?Math.max(0,t.reconnectDelayMs):T+Math.floor(Math.random()*100)},N=(E,R=!0)=>{c||a.aborted||g||(G("stream-reconnect",{code:E}),R&&e.onDisconnect?.(E),g=setTimeout(()=>{g=null,d+=1,le()},U()))},$=()=>{c||a.aborted||!g||(clearTimeout(g),g=null,d+=1,le())},W=(E,R)=>{if(!(c||a.aborted||R!==A)){if(Oe(),!C&&m==="ws"&&t.transport!=="ws"&&(m="sse",e.onTransportSwitch?.()),C=!1,E==="runtime-change"){e.onDisconnect?.(E);return}if(E==="sse-auth-401"||E==="sse-auth-403"||E==="sse-auth-probe"){G("stream-auth",{code:E}),e.onDisconnect?.(E),e.onAuthRequired?.();return}N(E)}},de=(E,R)=>{if(c||a.aborted||R!==A)return;if(!i()){W("runtime-change",R);return}if(typeof E.stream=="string"||E.name==="session.moved"){typeof E.cursor=="string"&&E.cursor.length>0&&(f=E.cursor),v(R),e.onEvent(E);return}const T=typeof E.streamEpoch=="string"&&E.streamEpoch.length>0?E.streamEpoch:null;if(T&&T!==se){if(Ge.has(T)){G("stream-epoch",{code:"retired-frame"});return}const z=se??l;if(z!==null&&z!==T){if(Ce){Mt??={event:E,epoch:T,connectionId:R};return}ae(E,T,z,R);return}se=T,u=Math.max(u??0,E.sequence),z===null&&e.onEpochChange?.(T)}(u===void 0||E.sequence>u)&&(u=E.sequence),v(R),e.onEvent(E)},ae=async(E,R,T,z)=>{Ce=!0,te=new AbortController;const ue=setTimeout(()=>te?.abort(),Be);try{const ve=await bo(te.signal,s,{fresh:!0});if(c||a.aborted||z!==A)return;if(ve.state==="ready"&&ve.streamEpoch===R){Ge.add(T),se=R,u=E.sequence,G("stream-epoch",{code:"verified"}),e.onEpochChange?.(R),v(z),e.onEvent(E);return}if(ve.state==="unavailable"&&ve.error?.code==="DAEMON_AUTH_FAILED"){W("sse-auth-probe",z);return}if(ve.state==="ready"){Ge.add(R),G("stream-epoch",{code:"rejected"});return}G("stream-epoch",{code:"unverified"}),W("epoch-unverified",z)}finally{clearTimeout(ue),Ce=!1,te=null,Mt=null,Tt()}},dt=async E=>{const R=se??l;if(!R)return;if(Ce){rr=E;return}Ce=!0,te=new AbortController;const T=setTimeout(()=>te?.abort(),Be);try{const z=await bo(te.signal,s,{fresh:!0});if(c||a.aborted||E!==A)return;const ue=z.state==="ready"?z.streamEpoch:void 0;if(!ue||ue===R||Ge.has(ue)||(se??l)!==R)return;Ge.add(R),se=ue,u=void 0,G("stream-epoch",{code:"verified-on-resubscribe"}),e.onEpochChange?.(ue)}catch{}finally{clearTimeout(T),Ce=!1,te=null;const z=Mt;Mt=null,z&&de(z.event,z.connectionId),Tt()}},Tt=()=>{const E=rr;rr=null,!(E===null||c||a.aborted||E!==A)&&dt(E)},Fe=async()=>{let E=null;try{return await Promise.race([Lr(),new Promise((R,T)=>{E=setTimeout(()=>T(new Error("url-token-timeout")),P)})])}finally{E&&clearTimeout(E)}},le=async()=>{if(c||a.aborted)return;if(!i()){e.onDisconnect?.("runtime-change");return}const E=A+1;A=E;let R;if(m==="ws")try{R=await Fe()}catch{if(E!==A||c||a.aborted)return;if(t.transport!=="ws"){m="sse",e.onTransportSwitch?.(),Oe(),le();return}G("stream-auth",{code:"url-token-unavailable"}),W("ws-auth-token-unavailable",E);return}if(E!==A||c||a.aborted)return;if(!i()){W("runtime-change",E);return}if(m==="sse"&&so()){try{await Fe()}catch{if(E!==A||c||a.aborted)return;G("stream-auth",{code:"url-token-unavailable"}),W("sse-auth-token-unavailable",E);return}if(E!==A||c||a.aborted||!i())return}const T=se??l??void 0,z=Fs(m,{...u!==void 0?{fromSequence:u}:{},...t.sessionId?{sessionId:t.sessionId}:{},...T?{streamEpoch:T}:{},...f?{cursor:f}:{}},R),ue=()=>Uo(E),ve=I=>de(I,E),ar=I=>W(I,E),sr=zi({...u!==void 0?{fromSequence:u}:{},...t.sessionId?{sessionId:t.sessionId}:{},...T?{streamEpoch:T}:{},...f?{cursor:f}:{}});k=m==="ws"?Nu(z,a,ue,ve,ar,vu):Ou(sr,a,ue,()=>v(E),ve,ar,{setupTimeoutMs:B,...so()?{classifySourceError:I=>xu(s,Be,I)}:{}})},We=()=>{!ys()||!bs()||$()},lt=()=>{if(!(!so()||c||a.aborted)){if(w){$();return}w=!0,or(),Oe(),C=!1,N("system-resume",!1)}};typeof window<"u"&&(window.addEventListener("pichamber:system-resume",lt),window.addEventListener("online",We)),typeof document<"u"&&document.addEventListener("visibilitychange",We);const ut=()=>{c||(c=!0,typeof window<"u"&&(window.removeEventListener("pichamber:system-resume",lt),window.removeEventListener("online",We)),typeof document<"u"&&document.removeEventListener("visibilitychange",We),o?.removeEventListener("abort",n),a.removeEventListener("abort",ut),or(),Oe(),te?.abort(),te=null,a.aborted||r.abort())};return a.aborted?ut():a.addEventListener("abort",ut,{once:!0}),le(),{dispose:ut,reconnect:(E="manual")=>{c||a.aborted||(or(),Oe(),N(E))},get eventsUrl(){const E=se??l??void 0;return Fs(m,{...u!==void 0?{fromSequence:u}:{},...t.sessionId?{sessionId:t.sessionId}:{},...E?{streamEpoch:E}:{},...f?{cursor:f}:{}})}}},Lu=3e4,Pt=6e4,Uu=1,Hu=300,Ku=e=>new Promise(t=>setTimeout(t,e)),As=660*1e3,y=async(e,t)=>{const r=t.runtimeKey;if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");const o=t.query?`?${new URLSearchParams(Object.entries(t.query).map(([c,d])=>[c,String(d)])).toString()}`:"",n={Accept:"application/json"};t.body!==void 0&&(n["Content-Type"]="application/json");const s=t.retry!==!1?Uu:0;let i;for(let c=0;c<=s;c+=1){if(c>0){if(t.signal?.aborted)break;if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");if(await Ku(Hu),t.signal?.aborted)break;if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request")}const d=new AbortController,l=setTimeout(()=>d.abort(),t.timeoutMs??Lu),u=t.signal,f=()=>d.abort();u&&(u.aborted?d.abort():u.addEventListener("abort",f,{once:!0}));try{const m=await b(e+o,{method:t.method,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body),signal:d.signal});if(!m.ok){const p=(await m.json().catch(()=>null))?.error??{code:"DAEMON_REQUEST_FAILED"};if(m.status===503&&(p.code==="DAEMON_UNAVAILABLE"||p.code==="DAEMON_TIMEOUT")&&c<s&&!u?.aborted){i=new L(p.code,p.message,m.status);continue}throw new L(p.code,p.message,m.status,p.reason,p.messages)}if(m.status===204){if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");return}const g=await m.json();if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");return g}catch(m){if(i=m,m instanceof L||u?.aborted||m instanceof DOMException&&m.name==="AbortError")throw m;if(c<s&&!u?.aborted)continue;throw m}finally{clearTimeout(l),u&&u.removeEventListener("abort",f)}}throw i};class L extends Error{code;status;reason;messages;constructor(t,r,o,n,a){super(r??`Pi request failed: ${t}`),this.name="PiRequestError",this.code=t,o!==void 0&&(this.status=o),typeof n=="string"&&(this.reason=n),Array.isArray(a)&&(this.messages=a.filter(s=>typeof s=="string"))}}class lr extends Error{code;status;reason;constructor(t,r,o){super(r??`Pi send outcome unknown: ${t}`,o?.cause!==void 0?{cause:o.cause}:void 0),this.name="PiSendUnconfirmedError",this.code=t,o?.status!==void 0&&(this.status=o.status),typeof o?.reason=="string"&&(this.reason=o.reason),o?.cause!==void 0&&this.cause===void 0&&(this.cause=o.cause)}}const ju=e=>{if(!e||typeof e!="object")return!1;const t=e;if(!Array.isArray(t.sessions))return!1;if(t.sequence===void 0){if(t.incomplete!==!0)return!1}else if(!Number.isSafeInteger(t.sequence)||t.sequence<0)return!1;for(const r of t.sessions){if(!r||typeof r!="object")return!1;const o=r;if(typeof o.sessionId!="string"||o.sessionId.length===0||typeof o.directory!="string"||o.directory.length===0||!lu(o.pending))return!1}return!0},Zo=e=>{if(!e||typeof e!="object")return!1;const t=e;return!(t.accepted!==!0||typeof t.messageId!="string"||t.messageId.length===0||t.deduplicated!==void 0&&t.deduplicated!==!0)},$u=e=>{if(!(e instanceof L))return!1;const t=e.status;return typeof t!="number"||!Number.isInteger(t)?!1:t===503&&e.code==="SANDBOX_UNAVAILABLE"?!0:!(t<400||t>499||t===408||e.code==="OPERATION_EXPIRED"||e.code==="STALE_STREAM_EPOCH")},en=e=>e instanceof lr?e:e instanceof L?new lr(e.code,e.message,{status:e.status,cause:e,reason:e.reason}):e instanceof DOMException&&e.name==="AbortError"?new lr("DAEMON_TIMEOUT",e.message||"Send timed out",{cause:e}):e instanceof Error?new lr("DAEMON_REQUEST_FAILED",e.message,{cause:e}):new lr("DAEMON_REQUEST_FAILED",void 0,{cause:e}),F=e=>{if(e?.runtimeKey&&e.runtimeKey!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request")},Vr=(e,t,r)=>{const o=Ze(e,t);if(!r||!o||r!==o)throw new L("STALE_STREAM_EPOCH","The Pi runtime restarted before this send could be verified.",409);return r},qi=5e3,Es=32,be=new Map,Jr=new Map,Gi=new Map,zu=(e,t)=>`${e}
6
- ${t?.trim()??""}`,io=e=>Gi.get(e)??0,Yr=e=>{Gi.set(e,io(e)+1);const t=`${e}
7
- `;for(const r of[...be.keys()])r.startsWith(t)&&be.delete(r)},qu=(e,t,r)=>{if(be.size>=Es){const o=Date.now();for(const[n,a]of be)o-a.settledAt>=qi&&be.delete(n);for(;be.size>=Es;){const n=be.keys().next().value;if(typeof n!="string")break;be.delete(n)}}be.set(e,{response:t,settledAt:r})};class Gu{currentDirectory;setDirectory(t){this.currentDirectory=t}getDirectory(){return this.currentDirectory}async health(t){F(t);const r=await bo(void 0,t?.runtimeKey);return r.state==="ready"?{protocolVersion:r.protocolVersion,state:"ready",capabilities:r.capabilities,...r.streamEpoch?{streamEpoch:r.streamEpoch}:{}}:{protocolVersion:r.protocolVersion,state:"unavailable",capabilities:r.capabilities,...r.error?{error:r.error}:{}}}async listProjects(t){return F(t),y("/api/pi/projects",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async selectProject(t,r){return F(r),y("/api/pi/projects/select",{method:"POST",body:{directory:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listSessions(t){F(t);const r=t?.directory??this.currentDirectory;return y("/api/pi/sessions",{method:"GET",...r?{query:{directory:r}}:{},...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async listPendingInput(t){F(t);const r=await y("/api/pi/sessions/pending-input",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}});if(!ju(r))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed pending-input list");return r}async createSession(t,r){return F(r),y("/api/pi/sessions",{method:"POST",body:t,timeoutMs:Pt,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSession(t,r){F(r);const o=r?.directory??this.currentDirectory;return y(`/api/pi/sessions/${encodeURIComponent(t)}`,{method:"GET",timeoutMs:Pt,...o?{query:{directory:o}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSessionMessages(t,r,o){F(o);const n=o?.directory??this.currentDirectory;return y(`/api/pi/sessions/${encodeURIComponent(t)}/messages`,{method:"GET",timeoutMs:Pt,query:{...n?{directory:n}:{},...r.before?{before:r.before}:{},...r.limit!==void 0?{limit:r.limit}:{}},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async renameSession(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}`,{method:"PATCH",body:{sessionId:t.sessionId,title:t.title},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async discardDraftSession(t,r){return F(r),(await y(`/api/pi/sessions/${encodeURIComponent(t)}/discard-draft`,{method:"POST",...r?.directory?{query:{directory:r.directory}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}))?.discarded===!0}async deleteSession(t,r){F(r);try{return await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}`,{method:"DELETE",...r?.directory?{query:{directory:r.directory}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}),!0}catch(o){if(o instanceof L&&o.status===404)return!0;throw o}}async archiveSession(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/archive`,{method:"POST",body:{sessionId:t.sessionId,archived:t.archived,...r?.directory?{directory:r.directory}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSessionShelf(t){F(t);const r=await y("/api/pi/session-shelf",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}});if(!uu(r))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed session shelf");return r}async setSessionShelf(t,r){F(r);const{sessionId:o,...n}=t,s=(await y(`/api/pi/sessions/${encodeURIComponent(o)}/shelf`,{method:"POST",body:{...n,...r?.directory?{directory:r.directory}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}))?.entry;if(s!==null&&!Hi(s))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed session shelf entry");return s}async getSessionTree(t,r){return F(r),y(`/api/pi/sessions/${encodeURIComponent(t)}/tree`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async navigateSession(t,r,o){return F(o),y(`/api/pi/sessions/${encodeURIComponent(t)}/navigate`,{method:"POST",body:{messageId:r},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async forkSession(t,r){return F(r),y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/fork`,{method:"POST",timeoutMs:Pt,body:{sessionId:t.sessionId,...t.messageId?{messageId:t.messageId}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async cloneSession(t,r){return F(r),y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/clone`,{method:"POST",body:t,timeoutMs:Pt,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async sendPrompt(t,r){return this.sendWithReceipt("prompt",t,`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/prompt`,r)}async sendSteer(t,r){return this.sendWithReceipt("steer",t,`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/steer`,r)}async sendFollowUp(t,r){return this.sendWithReceipt("followUp",t,`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/follow-up`,r)}async getSendReceipt(t,r){const o=r?.runtimeKey??D();F({...r,runtimeKey:o});const n=Vr(o,t.sessionId,t.streamEpoch??r?.streamEpoch??Ze(o,t.sessionId)),a=r?.directory??this.currentDirectory,s=await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/send-receipt`,{method:"POST",body:{kind:t.kind,operationId:t.operationId,streamEpoch:n},...a?{query:{directory:a}}:{},runtimeKey:o});if(F({...r,runtimeKey:o}),Vr(o,t.sessionId,n),!s||typeof s!="object")throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send receipt");const i=s.status;if(i==="accepted"){const c=s.receipt;if(!Zo(c))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send receipt");return{status:"accepted",receipt:c}}if(i==="pending"||i==="expired"||i==="unknown")return{status:i};throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send receipt")}async sendWithReceipt(t,r,o,n){const a=n?.runtimeKey??D();let s;try{F({...n,runtimeKey:a}),s=Vr(a,r.sessionId,n?.streamEpoch??Ze(a,r.sessionId))}catch(c){throw en(c)}const i=n?.directory??this.currentDirectory;try{const c=await y(o,{method:"POST",body:{...r,streamEpoch:s},...i?{query:{directory:i}}:{},runtimeKey:a,retry:!1,timeoutMs:Pt});if(!Zo(c))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send response");return F({...n,runtimeKey:a}),Vr(a,r.sessionId,s),c}catch(c){if(c instanceof L&&c.code==="STALE_STREAM_EPOCH")throw en(c);if($u(c))throw c;const d=r.operationId;if(typeof d=="string"&&d.length>0)try{F({...n,runtimeKey:a});const l=this.getSendReceipt;if(!l)throw new L("DAEMON_UNAVAILABLE","Send receipt lookup unavailable");const u=await l.call(this,{sessionId:r.sessionId,kind:t,operationId:d,streamEpoch:s},{...n,runtimeKey:a,streamEpoch:s});if(F({...n,runtimeKey:a}),typeof u=="object"&&u!==null&&u.status==="accepted"&&Zo(u.receipt))return u.receipt}catch{}throw en(c)}}async abortSession(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/abort`,{method:"POST",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setSessionModel(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/model`,{method:"POST",body:{sessionId:t.sessionId,model:t.model},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setSessionThinking(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/thinking`,{method:"POST",body:{sessionId:t.sessionId,thinking:t.thinking},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async compactSession(t,r){if(F(r),(await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/compact`,{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})).accepted!==!0)throw new L("DAEMON_PROTOCOL_MISMATCH")}async runBash(t,r){F(r);const o=await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/bash`,{method:"POST",body:{command:t.command,...t.excludeFromContext?{excludeFromContext:!0}:{},...t.clientId?{clientId:t.clientId}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}});if(o?.accepted!==!0||typeof o.id!="string")throw new L("DAEMON_PROTOCOL_MISMATCH");return{id:o.id}}async abortBash(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/bash/abort`,{method:"POST",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listProviders(t){return F(t),y("/api/pi/providers",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async listEngines(t){return F(t),y("/api/pi/engines",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async refreshProviders(t){return F(t),y("/api/pi/providers/refresh",{method:"POST",...t?.directory?{body:{directory:t.directory}}:{body:void 0},...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async getProviderStatus(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t)}/status`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async loginProvider(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/login`,{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getProviderLogin(t,r,o){return F(o),y(`/api/pi/providers/${encodeURIComponent(t)}/login/${encodeURIComponent(r)}`,{method:"GET",...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async respondProviderLogin(t,r,o,n){return F(n),y(`/api/pi/providers/${encodeURIComponent(t)}/login/${encodeURIComponent(r)}/respond`,{method:"POST",body:{value:o},...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}})}async logoutProvider(t,r){F(r),await y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/logout`,{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getProviderConfig(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t)}/config`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setProviderModels(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/models`,{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async addProviderModel(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/models`,{method:"POST",body:t.model,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSandboxStatus(t){return F(t),y("/api/pi/sandbox",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async recheckSandbox(t){return F(t),y("/api/pi/sandbox/recheck",{method:"POST",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async listProjectSandboxes(t){return F(t),y("/api/pi/sandbox/projects",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async getSandboxDefaults(t){return F(t),(await y("/api/pi/sandbox/defaults",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})).defaults}async setSandboxDefaults(t,r){return F(r),y("/api/pi/sandbox/defaults",{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setProjectSandbox(t,r,o){return F(o),(await y(`/api/pi/sandbox/projects/${encodeURIComponent(t)}`,{method:"PUT",body:r,...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})).project}async getSandboxProfile(t){return F(t),(await y("/api/pi/sandbox/profile",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})).profile}async saveSandboxProfile(t,r){return F(r),(await y("/api/pi/sandbox/profile",{method:"PUT",body:{content:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})).profile}async resetSandboxProfile(t){return F(t),(await y("/api/pi/sandbox/profile",{method:"DELETE",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})).profile}async getSettings(t){return F(t),y("/api/pi/settings",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async setPiSettings(t,r){return F(r),y("/api/pi/settings/pi",{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setPiChamberDefaults(t,r){return F(r),y("/api/pi/settings/defaults",{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listResources(t,r){const o=typeof t=="string"?r:t,n=typeof t=="string"?t:void 0;F(o);const a=o?.runtimeKey??D(),s=zu(a,n),i=io(a);if(o?.reload!==!0){const m=be.get(s);if(m&&Date.now()-m.settledAt<qi)return structuredClone(m.response)}const c=Jr.get(s);if(c&&c.revision===i)return structuredClone(await c.promise);const d=Date.now(),l=io(a),u={},f=(async()=>{try{const m=await y("/api/pi/resources",{method:"GET",...n?{query:{directory:n}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}});if(D()===a&&io(a)===l){const g=be.get(s);(!g||g.settledAt<=d)&&qu(s,m,Date.now())}return m}finally{Jr.get(s)?.promise===u.promise&&Jr.delete(s)}})();return u.promise=f,Jr.set(s,{revision:l,promise:f}),structuredClone(await f)}async listCommands(t,r){return F(r),y("/api/pi/commands",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listSnippets(t,r){return F(r),y("/api/pi/snippets",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async createSnippet(t,r){return F(r),y("/api/pi/snippets",{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async updateSnippet(t,r,o,n){return F(n),y(`/api/pi/snippets/${encodeURIComponent(t)}`,{method:"PUT",body:r,...o?{query:{directory:o}}:{},...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}})}async deleteSnippet(t,r,o){return F(o),y(`/api/pi/snippets/${encodeURIComponent(t)}`,{method:"DELETE",...r?{query:{directory:r}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async updateResource(t,r){F(r);const o=r?.runtimeKey??D(),n=t.directory??r?.directory,a=await y(`/api/pi/resources/${encodeURIComponent(t.resourceId)}`,{method:"PUT",body:t,...n?{query:{directory:n}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}});return Yr(o),a}async createPromptTemplate(t,r,o){const n=r??t.directory??o?.directory;F(o);const a=o?.runtimeKey??D(),s=await y("/api/pi/resources/prompts",{method:"POST",body:t,...n?{query:{directory:n}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}});return Yr(a),s}async updatePromptTemplate(t,r,o,n){F(n);const a=n?.runtimeKey??D(),s=o??r.directory??n?.directory,i=await y(`/api/pi/resources/prompts/${encodeURIComponent(t)}`,{method:"PUT",body:r,...s?{query:{directory:s}}:{},...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}});return Yr(a),i}async deletePromptTemplate(t,r,o){F(o);const n=o?.runtimeKey??D(),a=r??o?.directory,s=await y(`/api/pi/resources/prompts/${encodeURIComponent(t)}`,{method:"DELETE",...a?{query:{directory:a}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}});return Yr(n),s}async createAttachment(t,r){return F(r),(await y("/api/pi/attachments",{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})).attachment}async uploadAttachment(t,r,o){F(o);const n=await cu("/api/pi/attachments",t,r);if(!n.ok){const i=(await n.json().catch(()=>null))?.error??{code:"ATTACHMENT_FAILED"};throw new L(i.code,i.message,n.status)}const a=await n.json();return F(o),a.attachment}async deleteAttachment(t,r){F(r),await y(`/api/pi/attachments/${encodeURIComponent(t)}`,{method:"DELETE",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listPlugins(t,r){return F(r),y("/api/pi/plugins",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setPluginEnabled(t,r,o){return F(o),y(`/api/pi/plugins/${encodeURIComponent(t)}`,{method:"PUT",body:{enabled:r},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async setPluginState(t,r,o){return F(o),y(`/api/pi/plugins/${encodeURIComponent(t)}/state`,{method:"PUT",body:r,...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async getPluginSessionState(t,r){return F(r),y(`/api/pi/plugins/sessions/${encodeURIComponent(t)}`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setPluginSessionState(t,r,o,n){return F(n),y(`/api/pi/plugins/${encodeURIComponent(t)}/sessions/${encodeURIComponent(r)}`,{method:"PUT",body:o,...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}})}async listExtensions(t,r){return F(r),y("/api/pi/extensions",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getExtensionConfig(t,r){return F(r),y("/api/pi/extensions/config",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setExtensionConfig(t,r,o){return F(o),y(`/api/pi/extensions/config/${encodeURIComponent(t)}`,{method:"PUT",body:r,retry:!1,...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async removeExtensionPackage(t,r,o){return F(o),y(`/api/pi/extensions/packages/${encodeURIComponent(t)}`,{method:"DELETE",retry:!1,...r?{query:{directory:r}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async installExtensionPackage(t,r){return F(r),y("/api/pi/extensions/packages",{method:"POST",body:t,retry:!1,timeoutMs:As,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async updateExtensionPackage(t,r,o){return F(o),y(`/api/pi/extensions/packages/${encodeURIComponent(t)}/update`,{method:"POST",retry:!1,timeoutMs:As,...r?{query:{directory:r}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async searchMarketplace(t,r){F(r);const o={};return t.query&&(o.q=t.query),t.from&&(o.from=String(t.from)),t.pichamberOnly&&(o.pichamber="1"),y("/api/pi/marketplace/search",{method:"GET",query:o,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getMarketplaceFeatured(t){return F(t),y("/api/pi/marketplace/featured",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async getMarketplacePackage(t,r){return F(r),y("/api/pi/marketplace/package",{method:"GET",query:{name:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getMarketplaceVersions(t,r){return F(r),y("/api/pi/marketplace/versions",{method:"GET",query:{names:t.join(",")},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getExtensionPalette(t,r){return F(r),y("/api/pi/extensions/palette",{method:"POST",body:{terminal:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async respondToExtensionDialog(t,r){F(r),await y("/api/pi/extensions/respond",{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async runExtensionControl(t,r){F(r);const o={...t,...r?.directory?{directory:r.directory}:{}};return{ran:(await y("/api/pi/extensions/control",{method:"POST",body:o,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}))?.ran===!0}}async sendExtensionSurface(t,r,o){F(o);const{sessionId:n,...a}=r;await y(`/api/pi/sessions/${encodeURIComponent(n)}/extensions/custom/${t}`,{method:"POST",body:a,...t==="input"||t==="close"?{retry:!1}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async updateExtensionDraft(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/editor-draft`,{method:"POST",body:{text:t.text,revision:t.revision,...t.directory?{directory:t.directory}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}}const bt=new Gu;async function Wu(e){return(await Ju(e)).home}let Cn=null,Fr=null;const Eb=()=>{Cn=null,Fr=null},Vu=async()=>{let e=null,t=null;try{const r=await b("/api/fs/home",{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(r.ok){const o=await r.json().catch(()=>null);typeof o?.home=="string"&&o.home.trim().length>0&&(e=o.home.trim()),typeof o?.pichamberDataDir=="string"&&o.pichamberDataDir.trim().length>0&&(t=o.pichamberDataDir.trim())}}catch{}return{home:e,pichamberDataDir:t}},Ju=async e=>{const t=D();if(!e?.fresh){const o=Cn;if(o&&o.key===t)return o.state;const n=Fr;if(n&&n.key===t)return n.promise}const r=(async()=>{const o=await Vu();return!e?.fresh&&o.home&&D()===t&&(Cn={key:t,state:o}),o})();e?.fresh||(Fr={key:t,promise:r});try{return await r}finally{Fr?.promise===r&&(Fr=null)}};async function wb(e,t){if(!e||e.trim().length===0)return[];const r={path:e},o=Ie().api("/api/fs/list",r),n=await b(o);if(!n.ok)return[];const a=await n.json();return Array.isArray(a.entries)?a.entries:[]}async function Yu(e,t){const r=t?.directory||"";if(!r)return[];const o={directory:r,query:e};t?.limit&&(o.limit=t.limit),t?.includeHidden&&(o.includeHidden=!0),t?.respectGitignore!==void 0&&(o.respectGitignore=t.respectGitignore),t?.type&&(o.type=t.type);const n=Ie().api("/api/fs/find",o),a=await b(n);if(!a.ok)return[];const s=await a.json();return Array.isArray(s.files)?s.files:[]}async function Bb(e=""){try{const t=await b("/api/fs/pick-directory",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({path:e||void 0})}),r=await t.json().catch(()=>null);return r?.cancelled===!0?{status:"cancelled"}:t.status===501?{status:"unavailable",error:typeof r?.error=="string"?r.error:"Folder picker is not available."}:t.ok?typeof r?.path=="string"&&r.path.trim()?{status:"picked",path:r.path.trim()}:{status:"failed",error:"Failed to select directory."}:{status:"failed",error:typeof r?.error=="string"?r.error:"Failed to select directory."}}catch(t){return{status:"failed",error:t instanceof Error?t.message:"Failed to select directory."}}}const Cb={explore:{label:"Explore the codebase",icon:"compass-3",text:"Explore this codebase and explain how it works. Start with an overview, then key files and data flow."},plan:{label:"Plan the work",icon:"list-check-2",text:"Plan this work before coding. Break it into small steps, list files to change, and call out risks."},review:{label:"Review my changes",icon:"file-search",text:"Review my current changes for bugs, edge cases, and regressions. Suggest specific fixes."},"find-bugs":{label:"Find bugs",icon:"bug",text:"Find bugs in the current selection. List each issue with what is wrong and a minimal fix."},"write-tests":{label:"Write tests",icon:"flask",text:"Write tests for the current selection. Cover the happy path, edge cases, and failure modes."}},Xu=e=>typeof e=="string"&&(e==="explore"||e==="plan"||e==="review"||e==="find-bugs"||e==="write-tests"),vb=[{type:"text",key:"explore"},{type:"text",key:"plan"},{type:"text",key:"review"},{type:"text",key:"find-bugs"},{type:"text",key:"write-tests"}],kb="book-open",Qu=/^[^\s/]+$/,ws=e=>e.type==="prompt"?`prompt:${e.name}`:`text:${e.key}`,Db=(e,t)=>e.type!==t.type?!1:e.type==="prompt"&&t.type==="prompt"?e.name===t.name:e.type==="text"&&t.type==="text"?e.key===t.key:!1,Sb=e=>{const t=e.replace(/^\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e},Ca=e=>{if(!Array.isArray(e))return[];const t=[],r=new Set;for(const o of e){if(!o||typeof o!="object")continue;const n=o;if(n.type==="text"){if(!Xu(n.key))continue;const d={type:"text",key:n.key},l=ws(d);if(r.has(l))continue;r.add(l),t.push(d);continue}if(n.type!=="prompt")continue;const a=typeof n.name=="string"?n.name.trim():"";if(!a||!Qu.test(a))continue;const s=n.scope==="global"||n.scope==="project"?n.scope:void 0,i=s?{type:"prompt",name:a,scope:s}:{type:"prompt",name:a},c=ws(i);r.has(c)||(r.add(c),t.push(i))}return t},Zu=e=>{let t,r=-1;for(const o of e){const a=(o.location==="project"?2:o.location==="global"?1:0)+(o.editable?.5:0);a>r&&(t=o,r=a)}return t},Mb=e=>{const t=new Map;for(const o of e){const n=t.get(o.name)??[];n.push(o),t.set(o.name,n)}const r=new Map;for(const[o,n]of t){const a=Zu(n);a&&r.set(o,a)}return r},Tb=(e,t)=>{const r=new Set,o=s=>s.filter(i=>{const c=i.insertText.trim();return r.has(c)?!1:(r.add(c),!0)}),n=o(e),a=o(t);return{project:n,global:a}},ef={markdown:"0.9375rem",code:"0.8125rem",uiHeader:"0.9375rem",uiLabel:"0.8750rem",meta:"0.8125rem",micro:"0.75rem",settingsPageTitle:"1.125rem"};function Bs(e){return`--text-${e.replace(/([A-Z])/g,"-$1").toLowerCase()}`}const Xr={semanticMarkdown:{fontSize:"var(--text-markdown)"},semanticCode:{fontSize:"var(--text-code)"},uiHeader:{fontSize:"var(--text-ui-header)"},uiLabel:{fontSize:"var(--text-ui-label)"},meta:{fontSize:"var(--text-meta)"},micro:{fontSize:"var(--text-micro)"},ui:{button:{fontSize:"var(--text-ui-label)",lineHeight:"var(--ui-button-line-height)",letterSpacing:"var(--ui-button-letter-spacing)",fontWeight:"var(--ui-button-font-weight)"},buttonSmall:{fontSize:"var(--text-meta)",lineHeight:"var(--ui-button-small-line-height)",letterSpacing:"var(--ui-button-small-letter-spacing)",fontWeight:"var(--ui-button-small-font-weight)"},buttonLarge:{fontSize:"var(--text-ui-label)",lineHeight:"var(--ui-button-large-line-height)",letterSpacing:"var(--ui-button-large-letter-spacing)",fontWeight:"var(--ui-button-large-font-weight)"},label:{fontSize:"var(--text-meta)",lineHeight:"var(--ui-label-line-height)",letterSpacing:"var(--ui-label-letter-spacing)",fontWeight:"var(--ui-label-font-weight)"},caption:{fontSize:"var(--text-micro)",lineHeight:"var(--ui-caption-line-height)",letterSpacing:"var(--ui-caption-letter-spacing)",fontWeight:"var(--ui-caption-font-weight)"},badge:{fontSize:"var(--text-micro)",lineHeight:"var(--ui-badge-line-height)",letterSpacing:"var(--ui-badge-letter-spacing)",fontWeight:"var(--ui-badge-font-weight)"},tooltip:{fontSize:"var(--text-micro)",lineHeight:"var(--ui-tooltip-line-height)",letterSpacing:"var(--ui-tooltip-letter-spacing)",fontWeight:"var(--ui-tooltip-font-weight)"},input:{fontSize:"var(--text-ui-label)",lineHeight:"var(--ui-input-line-height)",letterSpacing:"var(--ui-input-letter-spacing)",fontWeight:"var(--ui-input-font-weight)"},helperText:{fontSize:"var(--text-meta)",lineHeight:"var(--ui-helper-text-line-height)",letterSpacing:"var(--ui-helper-text-letter-spacing)",fontWeight:"var(--ui-helper-text-font-weight)"}},code:{inline:{fontSize:"var(--text-code)",lineHeight:"var(--code-inline-line-height)",letterSpacing:"var(--code-inline-letter-spacing)",fontWeight:"var(--code-inline-font-weight)"},block:{fontSize:"var(--text-code)",lineHeight:"var(--code-block-line-height)",letterSpacing:"var(--code-block-letter-spacing)",fontWeight:"var(--code-block-font-weight)"},lineNumbers:{fontSize:"var(--text-micro)",lineHeight:"var(--code-line-numbers-line-height)",letterSpacing:"var(--code-line-numbers-letter-spacing)",fontWeight:"var(--code-line-numbers-font-weight)"}},markdown:{body:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-body-line-height)",letterSpacing:"var(--markdown-body-letter-spacing)",fontWeight:"var(--markdown-body-font-weight)"},bodySmall:{fontSize:"var(--text-meta)",lineHeight:"var(--markdown-body-small-line-height)",letterSpacing:"var(--markdown-body-small-letter-spacing)",fontWeight:"var(--markdown-body-small-font-weight)"},bodyLarge:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-body-large-line-height)",letterSpacing:"var(--markdown-body-large-letter-spacing)",fontWeight:"var(--markdown-body-large-font-weight)"},blockquote:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-blockquote-line-height)",letterSpacing:"var(--markdown-blockquote-letter-spacing)",fontWeight:"var(--markdown-blockquote-font-weight)"},list:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-list-line-height)",letterSpacing:"var(--markdown-list-letter-spacing)",fontWeight:"var(--markdown-list-font-weight)"},link:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-link-line-height)",letterSpacing:"var(--markdown-link-letter-spacing)",fontWeight:"var(--markdown-link-font-weight)"},code:{fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-line-height)",letterSpacing:"var(--markdown-code-letter-spacing)",fontWeight:"var(--markdown-code-font-weight)"},codeBlock:{fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-block-line-height)",letterSpacing:"var(--markdown-code-block-letter-spacing)",fontWeight:"var(--markdown-code-block-font-weight)"}},tool:{collapsed:{fontSize:"var(--text-code)",lineHeight:"var(--code-block-line-height)",letterSpacing:"var(--code-block-letter-spacing)",fontWeight:"var(--code-block-font-weight)"},popup:{fontSize:"var(--text-code)",lineHeight:"var(--code-block-line-height)",letterSpacing:"var(--code-block-letter-spacing)",fontWeight:"var(--code-block-font-weight)"},inline:{fontSize:"var(--text-code)",lineHeight:"var(--code-inline-line-height)",letterSpacing:"var(--code-inline-letter-spacing)",fontWeight:"var(--code-inline-font-weight)"}}},tn={padding:{collapsed:"0.375rem",popup:"0.75rem",popupContainer:"1rem"},backgroundOpacity:{muted:"30",mutedAlt:"50"},getCollapsedStyles:()=>({...Xr.tool.collapsed,background:"transparent",backgroundColor:"transparent",margin:0,padding:tn.padding.collapsed,borderRadius:0}),getPopupStyles:()=>({...Xr.tool.popup,background:"transparent",backgroundColor:"transparent",margin:0,padding:tn.padding.popup,borderRadius:"0.75rem"}),getPopupContainerStyles:()=>({...Xr.tool.popup,background:"transparent",backgroundColor:"transparent",margin:0,padding:tn.padding.popupContainer,borderRadius:"0.5rem",overflowX:"auto"}),getInlineStyles:()=>({...Xr.tool.inline})},tf=[{id:"inter",label:"Inter",description:"Modern UI sans with excellent readability at small sizes.",stack:'"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Inter",packageName:"@fontsource/inter",filePrefix:"inter",weights:[400,500,600]}},{id:"geist-sans",label:"Geist Sans",description:"Crisp sans-serif with a technical interface feel.",stack:'"Geist Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Geist Sans",packageName:"@fontsource/geist-sans",filePrefix:"geist-sans",weights:[400,500,600]}},{id:"atkinson-hyperlegible",label:"Atkinson Hyperlegible",description:"Accessibility-focused sans-serif optimized for character distinction.",stack:'"Atkinson Hyperlegible", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Atkinson Hyperlegible",packageName:"@fontsource/atkinson-hyperlegible",filePrefix:"atkinson-hyperlegible",weights:[400,700]}},{id:"source-sans-3",label:"Source Sans 3",description:"Adobe sans-serif tuned for clean, readable interfaces.",stack:'"Source Sans 3", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Source Sans 3",packageName:"@fontsource/source-sans-3",filePrefix:"source-sans-3",weights:[400,500,600]}},{id:"roboto",label:"Roboto",description:"Familiar Material-style sans-serif with broad UI usage.",stack:'"Roboto", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Roboto",packageName:"@fontsource/roboto",filePrefix:"roboto",weights:[400,500,600]}},{id:"noto-sans",label:"Noto Sans",description:"Readable sans-serif with strong international coverage.",stack:'"Noto Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Noto Sans",packageName:"@fontsource/noto-sans",filePrefix:"noto-sans",weights:[400,500,600]}},{id:"dm-sans",label:"DM Sans",description:"Modern product UI sans-serif with friendly proportions.",stack:'"DM Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"DM Sans",packageName:"@fontsource/dm-sans",filePrefix:"dm-sans",weights:[400,500,600]}},{id:"manrope",label:"Manrope",description:"Polished geometric sans-serif for modern app interfaces.",stack:'"Manrope", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Manrope",packageName:"@fontsource/manrope",filePrefix:"manrope",weights:[400,500,600]}},{id:"system",label:"System",description:"Native operating system interface font.",stack:'"SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif'}],rf=[{id:"jetbrains-mono",label:"JetBrains Mono",description:"Developer-focused monospace with strong punctuation clarity.",stack:'"JetBrains Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"JetBrains Mono",packageName:"@fontsource/jetbrains-mono",filePrefix:"jetbrains-mono",weights:[400,500,600]}},{id:"fira-code",label:"Fira Code",description:"Readable coding font with ligature support.",stack:'"Fira Code", "SFMono-Regular", "Menlo", monospace',source:{family:"Fira Code",packageName:"@fontsource/fira-code",filePrefix:"fira-code",weights:[400,500,600]}},{id:"geist-mono",label:"Geist Mono",description:"Sharp monospace pair for Geist Sans.",stack:'"Geist Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"Geist Mono",packageName:"@fontsource/geist-mono",filePrefix:"geist-mono",weights:[400,500,600]}},{id:"commit-mono",label:"Commit Mono",description:"Code-oriented monospace with polished editor ergonomics.",stack:'"Commit Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"Commit Mono",packageName:"@fontsource/commit-mono",filePrefix:"commit-mono",weights:[400,500,600]}},{id:"source-code-pro",label:"Source Code Pro",description:"Adobe monospace designed for source code readability.",stack:'"Source Code Pro", "SFMono-Regular", "Menlo", monospace',source:{family:"Source Code Pro",packageName:"@fontsource/source-code-pro",filePrefix:"source-code-pro",weights:[400,500,600]}},{id:"cascadia-code",label:"Cascadia Code",description:"Microsoft coding font popular in terminals and editors.",stack:'"Cascadia Code", "SFMono-Regular", "Menlo", monospace',source:{family:"Cascadia Code",packageName:"@fontsource/cascadia-code",filePrefix:"cascadia-code",weights:[400,500,600]}},{id:"roboto-mono",label:"Roboto Mono",description:"Neutral monospace companion to Roboto.",stack:'"Roboto Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"Roboto Mono",packageName:"@fontsource/roboto-mono",filePrefix:"roboto-mono",weights:[400,500,600]}},{id:"iosevka",label:"Iosevka",description:"Compact monospace for dense code and terminal layouts.",stack:'"Iosevka", "SFMono-Regular", "Menlo", monospace',source:{family:"Iosevka",packageName:"@fontsource/iosevka",filePrefix:"iosevka",weights:[400,500,600]}},{id:"system-mono",label:"System Mono",description:"Native operating system monospace font.",stack:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'}],Wi=e=>Object.fromEntries(e.map(t=>[t.id,t])),of=Wi(tf),nf=Wi(rf),af="system",sf="system-mono",Vi=e=>typeof e=="string"&&e in of,Ji=e=>typeof e=="string"&&e in nf,rn="pichamber.pwaName",vn="pichamber.mobileKeyboardMode",Pb="pichamber.pwaRecentSessions",cf=["native","resize-content"];function df(e,t="resize-content"){return typeof e=="string"&&cf.includes(e)?e:t}const lf=64;function Yi(e,t){if(typeof e!="string")return t;const r=e.trim().replace(/\s+/g," ");return r?r.slice(0,lf):t}const Rb=()=>!0;function va(e,t="resize-content"){return df(e,t)??void 0}const uf=()=>{if(typeof window>"u")return"resize-content";try{return va(localStorage.getItem(vn))}catch{return"resize-content"}},ff=e=>{const t=va(e);if(typeof window<"u")try{t==="resize-content"?localStorage.removeItem(vn):localStorage.setItem(vn,t)}catch{}return t},K=e=>{if(!e)return"";const t=e.replace(/\\/g,"/"),r=t.startsWith("//");let o=t.replace(/\/+$/g,"").replace(/\/+/g,"/");return r&&!o.startsWith("//")&&(o=`/${o}`),o||(t.startsWith("/")?"/":"")},mf=["workspace","folder","timeline","threads"],gf="workspace",Xi=e=>typeof e=="string"&&mf.includes(e),pf=365,Vt=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=pf,Ib=e=>e===1?"1 session":`${e} sessions`,Se=20,hf=8,Cs=4096,Ff=2160*60*6e4,H=e=>{if(!e)return"";const t=e.replace(/\\/g,"/"),r=t.startsWith("//");let o=t.replace(/\/+/g,"/");r&&!o.startsWith("//")&&(o=`/${o}`);const n=o==="/",a=/^[A-Za-z]:\/$/.test(o);return!n&&!a&&(o=o.replace(/\/+$/,"")),o},Xe=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,et=(e,t)=>{const r=H(t),o=H(e);if(!r||!o)return!1;const n=Xe(r),a=Xe(o);return a===n||a.startsWith(`${n}/`)},ur=e=>{if(!e||typeof e!="object")return{};const t=e,r={};for(const[o,n]of Object.entries(t)){const a=H(o);if(!a||!n||typeof n!="object")continue;const s=n,i=Array.isArray(s.openPaths)?Array.from(new Set(s.openPaths.filter(m=>typeof m=="string").map(m=>H(m)).filter(m=>m.length<=Cs&&et(m,a)))).slice(-50):[],c=Array.isArray(s.expandedPaths)?Array.from(new Set(s.expandedPaths.filter(m=>typeof m=="string").map(m=>H(m)).filter(m=>m.length<=Cs&&et(m,a)))).slice(-500):[],d=typeof s.selectedPath=="string"?H(s.selectedPath):null,l=d&&et(d,a)?d:i[0]??null,u=typeof s.touchedAt=="number"&&Number.isFinite(s.touchedAt)?s.touchedAt:Date.now();if(Date.now()-u>Ff)continue;const f=r[a];if(f){const m=Array.from(new Set([...f.openPaths,...i])),g=Array.from(new Set([...f.expandedPaths,...c])),h=f.selectedPath??l??m[0]??null;r[a]={openPaths:m,selectedPath:h,expandedPaths:g,touchedAt:Math.max(f.touchedAt,u)};continue}r[a]={openPaths:i,selectedPath:l,expandedPaths:c,touchedAt:u}}return Me(r,Se)},Me=(e,t)=>{const r=Object.entries(e);if(r.length<=t)return e;r.sort((n,a)=>(a[1]?.touchedAt??0)-(n[1]?.touchedAt??0));const o={};for(const[n,a]of r.slice(0,t))o[n]=a;return o},Rt=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},yf=Ir()(_r(ea((e,t)=>({byRoot:{},activeRuntimeKey:D(),runtimeSnapshots:{},resetForRuntimeSwitch:r=>{e(o=>{const n={...o.runtimeSnapshots,[o.activeRuntimeKey]:{byRoot:ur(o.byRoot),updatedAt:Date.now()}};return{activeRuntimeKey:r,runtimeSnapshots:n,byRoot:ur(n[r]?.byRoot)}})},addOpenPath:(r,o,n)=>{const a=H((r||"").trim()),s=H((o||"").trim());!a||!s||!n?.allowOutsideRoot&&!et(s,a)||e(i=>{const c=i.byRoot[a],d=Rt(c),l=d.openPaths.includes(s),u=l?d.openPaths:[...d.openPaths,s],f=d.selectedPath??s;if(c&&l&&c.selectedPath===f)return i;const m={...i.byRoot,[a]:{...d,openPaths:u,selectedPath:f}};return{byRoot:Me(m,Se)}})},removeOpenPath:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||e(s=>{const i=s.byRoot[n];if(!i)return s;const c=Xe(a),d=g=>Xe(g)===c,l=i.selectedPath?d(i.selectedPath):!1;if(!i.openPaths.some(d)&&!l)return s;const u=i.openPaths.filter(g=>!d(g)),f=l?u[0]??null:i.selectedPath,m={...s.byRoot,[n]:{...i,openPaths:u,selectedPath:f,touchedAt:Date.now()}};return{byRoot:Me(m,Se)}})},removeOpenPathsByPrefix:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||e(s=>{const i=s.byRoot[n];if(!i)return s;const c=Xe(a),d=c.endsWith("/")?c:`${c}/`,l=g=>{const h=Xe(g);return h===c||h.startsWith(d)},u=i.openPaths.filter(g=>!l(g));if(u.length===i.openPaths.length)return s;const f=i.selectedPath&&l(i.selectedPath)?u[0]??null:i.selectedPath,m={...s.byRoot,[n]:{...i,openPaths:u,selectedPath:f,touchedAt:Date.now()}};return{byRoot:Me(m,Se)}})},removeExpandedPathsByPrefix:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||e(s=>{const i=s.byRoot[n];if(!i)return s;const c=Xe(a),d=c.endsWith("/")?c:`${c}/`,l=i.expandedPaths.filter(f=>{const m=Xe(f);return m!==c&&!m.startsWith(d)});if(l.length===i.expandedPaths.length)return s;const u={...s.byRoot,[n]:{...i,expandedPaths:l,touchedAt:Date.now()}};return{byRoot:Me(u,Se)}})},setSelectedPath:(r,o,n)=>{const a=H((r||"").trim()),s=o?H(o.trim()):null;!a||s&&!n?.allowOutsideRoot&&!et(s,a)||e(i=>{const c=i.byRoot[a],d=Rt(c),l=s&&!d.openPaths.includes(s)?[...d.openPaths,s]:d.openPaths;if(c&&c.selectedPath===s&&l===c.openPaths)return i;const u={...i.byRoot,[a]:{...d,openPaths:l,selectedPath:s}};return{byRoot:Me(u,Se)}})},ensureSelectedPath:r=>{const o=H((r||"").trim());if(!o)return;const n=t().byRoot[o];if(!n||n.selectedPath)return;const a=n.openPaths[0]??null;a&&t().setSelectedPath(o,a)},toggleExpandedPath:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||!et(a,n)||e(s=>{const i=s.byRoot[n],c=Rt(i),l=c.expandedPaths.includes(a)?c.expandedPaths.filter(f=>f!==a):[...c.expandedPaths,a];if(i&&i.expandedPaths===l&&i.selectedPath===c.selectedPath&&i.openPaths===c.openPaths)return s;const u={...s.byRoot,[n]:{...c,expandedPaths:l}};return{byRoot:Me(u,Se)}})},collapseAllExpandedPaths:r=>{const o=H((r||"").trim());o&&e(n=>{const a=n.byRoot[o];if(!a||a.expandedPaths.length===0)return n;const s={...n.byRoot,[o]:{...Rt(a),expandedPaths:[]}};return{byRoot:Me(s,Se)}})},expandPath:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||!et(a,n)||e(s=>{const i=s.byRoot[n],c=Rt(i);if(c.expandedPaths.includes(a)&&i)return s;const l={...s.byRoot,[n]:{...c,expandedPaths:[...c.expandedPaths,a]}};return{byRoot:Me(l,Se)}})},expandPaths:(r,o)=>{const n=H((r||"").trim());if(!n||!o||o.length===0)return;const a=o.map(s=>H((s||"").trim())).filter(s=>s&&et(s,n));a.length!==0&&e(s=>{const i=s.byRoot[n],c=Rt(i),d=new Set(c.expandedPaths),l=a.filter(f=>!d.has(f));if(l.length===0)return s;const u={...s.byRoot,[n]:{...c,expandedPaths:[...c.expandedPaths,...l]}};return{byRoot:Me(u,Se)}})}}),{name:"files-view-tabs-store",version:3,storage:la(),migrate:(e,t)=>t<3||!e||typeof e!="object"?{byRoot:{},activeRuntimeKey:D(),runtimeSnapshots:{}}:e,partialize:e=>{const t={...e.runtimeSnapshots,[e.activeRuntimeKey]:{byRoot:ur(e.byRoot),updatedAt:Date.now()}},r=Object.fromEntries(Object.entries(t).sort(([,o],[,n])=>n.updatedAt-o.updatedAt).slice(0,hf).map(([o,n])=>[o,{byRoot:ur(n.byRoot),updatedAt:n.updatedAt}]));return{activeRuntimeKey:e.activeRuntimeKey,runtimeSnapshots:r}},merge:(e,t)=>{const r=e&&typeof e=="object"?e:{},o=r.runtimeSnapshots&&typeof r.runtimeSnapshots=="object"?r.runtimeSnapshots:{},n=D();return{...t,activeRuntimeKey:n,runtimeSnapshots:o,byRoot:ur(o[n]?.byRoot)}}}),{name:"files-view-tabs-store"})),ka=12,bf=4096,Af=200,Ef=/^[A-Za-z0-9_.:-]{1,120}$/,_o=()=>`page-${Math.random().toString(36).slice(2,10)}${Date.now().toString(36).slice(-4)}`,Mr=e=>{if(typeof e!="string")return null;const t=e.trim();return!t||t==="about:blank"?null:t.slice(0,bf)},Qi=e=>{if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t?t.slice(0,Af):null},Tr=e=>e==="server"||e==="device"?e:null,Zi=(e,t)=>t&&e.some(r=>r.id===t)?t:e[0]?.id??null,wf=(e,t)=>{const r=e&&typeof e=="object"?e:null,o=[],n=new Set;if(r&&Array.isArray(r.pages))for(const s of r.pages){if(!s||typeof s!="object")continue;const i=s,c=typeof i.id=="string"?i.id:"";if(!(!Ef.test(c)||n.has(c))&&(n.add(c),o.push({id:c,url:Mr(i.url),route:Tr(i.route),title:Qi(i.title)}),o.length>=ka))break}o.length===0&&o.push({id:t.tabId,url:Mr(t.url),route:t.route,title:null});const a=typeof r?.activePageId=="string"?r.activePageId:null;return{pages:o,activePageId:Zi(o,a)}},Bf=(e,t=_o)=>{const r=t();return{pages:[{id:r,url:Mr(e.url),route:Tr(e.route),title:null}],activePageId:r}},Cf=(e,t,r=_o)=>{const o=Mr(t.url),n=Tr(t.route),a=e.pages.find(l=>l.id===e.activePageId)??null,s=a&&(t.target==="current"||o!==null&&a.url===null||e.pages.length>=ka);if(a&&s)return{pages:e.pages.map(u=>u.id===a.id?{...u,url:o??u.url,route:n??u.route,title:o&&o!==u.url?null:u.title}:u),activePageId:a.id,pageId:a.id};const i={id:r(),url:o,route:n,title:null},c=a?e.pages.indexOf(a):e.pages.length-1;return{pages:[...e.pages.slice(0,c+1),i,...e.pages.slice(c+1)],activePageId:i.id,pageId:i.id}},vf=(e,t,r=_o)=>{if(e.pages.length>=ka)return null;const o={id:r(),url:null,route:"server",title:null,popupId:t.popupId},n=e.pages.findIndex(i=>i.id===t.openerPageId),a=n===-1?e.pages.length-1:n;return{pages:[...e.pages.slice(0,a+1),o,...e.pages.slice(a+1)],activePageId:o.id,pageId:o.id}},kf=(e,t,r=_o)=>{const o=e.pages.findIndex(s=>s.id===t);if(o===-1)return e;const n=e.pages.filter(s=>s.id!==t);if(n.length===0){const s={id:r(),url:null,route:e.pages[o].route,title:null};return{pages:[s],activePageId:s.id}}if(e.activePageId!==t)return{pages:n,activePageId:Zi(n,e.activePageId)};const a=n[Math.min(o,n.length-1)];return{pages:n,activePageId:a.id}},Df=(e,t)=>e.activePageId!==t&&e.pages.some(r=>r.id===t)?{...e,activePageId:t}:e,Sf=(e,t,r)=>{let o=!1;const n=e.pages.map(a=>{if(a.id!==t)return a;const s={...a};if(r.url!==void 0){const i=Mr(r.url);i&&i!==a.url&&(s.url=i)}return r.title!==void 0&&(s.title=Qi(r.title)),r.route!==void 0&&(s.route=Tr(r.route)??a.route),r.defaultRoute!==void 0&&s.route===null&&(s.route=Tr(r.defaultRoute)),r.popupId===null&&delete s.popupId,(s.url!==a.url||s.title!==a.title||s.route!==a.route||s.popupId!==a.popupId)&&(o=!0),o?s:a});return o?{...e,pages:n}:e},_b=e=>{if(e.title)return e.title;if(!e.url)return"New tab";try{return new URL(e.url).host||e.url}catch{return e.url}},Mf=380,Tf=380,Pf=1400,ec=12,vs=120,Rf=["git","file","diff","context","terminal","browser","preview","pull-requests","issues","extensions","agents"],If=K,co=e=>Number.isFinite(e)?Math.min(Pf,Math.max(Tf,Math.round(e))):Mf,_f=e=>{if(typeof e.width=="number"&&Number.isFinite(e.width))return co(e.width);if(!e.widthByMode||typeof e.widthByMode!="object")return;const t=e.widthByMode;for(const r of Rf){const o=t[r];if(typeof o=="number"&&Number.isFinite(o))return co(o)}for(const r of Object.values(t))if(typeof r=="number"&&Number.isFinite(r))return co(r)},Ao=e=>{if(typeof e!="string")return null;const t=e.trim();return t?t.replace(/\\/g,"/"):null},Eo=e=>{if(typeof e!="string")return null;const t=e.trim();return t?t.length>vs?t.slice(0,vs):t:null},Da=e=>e==="server"||e==="device"?e:null,Sa=e=>e==="all"||e==="working"||e==="staged"||e==="turn"||e==="branch"?e:null,xf=(e,t)=>(e==="file"||e==="preview")&&t||e,tc=(e,t,r)=>{if(e==="diff")return e;if(e==="browser")return Ma;if(typeof r=="string"){const o=r.trim();if(o)return o}return xf(e,t)},kn=(e,t)=>t===e?e:`${e}:${t}`,Ma="desktop-browser",rc=`browser:${Ma}`,Of=(e,t)=>{let r=!1;const o=e.tabs.map(n=>{if(n.id!==rc||!n.browser)return n;const a=t(n.browser);return a===n.browser?n:(r=!0,{...n,browser:{pages:a.pages,activePageId:a.activePageId}})});return r?{...e,tabs:o}:e},Ta=e=>{const t=Ao(e.targetPath),r=tc(e.mode,t,e.dedupeKey),o=kn(e.mode,r),n=e.mode==="browser";return{id:o,mode:e.mode,targetPath:n?null:t,dedupeKey:r,label:Eo(e.label),sessionTitleFallback:Eo(e.sessionTitleFallback),readOnly:e.readOnly===!0,stagedDiff:e.stagedDiff===!0,diffScope:Sa(e.diffScope)??(e.stagedDiff===!0?"staged":"working"),browser:n?Bf({url:t,route:Da(e.browserRoute)}):null,touchedAt:Date.now()}},oc=(e,t,r)=>{if(e.length<=t)return e;const n=[...e].sort((i,c)=>i.touchedAt-c.touchedAt).filter(i=>i.id!==r),a=e.length-t;if(a<=0||n.length===0)return e.slice(-t);const s=new Set(n.slice(0,a).map(i=>i.id));return e.filter(i=>!s.has(i.id))},nc=e=>{if(!Array.isArray(e))return[];const t=[],r=new Set;for(const o of e){if(!o||typeof o!="object")continue;const n=o;if(n.mode!=="diff"&&n.mode!=="file"&&n.mode!=="context"&&n.mode!=="preview"&&n.mode!=="browser"&&n.mode!=="git"&&n.mode!=="terminal"&&n.mode!=="pull-requests"&&n.mode!=="issues"&&n.mode!=="extensions"&&n.mode!=="agents")continue;const a=Ao(typeof n.targetPath=="string"?n.targetPath:null),s=tc(n.mode,a,typeof n.dedupeKey=="string"?n.dedupeKey:null),i=kn(n.mode,s);if(!i||r.has(i))continue;r.add(i);const c=n.mode==="browser",d=typeof n.dedupeKey=="string"&&n.dedupeKey.trim()?n.dedupeKey.trim():"browser";t.push({id:i,mode:n.mode,targetPath:c?null:a,dedupeKey:s,label:Eo(typeof n.label=="string"?n.label:null),sessionTitleFallback:Eo(typeof n.sessionTitleFallback=="string"?n.sessionTitleFallback:null),readOnly:n.readOnly===!0,stagedDiff:n.stagedDiff===!0,diffScope:Sa(n.diffScope)??(n.stagedDiff===!0?"staged":"working"),browser:c?wf(n.browser,{tabId:kn("browser",d),url:a,route:Da(n.browserRoute)}):null,touchedAt:typeof n.touchedAt=="number"&&Number.isFinite(n.touchedAt)?n.touchedAt:Date.now()})}return t},Jt=(e,t)=>t&&e.some(r=>r.id===t)?t:e.length===0?null:e[e.length-1].id,gt=e=>{if(e){const t=nc(e.tabs),r=Jt(t,e.activeTabId);return{...e,tabs:t,activeTabId:r,width:e.width,touchedAt:Date.now()}}return{isOpen:!1,expanded:!1,tabs:[],activeTabId:null,touchedAt:Date.now()}},Nf=(e,t)=>{const r=Ta(t),o=r.mode==="file"&&r.targetPath?e.tabs.filter(c=>!(c.mode==="file"&&!c.targetPath)):e.tabs,n=o.findIndex(c=>c.id===r.id),a=n===-1?[...o,r]:o.map((c,d)=>d===n?{...c,mode:r.mode,targetPath:r.targetPath||c.targetPath,dedupeKey:r.dedupeKey,label:r.label,sessionTitleFallback:r.sessionTitleFallback||c.sessionTitleFallback,stagedDiff:r.stagedDiff,diffScope:r.diffScope,browser:c.browser??r.browser,readOnly:r.readOnly,touchedAt:Date.now()}:c),s=r.id,i=oc(a,ec,s);return{...e,isOpen:!0,tabs:i,activeTabId:Jt(i,s),touchedAt:Date.now()}},Lf=(e,t)=>{const r=e.tabs.find(s=>s.id===t)??null,o=e.tabs.filter(s=>s.id!==t);if(e.activeTabId!==t)return{...e,tabs:o,activeTabId:Jt(o,e.activeTabId),isOpen:o.length>0?e.isOpen:!1,touchedAt:Date.now()};const n=r?o.filter(s=>s.mode===r.mode):[],a=n.length>0?n.reduce((s,i)=>i.touchedAt>=s.touchedAt?i:s):null;return{...e,tabs:o,activeTabId:a?.id??Jt(o,null),isOpen:a?e.isOpen:!1,touchedAt:Date.now()}},Uf=(e,t,r)=>{if(t===r)return e;const o=e.tabs.findIndex(i=>i.id===t),n=e.tabs.findIndex(i=>i.id===r);if(o===-1||n===-1)return e;const a=[...e.tabs],[s]=a.splice(o,1);return s?(a.splice(n,0,s),{...e,tabs:a,touchedAt:Date.now()}):e},Hf=(e,t,r)=>({...e,tabs:e.tabs.map(o=>o.id===t?{...o,targetPath:r}:o)}),Kf=e=>{const t=[];let r=!1;for(const o of e){if(o.mode!=="diff"&&o.mode!=="git"){t.push(o);continue}r||(r=!0,t.push(o.mode==="git"?o:Ta({mode:"git"})))}return t},Ve=e=>{if(!e||typeof e!="object")return{};const t=e,r={};for(const[o,n]of Object.entries(t)){const a=K(o);if(!a||!n||typeof n!="object")continue;const s=n;let i=Kf(nc(s.tabs)),c=typeof s.activeTabId=="string"?s.activeTabId:null;i.length===0&&(s.mode==="diff"||s.mode==="file"||s.mode==="context")&&(i=[Ta({mode:s.mode,targetPath:typeof s.targetPath=="string"?s.targetPath:null,dedupeKey:typeof s.dedupeKey=="string"?s.dedupeKey:null,label:typeof s.label=="string"?s.label:null})],c=i[0]?.id??null);const d=Jt(i,c),l=oc(i,ec,d),u=_f(s);r[a]={isOpen:s.isOpen===!0,expanded:s.expanded===!0,tabs:l,activeTabId:Jt(l,d),...u!==void 0?{width:u}:{},touchedAt:typeof s.touchedAt=="number"&&Number.isFinite(s.touchedAt)?s.touchedAt:Date.now()}}return r},pt=(e,t)=>{const r=Object.entries(e);if(r.length<=t)return e;r.sort((n,a)=>(a[1]?.touchedAt??0)-(n[1]?.touchedAt??0));const o={};for(const[n,a]of r.slice(0,t))o[n]=a;return o},ks=50,jf=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const r=t.split("/");if(r.length!==3)return null;const[o,n,a]=r.map(s=>s.trim());return!o||!n||!a||n.length>100||a.length>100||o.length>253?null:`${o}/${n}/${a}`},$f=e=>{if(!e||typeof e!="object")return{};const t=e,r={};for(const[o,n]of Object.entries(t)){const a=K(o),s=jf(n);!a||!s||(r[a]=s)}return r},Ds=(e,t)=>{const r=Object.entries(e);if(r.length<=t)return e;const o={};for(const[n,a]of r.slice(-t))o[n]=a;return o};function Ss(e){return e==="vim"?"vim":"default"}const fr=280,on=new Map,nn=e=>(e??D()).trim()||"default",mr=(e,t,r,o)=>{const n=t(),a=n.contextPanelByDirectory[r];if(!a)return;const s=Of(a,o);s!==a&&e({contextPanelByDirectory:{...n.contextPanelByDirectory,[r]:s}})},ie=Ir()(_r(ea((e,t)=>({theme:"system",isSidebarOpen:!0,sidebarWidth:fr,hasManuallyResizedLeftSidebar:!1,contextPanelByDirectory:{},browserRoutePreference:null,chatLinkTarget:"system",contextRailOrder:[],contextEditorTreeVisible:!0,fileTreeReveal:null,gitReturnToFile:null,contextEditorTreeWidth:240,githubSelectedRepoByDirectory:{},isSessionSwitcherOpen:!1,isSessionDropdownOpen:!1,activeMainTab:"chat",mainTabGuard:null,sidebarOpenBeforeFullscreenTab:null,pendingDiffFile:null,pendingDiffStaged:!1,pendingDiffScope:null,pendingDiagramFile:null,pendingFileNavigation:null,pendingFileFocusPath:null,isMobile:!1,isCommandPaletteOpen:!1,isHelpDialogOpen:!1,isSessionCreateDialogOpen:!1,isArchivePageOpen:!1,isSettingsDialogOpen:!1,isModelSelectorOpen:!1,sidebarSection:"sessions",settingsPage:"home",settingsHasOpenedOnce:!1,settingsProjectsSelectedId:null,settingsRemoteInstancesSelectedId:null,eventStreamStatus:"idle",eventStreamHint:null,showDeletionDialog:!0,autoDeleteEnabled:!1,autoSaveEnabled:!0,autoDeleteAfterDays:30,sessionRetentionAction:"archive",autoDeleteLastRunAt:null,messageLimit:200,fontSize:100,globalDraftStarters:null,terminalFontSize:14,terminalShell:"auto",terminalLoginShells:[],editorFontSize:13,uiFont:af,monoFont:sf,padding:100,cornerRadius:18,inputBarOffset:0,mobileKeyboardMode:uf(),favoriteModels:[],hiddenModels:[],collapsedModelProviders:[],recentModels:[],recentAgents:[],recentEfforts:{},diffLayoutPreference:"inline",diffFileLayout:{},diffWrapLinesOverride:null,wrapLinesByDefault:!0,walkthroughTocWidth:224,gitChangesViewMode:"flat",isTimelineDialogOpen:!1,isPromptNavigatorPanelOpen:!1,isImagePreviewOpen:!1,nativeNotificationsEnabled:!1,notificationMode:"hidden-only",dockBadgeEnabled:!0,notifyOnCompletion:!0,notifyOnError:!0,notifyOnInputNeeded:!0,summarizeLastMessage:!1,summaryThreshold:200,summaryLength:100,maxLastMessageLength:250,showTerminalQuickKeysOnDesktop:!1,timeFormatPreference:"auto",weekStartPreference:"auto",sidebarViewMode:gf,sessionAutoArchiveAfterDays:0,sessionAutoDeleteAfterDays:0,expandedEditorToolbar:!1,draftStartersVisible:!0,isExpandedInput:!1,shortcutOverrides:{},commandTriggers:[],fileEditorKeymap:"default",setTheme:r=>{e({theme:r}),t().applyTheme()},toggleSidebar:()=>{e(r=>{const o=!r.isSidebarOpen;return o&&!r.hasManuallyResizedLeftSidebar?{isSidebarOpen:o,sidebarWidth:fr}:{isSidebarOpen:o}})},setSidebarOpen:r=>{e(o=>o.isSidebarOpen===r?r&&!o.hasManuallyResizedLeftSidebar&&o.sidebarWidth!==fr?{isSidebarOpen:r,sidebarWidth:fr}:o:r&&!o.hasManuallyResizedLeftSidebar?{isSidebarOpen:r,sidebarWidth:fr}:{isSidebarOpen:r})},setSidebarWidth:r=>{e({sidebarWidth:r,hasManuallyResizedLeftSidebar:!0})},setContextRailOrder:r=>{const o=Array.isArray(r)?r.filter((n,a)=>typeof n=="string"&&n.trim()!==""&&r.indexOf(n)===a):[];e({contextRailOrder:o})},toggleContextEditorTree:()=>{e(r=>({contextEditorTreeVisible:!r.contextEditorTreeVisible}))},revealInFileTree:r=>{e(o=>({fileTreeReveal:{path:r,nonce:(o.fileTreeReveal?.nonce??0)+1}}))},clearGitReturnToFile:()=>{t().gitReturnToFile&&e({gitReturnToFile:null})},showAllGitChanges:()=>{const r=t().gitReturnToFile;r?.focusPath&&e({gitReturnToFile:{...r,focusPath:null}})},clearFileTreeReveal:()=>{e({fileTreeReveal:null})},setContextEditorTreeWidth:r=>{Number.isFinite(r)&&e({contextEditorTreeWidth:Math.min(480,Math.max(200,Math.round(r)))})},setGitHubSelectedRepo:(r,o)=>{const n=K((r||"").trim());n&&e(a=>{if(o==null){if(!(n in a.githubSelectedRepoByDirectory))return a;const i={...a.githubSelectedRepoByDirectory};return delete i[n],{githubSelectedRepoByDirectory:i}}const s=o.trim();return!s||a.githubSelectedRepoByDirectory[n]===s?a:{githubSelectedRepoByDirectory:Ds({...a.githubSelectedRepoByDirectory,[n]:s},ks)}})},openContextSurface:(r,o)=>{const n=o==="diff"?"git":o,a=K((r||"").trim());if(!a)return;const s=t(),i=s.contextPanelByDirectory[a],c=i?.tabs??[],d=c.find(u=>u.id===i?.activeTabId)??null;if(i?.isOpen&&d?.mode===n){s.closeContextPanel(a);return}const l=c.filter(u=>u.mode===n);if(l.length>0){const u=l.reduce((f,m)=>m.touchedAt>=f.touchedAt?m:f);s.setActiveContextPanelTab(a,u.id);return}n!=="preview"&&s.openContextPanelTab(a,{mode:n})},openContextPanelTab:(r,o)=>{const n=K((r||"").trim());n&&e(a=>{const s=a.contextPanelByDirectory[n],i=gt(s),c={...a.contextPanelByDirectory,[n]:Nf(i,o)};return{contextPanelByDirectory:pt(c,20)}})},openContextDiff:(r,o,n=!1,a=null)=>{const s=K((r||"").trim()),i=(o||"").trim();if(!s||!i)return;const c=Sa(a)??(n?"staged":"working"),d=t().contextPanelByDirectory[s],l=d?.isOpen?d.tabs.find(u=>u.id===d.activeTabId):void 0;t().setPendingDiffFile(i,n,c),t().openContextPanelTab(s,{mode:"git"}),e({gitReturnToFile:l?.mode==="file"?{directory:s,tabId:l.id,focusPath:i}:null})},openContextFile:(r,o)=>{const n=K((r||"").trim()),a=Ao(o);!n||!a||(t().openContextPanelTab(n,{mode:"file",targetPath:a}),t().setPendingFileFocusPath(a),t().setPendingFileNavigation(null))},openContextFileAtLine:(r,o,n,a)=>{const s=K((r||"").trim()),i=Ao(o),c=Number.isFinite(n)?Math.max(1,Math.trunc(n)):1,d=Number.isFinite(a)?Math.max(1,Math.trunc(a)):1;!s||!i||(t().openContextPanelTab(s,{mode:"file",targetPath:i}),t().setPendingFileFocusPath(null),t().setPendingFileNavigation({path:i,line:c,column:d}))},openContextOverview:r=>{const o=K((r||"").trim());o&&t().openContextPanelTab(o,{mode:"context"})},openContextPreview:(r,o)=>{const n=K((r||"").trim()),a=(o||"").trim();if(!n||!a)return;let s=null;try{const i=new URL(a);(i.protocol==="http:"||i.protocol==="https:")&&(s=i.host||i.hostname||"Preview")}catch{}t().openContextPanelTab(n,{mode:"preview",targetPath:a,dedupeKey:a,label:s})},openContextBrowser:(r,o="",n)=>{const a=K((r||"").trim());if(!a)return;const s=typeof o=="string"&&o.trim().length>0?o.trim():"",i=!!t().contextPanelByDirectory[a]?.tabs.some(d=>d.id===rc);if(t().openContextPanelTab(a,{mode:"browser",targetPath:i?null:s,dedupeKey:Ma,label:"Browser",browserRoute:i?null:n?.route??null}),!i)return;const c=n?.target??(s?"new":null);c&&mr(e,t,a,d=>Cf(d,{url:s||null,route:n?.route??null,target:c}))},openBrowserPopup:(r,o,n)=>{const a=K((r||"").trim());if(!a)return!1;let s=!1;return mr(e,t,a,i=>{const c=vf(i,{openerPageId:o,popupId:n});return s=c!==null,c??i}),s},closeBrowserPage:(r,o)=>{const n=K((r||"").trim());n&&mr(e,t,n,a=>kf(a,o))},activateBrowserPage:(r,o)=>{const n=K((r||"").trim());n&&mr(e,t,n,a=>Df(a,o))},updateBrowserPage:(r,o,n)=>{const a=K((r||"").trim());a&&mr(e,t,a,s=>Sf(s,o,n))},setBrowserRoutePreference:r=>{e({browserRoutePreference:Da(r)})},setChatLinkTarget:r=>{e({chatLinkTarget:r==="pichamber"?"pichamber":"system"})},setContextPanelTabTargetPath:(r,o,n)=>{const a=K((r||"").trim()),s=(o||"").trim();!a||!s||e(i=>{const c=i.contextPanelByDirectory[a];return c?{contextPanelByDirectory:{...i.contextPanelByDirectory,[a]:Hf(c,s,n)}}:i})},setActiveContextPanelTab:(r,o)=>{const n=K((r||"").trim()),a=(o||"").trim();!n||!a||e(s=>{const i=s.contextPanelByDirectory[n],c=gt(i);if(!c.tabs.some(l=>l.id===a)||c.activeTabId===a&&c.isOpen)return s;const d={...s.contextPanelByDirectory,[n]:{...c,isOpen:!0,activeTabId:a,touchedAt:Date.now(),tabs:c.tabs.map(l=>l.id===a?{...l,touchedAt:Date.now()}:l)}};return{contextPanelByDirectory:pt(d,20)}})},reorderContextPanelTabs:(r,o,n)=>{const a=K((r||"").trim()),s=(o||"").trim(),i=(n||"").trim();!a||!s||!i||e(c=>{const d=c.contextPanelByDirectory[a],l=gt(d);if(!l.tabs.some(m=>m.id===s)||!l.tabs.some(m=>m.id===i))return c;const u=Uf(l,s,i);if(u.tabs===l.tabs)return c;const f={...c.contextPanelByDirectory,[a]:u};return{contextPanelByDirectory:pt(f,20)}})},closeContextPanelTab:(r,o)=>{const n=K((r||"").trim()),a=(o||"").trim();if(!n||!a)return;const s=t().contextPanelByDirectory[n]?.tabs.find(i=>i.id===a);e(i=>{const c=i.contextPanelByDirectory[n],d=gt(c);if(!d.tabs.some(u=>u.id===a))return i;const l={...i.contextPanelByDirectory,[n]:Lf(d,a)};return{contextPanelByDirectory:pt(l,20)}}),s?.mode==="file"&&s.targetPath&&yf.getState().removeOpenPath(n,s.targetPath)},closeContextPanel:r=>{const o=K((r||"").trim());o&&e(n=>{const a=n.contextPanelByDirectory[o];if(!a||!a.isOpen)return n;const s={...n.contextPanelByDirectory,[o]:{...gt(a),isOpen:!1}};return{contextPanelByDirectory:pt(s,20)}})},toggleContextPanelExpanded:r=>{const o=K((r||"").trim());o&&e(n=>{const a=n.contextPanelByDirectory[o],s=gt(a),i={...n.contextPanelByDirectory,[o]:{...s,expanded:!s.expanded}};return{contextPanelByDirectory:pt(i,20)}})},setContextPanelWidth:(r,o)=>{const n=K((r||"").trim());n&&e(a=>{const s=a.contextPanelByDirectory[n],i=gt(s),c={...a.contextPanelByDirectory,[n]:{...i,width:co(o)}};return{contextPanelByDirectory:pt(c,20)}})},setSessionSwitcherOpen:r=>{t().isSessionSwitcherOpen!==r&&e({isSessionSwitcherOpen:r})},setSessionDropdownOpen:r=>{t().isSessionDropdownOpen!==r&&e({isSessionDropdownOpen:r})},setMainTabGuard:r=>{t().mainTabGuard!==r&&e({mainTabGuard:r})},setActiveMainTab:r=>{const o=t().mainTabGuard;o&&!o(r)||(on.set(nn(),r),e({activeMainTab:r}))},prepareForRuntimeSwitch:r=>{on.set(nn(r),t().activeMainTab)},restoreForRuntimeSwitch:r=>{const o=on.get(nn(r))??"chat";e({activeMainTab:o})},setPendingDiffFile:(r,o=!1,n=null)=>{e({pendingDiffFile:r,pendingDiffStaged:r?o:!1,pendingDiffScope:r?n:null})},setPendingDiagramFile:r=>{e({pendingDiagramFile:r})},setPendingFileNavigation:r=>{e({pendingFileNavigation:r})},setPendingFileFocusPath:r=>{e({pendingFileFocusPath:r})},navigateToDiff:(r,o=!1,n=null)=>{const a=t().mainTabGuard;a&&!a("diff")||e({pendingDiffFile:r,pendingDiffStaged:o,pendingDiffScope:n,activeMainTab:"diff"})},consumePendingDiffFile:()=>{const{pendingDiffFile:r}=t();return r&&e({pendingDiffFile:null,pendingDiffStaged:!1,pendingDiffScope:null}),r},navigateToDiagram:r=>{const o=t().mainTabGuard;o&&!o("diagram")||e({pendingDiagramFile:r,activeMainTab:"diagram"})},consumePendingDiagramFile:()=>{const{pendingDiagramFile:r}=t();return r&&e({pendingDiagramFile:null}),r},setIsMobile:r=>{e({isMobile:r})},toggleCommandPalette:()=>{e(r=>({isCommandPaletteOpen:!r.isCommandPaletteOpen}))},setCommandPaletteOpen:r=>{e({isCommandPaletteOpen:r})},toggleHelpDialog:()=>{e(r=>({isHelpDialogOpen:!r.isHelpDialogOpen}))},setHelpDialogOpen:r=>{e({isHelpDialogOpen:r})},setSessionCreateDialogOpen:r=>{e({isSessionCreateDialogOpen:r})},setArchivePageOpen:r=>{e({isArchivePageOpen:r})},closeMainSurfaces:()=>{t().isArchivePageOpen&&e({isArchivePageOpen:!1})},setSettingsDialogOpen:r=>{e(o=>r?o.settingsHasOpenedOnce?{isSettingsDialogOpen:!0}:{isSettingsDialogOpen:!0,settingsHasOpenedOnce:!0}:{isSettingsDialogOpen:!1})},setModelSelectorOpen:r=>{e({isModelSelectorOpen:r})},setSidebarSection:r=>{e({sidebarSection:r})},setSettingsPage:r=>{e({settingsPage:r})},setSettingsProjectsSelectedId:r=>{e({settingsProjectsSelectedId:r})},setSettingsRemoteInstancesSelectedId:r=>{e({settingsRemoteInstancesSelectedId:r})},setEventStreamStatus:(r,o)=>{e({eventStreamStatus:r,eventStreamHint:o??null})},setShowDeletionDialog:r=>{e({showDeletionDialog:r})},setAutoDeleteEnabled:r=>{e({autoDeleteEnabled:r})},setAutoSaveEnabled:r=>{e({autoSaveEnabled:r})},setAutoDeleteAfterDays:r=>{const o=Math.max(1,Math.min(365,r));e({autoDeleteAfterDays:o})},setSessionRetentionAction:r=>{e({sessionRetentionAction:r})},setAutoDeleteLastRunAt:r=>{e({autoDeleteLastRunAt:r})},setMessageLimit:r=>{const o=Math.max(10,Math.min(500,Math.round(r)));e({messageLimit:o})},setFontSize:r=>{const o=Math.max(50,Math.min(200,r));e({fontSize:o}),t().applyTypography()},setGlobalDraftStarters:r=>{e({globalDraftStarters:r})},setDraftStartersVisible:r=>{e({draftStartersVisible:r})},setTerminalFontSize:r=>{const o=Math.round(r),n=Math.max(9,Math.min(52,o));e({terminalFontSize:n})},setTerminalShell:r=>{e({terminalShell:r})},setTerminalLoginShells:r=>{e({terminalLoginShells:[...new Set(r)]})},setEditorFontSize:r=>{const o=Math.round(r),n=Math.max(9,Math.min(32,o));e({editorFontSize:n})},setUiFont:r=>{e({uiFont:r})},setMonoFont:r=>{e({monoFont:r})},setPadding:r=>{const o=Math.max(50,Math.min(200,r));e({padding:o}),t().applyPadding()},setCornerRadius:r=>{e({cornerRadius:r})},applyTypography:()=>{const{fontSize:r}=t(),o=document.documentElement,n=r/100,a=Object.entries(ef);if(n===1){for(const[s]of a)o.style.removeProperty(Bs(s));return}for(const[s,i]of a){const c=parseFloat(i);Number.isFinite(c)&&o.style.setProperty(Bs(s),`${c*n}rem`)}},applyPadding:()=>{const{padding:r}=t(),o=document.documentElement,n=r/100;if(n===1){o.style.removeProperty("--padding-scale"),o.style.removeProperty("--line-height-tight"),o.style.removeProperty("--line-height-normal"),o.style.removeProperty("--line-height-relaxed"),o.style.removeProperty("--line-height-loose");return}const a=Math.sqrt(n);o.style.setProperty("--padding-scale",a.toString());const s=1+(n-1)*.15;o.style.setProperty("--line-height-tight",(1.25*s).toFixed(3)),o.style.setProperty("--line-height-normal",(1.5*s).toFixed(3)),o.style.setProperty("--line-height-relaxed",(1.625*s).toFixed(3)),o.style.setProperty("--line-height-loose",(2*s).toFixed(3))},setDiffLayoutPreference:r=>{e({diffLayoutPreference:r})},setDiffFileLayout:(r,o)=>{e(n=>({diffFileLayout:{...n.diffFileLayout,[r]:o}}))},setDiffWrapLines:r=>{e({diffWrapLinesOverride:r})},setWrapLinesByDefault:r=>{e({wrapLinesByDefault:r,diffWrapLinesOverride:null})},setWalkthroughTocWidth:r=>{e({walkthroughTocWidth:Math.round(r)})},setGitChangesViewMode:r=>{e({gitChangesViewMode:r})},setInputBarOffset:r=>{e({inputBarOffset:r})},setMobileKeyboardMode:r=>{e(o=>o.mobileKeyboardMode===r?o:{mobileKeyboardMode:r})},toggleFavoriteModel:(r,o)=>{e(n=>n.favoriteModels.some(s=>s.providerID===r&&s.modelID===o)?{favoriteModels:n.favoriteModels.filter(s=>!(s.providerID===r&&s.modelID===o))}:{favoriteModels:[{providerID:r,modelID:o},...n.favoriteModels]})},reorderFavoriteModel:(r,o,n,a)=>{e(s=>{const i=s.favoriteModels.findIndex(u=>u.providerID===r&&u.modelID===o),c=s.favoriteModels.findIndex(u=>u.providerID===n&&u.modelID===a);if(i===-1||c===-1||i===c)return s;const d=s.favoriteModels.slice(),[l]=d.splice(i,1);return l?(d.splice(c,0,l),{favoriteModels:d}):s})},toggleHiddenModel:(r,o)=>{e(n=>n.hiddenModels.some(s=>s.providerID===r&&s.modelID===o)?{hiddenModels:n.hiddenModels.filter(s=>!(s.providerID===r&&s.modelID===o))}:{hiddenModels:[{providerID:r,modelID:o},...n.hiddenModels]})},isHiddenModel:(r,o)=>{const{hiddenModels:n}=t();return n.some(a=>a.providerID===r&&a.modelID===o)},hideAllModels:(r,o)=>{e(n=>{const a=n.hiddenModels.filter(i=>i.providerID!==r);return{hiddenModels:[...[...new Set(o.filter(i=>typeof i=="string"&&i.length>0))].map(i=>({providerID:r,modelID:i})),...a]}})},showAllModels:r=>{e(o=>({hiddenModels:o.hiddenModels.filter(n=>n.providerID!==r)}))},toggleModelProviderCollapsed:r=>{const o=typeof r=="string"?r.trim():"";o&&e(n=>n.collapsedModelProviders.includes(o)?{collapsedModelProviders:n.collapsedModelProviders.filter(s=>s!==o)}:{collapsedModelProviders:[...n.collapsedModelProviders,o]})},setModelProvidersCollapsed:(r,o)=>{const n=Array.from(new Set(r.filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean)));n.length!==0&&e(a=>{const s=new Set(n),i=a.collapsedModelProviders.filter(c=>!s.has(c));return{collapsedModelProviders:o?[...i,...n]:i}})},isFavoriteModel:(r,o)=>{const{favoriteModels:n}=t();return n.some(a=>a.providerID===r&&a.modelID===o)},addRecentModel:(r,o)=>{e(n=>{const a=n.recentModels.filter(s=>!(s.providerID===r&&s.modelID===o));return{recentModels:[{providerID:r,modelID:o},...a].slice(0,5)}})},addRecentAgent:r=>{const o=typeof r=="string"?r.trim():"";o&&e(n=>{if(n.recentAgents.includes(o))return n;const a=n.recentAgents;return{recentAgents:[o,...a].slice(0,5)}})},addRecentEffort:(r,o,n)=>{const a=typeof r=="string"?r.trim():"",s=typeof o=="string"?o.trim():"";if(!a||!s)return;const i=`${a}/${s}`,c=typeof n=="string"&&n.trim().length>0?n.trim():"default";e(d=>{const l=d.recentEfforts[i]??[];if(l.includes(c))return d;const u=l;return{recentEfforts:{...d.recentEfforts,[i]:[c,...u].slice(0,5)}}})},applyTheme:()=>{const{theme:r}=t(),o=document.documentElement;if(o.classList.remove("light","dark"),r==="system"){const n=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";o.classList.add(n)}else o.classList.add(r)},setTimelineDialogOpen:r=>{e({isTimelineDialogOpen:r})},setPromptNavigatorPanelOpen:r=>{e({isPromptNavigatorPanelOpen:r})},togglePromptNavigatorPanel:()=>{e(r=>({isPromptNavigatorPanelOpen:!r.isPromptNavigatorPanelOpen}))},setImagePreviewOpen:r=>{e({isImagePreviewOpen:r})},setNativeNotificationsEnabled:r=>{e({nativeNotificationsEnabled:r})},setNotificationMode:r=>{e({notificationMode:r})},setShowTerminalQuickKeysOnDesktop:r=>{e({showTerminalQuickKeysOnDesktop:r})},setDockBadgeEnabled:r=>{e({dockBadgeEnabled:r})},setNotifyOnCompletion:r=>{e({notifyOnCompletion:r})},setNotifyOnError:r=>{e({notifyOnError:r})},setNotifyOnInputNeeded:r=>{e({notifyOnInputNeeded:r})},setSummarizeLastMessage:r=>{e({summarizeLastMessage:r})},setSummaryThreshold:r=>{e({summaryThreshold:r})},setSummaryLength:r=>{e({summaryLength:r})},setMaxLastMessageLength:r=>{e({maxLastMessageLength:r})},setTimeFormatPreference:r=>{e({timeFormatPreference:r})},setWeekStartPreference:r=>{e({weekStartPreference:r})},setSidebarViewMode:r=>{e({sidebarViewMode:r})},setSessionAutoArchiveAfterDays:r=>{Vt(r)&&e({sessionAutoArchiveAfterDays:r})},setSessionAutoDeleteAfterDays:r=>{Vt(r)&&e({sessionAutoDeleteAfterDays:r})},setExpandedEditorToolbar:r=>{e({expandedEditorToolbar:r})},viewPagerPage:"center",setViewPagerPage:r=>{e({viewPagerPage:r}),e({isSessionSwitcherOpen:r==="left"})},setShortcutOverride:(r,o)=>{e(n=>({shortcutOverrides:{...n.shortcutOverrides,[r]:o}}))},clearShortcutOverride:r=>{e(o=>{const n={...o.shortcutOverrides};return delete n[r],{shortcutOverrides:n}})},resetAllShortcutOverrides:()=>{e({shortcutOverrides:{}})},setFileEditorKeymap:r=>{e({fileEditorKeymap:Ss(r)})},toggleExpandedInput:()=>{e(r=>({isExpandedInput:!r.isExpandedInput}))},setExpandedInput:r=>{e({isExpandedInput:r})}}),{name:"ui-store",storage:la(),version:21,migrate:(e,t)=>{if(!e||typeof e!="object")return e;const r=e;if(t<21&&(delete r.diffWrapLines,delete r.diffWrapLinesOverride,typeof r.wrapLinesByDefault!="boolean"&&(r.wrapLinesByDefault=!0)),t<20&&(delete r.notifyOnSubtasks,delete r.notifyOnQuestion,delete r.notificationTemplates),t<19&&(delete r.showReasoningTraces,delete r.collapsibleThinkingBlocks,delete r.collapseThinkingByDefault,delete r.persistChatDraft,delete r.inputSpellcheckEnabled,delete r.wideChatLayoutEnabled,delete r.codeBlockLineWrap,delete r.showToolFileIcons,delete r.showTurnChangedFiles,delete r.showExpandedBashTools,delete r.showExpandedEditTools,delete r.desktopWindowControlsPosition,delete r.desktopWindowControlsStyle,delete r.mermaidRenderingMode,delete r.userMessageRenderingMode,delete r.collapsibleUserMessages,delete r.stickyUserHeader,delete r.promptNavigatorEnabled,delete r.showSplitAssistantMessageActions),t<18&&(delete r.notesPanelHeight,delete r.todoPanelHeight,r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="notes"))),t<17&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="chat"))),t<16&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="chat"))),t<15&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="pr"))),t<14&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="diff"))),t<13&&typeof r.autoSaveEnabled!="boolean"){let o=!0;try{if(typeof localStorage<"u"){const n=localStorage.getItem("pichamber:files:auto-save-enabled");n!==null&&(o=n!=="false",localStorage.removeItem("pichamber:files:auto-save-enabled"))}}catch{o=!0}r.autoSaveEnabled=o}if(t<12&&(delete r.desktopWindowControlsPosition,delete r.desktopWindowControlsStyle),t<11&&r.terminalFontSize===13&&(r.terminalFontSize=14),t<10&&delete r.diffViewMode,t<9&&((typeof r.notesPanelHeight!="number"||!Number.isFinite(r.notesPanelHeight))&&(r.notesPanelHeight=112),(typeof r.todoPanelHeight!="number"||!Number.isFinite(r.todoPanelHeight))&&(r.todoPanelHeight=259)),t<3){const o=new Set([90,120,180,220]),n=r.memoryLimitHistorical,a=r.memoryLimitActiveSession;typeof n=="number"&&!o.has(n)?r.messageLimit=n:typeof a=="number"&&!o.has(a)&&(r.messageLimit=a),delete r.memoryLimitHistorical,delete r.memoryLimitViewport,delete r.memoryLimitActiveSession}if(delete r.isRightSidebarOpen,delete r.rightSidebarWidth,delete r.rightSidebarTab,delete r.workStatusExpandedSections,delete r.workStatusScrollTop,delete r.workStatusPanelEnabled,delete r.workStatusHiddenSections,delete r.showReasoningTraces,delete r.collapsibleThinkingBlocks,delete r.collapseThinkingByDefault,delete r.persistChatDraft,delete r.inputSpellcheckEnabled,delete r.wideChatLayoutEnabled,delete r.codeBlockLineWrap,delete r.showToolFileIcons,delete r.showTurnChangedFiles,delete r.showExpandedBashTools,delete r.showExpandedEditTools,delete r.desktopWindowControlsPosition,delete r.desktopWindowControlsStyle,delete r.mermaidRenderingMode,delete r.userMessageRenderingMode,delete r.collapsibleUserMessages,delete r.stickyUserHeader,delete r.promptNavigatorEnabled,delete r.showSplitAssistantMessageActions,delete r.diffWrapLines,r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),t<5)if(!r.shortcutOverrides||typeof r.shortcutOverrides!="object")r.shortcutOverrides={};else{const o=r.shortcutOverrides,n={};for(const[a,s]of Object.entries(o))typeof a=="string"&&typeof s=="string"&&(n[a]=s);r.shortcutOverrides=n}return t<6&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory)),t<7&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory)),t<8&&r.gitChangesViewMode!=="flat"&&r.gitChangesViewMode!=="tree"&&(r.gitChangesViewMode="flat"),r.fileEditorKeymap=Ss(r.fileEditorKeymap),r.githubSelectedRepoByDirectory=Ds($f(r.githubSelectedRepoByDirectory),ks),typeof r.autoSaveEnabled!="boolean"&&(r.autoSaveEnabled=!0),typeof r.wrapLinesByDefault!="boolean"&&(r.wrapLinesByDefault=!0),r.contextRailOrder=Array.isArray(r.contextRailOrder)?r.contextRailOrder.filter(o=>typeof o=="string"&&o.trim()!==""&&o!=="pr"&&o!=="diff"&&o!=="chat"&&o!=="notes"):[],r},partialize:e=>({theme:e.theme,isSidebarOpen:e.isSidebarOpen,sidebarWidth:e.sidebarWidth,contextPanelByDirectory:e.contextPanelByDirectory,browserRoutePreference:e.browserRoutePreference,chatLinkTarget:e.chatLinkTarget,contextRailOrder:e.contextRailOrder,contextEditorTreeVisible:e.contextEditorTreeVisible,contextEditorTreeWidth:e.contextEditorTreeWidth,githubSelectedRepoByDirectory:e.githubSelectedRepoByDirectory,isSessionSwitcherOpen:e.isSessionSwitcherOpen,activeMainTab:e.activeMainTab,sidebarSection:e.sidebarSection,settingsPage:e.settingsPage,settingsHasOpenedOnce:e.settingsHasOpenedOnce,settingsProjectsSelectedId:e.settingsProjectsSelectedId,settingsRemoteInstancesSelectedId:e.settingsRemoteInstancesSelectedId,isSessionCreateDialogOpen:e.isSessionCreateDialogOpen,showDeletionDialog:e.showDeletionDialog,autoDeleteEnabled:e.autoDeleteEnabled,autoSaveEnabled:e.autoSaveEnabled,autoDeleteAfterDays:e.autoDeleteAfterDays,sessionRetentionAction:e.sessionRetentionAction,autoDeleteLastRunAt:e.autoDeleteLastRunAt,messageLimit:e.messageLimit,fontSize:e.fontSize,globalDraftStarters:e.globalDraftStarters,terminalFontSize:e.terminalFontSize,terminalShell:e.terminalShell,terminalLoginShells:e.terminalLoginShells,editorFontSize:e.editorFontSize,uiFont:e.uiFont,monoFont:e.monoFont,padding:e.padding,cornerRadius:e.cornerRadius,favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,collapsedModelProviders:e.collapsedModelProviders,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts,diffLayoutPreference:e.diffLayoutPreference,wrapLinesByDefault:e.wrapLinesByDefault,walkthroughTocWidth:e.walkthroughTocWidth,gitChangesViewMode:e.gitChangesViewMode,nativeNotificationsEnabled:e.nativeNotificationsEnabled,notificationMode:e.notificationMode,showTerminalQuickKeysOnDesktop:e.showTerminalQuickKeysOnDesktop,dockBadgeEnabled:e.dockBadgeEnabled,notifyOnCompletion:e.notifyOnCompletion,notifyOnError:e.notifyOnError,notifyOnInputNeeded:e.notifyOnInputNeeded,summarizeLastMessage:e.summarizeLastMessage,summaryThreshold:e.summaryThreshold,summaryLength:e.summaryLength,maxLastMessageLength:e.maxLastMessageLength,timeFormatPreference:e.timeFormatPreference,weekStartPreference:e.weekStartPreference,sidebarViewMode:e.sidebarViewMode,sessionAutoArchiveAfterDays:e.sessionAutoArchiveAfterDays,sessionAutoDeleteAfterDays:e.sessionAutoDeleteAfterDays,expandedEditorToolbar:e.expandedEditorToolbar,draftStartersVisible:e.draftStartersVisible,shortcutOverrides:e.shortcutOverrides,fileEditorKeymap:e.fileEditorKeymap})}),{name:"ui-store"})),xb=Object.freeze(Object.defineProperty({__proto__:null,normalizeContextPanelDirectoryKey:If,useUIStore:ie},Symbol.toStringTag,{value:"Module"}));let Ms="idle";const zf=new Set;let Qr=null;const ye=e=>{Qr&&(clearTimeout(Qr),Qr=null);const t=e==="saved"?"idle":e;t!==Ms&&(Ms=t,zf.forEach(r=>r())),t==="error"&&(Qr=setTimeout(()=>ye("saved"),6e3)),!(typeof window>"u")&&window.dispatchEvent(new CustomEvent("pichamber:settings-save-state",{detail:e}))},Ob=e=>{ye(e)},qf=e=>{if(!(typeof window>"u")&&!(typeof window.__PICHAMBER_HOME__=="string"&&window.__PICHAMBER_HOME__.length>0))try{window.__PICHAMBER_HOME__=e}catch{}},Ts="pichamber.settingsMirror.v2.index",Gf="pichamber.settingsMirror.v2:",Wf=5,Ps=e=>`${Gf}${encodeURIComponent(e)}`,ht=(e,t)=>{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)},Vf=(e,t)=>{const r={themeId:e.themeId,themeVariant:e.themeVariant,lightThemeId:e.lightThemeId,darkThemeId:e.darkThemeId,useSystemTheme:e.useSystemTheme,lastDirectory:e.lastDirectory,homeDirectory:e.homeDirectory,projects:e.projects,activeProjectId:e.activeProjectId,pinnedDirectories:e.pinnedDirectories,filesViewShowGitignored:e.filesViewShowGitignored,openInAppId:e.openInAppId,pwaAppName:e.pwaAppName,mobileKeyboardMode:e.mobileKeyboardMode};localStorage.setItem(Ps(t),JSON.stringify(r));let o=[];try{const a=JSON.parse(localStorage.getItem(Ts)??"[]");Array.isArray(a)&&(o=a.filter(s=>typeof s=="string"))}catch{o=[]}const n=[t,...o.filter(a=>a!==t)].slice(0,Wf);for(const a of o)n.includes(a)||localStorage.removeItem(Ps(a));localStorage.setItem(Ts,JSON.stringify(n))},Jf=e=>{if(!(typeof window>"u")){if(Vf(e,D()),ht("selectedThemeId",e.themeId||null),ht("selectedThemeVariant",e.themeVariant||null),ht("lightThemeId",e.lightThemeId||null),ht("darkThemeId",e.darkThemeId||null),ht("useSystemTheme",typeof e.useSystemTheme=="boolean"?String(e.useSystemTheme):null),ht("lastDirectory",e.lastDirectory||null),e.homeDirectory?(localStorage.setItem("homeDirectory",e.homeDirectory),qf(e.homeDirectory)):localStorage.removeItem("homeDirectory"),Array.isArray(e.projects)&&e.projects.length>0?localStorage.setItem("projects",JSON.stringify(e.projects)):localStorage.removeItem("projects"),e.activeProjectId?localStorage.setItem("activeProjectId",e.activeProjectId):localStorage.removeItem("activeProjectId"),Array.isArray(e.pinnedDirectories)&&e.pinnedDirectories.length>0?localStorage.setItem("pinnedDirectories",JSON.stringify(e.pinnedDirectories)):localStorage.removeItem("pinnedDirectories"),Array.isArray(e.projects)&&e.projects.length>0){const t=e.projects.filter(r=>r.sidebarCollapsed===!0).map(r=>r.id).filter(r=>typeof r=="string"&&r.length>0);t.length>0?localStorage.setItem("oc.sessions.projectCollapse",JSON.stringify(t)):localStorage.removeItem("oc.sessions.projectCollapse")}else localStorage.removeItem("oc.sessions.projectCollapse");if(typeof e.filesViewShowGitignored=="boolean"?localStorage.setItem("filesViewShowGitignored",e.filesViewShowGitignored?"true":"false"):localStorage.removeItem("filesViewShowGitignored"),ht("openInAppId",typeof e.openInAppId=="string"&&e.openInAppId.length>0?e.openInAppId:null),typeof e.pwaAppName=="string"){const t=Yi(e.pwaAppName,"");t.length>0?localStorage.setItem(rn,t):localStorage.removeItem(rn)}else localStorage.removeItem(rn);ff(e.mobileKeyboardMode)}},Dn=e=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("pichamber:settings-synced",{detail:e}))},Yf=()=>{const e=globalThis.crypto;if(typeof e?.randomUUID=="function")return e.randomUUID();if(typeof e?.getRandomValues!="function")throw new Error("Secure random UUID is unavailable in this browser context");const t=e.getRandomValues(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const r=Array.from(t,o=>o.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`},Xf=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const r=t.replace(/\\/g,"/").replace(/^([a-z]):/,(n,a)=>a.toUpperCase()+":");return r==="/"?"/":(r.length>1?r.replace(/\/+$/,""):r)||null},Pa="queue",Ra=e=>e==="steer"||e==="queue",Ia=(e,t)=>e==="immediate"?"steer":Ra(e)?e:t===!1?"steer":t===!0?"queue":Pa,Rs=50,Is=20,an=(e,t)=>{if(e.runtimeKey!==D())return;const r=t.flatMap(o=>(o.attachments??[]).flatMap(n=>n.uploadState?.status==="ready"?[n.uploadState.attachmentId]:[]));for(const o of new Set(r))bt.deleteAttachment(o,{runtimeKey:e.runtimeKey}).catch(()=>{})},Qf=(e,t,r=D())=>{const o=Xf(t);return!r||!o||!e?null:{runtimeKey:r,directory:o,sessionId:e}},re=e=>`${e.runtimeKey}
5
+ `)}}}).catch(f=>{if(i.signal.aborted)return;const m=f instanceof Error?f.message.slice(0,80):"fetch-failed";W("stream-connect",{code:"fetch-failed",detail:m}),a(`sse-error:${m}`)}).finally(()=>{u(),t.removeEventListener("abort",c)}),c},Gu=(e,t,r,o,n,a)=>{const s=Ji(e);let i=!1,c=!1,d=null;const l=()=>{if(!i){i=!0,d&&clearTimeout(d),d=null;try{s.close()}catch{}}};d=setTimeout(()=>{c||i||(n("ws-ready-timeout"),l())},a);const u=()=>l();return t.aborted?l():t.addEventListener("abort",u,{once:!0}),s.onopen=()=>{c=!0,d&&clearTimeout(d),d=null,r()},s.onmessage=f=>{const m=typeof f.data=="string"?f.data:void 0;if(m)try{const g=JSON.parse(m);kn(g)&&o(g)}catch{}},s.onerror=()=>{i||n("ws-error")},s.onclose=f=>{t.removeEventListener("abort",u),i||n(`ws-close-${f?.code??0}`)},l},Cs=()=>typeof document>"u"||document.visibilityState==="visible",vs=()=>typeof navigator>"u"||navigator.onLine!==!1,Ub=(e,t={})=>{const r=new AbortController,o=t.signal,n=()=>r.abort();o&&(o.aborted?r.abort():o.addEventListener("abort",n,{once:!0}));const a=r.signal,s=t.runtimeKey,i=()=>!s||s===D();let c=!1,d=0;const l=typeof t.streamEpoch=="string"&&t.streamEpoch.length>0?t.streamEpoch:null;let u=typeof t.fromSequence=="number"&&Number.isFinite(t.fromSequence)?Math.max(0,Math.floor(t.fromSequence)):l?0:void 0,f=typeof t.cursor=="string"&&t.cursor.length>0?t.cursor:void 0,m=t.transport==="ws"?"ws":"sse",g=null,h=null,p=null,k=null,A=0,C=!1,w=!1;const B=t.setupTimeoutMs??Ou,P=t.authTokenTimeoutMs??Nu,ee=t.healthResetMs??Lu,Be=t.epochProbeTimeoutMs??Uu;let se=null;const We=new Set;let Ce=!1,te=null,Tt=null,or=null,qr=!1;const nr=()=>{g&&clearTimeout(g),h&&clearTimeout(h),p&&clearTimeout(p),g=null,h=null,p=null},Oe=()=>{A+=1,k?.(),k=null,h&&clearTimeout(h),h=null,p&&clearTimeout(p),p=null},ar=E=>{h&&clearTimeout(h),h=setTimeout(()=>{E===A&&G("heartbeat-timeout",E)},t.heartbeatTimeoutMs??Tu)},$o=E=>{c||a.aborted||E!==A||(ar(E),qr&&dt(E),qr=!0)},v=E=>{if(c||a.aborted||E!==A)return;const R=!C;C=!0,w=!1,R&&(p&&clearTimeout(p),p=setTimeout(()=>{p=null,E===A&&C&&(d=0)},ee),W("stream-ready",{code:m}),e.onReconnect?.()),ar(E)},U=()=>{const E=Cs()&&vs()?Ru:Iu,R=Math.min(_u,d),T=Math.min(E,Pu*2**R);return d===0&&t.reconnectDelayMs!==void 0?Math.max(0,t.reconnectDelayMs):T+Math.floor(Math.random()*100)},N=(E,R=!0)=>{c||a.aborted||g||(W("stream-reconnect",{code:E}),R&&e.onDisconnect?.(E),g=setTimeout(()=>{g=null,d+=1,le()},U()))},$=()=>{c||a.aborted||!g||(clearTimeout(g),g=null,d+=1,le())},G=(E,R)=>{if(!(c||a.aborted||R!==A)){if(Oe(),!C&&m==="ws"&&t.transport!=="ws"&&(m="sse",e.onTransportSwitch?.()),C=!1,E==="runtime-change"){e.onDisconnect?.(E);return}if(E==="sse-auth-401"||E==="sse-auth-403"||E==="sse-auth-probe"){W("stream-auth",{code:E}),e.onDisconnect?.(E),e.onAuthRequired?.();return}N(E)}},de=(E,R)=>{if(c||a.aborted||R!==A)return;if(!i()){G("runtime-change",R);return}if(typeof E.stream=="string"||E.name==="session.moved"){typeof E.cursor=="string"&&E.cursor.length>0&&(f=E.cursor),v(R),e.onEvent(E);return}const T=typeof E.streamEpoch=="string"&&E.streamEpoch.length>0?E.streamEpoch:null;if(T&&T!==se){if(We.has(T)){W("stream-epoch",{code:"retired-frame"});return}const z=se??l;if(z!==null&&z!==T){if(Ce){Tt??={event:E,epoch:T,connectionId:R};return}ae(E,T,z,R);return}se=T,u=Math.max(u??0,E.sequence),z===null&&e.onEpochChange?.(T)}(u===void 0||E.sequence>u)&&(u=E.sequence),v(R),e.onEvent(E)},ae=async(E,R,T,z)=>{Ce=!0,te=new AbortController;const ue=setTimeout(()=>te?.abort(),Be);try{const ve=await Eo(te.signal,s,{fresh:!0});if(c||a.aborted||z!==A)return;if(ve.state==="ready"&&ve.streamEpoch===R){We.add(T),se=R,u=E.sequence,W("stream-epoch",{code:"verified"}),e.onEpochChange?.(R),v(z),e.onEvent(E);return}if(ve.state==="unavailable"&&ve.error?.code==="DAEMON_AUTH_FAILED"){G("sse-auth-probe",z);return}if(ve.state==="ready"){We.add(R),W("stream-epoch",{code:"rejected"});return}W("stream-epoch",{code:"unverified"}),G("epoch-unverified",z)}finally{clearTimeout(ue),Ce=!1,te=null,Tt=null,Pt()}},dt=async E=>{const R=se??l;if(!R)return;if(Ce){or=E;return}Ce=!0,te=new AbortController;const T=setTimeout(()=>te?.abort(),Be);try{const z=await Eo(te.signal,s,{fresh:!0});if(c||a.aborted||E!==A)return;const ue=z.state==="ready"?z.streamEpoch:void 0;if(!ue||ue===R||We.has(ue)||(se??l)!==R)return;We.add(R),se=ue,u=void 0,W("stream-epoch",{code:"verified-on-resubscribe"}),e.onEpochChange?.(ue)}catch{}finally{clearTimeout(T),Ce=!1,te=null;const z=Tt;Tt=null,z&&de(z.event,z.connectionId),Pt()}},Pt=()=>{const E=or;or=null,!(E===null||c||a.aborted||E!==A)&&dt(E)},Fe=async()=>{let E=null;try{return await Promise.race([Hr(),new Promise((R,T)=>{E=setTimeout(()=>T(new Error("url-token-timeout")),P)})])}finally{E&&clearTimeout(E)}},le=async()=>{if(c||a.aborted)return;if(!i()){e.onDisconnect?.("runtime-change");return}const E=A+1;A=E;let R;if(m==="ws")try{R=await Fe()}catch{if(E!==A||c||a.aborted)return;if(t.transport!=="ws"){m="sse",e.onTransportSwitch?.(),Oe(),le();return}W("stream-auth",{code:"url-token-unavailable"}),G("ws-auth-token-unavailable",E);return}if(E!==A||c||a.aborted)return;if(!i()){G("runtime-change",E);return}if(m==="sse"&&co()){try{await Fe()}catch{if(E!==A||c||a.aborted)return;W("stream-auth",{code:"url-token-unavailable"}),G("sse-auth-token-unavailable",E);return}if(E!==A||c||a.aborted||!i())return}const T=se??l??void 0,z=Bs(m,{...u!==void 0?{fromSequence:u}:{},...t.sessionId?{sessionId:t.sessionId}:{},...T?{streamEpoch:T}:{},...f?{cursor:f}:{}},R),ue=()=>$o(E),ve=I=>de(I,E),sr=I=>G(I,E),ir=Qi({...u!==void 0?{fromSequence:u}:{},...t.sessionId?{sessionId:t.sessionId}:{},...T?{streamEpoch:T}:{},...f?{cursor:f}:{}});k=m==="ws"?Gu(z,a,ue,ve,sr,xu):Wu(ir,a,ue,()=>v(E),ve,sr,{setupTimeoutMs:B,...co()?{classifySourceError:I=>qu(s,Be,I)}:{}})},Ge=()=>{!Cs()||!vs()||$()},lt=()=>{if(!(!co()||c||a.aborted)){if(w){$();return}w=!0,nr(),Oe(),C=!1,N("system-resume",!1)}};typeof window<"u"&&(window.addEventListener("pichamber:system-resume",lt),window.addEventListener("online",Ge)),typeof document<"u"&&document.addEventListener("visibilitychange",Ge);const ut=()=>{c||(c=!0,typeof window<"u"&&(window.removeEventListener("pichamber:system-resume",lt),window.removeEventListener("online",Ge)),typeof document<"u"&&document.removeEventListener("visibilitychange",Ge),o?.removeEventListener("abort",n),a.removeEventListener("abort",ut),nr(),Oe(),te?.abort(),te=null,a.aborted||r.abort())};return a.aborted?ut():a.addEventListener("abort",ut,{once:!0}),le(),{dispose:ut,reconnect:(E="manual")=>{c||a.aborted||(nr(),Oe(),N(E))},get eventsUrl(){const E=se??l??void 0;return Bs(m,{...u!==void 0?{fromSequence:u}:{},...t.sessionId?{sessionId:t.sessionId}:{},...E?{streamEpoch:E}:{},...f?{cursor:f}:{}})}}},Vu=3e4,Rt=6e4,Ju=1,Yu=300,Xu=e=>new Promise(t=>setTimeout(t,e)),ks=660*1e3,y=async(e,t)=>{const r=t.runtimeKey;if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");const o=t.query?`?${new URLSearchParams(Object.entries(t.query).map(([c,d])=>[c,String(d)])).toString()}`:"",n={Accept:"application/json"};t.body!==void 0&&(n["Content-Type"]="application/json");const s=t.retry!==!1?Ju:0;let i;for(let c=0;c<=s;c+=1){if(c>0){if(t.signal?.aborted)break;if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");if(await Xu(Yu),t.signal?.aborted)break;if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request")}const d=new AbortController,l=setTimeout(()=>d.abort(),t.timeoutMs??Vu),u=t.signal,f=()=>d.abort();u&&(u.aborted?d.abort():u.addEventListener("abort",f,{once:!0}));try{const m=await b(e+o,{method:t.method,headers:n,body:t.body===void 0?void 0:JSON.stringify(t.body),signal:d.signal});if(!m.ok){const p=(await m.json().catch(()=>null))?.error??{code:"DAEMON_REQUEST_FAILED"};if(m.status===503&&(p.code==="DAEMON_UNAVAILABLE"||p.code==="DAEMON_TIMEOUT")&&c<s&&!u?.aborted){i=new L(p.code,p.message,m.status);continue}throw new L(p.code,p.message,m.status,p.reason,p.messages)}if(m.status===204){if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");return}const g=await m.json();if(r&&r!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request");return g}catch(m){if(i=m,m instanceof L||u?.aborted||m instanceof DOMException&&m.name==="AbortError")throw m;if(c<s&&!u?.aborted)continue;throw m}finally{clearTimeout(l),u&&u.removeEventListener("abort",f)}}throw i};class L extends Error{code;status;reason;messages;constructor(t,r,o,n,a){super(r??`Pi request failed: ${t}`),this.name="PiRequestError",this.code=t,o!==void 0&&(this.status=o),typeof n=="string"&&(this.reason=n),Array.isArray(a)&&(this.messages=a.filter(s=>typeof s=="string"))}}class ur extends Error{code;status;reason;constructor(t,r,o){super(r??`Pi send outcome unknown: ${t}`,o?.cause!==void 0?{cause:o.cause}:void 0),this.name="PiSendUnconfirmedError",this.code=t,o?.status!==void 0&&(this.status=o.status),typeof o?.reason=="string"&&(this.reason=o.reason),o?.cause!==void 0&&this.cause===void 0&&(this.cause=o.cause)}}const Qu=e=>{if(!e||typeof e!="object")return!1;const t=e;if(!Array.isArray(t.sessions))return!1;if(t.sequence===void 0){if(t.incomplete!==!0)return!1}else if(!Number.isSafeInteger(t.sequence)||t.sequence<0)return!1;for(const r of t.sessions){if(!r||typeof r!="object")return!1;const o=r;if(typeof o.sessionId!="string"||o.sessionId.length===0||typeof o.directory!="string"||o.directory.length===0||!Au(o.pending))return!1}return!0},on=e=>{if(!e||typeof e!="object")return!1;const t=e;return!(t.accepted!==!0||typeof t.messageId!="string"||t.messageId.length===0||t.deduplicated!==void 0&&t.deduplicated!==!0)},Zu=e=>{if(!(e instanceof L))return!1;const t=e.status;return typeof t!="number"||!Number.isInteger(t)?!1:t===503&&e.code==="SANDBOX_UNAVAILABLE"?!0:!(t<400||t>499||t===408||e.code==="OPERATION_EXPIRED"||e.code==="STALE_STREAM_EPOCH")},nn=e=>e instanceof ur?e:e instanceof L?new ur(e.code,e.message,{status:e.status,cause:e,reason:e.reason}):e instanceof DOMException&&e.name==="AbortError"?new ur("DAEMON_TIMEOUT",e.message||"Send timed out",{cause:e}):e instanceof Error?new ur("DAEMON_REQUEST_FAILED",e.message,{cause:e}):new ur("DAEMON_REQUEST_FAILED",void 0,{cause:e}),F=e=>{if(e?.runtimeKey&&e.runtimeKey!==D())throw new L("DAEMON_UNAVAILABLE","Runtime changed during request")},Yr=(e,t,r)=>{const o=Ze(e,t);if(!r||!o||r!==o)throw new L("STALE_STREAM_EPOCH","The Pi runtime restarted before this send could be verified.",409);return r},Zi=5e3,Ds=32,be=new Map,Xr=new Map,ec=new Map,ef=(e,t)=>`${e}
6
+ ${t?.trim()??""}`,lo=e=>ec.get(e)??0,Qr=e=>{ec.set(e,lo(e)+1);const t=`${e}
7
+ `;for(const r of[...be.keys()])r.startsWith(t)&&be.delete(r)},tf=(e,t,r)=>{if(be.size>=Ds){const o=Date.now();for(const[n,a]of be)o-a.settledAt>=Zi&&be.delete(n);for(;be.size>=Ds;){const n=be.keys().next().value;if(typeof n!="string")break;be.delete(n)}}be.set(e,{response:t,settledAt:r})};class rf{currentDirectory;setDirectory(t){this.currentDirectory=t}getDirectory(){return this.currentDirectory}async health(t){F(t);const r=await Eo(void 0,t?.runtimeKey);return r.state==="ready"?{protocolVersion:r.protocolVersion,state:"ready",capabilities:r.capabilities,...r.streamEpoch?{streamEpoch:r.streamEpoch}:{}}:{protocolVersion:r.protocolVersion,state:"unavailable",capabilities:r.capabilities,...r.error?{error:r.error}:{}}}async listProjects(t){return F(t),y("/api/pi/projects",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async selectProject(t,r){return F(r),y("/api/pi/projects/select",{method:"POST",body:{directory:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listSessions(t){F(t);const r=t?.directory??this.currentDirectory;return y("/api/pi/sessions",{method:"GET",...r?{query:{directory:r}}:{},...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async listPendingInput(t){F(t);const r=await y("/api/pi/sessions/pending-input",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}});if(!Qu(r))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed pending-input list");return r}async createSession(t,r){return F(r),y("/api/pi/sessions",{method:"POST",body:t,timeoutMs:Rt,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSession(t,r){F(r);const o=r?.directory??this.currentDirectory;return y(`/api/pi/sessions/${encodeURIComponent(t)}`,{method:"GET",timeoutMs:Rt,...o?{query:{directory:o}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSessionMessages(t,r,o){F(o);const n=o?.directory??this.currentDirectory;return y(`/api/pi/sessions/${encodeURIComponent(t)}/messages`,{method:"GET",timeoutMs:Rt,query:{...n?{directory:n}:{},...r.before?{before:r.before}:{},...r.limit!==void 0?{limit:r.limit}:{}},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async renameSession(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}`,{method:"PATCH",body:{sessionId:t.sessionId,title:t.title},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async discardDraftSession(t,r){return F(r),(await y(`/api/pi/sessions/${encodeURIComponent(t)}/discard-draft`,{method:"POST",...r?.directory?{query:{directory:r.directory}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}))?.discarded===!0}async deleteSession(t,r){F(r);try{return await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}`,{method:"DELETE",...r?.directory?{query:{directory:r.directory}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}),!0}catch(o){if(o instanceof L&&o.status===404)return!0;throw o}}async archiveSession(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/archive`,{method:"POST",body:{sessionId:t.sessionId,archived:t.archived,...r?.directory?{directory:r.directory}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSessionShelf(t){F(t);const r=await y("/api/pi/session-shelf",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}});if(!Eu(r))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed session shelf");return r}async setSessionShelf(t,r){F(r);const{sessionId:o,...n}=t,s=(await y(`/api/pi/sessions/${encodeURIComponent(o)}/shelf`,{method:"POST",body:{...n,...r?.directory?{directory:r.directory}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}))?.entry;if(s!==null&&!Vi(s))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed session shelf entry");return s}async getSessionTree(t,r){return F(r),y(`/api/pi/sessions/${encodeURIComponent(t)}/tree`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async navigateSession(t,r,o){return F(o),y(`/api/pi/sessions/${encodeURIComponent(t)}/navigate`,{method:"POST",body:{messageId:r},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async forkSession(t,r){return F(r),y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/fork`,{method:"POST",timeoutMs:Rt,body:{sessionId:t.sessionId,...t.messageId?{messageId:t.messageId}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async cloneSession(t,r){return F(r),y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/clone`,{method:"POST",body:t,timeoutMs:Rt,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async sendPrompt(t,r){return this.sendWithReceipt("prompt",t,`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/prompt`,r)}async sendSteer(t,r){return this.sendWithReceipt("steer",t,`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/steer`,r)}async sendFollowUp(t,r){return this.sendWithReceipt("followUp",t,`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/follow-up`,r)}async getSendReceipt(t,r){const o=r?.runtimeKey??D();F({...r,runtimeKey:o});const n=Yr(o,t.sessionId,t.streamEpoch??r?.streamEpoch??Ze(o,t.sessionId)),a=r?.directory??this.currentDirectory,s=await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/send-receipt`,{method:"POST",body:{kind:t.kind,operationId:t.operationId,streamEpoch:n},...a?{query:{directory:a}}:{},runtimeKey:o});if(F({...r,runtimeKey:o}),Yr(o,t.sessionId,n),!s||typeof s!="object")throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send receipt");const i=s.status;if(i==="accepted"){const c=s.receipt;if(!on(c))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send receipt");return{status:"accepted",receipt:c}}if(i==="pending"||i==="expired"||i==="unknown")return{status:i};throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send receipt")}async sendWithReceipt(t,r,o,n){const a=n?.runtimeKey??D();let s;try{F({...n,runtimeKey:a}),s=Yr(a,r.sessionId,n?.streamEpoch??Ze(a,r.sessionId))}catch(c){throw nn(c)}const i=n?.directory??this.currentDirectory;try{const c=await y(o,{method:"POST",body:{...r,streamEpoch:s},...i?{query:{directory:i}}:{},runtimeKey:a,retry:!1,timeoutMs:Rt});if(!on(c))throw new L("DAEMON_PROTOCOL_MISMATCH","Malformed send response");return F({...n,runtimeKey:a}),Yr(a,r.sessionId,s),c}catch(c){if(c instanceof L&&c.code==="STALE_STREAM_EPOCH")throw nn(c);if(Zu(c))throw c;const d=r.operationId;if(typeof d=="string"&&d.length>0)try{F({...n,runtimeKey:a});const l=this.getSendReceipt;if(!l)throw new L("DAEMON_UNAVAILABLE","Send receipt lookup unavailable");const u=await l.call(this,{sessionId:r.sessionId,kind:t,operationId:d,streamEpoch:s},{...n,runtimeKey:a,streamEpoch:s});if(F({...n,runtimeKey:a}),typeof u=="object"&&u!==null&&u.status==="accepted"&&on(u.receipt))return u.receipt}catch{}throw nn(c)}}async abortSession(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/abort`,{method:"POST",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setSessionModel(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/model`,{method:"POST",body:{sessionId:t.sessionId,model:t.model},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setSessionThinking(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/thinking`,{method:"POST",body:{sessionId:t.sessionId,thinking:t.thinking},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async compactSession(t,r){if(F(r),(await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/compact`,{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})).accepted!==!0)throw new L("DAEMON_PROTOCOL_MISMATCH")}async runBash(t,r){F(r);const o=await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/bash`,{method:"POST",body:{command:t.command,...t.excludeFromContext?{excludeFromContext:!0}:{},...t.clientId?{clientId:t.clientId}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}});if(o?.accepted!==!0||typeof o.id!="string")throw new L("DAEMON_PROTOCOL_MISMATCH");return{id:o.id}}async abortBash(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/bash/abort`,{method:"POST",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listProviders(t){return F(t),y("/api/pi/providers",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async listEngines(t){return F(t),y("/api/pi/engines",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async refreshProviders(t){return F(t),y("/api/pi/providers/refresh",{method:"POST",...t?.directory?{body:{directory:t.directory}}:{body:void 0},...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async getProviderStatus(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t)}/status`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async loginProvider(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/login`,{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getProviderLogin(t,r,o){return F(o),y(`/api/pi/providers/${encodeURIComponent(t)}/login/${encodeURIComponent(r)}`,{method:"GET",...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async respondProviderLogin(t,r,o,n){return F(n),y(`/api/pi/providers/${encodeURIComponent(t)}/login/${encodeURIComponent(r)}/respond`,{method:"POST",body:{value:o},...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}})}async logoutProvider(t,r){F(r),await y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/logout`,{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getProviderConfig(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t)}/config`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setProviderModels(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/models`,{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async addProviderModel(t,r){return F(r),y(`/api/pi/providers/${encodeURIComponent(t.providerId)}/models`,{method:"POST",body:t.model,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getSandboxStatus(t){return F(t),y("/api/pi/sandbox",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async recheckSandbox(t){return F(t),y("/api/pi/sandbox/recheck",{method:"POST",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async listProjectSandboxes(t){return F(t),y("/api/pi/sandbox/projects",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async getSandboxDefaults(t){return F(t),(await y("/api/pi/sandbox/defaults",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})).defaults}async setSandboxDefaults(t,r){return F(r),y("/api/pi/sandbox/defaults",{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setProjectSandbox(t,r,o){return F(o),(await y(`/api/pi/sandbox/projects/${encodeURIComponent(t)}`,{method:"PUT",body:r,...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})).project}async getSandboxProfile(t){return F(t),(await y("/api/pi/sandbox/profile",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})).profile}async saveSandboxProfile(t,r){return F(r),(await y("/api/pi/sandbox/profile",{method:"PUT",body:{content:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})).profile}async resetSandboxProfile(t){return F(t),(await y("/api/pi/sandbox/profile",{method:"DELETE",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})).profile}async getSettings(t){return F(t),y("/api/pi/settings",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async setPiSettings(t,r){return F(r),y("/api/pi/settings/pi",{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setPiChamberDefaults(t,r){return F(r),y("/api/pi/settings/defaults",{method:"PUT",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listResources(t,r){const o=typeof t=="string"?r:t,n=typeof t=="string"?t:void 0;F(o);const a=o?.runtimeKey??D(),s=ef(a,n),i=lo(a);if(o?.reload!==!0){const m=be.get(s);if(m&&Date.now()-m.settledAt<Zi)return structuredClone(m.response)}const c=Xr.get(s);if(c&&c.revision===i)return structuredClone(await c.promise);const d=Date.now(),l=lo(a),u={},f=(async()=>{try{const m=await y("/api/pi/resources",{method:"GET",...n?{query:{directory:n}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}});if(D()===a&&lo(a)===l){const g=be.get(s);(!g||g.settledAt<=d)&&tf(s,m,Date.now())}return m}finally{Xr.get(s)?.promise===u.promise&&Xr.delete(s)}})();return u.promise=f,Xr.set(s,{revision:l,promise:f}),structuredClone(await f)}async listCommands(t,r){return F(r),y("/api/pi/commands",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listSnippets(t,r){return F(r),y("/api/pi/snippets",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async createSnippet(t,r){return F(r),y("/api/pi/snippets",{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async updateSnippet(t,r,o,n){return F(n),y(`/api/pi/snippets/${encodeURIComponent(t)}`,{method:"PUT",body:r,...o?{query:{directory:o}}:{},...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}})}async deleteSnippet(t,r,o){return F(o),y(`/api/pi/snippets/${encodeURIComponent(t)}`,{method:"DELETE",...r?{query:{directory:r}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async updateResource(t,r){F(r);const o=r?.runtimeKey??D(),n=t.directory??r?.directory,a=await y(`/api/pi/resources/${encodeURIComponent(t.resourceId)}`,{method:"PUT",body:t,...n?{query:{directory:n}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}});return Qr(o),a}async createPromptTemplate(t,r,o){const n=r??t.directory??o?.directory;F(o);const a=o?.runtimeKey??D(),s=await y("/api/pi/resources/prompts",{method:"POST",body:t,...n?{query:{directory:n}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}});return Qr(a),s}async updatePromptTemplate(t,r,o,n){F(n);const a=n?.runtimeKey??D(),s=o??r.directory??n?.directory,i=await y(`/api/pi/resources/prompts/${encodeURIComponent(t)}`,{method:"PUT",body:r,...s?{query:{directory:s}}:{},...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}});return Qr(a),i}async deletePromptTemplate(t,r,o){F(o);const n=o?.runtimeKey??D(),a=r??o?.directory,s=await y(`/api/pi/resources/prompts/${encodeURIComponent(t)}`,{method:"DELETE",...a?{query:{directory:a}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}});return Qr(n),s}async createAttachment(t,r){return F(r),(await y("/api/pi/attachments",{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})).attachment}async uploadAttachment(t,r,o){F(o);const n=await yu("/api/pi/attachments",t,r);if(!n.ok){const i=(await n.json().catch(()=>null))?.error??{code:"ATTACHMENT_FAILED"};throw new L(i.code,i.message,n.status)}const a=await n.json();return F(o),a.attachment}async deleteAttachment(t,r){F(r),await y(`/api/pi/attachments/${encodeURIComponent(t)}`,{method:"DELETE",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async listPlugins(t,r){return F(r),y("/api/pi/plugins",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setPluginEnabled(t,r,o){return F(o),y(`/api/pi/plugins/${encodeURIComponent(t)}`,{method:"PUT",body:{enabled:r},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async setPluginState(t,r,o){return F(o),y(`/api/pi/plugins/${encodeURIComponent(t)}/state`,{method:"PUT",body:r,...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async getPluginSessionState(t,r){return F(r),y(`/api/pi/plugins/sessions/${encodeURIComponent(t)}`,{method:"GET",...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setPluginSessionState(t,r,o,n){return F(n),y(`/api/pi/plugins/${encodeURIComponent(t)}/sessions/${encodeURIComponent(r)}`,{method:"PUT",body:o,...n?.runtimeKey?{runtimeKey:n.runtimeKey}:{}})}async listExtensions(t,r){return F(r),y("/api/pi/extensions",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getExtensionConfig(t,r){return F(r),y("/api/pi/extensions/config",{method:"GET",...t?{query:{directory:t}}:{},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async setExtensionConfig(t,r,o){return F(o),y(`/api/pi/extensions/config/${encodeURIComponent(t)}`,{method:"PUT",body:r,retry:!1,...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async removeExtensionPackage(t,r,o){return F(o),y(`/api/pi/extensions/packages/${encodeURIComponent(t)}`,{method:"DELETE",retry:!1,...r?{query:{directory:r}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async installExtensionPackage(t,r){return F(r),y("/api/pi/extensions/packages",{method:"POST",body:t,retry:!1,timeoutMs:ks,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async updateExtensionPackage(t,r,o){return F(o),y(`/api/pi/extensions/packages/${encodeURIComponent(t)}/update`,{method:"POST",retry:!1,timeoutMs:ks,...r?{query:{directory:r}}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async searchMarketplace(t,r){F(r);const o={};return t.query&&(o.q=t.query),t.from&&(o.from=String(t.from)),t.pichamberOnly&&(o.pichamber="1"),y("/api/pi/marketplace/search",{method:"GET",query:o,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getMarketplaceFeatured(t){return F(t),y("/api/pi/marketplace/featured",{method:"GET",...t?.runtimeKey?{runtimeKey:t.runtimeKey}:{}})}async getMarketplacePackage(t,r){return F(r),y("/api/pi/marketplace/package",{method:"GET",query:{name:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getMarketplaceVersions(t,r){return F(r),y("/api/pi/marketplace/versions",{method:"GET",query:{names:t.join(",")},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async getExtensionPalette(t,r){return F(r),y("/api/pi/extensions/palette",{method:"POST",body:{terminal:t},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async respondToExtensionDialog(t,r){F(r),await y("/api/pi/extensions/respond",{method:"POST",body:t,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}async runExtensionControl(t,r){F(r);const o={...t,...r?.directory?{directory:r.directory}:{}};return{ran:(await y("/api/pi/extensions/control",{method:"POST",body:o,...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}}))?.ran===!0}}async sendExtensionSurface(t,r,o){F(o);const{sessionId:n,...a}=r;await y(`/api/pi/sessions/${encodeURIComponent(n)}/extensions/custom/${t}`,{method:"POST",body:a,...t==="input"||t==="close"?{retry:!1}:{},...o?.runtimeKey?{runtimeKey:o.runtimeKey}:{}})}async updateExtensionDraft(t,r){F(r),await y(`/api/pi/sessions/${encodeURIComponent(t.sessionId)}/editor-draft`,{method:"POST",body:{text:t.text,revision:t.revision,...t.directory?{directory:t.directory}:{}},...r?.runtimeKey?{runtimeKey:r.runtimeKey}:{}})}}const At=new rf;async function of(e){return(await af(e)).home}let Sn=null,yr=null;const Hb=()=>{Sn=null,yr=null},nf=async()=>{let e=null,t=null;try{const r=await b("/api/fs/home",{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(r.ok){const o=await r.json().catch(()=>null);typeof o?.home=="string"&&o.home.trim().length>0&&(e=o.home.trim()),typeof o?.pichamberDataDir=="string"&&o.pichamberDataDir.trim().length>0&&(t=o.pichamberDataDir.trim())}}catch{}return{home:e,pichamberDataDir:t}},af=async e=>{const t=D();if(!e?.fresh){const o=Sn;if(o&&o.key===t)return o.state;const n=yr;if(n&&n.key===t)return n.promise}const r=(async()=>{const o=await nf();return!e?.fresh&&o.home&&D()===t&&(Sn={key:t,state:o}),o})();e?.fresh||(yr={key:t,promise:r});try{return await r}finally{yr?.promise===r&&(yr=null)}};async function Kb(e,t){if(!e||e.trim().length===0)return[];const r={path:e},o=Ie().api("/api/fs/list",r),n=await b(o);if(!n.ok)return[];const a=await n.json();return Array.isArray(a.entries)?a.entries:[]}async function sf(e,t){const r=t?.directory||"";if(!r)return[];const o={directory:r,query:e};t?.limit&&(o.limit=t.limit),t?.includeHidden&&(o.includeHidden=!0),t?.respectGitignore!==void 0&&(o.respectGitignore=t.respectGitignore),t?.type&&(o.type=t.type);const n=Ie().api("/api/fs/find",o),a=await b(n);if(!a.ok)return[];const s=await a.json();return Array.isArray(s.files)?s.files:[]}async function jb(e=""){try{const t=await b("/api/fs/pick-directory",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({path:e||void 0})}),r=await t.json().catch(()=>null);return r?.cancelled===!0?{status:"cancelled"}:t.status===501?{status:"unavailable",error:typeof r?.error=="string"?r.error:"Folder picker is not available."}:t.ok?typeof r?.path=="string"&&r.path.trim()?{status:"picked",path:r.path.trim()}:{status:"failed",error:"Failed to select directory."}:{status:"failed",error:typeof r?.error=="string"?r.error:"Failed to select directory."}}catch(t){return{status:"failed",error:t instanceof Error?t.message:"Failed to select directory."}}}const $b={explore:{label:"Explore the codebase",icon:"compass-3",text:"Explore this codebase and explain how it works. Start with an overview, then key files and data flow."},plan:{label:"Plan the work",icon:"list-check-2",text:"Plan this work before coding. Break it into small steps, list files to change, and call out risks."},review:{label:"Review my changes",icon:"file-search",text:"Review my current changes for bugs, edge cases, and regressions. Suggest specific fixes."},"find-bugs":{label:"Find bugs",icon:"bug",text:"Find bugs in the current selection. List each issue with what is wrong and a minimal fix."},"write-tests":{label:"Write tests",icon:"flask",text:"Write tests for the current selection. Cover the happy path, edge cases, and failure modes."}},cf=e=>typeof e=="string"&&(e==="explore"||e==="plan"||e==="review"||e==="find-bugs"||e==="write-tests"),zb=[{type:"text",key:"explore"},{type:"text",key:"plan"},{type:"text",key:"review"},{type:"text",key:"find-bugs"},{type:"text",key:"write-tests"}],qb="book-open",df=/^[^\s/]+$/,Ss=e=>e.type==="prompt"?`prompt:${e.name}`:`text:${e.key}`,Wb=(e,t)=>e.type!==t.type?!1:e.type==="prompt"&&t.type==="prompt"?e.name===t.name:e.type==="text"&&t.type==="text"?e.key===t.key:!1,Gb=e=>{const t=e.replace(/^\//,"").replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):e},Ma=e=>{if(!Array.isArray(e))return[];const t=[],r=new Set;for(const o of e){if(!o||typeof o!="object")continue;const n=o;if(n.type==="text"){if(!cf(n.key))continue;const d={type:"text",key:n.key},l=Ss(d);if(r.has(l))continue;r.add(l),t.push(d);continue}if(n.type!=="prompt")continue;const a=typeof n.name=="string"?n.name.trim():"";if(!a||!df.test(a))continue;const s=n.scope==="global"||n.scope==="project"?n.scope:void 0,i=s?{type:"prompt",name:a,scope:s}:{type:"prompt",name:a},c=Ss(i);r.has(c)||(r.add(c),t.push(i))}return t},lf=e=>{let t,r=-1;for(const o of e){const a=(o.location==="project"?2:o.location==="global"?1:0)+(o.editable?.5:0);a>r&&(t=o,r=a)}return t},Vb=e=>{const t=new Map;for(const o of e){const n=t.get(o.name)??[];n.push(o),t.set(o.name,n)}const r=new Map;for(const[o,n]of t){const a=lf(n);a&&r.set(o,a)}return r},Jb=(e,t)=>{const r=new Set,o=s=>s.filter(i=>{const c=i.insertText.trim();return r.has(c)?!1:(r.add(c),!0)}),n=o(e),a=o(t);return{project:n,global:a}},uf={markdown:"0.875rem",code:"0.8125rem",uiHeader:"0.9375rem",uiLabel:"0.8750rem",meta:"0.8125rem",micro:"0.75rem",settingsPageTitle:"1.125rem"};function Ms(e){return`--text-${e.replace(/([A-Z])/g,"-$1").toLowerCase()}`}const Zr={semanticMarkdown:{fontSize:"var(--text-markdown)"},semanticCode:{fontSize:"var(--text-code)"},uiHeader:{fontSize:"var(--text-ui-header)"},uiLabel:{fontSize:"var(--text-ui-label)"},meta:{fontSize:"var(--text-meta)"},micro:{fontSize:"var(--text-micro)"},ui:{button:{fontSize:"var(--text-ui-label)",lineHeight:"var(--ui-button-line-height)",letterSpacing:"var(--ui-button-letter-spacing)",fontWeight:"var(--ui-button-font-weight)"},buttonSmall:{fontSize:"var(--text-meta)",lineHeight:"var(--ui-button-small-line-height)",letterSpacing:"var(--ui-button-small-letter-spacing)",fontWeight:"var(--ui-button-small-font-weight)"},buttonLarge:{fontSize:"var(--text-ui-label)",lineHeight:"var(--ui-button-large-line-height)",letterSpacing:"var(--ui-button-large-letter-spacing)",fontWeight:"var(--ui-button-large-font-weight)"},label:{fontSize:"var(--text-meta)",lineHeight:"var(--ui-label-line-height)",letterSpacing:"var(--ui-label-letter-spacing)",fontWeight:"var(--ui-label-font-weight)"},caption:{fontSize:"var(--text-micro)",lineHeight:"var(--ui-caption-line-height)",letterSpacing:"var(--ui-caption-letter-spacing)",fontWeight:"var(--ui-caption-font-weight)"},badge:{fontSize:"var(--text-micro)",lineHeight:"var(--ui-badge-line-height)",letterSpacing:"var(--ui-badge-letter-spacing)",fontWeight:"var(--ui-badge-font-weight)"},tooltip:{fontSize:"var(--text-micro)",lineHeight:"var(--ui-tooltip-line-height)",letterSpacing:"var(--ui-tooltip-letter-spacing)",fontWeight:"var(--ui-tooltip-font-weight)"},input:{fontSize:"var(--text-ui-label)",lineHeight:"var(--ui-input-line-height)",letterSpacing:"var(--ui-input-letter-spacing)",fontWeight:"var(--ui-input-font-weight)"},helperText:{fontSize:"var(--text-meta)",lineHeight:"var(--ui-helper-text-line-height)",letterSpacing:"var(--ui-helper-text-letter-spacing)",fontWeight:"var(--ui-helper-text-font-weight)"}},code:{inline:{fontSize:"var(--text-code)",lineHeight:"var(--code-inline-line-height)",letterSpacing:"var(--code-inline-letter-spacing)",fontWeight:"var(--code-inline-font-weight)"},block:{fontSize:"var(--text-code)",lineHeight:"var(--code-block-line-height)",letterSpacing:"var(--code-block-letter-spacing)",fontWeight:"var(--code-block-font-weight)"},lineNumbers:{fontSize:"var(--text-micro)",lineHeight:"var(--code-line-numbers-line-height)",letterSpacing:"var(--code-line-numbers-letter-spacing)",fontWeight:"var(--code-line-numbers-font-weight)"}},markdown:{body:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-body-line-height)",letterSpacing:"var(--markdown-body-letter-spacing)",fontWeight:"var(--markdown-body-font-weight)"},bodySmall:{fontSize:"var(--text-meta)",lineHeight:"var(--markdown-body-small-line-height)",letterSpacing:"var(--markdown-body-small-letter-spacing)",fontWeight:"var(--markdown-body-small-font-weight)"},bodyLarge:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-body-large-line-height)",letterSpacing:"var(--markdown-body-large-letter-spacing)",fontWeight:"var(--markdown-body-large-font-weight)"},blockquote:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-blockquote-line-height)",letterSpacing:"var(--markdown-blockquote-letter-spacing)",fontWeight:"var(--markdown-blockquote-font-weight)"},list:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-list-line-height)",letterSpacing:"var(--markdown-list-letter-spacing)",fontWeight:"var(--markdown-list-font-weight)"},link:{fontSize:"var(--text-markdown)",lineHeight:"var(--markdown-link-line-height)",letterSpacing:"var(--markdown-link-letter-spacing)",fontWeight:"var(--markdown-link-font-weight)"},code:{fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-line-height)",letterSpacing:"var(--markdown-code-letter-spacing)",fontWeight:"var(--markdown-code-font-weight)"},codeBlock:{fontSize:"var(--text-code)",lineHeight:"var(--markdown-code-block-line-height)",letterSpacing:"var(--markdown-code-block-letter-spacing)",fontWeight:"var(--markdown-code-block-font-weight)"}},tool:{collapsed:{fontSize:"var(--text-code)",lineHeight:"var(--code-block-line-height)",letterSpacing:"var(--code-block-letter-spacing)",fontWeight:"var(--code-block-font-weight)"},popup:{fontSize:"var(--text-code)",lineHeight:"var(--code-block-line-height)",letterSpacing:"var(--code-block-letter-spacing)",fontWeight:"var(--code-block-font-weight)"},inline:{fontSize:"var(--text-code)",lineHeight:"var(--code-inline-line-height)",letterSpacing:"var(--code-inline-letter-spacing)",fontWeight:"var(--code-inline-font-weight)"}}},an={padding:{collapsed:"0.375rem",popup:"0.75rem",popupContainer:"1rem"},backgroundOpacity:{muted:"30",mutedAlt:"50"},getCollapsedStyles:()=>({...Zr.tool.collapsed,background:"transparent",backgroundColor:"transparent",margin:0,padding:an.padding.collapsed,borderRadius:0}),getPopupStyles:()=>({...Zr.tool.popup,background:"transparent",backgroundColor:"transparent",margin:0,padding:an.padding.popup,borderRadius:"0.75rem"}),getPopupContainerStyles:()=>({...Zr.tool.popup,background:"transparent",backgroundColor:"transparent",margin:0,padding:an.padding.popupContainer,borderRadius:"0.5rem",overflowX:"auto"}),getInlineStyles:()=>({...Zr.tool.inline})},ff=[{id:"inter",label:"Inter",description:"Modern UI sans with excellent readability at small sizes.",stack:'"Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Inter",packageName:"@fontsource/inter",filePrefix:"inter",weights:[400,500,600]}},{id:"geist-sans",label:"Geist Sans",description:"Crisp sans-serif with a technical interface feel.",stack:'"Geist Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Geist Sans",packageName:"@fontsource/geist-sans",filePrefix:"geist-sans",weights:[400,500,600]}},{id:"atkinson-hyperlegible",label:"Atkinson Hyperlegible",description:"Accessibility-focused sans-serif optimized for character distinction.",stack:'"Atkinson Hyperlegible", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Atkinson Hyperlegible",packageName:"@fontsource/atkinson-hyperlegible",filePrefix:"atkinson-hyperlegible",weights:[400,700]}},{id:"source-sans-3",label:"Source Sans 3",description:"Adobe sans-serif tuned for clean, readable interfaces.",stack:'"Source Sans 3", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Source Sans 3",packageName:"@fontsource/source-sans-3",filePrefix:"source-sans-3",weights:[400,500,600]}},{id:"roboto",label:"Roboto",description:"Familiar Material-style sans-serif with broad UI usage.",stack:'"Roboto", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Roboto",packageName:"@fontsource/roboto",filePrefix:"roboto",weights:[400,500,600]}},{id:"noto-sans",label:"Noto Sans",description:"Readable sans-serif with strong international coverage.",stack:'"Noto Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Noto Sans",packageName:"@fontsource/noto-sans",filePrefix:"noto-sans",weights:[400,500,600]}},{id:"dm-sans",label:"DM Sans",description:"Modern product UI sans-serif with friendly proportions.",stack:'"DM Sans", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"DM Sans",packageName:"@fontsource/dm-sans",filePrefix:"dm-sans",weights:[400,500,600]}},{id:"manrope",label:"Manrope",description:"Polished geometric sans-serif for modern app interfaces.",stack:'"Manrope", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',source:{family:"Manrope",packageName:"@fontsource/manrope",filePrefix:"manrope",weights:[400,500,600]}},{id:"system",label:"System",description:"Native operating system interface font.",stack:'"SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif'}],mf=[{id:"jetbrains-mono",label:"JetBrains Mono",description:"Developer-focused monospace with strong punctuation clarity.",stack:'"JetBrains Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"JetBrains Mono",packageName:"@fontsource/jetbrains-mono",filePrefix:"jetbrains-mono",weights:[400,500,600]}},{id:"fira-code",label:"Fira Code",description:"Readable coding font with ligature support.",stack:'"Fira Code", "SFMono-Regular", "Menlo", monospace',source:{family:"Fira Code",packageName:"@fontsource/fira-code",filePrefix:"fira-code",weights:[400,500,600]}},{id:"geist-mono",label:"Geist Mono",description:"Sharp monospace pair for Geist Sans.",stack:'"Geist Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"Geist Mono",packageName:"@fontsource/geist-mono",filePrefix:"geist-mono",weights:[400,500,600]}},{id:"commit-mono",label:"Commit Mono",description:"Code-oriented monospace with polished editor ergonomics.",stack:'"Commit Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"Commit Mono",packageName:"@fontsource/commit-mono",filePrefix:"commit-mono",weights:[400,500,600]}},{id:"source-code-pro",label:"Source Code Pro",description:"Adobe monospace designed for source code readability.",stack:'"Source Code Pro", "SFMono-Regular", "Menlo", monospace',source:{family:"Source Code Pro",packageName:"@fontsource/source-code-pro",filePrefix:"source-code-pro",weights:[400,500,600]}},{id:"cascadia-code",label:"Cascadia Code",description:"Microsoft coding font popular in terminals and editors.",stack:'"Cascadia Code", "SFMono-Regular", "Menlo", monospace',source:{family:"Cascadia Code",packageName:"@fontsource/cascadia-code",filePrefix:"cascadia-code",weights:[400,500,600]}},{id:"roboto-mono",label:"Roboto Mono",description:"Neutral monospace companion to Roboto.",stack:'"Roboto Mono", "SFMono-Regular", "Menlo", monospace',source:{family:"Roboto Mono",packageName:"@fontsource/roboto-mono",filePrefix:"roboto-mono",weights:[400,500,600]}},{id:"iosevka",label:"Iosevka",description:"Compact monospace for dense code and terminal layouts.",stack:'"Iosevka", "SFMono-Regular", "Menlo", monospace',source:{family:"Iosevka",packageName:"@fontsource/iosevka",filePrefix:"iosevka",weights:[400,500,600]}},{id:"system-mono",label:"System Mono",description:"Native operating system monospace font.",stack:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'}],tc=e=>Object.fromEntries(e.map(t=>[t.id,t])),gf=tc(ff),pf=tc(mf),hf="system",Ff="system-mono",rc=e=>typeof e=="string"&&e in gf,oc=e=>typeof e=="string"&&e in pf,sn="pichamber.pwaName",Mn="pichamber.mobileKeyboardMode",Yb="pichamber.pwaRecentSessions",yf=["native","resize-content"];function bf(e,t="resize-content"){return typeof e=="string"&&yf.includes(e)?e:t}const Af=64;function nc(e,t){if(typeof e!="string")return t;const r=e.trim().replace(/\s+/g," ");return r?r.slice(0,Af):t}const Xb=()=>!0;function Ta(e,t="resize-content"){return bf(e,t)??void 0}const Ef=()=>{if(typeof window>"u")return"resize-content";try{return Ta(localStorage.getItem(Mn))}catch{return"resize-content"}},wf=e=>{const t=Ta(e);if(typeof window<"u")try{t==="resize-content"?localStorage.removeItem(Mn):localStorage.setItem(Mn,t)}catch{}return t},K=e=>{if(!e)return"";const t=e.replace(/\\/g,"/"),r=t.startsWith("//");let o=t.replace(/\/+$/g,"").replace(/\/+/g,"/");return r&&!o.startsWith("//")&&(o=`/${o}`),o||(t.startsWith("/")?"/":"")},Bf=["workspace","folder","timeline","threads"],Cf="workspace",ac=e=>typeof e=="string"&&Bf.includes(e),vf=["none","dither","ascii","halftone","strands","grain"],kf="none",Pa=e=>typeof e=="string"&&vf.includes(e),Qb=e=>e!=="none"&&e!=="grain",Zb=e=>e==="dither"||e==="ascii"||e==="halftone",sc=e=>typeof e=="string"&&/^[0-9a-f]{16}$/.test(e),eA=3,tA={width:7,height:13},Ts=" .:-=+*#%@",Df=[0,32,8,40,2,34,10,42,48,16,56,24,50,18,58,26,12,44,4,36,14,46,6,38,60,28,52,20,62,30,54,22,3,35,11,43,1,33,9,41,51,19,59,27,49,17,57,25,15,47,7,39,13,45,5,37,63,31,55,23,61,29,53,21].map(e=>(e+.5)/64),rA=(e,t)=>Df[(t&7)*8+(e&7)],bt=(e,t)=>{let r=Math.imul(e,374761393)^Math.imul(t,668265263);return r=Math.imul(r^r>>>13,1274126177),((r^r>>>16)>>>0)/4294967295},Tn=e=>e*e*(3-2*e),Sf=(e,t)=>{const r=Math.floor(e),o=Math.floor(t),n=Tn(e-r),a=Tn(t-o),s=bt(r,o)+(bt(r+1,o)-bt(r,o))*n,i=bt(r,o+1)+(bt(r+1,o+1)-bt(r,o+1))*n;return s+(i-s)*a},Oo=2*Math.PI/60,Mf={bottom:[.45,.78],session:[.12,.55]};function Ps(e,t,r){if(r==="none"||r==="full")return 1;const[o,n]=Mf[r],a=(e/Math.max(1,t)-o)/(n-o);return a<=0?1:a>=1?0:1-a}function Tf(e,t,r,o){const n=e/Math.max(1,r*.5),a=t/Math.max(1,o*.5),s=Math.min(1,Math.sqrt(n*n+a*a));return Tn(Math.min(1,Math.max(0,(s-.45)/.55)))}function Pf(e,t,r,o){const n=e/260,a=t/260;let s=0,i=.5,c=1;for(let l=0;l<4;l+=1)s+=i*Sf(n*c+l*17.3,a*c-l*9.1),i*=.5,c*=2;const d=Tf(e,t,r,o);return{noise:s,phase:(e*.6+t)/140+s*5,reveal:d}}function oA(e,t,r,o,n="none"){const a=Math.max(0,Math.ceil(e/r)),s=Math.max(0,Math.ceil(t/o)),i=e/2,c=t/2,d=[],l=[],u=[],f=[];for(let m=0;m<s;m+=1){const g=m*o+o/2-c;for(let h=0;h<a;h+=1){const p=Pf(h*r+r/2-i,g,e,t);n==="full"?p.reveal=1:n==="session"?p.reveal=Ps(g+c,t,n):n!=="none"&&(p.reveal*=Ps(g+c,t,n)),!(p.reveal<=0)&&(d.push(m*a+h),l.push(p.noise),u.push(p.phase),f.push(p.reveal))}}return{cols:a,rows:s,cells:Uint32Array.from(d),noise:Float32Array.from(l),phase:Float32Array.from(u),reveal:Float32Array.from(f)}}const Cr=4096,ic=Cr/(2*Math.PI),Rf=Float32Array.from({length:Cr},(e,t)=>.5+.5*Math.sin(t/ic)),No=e=>{const t=Math.floor(e*ic);return Rf[(t%Cr+Cr)%Cr]};function nA(e,t,r){const o=t*Oo,{noise:n,phase:a,reveal:s}=e;for(let i=0;i<e.cells.length;i+=1){const c=(n[i]*.55+No(a[i]-o)*.45-.35)*1.5;r[i]=c<=0?0:c>=1?s[i]:c*s[i]}}function aA(e,t,r){const o=t*Oo,{noise:n,phase:a}=e;for(let s=0;s<e.cells.length;s+=1)r[s]=n[s]*.55+No(a[s]-o)*.45}function sA(e,t,r){const o=t*Oo,{noise:n,phase:a}=e;for(let s=0;s<e.cells.length;s+=1)r[s]=n[s]*4*Math.PI+(No(a[s]-o)-.5)*1.2}const iA=(e,t)=>bt(e,t),cA=(e,t,r,o,n)=>{const a=(.2126*e+.7152*t+.0722*r)/255,s=n?a:1-a;return Math.min(1,Math.max(0,(s-.08)/.84))*(o/255)},If=.4;function dA(e,t,r,o){const n=r*Oo,{phase:a,reveal:s}=e;for(let i=0;i<e.cells.length;i+=1){const c=t[i]+(No(a[i]-n)-.5)*If;o[i]=c<=0?0:c>=1?s[i]:c*s[i]}}const lA=e=>Math.min(Ts.length-1,Math.floor(e*Ts.length)),_f=365,Jt=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=_f,uA=e=>e===1?"1 session":`${e} sessions`,Se=20,xf=8,Rs=4096,Of=2160*60*6e4,H=e=>{if(!e)return"";const t=e.replace(/\\/g,"/"),r=t.startsWith("//");let o=t.replace(/\/+/g,"/");r&&!o.startsWith("//")&&(o=`/${o}`);const n=o==="/",a=/^[A-Za-z]:\/$/.test(o);return!n&&!a&&(o=o.replace(/\/+$/,"")),o},Xe=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,et=(e,t)=>{const r=H(t),o=H(e);if(!r||!o)return!1;const n=Xe(r),a=Xe(o);return a===n||a.startsWith(`${n}/`)},fr=e=>{if(!e||typeof e!="object")return{};const t=e,r={};for(const[o,n]of Object.entries(t)){const a=H(o);if(!a||!n||typeof n!="object")continue;const s=n,i=Array.isArray(s.openPaths)?Array.from(new Set(s.openPaths.filter(m=>typeof m=="string").map(m=>H(m)).filter(m=>m.length<=Rs&&et(m,a)))).slice(-50):[],c=Array.isArray(s.expandedPaths)?Array.from(new Set(s.expandedPaths.filter(m=>typeof m=="string").map(m=>H(m)).filter(m=>m.length<=Rs&&et(m,a)))).slice(-500):[],d=typeof s.selectedPath=="string"?H(s.selectedPath):null,l=d&&et(d,a)?d:i[0]??null,u=typeof s.touchedAt=="number"&&Number.isFinite(s.touchedAt)?s.touchedAt:Date.now();if(Date.now()-u>Of)continue;const f=r[a];if(f){const m=Array.from(new Set([...f.openPaths,...i])),g=Array.from(new Set([...f.expandedPaths,...c])),h=f.selectedPath??l??m[0]??null;r[a]={openPaths:m,selectedPath:h,expandedPaths:g,touchedAt:Math.max(f.touchedAt,u)};continue}r[a]={openPaths:i,selectedPath:l,expandedPaths:c,touchedAt:u}}return Me(r,Se)},Me=(e,t)=>{const r=Object.entries(e);if(r.length<=t)return e;r.sort((n,a)=>(a[1]?.touchedAt??0)-(n[1]?.touchedAt??0));const o={};for(const[n,a]of r.slice(0,t))o[n]=a;return o},It=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Nf=xr()(Or(aa((e,t)=>({byRoot:{},activeRuntimeKey:D(),runtimeSnapshots:{},resetForRuntimeSwitch:r=>{e(o=>{const n={...o.runtimeSnapshots,[o.activeRuntimeKey]:{byRoot:fr(o.byRoot),updatedAt:Date.now()}};return{activeRuntimeKey:r,runtimeSnapshots:n,byRoot:fr(n[r]?.byRoot)}})},addOpenPath:(r,o,n)=>{const a=H((r||"").trim()),s=H((o||"").trim());!a||!s||!n?.allowOutsideRoot&&!et(s,a)||e(i=>{const c=i.byRoot[a],d=It(c),l=d.openPaths.includes(s),u=l?d.openPaths:[...d.openPaths,s],f=d.selectedPath??s;if(c&&l&&c.selectedPath===f)return i;const m={...i.byRoot,[a]:{...d,openPaths:u,selectedPath:f}};return{byRoot:Me(m,Se)}})},removeOpenPath:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||e(s=>{const i=s.byRoot[n];if(!i)return s;const c=Xe(a),d=g=>Xe(g)===c,l=i.selectedPath?d(i.selectedPath):!1;if(!i.openPaths.some(d)&&!l)return s;const u=i.openPaths.filter(g=>!d(g)),f=l?u[0]??null:i.selectedPath,m={...s.byRoot,[n]:{...i,openPaths:u,selectedPath:f,touchedAt:Date.now()}};return{byRoot:Me(m,Se)}})},removeOpenPathsByPrefix:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||e(s=>{const i=s.byRoot[n];if(!i)return s;const c=Xe(a),d=c.endsWith("/")?c:`${c}/`,l=g=>{const h=Xe(g);return h===c||h.startsWith(d)},u=i.openPaths.filter(g=>!l(g));if(u.length===i.openPaths.length)return s;const f=i.selectedPath&&l(i.selectedPath)?u[0]??null:i.selectedPath,m={...s.byRoot,[n]:{...i,openPaths:u,selectedPath:f,touchedAt:Date.now()}};return{byRoot:Me(m,Se)}})},removeExpandedPathsByPrefix:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||e(s=>{const i=s.byRoot[n];if(!i)return s;const c=Xe(a),d=c.endsWith("/")?c:`${c}/`,l=i.expandedPaths.filter(f=>{const m=Xe(f);return m!==c&&!m.startsWith(d)});if(l.length===i.expandedPaths.length)return s;const u={...s.byRoot,[n]:{...i,expandedPaths:l,touchedAt:Date.now()}};return{byRoot:Me(u,Se)}})},setSelectedPath:(r,o,n)=>{const a=H((r||"").trim()),s=o?H(o.trim()):null;!a||s&&!n?.allowOutsideRoot&&!et(s,a)||e(i=>{const c=i.byRoot[a],d=It(c),l=s&&!d.openPaths.includes(s)?[...d.openPaths,s]:d.openPaths;if(c&&c.selectedPath===s&&l===c.openPaths)return i;const u={...i.byRoot,[a]:{...d,openPaths:l,selectedPath:s}};return{byRoot:Me(u,Se)}})},ensureSelectedPath:r=>{const o=H((r||"").trim());if(!o)return;const n=t().byRoot[o];if(!n||n.selectedPath)return;const a=n.openPaths[0]??null;a&&t().setSelectedPath(o,a)},toggleExpandedPath:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||!et(a,n)||e(s=>{const i=s.byRoot[n],c=It(i),l=c.expandedPaths.includes(a)?c.expandedPaths.filter(f=>f!==a):[...c.expandedPaths,a];if(i&&i.expandedPaths===l&&i.selectedPath===c.selectedPath&&i.openPaths===c.openPaths)return s;const u={...s.byRoot,[n]:{...c,expandedPaths:l}};return{byRoot:Me(u,Se)}})},collapseAllExpandedPaths:r=>{const o=H((r||"").trim());o&&e(n=>{const a=n.byRoot[o];if(!a||a.expandedPaths.length===0)return n;const s={...n.byRoot,[o]:{...It(a),expandedPaths:[]}};return{byRoot:Me(s,Se)}})},expandPath:(r,o)=>{const n=H((r||"").trim()),a=H((o||"").trim());!n||!a||!et(a,n)||e(s=>{const i=s.byRoot[n],c=It(i);if(c.expandedPaths.includes(a)&&i)return s;const l={...s.byRoot,[n]:{...c,expandedPaths:[...c.expandedPaths,a]}};return{byRoot:Me(l,Se)}})},expandPaths:(r,o)=>{const n=H((r||"").trim());if(!n||!o||o.length===0)return;const a=o.map(s=>H((s||"").trim())).filter(s=>s&&et(s,n));a.length!==0&&e(s=>{const i=s.byRoot[n],c=It(i),d=new Set(c.expandedPaths),l=a.filter(f=>!d.has(f));if(l.length===0)return s;const u={...s.byRoot,[n]:{...c,expandedPaths:[...c.expandedPaths,...l]}};return{byRoot:Me(u,Se)}})}}),{name:"files-view-tabs-store",version:3,storage:pa(),migrate:(e,t)=>t<3||!e||typeof e!="object"?{byRoot:{},activeRuntimeKey:D(),runtimeSnapshots:{}}:e,partialize:e=>{const t={...e.runtimeSnapshots,[e.activeRuntimeKey]:{byRoot:fr(e.byRoot),updatedAt:Date.now()}},r=Object.fromEntries(Object.entries(t).sort(([,o],[,n])=>n.updatedAt-o.updatedAt).slice(0,xf).map(([o,n])=>[o,{byRoot:fr(n.byRoot),updatedAt:n.updatedAt}]));return{activeRuntimeKey:e.activeRuntimeKey,runtimeSnapshots:r}},merge:(e,t)=>{const r=e&&typeof e=="object"?e:{},o=r.runtimeSnapshots&&typeof r.runtimeSnapshots=="object"?r.runtimeSnapshots:{},n=D();return{...t,activeRuntimeKey:n,runtimeSnapshots:o,byRoot:fr(o[n]?.byRoot)}}}),{name:"files-view-tabs-store"})),Ra=12,Lf=4096,Uf=200,Hf=/^[A-Za-z0-9_.:-]{1,120}$/,Lo=()=>`page-${Math.random().toString(36).slice(2,10)}${Date.now().toString(36).slice(-4)}`,Pr=e=>{if(typeof e!="string")return null;const t=e.trim();return!t||t==="about:blank"?null:t.slice(0,Lf)},cc=e=>{if(typeof e!="string")return null;const t=e.replace(/\s+/g," ").trim();return t?t.slice(0,Uf):null},Rr=e=>e==="server"||e==="device"?e:null,dc=(e,t)=>t&&e.some(r=>r.id===t)?t:e[0]?.id??null,Kf=(e,t)=>{const r=e&&typeof e=="object"?e:null,o=[],n=new Set;if(r&&Array.isArray(r.pages))for(const s of r.pages){if(!s||typeof s!="object")continue;const i=s,c=typeof i.id=="string"?i.id:"";if(!(!Hf.test(c)||n.has(c))&&(n.add(c),o.push({id:c,url:Pr(i.url),route:Rr(i.route),title:cc(i.title)}),o.length>=Ra))break}o.length===0&&o.push({id:t.tabId,url:Pr(t.url),route:t.route,title:null});const a=typeof r?.activePageId=="string"?r.activePageId:null;return{pages:o,activePageId:dc(o,a)}},jf=(e,t=Lo)=>{const r=t();return{pages:[{id:r,url:Pr(e.url),route:Rr(e.route),title:null}],activePageId:r}},$f=(e,t,r=Lo)=>{const o=Pr(t.url),n=Rr(t.route),a=e.pages.find(l=>l.id===e.activePageId)??null,s=a&&(t.target==="current"||o!==null&&a.url===null||e.pages.length>=Ra);if(a&&s)return{pages:e.pages.map(u=>u.id===a.id?{...u,url:o??u.url,route:n??u.route,title:o&&o!==u.url?null:u.title}:u),activePageId:a.id,pageId:a.id};const i={id:r(),url:o,route:n,title:null},c=a?e.pages.indexOf(a):e.pages.length-1;return{pages:[...e.pages.slice(0,c+1),i,...e.pages.slice(c+1)],activePageId:i.id,pageId:i.id}},zf=(e,t,r=Lo)=>{if(e.pages.length>=Ra)return null;const o={id:r(),url:null,route:"server",title:null,popupId:t.popupId},n=e.pages.findIndex(i=>i.id===t.openerPageId),a=n===-1?e.pages.length-1:n;return{pages:[...e.pages.slice(0,a+1),o,...e.pages.slice(a+1)],activePageId:o.id,pageId:o.id}},qf=(e,t,r=Lo)=>{const o=e.pages.findIndex(s=>s.id===t);if(o===-1)return e;const n=e.pages.filter(s=>s.id!==t);if(n.length===0){const s={id:r(),url:null,route:e.pages[o].route,title:null};return{pages:[s],activePageId:s.id}}if(e.activePageId!==t)return{pages:n,activePageId:dc(n,e.activePageId)};const a=n[Math.min(o,n.length-1)];return{pages:n,activePageId:a.id}},Wf=(e,t)=>e.activePageId!==t&&e.pages.some(r=>r.id===t)?{...e,activePageId:t}:e,Gf=(e,t,r)=>{let o=!1;const n=e.pages.map(a=>{if(a.id!==t)return a;const s={...a};if(r.url!==void 0){const i=Pr(r.url);i&&i!==a.url&&(s.url=i)}return r.title!==void 0&&(s.title=cc(r.title)),r.route!==void 0&&(s.route=Rr(r.route)??a.route),r.defaultRoute!==void 0&&s.route===null&&(s.route=Rr(r.defaultRoute)),r.popupId===null&&delete s.popupId,(s.url!==a.url||s.title!==a.title||s.route!==a.route||s.popupId!==a.popupId)&&(o=!0),o?s:a});return o?{...e,pages:n}:e},fA=e=>{if(e.title)return e.title;if(!e.url)return"New tab";try{return new URL(e.url).host||e.url}catch{return e.url}},Vf=380,Jf=380,Yf=1400,lc=12,Is=120,Xf=["git","file","diff","context","terminal","browser","preview","pull-requests","issues","extensions","agents"],Qf=K,uo=e=>Number.isFinite(e)?Math.min(Yf,Math.max(Jf,Math.round(e))):Vf,Zf=e=>{if(typeof e.width=="number"&&Number.isFinite(e.width))return uo(e.width);if(!e.widthByMode||typeof e.widthByMode!="object")return;const t=e.widthByMode;for(const r of Xf){const o=t[r];if(typeof o=="number"&&Number.isFinite(o))return uo(o)}for(const r of Object.values(t))if(typeof r=="number"&&Number.isFinite(r))return uo(r)},wo=e=>{if(typeof e!="string")return null;const t=e.trim();return t?t.replace(/\\/g,"/"):null},Bo=e=>{if(typeof e!="string")return null;const t=e.trim();return t?t.length>Is?t.slice(0,Is):t:null},Ia=e=>e==="server"||e==="device"?e:null,_a=e=>e==="all"||e==="working"||e==="staged"||e==="turn"||e==="branch"?e:null,em=(e,t)=>(e==="file"||e==="preview")&&t||e,uc=(e,t,r)=>{if(e==="diff")return e;if(e==="browser")return xa;if(typeof r=="string"){const o=r.trim();if(o)return o}return em(e,t)},Pn=(e,t)=>t===e?e:`${e}:${t}`,xa="desktop-browser",fc=`browser:${xa}`,tm=(e,t)=>{let r=!1;const o=e.tabs.map(n=>{if(n.id!==fc||!n.browser)return n;const a=t(n.browser);return a===n.browser?n:(r=!0,{...n,browser:{pages:a.pages,activePageId:a.activePageId}})});return r?{...e,tabs:o}:e},Oa=e=>{const t=wo(e.targetPath),r=uc(e.mode,t,e.dedupeKey),o=Pn(e.mode,r),n=e.mode==="browser";return{id:o,mode:e.mode,targetPath:n?null:t,dedupeKey:r,label:Bo(e.label),sessionTitleFallback:Bo(e.sessionTitleFallback),readOnly:e.readOnly===!0,stagedDiff:e.stagedDiff===!0,diffScope:_a(e.diffScope)??(e.stagedDiff===!0?"staged":"working"),browser:n?jf({url:t,route:Ia(e.browserRoute)}):null,touchedAt:Date.now()}},mc=(e,t,r)=>{if(e.length<=t)return e;const n=[...e].sort((i,c)=>i.touchedAt-c.touchedAt).filter(i=>i.id!==r),a=e.length-t;if(a<=0||n.length===0)return e.slice(-t);const s=new Set(n.slice(0,a).map(i=>i.id));return e.filter(i=>!s.has(i.id))},gc=e=>{if(!Array.isArray(e))return[];const t=[],r=new Set;for(const o of e){if(!o||typeof o!="object")continue;const n=o;if(n.mode!=="diff"&&n.mode!=="file"&&n.mode!=="context"&&n.mode!=="preview"&&n.mode!=="browser"&&n.mode!=="git"&&n.mode!=="terminal"&&n.mode!=="pull-requests"&&n.mode!=="issues"&&n.mode!=="extensions"&&n.mode!=="agents")continue;const a=wo(typeof n.targetPath=="string"?n.targetPath:null),s=uc(n.mode,a,typeof n.dedupeKey=="string"?n.dedupeKey:null),i=Pn(n.mode,s);if(!i||r.has(i))continue;r.add(i);const c=n.mode==="browser",d=typeof n.dedupeKey=="string"&&n.dedupeKey.trim()?n.dedupeKey.trim():"browser";t.push({id:i,mode:n.mode,targetPath:c?null:a,dedupeKey:s,label:Bo(typeof n.label=="string"?n.label:null),sessionTitleFallback:Bo(typeof n.sessionTitleFallback=="string"?n.sessionTitleFallback:null),readOnly:n.readOnly===!0,stagedDiff:n.stagedDiff===!0,diffScope:_a(n.diffScope)??(n.stagedDiff===!0?"staged":"working"),browser:c?Kf(n.browser,{tabId:Pn("browser",d),url:a,route:Ia(n.browserRoute)}):null,touchedAt:typeof n.touchedAt=="number"&&Number.isFinite(n.touchedAt)?n.touchedAt:Date.now()})}return t},Yt=(e,t)=>t&&e.some(r=>r.id===t)?t:e.length===0?null:e[e.length-1].id,gt=e=>{if(e){const t=gc(e.tabs),r=Yt(t,e.activeTabId);return{...e,tabs:t,activeTabId:r,width:e.width,touchedAt:Date.now()}}return{isOpen:!1,expanded:!1,tabs:[],activeTabId:null,touchedAt:Date.now()}},rm=(e,t)=>{const r=Oa(t),o=r.mode==="file"&&r.targetPath?e.tabs.filter(c=>!(c.mode==="file"&&!c.targetPath)):e.tabs,n=o.findIndex(c=>c.id===r.id),a=n===-1?[...o,r]:o.map((c,d)=>d===n?{...c,mode:r.mode,targetPath:r.targetPath||c.targetPath,dedupeKey:r.dedupeKey,label:r.label,sessionTitleFallback:r.sessionTitleFallback||c.sessionTitleFallback,stagedDiff:r.stagedDiff,diffScope:r.diffScope,browser:c.browser??r.browser,readOnly:r.readOnly,touchedAt:Date.now()}:c),s=r.id,i=mc(a,lc,s);return{...e,isOpen:!0,tabs:i,activeTabId:Yt(i,s),touchedAt:Date.now()}},om=(e,t)=>{const r=e.tabs.find(s=>s.id===t)??null,o=e.tabs.filter(s=>s.id!==t);if(e.activeTabId!==t)return{...e,tabs:o,activeTabId:Yt(o,e.activeTabId),isOpen:o.length>0?e.isOpen:!1,touchedAt:Date.now()};const n=r?o.filter(s=>s.mode===r.mode):[],a=n.length>0?n.reduce((s,i)=>i.touchedAt>=s.touchedAt?i:s):null;return{...e,tabs:o,activeTabId:a?.id??Yt(o,null),isOpen:a?e.isOpen:!1,touchedAt:Date.now()}},nm=(e,t,r)=>{if(t===r)return e;const o=e.tabs.findIndex(i=>i.id===t),n=e.tabs.findIndex(i=>i.id===r);if(o===-1||n===-1)return e;const a=[...e.tabs],[s]=a.splice(o,1);return s?(a.splice(n,0,s),{...e,tabs:a,touchedAt:Date.now()}):e},am=(e,t,r)=>({...e,tabs:e.tabs.map(o=>o.id===t?{...o,targetPath:r}:o)}),sm=e=>{const t=[];let r=!1;for(const o of e){if(o.mode!=="diff"&&o.mode!=="git"){t.push(o);continue}r||(r=!0,t.push(o.mode==="git"?o:Oa({mode:"git"})))}return t},Ve=e=>{if(!e||typeof e!="object")return{};const t=e,r={};for(const[o,n]of Object.entries(t)){const a=K(o);if(!a||!n||typeof n!="object")continue;const s=n;let i=sm(gc(s.tabs)),c=typeof s.activeTabId=="string"?s.activeTabId:null;i.length===0&&(s.mode==="diff"||s.mode==="file"||s.mode==="context")&&(i=[Oa({mode:s.mode,targetPath:typeof s.targetPath=="string"?s.targetPath:null,dedupeKey:typeof s.dedupeKey=="string"?s.dedupeKey:null,label:typeof s.label=="string"?s.label:null})],c=i[0]?.id??null);const d=Yt(i,c),l=mc(i,lc,d),u=Zf(s);r[a]={isOpen:s.isOpen===!0,expanded:s.expanded===!0,tabs:l,activeTabId:Yt(l,d),...u!==void 0?{width:u}:{},touchedAt:typeof s.touchedAt=="number"&&Number.isFinite(s.touchedAt)?s.touchedAt:Date.now()}}return r},pt=(e,t)=>{const r=Object.entries(e);if(r.length<=t)return e;r.sort((n,a)=>(a[1]?.touchedAt??0)-(n[1]?.touchedAt??0));const o={};for(const[n,a]of r.slice(0,t))o[n]=a;return o},_s=50,im=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const r=t.split("/");if(r.length!==3)return null;const[o,n,a]=r.map(s=>s.trim());return!o||!n||!a||n.length>100||a.length>100||o.length>253?null:`${o}/${n}/${a}`},cm=e=>{if(!e||typeof e!="object")return{};const t=e,r={};for(const[o,n]of Object.entries(t)){const a=K(o),s=im(n);!a||!s||(r[a]=s)}return r},xs=(e,t)=>{const r=Object.entries(e);if(r.length<=t)return e;const o={};for(const[n,a]of r.slice(-t))o[n]=a;return o};function Os(e){return e==="vim"?"vim":"default"}const mr=280,cn=new Map,dn=e=>(e??D()).trim()||"default",gr=(e,t,r,o)=>{const n=t(),a=n.contextPanelByDirectory[r];if(!a)return;const s=tm(a,o);s!==a&&e({contextPanelByDirectory:{...n.contextPanelByDirectory,[r]:s}})},ie=xr()(Or(aa((e,t)=>({theme:"system",isSidebarOpen:!0,sidebarWidth:mr,hasManuallyResizedLeftSidebar:!1,contextPanelByDirectory:{},browserRoutePreference:null,chatLinkTarget:"system",contextRailOrder:[],contextEditorTreeVisible:!0,fileTreeReveal:null,gitReturnToFile:null,contextEditorTreeWidth:240,githubSelectedRepoByDirectory:{},isSessionSwitcherOpen:!1,isSessionDropdownOpen:!1,activeMainTab:"chat",mainTabGuard:null,sidebarOpenBeforeFullscreenTab:null,pendingDiffFile:null,pendingDiffStaged:!1,pendingDiffScope:null,pendingDiagramFile:null,pendingFileNavigation:null,pendingFileFocusPath:null,isMobile:!1,isCommandPaletteOpen:!1,isHelpDialogOpen:!1,isSessionCreateDialogOpen:!1,isArchivePageOpen:!1,isSettingsDialogOpen:!1,isModelSelectorOpen:!1,sidebarSection:"sessions",settingsPage:"home",settingsHasOpenedOnce:!1,settingsProjectsSelectedId:null,settingsRemoteInstancesSelectedId:null,eventStreamStatus:"idle",eventStreamHint:null,showDeletionDialog:!0,autoDeleteEnabled:!1,autoSaveEnabled:!0,autoDeleteAfterDays:30,sessionRetentionAction:"archive",autoDeleteLastRunAt:null,messageLimit:200,fontSize:100,globalDraftStarters:null,terminalFontSize:14,terminalShell:"auto",terminalLoginShells:[],editorFontSize:13,uiFont:hf,monoFont:Ff,padding:100,cornerRadius:18,inputBarOffset:0,mobileKeyboardMode:Ef(),favoriteModels:[],hiddenModels:[],collapsedModelProviders:[],recentModels:[],recentAgents:[],recentEfforts:{},diffLayoutPreference:"inline",diffFileLayout:{},diffWrapLinesOverride:null,wrapLinesByDefault:!0,walkthroughTocWidth:224,gitChangesViewMode:"flat",isTimelineDialogOpen:!1,isPromptNavigatorPanelOpen:!1,isImagePreviewOpen:!1,nativeNotificationsEnabled:!1,notificationMode:"hidden-only",dockBadgeEnabled:!0,notifyOnCompletion:!0,notifyOnError:!0,notifyOnInputNeeded:!0,summarizeLastMessage:!1,summaryThreshold:200,summaryLength:100,maxLastMessageLength:250,showTerminalQuickKeysOnDesktop:!1,timeFormatPreference:"auto",weekStartPreference:"auto",sidebarViewMode:Cf,sessionAutoArchiveAfterDays:0,sessionAutoDeleteAfterDays:0,expandedEditorToolbar:!1,draftStartersVisible:!0,draftWallpaper:kf,draftWallpaperMotion:!0,draftWallpaperPicture:!1,draftWallpaperInSessions:!1,draftWallpaperImageVersion:null,isExpandedInput:!1,shortcutOverrides:{},commandTriggers:[],fileEditorKeymap:"default",setTheme:r=>{e({theme:r}),t().applyTheme()},toggleSidebar:()=>{e(r=>{const o=!r.isSidebarOpen;return o&&!r.hasManuallyResizedLeftSidebar?{isSidebarOpen:o,sidebarWidth:mr}:{isSidebarOpen:o}})},setSidebarOpen:r=>{e(o=>o.isSidebarOpen===r?r&&!o.hasManuallyResizedLeftSidebar&&o.sidebarWidth!==mr?{isSidebarOpen:r,sidebarWidth:mr}:o:r&&!o.hasManuallyResizedLeftSidebar?{isSidebarOpen:r,sidebarWidth:mr}:{isSidebarOpen:r})},setSidebarWidth:r=>{e({sidebarWidth:r,hasManuallyResizedLeftSidebar:!0})},setContextRailOrder:r=>{const o=Array.isArray(r)?r.filter((n,a)=>typeof n=="string"&&n.trim()!==""&&r.indexOf(n)===a):[];e({contextRailOrder:o})},toggleContextEditorTree:()=>{e(r=>({contextEditorTreeVisible:!r.contextEditorTreeVisible}))},revealInFileTree:r=>{e(o=>({fileTreeReveal:{path:r,nonce:(o.fileTreeReveal?.nonce??0)+1}}))},clearGitReturnToFile:()=>{t().gitReturnToFile&&e({gitReturnToFile:null})},showAllGitChanges:()=>{const r=t().gitReturnToFile;r?.focusPath&&e({gitReturnToFile:{...r,focusPath:null}})},clearFileTreeReveal:()=>{e({fileTreeReveal:null})},setContextEditorTreeWidth:r=>{Number.isFinite(r)&&e({contextEditorTreeWidth:Math.min(480,Math.max(200,Math.round(r)))})},setGitHubSelectedRepo:(r,o)=>{const n=K((r||"").trim());n&&e(a=>{if(o==null){if(!(n in a.githubSelectedRepoByDirectory))return a;const i={...a.githubSelectedRepoByDirectory};return delete i[n],{githubSelectedRepoByDirectory:i}}const s=o.trim();return!s||a.githubSelectedRepoByDirectory[n]===s?a:{githubSelectedRepoByDirectory:xs({...a.githubSelectedRepoByDirectory,[n]:s},_s)}})},openContextSurface:(r,o)=>{const n=o==="diff"?"git":o,a=K((r||"").trim());if(!a)return;const s=t(),i=s.contextPanelByDirectory[a],c=i?.tabs??[],d=c.find(u=>u.id===i?.activeTabId)??null;if(i?.isOpen&&d?.mode===n){s.closeContextPanel(a);return}const l=c.filter(u=>u.mode===n);if(l.length>0){const u=l.reduce((f,m)=>m.touchedAt>=f.touchedAt?m:f);s.setActiveContextPanelTab(a,u.id);return}n!=="preview"&&s.openContextPanelTab(a,{mode:n})},openContextPanelTab:(r,o)=>{const n=K((r||"").trim());n&&e(a=>{const s=a.contextPanelByDirectory[n],i=gt(s),c={...a.contextPanelByDirectory,[n]:rm(i,o)};return{contextPanelByDirectory:pt(c,20)}})},openContextDiff:(r,o,n=!1,a=null)=>{const s=K((r||"").trim()),i=(o||"").trim();if(!s||!i)return;const c=_a(a)??(n?"staged":"working"),d=t().contextPanelByDirectory[s],l=d?.isOpen?d.tabs.find(u=>u.id===d.activeTabId):void 0;t().setPendingDiffFile(i,n,c),t().openContextPanelTab(s,{mode:"git"}),e({gitReturnToFile:l?.mode==="file"?{directory:s,tabId:l.id,focusPath:i}:null})},openContextFile:(r,o)=>{const n=K((r||"").trim()),a=wo(o);!n||!a||(t().openContextPanelTab(n,{mode:"file",targetPath:a}),t().setPendingFileFocusPath(a),t().setPendingFileNavigation(null))},openContextFileAtLine:(r,o,n,a)=>{const s=K((r||"").trim()),i=wo(o),c=Number.isFinite(n)?Math.max(1,Math.trunc(n)):1,d=Number.isFinite(a)?Math.max(1,Math.trunc(a)):1;!s||!i||(t().openContextPanelTab(s,{mode:"file",targetPath:i}),t().setPendingFileFocusPath(null),t().setPendingFileNavigation({path:i,line:c,column:d}))},openContextOverview:r=>{const o=K((r||"").trim());o&&t().openContextPanelTab(o,{mode:"context"})},openContextPreview:(r,o)=>{const n=K((r||"").trim()),a=(o||"").trim();if(!n||!a)return;let s=null;try{const i=new URL(a);(i.protocol==="http:"||i.protocol==="https:")&&(s=i.host||i.hostname||"Preview")}catch{}t().openContextPanelTab(n,{mode:"preview",targetPath:a,dedupeKey:a,label:s})},openContextBrowser:(r,o="",n)=>{const a=K((r||"").trim());if(!a)return;const s=typeof o=="string"&&o.trim().length>0?o.trim():"",i=!!t().contextPanelByDirectory[a]?.tabs.some(d=>d.id===fc);if(t().openContextPanelTab(a,{mode:"browser",targetPath:i?null:s,dedupeKey:xa,label:"Browser",browserRoute:i?null:n?.route??null}),!i)return;const c=n?.target??(s?"new":null);c&&gr(e,t,a,d=>$f(d,{url:s||null,route:n?.route??null,target:c}))},openBrowserPopup:(r,o,n)=>{const a=K((r||"").trim());if(!a)return!1;let s=!1;return gr(e,t,a,i=>{const c=zf(i,{openerPageId:o,popupId:n});return s=c!==null,c??i}),s},closeBrowserPage:(r,o)=>{const n=K((r||"").trim());n&&gr(e,t,n,a=>qf(a,o))},activateBrowserPage:(r,o)=>{const n=K((r||"").trim());n&&gr(e,t,n,a=>Wf(a,o))},updateBrowserPage:(r,o,n)=>{const a=K((r||"").trim());a&&gr(e,t,a,s=>Gf(s,o,n))},setBrowserRoutePreference:r=>{e({browserRoutePreference:Ia(r)})},setChatLinkTarget:r=>{e({chatLinkTarget:r==="pichamber"?"pichamber":"system"})},setContextPanelTabTargetPath:(r,o,n)=>{const a=K((r||"").trim()),s=(o||"").trim();!a||!s||e(i=>{const c=i.contextPanelByDirectory[a];return c?{contextPanelByDirectory:{...i.contextPanelByDirectory,[a]:am(c,s,n)}}:i})},setActiveContextPanelTab:(r,o)=>{const n=K((r||"").trim()),a=(o||"").trim();!n||!a||e(s=>{const i=s.contextPanelByDirectory[n],c=gt(i);if(!c.tabs.some(l=>l.id===a)||c.activeTabId===a&&c.isOpen)return s;const d={...s.contextPanelByDirectory,[n]:{...c,isOpen:!0,activeTabId:a,touchedAt:Date.now(),tabs:c.tabs.map(l=>l.id===a?{...l,touchedAt:Date.now()}:l)}};return{contextPanelByDirectory:pt(d,20)}})},reorderContextPanelTabs:(r,o,n)=>{const a=K((r||"").trim()),s=(o||"").trim(),i=(n||"").trim();!a||!s||!i||e(c=>{const d=c.contextPanelByDirectory[a],l=gt(d);if(!l.tabs.some(m=>m.id===s)||!l.tabs.some(m=>m.id===i))return c;const u=nm(l,s,i);if(u.tabs===l.tabs)return c;const f={...c.contextPanelByDirectory,[a]:u};return{contextPanelByDirectory:pt(f,20)}})},closeContextPanelTab:(r,o)=>{const n=K((r||"").trim()),a=(o||"").trim();if(!n||!a)return;const s=t().contextPanelByDirectory[n]?.tabs.find(i=>i.id===a);e(i=>{const c=i.contextPanelByDirectory[n],d=gt(c);if(!d.tabs.some(u=>u.id===a))return i;const l={...i.contextPanelByDirectory,[n]:om(d,a)};return{contextPanelByDirectory:pt(l,20)}}),s?.mode==="file"&&s.targetPath&&Nf.getState().removeOpenPath(n,s.targetPath)},closeContextPanel:r=>{const o=K((r||"").trim());o&&e(n=>{const a=n.contextPanelByDirectory[o];if(!a||!a.isOpen)return n;const s={...n.contextPanelByDirectory,[o]:{...gt(a),isOpen:!1}};return{contextPanelByDirectory:pt(s,20)}})},toggleContextPanelExpanded:r=>{const o=K((r||"").trim());o&&e(n=>{const a=n.contextPanelByDirectory[o],s=gt(a),i={...n.contextPanelByDirectory,[o]:{...s,expanded:!s.expanded}};return{contextPanelByDirectory:pt(i,20)}})},setContextPanelWidth:(r,o)=>{const n=K((r||"").trim());n&&e(a=>{const s=a.contextPanelByDirectory[n],i=gt(s),c={...a.contextPanelByDirectory,[n]:{...i,width:uo(o)}};return{contextPanelByDirectory:pt(c,20)}})},setSessionSwitcherOpen:r=>{t().isSessionSwitcherOpen!==r&&e({isSessionSwitcherOpen:r})},setSessionDropdownOpen:r=>{t().isSessionDropdownOpen!==r&&e({isSessionDropdownOpen:r})},setMainTabGuard:r=>{t().mainTabGuard!==r&&e({mainTabGuard:r})},setActiveMainTab:r=>{const o=t().mainTabGuard;o&&!o(r)||(cn.set(dn(),r),e({activeMainTab:r}))},prepareForRuntimeSwitch:r=>{cn.set(dn(r),t().activeMainTab)},restoreForRuntimeSwitch:r=>{const o=cn.get(dn(r))??"chat";e({activeMainTab:o})},setPendingDiffFile:(r,o=!1,n=null)=>{e({pendingDiffFile:r,pendingDiffStaged:r?o:!1,pendingDiffScope:r?n:null})},setPendingDiagramFile:r=>{e({pendingDiagramFile:r})},setPendingFileNavigation:r=>{e({pendingFileNavigation:r})},setPendingFileFocusPath:r=>{e({pendingFileFocusPath:r})},navigateToDiff:(r,o=!1,n=null)=>{const a=t().mainTabGuard;a&&!a("diff")||e({pendingDiffFile:r,pendingDiffStaged:o,pendingDiffScope:n,activeMainTab:"diff"})},consumePendingDiffFile:()=>{const{pendingDiffFile:r}=t();return r&&e({pendingDiffFile:null,pendingDiffStaged:!1,pendingDiffScope:null}),r},navigateToDiagram:r=>{const o=t().mainTabGuard;o&&!o("diagram")||e({pendingDiagramFile:r,activeMainTab:"diagram"})},consumePendingDiagramFile:()=>{const{pendingDiagramFile:r}=t();return r&&e({pendingDiagramFile:null}),r},setIsMobile:r=>{e({isMobile:r})},toggleCommandPalette:()=>{e(r=>({isCommandPaletteOpen:!r.isCommandPaletteOpen}))},setCommandPaletteOpen:r=>{e({isCommandPaletteOpen:r})},toggleHelpDialog:()=>{e(r=>({isHelpDialogOpen:!r.isHelpDialogOpen}))},setHelpDialogOpen:r=>{e({isHelpDialogOpen:r})},setSessionCreateDialogOpen:r=>{e({isSessionCreateDialogOpen:r})},setArchivePageOpen:r=>{e({isArchivePageOpen:r})},closeMainSurfaces:()=>{t().isArchivePageOpen&&e({isArchivePageOpen:!1})},setSettingsDialogOpen:r=>{e(o=>r?o.settingsHasOpenedOnce?{isSettingsDialogOpen:!0}:{isSettingsDialogOpen:!0,settingsHasOpenedOnce:!0}:{isSettingsDialogOpen:!1})},setModelSelectorOpen:r=>{e({isModelSelectorOpen:r})},setSidebarSection:r=>{e({sidebarSection:r})},setSettingsPage:r=>{e({settingsPage:r})},setSettingsProjectsSelectedId:r=>{e({settingsProjectsSelectedId:r})},setSettingsRemoteInstancesSelectedId:r=>{e({settingsRemoteInstancesSelectedId:r})},setEventStreamStatus:(r,o)=>{e({eventStreamStatus:r,eventStreamHint:o??null})},setShowDeletionDialog:r=>{e({showDeletionDialog:r})},setAutoDeleteEnabled:r=>{e({autoDeleteEnabled:r})},setAutoSaveEnabled:r=>{e({autoSaveEnabled:r})},setAutoDeleteAfterDays:r=>{const o=Math.max(1,Math.min(365,r));e({autoDeleteAfterDays:o})},setSessionRetentionAction:r=>{e({sessionRetentionAction:r})},setAutoDeleteLastRunAt:r=>{e({autoDeleteLastRunAt:r})},setMessageLimit:r=>{const o=Math.max(10,Math.min(500,Math.round(r)));e({messageLimit:o})},setFontSize:r=>{const o=Math.max(50,Math.min(200,r));e({fontSize:o}),t().applyTypography()},setGlobalDraftStarters:r=>{e({globalDraftStarters:r})},setDraftStartersVisible:r=>{e({draftStartersVisible:r})},setDraftWallpaper:r=>{Pa(r)&&e({draftWallpaper:r})},setDraftWallpaperMotion:r=>{e({draftWallpaperMotion:r})},setDraftWallpaperPicture:r=>{e({draftWallpaperPicture:r===!0})},setDraftWallpaperInSessions:r=>{e({draftWallpaperInSessions:r===!0})},setDraftWallpaperImageVersion:r=>{e({draftWallpaperImageVersion:r})},setTerminalFontSize:r=>{const o=Math.round(r),n=Math.max(9,Math.min(52,o));e({terminalFontSize:n})},setTerminalShell:r=>{e({terminalShell:r})},setTerminalLoginShells:r=>{e({terminalLoginShells:[...new Set(r)]})},setEditorFontSize:r=>{const o=Math.round(r),n=Math.max(9,Math.min(32,o));e({editorFontSize:n})},setUiFont:r=>{e({uiFont:r})},setMonoFont:r=>{e({monoFont:r})},setPadding:r=>{const o=Math.max(50,Math.min(200,r));e({padding:o}),t().applyPadding()},setCornerRadius:r=>{e({cornerRadius:r})},applyTypography:()=>{const{fontSize:r}=t(),o=document.documentElement,n=r/100,a=Object.entries(uf);if(n===1){for(const[s]of a)o.style.removeProperty(Ms(s));return}for(const[s,i]of a){const c=parseFloat(i);Number.isFinite(c)&&o.style.setProperty(Ms(s),`${c*n}rem`)}},applyPadding:()=>{const{padding:r}=t(),o=document.documentElement,n=r/100;if(n===1){o.style.removeProperty("--padding-scale"),o.style.removeProperty("--line-height-tight"),o.style.removeProperty("--line-height-normal"),o.style.removeProperty("--line-height-relaxed"),o.style.removeProperty("--line-height-loose");return}const a=Math.sqrt(n);o.style.setProperty("--padding-scale",a.toString());const s=1+(n-1)*.15;o.style.setProperty("--line-height-tight",(1.25*s).toFixed(3)),o.style.setProperty("--line-height-normal",(1.5*s).toFixed(3)),o.style.setProperty("--line-height-relaxed",(1.625*s).toFixed(3)),o.style.setProperty("--line-height-loose",(2*s).toFixed(3))},setDiffLayoutPreference:r=>{e({diffLayoutPreference:r})},setDiffFileLayout:(r,o)=>{e(n=>({diffFileLayout:{...n.diffFileLayout,[r]:o}}))},setDiffWrapLines:r=>{e({diffWrapLinesOverride:r})},setWrapLinesByDefault:r=>{e({wrapLinesByDefault:r,diffWrapLinesOverride:null})},setWalkthroughTocWidth:r=>{e({walkthroughTocWidth:Math.round(r)})},setGitChangesViewMode:r=>{e({gitChangesViewMode:r})},setInputBarOffset:r=>{e({inputBarOffset:r})},setMobileKeyboardMode:r=>{e(o=>o.mobileKeyboardMode===r?o:{mobileKeyboardMode:r})},toggleFavoriteModel:(r,o)=>{e(n=>n.favoriteModels.some(s=>s.providerID===r&&s.modelID===o)?{favoriteModels:n.favoriteModels.filter(s=>!(s.providerID===r&&s.modelID===o))}:{favoriteModels:[{providerID:r,modelID:o},...n.favoriteModels]})},reorderFavoriteModel:(r,o,n,a)=>{e(s=>{const i=s.favoriteModels.findIndex(u=>u.providerID===r&&u.modelID===o),c=s.favoriteModels.findIndex(u=>u.providerID===n&&u.modelID===a);if(i===-1||c===-1||i===c)return s;const d=s.favoriteModels.slice(),[l]=d.splice(i,1);return l?(d.splice(c,0,l),{favoriteModels:d}):s})},toggleHiddenModel:(r,o)=>{e(n=>n.hiddenModels.some(s=>s.providerID===r&&s.modelID===o)?{hiddenModels:n.hiddenModels.filter(s=>!(s.providerID===r&&s.modelID===o))}:{hiddenModels:[{providerID:r,modelID:o},...n.hiddenModels]})},isHiddenModel:(r,o)=>{const{hiddenModels:n}=t();return n.some(a=>a.providerID===r&&a.modelID===o)},hideAllModels:(r,o)=>{e(n=>{const a=n.hiddenModels.filter(i=>i.providerID!==r);return{hiddenModels:[...[...new Set(o.filter(i=>typeof i=="string"&&i.length>0))].map(i=>({providerID:r,modelID:i})),...a]}})},showAllModels:r=>{e(o=>({hiddenModels:o.hiddenModels.filter(n=>n.providerID!==r)}))},toggleModelProviderCollapsed:r=>{const o=typeof r=="string"?r.trim():"";o&&e(n=>n.collapsedModelProviders.includes(o)?{collapsedModelProviders:n.collapsedModelProviders.filter(s=>s!==o)}:{collapsedModelProviders:[...n.collapsedModelProviders,o]})},setModelProvidersCollapsed:(r,o)=>{const n=Array.from(new Set(r.filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean)));n.length!==0&&e(a=>{const s=new Set(n),i=a.collapsedModelProviders.filter(c=>!s.has(c));return{collapsedModelProviders:o?[...i,...n]:i}})},isFavoriteModel:(r,o)=>{const{favoriteModels:n}=t();return n.some(a=>a.providerID===r&&a.modelID===o)},addRecentModel:(r,o)=>{e(n=>{const a=n.recentModels.filter(s=>!(s.providerID===r&&s.modelID===o));return{recentModels:[{providerID:r,modelID:o},...a].slice(0,5)}})},addRecentAgent:r=>{const o=typeof r=="string"?r.trim():"";o&&e(n=>{if(n.recentAgents.includes(o))return n;const a=n.recentAgents;return{recentAgents:[o,...a].slice(0,5)}})},addRecentEffort:(r,o,n)=>{const a=typeof r=="string"?r.trim():"",s=typeof o=="string"?o.trim():"";if(!a||!s)return;const i=`${a}/${s}`,c=typeof n=="string"&&n.trim().length>0?n.trim():"default";e(d=>{const l=d.recentEfforts[i]??[];if(l.includes(c))return d;const u=l;return{recentEfforts:{...d.recentEfforts,[i]:[c,...u].slice(0,5)}}})},applyTheme:()=>{const{theme:r}=t(),o=document.documentElement;if(o.classList.remove("light","dark"),r==="system"){const n=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";o.classList.add(n)}else o.classList.add(r)},setTimelineDialogOpen:r=>{e({isTimelineDialogOpen:r})},setPromptNavigatorPanelOpen:r=>{e({isPromptNavigatorPanelOpen:r})},togglePromptNavigatorPanel:()=>{e(r=>({isPromptNavigatorPanelOpen:!r.isPromptNavigatorPanelOpen}))},setImagePreviewOpen:r=>{e({isImagePreviewOpen:r})},setNativeNotificationsEnabled:r=>{e({nativeNotificationsEnabled:r})},setNotificationMode:r=>{e({notificationMode:r})},setShowTerminalQuickKeysOnDesktop:r=>{e({showTerminalQuickKeysOnDesktop:r})},setDockBadgeEnabled:r=>{e({dockBadgeEnabled:r})},setNotifyOnCompletion:r=>{e({notifyOnCompletion:r})},setNotifyOnError:r=>{e({notifyOnError:r})},setNotifyOnInputNeeded:r=>{e({notifyOnInputNeeded:r})},setSummarizeLastMessage:r=>{e({summarizeLastMessage:r})},setSummaryThreshold:r=>{e({summaryThreshold:r})},setSummaryLength:r=>{e({summaryLength:r})},setMaxLastMessageLength:r=>{e({maxLastMessageLength:r})},setTimeFormatPreference:r=>{e({timeFormatPreference:r})},setWeekStartPreference:r=>{e({weekStartPreference:r})},setSidebarViewMode:r=>{e({sidebarViewMode:r})},setSessionAutoArchiveAfterDays:r=>{Jt(r)&&e({sessionAutoArchiveAfterDays:r})},setSessionAutoDeleteAfterDays:r=>{Jt(r)&&e({sessionAutoDeleteAfterDays:r})},setExpandedEditorToolbar:r=>{e({expandedEditorToolbar:r})},viewPagerPage:"center",setViewPagerPage:r=>{e({viewPagerPage:r}),e({isSessionSwitcherOpen:r==="left"})},setShortcutOverride:(r,o)=>{e(n=>({shortcutOverrides:{...n.shortcutOverrides,[r]:o}}))},clearShortcutOverride:r=>{e(o=>{const n={...o.shortcutOverrides};return delete n[r],{shortcutOverrides:n}})},resetAllShortcutOverrides:()=>{e({shortcutOverrides:{}})},setFileEditorKeymap:r=>{e({fileEditorKeymap:Os(r)})},toggleExpandedInput:()=>{e(r=>({isExpandedInput:!r.isExpandedInput}))},setExpandedInput:r=>{e({isExpandedInput:r})}}),{name:"ui-store",storage:pa(),version:21,migrate:(e,t)=>{if(!e||typeof e!="object")return e;const r=e;if(t<21&&(delete r.diffWrapLines,delete r.diffWrapLinesOverride,typeof r.wrapLinesByDefault!="boolean"&&(r.wrapLinesByDefault=!0)),t<20&&(delete r.notifyOnSubtasks,delete r.notifyOnQuestion,delete r.notificationTemplates),t<19&&(delete r.showReasoningTraces,delete r.collapsibleThinkingBlocks,delete r.collapseThinkingByDefault,delete r.persistChatDraft,delete r.inputSpellcheckEnabled,delete r.wideChatLayoutEnabled,delete r.codeBlockLineWrap,delete r.showToolFileIcons,delete r.showTurnChangedFiles,delete r.showExpandedBashTools,delete r.showExpandedEditTools,delete r.desktopWindowControlsPosition,delete r.desktopWindowControlsStyle,delete r.mermaidRenderingMode,delete r.userMessageRenderingMode,delete r.collapsibleUserMessages,delete r.stickyUserHeader,delete r.promptNavigatorEnabled,delete r.showSplitAssistantMessageActions),t<18&&(delete r.notesPanelHeight,delete r.todoPanelHeight,r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="notes"))),t<17&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="chat"))),t<16&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="chat"))),t<15&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="pr"))),t<14&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),Array.isArray(r.contextRailOrder)&&(r.contextRailOrder=r.contextRailOrder.filter(o=>o!=="diff"))),t<13&&typeof r.autoSaveEnabled!="boolean"){let o=!0;try{if(typeof localStorage<"u"){const n=localStorage.getItem("pichamber:files:auto-save-enabled");n!==null&&(o=n!=="false",localStorage.removeItem("pichamber:files:auto-save-enabled"))}}catch{o=!0}r.autoSaveEnabled=o}if(t<12&&(delete r.desktopWindowControlsPosition,delete r.desktopWindowControlsStyle),t<11&&r.terminalFontSize===13&&(r.terminalFontSize=14),t<10&&delete r.diffViewMode,t<9&&((typeof r.notesPanelHeight!="number"||!Number.isFinite(r.notesPanelHeight))&&(r.notesPanelHeight=112),(typeof r.todoPanelHeight!="number"||!Number.isFinite(r.todoPanelHeight))&&(r.todoPanelHeight=259)),t<3){const o=new Set([90,120,180,220]),n=r.memoryLimitHistorical,a=r.memoryLimitActiveSession;typeof n=="number"&&!o.has(n)?r.messageLimit=n:typeof a=="number"&&!o.has(a)&&(r.messageLimit=a),delete r.memoryLimitHistorical,delete r.memoryLimitViewport,delete r.memoryLimitActiveSession}if(delete r.isRightSidebarOpen,delete r.rightSidebarWidth,delete r.rightSidebarTab,delete r.workStatusExpandedSections,delete r.workStatusScrollTop,delete r.workStatusPanelEnabled,delete r.workStatusHiddenSections,delete r.showReasoningTraces,delete r.collapsibleThinkingBlocks,delete r.collapseThinkingByDefault,delete r.persistChatDraft,delete r.inputSpellcheckEnabled,delete r.wideChatLayoutEnabled,delete r.codeBlockLineWrap,delete r.showToolFileIcons,delete r.showTurnChangedFiles,delete r.showExpandedBashTools,delete r.showExpandedEditTools,delete r.desktopWindowControlsPosition,delete r.desktopWindowControlsStyle,delete r.mermaidRenderingMode,delete r.userMessageRenderingMode,delete r.collapsibleUserMessages,delete r.stickyUserHeader,delete r.promptNavigatorEnabled,delete r.showSplitAssistantMessageActions,delete r.diffWrapLines,r.contextPanelByDirectory=Ve(r.contextPanelByDirectory),t<5)if(!r.shortcutOverrides||typeof r.shortcutOverrides!="object")r.shortcutOverrides={};else{const o=r.shortcutOverrides,n={};for(const[a,s]of Object.entries(o))typeof a=="string"&&typeof s=="string"&&(n[a]=s);r.shortcutOverrides=n}return t<6&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory)),t<7&&(r.contextPanelByDirectory=Ve(r.contextPanelByDirectory)),t<8&&r.gitChangesViewMode!=="flat"&&r.gitChangesViewMode!=="tree"&&(r.gitChangesViewMode="flat"),r.fileEditorKeymap=Os(r.fileEditorKeymap),r.githubSelectedRepoByDirectory=xs(cm(r.githubSelectedRepoByDirectory),_s),typeof r.autoSaveEnabled!="boolean"&&(r.autoSaveEnabled=!0),typeof r.wrapLinesByDefault!="boolean"&&(r.wrapLinesByDefault=!0),r.contextRailOrder=Array.isArray(r.contextRailOrder)?r.contextRailOrder.filter(o=>typeof o=="string"&&o.trim()!==""&&o!=="pr"&&o!=="diff"&&o!=="chat"&&o!=="notes"):[],r},partialize:e=>({theme:e.theme,isSidebarOpen:e.isSidebarOpen,sidebarWidth:e.sidebarWidth,contextPanelByDirectory:e.contextPanelByDirectory,browserRoutePreference:e.browserRoutePreference,chatLinkTarget:e.chatLinkTarget,contextRailOrder:e.contextRailOrder,contextEditorTreeVisible:e.contextEditorTreeVisible,contextEditorTreeWidth:e.contextEditorTreeWidth,githubSelectedRepoByDirectory:e.githubSelectedRepoByDirectory,isSessionSwitcherOpen:e.isSessionSwitcherOpen,activeMainTab:e.activeMainTab,sidebarSection:e.sidebarSection,settingsPage:e.settingsPage,settingsHasOpenedOnce:e.settingsHasOpenedOnce,settingsProjectsSelectedId:e.settingsProjectsSelectedId,settingsRemoteInstancesSelectedId:e.settingsRemoteInstancesSelectedId,isSessionCreateDialogOpen:e.isSessionCreateDialogOpen,showDeletionDialog:e.showDeletionDialog,autoDeleteEnabled:e.autoDeleteEnabled,autoSaveEnabled:e.autoSaveEnabled,autoDeleteAfterDays:e.autoDeleteAfterDays,sessionRetentionAction:e.sessionRetentionAction,autoDeleteLastRunAt:e.autoDeleteLastRunAt,messageLimit:e.messageLimit,fontSize:e.fontSize,globalDraftStarters:e.globalDraftStarters,terminalFontSize:e.terminalFontSize,terminalShell:e.terminalShell,terminalLoginShells:e.terminalLoginShells,editorFontSize:e.editorFontSize,uiFont:e.uiFont,monoFont:e.monoFont,padding:e.padding,cornerRadius:e.cornerRadius,favoriteModels:e.favoriteModels,hiddenModels:e.hiddenModels,collapsedModelProviders:e.collapsedModelProviders,recentModels:e.recentModels,recentAgents:e.recentAgents,recentEfforts:e.recentEfforts,diffLayoutPreference:e.diffLayoutPreference,wrapLinesByDefault:e.wrapLinesByDefault,walkthroughTocWidth:e.walkthroughTocWidth,gitChangesViewMode:e.gitChangesViewMode,nativeNotificationsEnabled:e.nativeNotificationsEnabled,notificationMode:e.notificationMode,showTerminalQuickKeysOnDesktop:e.showTerminalQuickKeysOnDesktop,dockBadgeEnabled:e.dockBadgeEnabled,notifyOnCompletion:e.notifyOnCompletion,notifyOnError:e.notifyOnError,notifyOnInputNeeded:e.notifyOnInputNeeded,summarizeLastMessage:e.summarizeLastMessage,summaryThreshold:e.summaryThreshold,summaryLength:e.summaryLength,maxLastMessageLength:e.maxLastMessageLength,timeFormatPreference:e.timeFormatPreference,weekStartPreference:e.weekStartPreference,sidebarViewMode:e.sidebarViewMode,sessionAutoArchiveAfterDays:e.sessionAutoArchiveAfterDays,sessionAutoDeleteAfterDays:e.sessionAutoDeleteAfterDays,expandedEditorToolbar:e.expandedEditorToolbar,draftStartersVisible:e.draftStartersVisible,draftWallpaper:e.draftWallpaper,draftWallpaperMotion:e.draftWallpaperMotion,draftWallpaperPicture:e.draftWallpaperPicture,draftWallpaperInSessions:e.draftWallpaperInSessions,draftWallpaperImageVersion:e.draftWallpaperImageVersion,shortcutOverrides:e.shortcutOverrides,fileEditorKeymap:e.fileEditorKeymap})}),{name:"ui-store"})),mA=Object.freeze(Object.defineProperty({__proto__:null,normalizeContextPanelDirectoryKey:Qf,useUIStore:ie},Symbol.toStringTag,{value:"Module"}));let Ns="idle";const dm=new Set;let eo=null;const ye=e=>{eo&&(clearTimeout(eo),eo=null);const t=e==="saved"?"idle":e;t!==Ns&&(Ns=t,dm.forEach(r=>r())),t==="error"&&(eo=setTimeout(()=>ye("saved"),6e3)),!(typeof window>"u")&&window.dispatchEvent(new CustomEvent("pichamber:settings-save-state",{detail:e}))},gA=e=>{ye(e)},lm=e=>{if(!(typeof window>"u")&&!(typeof window.__PICHAMBER_HOME__=="string"&&window.__PICHAMBER_HOME__.length>0))try{window.__PICHAMBER_HOME__=e}catch{}},Ls="pichamber.settingsMirror.v2.index",um="pichamber.settingsMirror.v2:",fm=5,Us=e=>`${um}${encodeURIComponent(e)}`,ht=(e,t)=>{t===null?localStorage.removeItem(e):localStorage.setItem(e,t)},mm=(e,t)=>{const r={themeId:e.themeId,themeVariant:e.themeVariant,lightThemeId:e.lightThemeId,darkThemeId:e.darkThemeId,useSystemTheme:e.useSystemTheme,lastDirectory:e.lastDirectory,homeDirectory:e.homeDirectory,projects:e.projects,activeProjectId:e.activeProjectId,pinnedDirectories:e.pinnedDirectories,filesViewShowGitignored:e.filesViewShowGitignored,openInAppId:e.openInAppId,pwaAppName:e.pwaAppName,mobileKeyboardMode:e.mobileKeyboardMode};localStorage.setItem(Us(t),JSON.stringify(r));let o=[];try{const a=JSON.parse(localStorage.getItem(Ls)??"[]");Array.isArray(a)&&(o=a.filter(s=>typeof s=="string"))}catch{o=[]}const n=[t,...o.filter(a=>a!==t)].slice(0,fm);for(const a of o)n.includes(a)||localStorage.removeItem(Us(a));localStorage.setItem(Ls,JSON.stringify(n))},gm=e=>{if(!(typeof window>"u")){if(mm(e,D()),ht("selectedThemeId",e.themeId||null),ht("selectedThemeVariant",e.themeVariant||null),ht("lightThemeId",e.lightThemeId||null),ht("darkThemeId",e.darkThemeId||null),ht("useSystemTheme",typeof e.useSystemTheme=="boolean"?String(e.useSystemTheme):null),ht("lastDirectory",e.lastDirectory||null),e.homeDirectory?(localStorage.setItem("homeDirectory",e.homeDirectory),lm(e.homeDirectory)):localStorage.removeItem("homeDirectory"),Array.isArray(e.projects)&&e.projects.length>0?localStorage.setItem("projects",JSON.stringify(e.projects)):localStorage.removeItem("projects"),e.activeProjectId?localStorage.setItem("activeProjectId",e.activeProjectId):localStorage.removeItem("activeProjectId"),Array.isArray(e.pinnedDirectories)&&e.pinnedDirectories.length>0?localStorage.setItem("pinnedDirectories",JSON.stringify(e.pinnedDirectories)):localStorage.removeItem("pinnedDirectories"),Array.isArray(e.projects)&&e.projects.length>0){const t=e.projects.filter(r=>r.sidebarCollapsed===!0).map(r=>r.id).filter(r=>typeof r=="string"&&r.length>0);t.length>0?localStorage.setItem("oc.sessions.projectCollapse",JSON.stringify(t)):localStorage.removeItem("oc.sessions.projectCollapse")}else localStorage.removeItem("oc.sessions.projectCollapse");if(typeof e.filesViewShowGitignored=="boolean"?localStorage.setItem("filesViewShowGitignored",e.filesViewShowGitignored?"true":"false"):localStorage.removeItem("filesViewShowGitignored"),ht("openInAppId",typeof e.openInAppId=="string"&&e.openInAppId.length>0?e.openInAppId:null),typeof e.pwaAppName=="string"){const t=nc(e.pwaAppName,"");t.length>0?localStorage.setItem(sn,t):localStorage.removeItem(sn)}else localStorage.removeItem(sn);wf(e.mobileKeyboardMode)}},Rn=e=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("pichamber:settings-synced",{detail:e}))},pm=()=>{const e=globalThis.crypto;if(typeof e?.randomUUID=="function")return e.randomUUID();if(typeof e?.getRandomValues!="function")throw new Error("Secure random UUID is unavailable in this browser context");const t=e.getRandomValues(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const r=Array.from(t,o=>o.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`},hm=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const r=t.replace(/\\/g,"/").replace(/^([a-z]):/,(n,a)=>a.toUpperCase()+":");return r==="/"?"/":(r.length>1?r.replace(/\/+$/,""):r)||null},Na="queue",La=e=>e==="steer"||e==="queue",Ua=(e,t)=>e==="immediate"?"steer":La(e)?e:t===!1?"steer":t===!0?"queue":Na,Hs=50,Ks=20,ln=(e,t)=>{if(e.runtimeKey!==D())return;const r=t.flatMap(o=>(o.attachments??[]).flatMap(n=>n.uploadState?.status==="ready"?[n.uploadState.attachmentId]:[]));for(const o of new Set(r))At.deleteAttachment(o,{runtimeKey:e.runtimeKey}).catch(()=>{})},Fm=(e,t,r=D())=>{const o=hm(t);return!r||!o||!e?null:{runtimeKey:r,directory:o,sessionId:e}},re=e=>`${e.runtimeKey}
8
8
  ${e.directory}
9
- ${e.sessionId}`,Zf=e=>{const[t,r,...o]=e.split(`
10
- `);return Qf(o.join(`
11
- `),r,t)},em=(e,t)=>{const r=e??{},o=t<2?r.queuedMessages??{}:{};return{queuedMessages:t<2?{}:r.queuedMessages??{},quarantinedLegacyMessages:{...r.quarantinedLegacyMessages??{},...o},followUpBehavior:Ia(r.followUpBehavior,r.queueModeEnabled??null)}},tm=Ir()(_r(ea((e,t)=>({queuedMessages:{},quarantinedLegacyMessages:{},followUpBehavior:Pa,sendingIds:{},addToQueue:(r,o)=>{const n=re(r),a=t();if((a.queuedMessages[n]??[]).length>=Is||!(n in a.queuedMessages)&&Object.keys(a.queuedMessages).length>=Rs)return!1;const c={id:`queued-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,content:o.content,attachments:o.attachments,createdAt:Date.now(),sendConfig:o.sendConfig};let d=!1;return e(l=>{const u=l.queuedMessages[n]??[];return u.length>=Is||!(n in l.queuedMessages)&&Object.keys(l.queuedMessages).length>=Rs?l:(d=!0,{queuedMessages:{...l.queuedMessages,[n]:[...u,c]}})}),d},removeFromQueue:(r,o)=>{const n=re(r);if((t().sendingIds[n]??[]).includes(o))return;const a=(t().queuedMessages[n]??[]).filter(s=>s.id===o);an(r,a.filter(s=>!s.deliveryAttempt)),e(s=>{const c=(s.queuedMessages[n]??[]).filter(d=>d.id!==o);if(c.length===0){const{[n]:d,...l}=s.queuedMessages;return{queuedMessages:l}}return{queuedMessages:{...s.queuedMessages,[n]:c}}})},reorderQueue:(r,o,n)=>{if(o===n)return;const a=re(r);e(s=>{const i=s.queuedMessages[a];if(!i)return s;const c=i.findIndex(f=>f.id===o),d=i.findIndex(f=>f.id===n);if(c===-1||d===-1)return s;const l=i.slice(),[u]=l.splice(c,1);return l.splice(d,0,u),{queuedMessages:{...s.queuedMessages,[a]:l}}})},popToInput:(r,o)=>{const n=re(r),a=t();if((a.sendingIds[n]??[]).includes(o))return null;const i=(a.queuedMessages[n]??[]).find(c=>c.id===o);return i?(e(c=>{const l=(c.queuedMessages[n]??[]).filter(u=>u.id!==o);if(l.length===0){const{[n]:u,...f}=c.queuedMessages;return{queuedMessages:f}}return{queuedMessages:{...c.queuedMessages,[n]:l}}}),i):null},clearQueue:r=>{const o=re(r),n=t(),a=n.sendingIds[o]??[];an(r,(n.queuedMessages[o]??[]).filter(s=>!a.includes(s.id)&&!s.deliveryAttempt)),e(s=>{const i=s.sendingIds[o]??[],c=(s.queuedMessages[o]??[]).filter(u=>i.includes(u.id)||u.deliveryAttempt);if(c.length>0)return{queuedMessages:{...s.queuedMessages,[o]:c}};const{[o]:d,...l}=s.queuedMessages;return{queuedMessages:l}})},clearAllQueues:()=>{const r=t();for(const[o,n]of Object.entries(r.queuedMessages)){const a=Zf(o);if(!a)continue;const s=r.sendingIds[o]??[],i=n.filter(c=>!s.includes(c.id)&&!c.deliveryAttempt);i.length>0&&an(a,i)}e(o=>{const n={},a={};for(const[s,i]of Object.entries(o.queuedMessages)){const c=o.sendingIds[s]??[],d=i.filter(l=>c.includes(l.id)||l.deliveryAttempt);if(d.length>0){n[s]=d;const l=c.filter(u=>d.some(f=>f.id===u));l.length>0&&(a[s]=l)}}return{queuedMessages:n,sendingIds:a}})},markSending:(r,o)=>{const n=re(r);e(a=>{const s=a.sendingIds[n]??[];return s.includes(o)?a:{sendingIds:{...a.sendingIds,[n]:[...s,o]}}})},clearSending:(r,o)=>{const n=re(r);e(a=>{const s=a.sendingIds[n];if(!s||!s.includes(o))return a;const i=s.filter(c=>c!==o);if(i.length===0){const{[n]:c,...d}=a.sendingIds;return{sendingIds:d}}return{sendingIds:{...a.sendingIds,[n]:i}}})},markDeliveryAttempt:(r,o,n)=>{if(r.runtimeKey!==D())return null;const a=Ze(r.runtimeKey,r.sessionId);if(!a)return null;const s=re(r);let i=null;return e(c=>{const d=c.queuedMessages[s];if(!d)return c;const l=d.findIndex(g=>g.id===o);if(l===-1)return c;const u=d[l],f=u.deliveryAttempt;if(f?.kind===n&&f.operationId===o&&f.streamEpoch===a&&!u.sendFailed)return i=f,c;i={kind:n,operationId:o,streamEpoch:a};const m=d.slice();return m[l]={...u,deliveryAttempt:i,sendFailed:void 0},{queuedMessages:{...c.queuedMessages,[s]:m}}}),i},markSendFailed:(r,o)=>{const n=re(r);e(a=>{const s=a.queuedMessages[n];if(!s)return a;const i=s.findIndex(f=>f.id===o);if(i===-1)return a;const c=s[i];if(c.sendFailed===!0&&!c.deliveryAttempt)return a;const d=s.slice(),{deliveryAttempt:l,...u}=c;return d[i]={...u,sendFailed:!0},{queuedMessages:{...a.queuedMessages,[n]:d}}})},releaseRefusedSend:(r,o)=>{const n=re(r);e(a=>{const s=a.queuedMessages[n];if(!s)return a;const i=s.findIndex(u=>u.id===o);if(i===-1||!s[i].deliveryAttempt)return a;const{deliveryAttempt:c,...d}=s[i],l=s.slice();return l[i]=d,{queuedMessages:{...a.queuedMessages,[n]:l}}})},markSendUnconfirmed:(r,o,n)=>{const a=re(r);e(s=>{const i=s.queuedMessages[a];if(!i)return s;const c=i.findIndex(f=>f.id===o);if(c===-1)return s;const d=i[c];if(d.deliveryAttempt)return s;const l=i.slice(),u=Ze(r.runtimeKey,r.sessionId);return l[c]={...d,deliveryAttempt:{kind:n,operationId:o,...u?{streamEpoch:u}:{}}},{queuedMessages:{...s.queuedMessages,[a]:l}}})},requeueWithNewIntent:(r,o)=>{if(r.runtimeKey!==D()||!Ze(r.runtimeKey,r.sessionId))return null;const n=re(r),a=`queued-${Yf()}`;let s=!1;return e(i=>{if((i.sendingIds[n]??[]).includes(o))return i;const c=i.queuedMessages[n];if(!c)return i;const d=c.findIndex(g=>g.id===o);if(d===-1||!c[d].deliveryAttempt)return i;const{deliveryAttempt:l,sendFailed:u,...f}=c[d],m=c.slice();return m[d]={...f,id:a},s=!0,{queuedMessages:{...i.queuedMessages,[n]:m}}}),s?a:null},completeQueuedSend:(r,o)=>{const n=re(r);(t().queuedMessages[n]??[]).filter(a=>a.id===o),e(a=>{const s=a.queuedMessages[n]??[],i=s.filter(u=>u.id!==o),c=a.sendingIds[n],d=c?.includes(o)?c.filter(u=>u!==o):c,l={};if(i.length===0){if(n in a.queuedMessages){const{[n]:u,...f}=a.queuedMessages;l.queuedMessages=f}}else i.length!==s.length&&(l.queuedMessages={...a.queuedMessages,[n]:i});if(d!==c)if(!d||d.length===0){const{[n]:u,...f}=a.sendingIds;l.sendingIds=f}else l.sendingIds={...a.sendingIds,[n]:d};return Object.keys(l).length>0?l:a})},claimQueuedMessage:(r,o)=>{const n=re(r);let a=null;return e(s=>{const i=s.queuedMessages[n]??[],c=s.sendingIds[n]??[];if(c.includes(o))return s;const d=i.find(u=>u.id===o);if(!d)return s;const l=Ze(r.runtimeKey,r.sessionId);return r.runtimeKey!==D()||!l||d.deliveryAttempt?s:(a=d,{sendingIds:{...s.sendingIds,[n]:[...c,o]}})}),a},getAutoSendCandidate:r=>{const o=re(r),n=t(),a=n.queuedMessages[o]??[],s=n.sendingIds[o]??[];if(r.runtimeKey!==D()||!Ze(r.runtimeKey,r.sessionId))return null;for(const i of a){if(s.includes(i.id)||i.deliveryAttempt)return null;if(i.sendFailed!==!0)return i}return null},getSendableQueue:r=>{const o=re(r),n=t(),a=n.queuedMessages[o]??[],s=n.sendingIds[o];return!s||s.length===0?a:a.filter(i=>!s.includes(i.id))},setFollowUpBehavior:r=>{e({followUpBehavior:r}),Ke({followUpBehavior:r})},getQueueForTarget:r=>t().queuedMessages[re(r)]??[]}),{name:"message-queue-store",version:2,storage:la(),partialize:e=>({queuedMessages:e.queuedMessages,quarantinedLegacyMessages:e.quarantinedLegacyMessages,followUpBehavior:e.followUpBehavior}),migrate:em}),{name:"message-queue-store"})),rm=["bash","zsh","sh","fish","pwsh","powershell","cmd","dash","ksh","nu"],wo=e=>e==="auto"||typeof e=="string"&&rm.includes(e),om={threshold:.4,distance:100,ignoreLocation:!0,preferSubstring:!0};function nm(e,t,r){if(!t)return!0;if(!e)return!1;const o={...om,...r};return o.preferSubstring&&e.toLowerCase().includes(t.toLowerCase())?!0:new Vs([e],{threshold:o.threshold,distance:o.distance,ignoreLocation:o.ignoreLocation}).search(t).length>0}function Nb(e,t,r,o){if(!t)return e.map(l=>({item:l,score:0}));const n=o?.limit??e.length,a=o?.threshold??.3,s=o?.noFuzzy??!1,i=t.toLowerCase(),c=[],d=[];for(const l of e){const u=r(l);if(!u)continue;const m=u.toLowerCase().indexOf(i);if(m===0){c.push({item:l,score:-1});continue}if(m>0){c.push({item:l,score:m/1e3});continue}s||d.push({item:l,text:u})}if(d.length>0){const l=new Vs(d.map(u=>u.text),{threshold:a,ignoreLocation:!0,distance:100,includeScore:!0,minMatchCharLength:2});for(const u of l.search(t))c.push({item:d[u.refIndex].item,score:u.score??1})}return c.sort((l,u)=>l.score-u.score),c.slice(0,n)}function Lb(...e){return Nc(Oc(e))}const qe=()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),am=()=>typeof navigator>"u"?!1:/Windows/.test(navigator.userAgent||""),Ub=()=>qe()?"Reveal in Finder":am()?"Open in File Explorer":"Open in File Manager",Hb=e=>qe()&&we()?e.metaKey:e.ctrlKey,Kb=()=>qe()&&we()?"⌘":"Ctrl",jb=(e,t)=>{const r=e??"",o=Math.max(16,t?.maxLength??45);if(r.length<=o)return r;const n=r.split("/");if(n.length<=1)return r;const a=n.pop()??"";if(!a)return r;const s=Math.max(0,o-(a.length+2));if(s<=0)return`…/${a}`;let i="";for(const c of n){if(!c)continue;const d=i?`${i}/${c}`:c;if(d.length>s)break;i=d}if(!i){const c=n[0]??"";i=c?c.slice(0,s):""}return i?`${i}…/${a}`:`…/${a}`},Bo=e=>e?e==="/"?"/":e.replace(/\/+$/,""):"";function $b(e,t){if(!e)return"";const r=Bo(e);if(r==="/")return"/";const o=t?Bo(t):void 0;if(o&&o!=="/"){if(r===o)return"~";if(r.startsWith(`${o}/`)){const n=r.slice(o.length+1);return n?`~/${n}`:"~"}}return r}function zb(e,t){if(!e)return"/";const r=Bo(e);if(!r||r==="/")return"/";const o=t?Bo(t):void 0;return o&&o!=="/"&&r===o?"~":r.split("/").pop()||r||"/"}function qb(e,t){return nm(e,t)}const $e="__unassigned__",ac={mod:"mod",shift:"shift",alt:"alt",option:"alt",ctrl:"ctrl",meta:"mod",cmd:"mod",command:"mod"},gr=qe()&&we(),sm={mod:gr?"⌘":"Ctrl",shift:gr?"⇧":"Shift",alt:gr?"⌥":"Alt",option:gr?"⌥":"Alt",ctrl:gr?"⌃":"Ctrl"},im={mod:qe()&&we()?["meta"]:qe()?["meta","control"]:["control"],shift:["shift"],alt:["alt"],option:["alt"],ctrl:["control"]},cm={comma:",",period:".",enter:"Enter",escape:"Esc",tab:"Tab",space:"Space",backspace:"⌫",delete:"⌦",arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→",home:"Home",end:"End",pageup:"Page Up",pagedown:"Page Down"},sc=["mod","ctrl","shift","alt"],dm={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\","~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0"};function ct(e){return e.trim().toLowerCase()===$e}function _s(e){const t=e.toLowerCase();return t===","?"comma":t==="."?"period":t===" "?"space":t==="esc"?"escape":t==="+"?"plus":t==="-"||t==="_"?"minus":t==="arrowup"?"arrowup":t==="arrowdown"?"arrowdown":t==="arrowleft"?"arrowleft":t==="arrowright"?"arrowright":dm[t]??t}const ic=[{id:"open_command_palette",defaultCombo:"mod+p",label:"Open command palette",description:"Open the command palette",customizable:!0},{id:"focus_input",defaultCombo:"mod+i",label:"Focus input",description:"Focus the chat input field",customizable:!0},{id:"open_settings",defaultCombo:"mod+comma",label:"Open settings",description:"Open the settings panel",customizable:!0},{id:"toggle_terminal",defaultCombo:"mod+j",label:"Toggle terminal dock",description:"Toggle the bottom terminal dock",customizable:!0},{id:"add_selection_to_chat",defaultCombo:"mod+l",label:"Add selection to chat",description:"Add the selected text to the chat input",customizable:!0},{id:"toggle_sidebar",defaultCombo:"mod+alt+l",label:"Toggle sidebar",description:"Toggle the session sidebar",customizable:!0},{id:"open_timeline_dialog",defaultCombo:"mod+t",label:"Open conversation timeline",description:"Search and navigate within current conversation",customizable:!0},{id:"open_right_sidebar",defaultCombo:"mod+b",label:"Open right sidebar",description:"Open the right sidebar",customizable:!0},{id:"cycle_session_folder",defaultCombo:"mod+shift+f",label:"Cycle session folder",description:"Switch to the next session folder",customizable:!0},{id:"cycle_draft_folder",defaultCombo:"mod+shift+d",label:"Cycle draft folder",description:"Change the folder for the new session draft",customizable:!0},{id:"switch_context_surface",defaultCombo:"mod",label:"Switch context panel surface",description:"Hold the modifier and press a number to open or close the matching rail icon",customizable:!0},{id:"new_chat",defaultCombo:"mod+n",label:"New session",description:"Start a new session",customizable:!0},{id:"new_mini_chat",defaultCombo:"mod+alt+n",label:"New Mini Chat window",description:"Open a new Mini Chat draft window",customizable:!0},{id:"submit_message",defaultCombo:"mod+enter",label:"Submit message",description:"Submit the current message"},{id:"clear_input",defaultCombo:"escape",label:"Clear input",description:"Clear the input field"},{id:"open_help",defaultCombo:"mod+.",label:"Open keyboard shortcuts",description:"Show the keyboard shortcuts help",customizable:!0},{id:"toggle_services_menu",defaultCombo:"mod+shift+s",label:"Toggle services menu",description:"Open or close the services menu",customizable:!0},{id:"cycle_theme",defaultCombo:"mod+/",label:"Cycle theme",description:"Cycle between light, dark, and system theme",customizable:!0},{id:"open_model_selector",defaultCombo:"mod+shift+m",label:"Open model selector",description:"Open model selector while in chat",customizable:!0},{id:"cycle_thinking_variant",defaultCombo:"mod+shift+t",label:"Cycle thinking",description:"Cycle thinking while in chat"},{id:"cycle_favorite_model_forward",defaultCombo:"ctrl+]",label:"Cycle favorite model forward",description:"Cycle forward through starred models without opening the picker",customizable:!0},{id:"cycle_favorite_model_backward",defaultCombo:"ctrl+[",label:"Cycle favorite model backward",description:"Cycle backward through starred models without opening the picker",customizable:!0},{id:"abort_run",defaultCombo:"escape",label:"Abort active run",description:"Abort the currently running task (double press)"}];function xo(e){if(ct(e))return $e;const t=e.toLowerCase().trim().split("+").map(a=>a.trim()).filter(Boolean),r=new Set;let o="";for(const a of t){const s=a===","?"comma":a==="."?"period":a,i=ac[s];if(i){r.add(i);continue}o=s}return[...sc.filter(a=>r.has(a)),o].filter(Boolean).join("+")}function lm(e){return ct(e)?!0:St(e).key.trim().length>0}function St(e){if(ct(e))return{modifiers:new Set,key:$e};const r=xo(e).split("+"),o=new Set;let n="";for(const a of r){const s=ac[a];s?o.add(s):n=a}return{modifiers:o,key:n}}function Gb(e){if(ct(e))return"Unassigned";const t=St(e);if(!t.key&&t.modifiers.size===0)return"Unassigned";const r=[];for(const o of sc)t.modifiers.has(o)&&r.push(sm[o]);if(t.key){const o=cm[t.key.toLowerCase()]||t.key.toUpperCase();r.push(o)}return r.join(" + ")}function cc(e){return ic.find(t=>t.id===e)}function Wb(){return ic.filter(e=>e.customizable===!0)}function Vb(e,t){const r=cc(e);if(!r)return"";const o=t?.[e];if(typeof o=="string"){if(o.trim().toLowerCase()===$e)return"";const n=xo(o);if(n===$e)return $e;if(lm(n))return n}return r.defaultCombo}function Jb(e){if(ct(e))return!1;const t=St(e);if(!t.modifiers.has("mod"))return!1;const r=t.key.toLowerCase();return new Set(["w","t","r","p","s","f","l","n"]).has(r)&&!t.modifiers.has("shift")&&!t.modifiers.has("alt")}const dc=(e,t)=>{const r=t.modifiers.has("mod"),o=t.modifiers.has("shift"),n=t.modifiers.has("alt"),a=t.modifiers.has("ctrl"),s=qe()&&we(),i=qe(),c=s?e.metaKey:i&&e.metaKey||e.ctrlKey;if(r&&!c||!r&&e.metaKey||o!==e.shiftKey||n!==e.altKey)return!1;if(a)return e.ctrlKey;const d=r&&!s&&e.ctrlKey;return!e.ctrlKey||d};function Yb(e,t){const r=typeof t=="string"?t:t.defaultCombo;if(ct(r))return!1;const o=St(r);if(!dc(e,o))return!1;let n=e.key;e.altKey&&(e.code.startsWith("Key")&&e.code.length===4?n=e.code.slice(3).toLowerCase():e.code.startsWith("Digit")&&e.code.length===6&&(n=e.code.slice(5)));const a=_s(n),s=_s(o.key);return a===s}function Xb(){return qe()&&we()?"⌘":"Ctrl"}function Qb(e,t){const r=cc(e);if(!r)return"";const o=t?.[e];if(typeof o=="string"&&o.trim()!==""){const n=xo(o);if(n===$e)return $e;if(n){const a=St(n);if(a.modifiers.size>0||a.key)return n}}return r.defaultCombo}function Zb(e,t){if(ct(e))return!1;const r=St(e);for(const o of r.modifiers)if(!im[o].some(a=>t.has(a)))return!1;return!(r.key&&!t.has(r.key.toLowerCase()))}function eA(e,t,r){if(ct(t))return!1;const o=St(t);return!(!dc(e,o)||o.key&&(!r||!r.has(o.key.toLowerCase())))}const um=12,fm=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Zr=(e,t)=>{if(!(typeof e!="string"||e.length===0))return e.length>t?e.slice(0,t):e},mm=e=>{if(!Array.isArray(e))return;const t=[],r=new Set;for(const o of e.slice(0,um)){if(!fm(o))continue;const n=Zr(o.label,64),a=Zr(o.command,128);if(!n||!a||a.includes("/")||a.startsWith("."))continue;let s=Zr(o.id,64);(!s||r.has(s))&&(s=`trigger-${t.length+1}-${a}`),r.add(s);const i=Zr(o.args,2e3),c=typeof o.combo=="string"&&o.combo.length>0?xo(o.combo):void 0,d=c&&c!==$e?c:void 0;t.push({id:s,label:n,command:a,...i!==void 0?{args:i}:{},...d!==void 0?{combo:d}:{}})}return t.length>0?t:void 0},gm=e=>Array.from(e??"",t=>{const r=t.charCodeAt(0);return r<32||r===127?" ":t}).join("").trim().slice(0,2e3),pm=(e,t)=>{const r=gm(t);return r?`/${e} ${r}`:`/${e}`},tA=e=>pm(e.command,e.args),hm=e=>{const t=e.replace(/\\/g,"/").replace(/\/+$/g,"").trim();if(!t)return"";const r=new TextEncoder().encode(t);let o="";for(const a of r)o+=String.fromCharCode(a);return`path_${typeof btoa=="function"?btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""):t.replace(/[^A-Za-z0-9._-]+/g,"_")}`},Fm="#8957e5",ym="#8250df",bm=e=>{const t=e.colors.syntax?.tokens??{},r=[t.className,t.enum,t.variableGlobal,e.colors.syntax?.base?.keyword].filter(o=>typeof o=="string"&&o.trim().length>0);return r.length>0?r[0]:e.metadata.variant==="dark"?Fm:ym},Hr=e=>e.colors.pr?e:{...e,colors:{...e.colors,pr:{open:e.colors.status.success,draft:e.colors.surface.mutedForeground,blocked:e.colors.status.warning,merged:bm(e),closed:e.colors.status.error}}},Am={id:"aura-dark",name:"Aura",description:"Aura",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Em={primary:{base:"#A277FF",hover:"#8D68DD",active:"#B08BFF",foreground:"#15141B",muted:"#A277FF80",emphasis:"#8D68DD"},surface:{background:"#15141B",foreground:"#EDECEE",muted:"#1A1921",mutedForeground:"#8a8282",elevated:"#201e2b",elevatedForeground:"#EDECEE",overlay:"#FFFFFF20",subtle:"#25232f"},interactive:{border:"#2a2935",borderHover:"#47415a",borderFocus:"#4E496C",selection:"#95abe02d",selectionForeground:"#FFFFFF",focus:"#A277FF",focusRing:"#A277FF40",cursor:"#FFFFFF",hover:"#7887ac2d",active:"#95abe02d"},status:{error:"#FF6767",errorForeground:"#15141B",errorBackground:"#FF676720",errorBorder:"#FF676750",warning:"#FFCA85",warningForeground:"#15141B",warningBackground:"#FFCA8520",warningBorder:"#FFCA8550",success:"#61FFCA",successForeground:"#15141B",successBackground:"#61FFCA20",successBorder:"#61FFCA50",info:"#82E2FF",infoForeground:"#15141B",infoBackground:"#82E2FF20",infoBorder:"#82E2FF50"},pr:{open:"#61FFCA",draft:"#6D6D6D",blocked:"#FFCA85",merged:"#A277FF",closed:"#FF6767"},syntax:{base:{background:"#1A1921",foreground:"#EDECEE",comment:"#6D6D6D",keyword:"#A277FF",string:"#61FFCA",number:"#FF6767",function:"#A277FF",variable:"#EDECEE",type:"#FFCA85",operator:"#FF6767"},tokens:{boolean:"#FFCA85",class:"#A277FF",className:"#A277FF",commentDoc:"#606061",constant:"#82E2FF",decorator:"#FFCA85",enum:"#A277FF",exception:"#FF6767",functionCall:"#A277FF",interface:"#FFCA85",jsxTag:"#A277FF",key:"#A277FF",keywordImport:"#FF6767",label:"#FF6767",macro:"#82E2FF",method:"#61FFCA",module:"#FF6767",namespace:"#FFCA85",parameter:"#EDECEE",preprocessor:"#FF6767",punctuation:"#6D6D6D",regex:"#61FFCA",storageModifier:"#82E2FF",stringEscape:"#FFFFFF",struct:"#A277FF",tag:"#A277FF",tagAttribute:"#FFCA85",tagAttributeValue:"#61FFCA",typeParameter:"#FFCA85",url:"#A277FF",variableGlobal:"#A277FF",variableLocal:"#121118",variableOther:"#61FFCA",variableProperty:"#82E2FF"},highlights:{diffAdded:"#61FFCA",diffAddedBackground:"#162620",diffModified:"#82E2FF",diffModifiedBackground:"#1E1D2A",diffRemoved:"#FF6767",diffRemovedBackground:"#26161A",lineNumber:"#3E3A56",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#e7d7f4",heading2:"#e7e0ee",heading3:"#ece7f0",heading4:"#EDECEE",link:"#A277FF",linkHover:"#F694FF",inlineCode:"#61FFCA",inlineCodeBackground:"#1A1921",blockquote:"#6D6D6D",blockquoteBorder:"#2D2B38",listMarker:"#A277FF99"},chat:{userMessage:"#EDECEE",userMessageBackground:"#393647",assistantMessage:"#EDECEE",assistantMessageBackground:"#15141B",timestamp:"#6D6D6D",divider:"#2D2B38"},tools:{background:"#1A192180",border:"#43415480",headerHover:"#0F0E14",icon:"#6D6D6D",title:"#EDECEE",description:"#6D6D6D",edit:{added:"#61FFCA",addedBackground:"#61FFCA25",removed:"#FF6767",removedBackground:"#FF676725",lineNumber:"#3E3A56"}}},wm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Bm={metadata:Am,colors:Em,config:wm},Cm={id:"aura-light",name:"Aura",description:"Aura",version:"1.0.0",variant:"light",tags:["light","palette"]},vm={primary:{base:"#A277FF",hover:"#B38FFF",active:"#8D68DD",foreground:"#F5F0FF",muted:"#A277FF80",emphasis:"#B38FFF"},surface:{background:"#F5F0FF",foreground:"#2D2640",muted:"#EFE8FC",mutedForeground:"#807b8b",elevated:"#f1ebfb",elevatedForeground:"#2D2640",overlay:"#15101F20",subtle:"#EFE8FC"},interactive:{border:"#E0D6F2",borderHover:"#D5C9EB",borderFocus:"#A593C8",selection:"#bdb2d74c",selectionForeground:"#15101F",focus:"#A277FF",focusRing:"#A277FF40",cursor:"#15101F",hover:"#bdb2d72d",active:"#bdb2d74c"},status:{error:"#D94F4F",errorForeground:"#F5F0FF",errorBackground:"#D94F4F20",errorBorder:"#D94F4F50",warning:"#D9A24A",warningForeground:"#F5F0FF",warningBackground:"#D9A24A20",warningBorder:"#D9A24A50",success:"#40BF7A",successForeground:"#F5F0FF",successBackground:"#40BF7A20",successBorder:"#40BF7A50",info:"#5BB8D9",infoForeground:"#F5F0FF",infoBackground:"#5BB8D920",infoBorder:"#5BB8D950"},pr:{open:"#40BF7A",draft:"#6D6D6D",blocked:"#D9A24A",merged:"#A277FF",closed:"#D94F4F"},syntax:{base:{background:"#EFE8FC",foreground:"#2D2640",comment:"#5C5270",keyword:"#A277FF",string:"#40BF7A",number:"#D94F4F",function:"#A277FF",variable:"#2D2640",type:"#D9A24A",operator:"#D94F4F"},tokens:{boolean:"#D9A24A",class:"#A277FF",className:"#A277FF",commentDoc:"#A9A1B8",constant:"#5BB8D9",decorator:"#D9A24A",enum:"#A277FF",exception:"#D94F4F",functionCall:"#A277FF",interface:"#D9A24A",jsxTag:"#A277FF",key:"#A277FF",keywordImport:"#D94F4F",label:"#D94F4F",macro:"#5BB8D9",method:"#40BF7A",module:"#D94F4F",namespace:"#D9A24A",parameter:"#2D2640",preprocessor:"#D94F4F",punctuation:"#5C5270",regex:"#40BF7A",storageModifier:"#5BB8D9",stringEscape:"#15101F",struct:"#A277FF",tag:"#A277FF",tagAttribute:"#D9A24A",tagAttributeValue:"#40BF7A",typeParameter:"#D9A24A",url:"#A277FF",variableGlobal:"#A277FF",variableLocal:"#FAF7FF",variableOther:"#40BF7A",variableProperty:"#5BB8D9"},highlights:{diffAdded:"#40BF7A",diffAddedBackground:"#E8F5ED",diffModified:"#5BB8D9",diffModifiedBackground:"#E8E4F5",diffRemoved:"#D94F4F",diffRemovedBackground:"#FAE8E8",lineNumber:"#C0B3DC",lineNumberActive:"#15101F"}},markdown:{heading1:"#A277FF",heading2:"#A277FF",heading3:"#D9A24A",heading4:"#2D2640",link:"#A277FF",linkHover:"#C17AC8",inlineCode:"#40BF7A",inlineCodeBackground:"#EFE8FC",blockquote:"#6D6D6D",blockquoteBorder:"#E0D6F2",listMarker:"#A277FF99"},chat:{userMessage:"#2D2640",userMessageBackground:"#EFE8FC",assistantMessage:"#2D2640",assistantMessageBackground:"#F5F0FF",timestamp:"#5C5270",divider:"#E0D6F2"},tools:{background:"#EFE8FC80",border:"#bdb5cd80",headerHover:"#FDFCFF",icon:"#5C5270",title:"#2D2640",description:"#5C5270",edit:{added:"#40BF7A",addedBackground:"#40BF7A25",removed:"#D94F4F",removedBackground:"#D94F4F25",lineNumber:"#C0B3DC"}}},km={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Dm={metadata:Cm,colors:vm,config:km},Sm={id:"ayu-dark",name:"Ayu",description:"Ayu",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Mm={primary:{base:"#3FB7E3",hover:"#389FC5",active:"#5BC1E7",foreground:"#0F1419",muted:"#3FB7E380",emphasis:"#389FC5"},surface:{background:"#0F1419",foreground:"#D6DAE0",muted:"#18222C",mutedForeground:"#777e86",elevated:"#17202a",elevatedForeground:"#D6DAE0",overlay:"#FBFBFD20",subtle:"#1e252d"},interactive:{border:"#292c30",borderHover:"#323C49",borderFocus:"#56647C",selection:"#c7c7df1d",selectionForeground:"#FBFBFD",focus:"#3FB7E3",focusRing:"#3FB7E340",cursor:"#FBFBFD",hover:"#b6b6cc1d",active:"#b8b8ce1d"},status:{error:"#F58572",errorForeground:"#0F1419",errorBackground:"#F5857220",errorBorder:"#F5857250",warning:"#E4A75C",warningForeground:"#0F1419",warningBackground:"#E4A75C20",warningBorder:"#E4A75C50",success:"#78D05C",successForeground:"#0F1419",successBackground:"#78D05C20",successBorder:"#78D05C50",info:"#66C6F1",infoForeground:"#0F1419",infoBackground:"#66C6F120",infoBorder:"#66C6F150"},pr:{open:"#78D05C",draft:"#A3ADBA",blocked:"#E4A75C",merged:"#8a44f2",closed:"#F58572"},syntax:{base:{background:"#18222C",foreground:"#D6DAE0",comment:"#A3ADBA",keyword:"#3FB7E3",string:"#B1C74A",number:"#F2856F",function:"#3FB7E3",variable:"#D6DAE0",type:"#E4A75C",operator:"#F2856F"},tokens:{boolean:"#E4A75C",class:"#3FB7E3",className:"#3FB7E3",commentDoc:"#8D96A2",constant:"#66C6F1",decorator:"#E4A75C",enum:"#3FB7E3",exception:"#F2856F",functionCall:"#3FB7E3",interface:"#E4A75C",jsxTag:"#3FB7E3",key:"#3FB7E3",keywordImport:"#F2856F",label:"#F2856F",macro:"#66C6F1",method:"#78D05C",module:"#F2856F",namespace:"#E4A75C",parameter:"#D6DAE0",preprocessor:"#F2856F",punctuation:"#A3ADBA",regex:"#B1C74A",storageModifier:"#66C6F1",stringEscape:"#FBFBFD",struct:"#3FB7E3",tag:"#3FB7E3",tagAttribute:"#E4A75C",tagAttributeValue:"#B1C74A",typeParameter:"#E4A75C",url:"#66C6F1",variableGlobal:"#3FB7E3",variableLocal:"#0B1015",variableOther:"#78D05C",variableProperty:"#66C6F1"},highlights:{diffAdded:"#78D05C",diffAddedBackground:"#132F27",diffModified:"#66C6F1",diffModifiedBackground:"#1B2632",diffRemoved:"#F58572",diffRemovedBackground:"#361D20",lineNumber:"#415063",lineNumberActive:"#FBFBFD"}},markdown:{heading1:"#D6DAE0",heading2:"#D6DAE0",heading3:"#D6DAE0",heading4:"#D6DAE0",link:"#66C6F1",linkHover:"#3FB7E3",inlineCode:"#B1C74A",inlineCodeBackground:"#161d23",blockquote:"#E4A75C",blockquoteBorder:"#2B3440",listMarker:"#3FB7E399"},chat:{userMessage:"#D6DAE0",userMessageBackground:"#1d2935",assistantMessage:"#D6DAE0",assistantMessageBackground:"#0F1419",timestamp:"#A3ADBA",divider:"#2B3440"},tools:{background:"#18222C80",border:"#414e5f80",headerHover:"#080C10",icon:"#A3ADBA",title:"#D6DAE0",description:"#A3ADBA",edit:{added:"#78D05C",addedBackground:"#78D05C25",removed:"#F58572",removedBackground:"#F5857225",lineNumber:"#415063"}}},Tm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Pm={metadata:Sm,colors:Mm,config:Tm},Rm={id:"ayu-light",name:"Ayu",description:"Ayu",version:"1.0.0",variant:"light",tags:["light","palette"]},Im={primary:{base:"#4AA8C8",hover:"#6EB8D1",active:"#4394B0",foreground:"#FDFAF4",muted:"#4AA8C880",emphasis:"#6EB8D1"},surface:{background:"#FDFAF4",foreground:"#394049",muted:"#f7f3eb",mutedForeground:"#777e87",elevated:"#faf6ed",elevatedForeground:"#4F5964",overlay:"#1B232B20",subtle:"#FFF7E5"},interactive:{border:"#ece5d9",borderHover:"#DCD3C5",borderFocus:"#B09F8F",selection:"#9fb2c43e",selectionForeground:"#171e25",focus:"#4AA8C8",focusRing:"#4AA8C840",cursor:"#1B232B",hover:"#9fb2c42c",active:"#9fb2c43e"},status:{error:"#E6656A",errorForeground:"#FDFAF4",errorBackground:"#E6656A20",errorBorder:"#E6656A50",warning:"#EA9F41",warningForeground:"#FDFAF4",warningBackground:"#EA9F4120",warningBorder:"#EA9F4150",success:"#5FB978",successForeground:"#FDFAF4",successBackground:"#5FB97820",successBorder:"#5FB97850",info:"#2F9BCE",infoForeground:"#FDFAF4",infoBackground:"#2F9BCE20",infoBorder:"#2F9BCE50"},pr:{open:"#5FB978",draft:"#77818D",blocked:"#EA9F41",merged:"#7b3cda",closed:"#E6656A"},syntax:{base:{background:"#FCF9F3",foreground:"#4F5964",comment:"#77818D",keyword:"#4AA8C8",string:"#7FAD00",number:"#EF7D71",function:"#4AA8C8",variable:"#4F5964",type:"#ED982E",operator:"#EF7D71"},tokens:{boolean:"#ED982E",class:"#4AA8C8",className:"#4AA8C8",commentDoc:"#BABEC1",constant:"#2F9BCE",decorator:"#ED982E",enum:"#4AA8C8",exception:"#EF7D71",functionCall:"#4AA8C8",interface:"#ED982E",jsxTag:"#4AA8C8",key:"#4AA8C8",keywordImport:"#EF7D71",label:"#EF7D71",macro:"#2F9BCE",method:"#5FB978",module:"#EF7D71",namespace:"#ED982E",parameter:"#4F5964",preprocessor:"#EF7D71",punctuation:"#77818D",regex:"#7FAD00",storageModifier:"#2F9BCE",stringEscape:"#1B232B",struct:"#4AA8C8",tag:"#4AA8C8",tagAttribute:"#ED982E",tagAttributeValue:"#7FAD00",typeParameter:"#ED982E",url:"#2F9BCE",variableGlobal:"#4AA8C8",variableLocal:"#FBF8F2",variableOther:"#5FB978",variableProperty:"#2F9BCE"},highlights:{diffAdded:"#5FB978",diffAddedBackground:"#EEF5E4",diffModified:"#2F9BCE",diffModifiedBackground:"#E3EDF3",diffRemoved:"#E6656A",diffRemovedBackground:"#FDE5E5",lineNumber:"#C6BFAF",lineNumberActive:"#1B232B"}},markdown:{heading1:"#394049",heading2:"#394049",heading3:"#394049",heading4:"#394049",link:"#2F9BCE",linkHover:"#4AA8C8",inlineCode:"#7FAD00",inlineCodeBackground:"#FCF9F3",blockquote:"#ED982E",blockquoteBorder:"#E6DDCF",listMarker:"#4AA8C899"},chat:{userMessage:"#4F5964",userMessageBackground:"#fff7e5",assistantMessage:"#4F5964",assistantMessageBackground:"#FDFAF4",timestamp:"#77818D",divider:"#E6DDCF"},tools:{background:"#FCF9F380",border:"#cec6b980",headerHover:"#FAF7F1",icon:"#77818D",title:"#4F5964",description:"#77818D",edit:{added:"#5FB978",addedBackground:"#5FB97825",removed:"#E6656A",removedBackground:"#E6656A25",lineNumber:"#C6BFAF"}}},_m={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},xm={metadata:Rm,colors:Im,config:_m},Om={id:"carbonfox-dark",name:"Carbonfox",description:"Carbonfox",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Nm={primary:{base:"#33B1FF",hover:"#2F9ADC",active:"#52BDFF",foreground:"#161616",muted:"#33B1FF80",emphasis:"#2F9ADC"},surface:{background:"#161616",foreground:"#F2F4F8",muted:"#222222",mutedForeground:"#8b8a8a",elevated:"#222222",elevatedForeground:"#F2F4F8",overlay:"#FFFFFF20",subtle:"#292828"},interactive:{border:"#2d2c2c",borderHover:"#4C4C4C",borderFocus:"#4589FF",selection:"#ffffff20",selectionForeground:"#FFFFFF",focus:"#4589FF",focusRing:"#4589FF40",cursor:"#FFFFFF",hover:"#ffffff12",active:"#ffffff12"},status:{error:"#FF8389",errorForeground:"#161616",errorBackground:"#FF838920",errorBorder:"#FF838950",warning:"#F1C21B",warningForeground:"#161616",warningBackground:"#F1C21B20",warningBorder:"#F1C21B50",success:"#42BE65",successForeground:"#161616",successBackground:"#42BE6520",successBorder:"#42BE6550",info:"#78A9FF",infoForeground:"#161616",infoBackground:"#78A9FF20",infoBorder:"#78A9FF50"},pr:{open:"#42BE65",draft:"#8D8D8D",blocked:"#F1C21B",merged:"#BE95FF",closed:"#FF8389"},syntax:{base:{background:"#262626",foreground:"#F2F4F8",comment:"#8D8D8D",keyword:"#78A9FF",string:"#42BE65",number:"#FF8389",function:"#78A9FF",variable:"#F2F4F8",type:"#08BDBA",operator:"#FF8389"},tokens:{boolean:"#08BDBA",class:"#78A9FF",className:"#78A9FF",commentDoc:"#7B7B7B",constant:"#BE95FF",decorator:"#08BDBA",enum:"#78A9FF",exception:"#FF8389",functionCall:"#78A9FF",interface:"#08BDBA",jsxTag:"#78A9FF",key:"#78A9FF",keywordImport:"#FF8389",label:"#FF8389",macro:"#78A9FF",method:"#42BE65",module:"#FF8389",namespace:"#08BDBA",parameter:"#F2F4F8",preprocessor:"#FF8389",punctuation:"#8D8D8D",regex:"#42BE65",storageModifier:"#78A9FF",stringEscape:"#FFFFFF",struct:"#78A9FF",tag:"#78A9FF",tagAttribute:"#08BDBA",tagAttributeValue:"#42BE65",typeParameter:"#08BDBA",url:"#33B1FF",variableGlobal:"#78A9FF",variableLocal:"#0D0D0D",variableOther:"#42BE65",variableProperty:"#BE95FF"},highlights:{diffAdded:"#42BE65",diffAddedBackground:"#0E3A22",diffModified:"#78A9FF",diffModifiedBackground:"#78A9FF20",diffRemoved:"#FF8389",diffRemovedBackground:"#4D1A1F",lineNumber:"#4C4C4C",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#F2F4F8",heading2:"#F2F4F8",heading3:"#F2F4F8",heading4:"#F2F4F8",link:"#33B1FF",linkHover:"#78A9FF",inlineCode:"#42BE65",inlineCodeBackground:"#1e1e1e",blockquote:"#8D8D8D",blockquoteBorder:"#393939",listMarker:"#33B1FF99"},chat:{userMessage:"#F2F4F8",userMessageBackground:"#262626",assistantMessage:"#F2F4F8",assistantMessageBackground:"#161616",timestamp:"#8D8D8D",divider:"#393939"},tools:{background:"#26262680",border:"#4e4c4c80",headerHover:"#000000",icon:"#8D8D8D",title:"#F2F4F8",description:"#8D8D8D",edit:{added:"#42BE65",addedBackground:"#42BE6525",removed:"#FF8389",removedBackground:"#FF838925",lineNumber:"#4C4C4C"}}},Lm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Um={metadata:Om,colors:Nm,config:Lm},Hm={id:"carbonfox-light",name:"Carbonfox",description:"Carbonfox",version:"1.0.0",variant:"light",tags:["light","palette"]},Km={primary:{base:"#0072C3",hover:"#338ECF",active:"#0061A6",foreground:"#FFFFFF",muted:"#0072C380",emphasis:"#338ECF"},surface:{background:"#FFFFFF",foreground:"#161616",muted:"#F4F4F4",mutedForeground:"#868585",elevated:"#f4f4f7",elevatedForeground:"#161616",overlay:"#00000020",subtle:"#f6f6f8"},interactive:{border:"#e3e2e2",borderHover:"#D0D0D0",borderFocus:"#0F62FE",selection:"#cacfd87f",selectionForeground:"#000000",focus:"#0F62FE",focusRing:"#0F62FE40",cursor:"#000000",hover:"#43424214",active:"#43424212"},status:{error:"#DA1E28",errorForeground:"#FFFFFF",errorBackground:"#DA1E2820",errorBorder:"#DA1E2850",warning:"#F1C21B",warningForeground:"#FFFFFF",warningBackground:"#F1C21B20",warningBorder:"#F1C21B50",success:"#198038",successForeground:"#FFFFFF",successBackground:"#19803820",successBorder:"#19803850",info:"#0043CE",infoForeground:"#FFFFFF",infoBackground:"#0043CE20",infoBorder:"#0043CE50"},pr:{open:"#42BE65",draft:"#8D8D8D",blocked:"#F1C21B",merged:"#BE95FF",closed:"#FF8389"},syntax:{base:{background:"#F4F4F4",foreground:"#161616",comment:"#525252",keyword:"#0043CE",string:"#198038",number:"#DA1E28",function:"#0043CE",variable:"#161616",type:"#007D79",operator:"#DA1E28"},tokens:{boolean:"#007D79",class:"#0043CE",className:"#0043CE",commentDoc:"#A9A9A9",constant:"#6929C4",decorator:"#007D79",enum:"#0043CE",exception:"#DA1E28",functionCall:"#0043CE",interface:"#007D79",jsxTag:"#0043CE",key:"#0043CE",keywordImport:"#DA1E28",label:"#DA1E28",macro:"#0043CE",method:"#198038",module:"#DA1E28",namespace:"#007D79",parameter:"#161616",preprocessor:"#DA1E28",punctuation:"#525252",regex:"#198038",storageModifier:"#0043CE",stringEscape:"#000000",struct:"#0043CE",tag:"#0043CE",tagAttribute:"#007D79",tagAttributeValue:"#198038",typeParameter:"#007D79",url:"#0072C3",variableGlobal:"#0043CE",variableLocal:"#E8E8E8",variableOther:"#198038",variableProperty:"#6929C4"},highlights:{diffAdded:"#198038",diffAddedBackground:"#19803820",diffModified:"#0043CE",diffModifiedBackground:"#0043CE20",diffRemoved:"#DA1E28",diffRemovedBackground:"#DA1E2820",lineNumber:"#D0D0D0",lineNumberActive:"#000000"}},markdown:{heading1:"#161616",heading2:"#161616",heading3:"#161616",heading4:"#161616",link:"#0072C3",linkHover:"#0043CE",inlineCode:"#198038",inlineCodeBackground:"#F4F4F4",blockquote:"#525252",blockquoteBorder:"#DCDCDC",listMarker:"#0072C399"},chat:{userMessage:"#161616",userMessageBackground:"#f4f4f7",assistantMessage:"#161616",assistantMessageBackground:"#FFFFFF",timestamp:"#525252",divider:"#DCDCDC"},tools:{background:"#F4F4F480",border:"#bdbbbb80",headerHover:"#DCDCDC",icon:"#525252",title:"#161616",description:"#525252",edit:{added:"#198038",addedBackground:"#19803825",removed:"#DA1E28",removedBackground:"#DA1E2825",lineNumber:"#D0D0D0"}}},jm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},$m={metadata:Hm,colors:Km,config:jm},zm={id:"catppuccin-dark",name:"Catppuccin",description:"Catppuccin",version:"1.0.0",variant:"dark",tags:["dark","palette"]},qm={primary:{base:"#7d8fff",hover:"#9EA6DF",active:"#BEC6FE",foreground:"#1E1E2E",muted:"#B4BEFE80",emphasis:"#9EA6DF"},surface:{background:"#1E1E2E",foreground:"#CDD6F4",muted:"#2a273b",mutedForeground:"#969cb1",elevated:"#282841",elevatedForeground:"#CDD6F4",overlay:"#F4F2FF20",subtle:"#26263f"},interactive:{border:"#35324A",borderHover:"#393655",borderFocus:"#575379",selection:"#8883ae5c",selectionForeground:"#F4F2FF",focus:"#B4BEFE",focusRing:"#B4BEFE40",cursor:"#F4F2FF",hover:"#a19ace20",active:"#a19ace20"},status:{error:"#F38BA8",errorForeground:"#1E1E2E",errorBackground:"#F38BA820",errorBorder:"#F38BA850",warning:"#F4B8E4",warningForeground:"#1E1E2E",warningBackground:"#F4B8E420",warningBorder:"#F4B8E450",success:"#A6D189",successForeground:"#1E1E2E",successBackground:"#A6D18920",successBorder:"#A6D18950",info:"#89DCEB",infoForeground:"#1E1E2E",infoBackground:"#89DCEB20",infoBorder:"#89DCEB50"},pr:{open:"#A6D189",draft:"#A6ADC8",blocked:"#F9E2AF",merged:"#d8b4fe",closed:"#F38BA8"},syntax:{base:{background:"#211F31",foreground:"#CDD6F4",comment:"#A6ADC8",keyword:"#B4BEFE",string:"#A6E3A1",number:"#F38BA8",function:"#B4BEFE",variable:"#CDD6F4",type:"#F9E2AF",operator:"#F38BA8"},tokens:{boolean:"#F9E2AF",class:"#B4BEFE",className:"#B4BEFE",commentDoc:"#9298B1",constant:"#89DCEB",decorator:"#F9E2AF",enum:"#B4BEFE",exception:"#F38BA8",functionCall:"#B4BEFE",interface:"#F9E2AF",jsxTag:"#B4BEFE",key:"#B4BEFE",keywordImport:"#F38BA8",label:"#F38BA8",macro:"#89DCEB",method:"#A6D189",module:"#F38BA8",namespace:"#F9E2AF",parameter:"#CDD6F4",preprocessor:"#F38BA8",punctuation:"#A6ADC8",regex:"#A6E3A1",storageModifier:"#89DCEB",stringEscape:"#F4F2FF",struct:"#B4BEFE",tag:"#B4BEFE",tagAttribute:"#F9E2AF",tagAttributeValue:"#A6E3A1",typeParameter:"#F9E2AF",url:"#89DCEB",variableGlobal:"#B4BEFE",variableLocal:"#1C1C29",variableOther:"#A6D189",variableProperty:"#89DCEB"},highlights:{diffAdded:"#A6D189",diffAddedBackground:"#1D2C30",diffModified:"#89DCEB",diffModifiedBackground:"#232538",diffRemoved:"#F38BA8",diffRemovedBackground:"#2C1F2A",lineNumber:"#47436D",lineNumberActive:"#F4F2FF"}},markdown:{heading1:"#CDD6F4",heading2:"#CDD6F4",heading3:"#CDD6F4",heading4:"#CDD6F4",link:"#89DCEB",linkHover:"#B4BEFE",inlineCode:"#A6E3A1",inlineCodeBackground:"#2d2a42",blockquote:"#F9E2AF",blockquoteBorder:"#35324A",listMarker:"#B4BEFE99"},chat:{userMessage:"#CDD6F4",userMessageBackground:"#3a3a5b",assistantMessage:"#CDD6F4",assistantMessageBackground:"#1E1E2E",timestamp:"#A6ADC8",divider:"#35324A"},tools:{background:"#211F3180",border:"#534e7180",headerHover:"#191926",icon:"#A6ADC8",title:"#CDD6F4",description:"#A6ADC8",edit:{added:"#A6D189",addedBackground:"#A6D18925",removed:"#F38BA8",removedBackground:"#F38BA825",lineNumber:"#47436D"}}},Gm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Wm={metadata:zm,colors:qm,config:Gm},Vm={id:"catppuccin-light",name:"Catppuccin",description:"Catppuccin",version:"1.0.0",variant:"light",tags:["light","palette"]},Jm={primary:{base:"#7287FD",hover:"#8C99F6",active:"#6677DD",foreground:"#F5E0DC",muted:"#7287FD80",emphasis:"#8C99F6"},surface:{background:"#fff6f4",foreground:"#2e314a",muted:"#f8edeb",mutedForeground:"#888992",elevated:"#fbefea",elevatedForeground:"#4C4F69",overlay:"#1F1F2A20",subtle:"#fdeeee"},interactive:{border:"#e4d9dc",borderHover:"#D6C4C8",borderFocus:"#AB97A1",selection:"#ffffff",selectionForeground:"#1F1F2A",focus:"#7287FD",focusRing:"#7287FD40",cursor:"#1F1F2A",hover:"#ffffff8f",active:"#ffffff"},status:{error:"#D20F39",errorForeground:"#F5E0DC",errorBackground:"#D20F3920",errorBorder:"#D20F3950",warning:"#DF8E1D",warningForeground:"#F5E0DC",warningBackground:"#DF8E1D20",warningBorder:"#DF8E1D50",success:"#40A02B",successForeground:"#F5E0DC",successBackground:"#40A02B20",successBorder:"#40A02B50",info:"#04A5E5",infoForeground:"#F5E0DC",infoBackground:"#04A5E520",infoBorder:"#04A5E550"},pr:{open:"#40A02B",draft:"#6C6F85",blocked:"#DF8E1D",merged:"#9572fd",closed:"#D20F39"},syntax:{base:{background:"#F2D8D4",foreground:"#4C4F69",comment:"#6C6F85",keyword:"#7287FD",string:"#40A02B",number:"#D20F39",function:"#7287FD",variable:"#4C4F69",type:"#DF8E1D",operator:"#D20F39"},tokens:{boolean:"#DF8E1D",class:"#7287FD",className:"#7287FD",commentDoc:"#B1A8B1",constant:"#04A5E5",decorator:"#DF8E1D",enum:"#7287FD",exception:"#D20F39",functionCall:"#7287FD",interface:"#DF8E1D",jsxTag:"#7287FD",key:"#7287FD",keywordImport:"#D20F39",label:"#D20F39",macro:"#04A5E5",method:"#40A02B",module:"#D20F39",namespace:"#DF8E1D",parameter:"#4C4F69",preprocessor:"#D20F39",punctuation:"#6C6F85",regex:"#40A02B",storageModifier:"#04A5E5",stringEscape:"#1F1F2A",struct:"#7287FD",tag:"#7287FD",tagAttribute:"#DF8E1D",tagAttributeValue:"#40A02B",typeParameter:"#DF8E1D",url:"#04A5E5",variableGlobal:"#7287FD",variableLocal:"#F9E8E4",variableOther:"#40A02B",variableProperty:"#04A5E5"},highlights:{diffAdded:"#40A02B",diffAddedBackground:"#EDF5E6",diffModified:"#04A5E5",diffModifiedBackground:"#E4E2F6",diffRemoved:"#D20F39",diffRemovedBackground:"#FDE1E3",lineNumber:"#C2AEB4",lineNumberActive:"#1F1F2A"}},markdown:{heading1:"#2e314a",heading2:"#2e314a",heading3:"#2e314a",heading4:"#2e314a",link:"#04A5E5",linkHover:"#7287FD",inlineCode:"#40A02B",inlineCodeBackground:"#f6eeec",blockquote:"#DF8E1D",blockquoteBorder:"#E0CFD3",listMarker:"#7287FD99"},chat:{userMessage:"#2e314a",userMessageBackground:"#ffffff",assistantMessage:"#4C4F69",assistantMessageBackground:"#F5E0DC",timestamp:"#6C6F85",divider:"#E0CFD3"},tools:{background:"#F2D8D480",border:"#cbbec180",headerHover:"#FDEEEE",icon:"#6C6F85",title:"#4C4F69",description:"#6C6F85",edit:{added:"#40A02B",addedBackground:"#40A02B25",removed:"#D20F39",removedBackground:"#D20F3925",lineNumber:"#C2AEB4"}}},Ym={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Xm={metadata:Vm,colors:Jm,config:Ym},Qm={id:"dracula-dark",name:"Dracula",description:"Dracula",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Zm={primary:{base:"#BD93F9",hover:"#A480D8",active:"#C7A3FA",foreground:"#14151F",muted:"#BD93F980",emphasis:"#A480D8"},surface:{background:"#14151F",foreground:"#F8F8F2",muted:"#181926",mutedForeground:"#7c7e9c",elevated:"#161722",elevatedForeground:"#F8F8F2",overlay:"#FFFFFF20",subtle:"#1f2030"},interactive:{border:"#292a36",borderHover:"#303244",borderFocus:"#4A4D6D",selection:"#30334b",selectionForeground:"#FFFFFF",focus:"#BD93F9",focusRing:"#BD93F940",cursor:"#FFFFFF",hover:"#30334ba3",active:"#30334b"},status:{error:"#FF5555",errorForeground:"#14151F",errorBackground:"#FF555520",errorBorder:"#FF555550",warning:"#FFB86C",warningForeground:"#14151F",warningBackground:"#FFB86C20",warningBorder:"#FFB86C50",success:"#50FA7B",successForeground:"#14151F",successBackground:"#50FA7B20",successBorder:"#50FA7B50",info:"#8BE9FD",infoForeground:"#14151F",infoBackground:"#8BE9FD20",infoBorder:"#8BE9FD50"},pr:{open:"#50FA7B",draft:"#B6B9E4",blocked:"#FFB86C",merged:"#BD93F9",closed:"#FF5555"},syntax:{base:{background:"#181926",foreground:"#F8F8F2",comment:"#B6B9E4",keyword:"#BD93F9",string:"#50FA7B",number:"#FF79C6",function:"#BD93F9",variable:"#F8F8F2",type:"#FFB86C",operator:"#FF79C6"},tokens:{boolean:"#FFB86C",class:"#BD93F9",className:"#BD93F9",commentDoc:"#9EA0C6",constant:"#8BE9FD",decorator:"#FFB86C",enum:"#BD93F9",exception:"#FF79C6",functionCall:"#BD93F9",interface:"#FFB86C",jsxTag:"#BD93F9",key:"#BD93F9",keywordImport:"#FF79C6",label:"#FF79C6",macro:"#8BE9FD",method:"#50FA7B",module:"#FF79C6",namespace:"#FFB86C",parameter:"#F8F8F2",preprocessor:"#FF79C6",punctuation:"#B6B9E4",regex:"#50FA7B",storageModifier:"#8BE9FD",stringEscape:"#FFFFFF",struct:"#BD93F9",tag:"#BD93F9",tagAttribute:"#FFB86C",tagAttributeValue:"#50FA7B",typeParameter:"#FFB86C",url:"#8BE9FD",variableGlobal:"#BD93F9",variableLocal:"#161722",variableOther:"#50FA7B",variableProperty:"#8BE9FD"},highlights:{diffAdded:"#50FA7B",diffAddedBackground:"#1F2A2F",diffModified:"#8BE9FD",diffModifiedBackground:"#24253A",diffRemoved:"#FF5555",diffRemovedBackground:"#2D1F27",lineNumber:"#3B3D55",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#F8F8F2",heading2:"#F8F8F2",heading3:"#F8F8F2",heading4:"#F8F8F2",link:"#8BE9FD",linkHover:"#BD93F9",inlineCode:"#4aeb72",inlineCodeBackground:"#202132",blockquote:"#FFB86C",blockquoteBorder:"#2D2F3C",listMarker:"#BD93F999"},chat:{userMessage:"#F8F8F2",userMessageBackground:"#222436",assistantMessage:"#F8F8F2",assistantMessageBackground:"#14151F",timestamp:"#B6B9E4",divider:"#2D2F3C"},tools:{background:"#18192680",border:"#494c6180",headerHover:"#191A26",icon:"#B6B9E4",title:"#F8F8F2",description:"#B6B9E4",edit:{added:"#50FA7B",addedBackground:"#50FA7B25",removed:"#FF5555",removedBackground:"#FF555525",lineNumber:"#3B3D55"}}},eg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},tg={metadata:Qm,colors:Zm,config:eg},rg={id:"dracula-light",name:"Dracula",description:"Dracula",version:"1.0.0",variant:"light",tags:["light","palette"]},og={primary:{base:"#7C6BF5",hover:"#9587F4",active:"#6A5CD2",foreground:"#F8F8F2",muted:"#7C6BF580",emphasis:"#9587F4"},surface:{background:"#F8F8F2",foreground:"#1F1F2F",muted:"#eff1eb",mutedForeground:"#6c6c7a",elevated:"#eeeee5",elevatedForeground:"#1F1F2F",overlay:"#05040C20",subtle:"#edeee7"},interactive:{border:"#E2E3DA",borderHover:"#D8D9D0",borderFocus:"#B0B2A7",selection:"#c2bcea63",selectionForeground:"#05040C",focus:"#7C6BF5",focusRing:"#7C6BF540",cursor:"#05040C",hover:"#c2bcea38",active:"#c2bcea63"},status:{error:"#D9536F",errorForeground:"#F8F8F2",errorBackground:"#D9536F20",errorBorder:"#D9536F50",warning:"#F7A14D",warningForeground:"#F8F8F2",warningBackground:"#F7A14D20",warningBorder:"#F7A14D50",success:"#2FBF71",successForeground:"#F8F8F2",successBackground:"#2FBF7120",successBorder:"#2FBF7150",info:"#1D7FC5",infoForeground:"#F8F8F2",infoBackground:"#1D7FC520",infoBorder:"#1D7FC550"},pr:{open:"#2FBF71",draft:"#52526B",blocked:"#F7A14D",merged:"#7C6BF5",closed:"#D9536F"},syntax:{base:{background:"#F1F2ED",foreground:"#1F1F2F",comment:"#52526B",keyword:"#7C6BF5",string:"#2FBF71",number:"#D16090",function:"#7C6BF5",variable:"#1F1F2F",type:"#F7A14D",operator:"#D16090"},tokens:{boolean:"#F7A14D",class:"#7C6BF5",className:"#7C6BF5",commentDoc:"#A5A5AF",constant:"#1D7FC5",decorator:"#F7A14D",enum:"#7C6BF5",exception:"#D16090",functionCall:"#7C6BF5",interface:"#F7A14D",jsxTag:"#7C6BF5",key:"#7C6BF5",keywordImport:"#D16090",label:"#D16090",macro:"#1D7FC5",method:"#2FBF71",module:"#D16090",namespace:"#F7A14D",parameter:"#1F1F2F",preprocessor:"#D16090",punctuation:"#52526B",regex:"#2FBF71",storageModifier:"#1D7FC5",stringEscape:"#05040C",struct:"#7C6BF5",tag:"#7C6BF5",tagAttribute:"#F7A14D",tagAttributeValue:"#2FBF71",typeParameter:"#F7A14D",url:"#1D7FC5",variableGlobal:"#7C6BF5",variableLocal:"#F6F6F1",variableOther:"#2FBF71",variableProperty:"#1D7FC5"},highlights:{diffAdded:"#2FBF71",diffAddedBackground:"#E4F5E6",diffModified:"#1D7FC5",diffModifiedBackground:"#DEDFE9",diffRemoved:"#D9536F",diffRemovedBackground:"#FAE4EB",lineNumber:"#C4C6BC",lineNumberActive:"#05040C"}},markdown:{heading1:"#1F1F2F",heading2:"#1F1F2F",heading3:"#1F1F2F",heading4:"#1F1F2F",link:"#1D7FC5",linkHover:"#7C6BF5",inlineCode:"#2FBF71",inlineCodeBackground:"#F1F2ED",blockquote:"#F7A14D",blockquoteBorder:"#E2E3DA",listMarker:"#7C6BF599"},chat:{userMessage:"#1F1F2F",userMessageBackground:"#F1F2ED",assistantMessage:"#1F1F2F",assistantMessageBackground:"#F8F8F2",timestamp:"#52526B",divider:"#E2E3DA"},tools:{background:"#F1F2ED80",border:"#E2E3DA80",headerHover:"#F2F2EC",icon:"#52526B",title:"#1F1F2F",description:"#52526B",edit:{added:"#2FBF71",addedBackground:"#2FBF7125",removed:"#D9536F",removedBackground:"#D9536F25",lineNumber:"#C4C6BC"}}},ng={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},ag={metadata:rg,colors:og,config:ng},sg={id:"gruvbox-dark",name:"Gruvbox",description:"Gruvbox",version:"1.0.0",variant:"dark",tags:["dark","palette"]},ig={primary:{base:"#83A598",hover:"#759287",active:"#95B09F",foreground:"#282828",muted:"#83A59880",emphasis:"#759287"},surface:{background:"#282828",foreground:"#EBDBB2",muted:"#32302F",mutedForeground:"#918574",elevated:"#25292b",elevatedForeground:"#EBDBB2",overlay:"#FBF1C720",subtle:"#343230"},interactive:{border:"#453f3b",borderHover:"#5A524B",borderFocus:"#7C6F64",selection:"#5a5647db",selectionForeground:"#FBF1C7",focus:"#83A598",focusRing:"#83A59840",cursor:"#FBF1C7",hover:"#5a5647d9",active:"#5a5647ec"},status:{error:"#FB4934",errorForeground:"#282828",errorBackground:"#FB493420",errorBorder:"#FB493450",warning:"#FABD2F",warningForeground:"#282828",warningBackground:"#FABD2F20",warningBorder:"#FABD2F50",success:"#B8BB26",successForeground:"#282828",successBackground:"#B8BB2620",successBorder:"#B8BB2650",info:"#D3869B",infoForeground:"#282828",infoBackground:"#D3869B20",infoBorder:"#D3869B50"},pr:{open:"#B8BB26",draft:"#A89984",blocked:"#FABD2F",merged:"#8973a8",closed:"#FB4934"},syntax:{base:{background:"#32302F",foreground:"#EBDBB2",comment:"#A89984",keyword:"#83A598",string:"#B8BB26",number:"#FB4934",function:"#83A598",variable:"#EBDBB2",type:"#FABD2F",operator:"#FB4934"},tokens:{boolean:"#FABD2F",class:"#83A598",className:"#83A598",commentDoc:"#958876",constant:"#D3869B",decorator:"#FABD2F",enum:"#83A598",exception:"#FB4934",functionCall:"#83A598",interface:"#FABD2F",jsxTag:"#83A598",key:"#83A598",keywordImport:"#FB4934",label:"#FB4934",macro:"#8EC07C",method:"#B8BB26",module:"#FB4934",namespace:"#FABD2F",parameter:"#EBDBB2",preprocessor:"#FB4934",punctuation:"#A89984",regex:"#B8BB26",storageModifier:"#8EC07C",stringEscape:"#FBF1C7",struct:"#83A598",tag:"#83A598",tagAttribute:"#FABD2F",tagAttributeValue:"#B8BB26",typeParameter:"#FABD2F",url:"#8EC07C",variableGlobal:"#83A598",variableLocal:"#1D2021",variableOther:"#B8BB26",variableProperty:"#D3869B"},highlights:{diffAdded:"#B8BB26",diffAddedBackground:"#2A3325",diffModified:"#D3869B",diffModifiedBackground:"#32302F",diffRemoved:"#FB4934",diffRemovedBackground:"#3C2222",lineNumber:"#70665D",lineNumberActive:"#FBF1C7"}},markdown:{heading1:"#EBDBB2",heading2:"#EBDBB2",heading3:"#EBDBB2",heading4:"#EBDBB2",link:"#8EC07C",linkHover:"#83A598",inlineCode:"#B8BB26",inlineCodeBackground:"#32302F",blockquote:"#928374",blockquoteBorder:"#504945",listMarker:"#83A59899"},chat:{userMessage:"#EBDBB2",userMessageBackground:"#3e3c3a",assistantMessage:"#EBDBB2",assistantMessageBackground:"#282828",timestamp:"#A89984",divider:"#504945"},tools:{background:"#32302F80",border:"#6e645e80",headerHover:"#141617",icon:"#A89984",title:"#EBDBB2",description:"#A89984",edit:{added:"#B8BB26",addedBackground:"#B8BB2625",removed:"#FB4934",removedBackground:"#FB493425",lineNumber:"#70665D"}}},cg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},dg={metadata:sg,colors:ig,config:cg},lg={id:"gruvbox-light",name:"Gruvbox",description:"Gruvbox",version:"1.0.0",variant:"light",tags:["light","palette"]},ug={primary:{base:"#076678",hover:"#388288",active:"#0C5D6C",foreground:"#FBF1C7",muted:"#07667880",emphasis:"#388288"},surface:{background:"#f8f1d5",foreground:"#3C3836",muted:"#F2E5BC",mutedForeground:"#7C6F64",elevated:"#efebcd",elevatedForeground:"#3C3836",overlay:"#28282820",subtle:"#f3efde"},interactive:{border:"#e8d7b7",borderHover:"#C9B897",borderFocus:"#A89984",selection:"#f1eaeaec",selectionForeground:"#282828",focus:"#076678",focusRing:"#07667840",cursor:"#282828",hover:"#fffdfdb3",active:"#f1eaeaec"},status:{error:"#9D0006",errorForeground:"#FBF1C7",errorBackground:"#9D000620",errorBorder:"#9D000650",warning:"#B57614",warningForeground:"#FBF1C7",warningBackground:"#B5761420",warningBorder:"#B5761450",success:"#79740E",successForeground:"#FBF1C7",successBackground:"#79740E20",successBorder:"#79740E50",info:"#8F3F71",infoForeground:"#FBF1C7",infoBackground:"#8F3F7120",infoBorder:"#8F3F7150"},pr:{open:"#79740E",draft:"#7C6F64",blocked:"#B57614",merged:"#5e4c76",closed:"#9D0006"},syntax:{base:{background:"#F2E5BC",foreground:"#3C3836",comment:"#7C6F64",keyword:"#076678",string:"#79740E",number:"#9D0006",function:"#076678",variable:"#3C3836",type:"#B57614",operator:"#9D0006"},tokens:{boolean:"#B57614",class:"#076678",className:"#076678",commentDoc:"#BCB096",constant:"#8F3F71",decorator:"#B57614",enum:"#076678",exception:"#9D0006",functionCall:"#076678",interface:"#B57614",jsxTag:"#076678",key:"#076678",keywordImport:"#9D0006",label:"#9D0006",macro:"#427B58",method:"#79740E",module:"#9D0006",namespace:"#B57614",parameter:"#3C3836",preprocessor:"#9D0006",punctuation:"#7C6F64",regex:"#79740E",storageModifier:"#427B58",stringEscape:"#282828",struct:"#076678",tag:"#076678",tagAttribute:"#B57614",tagAttributeValue:"#79740E",typeParameter:"#B57614",url:"#427B58",variableGlobal:"#076678",variableLocal:"#F9F5D7",variableOther:"#79740E",variableProperty:"#8F3F71"},highlights:{diffAdded:"#79740E",diffAddedBackground:"#DDE3B1",diffModified:"#8F3F71",diffModifiedBackground:"#EBDFB5",diffRemoved:"#9D0006",diffRemovedBackground:"#E8C7C3",lineNumber:"#B0A285",lineNumberActive:"#282828"}},markdown:{heading1:"#3C3836",heading2:"#3C3836",heading3:"#3C3836",heading4:"#3C3836",link:"#427B58",linkHover:"#076678",inlineCode:"#79740E",inlineCodeBackground:"#F2E5BC",blockquote:"#928374",blockquoteBorder:"#D5C4A1",listMarker:"#07667899"},chat:{userMessage:"#3C3836",userMessageBackground:"#FDF9E8",assistantMessage:"#3C3836",assistantMessageBackground:"#FBF1C7",timestamp:"#7C6F64",divider:"#D5C4A1"},tools:{background:"#F2E5BC80",border:"#a6997e80",headerHover:"#FDF9E8",icon:"#7C6F64",title:"#3C3836",description:"#7C6F64",edit:{added:"#79740E",addedBackground:"#79740E25",removed:"#9D0006",removedBackground:"#9D000625",lineNumber:"#B0A285"}}},fg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},mg={metadata:lg,colors:ug,config:fg},gg={id:"jetbrains-dark",name:"JetBrains",description:"JetBrains IDE-inspired colors for PiChamber - dark variant",author:"Artem Evsevev, adapted for PiChamber",version:"1.0.0",variant:"dark",tags:["dark","jetbrains","ide","blue"]},pg={primary:{base:"#6796f5",hover:"#70AEFF",active:"#5594FA",foreground:"#1E1F22",muted:"#6796f580",emphasis:"#70AEFF"},surface:{background:"#1E1F22",foreground:"#DFE1E5",muted:"#26282B",mutedForeground:"#9fa0a2",elevated:"#2B2D30",elevatedForeground:"#DFE1E5",overlay:"#00000080",subtle:"#28292c"},interactive:{border:"#383a3f",borderHover:"#4B5059",borderFocus:"#6796f5",selection:"#43454A",selectionForeground:"#DFE1E5",focus:"#6796f5",focusRing:"#6796f550",cursor:"#CED0D6",hover:"#3C3E41",active:"#494A4D"},status:{error:"#FA6675",errorForeground:"#1E1F22",errorBackground:"#402929",errorBorder:"#FA6675",warning:"#F2C55C",warningForeground:"#1E1F22",warningBackground:"#665014",warningBorder:"#F2C55C",success:"#57965D",successForeground:"#1E1F22",successBackground:"#253627",successBorder:"#57965D",info:"#3592C4",infoForeground:"#1E1F22",infoBackground:"#243846",infoBorder:"#3592C4"},pr:{open:"#5FAD65",draft:"#868A91",blocked:"#F2C55C",merged:"#A571E6",closed:"#DB5C5C"},syntax:{base:{background:"#1E1F22",foreground:"#BCBEC4",comment:"#7A7E85",keyword:"#CF8E6D",string:"#6AAB73",number:"#2AACB8",function:"#6AA2D7",variable:"#BCBEC4",type:"#A6BB77",operator:"#BCBEC4"},tokens:{commentDoc:"#5F826B",stringEscape:"#CF8E6D",keywordImport:"#CF8E6D",storageModifier:"#CF8E6D",functionCall:"#6AA2D7",method:"#6AA2D7",functionBuiltin:"#D5A563",variableProperty:"#C77DBB",variableOther:"#BCBEC4",variableGlobal:"#E59EAE",variableLocal:"#BCBEC4",parameter:"#3CACAC",constant:"#C77DBB",class:"#57AAF7",className:"#57AAF7",interface:"#8D91DC",struct:"#A6BB77",enum:"#A6BB77",typeParameter:"#3CACAC",namespace:"#BCBEC4",module:"#8D91DC",tag:"#D5B778",jsxTag:"#D5B778",tagAttribute:"#B3AE60",tagAttributeValue:"#6AAB73",boolean:"#CF8E6D",decorator:"#B3AE60",label:"#D5A563",punctuation:"#BCBEC4",macro:"#D5A563",preprocessor:"#D5A563",regex:"#6AAB73",url:"#57AAF7",key:"#C77DBB",exception:"#E59EAE"},highlights:{diffAdded:"#549159",diffAddedBackground:"#294436",diffRemoved:"#F75464",diffRemovedBackground:"#45302B",diffModified:"#70AEFF",diffModifiedBackground:"#243C63",lineNumber:"#4B5059",lineNumberActive:"#A1A3AB"}},markdown:{heading1:"#FFFFFF",heading2:"#DFE1E5",heading3:"#CED0D6",heading4:"#BCBEC4",link:"#56A8F5",linkHover:"#6796f5",inlineCode:"#6AAB73",inlineCodeBackground:"#26282B",blockquote:"#7A7E85",blockquoteBorder:"#393B41",listMarker:"#B3AE6099"},chat:{userMessage:"#DFE1E5",userMessageBackground:"#2a3b5d76",assistantMessage:"#DFE1E5",assistantMessageBackground:"#1E1F22",timestamp:"#7A7E85",divider:"#393B41"},tools:{background:"#26282B50",border:"#393B41",headerHover:"#3C3E4150",icon:"#B0B1B3",title:"#DFE1E5",description:"#B0B1B3",edit:{added:"#549159",addedBackground:"#29443640",removed:"#F75464",removedBackground:"#45302B40",lineNumber:"#4B5059"}}},hg={fonts:{sans:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Fg={metadata:gg,colors:pg,config:hg},yg={id:"jetbrains-light",name:"JetBrains",description:"JetBrains IDE-inspired colors for PiChamber - light variant",author:"Artem Evsevev, adapted for PiChamber",version:"1.0.0",variant:"light",tags:["light","jetbrains","ide","blue"]},bg={primary:{base:"#195ce3",hover:"#2D61F0",active:"#0055FF",foreground:"#FFFFFF",muted:"#3573F080",emphasis:"#006DCC"},surface:{background:"#FFF",foreground:"#000000",muted:"#F7F8FA",mutedForeground:"#404040",elevated:"#FFFFFF",elevatedForeground:"#000000",overlay:"#00000025",subtle:"#f5f8fd"},interactive:{border:"#dde0ea",borderHover:"#AEB3C2",borderFocus:"#0055FF",selection:"#DFE1E5",selectionForeground:"#000000",focus:"#0055FF",focusRing:"#0055FF40",cursor:"#000000",hover:"#E6E6E8",active:"#DBDCDE"},status:{error:"#CE0606",errorForeground:"#FFFFFF",errorBackground:"#FFE8E8",errorBorder:"#CF5B56",warning:"#F49810",warningForeground:"#000000",warningBackground:"#FFF8DC",warningBorder:"#F49810",success:"#077D18",successForeground:"#FFFFFF",successBackground:"#E9F5E6",successBorder:"#55A76A",info:"#389FD6",infoForeground:"#000000",infoBackground:"#E7F4FB",infoBorder:"#389FD6"},pr:{open:"#369650",draft:"#808080",blocked:"#F49810",merged:"#834DF0",closed:"#E55765"},syntax:{base:{background:"#FFFFFF",foreground:"#080808",comment:"#8C8C8C",keyword:"#0033B3",string:"#067D17",number:"#1750EB",function:"#00627A",variable:"#000000",type:"#A04908",operator:"#080808"},tokens:{commentDoc:"#8C8C8C",stringEscape:"#0037A6",keywordImport:"#0033B3",storageModifier:"#0033B3",functionCall:"#00627A",method:"#00627A",functionBuiltin:"#C27203",variableProperty:"#871094",variableOther:"#000000",variableGlobal:"#1C5DFE",variableLocal:"#000000",parameter:"#007E8A",constant:"#871094",class:"#00627A",className:"#00627A",interface:"#835DDA",struct:"#A04908",enum:"#A04908",typeParameter:"#007E8A",namespace:"#000000",module:"#835DDA",tag:"#0033B3",jsxTag:"#0033B3",tagAttribute:"#9E880D",tagAttributeValue:"#067D17",boolean:"#0033B3",decorator:"#9E880D",label:"#C27203",punctuation:"#080808",macro:"#C27203",preprocessor:"#C27203",regex:"#067D17",url:"#00627A",key:"#871094",exception:"#1C5DFE"},highlights:{diffAdded:"#077D18",diffAddedBackground:"#BEE6BE",diffRemoved:"#FF0000",diffRemovedBackground:"#FFD5CC",diffModified:"#0133B3",diffModifiedBackground:"#DDE8FF",lineNumber:"#AEB3C2",lineNumberActive:"#767A8A"}},markdown:{heading1:"#000000",heading2:"#161617",heading3:"#404040",heading4:"#404040",link:"#006DCC",linkHover:"#3573F0",inlineCode:"#067D17",inlineCodeBackground:"#F5F7F9",blockquote:"#8C8C8C",blockquoteBorder:"#C9CCD6",listMarker:"#9E880D99"},chat:{userMessage:"#000000",userMessageBackground:"#eff4fd",assistantMessage:"#000000",assistantMessageBackground:"#F7F8FA",timestamp:"#767A8A",divider:"#C9CCD6"},tools:{background:"#F5F7F950",border:"#AEB3C280",headerHover:"#E6E6E8",icon:"#404040",title:"#000000",description:"#404040",edit:{added:"#077D18",addedBackground:"#BEE6BE50",removed:"#FF0000",removedBackground:"#FFD5CC50",lineNumber:"#AEB3C2"}}},Ag={fonts:{sans:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Eg={metadata:yg,colors:bg,config:Ag},wg={id:"kanagawa-dark",name:"Kanagawa",description:"A color scheme inspired by Japanese art and ink painting - dark variant",version:"1.0.0",variant:"dark",tags:["dark","japanese","ink","elegant"]},Bg={primary:{base:"#7FB4CA",hover:"#9DC5E0",active:"#658594",foreground:"#1F1F28",muted:"#7FB4CA80",emphasis:"#7E9CD8"},surface:{background:"#1F1F28",foreground:"#DCD7BA",muted:"#23232d",mutedForeground:"#8b8b85",elevated:"#2A2A37",elevatedForeground:"#DCD7BA",overlay:"#16161DCC",subtle:"#2a2a36"},interactive:{border:"#333343",borderHover:"#54546D",borderFocus:"#7FB4CA",selection:"#729fb333",selectionForeground:"#DCD7BA",focus:"#7FB4CA",focusRing:"#7FB4CA50",cursor:"#DCD7BA",hover:"#363646",active:"#54546D"},status:{error:"#E82424",errorForeground:"#DCD7BA",errorBackground:"#E8242420",errorBorder:"#E8242450",warning:"#FF9E3B",warningForeground:"#1F1F28",warningBackground:"#FF9E3B20",warningBorder:"#FF9E3B50",success:"#98BB6C",successForeground:"#1F1F28",successBackground:"#98BB6C20",successBorder:"#98BB6C50",info:"#7E9CD8",infoForeground:"#1F1F28",infoBackground:"#7E9CD820",infoBorder:"#7E9CD850"},pr:{open:"#98BB6C",draft:"#54546D",blocked:"#FF9E3B",merged:"#957FB8",closed:"#E82424"},syntax:{base:{background:"#16161D",foreground:"#DCD7BA",comment:"#54546D",keyword:"#7E9CD8",string:"#98BB6C",number:"#FF9E3B",function:"#E6C384",variable:"#DCD7BA",type:"#C8C093",operator:"#C34043"},tokens:{commentDoc:"#727169",stringEscape:"#DCD7BA",keywordImport:"#957FB8",storageModifier:"#7E9CD8",functionCall:"#E6C384",method:"#76946A",variableProperty:"#7E9CD8",variableOther:"#76946A",variableGlobal:"#D27E99",variableLocal:"#2A2A37",parameter:"#DCD7BA",constant:"#DCD7BA",class:"#E6C384",className:"#E6C384",interface:"#C8C093",struct:"#E6C384",enum:"#E6C384",typeParameter:"#E6C384",namespace:"#C8C093",module:"#C34043",tag:"#7E9CD8",jsxTag:"#D27E99",tagAttribute:"#C8C093",tagAttributeValue:"#98BB6C",boolean:"#C8C093",decorator:"#C8C093",label:"#D27E99",punctuation:"#54546D",macro:"#7E9CD8",preprocessor:"#D27E99",regex:"#98BB6C",url:"#7E9CD8",key:"#E6C384",exception:"#D27E99"},highlights:{diffAdded:"#98BB6C",diffAddedBackground:"#76946A20",diffRemoved:"#C34043",diffRemovedBackground:"#E8242420",diffModified:"#7E9CD8",diffModifiedBackground:"#7E9CD820",lineNumber:"#363646",lineNumberActive:"#DCD7BA"}},markdown:{heading1:"#DCD7BA",heading2:"#DCD7BA",heading3:"#DCD7BA",heading4:"#DCD7BA",link:"#7FB4CA",linkHover:"#7E9CD8",inlineCode:"#98BB6C",inlineCodeBackground:"#16161D",blockquote:"#54546D",blockquoteBorder:"#363646",listMarker:"#FF9E3B99"},chat:{userMessage:"#DCD7BA",userMessageBackground:"#2A2A37",assistantMessage:"#DCD7BA",assistantMessageBackground:"#2f2f3d",timestamp:"#54546D",divider:"#363646"},tools:{background:"#16161D50",border:"#4a4a5f80",headerHover:"#36364650",icon:"#afad9c",title:"#DCD7BA",description:"#818182",edit:{added:"#98BB6C",addedBackground:"#98BB6C25",removed:"#C34043",removedBackground:"#C3404325",lineNumber:"#56566d"}}},Cg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},vg={metadata:wg,colors:Bg,config:Cg},kg={id:"kanagawa-light",name:"Kanagawa",description:"A color scheme inspired by Japanese art and ink painting - light variant (Lotus)",version:"1.0.0",variant:"light",tags:["light","japanese","lotus","elegant"]},Dg={primary:{base:"#4D699B",hover:"#6693BF",active:"#5D57A3",foreground:"#f6f3d6",muted:"#4D699B80",emphasis:"#6693BF"},surface:{background:"#f6f3d6",foreground:"#545464",muted:"#ece6c8",mutedForeground:"#6c6c67",elevated:"#eae4bf",elevatedForeground:"#545464",overlay:"#54546433",subtle:"#e6f0e3"},interactive:{border:"#d7d1ba",borderHover:"#8A8980",borderFocus:"#4D699B",selection:"#e9f3e5cf",selectionForeground:"#545464",focus:"#4D699B",focusRing:"#4D699B40",cursor:"#545464",hover:"#e9f3e5a9",active:"#e9f3e5cf"},status:{error:"#E82424",errorForeground:"#f6f3d6",errorBackground:"#E8242420",errorBorder:"#E8242450",warning:"#DE9800",warningForeground:"#545464",warningBackground:"#DE980020",warningBorder:"#DE980050",success:"#6F894E",successForeground:"#f6f3d6",successBackground:"#98BB6C20",successBorder:"#6F894E50",info:"#4D699B",infoForeground:"#f6f3d6",infoBackground:"#6693BF20",infoBorder:"#4D699B50"},pr:{open:"#6F894E",draft:"#716E61",blocked:"#DE9800",merged:"#624C83",closed:"#E82424"},syntax:{base:{background:"#DCD5AC",foreground:"#545464",comment:"#716E61",keyword:"#4D699B",string:"#6F894E",number:"#836F4A",function:"#CC6D00",variable:"#545464",type:"#77713F",operator:"#C84053"},tokens:{commentDoc:"#8A8980",stringEscape:"#545464",keywordImport:"#624C83",storageModifier:"#4D699B",functionCall:"#CC6D00",method:"#6E915F",variableProperty:"#4D699B",variableOther:"#6E915F",variableGlobal:"#B35B79",variableLocal:"#D5CEA3",parameter:"#545464",constant:"#545464",class:"#CC6D00",className:"#CC6D00",interface:"#77713F",struct:"#CC6D00",enum:"#CC6D00",typeParameter:"#CC6D00",namespace:"#77713F",module:"#C84053",tag:"#4D699B",jsxTag:"#B35B79",tagAttribute:"#77713F",tagAttributeValue:"#6F894E",boolean:"#77713F",decorator:"#77713F",label:"#B35B79",punctuation:"#716E61",macro:"#4D699B",preprocessor:"#B35B79",regex:"#6F894E",url:"#4D699B",key:"#CC6D00",exception:"#B35B79"},highlights:{diffAdded:"#6F894E",diffAddedBackground:"#6F894E20",diffRemoved:"#C84053",diffRemovedBackground:"#C8405320",diffModified:"#4D699B",diffModifiedBackground:"#4D699B20",lineNumber:"#8A8980",lineNumberActive:"#545464"}},markdown:{heading1:"#545464",heading2:"#545464",heading3:"#545464",heading4:"#545464",link:"#5D57A3",linkHover:"#4D699B",inlineCode:"#6F894E",inlineCodeBackground:"#e7e2c7",blockquote:"#716E61",blockquoteBorder:"#716E61",listMarker:"#836F4A99"},chat:{userMessage:"#545464",userMessageBackground:"#e6f2e1",assistantMessage:"#545464",assistantMessageBackground:"#f6f3d6",timestamp:"#716E61",divider:"#716E61"},tools:{background:"#DCD5AC50",border:"#716E6180",headerHover:"#716E61",icon:"#8A8980",title:"#545464",description:"#8A8980",edit:{added:"#6F894E",addedBackground:"#6F894E25",removed:"#C84053",removedBackground:"#C8405325",lineNumber:"#8A8980"}}},Sg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Mg={metadata:kg,colors:Dg,config:Sg},Tg={id:"monokai-dark",name:"Monokai",description:"Monokai",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Pg={primary:{base:"#AE81FF",hover:"#9973DD",active:"#BA94FF",foreground:"#23241E",muted:"#AE81FF80",emphasis:"#9973DD"},surface:{background:"#23241E",foreground:"#F8F8F2",muted:"#282a20",mutedForeground:"#939390",elevated:"#21221a",elevatedForeground:"#F8F8F2",overlay:"#FFFFFF20",subtle:"#303126"},interactive:{border:"#343528",borderHover:"#393A2D",borderFocus:"#555741",selection:"#434d3cfe",selectionForeground:"#FFFFFF",focus:"#AE81FF",focusRing:"#AE81FF40",cursor:"#FFFFFF",hover:"#36372a",active:"#36382e"},status:{error:"#F92672",errorForeground:"#23241E",errorBackground:"#F9267220",errorBorder:"#F9267250",warning:"#FD971F",warningForeground:"#23241E",warningBackground:"#FD971F20",warningBorder:"#FD971F50",success:"#A6E22E",successForeground:"#23241E",successBackground:"#A6E22E20",successBorder:"#A6E22E50",info:"#66D9EF",infoForeground:"#23241E",infoBackground:"#66D9EF20",infoBorder:"#66D9EF50"},pr:{open:"#A6E22E",draft:"#C5C5C0",blocked:"#FD971F",merged:"#AE81FF",closed:"#F92672"},syntax:{base:{background:"#27281F",foreground:"#F8F8F2",comment:"#C5C5C0",keyword:"#AE81FF",string:"#A6E22E",number:"#F92672",function:"#AE81FF",variable:"#F8F8F2",type:"#FD971F",operator:"#F92672"},tokens:{boolean:"#FD971F",class:"#AE81FF",className:"#AE81FF",commentDoc:"#ADADA8",constant:"#66D9EF",decorator:"#FD971F",enum:"#AE81FF",exception:"#F92672",functionCall:"#AE81FF",interface:"#FD971F",jsxTag:"#AE81FF",key:"#AE81FF",keywordImport:"#F92672",label:"#F92672",macro:"#66D9EF",method:"#A6E22E",module:"#F92672",namespace:"#FD971F",parameter:"#F8F8F2",preprocessor:"#F92672",punctuation:"#C5C5C0",regex:"#A6E22E",storageModifier:"#66D9EF",stringEscape:"#FFFFFF",struct:"#AE81FF",tag:"#AE81FF",tagAttribute:"#FD971F",tagAttributeValue:"#A6E22E",typeParameter:"#FD971F",url:"#66D9EF",variableGlobal:"#AE81FF",variableLocal:"#25261F",variableOther:"#A6E22E",variableProperty:"#66D9EF"},highlights:{diffAdded:"#A6E22E",diffAddedBackground:"#1E2A1D",diffModified:"#66D9EF",diffModifiedBackground:"#2F2F24",diffRemoved:"#F92672",diffRemovedBackground:"#301C24",lineNumber:"#454639",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#F8F8F2",heading2:"#F8F8F2",heading3:"#F8F8F2",heading4:"#F8F8F2",link:"#66D9EF",linkHover:"#AE81FF",inlineCode:"#A6E22E",inlineCodeBackground:"#27281F",blockquote:"#FD971F",blockquoteBorder:"#343528",listMarker:"#AE81FF99"},chat:{userMessage:"#F8F8F2",userMessageBackground:"#36372a",assistantMessage:"#F8F8F2",assistantMessageBackground:"#23241E",timestamp:"#C5C5C0",divider:"#343528"},tools:{background:"#27281F80",border:"#4d4f3c80",headerHover:"#292A23",icon:"#C5C5C0",title:"#F8F8F2",description:"#C5C5C0",edit:{added:"#A6E22E",addedBackground:"#A6E22E25",removed:"#bd215a",removedBackground:"#F9267225",lineNumber:"#505142"}}},Rg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Ig={metadata:Tg,colors:Pg,config:Rg},_g={id:"monokai-light",name:"Monokai",description:"Monokai",version:"1.0.0",variant:"light",tags:["light","palette"]},xg={primary:{base:"#BF7BFF",hover:"#CB94FB",active:"#A76CDB",foreground:"#FDF8EC",muted:"#BF7BFF80",emphasis:"#CB94FB"},surface:{background:"#FDF8EC",foreground:"#292318",muted:"#F8F2E6",mutedForeground:"#887c6a",elevated:"#FBF5E8",elevatedForeground:"#292318",overlay:"#1C150C20",subtle:"#F7EFDD"},interactive:{border:"#E9E0CF",borderHover:"#DFD5C3",borderFocus:"#B6A893",selection:"#1C150C22",selectionForeground:"#1C150C",focus:"#BF7BFF",focusRing:"#BF7BFF40",cursor:"#1C150C",hover:"#e6e0d5",active:"#FBF5E8"},status:{error:"#E54B4B",errorForeground:"#FDF8EC",errorBackground:"#E54B4B20",errorBorder:"#E54B4B50",warning:"#F1A948",warningForeground:"#FDF8EC",warningBackground:"#F1A94820",warningBorder:"#F1A94850",success:"#4FB54B",successForeground:"#FDF8EC",successBackground:"#4FB54B20",successBorder:"#4FB54B50",info:"#2D9AD7",infoForeground:"#FDF8EC",infoBackground:"#2D9AD720",infoBorder:"#2D9AD750"},pr:{open:"#4FB54B",draft:"#6D5C40",blocked:"#F1A948",merged:"#BF7BFF",closed:"#E54B4B"},syntax:{base:{background:"#F8F2E6",foreground:"#292318",comment:"#6D5C40",keyword:"#BF7BFF",string:"#4FB54B",number:"#D9487C",function:"#BF7BFF",variable:"#292318",type:"#F1A948",operator:"#D9487C"},tokens:{boolean:"#F1A948",class:"#BF7BFF",className:"#BF7BFF",commentDoc:"#B5AA96",constant:"#2D9AD7",decorator:"#F1A948",enum:"#BF7BFF",exception:"#D9487C",functionCall:"#BF7BFF",interface:"#F1A948",jsxTag:"#BF7BFF",key:"#BF7BFF",keywordImport:"#D9487C",label:"#D9487C",macro:"#2D9AD7",method:"#4FB54B",module:"#D9487C",namespace:"#F1A948",parameter:"#292318",preprocessor:"#D9487C",punctuation:"#6D5C40",regex:"#4FB54B",storageModifier:"#2D9AD7",stringEscape:"#1C150C",struct:"#BF7BFF",tag:"#BF7BFF",tagAttribute:"#F1A948",tagAttributeValue:"#4FB54B",typeParameter:"#F1A948",url:"#2D9AD7",variableGlobal:"#BF7BFF",variableLocal:"#FBF5E8",variableOther:"#4FB54B",variableProperty:"#2D9AD7"},highlights:{diffAdded:"#4FB54B",diffAddedBackground:"#E8F7E1",diffModified:"#2D9AD7",diffModifiedBackground:"#E9E0D0",diffRemoved:"#E54B4B",diffRemovedBackground:"#FDE5E4",lineNumber:"#CABFAD",lineNumberActive:"#1C150C"}},markdown:{heading1:"#292318",heading2:"#292318",heading3:"#292318",heading4:"#292318",link:"#2D9AD7",linkHover:"#BF7BFF",inlineCode:"#4FB54B",inlineCodeBackground:"#F8F2E6",blockquote:"#F1A948",blockquoteBorder:"#E9E0CF",listMarker:"#BF7BFF99"},chat:{userMessage:"#292318",userMessageBackground:"#F8F2E6",assistantMessage:"#292318",assistantMessageBackground:"#FDF8EC",timestamp:"#6D5C40",divider:"#E9E0CF"},tools:{background:"#F8F2E680",border:"#d0c8b880",headerHover:"#F7EFDD",icon:"#6D5C40",title:"#292318",description:"#6D5C40",edit:{added:"#4FB54B",addedBackground:"#4FB54B25",removed:"#E54B4B",removedBackground:"#E54B4B25",lineNumber:"#bfb5a4"}}},Og={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Ng={metadata:_g,colors:xg,config:Og},Lg={id:"nightowl-dark",name:"Night Owl",description:"Night Owl",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Ug={primary:{base:"#82AAFF",hover:"#6F94DF",active:"#95B7FF",foreground:"#011627",muted:"#82AAFF80",emphasis:"#6F94DF"},surface:{background:"#011627",foreground:"#D6DEEB",muted:"#0B253A",mutedForeground:"#7d8892",elevated:"#001122",elevatedForeground:"#D6DEEB",overlay:"#FFFFFF20",subtle:"#162431"},interactive:{border:"#2b3339",borderHover:"#234561",borderFocus:"#82AAFF",selection:"#555d6d94",selectionForeground:"#FFFFFF",focus:"#82AAFF",focusRing:"#82AAFF40",cursor:"#FFFFFF",hover:"#555d6d68",active:"#555d6d94"},status:{error:"#EF5350",errorForeground:"#011627",errorBackground:"#EF535020",errorBorder:"#EF535050",warning:"#ECC48D",warningForeground:"#011627",warningBackground:"#ECC48D20",warningBorder:"#ECC48D50",success:"#C5E478",successForeground:"#011627",successBackground:"#C5E47820",successBorder:"#C5E47850",info:"#82AAFF",infoForeground:"#011627",infoBackground:"#82AAFF20",infoBorder:"#82AAFF50"},pr:{open:"#C5E478",draft:"#5F7E97",blocked:"#ECC48D",merged:"#BC82FF",closed:"#EF5350"},syntax:{base:{background:"#0B253A",foreground:"#D6DEEB",comment:"#5F7E97",keyword:"#82AAFF",string:"#ECC48D",number:"#F78C6C",function:"#82AAFF",variable:"#D6DEEB",type:"#C5E478",operator:"#F78C6C"},tokens:{boolean:"#C5E478",class:"#82AAFF",className:"#82AAFF",commentDoc:"#516E86",constant:"#7FDBCA",decorator:"#C5E478",enum:"#82AAFF",exception:"#F78C6C",functionCall:"#82AAFF",interface:"#C5E478",jsxTag:"#82AAFF",key:"#82AAFF",keywordImport:"#F78C6C",label:"#F78C6C",macro:"#82AAFF",method:"#C5E478",module:"#F78C6C",namespace:"#C5E478",parameter:"#D6DEEB",preprocessor:"#F78C6C",punctuation:"#5F7E97",regex:"#ECC48D",storageModifier:"#82AAFF",stringEscape:"#FFFFFF",struct:"#82AAFF",tag:"#82AAFF",tagAttribute:"#C5E478",tagAttributeValue:"#ECC48D",typeParameter:"#C5E478",url:"#7FDBCA",variableGlobal:"#82AAFF",variableLocal:"#001122",variableOther:"#C5E478",variableProperty:"#7FDBCA"},highlights:{diffAdded:"#C5E478",diffAddedBackground:"#0A2E1A",diffModified:"#82AAFF",diffModifiedBackground:"#0B253A",diffRemoved:"#EF5350",diffRemovedBackground:"#2D1B1B",lineNumber:"#82AAFF",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#D6DEEB",heading2:"#D6DEEB",heading3:"#D6DEEB",heading4:"#D6DEEB",link:"#7FDBCA",linkHover:"#82AAFF",inlineCode:"#C5E478",inlineCodeBackground:"#0B253A",blockquote:"#5F7E97",blockquoteBorder:"#1D3B53",listMarker:"#82AAFF99"},chat:{userMessage:"#D6DEEB",userMessageBackground:"#0f283f",assistantMessage:"#D6DEEB",assistantMessageBackground:"#011627",timestamp:"#5F7E97",divider:"#1D3B53"},tools:{background:"#0B253A80",border:"#24496780",headerHover:"#000C17",icon:"#5F7E97",title:"#D6DEEB",description:"#5F7E97",edit:{added:"#C5E478",addedBackground:"#C5E47825",removed:"#EF5350",removedBackground:"#EF535025",lineNumber:"#58698f"}}},Hg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Kg={metadata:Lg,colors:Ug,config:Hg},jg={id:"nightowl-light",name:"Night Owl",description:"Night Owl",version:"1.0.0",variant:"light",tags:["light","palette"]},$g={primary:{base:"#4876D6",hover:"#6C91DD",active:"#4168BA",foreground:"#FBFBFB",muted:"#4876D680",emphasis:"#6C91DD"},surface:{background:"#FBFBFB",foreground:"#403F53",muted:"#F0F0F0",mutedForeground:"#747a7a",elevated:"#FFFFFF",elevatedForeground:"#403F53",overlay:"#1A1A1A20",subtle:"#F0F0F0"},interactive:{border:"#dfdfdf",borderHover:"#CCCCCC",borderFocus:"#4876D6",selection:"#706e6e22",selectionForeground:"#1A1A1A",focus:"#4876D6",focusRing:"#4876D640",cursor:"#1A1A1A",hover:"#706e6e16",active:"#706e6e22"},status:{error:"#DE3D3B",errorForeground:"#FBFBFB",errorBackground:"#DE3D3B20",errorBorder:"#DE3D3B50",warning:"#C96765",warningForeground:"#FBFBFB",warningBackground:"#C9676520",warningBorder:"#C9676550",success:"#2AA298",successForeground:"#FBFBFB",successBackground:"#2AA29820",successBorder:"#2AA29850",info:"#4876D6",infoForeground:"#FBFBFB",infoBackground:"#4876D620",infoBorder:"#4876D650"},pr:{open:"#2AA298",draft:"#7A8181",blocked:"#c98f65",merged:"#994CC3",closed:"#DE3D3B"},syntax:{base:{background:"#F0F0F0",foreground:"#403F53",comment:"#7A8181",keyword:"#4876D6",string:"#C96765",number:"#AA0982",function:"#4876D6",variable:"#403F53",type:"#994CC3",operator:"#AA0982"},tokens:{boolean:"#994CC3",class:"#4876D6",className:"#4876D6",commentDoc:"#BBBEBE",constant:"#2AA298",decorator:"#994CC3",enum:"#4876D6",exception:"#AA0982",functionCall:"#4876D6",interface:"#994CC3",jsxTag:"#4876D6",key:"#4876D6",keywordImport:"#AA0982",label:"#AA0982",macro:"#4876D6",method:"#2AA298",module:"#AA0982",namespace:"#994CC3",parameter:"#403F53",preprocessor:"#AA0982",punctuation:"#7A8181",regex:"#C96765",storageModifier:"#4876D6",stringEscape:"#1A1A1A",struct:"#4876D6",tag:"#4876D6",tagAttribute:"#994CC3",tagAttributeValue:"#C96765",typeParameter:"#994CC3",url:"#2AA298",variableGlobal:"#4876D6",variableLocal:"#FFFFFF",variableOther:"#2AA298",variableProperty:"#2AA298"},highlights:{diffAdded:"#2AA298",diffAddedBackground:"#EAF8F6",diffModified:"#4876D6",diffModifiedBackground:"#E8F0FC",diffRemoved:"#DE3D3B",diffRemovedBackground:"#FBE9E9",lineNumber:"#4876D6",lineNumberActive:"#1A1A1A"}},markdown:{heading1:"#403F53",heading2:"#403F53",heading3:"#403F53",heading4:"#403F53",link:"#2AA298",linkHover:"#4876D6",inlineCode:"#2AA298",inlineCodeBackground:"#F0F0F0",blockquote:"#7A8181",blockquoteBorder:"#D9D9D9",listMarker:"#4876D699"},chat:{userMessage:"#403F53",userMessageBackground:"#F0F0F0",assistantMessage:"#403F53",assistantMessageBackground:"#FBFBFB",timestamp:"#7A8181",divider:"#D9D9D9"},tools:{background:"#F0F0F080",border:"#D9D9D980",headerHover:"#FFFFFF",icon:"#7A8181",title:"#403F53",description:"#7A8181",edit:{added:"#2AA298",addedBackground:"#2AA29825",removed:"#DE3D3B",removedBackground:"#DE3D3B25",lineNumber:"#4876D6"}}},zg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},qg={metadata:jg,colors:$g,config:zg},Gg={id:"nord-dark",name:"Nord",description:"Nord",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Wg={primary:{base:"#88C0D0",hover:"#78A9B8",active:"#99C9D7",foreground:"#1F2430",muted:"#88C0D080",emphasis:"#78A9B8"},surface:{background:"#1F2430",foreground:"#E5E9F0",muted:"#222938",mutedForeground:"#7c828e",elevated:"#1C202A",elevatedForeground:"#E5E9F0",overlay:"#F8FAFC20",subtle:"#252c3c"},interactive:{border:"#383d49",borderHover:"#383F50",borderFocus:"#545B78",selection:"#3e4a56fe",selectionForeground:"#F8FAFC",focus:"#88C0D0",focusRing:"#88C0D040",cursor:"#F8FAFC",hover:"#3e4a5692",active:"#3e4a56fe"},status:{error:"#BF616A",errorForeground:"#1F2430",errorBackground:"#BF616A20",errorBorder:"#BF616A50",warning:"#D08770",warningForeground:"#1F2430",warningBackground:"#D0877020",warningBorder:"#D0877050",success:"#A3BE8C",successForeground:"#1F2430",successBackground:"#A3BE8C20",successBorder:"#A3BE8C50",info:"#81A1C1",infoForeground:"#1F2430",infoBackground:"#81A1C120",infoBorder:"#81A1C150"},pr:{open:"#A3BE8C",draft:"#A4ADBF",blocked:"#D08770",merged:"#b788d0",closed:"#BF616A"},syntax:{base:{background:"#222938",foreground:"#E5E9F0",comment:"#A4ADBF",keyword:"#88C0D0",string:"#A3BE8C",number:"#D57780",function:"#88C0D0",variable:"#E5E9F0",type:"#EAC196",operator:"#D57780"},tokens:{boolean:"#EAC196",class:"#88C0D0",className:"#88C0D0",commentDoc:"#9098AA",constant:"#81A1C1",decorator:"#EAC196",enum:"#88C0D0",exception:"#D57780",functionCall:"#88C0D0",interface:"#EAC196",jsxTag:"#88C0D0",key:"#88C0D0",keywordImport:"#D57780",label:"#D57780",macro:"#81A1C1",method:"#A3BE8C",module:"#D57780",namespace:"#EAC196",parameter:"#E5E9F0",preprocessor:"#D57780",punctuation:"#A4ADBF",regex:"#A3BE8C",storageModifier:"#81A1C1",stringEscape:"#F8FAFC",struct:"#88C0D0",tag:"#88C0D0",tagAttribute:"#EAC196",tagAttributeValue:"#A3BE8C",typeParameter:"#EAC196",url:"#81A1C1",variableGlobal:"#88C0D0",variableLocal:"#1C202A",variableOther:"#A3BE8C",variableProperty:"#81A1C1"},highlights:{diffAdded:"#A3BE8C",diffAddedBackground:"#1F2E33",diffModified:"#81A1C1",diffModifiedBackground:"#222B3A",diffRemoved:"#BF616A",diffRemovedBackground:"#2E212A",lineNumber:"#434A62",lineNumberActive:"#F8FAFC"}},markdown:{heading1:"#E5E9F0",heading2:"#E5E9F0",heading3:"#E5E9F0",heading4:"#E5E9F0",link:"#81A1C1",linkHover:"#88C0D0",inlineCode:"#A3BE8C",inlineCodeBackground:"#252c3c",blockquote:"#D08770",blockquoteBorder:"#343A47",listMarker:"#88C0D099"},chat:{userMessage:"#E5E9F0",userMessageBackground:"#272f40",assistantMessage:"#E5E9F0",assistantMessageBackground:"#1F2430",timestamp:"#A4ADBF",divider:"#343A47"},tools:{background:"#22293880",border:"#454e5f80",headerHover:"#181C24",icon:"#A4ADBF",title:"#E5E9F0",description:"#A4ADBF",edit:{added:"#A3BE8C",addedBackground:"#A3BE8C25",removed:"#BF616A",removedBackground:"#BF616A25",lineNumber:"#4a526b"}}},Vg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Jg={metadata:Gg,colors:Wg,config:Vg},Yg={id:"nord-light",name:"Nord",description:"Nord",version:"1.0.0",variant:"light",tags:["light","palette"]},Xg={primary:{base:"#5E81AC",hover:"#7A97BA",active:"#557399",foreground:"#ECEFF4",muted:"#5E81AC80",emphasis:"#7A97BA"},surface:{background:"#ECEFF4",foreground:"#2E3440",muted:"#E4E8F0",mutedForeground:"#6e7481",elevated:"#e7ebf5",elevatedForeground:"#2E3440",overlay:"#1F253020",subtle:"#e3e7ee"},interactive:{border:"#cfd5df",borderHover:"#C9D0DE",borderFocus:"#9CA4BA",selection:"#c6ccd881",selectionForeground:"#1F2530",focus:"#5E81AC",focusRing:"#5E81AC40",cursor:"#1F2530",hover:"#c6ccd84a",active:"#c6ccd881"},status:{error:"#BF616A",errorForeground:"#ECEFF4",errorBackground:"#BF616A20",errorBorder:"#BF616A50",warning:"#D08770",warningForeground:"#ECEFF4",warningBackground:"#D0877020",warningBorder:"#D0877050",success:"#8FBCBB",successForeground:"#ECEFF4",successBackground:"#8FBCBB20",successBorder:"#8FBCBB50",info:"#81A1C1",infoForeground:"#ECEFF4",infoBackground:"#81A1C120",infoBorder:"#81A1C150"},pr:{open:"#8FBCBB",draft:"#4C566A",blocked:"#D08770",merged:"#9b5eac",closed:"#BF616A"},syntax:{base:{background:"#E4E8F0",foreground:"#2E3440",comment:"#4C566A",keyword:"#5E81AC",string:"#A3BE8C",number:"#BF616A",function:"#5E81AC",variable:"#2E3440",type:"#D08770",operator:"#BF616A"},tokens:{boolean:"#D08770",class:"#5E81AC",className:"#5E81AC",commentDoc:"#9CA3AF",constant:"#81A1C1",decorator:"#D08770",enum:"#5E81AC",exception:"#BF616A",functionCall:"#5E81AC",interface:"#D08770",jsxTag:"#5E81AC",key:"#5E81AC",keywordImport:"#BF616A",label:"#BF616A",macro:"#81A1C1",method:"#8FBCBB",module:"#BF616A",namespace:"#D08770",parameter:"#2E3440",preprocessor:"#BF616A",punctuation:"#4C566A",regex:"#A3BE8C",storageModifier:"#81A1C1",stringEscape:"#1F2530",struct:"#5E81AC",tag:"#5E81AC",tagAttribute:"#D08770",tagAttributeValue:"#A3BE8C",typeParameter:"#D08770",url:"#81A1C1",variableGlobal:"#5E81AC",variableLocal:"#F1F3F8",variableOther:"#8FBCBB",variableProperty:"#81A1C1"},highlights:{diffAdded:"#8FBCBB",diffAddedBackground:"#E4F0E4",diffModified:"#81A1C1",diffModifiedBackground:"#DFE6F2",diffRemoved:"#BF616A",diffRemovedBackground:"#F4E1E4",lineNumber:"#B2BACC",lineNumberActive:"#1F2530"}},markdown:{heading1:"#2E3440",heading2:"#2E3440",heading3:"#2E3440",heading4:"#2E3440",link:"#81A1C1",linkHover:"#5E81AC",inlineCode:"#4f7034",inlineCodeBackground:"#E4E8F0",blockquote:"#D08770",blockquoteBorder:"#D5DBE7",listMarker:"#5E81AC99"},chat:{userMessage:"#2E3440",userMessageBackground:"#dee4f0",assistantMessage:"#2E3440",assistantMessageBackground:"#ECEFF4",timestamp:"#4C566A",divider:"#D5DBE7"},tools:{background:"#E4E8F080",border:"#b8bfcc80",headerHover:"#F6F8FC",icon:"#4C566A",title:"#2E3440",description:"#4C566A",edit:{added:"#8FBCBB",addedBackground:"#8FBCBB25",removed:"#BF616A",removedBackground:"#BF616A25",lineNumber:"#b7bfd1"}}},Qg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Zg={metadata:Yg,colors:Xg,config:Qg},ep={id:"fields-of-the-shire-dark",name:"Fields of the Shire",description:"Fields of the Shire theme - dark variant",author:"PiChamber",version:"1.0.0",variant:"dark",tags:["dark","warm","earthy","brand"]},tp={primary:{base:"#7a8a5a",hover:"#93a56b",active:"#a4b67d",foreground:"#0c0a08",muted:"#7a8a5a80",emphasis:"#93a56b"},surface:{background:"#1b1815",foreground:"#ebe0d1",muted:"#23201c",mutedForeground:"#83796f",elevated:"#2b2622",elevatedForeground:"#ebe0d1",overlay:"#1b1815cc",subtle:"#282320"},interactive:{border:"#35322f",borderHover:"#f0e6d830",borderFocus:"#373d2c",selection:"#f0e6d81f",selectionForeground:"#ebe0d1",focus:"#7a8a5a",focusRing:"#7a8a5a4d",cursor:"#ebe0d1",hover:"#332d28",active:"#f0e6d824"},status:{error:"#b34d3b",errorForeground:"#0c0a08",errorBackground:"#b85a4a20",errorBorder:"#b85a4a50",warning:"#c47a3a",warningForeground:"#0c0a08",warningBackground:"#c47a3a20",warningBorder:"#c47a3a50",success:"#7f905e",successForeground:"#0c0a08",successBackground:"#7a8a5a20",successBorder:"#7a8a5a50",info:"#667c8a",infoForeground:"#f0e6d8",infoBackground:"#5a6d7a20",infoBorder:"#5a6d7a50"},pr:{open:"#7a8a5a",draft:"#6a5e52",blocked:"#c47a3a",merged:"#5a6d7a",closed:"#b85a4a"},syntax:{base:{background:"#23201c",foreground:"#ebe0d1",comment:"#6a5e52",keyword:"#5a6d7a",string:"#93a56b",number:"#c47a3a",function:"#c47a3a",variable:"#ebe0d1",type:"#7a8a5a",operator:"#a89888"},tokens:{commentDoc:"#4a4238",stringEscape:"#ebe0d1",keywordImport:"#5a6d7a",storageModifier:"#5a6d7a",functionCall:"#c47a3a",method:"#93a56b",variableProperty:"#5a6d7a",variableOther:"#ebe0d1",variableGlobal:"#c47a3a",variableLocal:"#a89888",parameter:"#ebe0d1",constant:"#c47a3a",class:"#7a8a5a",className:"#7a8a5a",interface:"#7a8a5a",struct:"#7a8a5a",enum:"#7a8a5a",typeParameter:"#93a56b",namespace:"#5a6d7a",module:"#5a6d7a",tag:"#c47a3a",jsxTag:"#c47a3a",tagAttribute:"#93a56b",tagAttributeValue:"#93a56b",boolean:"#7a8a5a",decorator:"#5a6d7a",label:"#c47a3a",punctuation:"#a89888",macro:"#5a6d7a",preprocessor:"#5a6d7a",regex:"#93a56b",url:"#5a6d7a",key:"#c47a3a",exception:"#b85a4a"},highlights:{diffAdded:"#7a8a5a",diffAddedBackground:"#7a8a5a20",diffRemoved:"#b85a4a",diffRemovedBackground:"#b85a4a20",diffModified:"#5a6d7a",diffModifiedBackground:"#5a6d7a20",lineNumber:"#6a5e52",lineNumberActive:"#ebe0d1"}},markdown:{heading1:"#c47a3a",heading2:"#93a56b",heading3:"#ebe0d1",heading4:"#ebe0d1",link:"#5a6d7a",linkHover:"#93a56b",inlineCode:"#93a56b",inlineCodeBackground:"#23201c",blockquote:"#a89888",blockquoteBorder:"#f0e6d830",listMarker:"#c47a3a99"},chat:{userMessage:"#ebe0d1",userMessageBackground:"#272a25",assistantMessage:"#ebe0d1",assistantMessageBackground:"#1b1815",timestamp:"#6a5e52",divider:"#f0e6d81c"},tools:{background:"#23201c80",border:"#f0e6d830",headerHover:"#2a252180",icon:"#a89888",title:"#ebe0d1",description:"#a19a96",edit:{added:"#7a8a5a",addedBackground:"#7a8a5a25",removed:"#b85a4a",removedBackground:"#b85a4a25",lineNumber:"#6a5e52"}}},rp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},op={metadata:ep,colors:tp,config:rp},np={id:"fields-of-the-shire-light",name:"Fields of the Shire",description:"Fields of the Shire theme - light variant",author:"PiChamber",version:"1.0.0",variant:"light",tags:["light","warm","earthy","brand"]},ap={primary:{base:"#4a6030",hover:"#5e773f",active:"#708a50",foreground:"#faf8f5",muted:"#4a603080",emphasis:"#5e773f"},surface:{background:"#f9f5eb",foreground:"#1a1612",muted:"#f4efe3",mutedForeground:"#5a5048",elevated:"#fcf9f0",elevatedForeground:"#1a1612",overlay:"#1a161220",subtle:"#f1ece1"},interactive:{border:"#1a16121c",borderHover:"#1a161230",borderFocus:"#4a6030",selection:"#1a16121a",selectionForeground:"#1a1612",focus:"#4a6030",focusRing:"#4a603040",cursor:"#1a1612",hover:"#efe8da",active:"#1a16121f"},status:{error:"#a24d3f",errorForeground:"#faf8f5",errorBackground:"#a24d3f20",errorBorder:"#a24d3f50",warning:"#8c5520",warningForeground:"#faf8f5",warningBackground:"#8c552020",warningBorder:"#8c552050",success:"#4a6030",successForeground:"#faf8f5",successBackground:"#4a603020",successBorder:"#4a603050",info:"#3d4f5a",infoForeground:"#faf8f5",infoBackground:"#3d4f5a20",infoBorder:"#3d4f5a50"},pr:{open:"#4a6030",draft:"#8a7e72",blocked:"#8c5520",merged:"#3d4f5a",closed:"#a24d3f"},syntax:{base:{background:"#ece5d6",foreground:"#1a1612",comment:"#8a7e72",keyword:"#3d4f5a",string:"#5e773f",number:"#8c5520",function:"#8c5520",variable:"#1a1612",type:"#4a6030",operator:"#5a5048"},tokens:{commentDoc:"#b8b0a4",stringEscape:"#1a1612",keywordImport:"#3d4f5a",storageModifier:"#3d4f5a",functionCall:"#8c5520",method:"#5e773f",variableProperty:"#3d4f5a",variableOther:"#1a1612",variableGlobal:"#8c5520",variableLocal:"#5a5048",parameter:"#1a1612",constant:"#8c5520",class:"#4a6030",className:"#4a6030",interface:"#4a6030",struct:"#4a6030",enum:"#4a6030",typeParameter:"#5e773f",namespace:"#3d4f5a",module:"#3d4f5a",tag:"#8c5520",jsxTag:"#8c5520",tagAttribute:"#4a6030",tagAttributeValue:"#5e773f",boolean:"#4a6030",decorator:"#3d4f5a",label:"#8c5520",punctuation:"#5a5048",macro:"#3d4f5a",preprocessor:"#3d4f5a",regex:"#5e773f",url:"#3d4f5a",key:"#8c5520",exception:"#a24d3f"},highlights:{diffAdded:"#4a6030",diffAddedBackground:"#4a603020",diffRemoved:"#a24d3f",diffRemovedBackground:"#a24d3f20",diffModified:"#3d4f5a",diffModifiedBackground:"#3d4f5a20",lineNumber:"#8a7e72",lineNumberActive:"#1a1612"}},markdown:{heading1:"#8c5520",heading2:"#4a6030",heading3:"#1a1612",heading4:"#1a1612",link:"#3d4f5a",linkHover:"#4a6030",inlineCode:"#4a6030",inlineCodeBackground:"#ece5d6",blockquote:"#5a5048",blockquoteBorder:"#1a161230",listMarker:"#8c552099"},chat:{userMessage:"#1a1612",userMessageBackground:"#efe8da",assistantMessage:"#1a1612",assistantMessageBackground:"#f9f5eb",timestamp:"#8a7e72",divider:"#1a16121c"},tools:{background:"#f4efe380",border:"#1a161230",headerHover:"#efe8da",icon:"#5a5048",title:"#1a1612",description:"#5a5048",edit:{added:"#4a6030",addedBackground:"#4a603025",removed:"#a24d3f",removedBackground:"#a24d3f25",lineNumber:"#8a7e72"}}},sp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},ip={metadata:np,colors:ap,config:sp},cp={id:"onedarkpro-dark",name:"One Dark Pro",description:"One Dark Pro",version:"1.0.0",variant:"dark",tags:["dark","palette"]},dp={primary:{base:"#61AFEF",hover:"#579AD1",active:"#77BAF1",foreground:"#1E222A",muted:"#61AFEF80",emphasis:"#579AD1"},surface:{background:"#1E222A",foreground:"#ABB2BF",muted:"#212631",mutedForeground:"#737a89",elevated:"#232832",elevatedForeground:"#ABB2BF",overlay:"#F6F7FB20",subtle:"#272c37"},interactive:{border:"#313848",borderHover:"#363D52",borderFocus:"#555C79",selection:"#a8aec533",selectionForeground:"#F6F7FB",focus:"#61AFEF",focusRing:"#61AFEF40",cursor:"#F6F7FB",hover:"#a8aec525",active:"#a8aec533"},status:{error:"#E06C75",errorForeground:"#1E222A",errorBackground:"#E06C7520",errorBorder:"#E06C7550",warning:"#E5C07B",warningForeground:"#1E222A",warningBackground:"#E5C07B20",warningBorder:"#E5C07B50",success:"#98C379",successForeground:"#1E222A",successBackground:"#98C37920",successBorder:"#98C37950",info:"#56B6C2",infoForeground:"#1E222A",infoBackground:"#56B6C220",infoBorder:"#56B6C250"},pr:{open:"#98C379",draft:"#818899",blocked:"#E5C07B",merged:"#bb61ef",closed:"#E06C75"},syntax:{base:{background:"#212631",foreground:"#ABB2BF",comment:"#818899",keyword:"#61AFEF",string:"#98C379",number:"#E06C75",function:"#61AFEF",variable:"#ABB2BF",type:"#E5C07B",operator:"#E06C75"},tokens:{boolean:"#E5C07B",class:"#61AFEF",className:"#61AFEF",commentDoc:"#727988",constant:"#56B6C2",decorator:"#E5C07B",enum:"#61AFEF",exception:"#E06C75",functionCall:"#61AFEF",interface:"#E5C07B",jsxTag:"#61AFEF",key:"#61AFEF",keywordImport:"#E06C75",label:"#E06C75",macro:"#56B6C2",method:"#98C379",module:"#E06C75",namespace:"#E5C07B",parameter:"#ABB2BF",preprocessor:"#E06C75",punctuation:"#818899",regex:"#98C379",storageModifier:"#56B6C2",stringEscape:"#F6F7FB",struct:"#61AFEF",tag:"#61AFEF",tagAttribute:"#E5C07B",tagAttributeValue:"#98C379",typeParameter:"#E5C07B",url:"#56B6C2",variableGlobal:"#61AFEF",variableLocal:"#1B1F27",variableOther:"#98C379",variableProperty:"#56B6C2"},highlights:{diffAdded:"#98C379",diffAddedBackground:"#1C2A26",diffModified:"#56B6C2",diffModifiedBackground:"#232836",diffRemoved:"#E06C75",diffRemovedBackground:"#2A1C22",lineNumber:"#424967",lineNumberActive:"#F6F7FB"}},markdown:{heading1:"#ABB2BF",heading2:"#ABB2BF",heading3:"#ABB2BF",heading4:"#ABB2BF",link:"#56B6C2",linkHover:"#61AFEF",inlineCode:"#a0c288",inlineCodeBackground:"#232937",blockquote:"#E5C07B",blockquoteBorder:"#323848",listMarker:"#61AFEF99"},chat:{userMessage:"#ABB2BF",userMessageBackground:"#2e3442",assistantMessage:"#ABB2BF",assistantMessageBackground:"#1E222A",timestamp:"#818899",divider:"#323848"},tools:{background:"#21263180",border:"#41495e80",headerHover:"#171B23",icon:"#818899",title:"#ABB2BF",description:"#818899",edit:{added:"#98C379",addedBackground:"#98C37925",removed:"#E06C75",removedBackground:"#E06C7525",lineNumber:"#545c81"}}},lp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},up={metadata:cp,colors:dp,config:lp},fp={id:"onedarkpro-light",name:"One Dark Pro",description:"One Dark Pro",version:"1.0.0",variant:"light",tags:["light","palette"]},mp={primary:{base:"#528BFF",hover:"#73A0FE",active:"#4879DC",foreground:"#F5F6F8",muted:"#528BFF80",emphasis:"#73A0FE"},surface:{background:"#F5F6F8",foreground:"#2B303B",muted:"#EEF0F4",mutedForeground:"#6e727b",elevated:"#f0f5fa",elevatedForeground:"#2B303B",overlay:"#0E111820",subtle:"#edeff5"},interactive:{border:"#d5d8de",borderHover:"#D4D9E3",borderFocus:"#A6ADBF",selection:"#d8dde6",selectionForeground:"#0E1118",focus:"#528BFF",focusRing:"#528BFF40",cursor:"#0E1118",hover:"#d8dde6c2",active:"#FAFBFC"},status:{error:"#E06C75",errorForeground:"#F5F6F8",errorBackground:"#E06C7520",errorBorder:"#E06C7550",warning:"#D19A66",warningForeground:"#F5F6F8",warningBackground:"#D19A6620",warningBorder:"#D19A6650",success:"#4FA66D",successForeground:"#F5F6F8",successBackground:"#4FA66D20",successBorder:"#4FA66D50",info:"#61AFEF",infoForeground:"#F5F6F8",infoBackground:"#61AFEF20",infoBorder:"#61AFEF50"},pr:{open:"#4FA66D",draft:"#6B717F",blocked:"#D19A66",merged:"#a052ff",closed:"#E06C75"},syntax:{base:{background:"#EEF0F4",foreground:"#2B303B",comment:"#6B717F",keyword:"#528BFF",string:"#4FA66D",number:"#D85462",function:"#528BFF",variable:"#2B303B",type:"#D19A66",operator:"#D85462"},tokens:{boolean:"#D19A66",class:"#528BFF",className:"#528BFF",commentDoc:"#B0B4BC",constant:"#61AFEF",decorator:"#D19A66",enum:"#528BFF",exception:"#D85462",functionCall:"#528BFF",interface:"#D19A66",jsxTag:"#528BFF",key:"#528BFF",keywordImport:"#D85462",label:"#D85462",macro:"#61AFEF",method:"#4FA66D",module:"#D85462",namespace:"#D19A66",parameter:"#2B303B",preprocessor:"#D85462",punctuation:"#6B717F",regex:"#4FA66D",storageModifier:"#61AFEF",stringEscape:"#0E1118",struct:"#528BFF",tag:"#528BFF",tagAttribute:"#D19A66",tagAttributeValue:"#4FA66D",typeParameter:"#D19A66",url:"#61AFEF",variableGlobal:"#528BFF",variableLocal:"#FAFBFC",variableOther:"#4FA66D",variableProperty:"#61AFEF"},highlights:{diffAdded:"#4FA66D",diffAddedBackground:"#E5F4EA",diffModified:"#61AFEF",diffModifiedBackground:"#E4E8F4",diffRemoved:"#E06C75",diffRemovedBackground:"#FDE7EA",lineNumber:"#BEC4D0",lineNumberActive:"#0E1118"}},markdown:{heading1:"#2B303B",heading2:"#2B303B",heading3:"#2B303B",heading4:"#2B303B",link:"#61AFEF",linkHover:"#528BFF",inlineCode:"#327d4c",inlineCodeBackground:"#EEF0F4",blockquote:"#D19A66",blockquoteBorder:"#DEE2EB",listMarker:"#528BFF99"},chat:{userMessage:"#2B303B",userMessageBackground:"#eaedf4",assistantMessage:"#2B303B",assistantMessageBackground:"#F5F6F8",timestamp:"#6B717F",divider:"#DEE2EB"},tools:{background:"#EEF0F480",border:"#c4c8d080",headerHover:"#FFFFFF",icon:"#6B717F",title:"#2B303B",description:"#6B717F",edit:{added:"#4FA66D",addedBackground:"#4FA66D25",removed:"#E06C75",removedBackground:"#E06C7525",lineNumber:"#afb5c1"}}},gp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},pp={metadata:fp,colors:mp,config:gp},hp={id:"solarized-dark",name:"Solarized",description:"Solarized",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Fp={primary:{base:"#278BD2",hover:"#5C65AC",active:"#8285C9",foreground:"#001F27",muted:"#6C71C480",emphasis:"#5C65AC"},surface:{background:"#001e25",foreground:"#93A1A1",muted:"#02232e",mutedForeground:"#6f7475",elevated:"#052832",elevatedForeground:"#93A1A1",overlay:"#FDF6E320",subtle:"#062930"},interactive:{border:"#223a41",borderHover:"#243E47",borderFocus:"#3A5A6B",selection:"#98afbd33",selectionForeground:"#FDF6E3",focus:"#6C71C4",focusRing:"#6C71C440",cursor:"#FDF6E3",hover:"#98afbd25",active:"#98afbd33"},status:{error:"#DC322F",errorForeground:"#001F27",errorBackground:"#DC322F20",errorBorder:"#DC322F50",warning:"#B58900",warningForeground:"#001F27",warningBackground:"#B5890020",warningBorder:"#B5890050",success:"#859900",successForeground:"#001F27",successBackground:"#85990020",successBorder:"#85990050",info:"#2AA198",infoForeground:"#001F27",infoBackground:"#2AA19820",infoBorder:"#2AA19850"},pr:{open:"#859900",draft:"#6C7F80",blocked:"#B58900",merged:"#7f6cc4",closed:"#DC322F"},syntax:{base:{background:"#022733",foreground:"#93A1A1",comment:"#6C7F80",keyword:"#6C71C4",string:"#859900",number:"#D33682",function:"#6C71C4",variable:"#93A1A1",type:"#B58900",operator:"#D33682"},tokens:{boolean:"#B58900",class:"#6C71C4",className:"#6C71C4",commentDoc:"#5C7173",constant:"#2AA198",decorator:"#B58900",enum:"#6C71C4",exception:"#D33682",functionCall:"#6C71C4",interface:"#B58900",jsxTag:"#6C71C4",key:"#6C71C4",keywordImport:"#D33682",label:"#D33682",macro:"#2AA198",method:"#859900",module:"#D33682",namespace:"#B58900",parameter:"#93A1A1",preprocessor:"#D33682",punctuation:"#6C7F80",regex:"#859900",storageModifier:"#2AA198",stringEscape:"#FDF6E3",struct:"#6C71C4",tag:"#6C71C4",tagAttribute:"#B58900",tagAttributeValue:"#859900",typeParameter:"#B58900",url:"#2AA198",variableGlobal:"#6C71C4",variableLocal:"#01222B",variableOther:"#859900",variableProperty:"#2AA198"},highlights:{diffAdded:"#859900",diffAddedBackground:"#0F2F29",diffModified:"#2AA198",diffModifiedBackground:"#0F3844",diffRemoved:"#DC322F",diffRemovedBackground:"#321C1C",lineNumber:"#2D4958",lineNumberActive:"#FDF6E3"}},markdown:{heading1:"#93A1A1",heading2:"#93A1A1",heading3:"#93A1A1",heading4:"#93A1A1",link:"#2AA198",linkHover:"#6C71C4",inlineCode:"#859900",inlineCodeBackground:"#022733",blockquote:"#B58900",blockquoteBorder:"#20373F",listMarker:"#6C71C499"},chat:{userMessage:"#93A1A1",userMessageBackground:"#042B34",assistantMessage:"#93A1A1",assistantMessageBackground:"#001F27",timestamp:"#6C7F80",divider:"#20373F"},tools:{background:"#02273380",border:"#2b495380",headerHover:"#032830",icon:"#6C7F80",title:"#93A1A1",description:"#6C7F80",edit:{added:"#859900",addedBackground:"#85990025",removed:"#DC322F",removedBackground:"#DC322F25",lineNumber:"#345567"}}},yp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},bp={metadata:hp,colors:Fp,config:yp},Ap={id:"solarized-light",name:"Solarized",description:"Solarized",version:"1.0.0",variant:"light",tags:["light","palette"]},Ep={primary:{base:"#268BD2",hover:"#51A0D5",active:"#217EBC",foreground:"#FDF6E3",muted:"#268BD280",emphasis:"#51A0D5"},surface:{background:"#FDF6E3",foreground:"#586E75",muted:"#F6EFDA",mutedForeground:"#7a8587",elevated:"#FAF3DC",elevatedForeground:"#586E75",overlay:"#07364220",subtle:"#F6EFDA"},interactive:{border:"#e0decc",borderHover:"#D9D4C2",borderFocus:"#ACA58F",selection:"#10647a22",selectionForeground:"#073642",focus:"#268BD2",focusRing:"#268BD240",cursor:"#073642",hover:"#10647a14",active:"#10647a22"},status:{error:"#DC322F",errorForeground:"#FDF6E3",errorBackground:"#DC322F20",errorBorder:"#DC322F50",warning:"#B58900",warningForeground:"#FDF6E3",warningBackground:"#B5890020",warningBorder:"#B5890050",success:"#859900",successForeground:"#FDF6E3",successBackground:"#85990020",successBorder:"#85990050",info:"#2AA198",infoForeground:"#FDF6E3",infoBackground:"#2AA19820",infoBorder:"#2AA19850"},pr:{open:"#859900",draft:"#7A8C8E",blocked:"#B58900",merged:"#6e26d2",closed:"#DC322F"},syntax:{base:{background:"#F6EFDA",foreground:"#586E75",comment:"#7A8C8E",keyword:"#268BD2",string:"#859900",number:"#D33682",function:"#268BD2",variable:"#586E75",type:"#B58900",operator:"#D33682"},tokens:{boolean:"#B58900",class:"#268BD2",className:"#268BD2",commentDoc:"#BCC1B9",constant:"#2AA198",decorator:"#B58900",enum:"#268BD2",exception:"#D33682",functionCall:"#268BD2",interface:"#B58900",jsxTag:"#268BD2",key:"#268BD2",keywordImport:"#D33682",label:"#D33682",macro:"#2AA198",method:"#859900",module:"#D33682",namespace:"#B58900",parameter:"#586E75",preprocessor:"#D33682",punctuation:"#7A8C8E",regex:"#859900",storageModifier:"#2AA198",stringEscape:"#073642",struct:"#268BD2",tag:"#268BD2",tagAttribute:"#B58900",tagAttributeValue:"#859900",typeParameter:"#B58900",url:"#2AA198",variableGlobal:"#268BD2",variableLocal:"#FAF3DC",variableOther:"#859900",variableProperty:"#2AA198"},highlights:{diffAdded:"#859900",diffAddedBackground:"#EEF5D6",diffModified:"#2AA198",diffModifiedBackground:"#E3ECF3",diffRemoved:"#DC322F",diffRemovedBackground:"#FDE4DD",lineNumber:"#C5C0AD",lineNumberActive:"#073642"}},markdown:{heading1:"#586E75",heading2:"#586E75",heading3:"#586E75",heading4:"#586E75",link:"#2AA198",linkHover:"#268BD2",inlineCode:"#859900",inlineCodeBackground:"#F6EFDA",blockquote:"#B58900",blockquoteBorder:"#E3E0CD",listMarker:"#268BD299"},chat:{userMessage:"#586E75",userMessageBackground:"#F6EFDA",assistantMessage:"#586E75",assistantMessageBackground:"#FDF6E3",timestamp:"#7A8C8E",divider:"#E3E0CD"},tools:{background:"#F6EFDA80",border:"#d1cebc80",headerHover:"#F6EDD4",icon:"#7A8C8E",title:"#586E75",description:"#7A8C8E",edit:{added:"#859900",addedBackground:"#85990025",removed:"#DC322F",removedBackground:"#DC322F25",lineNumber:"#c3bead"}}},wp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Bp={metadata:Ap,colors:Ep,config:wp},Cp={id:"tokyonight-dark",name:"Tokyonight",description:"Tokyonight",version:"1.0.0",variant:"dark",tags:["dark","palette"]},vp={primary:{base:"#7AA2F7",hover:"#6A8CD6",active:"#8BADF8",foreground:"#0F111A",muted:"#7AA2F780",emphasis:"#6A8CD6"},surface:{background:"#0F111A",foreground:"#C0CAF5",muted:"#111428",mutedForeground:"#8890b3",elevated:"#131629",elevatedForeground:"#C0CAF5",overlay:"#EAEAFF20",subtle:"#15192b"},interactive:{border:"#2d2f43",borderHover:"#292C43",borderFocus:"#45496F",selection:"#b3b3cc33",selectionForeground:"#EAEAFF",focus:"#7AA2F7",focusRing:"#7AA2F740",cursor:"#EAEAFF",hover:"#272E49",active:"#262C46"},status:{error:"#F7768E",errorForeground:"#0F111A",errorBackground:"#F7768E20",errorBorder:"#F7768E50",warning:"#E0AF68",warningForeground:"#0F111A",warningBackground:"#E0AF6820",warningBorder:"#E0AF6850",success:"#9ECE6A",successForeground:"#0F111A",successBackground:"#9ECE6A20",successBorder:"#9ECE6A50",info:"#7DCFFF",infoForeground:"#0F111A",infoBackground:"#7DCFFF20",infoBorder:"#7DCFFF50"},pr:{open:"#9ECE6A",draft:"#7A88CF",blocked:"#E0AF68",merged:"#BB9AF7",closed:"#F7768E"},syntax:{base:{background:"#111428",foreground:"#C0CAF5",comment:"#7A88CF",keyword:"#BB9AF7",string:"#9ECE6A",number:"#FF9E64",function:"#BB9AF7",variable:"#C0CAF5",type:"#E0AF68",operator:"#FF9E64"},tokens:{boolean:"#E0AF68",class:"#BB9AF7",className:"#BB9AF7",commentDoc:"#6A76B4",constant:"#7DCFFF",decorator:"#E0AF68",enum:"#BB9AF7",exception:"#FF9E64",functionCall:"#BB9AF7",interface:"#E0AF68",jsxTag:"#BB9AF7",key:"#BB9AF7",keywordImport:"#FF9E64",label:"#FF9E64",macro:"#7DCFFF",method:"#9ECE6A",module:"#FF9E64",namespace:"#E0AF68",parameter:"#C0CAF5",preprocessor:"#FF9E64",punctuation:"#7A88CF",regex:"#9ECE6A",storageModifier:"#7DCFFF",stringEscape:"#EAEAFF",struct:"#BB9AF7",tag:"#BB9AF7",tagAttribute:"#E0AF68",tagAttributeValue:"#9ECE6A",typeParameter:"#E0AF68",url:"#7DCFFF",variableGlobal:"#BB9AF7",variableLocal:"#101324",variableOther:"#9ECE6A",variableProperty:"#7DCFFF"},highlights:{diffAdded:"#9ECE6A",diffAddedBackground:"#1C2A38",diffModified:"#7DCFFF",diffModifiedBackground:"#24283B",diffRemoved:"#F7768E",diffRemovedBackground:"#2A1F32",lineNumber:"#343755",lineNumberActive:"#EAEAFF"}},markdown:{heading1:"#C0CAF5",heading2:"#C0CAF5",heading3:"#C0CAF5",heading4:"#C0CAF5",link:"#7DCFFF",linkHover:"#7AA2F7",inlineCode:"#9ECE6A",inlineCodeBackground:"#111428",blockquote:"#E0AF68",blockquoteBorder:"#25283B",listMarker:"#7AA2F799"},chat:{userMessage:"#C0CAF5",userMessageBackground:"#171b30",assistantMessage:"#C0CAF5",assistantMessageBackground:"#0F111A",timestamp:"#7A88CF",divider:"#25283B"},tools:{background:"#11142880",border:"#393e5c80",headerHover:"#13172A",icon:"#7A88CF",title:"#C0CAF5",description:"#a4adda",edit:{added:"#9ECE6A",addedBackground:"#9ECE6A25",removed:"#F7768E",removedBackground:"#F7768E25",lineNumber:"#3e4266"}}},kp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Dp={metadata:Cp,colors:vp,config:kp},Sp={id:"tokyonight-light",name:"Tokyonight",description:"Tokyonight",version:"1.0.0",variant:"light",tags:["light","palette"]},Mp={primary:{base:"#2E7DE9",hover:"#5291E9",active:"#2B70D0",foreground:"#E1E2E7",muted:"#2E7DE980",emphasis:"#5291E9"},surface:{background:"#E1E2E7",foreground:"#273153",muted:"#DEE0EA",mutedForeground:"#686e9b",elevated:"#dee0ee",elevatedForeground:"#273153",overlay:"#1C254420",subtle:"#dadce6"},interactive:{border:"#c7c9d3",borderHover:"#C3C6D2",borderFocus:"#9599A8",selection:"#939cbf47",selectionForeground:"#1C2544",focus:"#2E7DE9",focusRing:"#2E7DE940",cursor:"#1C2544",hover:"#7b86ad2a",active:"#7b86ad47"},status:{error:"#C94060",errorForeground:"#E1E2E7",errorBackground:"#C9406020",errorBorder:"#C9406050",warning:"#8C6C3E",warningForeground:"#E1E2E7",warningBackground:"#8C6C3E20",warningBorder:"#8C6C3E50",success:"#587539",successForeground:"#E1E2E7",successBackground:"#58753920",successBorder:"#58753950",info:"#007197",infoForeground:"#E1E2E7",infoBackground:"#00719720",infoBorder:"#00719750"},pr:{open:"#587539",draft:"#5C6390",blocked:"#8C6C3E",merged:"#9854F1",closed:"#C94060"},syntax:{base:{background:"#DEE0EA",foreground:"#273153",comment:"#5C6390",keyword:"#9854F1",string:"#587539",number:"#B15C00",function:"#9854F1",variable:"#273153",type:"#3760BF",operator:"#B15C00"},tokens:{boolean:"#3760BF",class:"#9854F1",className:"#9854F1",commentDoc:"#9FA3BC",constant:"#007197",decorator:"#3760BF",enum:"#9854F1",exception:"#B15C00",functionCall:"#9854F1",interface:"#3760BF",jsxTag:"#9854F1",key:"#9854F1",keywordImport:"#B15C00",label:"#B15C00",macro:"#007197",method:"#587539",module:"#B15C00",namespace:"#3760BF",parameter:"#273153",preprocessor:"#B15C00",punctuation:"#5C6390",regex:"#587539",storageModifier:"#007197",stringEscape:"#1C2544",struct:"#9854F1",tag:"#9854F1",tagAttribute:"#3760BF",tagAttributeValue:"#587539",typeParameter:"#3760BF",url:"#007197",variableGlobal:"#9854F1",variableLocal:"#E5E6EE",variableOther:"#587539",variableProperty:"#007197"},highlights:{diffAdded:"#587539",diffAddedBackground:"#DFE7DA",diffModified:"#007197",diffModifiedBackground:"#CFD1DD",diffRemoved:"#C94060",diffRemovedBackground:"#F4DADD",lineNumber:"#AEB2BF",lineNumberActive:"#1C2544"}},markdown:{heading1:"#9854F1",heading2:"#B15C00",heading3:"#8C6C3E",heading4:"#273153",link:"#007197",linkHover:"#2E7DE9",inlineCode:"#587539",inlineCodeBackground:"#DEE0EA",blockquote:"#8C6C3E",blockquoteBorder:"#CDD0DC",listMarker:"#2E7DE999"},chat:{userMessage:"#273153",userMessageBackground:"#dcdee9",assistantMessage:"#273153",assistantMessageBackground:"#E1E2E7",timestamp:"#5C6390",divider:"#CDD0DC"},tools:{background:"#DEE0EA80",border:"#a5a8b580",headerHover:"#E9EAF1",icon:"#5C6390",title:"#273153",description:"#5C6390",edit:{added:"#587539",addedBackground:"#58753925",removed:"#C94060",removedBackground:"#C9406025",lineNumber:"#9b9ea9"}}},Tp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Pp={metadata:Sp,colors:Mp,config:Tp},Rp={id:"vesper-dark",name:"Vesper",description:"Vesper",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Ip={primary:{base:"#FFC799",hover:"#DBAC84",active:"#FFCFA8",foreground:"#101010",muted:"#FFC79980",emphasis:"#DBAC84"},surface:{background:"#151515",foreground:"#e8e5e5",muted:"#1c1b1b",mutedForeground:"#848484",elevated:"#242121",elevatedForeground:"#FFFFFF",overlay:"#FFFFFF20",subtle:"#1f1f1f"},interactive:{border:"#373636",borderHover:"#202020",borderFocus:"#383838",selection:"#b1adad33",selectionForeground:"#FFFFFF",focus:"#FFC799",focusRing:"#FFC79940",cursor:"#FFFFFF",hover:"#ffffff1c",active:"#ffffff33"},status:{error:"#FF8080",errorForeground:"#101010",errorBackground:"#FF808020",errorBorder:"#FF808050",warning:"#FFC799",warningForeground:"#101010",warningBackground:"#FFC79920",warningBorder:"#FFC79950",success:"#99FFE4",successForeground:"#101010",successBackground:"#99FFE420",successBorder:"#99FFE450",info:"#FFC799",infoForeground:"#101010",infoBackground:"#FFC79920",infoBorder:"#FFC79950"},pr:{open:"#99FFE4",draft:"#A0A0A0",blocked:"#FFC799",merged:"#ca99ff",closed:"#FF8080"},syntax:{base:{background:"#141414",foreground:"#FFFFFF",comment:"#A0A0A0",keyword:"#FFC799",string:"#99FFE4",number:"#FF8080",function:"#FFC799",variable:"#FFFFFF",type:"#FFC799",operator:"#FF8080"},tokens:{boolean:"#FFC799",class:"#FFC799",className:"#FFC799",commentDoc:"#8A8A8A",constant:"#A0A0A0",decorator:"#FFC799",enum:"#FFC799",exception:"#FF8080",functionCall:"#FFC799",interface:"#FFC799",jsxTag:"#FFC799",key:"#FFC799",keywordImport:"#FF8080",label:"#FF8080",macro:"#8B8B8B",method:"#99FFE4",module:"#FF8080",namespace:"#FFC799",parameter:"#FFFFFF",preprocessor:"#FF8080",punctuation:"#A0A0A0",regex:"#99FFE4",storageModifier:"#8B8B8B",stringEscape:"#FFFFFF",struct:"#FFC799",tag:"#FFC799",tagAttribute:"#FFC799",tagAttributeValue:"#99FFE4",typeParameter:"#FFC799",url:"#A0A0A0",variableGlobal:"#FFC799",variableLocal:"#0C0C0C",variableOther:"#99FFE4",variableProperty:"#A0A0A0"},highlights:{diffAdded:"#99FFE4",diffAddedBackground:"#0D2818",diffModified:"#FFC799",diffModifiedBackground:"#141414",diffRemoved:"#FF8080",diffRemovedBackground:"#281A1A",lineNumber:"#282828",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#FFFFFF",heading2:"#FFFFFF",heading3:"#FFFFFF",heading4:"#FFFFFF",link:"#A0A0A0",linkHover:"#FFC799",inlineCode:"#bba2a2",inlineCodeBackground:"#292727",blockquote:"#FFFFFF",blockquoteBorder:"#1C1C1C",listMarker:"#FFFFFF99"},chat:{userMessage:"#FFFFFF",userMessageBackground:"#2b2a2a",assistantMessage:"#FFFFFF",assistantMessageBackground:"#101010",timestamp:"#A0A0A0",divider:"#1C1C1C"},tools:{background:"#14141480",border:"#48474780",headerHover:"#080808",icon:"#A0A0A0",title:"#FFFFFF",description:"#A0A0A0",edit:{added:"#99FFE4",addedBackground:"#99FFE425",removed:"#FF8080",removedBackground:"#FF808025",lineNumber:"#615f5f"}}},_p={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},xp={metadata:Rp,colors:Ip,config:_p},Op={id:"vesper-light",name:"Vesper",description:"Vesper",version:"1.0.0",variant:"light",tags:["light","palette"]},Np={primary:{base:"#a06535",hover:"#FFD2AD",active:"#D9A982",foreground:"#FFFFFF",muted:"#cf9c7280",emphasis:"#FFD2AD"},surface:{background:"#FFFFFF",foreground:"#101010",muted:"#F8F8F8",mutedForeground:"#6e6d6d",elevated:"#f6f5f5",elevatedForeground:"#101010",overlay:"#00000020",subtle:"#f6f2f2"},interactive:{border:"#dfdada",borderHover:"#E0E0E0",borderFocus:"#9e9e9e",selection:"#5e5b5b22",selectionForeground:"#000000",focus:"#be875b",focusRing:"#cf9c7240",cursor:"#000000",hover:"#5e5c5c22",active:"#48474722"},status:{error:"#d46868",errorForeground:"#FFFFFF",errorBackground:"#b95f5f20",errorBorder:"#b95f5f50",warning:"#cb7f40",warningForeground:"#FFFFFF",warningBackground:"#cf9c7220",warningBorder:"#cf9c7250",success:"#109b76",successForeground:"#FFFFFF",successBackground:"#99FFE420",successBorder:"#99FFE450",info:"#62bced",infoForeground:"#FFFFFF",infoBackground:"#cf9c7220",infoBorder:"#cf9c7250"},pr:{open:"#0f926f",draft:"#888787",blocked:"#bf6f2e",merged:"#9f5fc1",closed:"#c56161"},syntax:{base:{background:"#F8F8F8",foreground:"#101010",comment:"#868686",keyword:"#cf9c72",string:"#43ae91",number:"#b95f5f",function:"#cf9c72",variable:"#101010",type:"#cf9c72",operator:"#b95f5f"},tokens:{boolean:"#cf9c72",class:"#cf9c72",className:"#cf9c72",commentDoc:"#D0D0D0",constant:"#838282",decorator:"#cf9c72",enum:"#cf9c72",exception:"#b95f5f",functionCall:"#cf9c72",interface:"#cf9c72",jsxTag:"#cf9c72",key:"#cf9c72",keywordImport:"#b95f5f",label:"#b95f5f",macro:"#717070",method:"#74e8c9",module:"#b95f5f",namespace:"#cf9c72",parameter:"#101010",preprocessor:"#b95f5f",punctuation:"#717070",regex:"#67e7c5",storageModifier:"#7b7b7b",stringEscape:"#000000",struct:"#cf9c72",tag:"#cf9c72",tagAttribute:"#cf9c72",tagAttributeValue:"#6adebf",typeParameter:"#cf9c72",url:"#797878",variableGlobal:"#cf9c72",variableLocal:"#F0F0F0",variableOther:"#49dcb5",variableProperty:"#717070"},highlights:{diffAdded:"#56d8b5",diffAddedBackground:"#E8F5E8",diffModified:"#cf9c72",diffModifiedBackground:"#F0F0F0",diffRemoved:"#b95f5f",diffRemovedBackground:"#F5E8E8",lineNumber:"#D0D0D0",lineNumberActive:"#000000"}},markdown:{heading1:"#101010",heading2:"#101010",heading3:"#101010",heading4:"#101010",link:"#717070",linkHover:"#c48959",inlineCode:"#665050",inlineCodeBackground:"#f3f1f1",blockquote:"#101010",blockquoteBorder:"#E8E8E8",listMarker:"#10101099"},chat:{userMessage:"#101010",userMessageBackground:"#f4f1f1",assistantMessage:"#101010",assistantMessageBackground:"#FFFFFF",timestamp:"#717070",divider:"#E8E8E8"},tools:{background:"#F8F8F880",border:"#d0cece80",headerHover:"#E8E8E8",icon:"#717070",title:"#101010",description:"#717070",edit:{added:"#40d7af",addedBackground:"#99FFE425",removed:"#b95f5f",removedBackground:"#b95f5f25",lineNumber:"#b4b2b2"}}},Lp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Up={metadata:Op,colors:Np,config:Lp},Hp={id:"mono-plus-dark",name:"Mono Plus",description:"A pure monochromatic theme - dark variant with slight colors added",version:"1.0.0",variant:"dark",tags:["dark","monochrome","minimal"]},Kp={primary:{base:"#a2bee8",hover:"#E5E5E5",active:"#CCCCCC",foreground:"#000000",muted:"#FFFFFF80",emphasis:"#FFFFFF"},surface:{background:"#000000",foreground:"#E5E5E5",muted:"#0A0A0A",mutedForeground:"#808080",elevated:"#141414",elevatedForeground:"#E5E5E5",overlay:"#00000080",subtle:"#1A1A1A"},interactive:{border:"#2f2f2f",borderHover:"#333333",borderFocus:"#FFFFFF",selection:"#ffffff1f",selectionForeground:"#E5E5E5",focus:"#FFFFFF",focusRing:"#FFFFFF50",cursor:"#E5E5E5",hover:"#ffffff1f",active:"#ffffff1f"},status:{error:"#9e6a6a",errorForeground:"#0a0a0a",errorBackground:"#9e6a6a20",errorBorder:"#9e6a6a50",warning:"#9e8a6a",warningForeground:"#0a0a0a",warningBackground:"#9e8a6a20",warningBorder:"#9e8a6a50",success:"#6a8e6a",successForeground:"#0a0a0a",successBackground:"#6a8e6a20",successBorder:"#6a8e6a50",info:"#6a7e9e",infoForeground:"#0a0a0a",infoBackground:"#6a7e9e20",infoBorder:"#6a7e9e50"},pr:{open:"#6a8e6a",draft:"#8c8c8c",blocked:"#9e8a6a",merged:"#bda2e8",closed:"#9e6a6a"},syntax:{base:{background:"#0a0a0a",foreground:"#d4d4d4",comment:"#8c8c8c",keyword:"#dccdbeff",string:"#b6d8e6ff",number:"#e3bdadff",function:"#a2bee8",variable:"#d4d4d4",type:"#edcbb8ff",operator:"#dccdbeff"},tokens:{commentDoc:"#8c8c8c",stringEscape:"#b6d8e6ff",keywordImport:"#dccdbeff",storageModifier:"#dccdbeff",functionCall:"#a2bee8",method:"#a2bee8",variableProperty:"#c0dcc0ff",variableOther:"#d4d4d4",class:"#edcbb8ff",className:"#edcbb8ff",interface:"#edcbb8ff",tag:"#a2bee8",boolean:"#e3bdadff",url:"#b6d8e6ff",key:"#c0dcc0ff"},highlights:{diffAdded:"#6a8e6a",diffAddedBackground:"#6a8e6a20",diffRemoved:"#9e6a6a",diffRemovedBackground:"#9e6a6a20",lineNumber:"#7c7c7c",lineNumberActive:"#d4d4d4"}},markdown:{heading1:"#FFFFFF",heading2:"#F2F2F2",heading3:"#E5E5E5",heading4:"#D9D9D9",link:"#CCCCCC",linkHover:"#a2bee8",inlineCode:"#a2bee8",inlineCodeBackground:"#1A1A1A",blockquote:"#808080",blockquoteBorder:"#333333",listMarker:"#99999999"},chat:{userMessage:"#E5E5E5",userMessageBackground:"#1A1A1A",assistantMessage:"#E5E5E5",assistantMessageBackground:"#000000",timestamp:"#808080",divider:"#333333"},tools:{background:"#0A0A0A50",border:"#4040409d",headerHover:"#33333350",icon:"#A6A6A6",title:"#E5E5E5",description:"#808080",edit:{added:"#6a8e6a",addedBackground:"#6a8e6a20",removed:"#9e6a6a",removedBackground:"#9e6a6a20",lineNumber:"#2a2a2a"}}},jp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},$p={metadata:Hp,colors:Kp,config:jp},zp={id:"mono-plus-light",name:"Mono Plus",description:"A pure monochromatic theme - light variant with slight colors added",version:"1.0.0",variant:"light",tags:["light","monochrome","minimal"]},qp={primary:{base:"#4a6a9e",hover:"#1A1A1A",active:"#333333",foreground:"#FFFFFF",muted:"#00000080",emphasis:"#000000"},surface:{background:"#FFFFFF",foreground:"#1A1A1A",muted:"#F5F5F5",mutedForeground:"#6f6f6f",elevated:"#FAFAFA",elevatedForeground:"#1A1A1A",overlay:"#00000020",subtle:"#F0F0F0"},interactive:{border:"#e3e3e3",borderHover:"#B3B3B3",borderFocus:"#000000",selection:"#00000015",selectionForeground:"#1A1A1A",focus:"#000000",focusRing:"#00000040",cursor:"#1A1A1A",hover:"#00000010",active:"#00000015"},status:{error:"#8a5a5a",errorForeground:"#fafafa",errorBackground:"#8a5a5a18",errorBorder:"#8a5a5a40",warning:"#8a7a5a",warningForeground:"#fafafa",warningBackground:"#8a7a5a18",warningBorder:"#8a7a5a40",success:"#5a7a5a",successForeground:"#fafafa",successBackground:"#5a7a5a18",successBorder:"#5a7a5a40",info:"#5a6a8a",infoForeground:"#fafafa",infoBackground:"#5a6a8a18",infoBorder:"#5a6a8a40"},pr:{open:"#6a8e6a",draft:"#8c8c8c",blocked:"#8a7a5a",merged:"#8769b6",closed:"#8a5a5a"},syntax:{base:{background:"#f5f5f5",foreground:"#2a2a2a",comment:"#8c8c8c",keyword:"#6a5a4a",string:"#4a6a7a",number:"#7a5a4a",function:"#4a6a9e",variable:"#2a2a2a",type:"#6a5040",operator:"#6a5a4a"},tokens:{commentDoc:"#8c8c8c",stringEscape:"#4a6a7a",keywordImport:"#6a5a4a",storageModifier:"#6a5a4a",functionCall:"#4a6a9e",method:"#4a6a9e",variableProperty:"#4a6a4a",variableOther:"#2a2a2a",class:"#6a5040",className:"#6a5040",interface:"#6a5040",tag:"#4a6a9e",boolean:"#7a5a4a",url:"#4a6a7a",key:"#4a6a4a"},highlights:{diffAdded:"#5a7a5a",diffAddedBackground:"#5a7a5a18",diffRemoved:"#8a5a5a",diffRemovedBackground:"#8a5a5a18",lineNumber:"#b0b0b0",lineNumberActive:"#2a2a2a"}},markdown:{heading1:"#000000",heading2:"#0D0D0D",heading3:"#1A1A1A",heading4:"#262626",link:"#333333",linkHover:"#4a6a9e",inlineCode:"#4a6a9e",inlineCodeBackground:"#f1f1f1",blockquote:"#808080",blockquoteBorder:"#D9D9D9",listMarker:"#66666699"},chat:{userMessage:"#1A1A1A",userMessageBackground:"#E5E5E5",assistantMessage:"#1A1A1A",assistantMessageBackground:"#FFFFFF",timestamp:"#808080",divider:"#D9D9D9"},tools:{background:"#F5F5F550",border:"#B3B3B380",headerHover:"#D9D9D9",icon:"#666666",title:"#1A1A1A",description:"#808080",edit:{added:"#5a7a5a",addedBackground:"#5a7a5a18",removed:"#8a5a5a",removedBackground:"#8a5a5a18",lineNumber:"#d0d0d0"}}},Gp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Wp={metadata:zp,colors:qp,config:Gp},Vp={id:"mono-dark",name:"Mono",description:"A pure monochromatic theme - dark variant with shades of grey",version:"1.0.0",variant:"dark",tags:["dark","monochrome","minimal","grayscale"]},Jp={primary:{base:"#FFFFFF",hover:"#E5E5E5",active:"#CCCCCC",foreground:"#000000",muted:"#FFFFFF80",emphasis:"#FFFFFF"},surface:{background:"#000000",foreground:"#E5E5E5",muted:"#0A0A0A",mutedForeground:"#808080",elevated:"#141414",elevatedForeground:"#E5E5E5",overlay:"#00000080",subtle:"#1A1A1A"},interactive:{border:"#2f2f2f",borderHover:"#333333",borderFocus:"#FFFFFF",selection:"#ffffff1f",selectionForeground:"#E5E5E5",focus:"#FFFFFF",focusRing:"#FFFFFF50",cursor:"#E5E5E5",hover:"#ffffff1f",active:"#ffffff1f"},status:{error:"#666666",errorForeground:"#000000",errorBackground:"#ffffff10",errorBorder:"#ffffff20",warning:"#999999",warningForeground:"#000000",warningBackground:"#ffffff12",warningBorder:"#ffffff25",success:"#E5E5E5",successForeground:"#000000",successBackground:"#ffffff18",successBorder:"#ffffff30",info:"#A6A6A6",infoForeground:"#000000",infoBackground:"#ffffff14",infoBorder:"#ffffff28"},pr:{open:"#E5E5E5",draft:"#B3B3B3",blocked:"#999999",merged:"#CCCCCC",closed:"#666666"},syntax:{base:{background:"#0A0A0A",foreground:"#E5E5E5",comment:"#666666",keyword:"#FFFFFF",string:"#B3B3B3",number:"#999999",function:"#E5E5E5",variable:"#CCCCCC",type:"#D9D9D9",operator:"#808080"},tokens:{commentDoc:"#595959",stringEscape:"#E5E5E5",keywordImport:"#FFFFFF",storageModifier:"#E5E5E5",functionCall:"#D9D9D9",method:"#CCCCCC",variableProperty:"#B3B3B3",variableOther:"#CCCCCC",variableGlobal:"#999999",variableLocal:"#1A1A1A",parameter:"#CCCCCC",constant:"#E5E5E5",class:"#FFFFFF",className:"#FFFFFF",interface:"#D9D9D9",struct:"#E5E5E5",enum:"#E5E5E5",typeParameter:"#D9D9D9",namespace:"#CCCCCC",module:"#B3B3B3",tag:"#E5E5E5",jsxTag:"#FFFFFF",tagAttribute:"#B3B3B3",tagAttributeValue:"#999999",boolean:"#CCCCCC",decorator:"#999999",label:"#808080",punctuation:"#666666",macro:"#D9D9D9",preprocessor:"#B3B3B3",regex:"#A6A6A6",url:"#CCCCCC",key:"#E5E5E5",exception:"#999999"},highlights:{diffAdded:"#E5E5E5",diffAddedBackground:"#ffffff18",diffRemoved:"#666666",diffRemovedBackground:"#ffffff0d",diffModified:"#B3B3B3",diffModifiedBackground:"#ffffff12",lineNumber:"#404040",lineNumberActive:"#E5E5E5"}},markdown:{heading1:"#FFFFFF",heading2:"#F2F2F2",heading3:"#E5E5E5",heading4:"#D9D9D9",link:"#CCCCCC",linkHover:"#FFFFFF",inlineCode:"#B3B3B3",inlineCodeBackground:"#1A1A1A",blockquote:"#808080",blockquoteBorder:"#333333",listMarker:"#99999999"},chat:{userMessage:"#E5E5E5",userMessageBackground:"#1A1A1A",assistantMessage:"#E5E5E5",assistantMessageBackground:"#000000",timestamp:"#808080",divider:"#333333"},tools:{background:"#0A0A0A50",border:"#4040409d",headerHover:"#33333350",icon:"#A6A6A6",title:"#E5E5E5",description:"#808080",edit:{added:"#E5E5E5",addedBackground:"#ffffff20",removed:"#666666",removedBackground:"#ffffff10",lineNumber:"#404040"}}},Yp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Xp={metadata:Vp,colors:Jp,config:Yp},Qp={id:"mono-light",name:"Mono",description:"A pure monochromatic theme - light variant with shades of grey",version:"1.0.0",variant:"light",tags:["light","monochrome","minimal","grayscale"]},Zp={primary:{base:"#000000",hover:"#1A1A1A",active:"#333333",foreground:"#FFFFFF",muted:"#00000080",emphasis:"#000000"},surface:{background:"#FFFFFF",foreground:"#1A1A1A",muted:"#F5F5F5",mutedForeground:"#757575",elevated:"#FAFAFA",elevatedForeground:"#1A1A1A",overlay:"#00000020",subtle:"#F0F0F0"},interactive:{border:"#e3e3e3",borderHover:"#B3B3B3",borderFocus:"#000000",selection:"#00000015",selectionForeground:"#1A1A1A",focus:"#000000",focusRing:"#00000040",cursor:"#1A1A1A",hover:"#00000010",active:"#00000015"},status:{error:"#999999",errorForeground:"#FFFFFF",errorBackground:"#00000008",errorBorder:"#00000015",warning:"#666666",warningForeground:"#FFFFFF",warningBackground:"#0000000a",warningBorder:"#00000018",success:"#1A1A1A",successForeground:"#FFFFFF",successBackground:"#00000012",successBorder:"#00000020",info:"#595959",infoForeground:"#FFFFFF",infoBackground:"#0000000c",infoBorder:"#0000001a"},pr:{open:"#1A1A1A",draft:"#4D4D4D",blocked:"#999999",merged:"#333333",closed:"#666666"},syntax:{base:{background:"#F5F5F5",foreground:"#1A1A1A",comment:"#999999",keyword:"#000000",string:"#4D4D4D",number:"#666666",function:"#1A1A1A",variable:"#333333",type:"#262626",operator:"#808080"},tokens:{commentDoc:"#ABABAB",stringEscape:"#1A1A1A",keywordImport:"#000000",storageModifier:"#1A1A1A",functionCall:"#262626",method:"#333333",variableProperty:"#4D4D4D",variableOther:"#333333",variableGlobal:"#666666",variableLocal:"#E5E5E5",parameter:"#333333",constant:"#1A1A1A",class:"#000000",className:"#000000",interface:"#262626",struct:"#1A1A1A",enum:"#1A1A1A",typeParameter:"#262626",namespace:"#333333",module:"#4D4D4D",tag:"#1A1A1A",jsxTag:"#000000",tagAttribute:"#4D4D4D",tagAttributeValue:"#666666",boolean:"#333333",decorator:"#666666",label:"#808080",punctuation:"#999999",macro:"#262626",preprocessor:"#4D4D4D",regex:"#595959",url:"#333333",key:"#1A1A1A",exception:"#666666"},highlights:{diffAdded:"#1A1A1A",diffAddedBackground:"#00000012",diffRemoved:"#999999",diffRemovedBackground:"#00000008",diffModified:"#595959",diffModifiedBackground:"#0000000c",lineNumber:"#CCCCCC",lineNumberActive:"#1A1A1A"}},markdown:{heading1:"#000000",heading2:"#0D0D0D",heading3:"#1A1A1A",heading4:"#262626",link:"#333333",linkHover:"#000000",inlineCode:"#4D4D4D",inlineCodeBackground:"#f1f1f1",blockquote:"#808080",blockquoteBorder:"#D9D9D9",listMarker:"#66666699"},chat:{userMessage:"#1A1A1A",userMessageBackground:"#E5E5E5",assistantMessage:"#1A1A1A",assistantMessageBackground:"#FFFFFF",timestamp:"#808080",divider:"#D9D9D9"},tools:{background:"#F5F5F550",border:"#B3B3B380",headerHover:"#D9D9D9",icon:"#666666",title:"#1A1A1A",description:"#808080",edit:{added:"#1A1A1A",addedBackground:"#00000015",removed:"#999999",removedBackground:"#0000000a",lineNumber:"#CCCCCC"}}},eh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},th={metadata:Qp,colors:Zp,config:eh},rh={id:"vitesse-dark-dark",name:"Vitesse Dark",description:"Converted from VS Code theme",version:"1.0.0",variant:"dark",tags:["dark","converted","vscode"]},oh={primary:{base:"#4d9375",hover:"#4d9375",active:"#5cb08c",foreground:"#121212",muted:"#4d937580",emphasis:"#64bf98"},surface:{background:"#121212",foreground:"#dbd7caee",muted:"#171717",mutedForeground:"#c0beb99c",elevated:"#1a1a1a",elevatedForeground:"#dbd7caee",overlay:"#12121280",subtle:"#1e1e1e"},interactive:{border:"#313131",borderHover:"#3c3c3c",borderFocus:"#00000000",selection:"#eeeeee18",selectionForeground:"#dbd7caee",focus:"#00000000",focusRing:"#0000000050",cursor:"#CECDC3",hover:"#eeeeee14",active:"#eeeeee18"},status:{error:"#cb7676",errorForeground:"#121212",errorBackground:"#cb767620",errorBorder:"#cb767650",warning:"#d4976c",warningForeground:"#121212",warningBackground:"#d4976c20",warningBorder:"#d4976c50",success:"#4d9375",successForeground:"#121212",successBackground:"#4d937520",successBorder:"#4d937550",info:"#6394bf",infoForeground:"#121212",infoBackground:"#6394bf20",infoBorder:"#6394bf50"},pr:{open:"#4d9375",draft:"#747f74",blocked:"#d4976c",merged:"#6c43be",closed:"#cb7676"},syntax:{base:{background:"#121212",foreground:"#dbd7caee",comment:"#758575dd",keyword:"#4d9375",string:"#c98a7d",number:"#4C9A91",function:"#80a665",variable:"#bd976a",type:"#5d99a9",operator:"#cb7676"},tokens:{commentDoc:"#575653",stringEscape:"#dbd7caee",keywordImport:"#D14D41",storageModifier:"#4385BE",functionCall:"#80a665",method:"#879A39",variableProperty:"#b8a965",variableOther:"#879A39",class:"#6872ab",className:"#6872ab",interface:"#5d99a9",tag:"#4d9375",boolean:"#4d9375",url:"#c98a7d",key:"#b8a965"},highlights:{diffAdded:"#4d9375",diffAddedBackground:"#4d937520",diffRemoved:"#cb7676",diffRemovedBackground:"#cb767620",lineNumber:"#dedcd550",lineNumberActive:"#bfbaaa"}},markdown:{heading1:"#4d9375",heading2:"#4d9375",heading3:"#4d9375",heading4:"#dbd7caee",link:"#4d9375",linkHover:"#4d9375",inlineCode:"#80a665",inlineCodeBackground:"#121212",blockquote:"#dedcd550",blockquoteBorder:"#ffffff15",listMarker:"#4d937599"},chat:{userMessage:"#dbd7caee",userMessageBackground:"#252525",assistantMessage:"#dbd7caee",assistantMessageBackground:"#121212",timestamp:"#dedcd550",divider:"#ffffff15"},tools:{background:"#12121250",border:"#2d2c2c",headerHover:"#ffffff1550",icon:"#dedcd5a4",title:"#dbd7caee",description:"#e9e8e27f",edit:{added:"#4d9375",addedBackground:"#4d937520",removed:"#cb7676",removedBackground:"#cb767620",lineNumber:"#ffffff24"}}},nh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},ah={metadata:rh,colors:oh,config:nh},sh={id:"vitesse-light-light",name:"Vitesse Light",description:"Converted from VS Code theme",version:"1.0.0",variant:"light",tags:["light","converted","vscode"]},ih={primary:{base:"#1c6b48",hover:"#1c6b48",active:"#228056",foreground:"#ffffff",muted:"#1c6b4880",emphasis:"#248b5e"},surface:{background:"#ffffff",foreground:"#2c2c28",muted:"#f2f0f0",mutedForeground:"#5b5c54cb",elevated:"#f7f7f7",elevatedForeground:"#393a34",overlay:"#ffffff80",subtle:"#f6f3f3"},interactive:{border:"#dbd8d8",borderHover:"#cbc7c7",borderFocus:"#635454b8",selection:"#22222218",selectionForeground:"#393a34",focus:"#00000000",focusRing:"#0000000050",cursor:"#CECDC3",hover:"#22222218",active:"#22222218"},status:{error:"#ab5959",errorForeground:"#ffffff",errorBackground:"#ab595920",errorBorder:"#ab595950",warning:"#a65e2b",warningForeground:"#ffffff",warningBackground:"#a65e2b20",warningBorder:"#a65e2b50",success:"#1e754f",successForeground:"#ffffff",successBackground:"#1e754f20",successBorder:"#1e754f50",info:"#296aa3",infoForeground:"#ffffff",infoBackground:"#296aa320",infoBorder:"#296aa350"},pr:{open:"#1e754f",draft:"#a0ada0",blocked:"#a65e2b",merged:"#5843be",closed:"#ab5959"},syntax:{base:{background:"#ffffff",foreground:"#393a34",comment:"#a0ada0",keyword:"#1e754f",string:"#b56959",number:"#2f798a",function:"#59873a",variable:"#b07d48",type:"#2e808f",operator:"#ab5959"},tokens:{commentDoc:"#575653",stringEscape:"#393a34",keywordImport:"#D14D41",storageModifier:"#4385BE",functionCall:"#59873a",method:"#879A39",variableProperty:"#998418",variableOther:"#879A39",class:"#5a6aa6",className:"#5a6aa6",interface:"#2e808f",tag:"#1e754f",boolean:"#1e754f",url:"#b56959",key:"#998418"},highlights:{diffAdded:"#1e754f",diffAddedBackground:"#1e754f20",diffRemoved:"#ab5959",diffRemovedBackground:"#ab595920",lineNumber:"#393a3450",lineNumberActive:"#4e4f47"}},markdown:{heading1:"#2c2c28",heading2:"#2c2c28",heading3:"#2c2c28",heading4:"#2c2c28",link:"#1e754f",linkHover:"#1c6b48",inlineCode:"#3a631e",inlineCodeBackground:"#f7f3f395",blockquote:"#2c2c2850",blockquoteBorder:"#00000015",listMarker:"#1c6b4899"},chat:{userMessage:"#2c2c28",userMessageBackground:"#f4f1f1",assistantMessage:"#393a34",assistantMessageBackground:"#ffffff",timestamp:"#393a3450",divider:"#00000015"},tools:{background:"#ffffff50",border:"#dbd7d7",headerHover:"#0000001550",icon:"#21221e86",title:"#393a34",description:"#404139b6",edit:{added:"#1e754f",addedBackground:"#1e754f20",removed:"#ab5959",removedBackground:"#ab595920",lineNumber:"#b9b6b6"}}},ch={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},dh={metadata:sh,colors:ih,config:ch},lh=[op,ip,Bm,Dm,Pm,xm,Um,$m,Wm,Xm,tg,ag,dg,mg,Fg,Eg,vg,Mg,Ig,Ng,Kg,qg,Jg,Zg,up,pp,bp,Bp,Dp,Pp,xp,Up,$p,Wp,Xp,th,ah,dh].map(e=>Hr(e)),uh={id:"flexoki-light",name:"Flexoki",description:"An inky color scheme for prose and code - light variant",version:"1.0.0",variant:"light",tags:["light","warm","natural","paper"]},fh={primary:{base:"#BC5215",hover:"#F9AE77",active:"#DA702C",foreground:"#fffdf4",muted:"#BC521580",emphasis:"#F9AE77"},surface:{background:"#fffdf4",foreground:"#100F0F",muted:"#f6f5ee",mutedForeground:"#686663",elevated:"#fbfaf2",elevatedForeground:"#100F0F",overlay:"#100F0F20",subtle:"#f7f4ec"},interactive:{border:"#e6e4db",borderHover:"#CECDC3",borderFocus:"#BC5215",selection:"#76736f30",selectionForeground:"#100F0F",focus:"#BC5215",focusRing:"#BC521540",cursor:"#100F0F",hover:"#76736f20",active:"#76736f20"},status:{error:"#AF3029",errorForeground:"#fffdf4",errorBackground:"#D14D4120",errorBorder:"#D14D4150",warning:"#BC5215",warningForeground:"#fffdf4",warningBackground:"#DA702C20",warningBorder:"#DA702C50",success:"#66800B",successForeground:"#fffdf4",successBackground:"#879A3920",successBorder:"#879A3950",info:"#205EA6",infoForeground:"#fffdf4",infoBackground:"#4385BE20",infoBorder:"#4385BE50"},pr:{open:"#66800B",draft:"#6F6E69",blocked:"#BC5215",merged:"#5E409D",closed:"#AF3029"},syntax:{base:{background:"#f6f5ee",foreground:"#100F0F",comment:"#6F6E69",keyword:"#205EA6",string:"#24837B",number:"#5E409D",function:"#BC5215",variable:"#100F0F",type:"#AD8301",operator:"#AF3029"},tokens:{commentDoc:"#B7B5AC",stringEscape:"#100F0F",keywordImport:"#AF3029",storageModifier:"#205EA6",functionCall:"#BC5215",method:"#66800B",variableProperty:"#205EA6",variableOther:"#66800B",variableGlobal:"#A02F6F",variableLocal:"#E6E4D9",parameter:"#100F0F",constant:"#100F0F",class:"#BC5215",className:"#BC5215",interface:"#AD8301",struct:"#BC5215",enum:"#BC5215",typeParameter:"#BC5215",namespace:"#AD8301",module:"#AF3029",tag:"#205EA6",jsxTag:"#A02F6F",tagAttribute:"#AD8301",tagAttributeValue:"#24837B",boolean:"#AD8301",decorator:"#AD8301",label:"#A02F6F",punctuation:"#6F6E69",macro:"#205EA6",preprocessor:"#A02F6F",regex:"#24837B",url:"#205EA6",key:"#BC5215",exception:"#A02F6F"},highlights:{diffAdded:"#66800B",diffAddedBackground:"#879A3920",diffRemoved:"#AF3029",diffRemovedBackground:"#D14D4120",diffModified:"#205EA6",diffModifiedBackground:"#4385BE20",lineNumber:"#CECDC3",lineNumberActive:"#100F0F"}},markdown:{heading1:"#100F0F",heading2:"#100F0F",heading3:"#100F0F",heading4:"#100F0F",link:"#205EA6",linkHover:"#4385BE",inlineCode:"#24837B",inlineCodeBackground:"#f6f5ee",blockquote:"#6F6E69",blockquoteBorder:"#DAD8CE",listMarker:"#AD830199"},chat:{userMessage:"#100F0F",userMessageBackground:"#f7f4ec",assistantMessage:"#100F0F",assistantMessageBackground:"#fffdf4",timestamp:"#6F6E69",divider:"#DAD8CE"},tools:{background:"#f6f5ee50",border:"#b4b2a980",headerHover:"#DAD8CE",icon:"#6F6E69",title:"#100F0F",description:"#6F6E69",edit:{added:"#66800B",addedBackground:"#66800B25",removed:"#AF3029",removedBackground:"#AF302925",lineNumber:"#CECDC3"}}},mh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},gh={metadata:uh,colors:fh,config:mh},ph={id:"flexoki-dark",name:"Flexoki",description:"An inky color scheme for prose and code - dark variant",version:"1.0.0",variant:"dark",tags:["dark","warm","natural","ink"]},hh={primary:{base:"#DA702C",hover:"#DA702C",active:"#F9AE77",foreground:"#171515",muted:"#DA702C80",emphasis:"#F9AE77"},surface:{background:"#171515",foreground:"#CECDC3",muted:"#1C1B1A",mutedForeground:"#807e79",elevated:"#1c1a19",elevatedForeground:"#CECDC3",overlay:"#00000080",subtle:"#1e1d1c"},interactive:{border:"#2b2a28",borderHover:"#403E3C",borderFocus:"#DA702C",selection:"#f4f4f41f",selectionForeground:"#CECDC3",focus:"#DA702C",focusRing:"#DA702C50",cursor:"#CECDC3",hover:"#ffffff18",active:"#ffffff1f"},status:{error:"#D14D41",errorForeground:"#171515",errorBackground:"#AF302920",errorBorder:"#AF302950",warning:"#DA702C",warningForeground:"#171515",warningBackground:"#BC521520",warningBorder:"#BC521550",success:"#A0AF54",successForeground:"#171515",successBackground:"#66800B20",successBorder:"#66800B50",info:"#4385BE",infoForeground:"#171515",infoBackground:"#205EA620",infoBorder:"#205EA650"},pr:{open:"#A0AF54",draft:"#878580",blocked:"#DA702C",merged:"#8B7EC8",closed:"#D14D41"},syntax:{base:{background:"#1C1B1A",foreground:"#CECDC3",comment:"#878580",keyword:"#4385BE",string:"#3AA99F",number:"#8B7EC8",function:"#DA702C",variable:"#CECDC3",type:"#D0A215",operator:"#D14D41"},tokens:{commentDoc:"#575653",stringEscape:"#CECDC3",keywordImport:"#D14D41",storageModifier:"#4385BE",functionCall:"#DA702C",method:"#879A39",variableProperty:"#4385BE",variableOther:"#879A39",variableGlobal:"#CE5D97",variableLocal:"#282726",parameter:"#CECDC3",constant:"#CECDC3",class:"#DA702C",className:"#DA702C",interface:"#D0A215",struct:"#DA702C",enum:"#DA702C",typeParameter:"#DA702C",namespace:"#D0A215",module:"#D14D41",tag:"#4385BE",jsxTag:"#CE5D97",tagAttribute:"#D0A215",tagAttributeValue:"#3AA99F",boolean:"#D0A215",decorator:"#D0A215",label:"#CE5D97",punctuation:"#878580",macro:"#4385BE",preprocessor:"#CE5D97",regex:"#3AA99F",url:"#4385BE",key:"#DA702C",exception:"#CE5D97"},highlights:{diffAdded:"#879A39",diffAddedBackground:"#66800B20",diffRemoved:"#D14D41",diffRemovedBackground:"#AF302920",diffModified:"#4385BE",diffModifiedBackground:"#205EA620",lineNumber:"#403E3C",lineNumberActive:"#CECDC3"}},markdown:{heading1:"#fbf9e6",heading2:"#e6e4d2",heading3:"#CECDC3",heading4:"#CECDC3",link:"#4385BE",linkHover:"#205EA6",inlineCode:"#A0AF53",inlineCodeBackground:"#1C1B1A",blockquote:"#878580",blockquoteBorder:"#343331",listMarker:"#D0A21599"},chat:{userMessage:"#CECDC3",userMessageBackground:"#27180E",assistantMessage:"#CECDC3",assistantMessageBackground:"#171515",timestamp:"#878580",divider:"#343331"},tools:{background:"#1C1B1A50",border:"#42403e9d",headerHover:"#34333150",icon:"#aca7a1",title:"#CECDC3",description:"#878580",edit:{added:"#879A39",addedBackground:"#66800B25",removed:"#D14D41",removedBackground:"#AF302925",lineNumber:"#403E3C"}}},Fh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},yh={metadata:ph,colors:hh,config:Fh},bh={id:"pichamber-light",name:"PiChamber",description:"The PiChamber signature - crisp white surfaces with neutral typography and clean accents, inspired by Comet (light variant)",author:"PiChamber",version:"1.0.0",variant:"light",tags:["light","brand","neutral","comet"]},Ah={primary:{base:"#1e1e24",hover:"#0a0a0d",active:"#2d2d34",foreground:"#fafafc",muted:"#1e1e2480",emphasis:"#0a0a0d"},surface:{background:"#fcfcfd",foreground:"#2d2d34",muted:"#f3f3f6",mutedForeground:"#5c5c69",elevated:"#ffffff",elevatedForeground:"#2d2d34",overlay:"#00000015",subtle:"#eaeaf0"},interactive:{border:"#d8d8e0",borderHover:"#bcbccb",borderFocus:"#4f46e5",selection:"#00000014",selectionForeground:"#2d2d34",focus:"#4f46e5",focusRing:"#4f46e530",cursor:"#2d2d34",hover:"#00000008",active:"#00000010"},status:{error:"#dc2626",errorForeground:"#ffffff",errorBackground:"#dc262614",errorBorder:"#dc262635",warning:"#d97706",warningForeground:"#ffffff",warningBackground:"#d9770614",warningBorder:"#d9770635",success:"#059669",successForeground:"#ffffff",successBackground:"#05966914",successBorder:"#05966935",info:"#4f46e5",infoForeground:"#ffffff",infoBackground:"#4f46e514",infoBorder:"#4f46e535"},pr:{open:"#059669",draft:"#686875",blocked:"#d97706",merged:"#6366f1",closed:"#dc2626"},syntax:{base:{background:"#f3f3f6",foreground:"#2d2d34",comment:"#686875",keyword:"#435278",string:"#0f5b41",number:"#7c451e",function:"#4450b0",variable:"#2d2d34",type:"#7c451e",operator:"#2d2d34"},tokens:{commentDoc:"#686875",stringEscape:"#8d2f58",keywordImport:"#8d2f58",storageModifier:"#435278",functionCall:"#4450b0",method:"#4450b0",variableProperty:"#7c451e",variableOther:"#2d2d34",variableGlobal:"#0f5b41",variableLocal:"#2d2d34",parameter:"#2d2d34",constant:"#0f5b41",class:"#7c451e",className:"#7c451e",interface:"#7c451e",struct:"#7c451e",enum:"#7c451e",typeParameter:"#7c451e",namespace:"#7c451e",module:"#8d2f58",tag:"#8d2f58",jsxTag:"#8d2f58",tagAttribute:"#7c451e",tagAttributeValue:"#0f5b41",boolean:"#7c451e",decorator:"#4450b0",label:"#7c451e",punctuation:"#686875",macro:"#8d2f58",preprocessor:"#8d2f58",regex:"#0f5b41",url:"#4450b0",key:"#7c451e",exception:"#dc2626"},highlights:{diffAdded:"#059669",diffAddedBackground:"#05966918",diffRemoved:"#dc2626",diffRemovedBackground:"#dc262618",diffModified:"#4f46e5",diffModifiedBackground:"#4f46e514",lineNumber:"#9ca3af",lineNumberActive:"#2d2d34"}},markdown:{heading1:"#2d2d34",heading2:"#2d2d34",heading3:"#2d2d34",heading4:"#2d2d34",link:"#4f46e5",linkHover:"#3730a3",inlineCode:"#2d2d34",inlineCodeBackground:"#00000008",blockquote:"#686875",blockquoteBorder:"#e2e2e8",listMarker:"#4f46e590"},chat:{userMessage:"#2d2d34",userMessageBackground:"#ededf2",assistantMessage:"#2d2d34",assistantMessageBackground:"#fcfcfd",timestamp:"#8c8c9a",divider:"#e2e2e8"},tools:{background:"#f3f3f680",border:"#d8d8e0",headerHover:"#0000000d",icon:"#686875",title:"#2d2d34",description:"#686875",edit:{added:"#059669",addedBackground:"#05966920",removed:"#dc2626",removedBackground:"#dc262620",lineNumber:"#9ca3af"}}},Eh={transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},wh={metadata:bh,colors:Ah,config:Eh},Bh={id:"pichamber-dark",name:"PiChamber",description:"The PiChamber signature - soft obsidian neutral surfaces with balanced contrast, inspired by Comet (dark variant)",author:"PiChamber",version:"1.0.0",variant:"dark",tags:["dark","brand","neutral","comet"]},Ch={primary:{base:"#dcdce0",hover:"#f4f4f6",active:"#c8c8cc",foreground:"#0b0b0e",muted:"#dcdce080",emphasis:"#f4f4f6"},surface:{background:"#0f0f12",foreground:"#dcdce0",muted:"#0b0b0e",mutedForeground:"#aaaab4",elevated:"#18181d",elevatedForeground:"#dcdce0",overlay:"#000000b3",subtle:"#141418"},interactive:{border:"#29292f",borderHover:"#484853",borderFocus:"#818cf8",selection:"#ffffff24",selectionForeground:"#dcdce0",focus:"#818cf8",focusRing:"#818cf840",cursor:"#dcdce0",hover:"#ffffff0d",active:"#ffffff17"},status:{error:"#f87171",errorForeground:"#000000",errorBackground:"#f8717120",errorBorder:"#f8717145",warning:"#fbbf24",warningForeground:"#000000",warningBackground:"#fbbf2420",warningBorder:"#fbbf2445",success:"#34d399",successForeground:"#000000",successBackground:"#34d39920",successBorder:"#34d39945",info:"#818cf8",infoForeground:"#000000",infoBackground:"#818cf820",infoBorder:"#818cf845"},pr:{open:"#34d399",draft:"#aaaab4",blocked:"#fbbf24",merged:"#a5b4fc",closed:"#f87171"},syntax:{base:{background:"#0f0f12",foreground:"#dcdce0",comment:"#868693",keyword:"#a5b4fc",string:"#8fd4b0",number:"#e5c07b",function:"#a5b4fc",variable:"#dcdce0",type:"#e5c07b",operator:"#dcdce0"},tokens:{commentDoc:"#868693",stringEscape:"#f472b6",keywordImport:"#f472b6",storageModifier:"#a5b4fc",functionCall:"#a5b4fc",method:"#a5b4fc",variableProperty:"#dcdce0",variableOther:"#dcdce0",variableGlobal:"#8fd4b0",variableLocal:"#dcdce0",parameter:"#dcdce0",constant:"#8fd4b0",class:"#e5c07b",className:"#e5c07b",interface:"#e5c07b",struct:"#e5c07b",enum:"#e5c07b",typeParameter:"#e5c07b",namespace:"#e5c07b",module:"#f472b6",tag:"#f472b6",jsxTag:"#f472b6",tagAttribute:"#e5c07b",tagAttributeValue:"#8fd4b0",boolean:"#e5c07b",decorator:"#a5b4fc",label:"#e5c07b",punctuation:"#aaaab4",macro:"#f472b6",preprocessor:"#f472b6",regex:"#8fd4b0",url:"#a5b4fc",key:"#e5c07b",exception:"#f87171"},highlights:{diffAdded:"#34d399",diffAddedBackground:"#34d3991c",diffRemoved:"#f87171",diffRemovedBackground:"#f871711c",diffModified:"#818cf8",diffModifiedBackground:"#818cf81c",lineNumber:"#74747e",lineNumberActive:"#dcdce0"}},markdown:{heading1:"#dcdce0",heading2:"#dcdce0",heading3:"#dcdce0",heading4:"#dcdce0",link:"#818cf8",linkHover:"#a5b4fc",inlineCode:"#a5b4fc",inlineCodeBackground:"#818cf81f",blockquote:"#aaaab4",blockquoteBorder:"#222228",listMarker:"#818cf880"},chat:{userMessage:"#dcdce0",userMessageBackground:"#18181d",assistantMessage:"#dcdce0",assistantMessageBackground:"#0f0f12",timestamp:"#8a8a95",divider:"#222228"},tools:{background:"#18181d80",border:"#222228",headerHover:"#ffffff0d",icon:"#aaaab4",title:"#dcdce0",description:"#8a8a95",edit:{added:"#34d399",addedBackground:"#34d39920",removed:"#f87171",removedBackground:"#f8717120",lineNumber:"#666671"}}},vh={transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},kh={metadata:Bh,colors:Ch,config:vh},lc=Hr(gh),Dh=Hr(yh),Sh=Hr(wh),Mh=Hr(kh),uc="pichamber-light",fc="pichamber-dark",Sn=[Sh,Mh,lc,Dh,...lh.filter(e=>e.metadata.id!=="pichamber-light"&&e.metadata.id!=="pichamber-dark"&&e.metadata.id!=="pichamber-light"&&e.metadata.id!=="pichamber-dark")];function Th(e){const t=e==="app-light"||e==="pichamber-light"?"pichamber-light":e==="app-dark"||e==="pichamber-dark"?"pichamber-dark":e;return Sn.find(r=>r.metadata.id===t)}function rA(e){const t=e?"dark":"light",o=Th(e?fc:uc);return o&&o.metadata.variant===t?o:Sn.find(n=>n.metadata.variant===t)??Sn[0]??lc}const Ph=[{id:"finder",label:"Finder",appName:"Finder"},{id:"terminal",label:"Terminal",appName:"Terminal"},{id:"iterm2",label:"iTerm2",appName:"iTerm"},{id:"ghostty",label:"Ghostty",appName:"Ghostty"},{id:"vscode",label:"VS Code",appName:"Visual Studio Code"},{id:"vscode-insiders",label:"VS Code Insiders",appName:"Visual Studio Code - Insiders"},{id:"intellij",label:"IntelliJ",appName:"IntelliJ IDEA"},{id:"visual-studio",label:"Visual Studio",appName:"Visual Studio"},{id:"cursor",label:"Cursor",appName:"Cursor"},{id:"android-studio",label:"Android Studio",appName:"Android Studio"},{id:"pycharm",label:"PyCharm",appName:"PyCharm"},{id:"xcode",label:"Xcode",appName:"Xcode"},{id:"sublime-text",label:"Sublime",appName:"Sublime Text"},{id:"webstorm",label:"WebStorm",appName:"WebStorm"},{id:"rider",label:"Rider",appName:"Rider"},{id:"zed",label:"Zed",appName:"Zed"},{id:"phpstorm",label:"PhpStorm",appName:"PhpStorm"},{id:"eclipse",label:"Eclipse",appName:"Eclipse"},{id:"windsurf",label:"Windsurf",appName:"Windsurf"},{id:"vscodium",label:"VSCodium",appName:"VSCodium"},{id:"rustrover",label:"RustRover",appName:"RustRover"},{id:"kiro",label:"Kiro",appName:"Kiro"},{id:"antigravity",label:"Antigravity",appName:"Antigravity"},{id:"trae",label:"Trae",appName:"Trae"}],Rh="finder",oA=new Set(["finder","terminal"]),Ih=e=>{if(typeof window>"u")return e;const t=window.__PICHAMBER_PLATFORM__;if(e.id==="finder"){if(t==="win32")return{...e,label:"Explorer",appName:"File Explorer"};if(t==="linux")return{...e,label:"File Manager"}}return e},nA=e=>{if(!e)return null;const t=Ph.find(r=>r.id===e)??null;return t?Ih(t):null},_h=e=>{if(!Array.isArray(e))return;const t=[],r=new Set;for(const o of e){if(!o||typeof o!="object")continue;const n=o,a=typeof n.id=="string"?n.id.trim():"",s=typeof n.label=="string"?n.label.trim():"",i=typeof n.source=="string"?n.source.trim():"",c=typeof n.subpath=="string"?n.subpath.trim():"";!a||!s||!i||r.has(a)||(r.add(a),t.push({id:a,label:s,source:i,...c?{subpath:c}:{}}))}return t},xh=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[r,o]of Object.entries(e)){const n=typeof r=="string"?r.trim():"",a=typeof o=="string"?o.trim():"";!n||!a||(t[n]=a)}return t},Mn=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(t=>typeof t=="string"&&t.length>0)))},Oh=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[r,o]of Object.entries(e)){if(!r||!Array.isArray(o))continue;const n=Mn(o);n&&n.length>0&&(t[r]=n.slice(0,5))}return Object.keys(t).length>0?t:void 0},Nh=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,Lh=e=>{if(typeof e!="string")return null;const t=e.trim();return t&&Nh.test(t)?t.toLowerCase():null},Uh=e=>{if(!Array.isArray(e))return;const t=[],r=new Set,o=new Set;for(const n of e){if(!n||typeof n!="object")continue;const a=n,s=typeof a.path=="string"?a.path.trim():"";if(!s)continue;const i=s==="/"?s:s.replace(/\\/g,"/").replace(/\/+$/,"");if(!i)continue;const c=hm(i);if(!c||r.has(c)||o.has(i))continue;r.add(c),o.add(i);const d={id:c,path:i};if(typeof a.label=="string"&&a.label.trim().length>0&&(d.label=a.label.trim()),typeof a.icon=="string"&&a.icon.trim().length>0&&(d.icon=a.icon.trim()),a.iconImage===null)d.iconImage=null;else if(a.iconImage&&typeof a.iconImage=="object"){const l=a.iconImage,u=typeof l.mime=="string"?l.mime.trim():"",f=typeof l.updatedAt=="number"&&Number.isFinite(l.updatedAt)?Math.max(0,Math.round(l.updatedAt)):0,m=l.source==="custom"||l.source==="auto"?l.source:null;u&&f>0&&m&&(d.iconImage={mime:u,updatedAt:f,source:m})}if(typeof a.color=="string"&&a.color.trim().length>0&&(d.color=a.color.trim()),a.iconBackground===null)d.iconBackground=null;else{const l=Lh(a.iconBackground);l&&(d.iconBackground=l)}typeof a.addedAt=="number"&&Number.isFinite(a.addedAt)&&a.addedAt>=0&&(d.addedAt=a.addedAt),typeof a.lastOpenedAt=="number"&&Number.isFinite(a.lastOpenedAt)&&a.lastOpenedAt>=0&&(d.lastOpenedAt=a.lastOpenedAt),typeof a.sidebarCollapsed=="boolean"&&(d.sidebarCollapsed=a.sidebarCollapsed),t.push(d)}return t.length>0?t:void 0},Hh=e=>{if(!Array.isArray(e))return;const t=[],r=new Set,o=new Set;for(const n of e){if(!n||typeof n!="object")continue;const a=n,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.name=="string"?a.name.trim():"",c=typeof a.hostname=="string"?a.hostname.trim().toLowerCase():"";!s||!i||!c||r.has(s)||o.has(c)||(r.add(s),o.add(c),t.push({id:s,name:i,hostname:c}))}return t},Kh=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,r={};for(const[o,n]of Object.entries(t)){const a=o.trim(),s=typeof n=="string"?n.trim():"";!a||!s||(r[a]=s)}return Object.keys(r).length>0?r:void 0},sn=(e,t)=>{if(!Array.isArray(e))return;const r=[],o=new Set;for(const n of e){if(!n||typeof n!="object")continue;const a=n,s=typeof a.providerID=="string"?a.providerID.trim():"",i=typeof a.modelID=="string"?a.modelID.trim():"";if(!s||!i)continue;const c=`${s}/${i}`;if(!o.has(c)&&(o.add(c),r.push({providerID:s,modelID:i}),r.length>=t))break}return r},jh=e=>{const t=ie.getInitialState();return{useSystemTheme:!0,lightThemeId:uc,darkThemeId:fc,openInAppId:Rh,autoDeleteEnabled:t.autoDeleteEnabled,autoSaveEnabled:t.autoSaveEnabled,autoDeleteAfterDays:t.autoDeleteAfterDays,sessionRetentionAction:t.sessionRetentionAction,followUpBehavior:Pa,showDeletionDialog:t.showDeletionDialog,nativeNotificationsEnabled:t.nativeNotificationsEnabled,notificationMode:t.notificationMode,notifyOnCompletion:t.notifyOnCompletion,notifyOnError:t.notifyOnError,notifyOnInputNeeded:t.notifyOnInputNeeded,summarizeLastMessage:t.summarizeLastMessage,summaryThreshold:t.summaryThreshold,summaryLength:t.summaryLength,maxLastMessageLength:t.maxLastMessageLength,timeFormatPreference:t.timeFormatPreference,weekStartPreference:t.weekStartPreference,sidebarViewMode:t.sidebarViewMode,sessionAutoArchiveAfterDays:t.sessionAutoArchiveAfterDays,sessionAutoDeleteAfterDays:t.sessionAutoDeleteAfterDays,expandedEditorToolbar:t.expandedEditorToolbar,wrapLinesByDefault:t.wrapLinesByDefault,draftStartersVisible:t.draftStartersVisible,fontSize:t.fontSize,terminalFontSize:t.terminalFontSize,terminalShell:t.terminalShell,terminalLoginShells:t.terminalLoginShells,editorFontSize:t.editorFontSize,uiFont:t.uiFont,monoFont:t.monoFont,padding:t.padding,cornerRadius:t.cornerRadius,inputBarOffset:t.inputBarOffset,shortcutOverrides:t.shortcutOverrides,mobileKeyboardMode:"resize-content",favoriteModels:t.favoriteModels,hiddenModels:t.hiddenModels,collapsedModelProviders:t.collapsedModelProviders,recentModels:t.recentModels,recentAgents:t.recentAgents,recentEfforts:t.recentEfforts,diffLayoutPreference:t.diffLayoutPreference,gitChangesViewMode:t.gitChangesViewMode,filesViewShowGitignored:!1,...e}},$h=(e,t)=>{const r=Object.entries(e),o=Object.entries(t);return r.length!==o.length?!1:r.every(([n,a])=>t[n]===a)},zh=(e,t)=>e.length===t.length&&e.every((r,o)=>{const n=t[o];return!!n&&r.id===n?.id&&r.label===n.label&&r.command===n.command&&r.args===n.args&&r.combo===n.combo}),cn=(e,t)=>e.length===t.length&&e.every((r,o)=>r.providerID===t[o]?.providerID&&r.modelID===t[o]?.modelID),Tn=(e,t)=>e.length===t.length&&e.every((r,o)=>r===t[o]),qh=(e,t)=>{const r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>Array.isArray(t[o])&&Tn(e[o],t[o]))},Pn=e=>{if(!e||typeof e!="object")return null;const t=e,r={};typeof t.themeId=="string"&&t.themeId.length>0&&(r.themeId=t.themeId),(t.useSystemTheme===!0||t.useSystemTheme===!1)&&(r.useSystemTheme=t.useSystemTheme),typeof t.themeVariant=="string"&&(t.themeVariant==="light"||t.themeVariant==="dark")&&(r.themeVariant=t.themeVariant),typeof t.lightThemeId=="string"&&t.lightThemeId.length>0&&(r.lightThemeId=t.lightThemeId),typeof t.darkThemeId=="string"&&t.darkThemeId.length>0&&(r.darkThemeId=t.darkThemeId),typeof t.lastDirectory=="string"&&t.lastDirectory.length>0&&(r.lastDirectory=t.lastDirectory),typeof t.homeDirectory=="string"&&t.homeDirectory.length>0&&(r.homeDirectory=t.homeDirectory),typeof t.desktopLanAccessEnabled=="boolean"&&(r.desktopLanAccessEnabled=t.desktopLanAccessEnabled),typeof t.desktopKeepAwakeEnabled=="boolean"&&(r.desktopKeepAwakeEnabled=t.desktopKeepAwakeEnabled),typeof t.desktopProcessPerformanceRecordingEnabled=="boolean"&&(r.desktopProcessPerformanceRecordingEnabled=t.desktopProcessPerformanceRecordingEnabled),typeof t.desktopMinimizeToTrayEnabled=="boolean"&&(r.desktopMinimizeToTrayEnabled=t.desktopMinimizeToTrayEnabled),typeof t.desktopMacMenuBarEnabled=="boolean"&&(r.desktopMacMenuBarEnabled=t.desktopMacMenuBarEnabled),(t.desktopUpdateChannel==="stable"||t.desktopUpdateChannel==="rc")&&(r.desktopUpdateChannel=t.desktopUpdateChannel),(t.serverUpdateChannel==="stable"||t.serverUpdateChannel==="rc")&&(r.serverUpdateChannel=t.serverUpdateChannel);const o=Uh(t.projects);if(o&&(r.projects=o),typeof t.activeProjectId=="string"&&t.activeProjectId.length>0&&(r.activeProjectId=t.activeProjectId),Array.isArray(t.securityScopedBookmarks)&&(r.securityScopedBookmarks=t.securityScopedBookmarks.filter(p=>typeof p=="string"&&p.length>0)),Array.isArray(t.pinnedDirectories)&&(r.pinnedDirectories=Array.from(new Set(t.pinnedDirectories.filter(p=>typeof p=="string"&&p.length>0)))),Array.isArray(t.draftStarters)&&(r.draftStarters=Ca(t.draftStarters)),typeof t.draftStartersVisible=="boolean"&&(r.draftStartersVisible=t.draftStartersVisible),typeof t.draftStartersScheduleTaskAdded=="boolean"&&(r.draftStartersScheduleTaskAdded=t.draftStartersScheduleTaskAdded),typeof t.autoDeleteEnabled=="boolean"&&(r.autoDeleteEnabled=t.autoDeleteEnabled),typeof t.autoSaveEnabled=="boolean"&&(r.autoSaveEnabled=t.autoSaveEnabled),typeof t.autoDeleteAfterDays=="number"&&Number.isFinite(t.autoDeleteAfterDays)&&(r.autoDeleteAfterDays=t.autoDeleteAfterDays),(t.sessionRetentionAction==="archive"||t.sessionRetentionAction==="delete")&&(r.sessionRetentionAction=t.sessionRetentionAction),typeof t.tunnelProvider=="string"){const p=t.tunnelProvider.trim().toLowerCase();p.length>0&&(r.tunnelProvider=p)}if(typeof t.tunnelMode=="string"){const p=t.tunnelMode.trim().toLowerCase();(p==="managed-remote"||p==="managed-local")&&(r.tunnelMode=p)}if(t.tunnelBootstrapTtlMs===null?r.tunnelBootstrapTtlMs=null:typeof t.tunnelBootstrapTtlMs=="number"&&Number.isFinite(t.tunnelBootstrapTtlMs)&&(r.tunnelBootstrapTtlMs=t.tunnelBootstrapTtlMs),typeof t.tunnelSessionTtlMs=="number"&&Number.isFinite(t.tunnelSessionTtlMs)&&(r.tunnelSessionTtlMs=t.tunnelSessionTtlMs),t.managedLocalTunnelConfigPath===null)r.managedLocalTunnelConfigPath=null;else if(typeof t.managedLocalTunnelConfigPath=="string"){const p=t.managedLocalTunnelConfigPath.trim();r.managedLocalTunnelConfigPath=p.length>0?p:null}typeof t.managedRemoteTunnelHostname=="string"&&(r.managedRemoteTunnelHostname=t.managedRemoteTunnelHostname.trim()),t.managedRemoteTunnelToken===null?r.managedRemoteTunnelToken=null:typeof t.managedRemoteTunnelToken=="string"&&(r.managedRemoteTunnelToken=t.managedRemoteTunnelToken.trim());const n=Hh(t.managedRemoteTunnelPresets);if(n&&(r.managedRemoteTunnelPresets=n),typeof t.managedRemoteTunnelSelectedPresetId=="string"){const p=t.managedRemoteTunnelSelectedPresetId.trim();r.managedRemoteTunnelSelectedPresetId=p.length>0?p:void 0}const a=Kh(t.managedRemoteTunnelPresetTokens);if(a&&(r.managedRemoteTunnelPresetTokens=a),typeof t.defaultModel=="string"&&t.defaultModel.length>0&&(r.defaultModel=t.defaultModel),typeof t.defaultVariant=="string"&&t.defaultVariant.length>0&&(r.defaultVariant=t.defaultVariant),typeof t.smallModelUseDefault=="boolean"&&(r.smallModelUseDefault=t.smallModelUseDefault),typeof t.smallModelOverride=="string"&&t.smallModelOverride.length>0&&(r.smallModelOverride=t.smallModelOverride),typeof t.walkthroughModelOverride=="string"&&t.walkthroughModelOverride.length>0&&(r.walkthroughModelOverride=t.walkthroughModelOverride),typeof t.autoCreateWorktree=="boolean"&&(r.autoCreateWorktree=t.autoCreateWorktree),Ra(t.followUpBehavior)?r.followUpBehavior=t.followUpBehavior:typeof t.queueModeEnabled=="boolean"&&(r.followUpBehavior=Ia(void 0,t.queueModeEnabled)),typeof t.showDeletionDialog=="boolean"&&(r.showDeletionDialog=t.showDeletionDialog),typeof t.nativeNotificationsEnabled=="boolean"&&(r.nativeNotificationsEnabled=t.nativeNotificationsEnabled),typeof t.notificationMode=="string"&&(t.notificationMode==="always"||t.notificationMode==="hidden-only")&&(r.notificationMode=t.notificationMode),typeof t.notifyOnCompletion=="boolean"&&(r.notifyOnCompletion=t.notifyOnCompletion),typeof t.notifyOnError=="boolean"&&(r.notifyOnError=t.notifyOnError),typeof t.notifyOnInputNeeded=="boolean"&&(r.notifyOnInputNeeded=t.notifyOnInputNeeded),typeof t.summarizeLastMessage=="boolean"&&(r.summarizeLastMessage=t.summarizeLastMessage),typeof t.summaryThreshold=="number"&&Number.isFinite(t.summaryThreshold)&&(r.summaryThreshold=Math.max(0,Math.round(t.summaryThreshold))),typeof t.summaryLength=="number"&&Number.isFinite(t.summaryLength)&&(r.summaryLength=Math.max(10,Math.round(t.summaryLength))),typeof t.maxLastMessageLength=="number"&&Number.isFinite(t.maxLastMessageLength)&&(r.maxLastMessageLength=Math.max(10,Math.round(t.maxLastMessageLength))),typeof t.usageAutoRefresh=="boolean"&&(r.usageAutoRefresh=t.usageAutoRefresh),typeof t.usageRefreshIntervalMs=="number"&&Number.isFinite(t.usageRefreshIntervalMs)&&(r.usageRefreshIntervalMs=t.usageRefreshIntervalMs),(t.usageDisplayMode==="usage"||t.usageDisplayMode==="remaining")&&(r.usageDisplayMode=t.usageDisplayMode),typeof t.usageShowPredValues=="boolean"&&(r.usageShowPredValues=t.usageShowPredValues),Array.isArray(t.usageDropdownProviders)&&(r.usageDropdownProviders=t.usageDropdownProviders.filter(p=>typeof p=="string"&&p.length>0)),t.usageSelectedModels&&typeof t.usageSelectedModels=="object"){const p={};for(const[k,A]of Object.entries(t.usageSelectedModels))Array.isArray(A)&&(p[k]=A.filter(C=>typeof C=="string"));Object.keys(p).length>0&&(r.usageSelectedModels=p)}if(t.usageCollapsedFamilies&&typeof t.usageCollapsedFamilies=="object"){const p={};for(const[k,A]of Object.entries(t.usageCollapsedFamilies))Array.isArray(A)&&(p[k]=A.filter(C=>typeof C=="string"));Object.keys(p).length>0&&(r.usageCollapsedFamilies=p)}if(t.usageExpandedFamilies&&typeof t.usageExpandedFamilies=="object"){const p={};for(const[k,A]of Object.entries(t.usageExpandedFamilies))Array.isArray(A)&&(p[k]=A.filter(C=>typeof C=="string"));Object.keys(p).length>0&&(r.usageExpandedFamilies=p)}if(t.usageModelGroups&&typeof t.usageModelGroups=="object"){const p={};for(const[k,A]of Object.entries(t.usageModelGroups))if(A&&typeof A=="object"){const C=A,w={};Array.isArray(C.customGroups)&&(w.customGroups=C.customGroups.filter(B=>B&&typeof B=="object").map(B=>({id:String(B.id??""),label:String(B.label??""),models:Array.isArray(B.models)?B.models.filter(P=>typeof P=="string"):[],order:typeof B.order=="number"?B.order:0}))),C.modelAssignments&&typeof C.modelAssignments=="object"&&(w.modelAssignments=Object.fromEntries(Object.entries(C.modelAssignments).filter(([,B])=>typeof B=="string").map(([B,P])=>[B,String(P)]))),C.renamedGroups&&typeof C.renamedGroups=="object"&&(w.renamedGroups=Object.fromEntries(Object.entries(C.renamedGroups).filter(([,B])=>typeof B=="string").map(([B,P])=>[B,String(P)]))),Object.keys(w).length>0&&(p[k]=w)}Object.keys(p).length>0&&(r.usageModelGroups=p)}typeof t.timeFormatPreference=="string"&&(t.timeFormatPreference==="auto"||t.timeFormatPreference==="12h"||t.timeFormatPreference==="24h")&&(r.timeFormatPreference=t.timeFormatPreference),typeof t.weekStartPreference=="string"&&(t.weekStartPreference==="auto"||t.weekStartPreference==="sunday"||t.weekStartPreference==="monday")&&(r.weekStartPreference=t.weekStartPreference),Xi(t.sidebarViewMode)&&(r.sidebarViewMode=t.sidebarViewMode);const s=t.sidebarAutoSettleAfterDays;if(typeof s=="number"&&Number.isInteger(s)&&s>=0&&s<=90&&(r.sidebarAutoSettleAfterDays=s),Vt(t.sessionAutoArchiveAfterDays)&&(r.sessionAutoArchiveAfterDays=t.sessionAutoArchiveAfterDays),Vt(t.sessionAutoDeleteAfterDays)&&(r.sessionAutoDeleteAfterDays=t.sessionAutoDeleteAfterDays),typeof t.expandedEditorToolbar=="boolean"&&(r.expandedEditorToolbar=t.expandedEditorToolbar),typeof t.wrapLinesByDefault=="boolean"&&(r.wrapLinesByDefault=t.wrapLinesByDefault),typeof t.fontSize=="number"&&Number.isFinite(t.fontSize)&&(r.fontSize=t.fontSize),typeof t.terminalFontSize=="number"&&Number.isFinite(t.terminalFontSize)&&(r.terminalFontSize=t.terminalFontSize),wo(t.terminalShell)&&(r.terminalShell=t.terminalShell),Array.isArray(t.terminalLoginShells)&&(r.terminalLoginShells=[...new Set(t.terminalLoginShells.filter(wo))]),typeof t.editorFontSize=="number"&&Number.isFinite(t.editorFontSize)&&(r.editorFontSize=t.editorFontSize),Vi(t.uiFont)&&(r.uiFont=t.uiFont),Ji(t.monoFont)&&(r.monoFont=t.monoFont),typeof t.padding=="number"&&Number.isFinite(t.padding)&&(r.padding=t.padding),typeof t.cornerRadius=="number"&&Number.isFinite(t.cornerRadius)&&(r.cornerRadius=t.cornerRadius),typeof t.inputBarOffset=="number"&&Number.isFinite(t.inputBarOffset)&&(r.inputBarOffset=t.inputBarOffset),typeof t.openInAppId=="string"&&t.openInAppId.length>0&&(r.openInAppId=t.openInAppId),typeof t.pwaAppName=="string"){const p=Yi(t.pwaAppName,"");r.pwaAppName=p.length>0?p:""}typeof t.mobileKeyboardMode=="string"&&(t.mobileKeyboardMode==="native"||t.mobileKeyboardMode==="resize-content")&&(r.mobileKeyboardMode=t.mobileKeyboardMode);const i=xh(t.shortcutOverrides);i&&(r.shortcutOverrides=i);const c=mm(t.commandTriggers);c&&(r.commandTriggers=c);const d=sn(t.favoriteModels,50);d&&(r.favoriteModels=d);const l=sn(t.hiddenModels,1e4);l&&(r.hiddenModels=l);const u=Mn(t.collapsedModelProviders);u&&(r.collapsedModelProviders=u);const f=sn(t.recentModels,10);f&&(r.recentModels=f);const m=Mn(t.recentAgents);m&&(r.recentAgents=m.slice(0,10));const g=Oh(t.recentEfforts);g&&(r.recentEfforts=g),typeof t.diffLayoutPreference=="string"&&(t.diffLayoutPreference==="dynamic"||t.diffLayoutPreference==="inline"||t.diffLayoutPreference==="side-by-side")&&(r.diffLayoutPreference=t.diffLayoutPreference),typeof t.gitChangesViewMode=="string"&&(t.gitChangesViewMode==="flat"||t.gitChangesViewMode==="tree")&&(r.gitChangesViewMode=t.gitChangesViewMode),typeof t.filesViewShowGitignored=="boolean"&&(r.filesViewShowGitignored=t.filesViewShowGitignored);const h=_h(t.skillCatalogs);return h&&(r.skillCatalogs=h),Object.keys(r).length>0?r:null},mc="filesViewShowGitignored",Rn="files-view-show-gitignored-change",xs=()=>{if(typeof window>"u")return!1;try{return Ur().getItem(mc)==="true"}catch{return!1}},Gh=()=>{typeof window>"u"||window.dispatchEvent(new Event(Rn))},Wh=(e,t={})=>{if(!(typeof window>"u")){try{Ur().setItem(mc,e?"true":"false"),Gh()}catch{}t.persist!==!1&&Ke({filesViewShowGitignored:e})}},aA=()=>{const[e,t]=qa.useState(xs);return qa.useEffect(()=>{if(typeof window>"u")return;const r=()=>{t(xs())};return window.addEventListener("storage",r),window.addEventListener(Rn,r),()=>{window.removeEventListener("storage",r),window.removeEventListener(Rn,r)}},[]),e},gc=e=>{if(!e||typeof e!="object")return!1;const t=e;return t.status===401||t.response?.status===401?!0:typeof t.message=="string"&&/(?:ui )?authentication required|unauthorized|\b401\b/i.test(t.message)},In=e=>{const t=ie.getState(),r=tm.getState();if(typeof e.autoDeleteEnabled=="boolean"&&e.autoDeleteEnabled!==t.autoDeleteEnabled&&t.setAutoDeleteEnabled(e.autoDeleteEnabled),typeof e.autoSaveEnabled=="boolean"&&e.autoSaveEnabled!==t.autoSaveEnabled&&t.setAutoSaveEnabled(e.autoSaveEnabled),typeof e.autoDeleteAfterDays=="number"&&Number.isFinite(e.autoDeleteAfterDays)){const n=Math.max(1,Math.min(365,e.autoDeleteAfterDays));n!==t.autoDeleteAfterDays&&t.setAutoDeleteAfterDays(n)}(e.sessionRetentionAction==="archive"||e.sessionRetentionAction==="delete")&&e.sessionRetentionAction!==t.sessionRetentionAction&&t.setSessionRetentionAction(e.sessionRetentionAction);let o=null;if(Ra(e.followUpBehavior)?o=e.followUpBehavior:typeof e.queueModeEnabled=="boolean"&&(o=Ia(void 0,e.queueModeEnabled)),o&&o!==r.followUpBehavior&&r.setFollowUpBehavior(o),typeof e.showDeletionDialog=="boolean"&&e.showDeletionDialog!==t.showDeletionDialog&&t.setShowDeletionDialog(e.showDeletionDialog),typeof e.nativeNotificationsEnabled=="boolean"&&e.nativeNotificationsEnabled!==t.nativeNotificationsEnabled&&t.setNativeNotificationsEnabled(e.nativeNotificationsEnabled),typeof e.notificationMode=="string"&&(e.notificationMode==="always"||e.notificationMode==="hidden-only")&&e.notificationMode!==t.notificationMode&&t.setNotificationMode(e.notificationMode),typeof e.notifyOnCompletion=="boolean"&&e.notifyOnCompletion!==t.notifyOnCompletion&&t.setNotifyOnCompletion(e.notifyOnCompletion),typeof e.notifyOnError=="boolean"&&e.notifyOnError!==t.notifyOnError&&t.setNotifyOnError(e.notifyOnError),typeof e.notifyOnInputNeeded=="boolean"&&e.notifyOnInputNeeded!==t.notifyOnInputNeeded&&t.setNotifyOnInputNeeded(e.notifyOnInputNeeded),typeof e.summarizeLastMessage=="boolean"&&e.summarizeLastMessage!==t.summarizeLastMessage&&t.setSummarizeLastMessage(e.summarizeLastMessage),typeof e.summaryThreshold=="number"&&Number.isFinite(e.summaryThreshold)&&t.setSummaryThreshold(e.summaryThreshold),typeof e.summaryLength=="number"&&Number.isFinite(e.summaryLength)&&t.setSummaryLength(e.summaryLength),typeof e.maxLastMessageLength=="number"&&Number.isFinite(e.maxLastMessageLength)&&t.setMaxLastMessageLength(e.maxLastMessageLength),typeof e.timeFormatPreference=="string"&&(e.timeFormatPreference==="auto"||e.timeFormatPreference==="12h"||e.timeFormatPreference==="24h")&&e.timeFormatPreference!==t.timeFormatPreference&&t.setTimeFormatPreference(e.timeFormatPreference),typeof e.weekStartPreference=="string"&&(e.weekStartPreference==="auto"||e.weekStartPreference==="sunday"||e.weekStartPreference==="monday")&&e.weekStartPreference!==t.weekStartPreference&&t.setWeekStartPreference(e.weekStartPreference),Xi(e.sidebarViewMode)&&e.sidebarViewMode!==t.sidebarViewMode&&t.setSidebarViewMode(e.sidebarViewMode),Vt(e.sessionAutoArchiveAfterDays)&&e.sessionAutoArchiveAfterDays!==t.sessionAutoArchiveAfterDays&&t.setSessionAutoArchiveAfterDays(e.sessionAutoArchiveAfterDays),Vt(e.sessionAutoDeleteAfterDays)&&e.sessionAutoDeleteAfterDays!==t.sessionAutoDeleteAfterDays&&t.setSessionAutoDeleteAfterDays(e.sessionAutoDeleteAfterDays),typeof e.expandedEditorToolbar=="boolean"&&e.expandedEditorToolbar!==t.expandedEditorToolbar&&t.setExpandedEditorToolbar(e.expandedEditorToolbar),typeof e.wrapLinesByDefault=="boolean"&&e.wrapLinesByDefault!==t.wrapLinesByDefault&&t.setWrapLinesByDefault(e.wrapLinesByDefault),typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)&&e.fontSize!==t.fontSize&&t.setFontSize(e.fontSize),Array.isArray(e.draftStarters)){const n=Ca(e.draftStarters);JSON.stringify(t.globalDraftStarters)!==JSON.stringify(n)&&t.setGlobalDraftStarters(n),e.draftStarters=n}if(delete e.draftStartersScheduleTaskAdded,typeof e.draftStartersVisible=="boolean"&&e.draftStartersVisible!==t.draftStartersVisible&&t.setDraftStartersVisible(e.draftStartersVisible),typeof e.terminalFontSize=="number"&&Number.isFinite(e.terminalFontSize)&&e.terminalFontSize!==t.terminalFontSize&&t.setTerminalFontSize(e.terminalFontSize),wo(e.terminalShell)&&e.terminalShell!==t.terminalShell&&t.setTerminalShell(e.terminalShell),Array.isArray(e.terminalLoginShells)&&(e.terminalLoginShells.length!==t.terminalLoginShells.length||e.terminalLoginShells.some((n,a)=>n!==t.terminalLoginShells[a]))&&t.setTerminalLoginShells(e.terminalLoginShells),typeof e.editorFontSize=="number"&&Number.isFinite(e.editorFontSize)&&e.editorFontSize!==t.editorFontSize&&t.setEditorFontSize(e.editorFontSize),Vi(e.uiFont)&&e.uiFont!==t.uiFont&&t.setUiFont(e.uiFont),Ji(e.monoFont)&&e.monoFont!==t.monoFont&&t.setMonoFont(e.monoFont),typeof e.padding=="number"&&Number.isFinite(e.padding)&&e.padding!==t.padding&&t.setPadding(e.padding),typeof e.cornerRadius=="number"&&Number.isFinite(e.cornerRadius)&&e.cornerRadius!==t.cornerRadius&&t.setCornerRadius(e.cornerRadius),typeof e.inputBarOffset=="number"&&Number.isFinite(e.inputBarOffset)&&e.inputBarOffset!==t.inputBarOffset&&t.setInputBarOffset(e.inputBarOffset),e.shortcutOverrides&&!$h(e.shortcutOverrides,t.shortcutOverrides)&&ie.setState({shortcutOverrides:e.shortcutOverrides}),e.commandTriggers&&!zh(e.commandTriggers,t.commandTriggers)&&ie.setState({commandTriggers:e.commandTriggers}),typeof e.mobileKeyboardMode=="string"){const n=va(e.mobileKeyboardMode,t.mobileKeyboardMode);n!==t.mobileKeyboardMode&&t.setMobileKeyboardMode(n)}if(Array.isArray(e.favoriteModels)){const n=t.favoriteModels,a=e.favoriteModels;cn(n,a)||ie.setState({favoriteModels:a})}if(Array.isArray(e.hiddenModels)){const n=t.hiddenModels,a=e.hiddenModels;cn(n,a)||ie.setState({hiddenModels:a})}if(Array.isArray(e.collapsedModelProviders)){const n=t.collapsedModelProviders,a=e.collapsedModelProviders;Tn(n,a)||ie.setState({collapsedModelProviders:a})}if(Array.isArray(e.recentModels)){const n=t.recentModels,a=e.recentModels;cn(n,a)||ie.setState({recentModels:a})}if(Array.isArray(e.recentAgents)){const n=t.recentAgents,a=e.recentAgents;Tn(n,a)||ie.setState({recentAgents:a})}if(e.recentEfforts&&typeof e.recentEfforts=="object"){const n=t.recentEfforts,a=e.recentEfforts;qh(n,a)||ie.setState({recentEfforts:a})}typeof e.diffLayoutPreference=="string"&&(e.diffLayoutPreference==="dynamic"||e.diffLayoutPreference==="inline"||e.diffLayoutPreference==="side-by-side")&&e.diffLayoutPreference!==t.diffLayoutPreference&&t.setDiffLayoutPreference(e.diffLayoutPreference),typeof e.gitChangesViewMode=="string"&&(e.gitChangesViewMode==="flat"||e.gitChangesViewMode==="tree")&&e.gitChangesViewMode!==t.gitChangesViewMode&&t.setGitChangesViewMode(e.gitChangesViewMode),typeof e.filesViewShowGitignored=="boolean"&&Wh(e.filesViewShowGitignored,{persist:!1})},Vh=()=>{const e=ie.persist;if(e&&typeof e=="object")return e},pc=()=>ma()?.settings??null;let _a=0,he=null,nt=null,He=null,Re=null,zt=null,Te=null,_n=[],Os=!1;const Jh=3e4,Yh=200,Xh=5e3;let xn=0,On=0,Nn=0,it=null,lo=[],Oo=!1;const Qh=3e3;let Ln=!1;const eo=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Un=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((r,o)=>Un(r,t[o]));if(eo(e)||eo(t)){if(!eo(e)||!eo(t))return!1;const r=Object.entries(e).filter(([,n])=>n!==void 0),o=Object.entries(t).filter(([,n])=>n!==void 0);return r.length===o.length&&r.every(([n,a])=>{if(!Object.prototype.hasOwnProperty.call(t,n))return!1;const s=t[n];return s!==void 0&&Un(a,s)})}return!1},hc=e=>JSON.parse(JSON.stringify(e)),Zh=e=>{const t={...it??{}};for(const[r,o]of Object.entries(e))if(o===void 0)delete t[r];else{const n=JSON.stringify(o);t[r]=n===void 0?o:JSON.parse(n)}it=t},eF=(e,t)=>{if(!it||lo.some(o=>Object.prototype.hasOwnProperty.call(o,e)))return!1;const r=it;return Object.prototype.hasOwnProperty.call(r,e)?Un(t,r[e]):t===void 0},tF=e=>{const t={};for(const[r,o]of Object.entries(e))eF(r,o)||(t[r]=o);return t},er=()=>({runtimeKey:D(),generation:_a}),Yt=(e,t)=>e.runtimeKey===t.runtimeKey&&e.generation===t.generation,Q=e=>e.generation===_a&&e.runtimeKey===D(),xa=()=>{Os||typeof window>"u"||(Os=!0,ll(e=>{e.runtimeKey!==e.previousRuntimeKey&&(Te&&clearTimeout(Te),Re&&Br({skipInitialLoadGate:!0}))}),Ti(e=>{e.runtimeKey!==e.previousRuntimeKey&&(_a+=1,he=null,nt=null,He=null,it=null,Oo=!1)}))},Fc=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null,Oa=async(e=er())=>{if(xa(),he&&Yt(he.context,e)&&Date.now()-he.at<Jh)return he.value;if(He&&Yt(He.context,e))return He.promise;Ln=!0;const t=Nn,r=(n,a)=>{Oo=!0,t===Nn&&(he={value:n,at:Date.now(),context:e},nt={value:Fc(a),context:e},n&&(it=hc(n)))},o={context:e,promise:(async()=>{const n=pc();if(n)try{const a=await n.load();if(!Q(e))return null;const s=Pn(a.settings);return r(s,a.settings),s}catch(a){if(!Q(e)||gc(a))return null;console.warn("Failed to load shared settings from runtime settings API:",a)}if(!Q(e))return null;try{const a=await b("/api/pi/ui-settings",{method:"GET",headers:{Accept:"application/json"}});if(!Q(e)||!a.ok)return null;const s=await a.json().catch(()=>null);if(!Q(e))return null;const i=Pn(s);return r(i,s),i}catch(a){return Q(e)&&console.warn("Failed to load shared settings from server:",a),null}})()};return He=o,Ln=!1,o.promise.finally(()=>{He===o&&(He=null)}),o.promise},sA=async()=>{const e=er();return await Oa(e)&&nt&&Yt(nt.context,e)?nt.value:null},rF=e=>{const t=e.draftStartersScheduleTaskAdded!==!0,r=Array.isArray(e.draftStarters)&&e.draftStarters.some(o=>{if(!o||typeof o!="object")return!1;const n=o.type;return n!=="prompt"&&n!=="text"});return!t&&!r?{}:{...Array.isArray(e.draftStarters)?{draftStarters:Ca(e.draftStarters)}:{},draftStartersScheduleTaskAdded:!0}},yc=async e=>{if(typeof window>"u")return;xa();const t=er(),r=xn,o=()=>e==="refresh"&&(r!==xn||Re!==null),n=Vh(),a=()=>!n?.hasHydrated||n.hasHydrated()||!n.onFinishHydration?Promise.resolve():new Promise(i=>{let c=!1;const d=()=>{c||(c=!0,i())},l=n.onFinishHydration(()=>{l?.(),d()});n.hasHydrated?.()&&d()}),s=async i=>{if(!Q(t)||o())return;const c=typeof i.autoSaveEnabled!="boolean",d=t.runtimeKey==="local"&&typeof i.autoDeleteEnabled!="boolean",l=t.runtimeKey==="local"&&typeof i.autoDeleteAfterDays!="number",u=t.runtimeKey==="local"&&i.sessionRetentionAction!=="archive"&&i.sessionRetentionAction!=="delete",f=jh(i);if(e==="refresh")delete f.activeProjectId;else try{Jf(i)}catch(h){console.warn("persistToLocalStorage failed:",h)}if(await a(),!Q(t)||o())return;const m=ie.getState();c&&(f.autoSaveEnabled=m.autoSaveEnabled),d&&(f.autoDeleteEnabled=m.autoDeleteEnabled),l&&(f.autoDeleteAfterDays=m.autoDeleteAfterDays),u&&(f.sessionRetentionAction=m.sessionRetentionAction),i.draftStarters===void 0&&ie.setState({globalDraftStarters:null});try{In(f)}catch(h){console.warn("applyDesktopUiPreferences failed:",h)}const g=rF(i);c&&(g.autoSaveEnabled=f.autoSaveEnabled),d&&(g.autoDeleteEnabled=f.autoDeleteEnabled),l&&(g.autoDeleteAfterDays=f.autoDeleteAfterDays),u&&(g.sessionRetentionAction=f.sessionRetentionAction),!(Object.keys(g).length>0&&(await Ke(g),!Q(t)))&&Dn(f)};try{const i=await Oa(t);i&&Q(t)&&await s(i)}catch(i){console.warn("Failed to synchronise settings:",i)}},iA=()=>yc("load"),cA=async()=>{if(typeof window>"u"||Re!==null||On>0)return;const e=er();he&&Yt(he.context,e)&&Date.now()-he.at<Xh||(he=null,nt=null,await yc("refresh"))},oF=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),dn=(e,t,r)=>{if(Nn+=1,oF(e)){it=hc(e),he={value:Pn(e),at:Date.now(),context:r},nt={value:Fc(e),context:r},Oo=!0;return}Zh(t),he=null,nt=null},nF=async e=>{const t=new Promise(r=>{setTimeout(()=>r(null),Qh)});await Promise.race([Oa(e).then(()=>{}),t])};async function Br(e={}){On+=1;try{await aF(e)}finally{On-=1}}async function aF(e){if(!e.skipInitialLoadGate&&Re&&Object.keys(Re).length>0&&!it&&!Ln){const a=zt??er(),s=!!He&&Yt(He.context,a);Q(a)&&(s||!Oo)&&await nF(a)}const t=Re,r=zt,o=_n;Re=null,zt=null,Te=null,_n=[];let n=null;try{if(!t||!r||Object.keys(t).length===0||!Q(r)){ye("saved");return}const a=tF(t);if(Object.keys(a).length===0){ye("saved");return}n=a,lo.push(a);const s=pc();if(s)try{const i=await s.save(a);if(!Q(r))return;i&&(dn(i,a,r),In(i),Dn(i)),ye(i?"saved":"error");return}catch(i){if(!Q(r))return;if(gc(i)){ye("error");return}console.warn("Failed to update settings via runtime settings API:",i)}if(!Q(r))return;try{const i=await b("/api/pi/ui-settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(a)});if(!Q(r))return;if(!i.ok){console.warn("Failed to update shared settings via API:",i.status,i.statusText),ye("error");return}const c=await i.json().catch(()=>null);if(!Q(r))return;c?(dn(c,a,r),In(c),Dn(c),ye("saved")):(dn(c,a,r),ye("error"))}catch(i){Q(r)&&(console.warn("Failed to update shared settings via API:",i),ye("error"))}}finally{n&&(lo=lo.filter(a=>a!==n)),o.forEach(a=>a())}}const Ke=async(e,t={})=>{if(typeof window>"u")return;xa();const r=er();zt&&!Yt(zt,r)&&(Te&&clearTimeout(Te),Br({skipInitialLoadGate:!0})),xn+=1,Re={...Re??{},...e},zt=r,ye("saving"),Te&&clearTimeout(Te);const o=new Promise(n=>{_n.push(n)});return t.immediate?Br({skipInitialLoadGate:!0}):Te=setTimeout(()=>{Br()},Yh),o},dA=()=>{Re!==null&&(Te&&clearTimeout(Te),Br({skipInitialLoadGate:!0}))},sF=3e4,iF=40,cF=60,dF=(e,t,r,o,n,a,s)=>{const i=t.trim(),c=r.trim().toLowerCase();return JSON.stringify([e,i,c,o,n,a,s])},Ns=(e,t)=>{try{const r=JSON.parse(e);return Array.isArray(r)&&r[1]===t}catch{return!1}},lF=Ir()(_r((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(r,o,n=cF,a){if(!r||r.trim().length===0)return[];const s=r.trim(),i=D(),c=typeof o=="string"?o.trim():"",d=!!a?.includeHidden,l=a?.respectGitignore??!0,u=a?.type==="directory"?"directory":"file",f=dF(i,s,c,n,d,l,u),m=Date.now(),g=t().cache[f];if(g&&m-g.timestamp<sF)return g.files;const h=t().inFlight[f];if(h)return h;const p=Yu(c,{directory:s,limit:n,includeHidden:d,respectGitignore:l,type:u}).then(k=>(e(A=>{if(A.inFlight[f]!==p)return A;const C={...A.cache,[f]:{files:k,timestamp:Date.now()}},w=A.cacheKeys.filter(B=>B!==f);for(w.push(f);w.length>iF;){const B=w.shift();B&&delete C[B]}return{cache:C,cacheKeys:w}}),k)).finally(()=>{e(k=>{if(k.inFlight[f]!==p)return k;const A={...k.inFlight};return delete A[f],{inFlight:A}})});return e(k=>({inFlight:{...k.inFlight,[f]:p}})),p},invalidateDirectory(r){if(!r||r.trim().length===0){e({cache:{},cacheKeys:[],inFlight:{}});return}const o=r.trim();e(n=>{const a={...n.cache},s=n.cacheKeys.filter(d=>Ns(d,o)?(delete a[d],!1):!0),i=Object.entries(n.inFlight).filter(([d])=>!Ns(d,o)),c=Object.fromEntries(i);return{cache:a,cacheKeys:s,inFlight:c}})},resetForRuntimeSwitch(){e({cache:{},cacheKeys:[],inFlight:{}})}}),{name:"file-search-store"})),Hn="pichamber_perf_hud",Kn=new Set,uF=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Hn)==="1"}catch{return!1}};let jn=uF(),Ls=!1;const fF=()=>{for(const e of Kn)e()},bc=()=>jn,lA=e=>(Kn.add(e),()=>{Kn.delete(e)}),Us=e=>{const t=jn!==e;if(jn=e,typeof window<"u")try{e?window.localStorage.setItem(Hn,"1"):window.localStorage.removeItem(Hn)}catch{}t&&fF()},mF=e=>{if(typeof window>"u"&&e===void 0)return!1;const r=new URLSearchParams(window.location.search).get("perf");return r==="1"?(Us(!0),!0):r==="0"?(Us(!1),!0):!1},uA=e=>Ls?!1:(Ls=!0,mF(e)),gF=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem("pichamber_stream_debug")==="1"}catch{return!1}},$n="pichamber_stream_perf",pF=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem($n)==="1"}catch{return!1}};let Ac=pF();const No=()=>Ac||bc(),Hs=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),Ec=()=>{if(!No()||typeof window>"u")return null;if(!window.__pichamberStreamPerfState){const e=Date.now();window.__pichamberStreamPerfState={counters:new Map,startedAt:e,lastUpdatedAt:e}}return window.__pichamberStreamPerfState},hF=e=>Array.from(e.entries()).map(([t,r])=>({metric:t,count:r.count,avg:r.count>0?Number((r.total/r.count).toFixed(3)):0,max:Number(r.max.toFixed(3)),total:Number(r.total.toFixed(3)),last:Number(r.last.toFixed(3))})).sort((t,r)=>r.total-t.total||r.count-t.count),Na=(e,t)=>{const r=Ec();if(!r)return;const o=r.counters.get(e)??{count:0,total:0,max:0,last:0};o.count+=1,o.total+=t,o.max=Math.max(o.max,t),o.last=t,r.counters.set(e,o),r.lastUpdatedAt=Date.now()},FF=e=>{if(Ac=e,!(typeof window>"u"))try{if(e){window.localStorage.setItem($n,"1"),window.__pichamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem($n),bc()||delete window.__pichamberStreamPerfState}catch{}},yF=()=>{typeof window>"u"||No()&&(window.__pichamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()})},bF=()=>{if(typeof window>"u")return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};const e=Ec();return e?{enabled:!0,startedAt:e.startedAt,lastUpdatedAt:e.lastUpdatedAt,durationMs:Math.max(0,Date.now()-e.startedAt),entries:hF(e.counters)}:{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]}},fA=(e,t=1)=>{Na(e,t)},mA=(e,t)=>{Na(e,t)},gA=e=>{!No()||typeof performance>"u"||typeof performance.mark!="function"||performance.mark(`pichamber.${e}`)},pA=(e,t)=>{if(!No())return t();const r=Hs();try{return t()}finally{Na(e,Hs()-r)}};typeof window<"u"&&(window.__pichamberStreamPerformance={setEnabled:FF,reset:yF,getSnapshot:bF});var AF={};let ge=null,At=0;const fe=Ur(),Ks=fe.getItem("lastDirectory"),EF=typeof Ks=="string"&&Ks.length>0,pr=e=>{try{lF.getState().invalidateDirectory(e)}catch(t){console.warn("Failed to invalidate file search cache:",t)}},Pr=e=>{const t=e.trim();if(!t)return t;const r=t.replace(/\\/g,"/").replace(/^([a-z]):/,(o,n)=>n.toUpperCase()+":");return r.length>1?r.replace(/\/+$/,""):r},wF=(e,t)=>{const r=e.trim();return r.startsWith("~")?r==="~"?t||r:(r.startsWith("~/")||r.startsWith("~\\"))&&t?`${t}${r.slice(1)}`:r:r},uo=(e,t)=>{const r=wF(e,t);return Pr(r)},BF=()=>{const e=fe.getItem("homeDirectory");if(typeof e!="string"||e.trim().length===0)return null;const t=Pr(e);return t.length>0?t:null},CF=()=>{const e=fe.getItem("lastDirectory");if(typeof e!="string"||e.trim().length===0)return null;const t=Pr(e);return t.length>0?t:null},vF=()=>{if(typeof process>"u")return null;const e=AF,t=e?.HOME||e?.USERPROFILE||(e?.HOMEDRIVE&&e?.HOMEPATH?`${e.HOMEDRIVE}${e.HOMEPATH}`:void 0);if(typeof t=="string"&&t.trim().length>0){const o=Pr(t);return o.length>0?o:null}const r=process?.cwd?.();if(typeof r=="string"&&r.trim().length>0){const o=Pr(r);return o.length>0?o:null}return null},Co=()=>{if(typeof window<"u"){if(ge)return ge;const t=ce()&&typeof window.__PICHAMBER_HOME__=="string"&&window.__PICHAMBER_HOME__.length>0?window.__PICHAMBER_HOME__:null;if(t&&t.length>0)return ge=t,fe.setItem("homeDirectory",t),t;const r=ce()?BF():null;if(r)return ge=r,r}const e=!we()||ce()?vF():null;return e||"/"},kF=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const r=t.replace(/\\/g,"/");if(r.length>1){const o=r.replace(/\/+$/,"");if(o&&o.length>0)return o==="/"?null:o}return r==="/"||r.length===0?null:r},DF=e=>(ge=e,typeof window<"u"&&fe.setItem("homeDirectory",e),Ke({homeDirectory:e}),e),zn=async(e=At)=>{const t=n=>{if(e!==At)return null;const a=kF(n);return a?DF(a):null};try{const n=await Wu(),a=t(n);if(a)return a}catch(n){console.warn("Failed to obtain filesystem home directory:",n)}if(ce())try{const n=await pl(),a=t(n);if(a)return a}catch(n){console.warn("Failed to obtain desktop-integrated home directory:",n)}const r=Co(),o=t(r);return o||r},Rr=Co(),vo=(()=>{const e=CF();return e?uo(e,Rr):Rr})();vo&&bt.setDirectory(vo);const SF=!!(Rr&&Rr!=="/"),qn=Ir()(_r((e,t)=>({currentDirectory:vo,directoryHistory:[vo],historyIndex:0,homeDirectory:Rr,hasPersistedDirectory:EF,isHomeReady:SF,isSwitchingDirectory:!1,setDirectory:(r,o)=>{const n=ge||t().homeDirectory||fe.getItem("homeDirectory"),a=uo(r,n);gF()&&console.log("[DirectoryStore] setDirectory called with path:",a),bt.setDirectory(a),pr(),e(s=>{const i=[...s.directoryHistory.slice(0,s.historyIndex+1),a];return fe.setItem("lastDirectory",a),Ke({lastDirectory:a}),{currentDirectory:a,directoryHistory:i,historyIndex:i.length-1,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1}})},goBack:()=>{const r=t();if(r.historyIndex>0){const o=r.historyIndex-1,n=r.directoryHistory[o];bt.setDirectory(n),pr(),fe.setItem("lastDirectory",n),Ke({lastDirectory:n}),e({currentDirectory:n,historyIndex:o,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goForward:()=>{const r=t();if(r.historyIndex<r.directoryHistory.length-1){const o=r.historyIndex+1,n=r.directoryHistory[o];bt.setDirectory(n),pr(),fe.setItem("lastDirectory",n),Ke({lastDirectory:n}),e({currentDirectory:n,historyIndex:o,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goToParent:()=>{const{currentDirectory:r,setDirectory:o}=t(),n=ge||t().homeDirectory||Co();if(r===n||r==="/")return;const a=r.endsWith("/")?r.slice(0,-1):r,s=a.lastIndexOf("/");if(s===-1){const i=ge||Co();o(i)}else o(s===0?"/":a.substring(0,s))},goHome:async()=>{const r=ge||t().homeDirectory||await zn();t().setDirectory(r)},resetForRuntimeSwitch:()=>{ge=null,At+=1,fe.removeItem("lastDirectory"),fe.removeItem("homeDirectory"),pr(),bt.setDirectory(""),e({currentDirectory:"",directoryHistory:[],historyIndex:-1,homeDirectory:"",hasPersistedDirectory:!1,isHomeReady:!1,isSwitchingDirectory:!1})},synchronizeHomeDirectory:r=>{const o=t(),n=r;ge=n;const a=o.homeDirectory!==n,s=fe.getItem("lastDirectory"),i=typeof s=="string"&&s.length>0,c=!i&&(o.currentDirectory==="/"||o.currentDirectory===o.homeDirectory||!o.currentDirectory);if(!a&&!c){o.isHomeReady||e({isHomeReady:!0});return}const d=typeof n=="string"&&n!==""&&n!=="/",l=o.currentDirectory?uo(o.currentDirectory,n):o.currentDirectory,u=o.directoryHistory.map(h=>uo(h,n)),f=u.some((h,p)=>h!==o.directoryHistory[p]),m=!!(l&&l!==o.currentDirectory),g={homeDirectory:n,hasPersistedDirectory:i,isHomeReady:d};if(c?(g.currentDirectory=n,g.directoryHistory=[n],g.historyIndex=0,g.isSwitchingDirectory=!1):(m||f)&&(g.currentDirectory=l,g.directoryHistory=u,g.historyIndex=Math.min(o.historyIndex,u.length-1),g.isSwitchingDirectory=!1),e(()=>g),(c||m)&&d){const h=c?n:l;bt.setDirectory(h),pr(),fe.setItem("lastDirectory",h),Ke({lastDirectory:h})}Ke({homeDirectory:n})}}),{name:"directory-store"}));if(typeof window<"u"){const e=At;zn(e).then(t=>{e===At&&qn.getState().synchronizeHomeDirectory(t)}),Ti(()=>{ge=null;const t=++At;zn().then(r=>{t===At&&qn.getState().synchronizeHomeDirectory(r)})})}const wc=1,js=512*1024,MF=0,Je=1,TF=45e3,PF=1e4,RF=15e3,La=new TextEncoder,Bc=new TextDecoder,to=()=>typeof document<"u"&&document.visibilityState==="hidden"||typeof navigator<"u"&&!navigator.onLine,IF=e=>{const t=La.encode(JSON.stringify(e)),r=new Uint8Array(t.length+1);return r[0]=wc,r.set(t,1),r},_F=async e=>{let t;if(e instanceof ArrayBuffer)t=new Uint8Array(e);else if(e instanceof Uint8Array)t=e;else if(typeof Blob<"u"&&e instanceof Blob)t=new Uint8Array(await e.arrayBuffer());else if(typeof e=="string")t=La.encode(e);else return null;t[0]===wc&&(t=t.subarray(1));try{return JSON.parse(Bc.decode(t))}catch{return null}},Ua=async(e,t)=>{const r=await e.json().catch(()=>null);return new Error(typeof r?.error=="string"?r.error:t)},xF=e=>{const t=La.encode(e);if(t.byteLength<=js)return e;let r=t.byteLength-js;for(;r<t.byteLength&&(t[r]&192)===128;)r+=1;return Bc.decode(t.subarray(r))};class Cc{constructor(t={refreshAuth:Lr,openSocket:r=>Ki(Ie().websocket("/api/terminal/ws",void 0,r)),clearUrlAuthToken:Nr}){this.dependencies=t,this.installPersistentListeners()}dependencies;socket=null;opening=null;subscribers=new Map;projections=new Map;reconnectTimer=null;keepaliveTimer=null;pongDeadlineTimer=null;idleCloseTimer=null;failures=0;persistentListenersInstalled=!1;generation=0;disposed=!1;subscribe(t,r){this.cancelIdleClose();const o={handlers:r,lastSequence:-1},n=this.subscribers.get(t)??new Set,a=n.size===0;n.add(o),this.subscribers.set(t,n);const s=this.projections.get(t);s&&(o.lastSequence=s.sequence,r.onEvent({type:"snapshot",sequence:s.sequence,data:s.history,status:s.status,exitCode:s.exitCode,signal:s.signal,runtime:s.runtime,ptyBackend:s.ptyBackend}));const i=this.socket?.readyState===Je;return this.ensureConnected().then(()=>{const c=this.subscribers.get(t);a&&i&&c===n&&c.size>0&&this.send({t:"attach",v:3,s:t})}).catch(c=>{n.has(o)&&(r.onError?.(c,!1),this.scheduleReconnect())}),()=>{const c=this.subscribers.get(t);if(c?.delete(o),c?.size===0&&(this.subscribers.delete(t),this.projections.delete(t),this.send({t:"detach",v:3,s:t})),this.subscribers.size===0){if(this.cancelReconnect(),this.failures=0,this.socket?.readyState===Je){this.scheduleIdleClose();return}this.generation+=1,this.opening=null,this.closeSocket()}}}async write(t,r){if(!r)return;const o=this.generation,n=()=>this.disposed||o!==this.generation;if(await this.ensureConnected(),n())throw new Error("Terminal runtime changed");if(!this.send({t:"write",v:3,s:t,d:r})){if(this.closeSocket(),await this.ensureConnected(),n())throw new Error("Terminal runtime changed");if(!this.send({t:"write",v:3,s:t,d:r}))throw new Error("Terminal connection is unavailable")}}dispose(){this.disposed=!0,this.generation+=1,this.opening=null,this.subscribers.clear(),this.projections.clear(),this.cancelReconnect(),this.cancelIdleClose(),this.removePersistentListeners(),this.closeSocket()}forget(t){this.projections.delete(t)}installPersistentListeners(){this.persistentListenersInstalled||(this.persistentListenersInstalled=!0,typeof window<"u"&&(window.addEventListener("pichamber:system-resume",this.handleWakeSignal),window.addEventListener("online",this.handleWakeSignal)),typeof document<"u"&&document.addEventListener("visibilitychange",this.handleWakeSignal))}removePersistentListeners(){this.persistentListenersInstalled&&(this.persistentListenersInstalled=!1,typeof window<"u"&&(window.removeEventListener("pichamber:system-resume",this.handleWakeSignal),window.removeEventListener("online",this.handleWakeSignal)),typeof document<"u"&&document.removeEventListener("visibilitychange",this.handleWakeSignal))}handleWakeSignal=()=>{if(!(this.disposed||to())){if(this.reconnectTimer!==null){this.wakeReconnect();return}this.socket?.readyState===Je&&this.sendPing()}};async ensureConnected(){if(this.disposed)throw new Error("Terminal runtime changed");if(this.socket?.readyState===Je)return;if(this.opening)return await this.opening,this.socket?.readyState===Je?void 0:this.ensureConnected();const t=this.generation,r=(async()=>{const o=await this.dependencies.refreshAuth();if(t!==this.generation||this.disposed)throw new Error("Terminal runtime changed");await new Promise((n,a)=>{let s=!1,i=!1,c=!1,d=null;const l=()=>t===this.generation&&!this.disposed&&d!==null&&this.socket===d,u=()=>{c||i||!l()||(c=!0,this.dependencies.clearUrlAuthToken?.(o))},f=g=>{s||(s=!0,clearTimeout(m),g?a(g):n())},m=setTimeout(()=>{u(),d?.close(),f(new Error("Terminal connection timed out"))},1e4);try{const g=this.dependencies.openSocket(o);d=g,g.binaryType="arraybuffer",this.socket=g,g.onopen=()=>{if(!l()){g.close(),f(new Error("Terminal runtime changed"));return}i=!0,this.failures=0,this.send({t:"hello",v:3});for(const h of this.subscribers.keys())this.send({t:"attach",v:3,s:h});this.startKeepalive(),f()},g.onmessage=h=>{this.handleMessage(h.data)},g.onerror=()=>{const h=l();h&&u(),f(new Error("Terminal WebSocket failed")),h&&this.subscribers.size>0&&this.scheduleReconnect()},g.onclose=()=>{const h=l();h&&(this.stopKeepalive(),u()),this.socket===g&&(this.socket=null),f(new Error("Terminal WebSocket closed")),h&&this.subscribers.size>0&&this.scheduleReconnect()}}catch(g){f(g instanceof Error?g:new Error("Terminal WebSocket failed")),!this.disposed&&this.subscribers.size>0&&this.scheduleReconnect()}})})();this.opening=r;try{await r}finally{this.opening===r&&(this.opening=null)}}async handleMessage(t){this.clearPongDeadline();const r=await _F(t);if(!r||r.t==="hello"||r.t==="pong")return;if(r.t==="error"){const a=new Error(typeof r.message=="string"?r.message:"Terminal error");typeof r.code=="string"&&(a.code=r.code);const s=r.s?[r.s]:[...this.subscribers.keys()];for(const i of s)for(const c of this.subscribers.get(i)??[])c.handlers.onError?.(a,r.fatal===!0);return}if(!r.s)return;const o=this.subscribers.get(r.s);if(!o)return;if(r.t==="snapshot"){const a={sequence:typeof r.q=="number"?r.q:0,history:typeof r.history=="string"?r.history:"",status:r.status,exitCode:typeof r.exitCode=="number"?r.exitCode:void 0,signal:typeof r.signal=="number"?r.signal:null,runtime:r.runtime,ptyBackend:typeof r.ptyBackend=="string"?r.ptyBackend:void 0};this.projections.set(r.s,a);for(const s of o)s.lastSequence=a.sequence,s.handlers.onEvent({type:"snapshot",sequence:a.sequence,data:a.history,status:a.status,exitCode:a.exitCode,signal:a.signal,runtime:a.runtime,ptyBackend:a.ptyBackend});return}if(typeof r.q!="number")return;const n=this.projections.get(r.s);n&&r.q>n.sequence&&(r.t==="output"?this.projections.set(r.s,{...n,sequence:r.q,history:xF(n.history+(typeof r.r=="string"?r.r:typeof r.d=="string"?r.d:""))}):r.t==="exit"?this.projections.set(r.s,{...n,sequence:r.q,status:"exited",exitCode:typeof r.exitCode=="number"?r.exitCode:void 0,signal:typeof r.signal=="number"?r.signal:null}):r.t==="restarted"&&this.projections.set(r.s,{...n,sequence:r.q,history:typeof r.history=="string"?r.history:"",status:"running",exitCode:void 0,signal:null}));for(const a of o)r.q<=a.lastSequence||(a.lastSequence=r.q,r.t==="output"?a.handlers.onEvent({type:"data",sequence:r.q,data:typeof r.d=="string"?r.d:"",replayData:typeof r.r=="string"?r.r:void 0}):r.t==="exit"?a.handlers.onEvent({type:"exit",sequence:r.q,exitCode:typeof r.exitCode=="number"?r.exitCode:void 0,signal:typeof r.signal=="number"?r.signal:null}):r.t==="restarted"&&a.handlers.onEvent({type:"snapshot",sequence:r.q,data:typeof r.history=="string"?r.history:"",status:"running"}))}send(t){if(!this.socket||this.socket.readyState!==Je)return!1;try{return this.socket.send(IF(t)),!0}catch{return!1}}sendPing(){this.disposed||!this.socket||this.socket.readyState!==Je||to()||this.pongDeadlineTimer===null&&this.send({t:"ping",v:3})&&this.armPongDeadline()}armPongDeadline(){this.clearPongDeadline(),this.pongDeadlineTimer=setTimeout(()=>{this.handlePongTimeout()},PF)}clearPongDeadline(){this.pongDeadlineTimer&&(clearTimeout(this.pongDeadlineTimer),this.pongDeadlineTimer=null)}handlePongTimeout(){this.clearPongDeadline();const t=this.socket;if(!t)return;const r=t.onclose;t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}r?.({code:4e3,reason:"terminal keepalive timeout"})}wakeReconnect(){this.disposed||to()||(this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ensureConnected().catch(()=>this.scheduleReconnect()))}scheduleReconnect(){if(this.reconnectTimer||this.disposed||this.subscribers.size===0)return;this.failures+=1;const t=to()?6e4:Math.min(500*2**Math.min(this.failures-1,10),8e3);for(const r of this.subscribers.values())for(const o of r)o.handlers.onEvent({type:"reconnecting",attempt:this.failures,maxAttempts:Number.POSITIVE_INFINITY});this.reconnectTimer=setTimeout(()=>this.wakeReconnect(),t)}scheduleIdleClose(){this.idleCloseTimer||this.disposed||(this.idleCloseTimer=setTimeout(()=>{this.idleCloseTimer=null,!(this.disposed||this.subscribers.size>0)&&(this.generation+=1,this.opening=null,this.closeSocket())},RF))}cancelIdleClose(){this.idleCloseTimer&&(clearTimeout(this.idleCloseTimer),this.idleCloseTimer=null)}startKeepalive(){this.stopKeepalive(),this.keepaliveTimer=setInterval(()=>this.sendPing(),TF)}stopKeepalive(){this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.clearPongDeadline()}cancelReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null}closeSocket(){this.stopKeepalive();const t=this.socket;this.socket=null,t&&(t.readyState===MF||t.readyState===Je)&&t.close()}}let kt=new Cc,vc=0;const Gn=new Set,hA=()=>vc,FA=e=>(Gn.add(e),()=>{Gn.delete(e)}),OF=()=>{vc+=1;for(const e of[...Gn])try{e()}catch{}};async function NF(e){const t=await b("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw await Ua(t,"Failed to create terminal session");return t.json()}async function LF(){const e=await b("/api/terminal/shells");if(!e.ok)throw await Ua(e,"Failed to list terminal shells");const t=await e.json().catch(()=>[]);return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"&&wo(r.id)&&typeof r.name=="string"&&typeof r.supportsLogin=="boolean"):[]}function UF(e,t,r){return kt.subscribe(e,{onEvent:t,onError:r})}async function HF(e,t){await kt.write(e,t)}async function Kr(e,t,r){const o={method:t};r!==void 0&&(o.headers={"Content-Type":"application/json"},o.body=JSON.stringify(r));const n=await b(e,o);if(!n.ok)throw await Ua(n,"Terminal command failed");return n}async function KF(e,t,r){await Kr(`/api/terminal/${e}/resize`,"POST",{cols:t,rows:r})}async function jF(e,t){await Kr(`/api/terminal/${e}/appearance`,"POST",t)}async function $F(e){await Kr(`/api/terminal/${e}`,"DELETE"),kt.forget(e)}async function zF(e,t){return(await Kr(`/api/terminal/${e}/restart`,"POST",t)).json()}async function qF(e){const r=await(await Kr("/api/terminal/force-kill","POST",e)).json().catch(()=>null);if(Array.isArray(r?.killedSessionIds))for(const o of r.killedSessionIds)typeof o=="string"&&kt.forget(o);else e.sessionId&&kt.forget(e.sessionId)}function yA(){kt.dispose(),kt=new Cc,OF()}const GF=()=>({async listShells(){return LF()},async createSession(e){return NF(e)},connect(e,t){const r=UF(e,t.onEvent,t.onError);return{close:()=>r()}},async sendInput(e,t){await HF(e,t)},async resize(e){await KF(e.sessionId,e.cols,e.rows)},async updateAppearance(e,t){await jF(e,t)},async close(e){await $F(e)},async restartSession(e,t){return zF(e,{cwd:t.cwd??"",cols:t.cols,rows:t.rows,themeMode:t.themeMode,terminalBackground:t.terminalBackground,terminalForeground:t.terminalForeground,shell:t.shell,loginShell:t.loginShell})},async forceKill(e){await qF(e)}}),S="/api/git",WF=1200,VF=5*6e4,JF=3e4,YF=1e4,ko=new Map,Nt=new Map,Ha=new Map,Do=new Map,Lt=new Map,Ka=new Map,So=new Map,Ut=new Map,ja=new Map,kc=e=>e.trim(),tr=(e,t)=>JSON.stringify([e,kc(t)]),Dc=(e,t,r)=>JSON.stringify([e,kc(t),r??"full"]),Wn=(e,t)=>Ha.get(tr(e,t))??0,Ee=e=>{const t=D(),r=tr(t,e);Ha.set(r,Wn(t,e)+1);for(const o of[void 0,"light"]){const n=Dc(t,e,o);ko.delete(n),Nt.delete(n)}},Vn=e=>Ka.get(e)??0,Jn=e=>ja.get(e)??0,Yn=e=>{const t=tr(D(),e);Ka.set(t,Vn(t)+1),Do.delete(t),Lt.delete(t)},Xn=e=>{const t=tr(D(),e);ja.set(t,Jn(t)+1),So.delete(t),Ut.delete(t)},bA=()=>{ko.clear(),Nt.clear(),Ha.clear(),Do.clear(),Lt.clear(),Ka.clear(),So.clear(),Ut.clear(),ja.clear()};function M(e,t,r){const o={...r};return t&&(o.directory=t),Ie().api(e,o)}async function XF(e){const t=tr(D(),e),r=Date.now(),o=Do.get(t);if(o&&o.expiresAt>r)return o.value;const n=Lt.get(t);if(n)return n;const a=(async()=>{const s=Vn(t),i=await b(M(`${S}/check`,e));if(!i.ok)throw new Error(`Failed to check git repository: ${i.statusText}`);const d=!!(await i.json()).isGitRepository;return Vn(t)===s&&Do.set(t,{value:d,expiresAt:Date.now()+(d?VF:JF)}),d})();Lt.set(t,a);try{return await a}finally{Lt.get(t)===a&&Lt.delete(t)}}async function QF(e,t){const r=t?.mode,o=D(),n=Dc(o,e,r),a=Date.now(),s=ko.get(n);if(s&&s.expiresAt>a)return s.value;const i=Nt.get(n);if(i)return i;const c=(async()=>{const d=Wn(o,e),l=await b(M(`${S}/status`,e,r?{mode:r}:void 0));if(!l.ok)throw new Error(`Failed to get git status: ${l.statusText}`);const u=await l.json();return Wn(o,e)===d&&ko.set(n,{value:u,expiresAt:Date.now()+WF}),u})();Nt.set(n,c);try{return await c}finally{Nt.get(n)===c&&Nt.delete(n)}}const jr=async(e,t)=>{const r=await e.json().catch(()=>null);return new Error(typeof r?.error=="string"&&r.error?r.error:t)};async function ZF(e){const t=tr(D(),e),r=Date.now(),o=So.get(t);if(o&&o.expiresAt>r)return o.value;const n=Ut.get(t);if(n)return n;const a=(async()=>{const s=Jn(t),i=await b(M(`${S}/worktrees`,e));if(!i.ok)throw await jr(i,"Failed to list git worktrees");const c=await i.json();if(!Array.isArray(c.worktrees))throw new Error("Git worktree response is invalid");return Jn(t)===s&&So.set(t,{value:c.worktrees,expiresAt:Date.now()+YF}),c.worktrees})();Ut.set(t,a);try{return await a}finally{Ut.get(t)===a&&Ut.delete(t)}}async function e0(e,t){const r=await b(M(`${S}/worktrees/validate`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw await jr(r,"Failed to validate git worktree");return r.json()}async function t0(e,t){const r=await b(M(`${S}/worktrees`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw await jr(r,"Failed to create git worktree");return Ee(e),Xn(e),Yn(e),r.json()}async function r0(e,t){const r=await b(M(`${S}/worktrees`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw await jr(r,"Failed to close git worktree");return Ee(e),Ee(t.directory),Xn(e),Xn(t.directory),Yn(e),Yn(t.directory),r.json()}async function o0(e){const t=await b(M(`${S}/worktrees/bootstrap-status`,e));if(!t.ok)throw await jr(t,"Failed to get git worktree bootstrap status");return t.json()}async function n0(e,t){const{path:r,staged:o,contextLines:n}=t;if(!r)throw new Error("path is required to fetch git diff");const a=t.source??(o?"staged":"unstaged"),s=await b(M(`${S}/diff`,e,{path:r,source:a,staged:a==="staged"?"true":void 0,context:n}));if(!s.ok)throw new Error(`Failed to get git diff: ${s.statusText}`);return s.json()}async function a0(e,t){const{base:r,head:o,path:n,contextLines:a}=t;if(!r||!o)throw new Error("base and head are required to fetch git range diff");const s=await b(M(`${S}/range-diff`,e,{base:r,head:o,path:n||void 0,context:a}));if(!s.ok)throw new Error(`Failed to get git range diff: ${s.statusText}`);return s.json()}async function s0(e,t){const{path:r,staged:o}=t;if(!r)throw new Error("path is required to fetch git file diff");const n=await b(M(`${S}/file-diff`,e,{path:r,staged:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get git file diff: ${n.statusText}`);return n.json()}async function i0(e,t,r){if(!t)throw new Error("path is required to revert git changes");const o=await b(M(`${S}/revert`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,scope:r?.scope})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to revert git changes")}Ee(e)}async function c0(e,t){await Sc(e,[t])}async function Sc(e,t){const r=t.map(n=>n.trim()).filter(Boolean);if(r.length===0)throw new Error("path is required to stage git changes");const o=await b(M(`${S}/stage`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to stage git changes")}Ee(e)}async function d0(e,t){await Mc(e,[t])}async function Mc(e,t){const r=t.map(n=>n.trim()).filter(Boolean);if(r.length===0)throw new Error("path is required to unstage git changes");const o=await b(M(`${S}/unstage`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to unstage git changes")}Ee(e)}async function l0(e,t,r){await $a(e,t,r,"stage")}async function u0(e,t,r){await $a(e,t,r,"unstage")}async function f0(e,t,r){await $a(e,t,r,"discard")}async function $a(e,t,r,o){if(!t)throw new Error("path is required to apply a git hunk");if(typeof r!="string"||!r.trim())throw new Error("patch is required to apply a git hunk");const n=await b(M(`${S}/apply-hunk`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,patch:r,action:o})});if(!n.ok){const a=await n.json().catch(()=>({error:n.statusText}));throw new Error(a.error||"Failed to apply git hunk")}Ee(e)}async function m0(e){const t=await b(M(`${S}/branches`,e));if(!t.ok)throw new Error(`Failed to get branches: ${t.statusText}`);return t.json()}async function g0(e,t){if(!t?.branch)throw new Error("branch is required to delete a branch");const r=await b(M(`${S}/branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete branch")}return r.json()}async function p0(e,t){if(!t?.branch)throw new Error("branch is required to delete remote branch");const r=await b(M(`${S}/remote-branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete remote branch")}return r.json()}async function h0(e,t){const r=t?.remote?.trim();if(!r)throw new Error("remote is required to remove a remote");const o=await b(M(`${S}/remotes`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to remove remote")}return o.json()}async function F0(e,t,r={}){const o=await b(M(`${S}/commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,addAll:r.addAll??!1,files:r.files,stageFiles:r.stageFiles})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to create commit")}const n=await o.json();return Ee(e),n}async function y0(e,t={}){const r=await b(M(`${S}/push`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to push")}const o=await r.json();return Ee(e),o}async function b0(e,t={}){const r=await b(M(`${S}/pull`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to pull")}const o=await r.json();return Ee(e),o}async function A0(e,t={}){const r=await b(M(`${S}/fetch`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to fetch")}const o=await r.json();return Ee(e),o}async function E0(e){const t=await b(M(`${S}/stashes`,e));if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to list stashes")}return t.json()}async function w0(e,t){const r=await b(M(`${S}/stashes/file-counts`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refs:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to count stash files")}return r.json()}async function Tc(e,t={}){const r=await b(M(`${S}/stash`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to stash changes")}return r.json()}const za=async(e,t,r)=>{const o=await b(M(`${S}/${t}`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||`Failed to ${t}`)}return o.json()},B0=(e,t)=>za(e,"stash/apply",t),Pc=(e,t)=>za(e,"stash/pop",t),C0=(e,t)=>za(e,"stash/drop",t);async function v0(e,t,r){const o=await b(M(`${S}/checkout`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t,...r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText})),a=new Error(n.error||"Failed to checkout branch");throw typeof n.code=="string"&&(a.code=n.code),(typeof n.currentBranch=="string"||n.currentBranch===null)&&(a.currentBranch=n.currentBranch),a}return o.json()}async function k0(e,t,r){const o=await b(M(`${S}/branches`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,startPoint:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create branch")}return o.json()}async function D0(e,t,r){const o=await b(M(`${S}/branches/rename`,e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:t,newName:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to rename branch")}return o.json()}async function S0(e,t={}){const r=await b(M(`${S}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file,all:t.all?"true":void 0}));if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(`Failed to get git log: ${o.error||r.statusText}`)}return r.json()}async function M0(e,t){const r=await b(M(`${S}/commit-files`,e,{hash:t}));if(!r.ok)throw new Error(`Failed to get commit files: ${r.statusText}`);return r.json()}async function AA(e,t,r,o){const n=await b(M(`${S}/commit-file-diff`,e,{hash:t,path:r,binary:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get commit file diff: ${n.statusText}`);return n.json()}async function T0(e,t){return await Tc(e,{message:t?.message}),{success:!0}}async function P0(e){return await Pc(e,{ref:"stash@{0}"}),{success:!0}}async function R0(e){const t=await b(M(`${S}/remotes`,e));if(!t.ok)throw new Error(`Failed to get remotes: ${t.statusText}`);return t.json()}async function I0(e,t){const r=await b(M(`${S}/rebase`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to rebase")}return r.json()}async function _0(e){const t=await b(M(`${S}/rebase/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort rebase")}return t.json()}async function x0(e,t){const r=await b(M(`${S}/merge`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to merge")}return r.json()}async function O0(e,t){const r=await b(M(`${S}/checkout-commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to checkout commit")}return r.json()}async function N0(e,t){const r=await b(M(`${S}/cherry-pick`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to cherry-pick")}return r.json()}async function L0(e,t){const r=await b(M(`${S}/revert-commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to revert commit")}return r.json()}async function U0(e,t,r,o){const n=await b(M(`${S}/reset-to-commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t,mode:r,force:o})});if(!n.ok){const a=await n.json().catch(()=>({error:n.statusText}));throw new Error(a.error||"Failed to reset")}return n.json()}async function H0(e){const t=await b(M(`${S}/merge/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort merge")}return t.json()}async function K0(e){const t=await b(M(`${S}/rebase/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue rebase")}return t.json()}async function j0(e){const t=await b(M(`${S}/merge/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue merge")}return t.json()}async function $0(e){const t=await b(M(`${S}/conflict-details`,e));if(!t.ok)throw new Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}const z0=()=>({checkIsGitRepository:XF,getGitStatus:QF,getGitDiff:n0,getGitFileDiff:s0,getGitRangeDiff:a0,revertGitFile:i0,stageGitFile:c0,stageGitFiles:Sc,unstageGitFile:d0,unstageGitFiles:Mc,stageGitHunk:l0,unstageGitHunk:u0,revertGitHunk:f0,getGitBranches:m0,listGitWorktrees:ZF,validateGitWorktree:e0,createGitWorktree:t0,deleteGitWorktree:r0,getGitWorktreeBootstrapStatus:o0,deleteGitBranch:g0,deleteRemoteBranch:p0,removeRemote:h0,createGitCommit(e,t,r){return F0(e,t,r)},gitPush:y0,gitPull:b0,gitFetch:A0,listGitStashes:E0,countGitStashFiles:w0,stashGitChanges:Tc,applyGitStash:B0,popGitStash:Pc,dropGitStash:C0,checkoutBranch:v0,createBranch:k0,renameBranch:D0,getGitLog(e,t){return S0(e,t)},getCommitFiles:M0,getRemotes:R0,rebase:I0,abortRebase:_0,continueRebase:K0,merge:x0,abortMerge:H0,continueMerge:j0,checkoutCommit:O0,cherryPick:N0,revertCommit:L0,resetToCommit:U0,stash:T0,stashPop:P0,getConflictDetails:$0});class q0 extends Error{body;status;constructor(t,r){super(t.kind==="failed"?t.message:t.kind),this.name="GitHubAPIError",this.body=t,this.status=r}}const _="/api/github",G0=(e,t)=>{if(e&&typeof e=="object"&&"error"in e){const r=e.error;if(r&&typeof r.kind=="string")return r}return{kind:"failed",message:`GitHub request failed (HTTP ${t}).`}},x=async(e,t)=>{const r=await b(e,t),o=await r.json().catch(()=>null);if(!r.ok||o&&typeof o=="object"&&"error"in o)throw new q0(G0(o,r.status),r.status);return o},ke=(e,t,r)=>({query:{directory:e,repo:t,...r}}),W0=()=>({status:()=>x(`${_}/status`),scope:e=>x(`${_}/scope`,{query:{directory:e}}),pullsList:(e,t,r={})=>x(`${_}/pulls`,{query:{directory:e,repo:t,...r.state?{state:r.state}:{},...r.filter?{filter:r.filter}:{},...r.q?{q:r.q}:{},...r.cursor?{cursor:r.cursor}:{},...r.sort?{sort:r.sort}:{},...r.perPage!=null?{perPage:String(r.perPage)}:{}}}),pullGet:(e,t,r)=>x(`${_}/pulls/${r}`,ke(e,t)),pullFiles:(e,t,r,o)=>x(`${_}/pulls/${r}/files`,ke(e,t,o?{cursor:o}:{})),pullChecks:(e,t,r,o)=>x(`${_}/pulls/${r}/checks`,ke(e,t,o?{details:"full"}:{})),prStatus:(e,t)=>x(`${_}/pr-status`,{query:t?{directory:e,branch:t}:{directory:e}}),pullCreate:e=>x(`${_}/pulls`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),pullAction:(e,t,r,o)=>x(`${_}/pulls/${r}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,action:o})}),pullUpdate:(e,t,r,o)=>x(`${_}/pulls/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...o})}),pullComment:(e,t,r,o)=>x(`${_}/pulls/${r}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,body:o})}),pullComments:(e,t,r,o)=>x(`${_}/pulls/${r}/comments`,ke(e,t,o?{cursor:o}:{})),pullReview:(e,t,r,o)=>x(`${_}/pulls/${r}/reviews`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...o})}),pullThread:(e,t,r,o,n)=>x(`${_}/pulls/${r}/threads/${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...n})}),pullCheckout:(e,t,r,o="worktree")=>x(`${_}/pulls/${r}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,mode:o})}),issuesList:(e,t,r={})=>x(`${_}/issues`,{query:{directory:e,repo:t,...r.state?{state:r.state}:{},...r.filter?{filter:r.filter}:{},...r.q?{q:r.q}:{},...r.labels?{labels:r.labels}:{},...r.cursor?{cursor:r.cursor}:{},...r.sort?{sort:r.sort}:{},...r.perPage!=null?{perPage:String(r.perPage)}:{}}}),issueGet:(e,t,r)=>x(`${_}/issues/${r}`,ke(e,t)),issueComments:(e,t,r,o)=>x(`${_}/issues/${r}/comments`,ke(e,t,o?{cursor:o}:{})),issueCreate:(e,t,r)=>x(`${_}/issues`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...r})}),issueUpdate:(e,t,r,o)=>x(`${_}/issues/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...o})}),issueComment:(e,t,r,o)=>x(`${_}/issues/${r}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,body:o})}),repoMeta:(e,t,r)=>x(`${_}/meta`,ke(e,t,r?.length?{kinds:r.join(",")}:{})),issueTemplates:(e,t)=>x(`${_}/templates`,ke(e,t)),checkJobs:(e,t,r,o)=>x(`${_}/checks/jobs`,ke(e,t,{...r!=null?{runId:String(r)}:{},...o!=null?{jobId:String(o)}:{}})),checkAnnotations:(e,t,r)=>x(`${_}/checks/annotations`,ke(e,t,{checkRunId:String(r)})),checksRerun:(e,t,r)=>x(`${_}/checks/rerun`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,runId:r})}),agentContext:(e,t,r,o,n)=>x(`${_}/context`,{query:{directory:e,repo:t,type:r,number:String(o),...n?.ref?{ref:n.ref}:{},...n?.includeDiff?{includeDiff:"true"}:{}}}),invalidate:e=>x(`${_}/invalidate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})});class Lo extends Error{reason;status;constructor(t,r={}){super(t),this.name="FilesystemError",this.reason=r.reason??"unknown",this.status=r.status}}class Rc extends Lo{currentRevision;exists;filePath;constructor(t,r={}){super(t,{reason:"file-revision-conflict",status:r.status??409}),this.name="FileRevisionConflictError",this.currentRevision=r.currentRevision??null,this.exists=r.exists??r.currentRevision!=null,this.filePath=r.path??""}}const EA=e=>e instanceof Rc||V0(e)&&e.reason==="file-revision-conflict",V0=e=>e instanceof Lo||!!(e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"),$s=e=>{switch(e){case"os-permission":case"not-found":case"not-directory":case"invalid-response":case"file-revision-conflict":return e;default:return"unknown"}},oe=e=>e.replace(/\\/g,"/"),J0=(e,t)=>{if(!t||!Array.isArray(t.entries))throw new Lo("Directory listing returned an invalid response",{reason:"invalid-response"});return{directory:oe(t?.directory||t?.path||e),entries:t.entries.filter(o=>!!(o&&typeof o.name=="string"&&typeof o.path=="string")).map(o=>({name:o.name,path:oe(o.path),isDirectory:!!o.isDirectory}))}},De=(e,t)=>{const r=t||e?.();return r?{"x-pichamber-directory":r}:void 0},Y0=({getDirectory:e})=>({async listDirectory(t,r){const o=oe(t),n=new URLSearchParams;o&&n.set("path",o),r?.respectGitignore&&n.set("respectGitignore","true");const a=await b("/api/fs/list",{query:n,headers:De(e)});if(!a.ok){const i=await a.json().catch(()=>({error:a.statusText}));throw new Lo(i.error||"Failed to list directory",{reason:$s(i.reason),status:a.status})}const s=await a.json();return J0(o,s)},async search(t){const r=new URLSearchParams,o=oe(t.directory);o&&r.set("directory",o),r.set("query",t.query),r.set("dirs","false"),r.set("type","file"),typeof t.maxResults=="number"&&Number.isFinite(t.maxResults)&&r.set("limit",String(t.maxResults));const n=await b("/api/find/file",{query:r,headers:De(e)});if(!n.ok){const i=await n.json().catch(()=>({error:n.statusText}));throw new Error(i.error||"Failed to search files")}const a=await n.json();return(Array.isArray(a)?a:[]).map(i=>({path:oe(`${o}/${i}`),preview:[oe(i)]}))},async createDirectory(t){const r=oe(t),o=await b("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({path:r})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to create directory")}const n=await o.json();return{success:!!n?.success,path:typeof n?.path=="string"?oe(n.path):r}},async statFile(t,r){const o=oe(t),n=new URLSearchParams({path:o});r?.allowOutsideWorkspace&&n.set("allowOutsideWorkspace","true"),r?.outsideFileGrant&&n.set("outsideFileGrant",r.outsideFileGrant),typeof r?.knownRevision=="string"&&r.knownRevision.length>0&&n.set("knownRevision",r.knownRevision);const a=await b("/api/fs/stat",{query:n,headers:De(e,r?.directory)});if(!a.ok){const c=await a.json().catch(()=>({error:a.statusText}));throw new Error(c.error||"Failed to stat file")}const s=await a.json().catch(()=>({})),i=s.exists!==!1;return{path:typeof s.path=="string"?oe(s.path):o,isFile:!!s.isFile,size:typeof s.size=="number"?s.size:0,mtimeMs:typeof s.mtimeMs=="number"?s.mtimeMs:void 0,revision:typeof s.revision=="string"?s.revision:i?void 0:null,exists:i}},async readFile(t,r){const o=oe(t),n=new URLSearchParams({path:o});r?.allowOutsideWorkspace&&n.set("allowOutsideWorkspace","true"),r?.outsideFileGrant&&n.set("outsideFileGrant",r.outsideFileGrant),r?.optional&&n.set("optional","true");const a=await b("/api/fs/read",{query:n,cache:r?.optional?"no-store":"default",headers:De(e,r?.directory)});if(!a.ok){const u=await a.json().catch(()=>({error:a.statusText}));throw new Error(u.error||"Failed to read file")}const s=await a.text(),i=a.headers?.get?.("x-pichamber-file-revision"),d=a.headers?.get?.("x-pichamber-file-exists")!=="false",l=typeof i=="string"&&i.length>0?i:d?void 0:null;return{content:s,path:o,revision:l,exists:d}},async writeFile(t,r,o){const n=oe(t),a={path:n,content:r};o&&"expectedRevision"in o&&(a.expectedRevision=o.expectedRevision??null),o?.overwrite===!0&&(a.overwrite=!0);const s=await b("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify(a)});if(!s.ok){const c=await s.json().catch(()=>({error:s.statusText}));throw s.status===409&&$s(c.reason)==="file-revision-conflict"?new Rc(c.error||"File has changed on disk",{currentRevision:typeof c.currentRevision=="string"?c.currentRevision:null,exists:typeof c.exists=="boolean"?c.exists:void 0,path:typeof c.path=="string"?c.path:n,status:s.status}):new Error(c.error||"Failed to write file")}const i=await s.json().catch(()=>({}));return{success:!!i.success,path:typeof i.path=="string"?oe(i.path):n,revision:typeof i.revision=="string"?i.revision:void 0,noop:!!i.noop||void 0}},async delete(t){const r=oe(t),o=await b("/api/fs/delete",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({path:r})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to delete file")}return{success:!!(await o.json().catch(()=>({}))).success}},async rename(t,r){const o=await b("/api/fs/rename",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({oldPath:t,newPath:r})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to rename file")}const n=await o.json().catch(()=>({}));return{success:!!n.success,path:typeof n.path=="string"?oe(n.path):r}},async revealPath(t){const r=await b("/api/fs/reveal",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({path:oe(t)})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to reveal path")}return{success:!!(await r.json().catch(()=>({}))).success}},async downloadFile(t){const r=oe(t),o=await b("/api/fs/raw",{query:{path:r,download:!0},headers:De(e)});if(!o.ok)throw new Error(`Download failed (${o.status})`);const n=await o.blob(),a=URL.createObjectURL(n),s=document.createElement("a");s.href=a,s.download=r.split("/").pop()||"file",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(a),100)}}),zs="/api/pi/ui-settings",qs=e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid settings response");return e},X0=()=>({async load(){const e=await b(zs,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load settings: ${e.statusText}`);return{settings:qs(await e.json()),source:"web"}},async save(e){const t=await b(zs,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to save settings")}return qs(await t.json())}}),Q0=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),Z0=1500,Qn=5e3,ey="pichamber-notification-claim:",ty=20,Cr=new Map,Ae=new Map,Gs="pichamber:input:",ry=(e,t)=>{if(t!=="input")return!1;const r=typeof e=="string"?e.trim():"";return r.startsWith(Gs)&&r.length>Gs.length},oy=(e,t,r)=>{if(!ry(e,r)||typeof e!="string"||e.length===0)return;const o=Ae.get(e);if(Ae.delete(e),o&&o!==t)try{o.close()}catch{}for(Ae.set(e,t);Ae.size>ty;){const n=Ae.keys().next().value;if(n===void 0)break;const a=Ae.get(n);if(Ae.delete(n),a)try{a.close()}catch{}}},ny=e=>{const t=typeof e?.tag=="string"?e.tag.trim():"";return t||[e?.sessionId,e?.kind,e?.title,e?.body].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim()).join("|")},ay=e=>{for(const[t,r]of Cr)e-r>Qn&&Cr.delete(t)},sy=e=>{const t=ny(e);if(!t)return!0;const r=Date.now();ay(r);const o=Cr.get(t)??0;if(r-o<Qn)return!1;try{if(typeof window<"u"&&window.localStorage){const n=`${ey}${t}`,a=Number(window.localStorage.getItem(n)??"0");if(Number.isFinite(a)&&r-a<Qn)return Cr.set(t,a),!1;Number.isFinite(a)&&a>0&&window.localStorage.removeItem(n),window.localStorage.setItem(n,String(r))}}catch{}return Cr.set(t,r),!0},Ic=async()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return null;let e=null;try{e=await navigator.serviceWorker.getRegistration()??null}catch{e=null}if(e?.active)return e;if(!e)return null;try{return await Promise.race([navigator.serviceWorker.ready,new Promise(r=>{setTimeout(()=>r(null),Z0)})])??e}catch{return e}},iy=async e=>{const t=await Ic();if(!t||typeof t.showNotification!="function")return!1;try{return await t.showNotification(e?.title??"PiChamber",{body:e?.body,tag:e?.tag}),!0}catch(r){return console.warn("Failed to send notification via service worker",r),!1}},cy=async e=>{if(e?.requireHidden&&typeof document<"u"&&document.hasFocus())return!0;if(typeof Notification>"u")return console.info("Notifications not supported in this environment",e),!1;if(Notification.permission==="default"&&await Notification.requestPermission()!=="granted"||Notification.permission!=="granted")return console.warn("Notification permission not granted"),!1;if(!sy(e))return!0;try{if(await iy(e))return!0;const t=new Notification(e?.title??"PiChamber",{body:e?.body,tag:e?.tag});return oy(e?.tag,t,e?.kind),t.onclose=()=>{e?.tag&&Ae.get(e.tag)===t&&Ae.delete(e.tag)},t.onclick=()=>{try{typeof window<"u"&&window.focus()}catch{}try{typeof window<"u"&&e?.sessionId&&window.dispatchEvent(new CustomEvent("pichamber:open-session",{detail:{sessionId:e.sessionId,directory:e.directory??""}}))}catch{}t.close()},!0}catch(t){return console.warn("Failed to send notification",t),!1}},dy=async e=>{if(typeof window>"u")return!1;const t=window.__PICHAMBER_DESKTOP__;if(!t?.invoke)return!1;try{return await t.invoke("desktop_notify",{payload:{title:e?.title,body:e?.body,tag:e?.tag,kind:e?.kind,sessionId:e?.sessionId,directory:e?.directory,requireHidden:e?.requireHidden}}),!0}catch(r){return console.warn("Failed to send native notification (desktop)",r),!1}},ly=()=>({async notify(e){return await dy(e)||await cy(e)},canNotify:()=>typeof window<"u"&&window.__PICHAMBER_DESKTOP__?.invoke?!0:typeof Notification<"u"?Notification.permission==="granted":!1,async close(e){if(typeof e!="string"||e.trim().length===0)return;const t=e.trim();if(typeof window<"u"){const o=window.__PICHAMBER_DESKTOP__;if(o?.invoke)try{await o.invoke("desktop_notification_close",{tag:t});return}catch(n){console.warn("Failed to close native notification (desktop)",n)}}const r=Ae.get(t);if(r){Ae.delete(t);try{r.close()}catch{}}try{const o=await Ic(),n=typeof o?.getNotifications=="function"?await o.getNotifications({tag:t}):[];for(const a of n??[])try{a.close()}catch{}}catch{}},setAttentionCount(e){const t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;if(typeof window<"u"){const r=window.__PICHAMBER_DESKTOP__;if(r?.invoke){r.invoke("desktop_tray_update",{dockBadgeCount:t}).catch(o=>{console.warn("Failed to update desktop attention count",o)});return}}try{const r=typeof navigator<"u"?navigator:null;if(!r)return;t>0&&typeof r.setAppBadge=="function"?r.setAppBadge(t).catch(()=>{}):t===0&&typeof r.clearAppBadge=="function"&&r.clearAppBadge().catch(()=>{})}catch{}}}),uy=()=>({async getAvailableTools(){const e=await b("/api/experimental/tool/ids");if(!e.ok)throw new Error(`Tools API returned ${e.status} ${e.statusText}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Tools API returned invalid data format");return t.filter(r=>typeof r=="string"&&r!=="invalid").sort()}}),Ye=async e=>await e.json().catch(()=>null),fy=()=>({async listClients(){const e=await b("/api/client-auth/clients",{method:"GET",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load remote clients");return Array.isArray(t.clients)?t.clients:[]},async createClient(e={}){const t=await b("/api/client-auth/clients",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({label:e.label??""})}),r=await Ye(t);if(!t.ok||!r?.client||typeof r.token!="string")throw new Error(r?.error||t.statusText||"Failed to create remote client token");return r},async createPairingSession(e={}){const t=await b("/api/client-auth/pairing/sessions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({label:e.label??"",...e.allowedClientKinds?{allowedClientKinds:e.allowedClientKinds}:{},...e.serverUrl?{serverUrl:e.serverUrl}:{},...typeof e.includeRelay=="boolean"?{includeRelay:e.includeRelay}:{},...typeof e.includeDirect=="boolean"?{includeDirect:e.includeDirect}:{}})}),r=await Ye(t);if(!t.ok||typeof r?.pairing?.secret!="string"||!r?.server)throw new Error(r?.error||t.statusText||"Failed to create pairing session");return r},async listPendingPairings(){const e=await b("/api/client-auth/pairing/sessions",{method:"GET",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load pending pairings");return Array.isArray(t.pending)?t.pending:[]},async getPairingTransports(){const e=await b("/api/client-auth/pairing/transports",{method:"GET",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load pairing transports");const r=t.tailscale&&typeof t.tailscale=="object"&&typeof t.tailscale.available=="boolean"?{available:t.tailscale.available,url:typeof t.tailscale.url=="string"?t.tailscale.url:null,mode:t.tailscale.mode==="public"?"public":"private"}:null;return{local:t.local??null,lan:t.lan??null,relayAvailable:t.relayAvailable!==!1,...r?{tailscale:r}:{}}},async cancelPairing(e){const t=await b(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:"DELETE",headers:{Accept:"application/json"}}),r=await Ye(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to cancel pairing");return{cancelled:r.cancelled===!0}},async revokeClient(e){const t=await b(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:"DELETE",headers:{Accept:"application/json"}}),r=await Ye(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to revoke remote client");return r},async purgeRevokedClients(){const e=await b("/api/client-auth/clients",{method:"DELETE",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to clear revoked clients");return t}}),my=(e={})=>{const t=e.urls??ca();return rl(t),{runtime:{platform:"web",isDesktop:!1,label:"web"},terminal:GF(),git:z0(),github:W0(),files:Y0({getDirectory:()=>qn.getState().currentDirectory}),settings:X0(),permissions:Q0(),notifications:ly(),clientAuth:fy(),tools:uy()}},Ws=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},gy=()=>{const e=t=>typeof t=="string"?t.trim():"";return{apiBaseUrl:e(window.__PICHAMBER_API_BASE_URL__),clientToken:e(window.__PICHAMBER_CLIENT_TOKEN__),localOrigin:e(window.__PICHAMBER_LOCAL_ORIGIN__),runtimeHeaders:window.__PICHAMBER_RUNTIME_HEADERS__,relayHostId:e(window.__PICHAMBER_RELAY_HOST_ID__)}};let Zn=Promise.resolve();const wA=()=>Zn,BA=e=>{const{apiBaseUrl:t,clientToken:r,localOrigin:o,runtimeHeaders:n,relayHostId:a,relay:s}=gy(),i=da({apiBaseUrl:t||void 0,realtimeBaseUrl:t||void 0});return dl({apiBaseUrl:t,runtimeKey:Ws(t,o)?"local":null}),mi(r||null),gi(n||null),s&&Kt({apiBaseUrl:t,clientToken:r||null,requestHeaders:n||null,runtimeKey:a?`host:${a}`:null,relay:s}),Ml(),Zn=s?Promise.resolve():Promise.race([nu(a||void 0).catch(()=>{}),new Promise(c=>{window.setTimeout(c,1e4)})]),Zn.then(()=>{Lr(ze()||void 0).catch(()=>{}),o&&!Ws(t,o)&&Object.keys(sa()).length>0&&$d(o).catch(()=>{})}),my({urls:i})};export{AA as $,K as A,ce as B,fA as C,mA as D,la as E,tn as F,Ur as G,G as H,ze as I,Kt as J,Fb as K,Dy as L,cA as M,Ub as N,Cy as O,Lr as P,vy as Q,yf as R,ef as S,wb as T,Kb as U,_y as V,aA as W,ab as X,Fl as Y,Ie as Z,Hb as _,rA as a,Jb as a$,Z as a0,_b as a1,If as a2,Qb as a3,Zb as a4,Nb as a5,Iy as a6,Gb as a7,jb as a8,Xb as a9,hb as aA,Wh as aB,va as aC,tf as aD,af as aE,rf as aF,sf as aG,wo as aH,tm as aI,lA as aJ,bc as aK,$y as aL,zy as aM,Rb as aN,Us as aO,Ib as aP,Gy as aQ,xy as aR,Ny as aS,Uy as aT,Ky as aU,Oy as aV,Ly as aW,Hy as aX,jy as aY,Wb as aZ,xo as a_,cc as aa,yA as ab,Yf as ac,Ty as ad,By as ae,Xt as af,ra as ag,Ol as ah,ub as ai,Ke as aj,Xy as ak,Yy as al,ba as am,Xl as an,Yl as ao,ot as ap,ya as aq,Ea as ar,Ob as as,$b as at,tb as au,hl as av,db as aw,lb as ax,Oi as ay,wy as az,D as b,Kl as b$,$e as b0,_s as b1,um as b2,mm as b3,cb as b4,Wu as b5,gl as b6,qy as b7,Vy as b8,Jy as b9,gm as bA,gb as bB,pb as bC,Ab as bD,bo as bE,du as bF,L as bG,hm as bH,sA as bI,vi as bJ,Qf as bK,lu as bL,Sy as bM,yb as bN,ky as bO,yu as bP,Sn as bQ,Th as bR,fc as bS,uc as bT,Hr as bU,ib as bV,dA as bW,cn as bX,Tn as bY,qh as bZ,X as b_,Bb as ba,V0 as bb,ll as bc,Nr as bd,Ki as be,zb as bf,gA as bg,ob as bh,rb as bi,To as bj,Xi as bk,My as bl,FA as bm,hA as bn,nf as bo,nA as bp,Ph as bq,sb as br,oA as bs,Ih as bt,Rh as bu,nb as bv,Eb as bw,bb as bx,bA as by,Ry as bz,Lb as c,$l as c0,ql as c1,_e as c2,wa as c3,Aa as c4,Wl as c5,Jl as c6,Vl as c7,Ni as c8,tu as c9,vb as cA,Tb as cB,ws as cC,Db as cD,qb as cE,pm as cF,Wy as cG,Xr as cH,pA as cI,of as cJ,Py as cK,fb as cL,mb as cM,xb as cN,Ui as ca,sa as cb,eb as cc,Qy as cd,Zy as ce,yF as cf,bF as cg,uA as ch,rt as ci,Da as cj,jf as ck,eA as cl,tA as cm,Pb as cn,lr as co,Ze as cp,Zf as cq,re as cr,Qt as cs,Ca as ct,Ju as cu,pl as cv,Mb as cw,Cb as cx,kb as cy,Sb as cz,BA as d,Zt as e,we as f,yl as g,wA as h,EA as i,gF as j,qn as k,ma as l,XF as m,Xf as n,Ro as o,bt as p,j as q,b as r,Ti as s,Yb as t,ie as u,xe as v,Vb as w,ul as x,iA as y,lF as z};
9
+ ${e.sessionId}`,ym=e=>{const[t,r,...o]=e.split(`
10
+ `);return Fm(o.join(`
11
+ `),r,t)},bm=(e,t)=>{const r=e??{},o=t<2?r.queuedMessages??{}:{};return{queuedMessages:t<2?{}:r.queuedMessages??{},quarantinedLegacyMessages:{...r.quarantinedLegacyMessages??{},...o},followUpBehavior:Ua(r.followUpBehavior,r.queueModeEnabled??null)}},Am=xr()(Or(aa((e,t)=>({queuedMessages:{},quarantinedLegacyMessages:{},followUpBehavior:Na,sendingIds:{},addToQueue:(r,o)=>{const n=re(r),a=t();if((a.queuedMessages[n]??[]).length>=Ks||!(n in a.queuedMessages)&&Object.keys(a.queuedMessages).length>=Hs)return!1;const c={id:`queued-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,content:o.content,attachments:o.attachments,createdAt:Date.now(),sendConfig:o.sendConfig};let d=!1;return e(l=>{const u=l.queuedMessages[n]??[];return u.length>=Ks||!(n in l.queuedMessages)&&Object.keys(l.queuedMessages).length>=Hs?l:(d=!0,{queuedMessages:{...l.queuedMessages,[n]:[...u,c]}})}),d},removeFromQueue:(r,o)=>{const n=re(r);if((t().sendingIds[n]??[]).includes(o))return;const a=(t().queuedMessages[n]??[]).filter(s=>s.id===o);ln(r,a.filter(s=>!s.deliveryAttempt)),e(s=>{const c=(s.queuedMessages[n]??[]).filter(d=>d.id!==o);if(c.length===0){const{[n]:d,...l}=s.queuedMessages;return{queuedMessages:l}}return{queuedMessages:{...s.queuedMessages,[n]:c}}})},reorderQueue:(r,o,n)=>{if(o===n)return;const a=re(r);e(s=>{const i=s.queuedMessages[a];if(!i)return s;const c=i.findIndex(f=>f.id===o),d=i.findIndex(f=>f.id===n);if(c===-1||d===-1)return s;const l=i.slice(),[u]=l.splice(c,1);return l.splice(d,0,u),{queuedMessages:{...s.queuedMessages,[a]:l}}})},popToInput:(r,o)=>{const n=re(r),a=t();if((a.sendingIds[n]??[]).includes(o))return null;const i=(a.queuedMessages[n]??[]).find(c=>c.id===o);return i?(e(c=>{const l=(c.queuedMessages[n]??[]).filter(u=>u.id!==o);if(l.length===0){const{[n]:u,...f}=c.queuedMessages;return{queuedMessages:f}}return{queuedMessages:{...c.queuedMessages,[n]:l}}}),i):null},clearQueue:r=>{const o=re(r),n=t(),a=n.sendingIds[o]??[];ln(r,(n.queuedMessages[o]??[]).filter(s=>!a.includes(s.id)&&!s.deliveryAttempt)),e(s=>{const i=s.sendingIds[o]??[],c=(s.queuedMessages[o]??[]).filter(u=>i.includes(u.id)||u.deliveryAttempt);if(c.length>0)return{queuedMessages:{...s.queuedMessages,[o]:c}};const{[o]:d,...l}=s.queuedMessages;return{queuedMessages:l}})},clearAllQueues:()=>{const r=t();for(const[o,n]of Object.entries(r.queuedMessages)){const a=ym(o);if(!a)continue;const s=r.sendingIds[o]??[],i=n.filter(c=>!s.includes(c.id)&&!c.deliveryAttempt);i.length>0&&ln(a,i)}e(o=>{const n={},a={};for(const[s,i]of Object.entries(o.queuedMessages)){const c=o.sendingIds[s]??[],d=i.filter(l=>c.includes(l.id)||l.deliveryAttempt);if(d.length>0){n[s]=d;const l=c.filter(u=>d.some(f=>f.id===u));l.length>0&&(a[s]=l)}}return{queuedMessages:n,sendingIds:a}})},markSending:(r,o)=>{const n=re(r);e(a=>{const s=a.sendingIds[n]??[];return s.includes(o)?a:{sendingIds:{...a.sendingIds,[n]:[...s,o]}}})},clearSending:(r,o)=>{const n=re(r);e(a=>{const s=a.sendingIds[n];if(!s||!s.includes(o))return a;const i=s.filter(c=>c!==o);if(i.length===0){const{[n]:c,...d}=a.sendingIds;return{sendingIds:d}}return{sendingIds:{...a.sendingIds,[n]:i}}})},markDeliveryAttempt:(r,o,n)=>{if(r.runtimeKey!==D())return null;const a=Ze(r.runtimeKey,r.sessionId);if(!a)return null;const s=re(r);let i=null;return e(c=>{const d=c.queuedMessages[s];if(!d)return c;const l=d.findIndex(g=>g.id===o);if(l===-1)return c;const u=d[l],f=u.deliveryAttempt;if(f?.kind===n&&f.operationId===o&&f.streamEpoch===a&&!u.sendFailed)return i=f,c;i={kind:n,operationId:o,streamEpoch:a};const m=d.slice();return m[l]={...u,deliveryAttempt:i,sendFailed:void 0},{queuedMessages:{...c.queuedMessages,[s]:m}}}),i},markSendFailed:(r,o)=>{const n=re(r);e(a=>{const s=a.queuedMessages[n];if(!s)return a;const i=s.findIndex(f=>f.id===o);if(i===-1)return a;const c=s[i];if(c.sendFailed===!0&&!c.deliveryAttempt)return a;const d=s.slice(),{deliveryAttempt:l,...u}=c;return d[i]={...u,sendFailed:!0},{queuedMessages:{...a.queuedMessages,[n]:d}}})},releaseRefusedSend:(r,o)=>{const n=re(r);e(a=>{const s=a.queuedMessages[n];if(!s)return a;const i=s.findIndex(u=>u.id===o);if(i===-1||!s[i].deliveryAttempt)return a;const{deliveryAttempt:c,...d}=s[i],l=s.slice();return l[i]=d,{queuedMessages:{...a.queuedMessages,[n]:l}}})},markSendUnconfirmed:(r,o,n)=>{const a=re(r);e(s=>{const i=s.queuedMessages[a];if(!i)return s;const c=i.findIndex(f=>f.id===o);if(c===-1)return s;const d=i[c];if(d.deliveryAttempt)return s;const l=i.slice(),u=Ze(r.runtimeKey,r.sessionId);return l[c]={...d,deliveryAttempt:{kind:n,operationId:o,...u?{streamEpoch:u}:{}}},{queuedMessages:{...s.queuedMessages,[a]:l}}})},requeueWithNewIntent:(r,o)=>{if(r.runtimeKey!==D()||!Ze(r.runtimeKey,r.sessionId))return null;const n=re(r),a=`queued-${pm()}`;let s=!1;return e(i=>{if((i.sendingIds[n]??[]).includes(o))return i;const c=i.queuedMessages[n];if(!c)return i;const d=c.findIndex(g=>g.id===o);if(d===-1||!c[d].deliveryAttempt)return i;const{deliveryAttempt:l,sendFailed:u,...f}=c[d],m=c.slice();return m[d]={...f,id:a},s=!0,{queuedMessages:{...i.queuedMessages,[n]:m}}}),s?a:null},completeQueuedSend:(r,o)=>{const n=re(r);(t().queuedMessages[n]??[]).filter(a=>a.id===o),e(a=>{const s=a.queuedMessages[n]??[],i=s.filter(u=>u.id!==o),c=a.sendingIds[n],d=c?.includes(o)?c.filter(u=>u!==o):c,l={};if(i.length===0){if(n in a.queuedMessages){const{[n]:u,...f}=a.queuedMessages;l.queuedMessages=f}}else i.length!==s.length&&(l.queuedMessages={...a.queuedMessages,[n]:i});if(d!==c)if(!d||d.length===0){const{[n]:u,...f}=a.sendingIds;l.sendingIds=f}else l.sendingIds={...a.sendingIds,[n]:d};return Object.keys(l).length>0?l:a})},claimQueuedMessage:(r,o)=>{const n=re(r);let a=null;return e(s=>{const i=s.queuedMessages[n]??[],c=s.sendingIds[n]??[];if(c.includes(o))return s;const d=i.find(u=>u.id===o);if(!d)return s;const l=Ze(r.runtimeKey,r.sessionId);return r.runtimeKey!==D()||!l||d.deliveryAttempt?s:(a=d,{sendingIds:{...s.sendingIds,[n]:[...c,o]}})}),a},getAutoSendCandidate:r=>{const o=re(r),n=t(),a=n.queuedMessages[o]??[],s=n.sendingIds[o]??[];if(r.runtimeKey!==D()||!Ze(r.runtimeKey,r.sessionId))return null;for(const i of a){if(s.includes(i.id)||i.deliveryAttempt)return null;if(i.sendFailed!==!0)return i}return null},getSendableQueue:r=>{const o=re(r),n=t(),a=n.queuedMessages[o]??[],s=n.sendingIds[o];return!s||s.length===0?a:a.filter(i=>!s.includes(i.id))},setFollowUpBehavior:r=>{e({followUpBehavior:r}),Ke({followUpBehavior:r})},getQueueForTarget:r=>t().queuedMessages[re(r)]??[]}),{name:"message-queue-store",version:2,storage:pa(),partialize:e=>({queuedMessages:e.queuedMessages,quarantinedLegacyMessages:e.quarantinedLegacyMessages,followUpBehavior:e.followUpBehavior}),migrate:bm}),{name:"message-queue-store"})),Em=["bash","zsh","sh","fish","pwsh","powershell","cmd","dash","ksh","nu"],Co=e=>e==="auto"||typeof e=="string"&&Em.includes(e),wm={threshold:.4,distance:100,ignoreLocation:!0,preferSubstring:!0};function Bm(e,t,r){if(!t)return!0;if(!e)return!1;const o={...wm,...r};return o.preferSubstring&&e.toLowerCase().includes(t.toLowerCase())?!0:new ri([e],{threshold:o.threshold,distance:o.distance,ignoreLocation:o.ignoreLocation}).search(t).length>0}function pA(e,t,r,o){if(!t)return e.map(l=>({item:l,score:0}));const n=o?.limit??e.length,a=o?.threshold??.3,s=o?.noFuzzy??!1,i=t.toLowerCase(),c=[],d=[];for(const l of e){const u=r(l);if(!u)continue;const m=u.toLowerCase().indexOf(i);if(m===0){c.push({item:l,score:-1});continue}if(m>0){c.push({item:l,score:m/1e3});continue}s||d.push({item:l,text:u})}if(d.length>0){const l=new ri(d.map(u=>u.text),{threshold:a,ignoreLocation:!0,distance:100,includeScore:!0,minMatchCharLength:2});for(const u of l.search(t))c.push({item:d[u.refIndex].item,score:u.score??1})}return c.sort((l,u)=>l.score-u.score),c.slice(0,n)}function hA(...e){return Gc(Wc(e))}const qe=()=>typeof navigator>"u"?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||""),Cm=()=>typeof navigator>"u"?!1:/Windows/.test(navigator.userAgent||""),FA=()=>qe()?"Reveal in Finder":Cm()?"Open in File Explorer":"Open in File Manager",yA=e=>qe()&&we()?e.metaKey:e.ctrlKey,bA=()=>qe()&&we()?"⌘":"Ctrl",AA=(e,t)=>{const r=e??"",o=Math.max(16,t?.maxLength??45);if(r.length<=o)return r;const n=r.split("/");if(n.length<=1)return r;const a=n.pop()??"";if(!a)return r;const s=Math.max(0,o-(a.length+2));if(s<=0)return`…/${a}`;let i="";for(const c of n){if(!c)continue;const d=i?`${i}/${c}`:c;if(d.length>s)break;i=d}if(!i){const c=n[0]??"";i=c?c.slice(0,s):""}return i?`${i}…/${a}`:`…/${a}`},vo=e=>e?e==="/"?"/":e.replace(/\/+$/,""):"";function EA(e,t){if(!e)return"";const r=vo(e);if(r==="/")return"/";const o=t?vo(t):void 0;if(o&&o!=="/"){if(r===o)return"~";if(r.startsWith(`${o}/`)){const n=r.slice(o.length+1);return n?`~/${n}`:"~"}}return r}function wA(e,t){if(!e)return"/";const r=vo(e);if(!r||r==="/")return"/";const o=t?vo(t):void 0;return o&&o!=="/"&&r===o?"~":r.split("/").pop()||r||"/"}function BA(e,t){return Bm(e,t)}const $e="__unassigned__",pc={mod:"mod",shift:"shift",alt:"alt",option:"alt",ctrl:"ctrl",meta:"mod",cmd:"mod",command:"mod"},pr=qe()&&we(),vm={mod:pr?"⌘":"Ctrl",shift:pr?"⇧":"Shift",alt:pr?"⌥":"Alt",option:pr?"⌥":"Alt",ctrl:pr?"⌃":"Ctrl"},km={mod:qe()&&we()?["meta"]:qe()?["meta","control"]:["control"],shift:["shift"],alt:["alt"],option:["alt"],ctrl:["control"]},Dm={comma:",",period:".",enter:"Enter",escape:"Esc",tab:"Tab",space:"Space",backspace:"⌫",delete:"⌦",arrowup:"↑",arrowdown:"↓",arrowleft:"←",arrowright:"→",home:"Home",end:"End",pageup:"Page Up",pagedown:"Page Down"},hc=["mod","ctrl","shift","alt"],Sm={"{":"[","}":"]",":":";",'"':"'","<":",",">":".","?":"/","|":"\\","~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0"};function ct(e){return e.trim().toLowerCase()===$e}function js(e){const t=e.toLowerCase();return t===","?"comma":t==="."?"period":t===" "?"space":t==="esc"?"escape":t==="+"?"plus":t==="-"||t==="_"?"minus":t==="arrowup"?"arrowup":t==="arrowdown"?"arrowdown":t==="arrowleft"?"arrowleft":t==="arrowright"?"arrowright":Sm[t]??t}const Fc=[{id:"open_command_palette",defaultCombo:"mod+p",label:"Open command palette",description:"Open the command palette",customizable:!0},{id:"focus_input",defaultCombo:"mod+i",label:"Focus input",description:"Focus the chat input field",customizable:!0},{id:"open_settings",defaultCombo:"mod+comma",label:"Open settings",description:"Open the settings panel",customizable:!0},{id:"toggle_terminal",defaultCombo:"mod+j",label:"Toggle terminal dock",description:"Toggle the bottom terminal dock",customizable:!0},{id:"add_selection_to_chat",defaultCombo:"mod+l",label:"Add selection to chat",description:"Add the selected text to the chat input",customizable:!0},{id:"toggle_sidebar",defaultCombo:"mod+alt+l",label:"Toggle sidebar",description:"Toggle the session sidebar",customizable:!0},{id:"open_timeline_dialog",defaultCombo:"mod+t",label:"Open conversation timeline",description:"Search and navigate within current conversation",customizable:!0},{id:"open_right_sidebar",defaultCombo:"mod+b",label:"Open right sidebar",description:"Open the right sidebar",customizable:!0},{id:"cycle_session_folder",defaultCombo:"mod+shift+f",label:"Cycle session folder",description:"Switch to the next session folder",customizable:!0},{id:"cycle_draft_folder",defaultCombo:"mod+shift+d",label:"Cycle draft folder",description:"Change the folder for the new session draft",customizable:!0},{id:"switch_context_surface",defaultCombo:"mod",label:"Switch context panel surface",description:"Hold the modifier and press a number to open or close the matching rail icon",customizable:!0},{id:"new_chat",defaultCombo:"mod+n",label:"New session",description:"Start a new session",customizable:!0},{id:"new_mini_chat",defaultCombo:"mod+alt+n",label:"New Mini Chat window",description:"Open a new Mini Chat draft window",customizable:!0},{id:"submit_message",defaultCombo:"mod+enter",label:"Submit message",description:"Submit the current message"},{id:"clear_input",defaultCombo:"escape",label:"Clear input",description:"Clear the input field"},{id:"open_help",defaultCombo:"mod+.",label:"Open keyboard shortcuts",description:"Show the keyboard shortcuts help",customizable:!0},{id:"toggle_services_menu",defaultCombo:"mod+shift+s",label:"Toggle services menu",description:"Open or close the services menu",customizable:!0},{id:"cycle_theme",defaultCombo:"mod+/",label:"Cycle theme",description:"Cycle between light, dark, and system theme",customizable:!0},{id:"open_model_selector",defaultCombo:"mod+shift+m",label:"Open model selector",description:"Open model selector while in chat",customizable:!0},{id:"cycle_thinking_variant",defaultCombo:"mod+shift+t",label:"Cycle thinking",description:"Cycle thinking while in chat"},{id:"cycle_favorite_model_forward",defaultCombo:"ctrl+]",label:"Cycle favorite model forward",description:"Cycle forward through starred models without opening the picker",customizable:!0},{id:"cycle_favorite_model_backward",defaultCombo:"ctrl+[",label:"Cycle favorite model backward",description:"Cycle backward through starred models without opening the picker",customizable:!0},{id:"abort_run",defaultCombo:"escape",label:"Abort active run",description:"Abort the currently running task (double press)"}];function Uo(e){if(ct(e))return $e;const t=e.toLowerCase().trim().split("+").map(a=>a.trim()).filter(Boolean),r=new Set;let o="";for(const a of t){const s=a===","?"comma":a==="."?"period":a,i=pc[s];if(i){r.add(i);continue}o=s}return[...hc.filter(a=>r.has(a)),o].filter(Boolean).join("+")}function Mm(e){return ct(e)?!0:Mt(e).key.trim().length>0}function Mt(e){if(ct(e))return{modifiers:new Set,key:$e};const r=Uo(e).split("+"),o=new Set;let n="";for(const a of r){const s=pc[a];s?o.add(s):n=a}return{modifiers:o,key:n}}function CA(e){if(ct(e))return"Unassigned";const t=Mt(e);if(!t.key&&t.modifiers.size===0)return"Unassigned";const r=[];for(const o of hc)t.modifiers.has(o)&&r.push(vm[o]);if(t.key){const o=Dm[t.key.toLowerCase()]||t.key.toUpperCase();r.push(o)}return r.join(" + ")}function yc(e){return Fc.find(t=>t.id===e)}function vA(){return Fc.filter(e=>e.customizable===!0)}function kA(e,t){const r=yc(e);if(!r)return"";const o=t?.[e];if(typeof o=="string"){if(o.trim().toLowerCase()===$e)return"";const n=Uo(o);if(n===$e)return $e;if(Mm(n))return n}return r.defaultCombo}function DA(e){if(ct(e))return!1;const t=Mt(e);if(!t.modifiers.has("mod"))return!1;const r=t.key.toLowerCase();return new Set(["w","t","r","p","s","f","l","n"]).has(r)&&!t.modifiers.has("shift")&&!t.modifiers.has("alt")}const bc=(e,t)=>{const r=t.modifiers.has("mod"),o=t.modifiers.has("shift"),n=t.modifiers.has("alt"),a=t.modifiers.has("ctrl"),s=qe()&&we(),i=qe(),c=s?e.metaKey:i&&e.metaKey||e.ctrlKey;if(r&&!c||!r&&e.metaKey||o!==e.shiftKey||n!==e.altKey)return!1;if(a)return e.ctrlKey;const d=r&&!s&&e.ctrlKey;return!e.ctrlKey||d};function SA(e,t){const r=typeof t=="string"?t:t.defaultCombo;if(ct(r))return!1;const o=Mt(r);if(!bc(e,o))return!1;let n=e.key;e.altKey&&(e.code.startsWith("Key")&&e.code.length===4?n=e.code.slice(3).toLowerCase():e.code.startsWith("Digit")&&e.code.length===6&&(n=e.code.slice(5)));const a=js(n),s=js(o.key);return a===s}function MA(){return qe()&&we()?"⌘":"Ctrl"}function TA(e,t){const r=yc(e);if(!r)return"";const o=t?.[e];if(typeof o=="string"&&o.trim()!==""){const n=Uo(o);if(n===$e)return $e;if(n){const a=Mt(n);if(a.modifiers.size>0||a.key)return n}}return r.defaultCombo}function PA(e,t){if(ct(e))return!1;const r=Mt(e);for(const o of r.modifiers)if(!km[o].some(a=>t.has(a)))return!1;return!(r.key&&!t.has(r.key.toLowerCase()))}function RA(e,t,r){if(ct(t))return!1;const o=Mt(t);return!(!bc(e,o)||o.key&&(!r||!r.has(o.key.toLowerCase())))}const Tm=12,Pm=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),to=(e,t)=>{if(!(typeof e!="string"||e.length===0))return e.length>t?e.slice(0,t):e},Rm=e=>{if(!Array.isArray(e))return;const t=[],r=new Set;for(const o of e.slice(0,Tm)){if(!Pm(o))continue;const n=to(o.label,64),a=to(o.command,128);if(!n||!a||a.includes("/")||a.startsWith("."))continue;let s=to(o.id,64);(!s||r.has(s))&&(s=`trigger-${t.length+1}-${a}`),r.add(s);const i=to(o.args,2e3),c=typeof o.combo=="string"&&o.combo.length>0?Uo(o.combo):void 0,d=c&&c!==$e?c:void 0;t.push({id:s,label:n,command:a,...i!==void 0?{args:i}:{},...d!==void 0?{combo:d}:{}})}return t.length>0?t:void 0},Im=e=>Array.from(e??"",t=>{const r=t.charCodeAt(0);return r<32||r===127?" ":t}).join("").trim().slice(0,2e3),_m=(e,t)=>{const r=Im(t);return r?`/${e} ${r}`:`/${e}`},IA=e=>_m(e.command,e.args),xm=e=>{const t=e.replace(/\\/g,"/").replace(/\/+$/g,"").trim();if(!t)return"";const r=new TextEncoder().encode(t);let o="";for(const a of r)o+=String.fromCharCode(a);return`path_${typeof btoa=="function"?btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""):t.replace(/[^A-Za-z0-9._-]+/g,"_")}`},Om="#8957e5",Nm="#8250df",Lm=e=>{const t=e.colors.syntax?.tokens??{},r=[t.className,t.enum,t.variableGlobal,e.colors.syntax?.base?.keyword].filter(o=>typeof o=="string"&&o.trim().length>0);return r.length>0?r[0]:e.metadata.variant==="dark"?Om:Nm},jr=e=>e.colors.pr?e:{...e,colors:{...e.colors,pr:{open:e.colors.status.success,draft:e.colors.surface.mutedForeground,blocked:e.colors.status.warning,merged:Lm(e),closed:e.colors.status.error}}},Um={id:"aura-dark",name:"Aura",description:"Aura",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Hm={primary:{base:"#A277FF",hover:"#8D68DD",active:"#B08BFF",foreground:"#15141B",muted:"#A277FF80",emphasis:"#8D68DD"},surface:{background:"#15141B",foreground:"#EDECEE",muted:"#1A1921",mutedForeground:"#8a8282",elevated:"#201e2b",elevatedForeground:"#EDECEE",overlay:"#FFFFFF20",subtle:"#25232f"},interactive:{border:"#2a2935",borderHover:"#47415a",borderFocus:"#4E496C",selection:"#95abe02d",selectionForeground:"#FFFFFF",focus:"#A277FF",focusRing:"#A277FF40",cursor:"#FFFFFF",hover:"#7887ac2d",active:"#95abe02d"},status:{error:"#FF6767",errorForeground:"#15141B",errorBackground:"#FF676720",errorBorder:"#FF676750",warning:"#FFCA85",warningForeground:"#15141B",warningBackground:"#FFCA8520",warningBorder:"#FFCA8550",success:"#61FFCA",successForeground:"#15141B",successBackground:"#61FFCA20",successBorder:"#61FFCA50",info:"#82E2FF",infoForeground:"#15141B",infoBackground:"#82E2FF20",infoBorder:"#82E2FF50"},pr:{open:"#61FFCA",draft:"#6D6D6D",blocked:"#FFCA85",merged:"#A277FF",closed:"#FF6767"},syntax:{base:{background:"#1A1921",foreground:"#EDECEE",comment:"#6D6D6D",keyword:"#A277FF",string:"#61FFCA",number:"#FF6767",function:"#A277FF",variable:"#EDECEE",type:"#FFCA85",operator:"#FF6767"},tokens:{boolean:"#FFCA85",class:"#A277FF",className:"#A277FF",commentDoc:"#606061",constant:"#82E2FF",decorator:"#FFCA85",enum:"#A277FF",exception:"#FF6767",functionCall:"#A277FF",interface:"#FFCA85",jsxTag:"#A277FF",key:"#A277FF",keywordImport:"#FF6767",label:"#FF6767",macro:"#82E2FF",method:"#61FFCA",module:"#FF6767",namespace:"#FFCA85",parameter:"#EDECEE",preprocessor:"#FF6767",punctuation:"#6D6D6D",regex:"#61FFCA",storageModifier:"#82E2FF",stringEscape:"#FFFFFF",struct:"#A277FF",tag:"#A277FF",tagAttribute:"#FFCA85",tagAttributeValue:"#61FFCA",typeParameter:"#FFCA85",url:"#A277FF",variableGlobal:"#A277FF",variableLocal:"#121118",variableOther:"#61FFCA",variableProperty:"#82E2FF"},highlights:{diffAdded:"#61FFCA",diffAddedBackground:"#162620",diffModified:"#82E2FF",diffModifiedBackground:"#1E1D2A",diffRemoved:"#FF6767",diffRemovedBackground:"#26161A",lineNumber:"#3E3A56",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#e7d7f4",heading2:"#e7e0ee",heading3:"#ece7f0",heading4:"#EDECEE",link:"#A277FF",linkHover:"#F694FF",inlineCode:"#61FFCA",inlineCodeBackground:"#1A1921",blockquote:"#6D6D6D",blockquoteBorder:"#2D2B38",listMarker:"#A277FF99"},chat:{userMessage:"#EDECEE",userMessageBackground:"#393647",assistantMessage:"#EDECEE",assistantMessageBackground:"#15141B",timestamp:"#6D6D6D",divider:"#2D2B38"},tools:{background:"#1A192180",border:"#43415480",headerHover:"#0F0E14",icon:"#6D6D6D",title:"#EDECEE",description:"#6D6D6D",edit:{added:"#61FFCA",addedBackground:"#61FFCA25",removed:"#FF6767",removedBackground:"#FF676725",lineNumber:"#3E3A56"}}},Km={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},jm={metadata:Um,colors:Hm,config:Km},$m={id:"aura-light",name:"Aura",description:"Aura",version:"1.0.0",variant:"light",tags:["light","palette"]},zm={primary:{base:"#A277FF",hover:"#B38FFF",active:"#8D68DD",foreground:"#F5F0FF",muted:"#A277FF80",emphasis:"#B38FFF"},surface:{background:"#F5F0FF",foreground:"#2D2640",muted:"#EFE8FC",mutedForeground:"#807b8b",elevated:"#f1ebfb",elevatedForeground:"#2D2640",overlay:"#15101F20",subtle:"#EFE8FC"},interactive:{border:"#E0D6F2",borderHover:"#D5C9EB",borderFocus:"#A593C8",selection:"#bdb2d74c",selectionForeground:"#15101F",focus:"#A277FF",focusRing:"#A277FF40",cursor:"#15101F",hover:"#bdb2d72d",active:"#bdb2d74c"},status:{error:"#D94F4F",errorForeground:"#F5F0FF",errorBackground:"#D94F4F20",errorBorder:"#D94F4F50",warning:"#D9A24A",warningForeground:"#F5F0FF",warningBackground:"#D9A24A20",warningBorder:"#D9A24A50",success:"#40BF7A",successForeground:"#F5F0FF",successBackground:"#40BF7A20",successBorder:"#40BF7A50",info:"#5BB8D9",infoForeground:"#F5F0FF",infoBackground:"#5BB8D920",infoBorder:"#5BB8D950"},pr:{open:"#40BF7A",draft:"#6D6D6D",blocked:"#D9A24A",merged:"#A277FF",closed:"#D94F4F"},syntax:{base:{background:"#EFE8FC",foreground:"#2D2640",comment:"#5C5270",keyword:"#A277FF",string:"#40BF7A",number:"#D94F4F",function:"#A277FF",variable:"#2D2640",type:"#D9A24A",operator:"#D94F4F"},tokens:{boolean:"#D9A24A",class:"#A277FF",className:"#A277FF",commentDoc:"#A9A1B8",constant:"#5BB8D9",decorator:"#D9A24A",enum:"#A277FF",exception:"#D94F4F",functionCall:"#A277FF",interface:"#D9A24A",jsxTag:"#A277FF",key:"#A277FF",keywordImport:"#D94F4F",label:"#D94F4F",macro:"#5BB8D9",method:"#40BF7A",module:"#D94F4F",namespace:"#D9A24A",parameter:"#2D2640",preprocessor:"#D94F4F",punctuation:"#5C5270",regex:"#40BF7A",storageModifier:"#5BB8D9",stringEscape:"#15101F",struct:"#A277FF",tag:"#A277FF",tagAttribute:"#D9A24A",tagAttributeValue:"#40BF7A",typeParameter:"#D9A24A",url:"#A277FF",variableGlobal:"#A277FF",variableLocal:"#FAF7FF",variableOther:"#40BF7A",variableProperty:"#5BB8D9"},highlights:{diffAdded:"#40BF7A",diffAddedBackground:"#E8F5ED",diffModified:"#5BB8D9",diffModifiedBackground:"#E8E4F5",diffRemoved:"#D94F4F",diffRemovedBackground:"#FAE8E8",lineNumber:"#C0B3DC",lineNumberActive:"#15101F"}},markdown:{heading1:"#A277FF",heading2:"#A277FF",heading3:"#D9A24A",heading4:"#2D2640",link:"#A277FF",linkHover:"#C17AC8",inlineCode:"#40BF7A",inlineCodeBackground:"#EFE8FC",blockquote:"#6D6D6D",blockquoteBorder:"#E0D6F2",listMarker:"#A277FF99"},chat:{userMessage:"#2D2640",userMessageBackground:"#EFE8FC",assistantMessage:"#2D2640",assistantMessageBackground:"#F5F0FF",timestamp:"#5C5270",divider:"#E0D6F2"},tools:{background:"#EFE8FC80",border:"#bdb5cd80",headerHover:"#FDFCFF",icon:"#5C5270",title:"#2D2640",description:"#5C5270",edit:{added:"#40BF7A",addedBackground:"#40BF7A25",removed:"#D94F4F",removedBackground:"#D94F4F25",lineNumber:"#C0B3DC"}}},qm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Wm={metadata:$m,colors:zm,config:qm},Gm={id:"ayu-dark",name:"Ayu",description:"Ayu",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Vm={primary:{base:"#3FB7E3",hover:"#389FC5",active:"#5BC1E7",foreground:"#0F1419",muted:"#3FB7E380",emphasis:"#389FC5"},surface:{background:"#0F1419",foreground:"#D6DAE0",muted:"#18222C",mutedForeground:"#777e86",elevated:"#17202a",elevatedForeground:"#D6DAE0",overlay:"#FBFBFD20",subtle:"#1e252d"},interactive:{border:"#292c30",borderHover:"#323C49",borderFocus:"#56647C",selection:"#c7c7df1d",selectionForeground:"#FBFBFD",focus:"#3FB7E3",focusRing:"#3FB7E340",cursor:"#FBFBFD",hover:"#b6b6cc1d",active:"#b8b8ce1d"},status:{error:"#F58572",errorForeground:"#0F1419",errorBackground:"#F5857220",errorBorder:"#F5857250",warning:"#E4A75C",warningForeground:"#0F1419",warningBackground:"#E4A75C20",warningBorder:"#E4A75C50",success:"#78D05C",successForeground:"#0F1419",successBackground:"#78D05C20",successBorder:"#78D05C50",info:"#66C6F1",infoForeground:"#0F1419",infoBackground:"#66C6F120",infoBorder:"#66C6F150"},pr:{open:"#78D05C",draft:"#A3ADBA",blocked:"#E4A75C",merged:"#8a44f2",closed:"#F58572"},syntax:{base:{background:"#18222C",foreground:"#D6DAE0",comment:"#A3ADBA",keyword:"#3FB7E3",string:"#B1C74A",number:"#F2856F",function:"#3FB7E3",variable:"#D6DAE0",type:"#E4A75C",operator:"#F2856F"},tokens:{boolean:"#E4A75C",class:"#3FB7E3",className:"#3FB7E3",commentDoc:"#8D96A2",constant:"#66C6F1",decorator:"#E4A75C",enum:"#3FB7E3",exception:"#F2856F",functionCall:"#3FB7E3",interface:"#E4A75C",jsxTag:"#3FB7E3",key:"#3FB7E3",keywordImport:"#F2856F",label:"#F2856F",macro:"#66C6F1",method:"#78D05C",module:"#F2856F",namespace:"#E4A75C",parameter:"#D6DAE0",preprocessor:"#F2856F",punctuation:"#A3ADBA",regex:"#B1C74A",storageModifier:"#66C6F1",stringEscape:"#FBFBFD",struct:"#3FB7E3",tag:"#3FB7E3",tagAttribute:"#E4A75C",tagAttributeValue:"#B1C74A",typeParameter:"#E4A75C",url:"#66C6F1",variableGlobal:"#3FB7E3",variableLocal:"#0B1015",variableOther:"#78D05C",variableProperty:"#66C6F1"},highlights:{diffAdded:"#78D05C",diffAddedBackground:"#132F27",diffModified:"#66C6F1",diffModifiedBackground:"#1B2632",diffRemoved:"#F58572",diffRemovedBackground:"#361D20",lineNumber:"#415063",lineNumberActive:"#FBFBFD"}},markdown:{heading1:"#D6DAE0",heading2:"#D6DAE0",heading3:"#D6DAE0",heading4:"#D6DAE0",link:"#66C6F1",linkHover:"#3FB7E3",inlineCode:"#B1C74A",inlineCodeBackground:"#161d23",blockquote:"#E4A75C",blockquoteBorder:"#2B3440",listMarker:"#3FB7E399"},chat:{userMessage:"#D6DAE0",userMessageBackground:"#1d2935",assistantMessage:"#D6DAE0",assistantMessageBackground:"#0F1419",timestamp:"#A3ADBA",divider:"#2B3440"},tools:{background:"#18222C80",border:"#414e5f80",headerHover:"#080C10",icon:"#A3ADBA",title:"#D6DAE0",description:"#A3ADBA",edit:{added:"#78D05C",addedBackground:"#78D05C25",removed:"#F58572",removedBackground:"#F5857225",lineNumber:"#415063"}}},Jm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Ym={metadata:Gm,colors:Vm,config:Jm},Xm={id:"ayu-light",name:"Ayu",description:"Ayu",version:"1.0.0",variant:"light",tags:["light","palette"]},Qm={primary:{base:"#4AA8C8",hover:"#6EB8D1",active:"#4394B0",foreground:"#FDFAF4",muted:"#4AA8C880",emphasis:"#6EB8D1"},surface:{background:"#FDFAF4",foreground:"#394049",muted:"#f7f3eb",mutedForeground:"#777e87",elevated:"#faf6ed",elevatedForeground:"#4F5964",overlay:"#1B232B20",subtle:"#FFF7E5"},interactive:{border:"#ece5d9",borderHover:"#DCD3C5",borderFocus:"#B09F8F",selection:"#9fb2c43e",selectionForeground:"#171e25",focus:"#4AA8C8",focusRing:"#4AA8C840",cursor:"#1B232B",hover:"#9fb2c42c",active:"#9fb2c43e"},status:{error:"#E6656A",errorForeground:"#FDFAF4",errorBackground:"#E6656A20",errorBorder:"#E6656A50",warning:"#EA9F41",warningForeground:"#FDFAF4",warningBackground:"#EA9F4120",warningBorder:"#EA9F4150",success:"#5FB978",successForeground:"#FDFAF4",successBackground:"#5FB97820",successBorder:"#5FB97850",info:"#2F9BCE",infoForeground:"#FDFAF4",infoBackground:"#2F9BCE20",infoBorder:"#2F9BCE50"},pr:{open:"#5FB978",draft:"#77818D",blocked:"#EA9F41",merged:"#7b3cda",closed:"#E6656A"},syntax:{base:{background:"#FCF9F3",foreground:"#4F5964",comment:"#77818D",keyword:"#4AA8C8",string:"#7FAD00",number:"#EF7D71",function:"#4AA8C8",variable:"#4F5964",type:"#ED982E",operator:"#EF7D71"},tokens:{boolean:"#ED982E",class:"#4AA8C8",className:"#4AA8C8",commentDoc:"#BABEC1",constant:"#2F9BCE",decorator:"#ED982E",enum:"#4AA8C8",exception:"#EF7D71",functionCall:"#4AA8C8",interface:"#ED982E",jsxTag:"#4AA8C8",key:"#4AA8C8",keywordImport:"#EF7D71",label:"#EF7D71",macro:"#2F9BCE",method:"#5FB978",module:"#EF7D71",namespace:"#ED982E",parameter:"#4F5964",preprocessor:"#EF7D71",punctuation:"#77818D",regex:"#7FAD00",storageModifier:"#2F9BCE",stringEscape:"#1B232B",struct:"#4AA8C8",tag:"#4AA8C8",tagAttribute:"#ED982E",tagAttributeValue:"#7FAD00",typeParameter:"#ED982E",url:"#2F9BCE",variableGlobal:"#4AA8C8",variableLocal:"#FBF8F2",variableOther:"#5FB978",variableProperty:"#2F9BCE"},highlights:{diffAdded:"#5FB978",diffAddedBackground:"#EEF5E4",diffModified:"#2F9BCE",diffModifiedBackground:"#E3EDF3",diffRemoved:"#E6656A",diffRemovedBackground:"#FDE5E5",lineNumber:"#C6BFAF",lineNumberActive:"#1B232B"}},markdown:{heading1:"#394049",heading2:"#394049",heading3:"#394049",heading4:"#394049",link:"#2F9BCE",linkHover:"#4AA8C8",inlineCode:"#7FAD00",inlineCodeBackground:"#FCF9F3",blockquote:"#ED982E",blockquoteBorder:"#E6DDCF",listMarker:"#4AA8C899"},chat:{userMessage:"#4F5964",userMessageBackground:"#fff7e5",assistantMessage:"#4F5964",assistantMessageBackground:"#FDFAF4",timestamp:"#77818D",divider:"#E6DDCF"},tools:{background:"#FCF9F380",border:"#cec6b980",headerHover:"#FAF7F1",icon:"#77818D",title:"#4F5964",description:"#77818D",edit:{added:"#5FB978",addedBackground:"#5FB97825",removed:"#E6656A",removedBackground:"#E6656A25",lineNumber:"#C6BFAF"}}},Zm={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},eg={metadata:Xm,colors:Qm,config:Zm},tg={id:"carbonfox-dark",name:"Carbonfox",description:"Carbonfox",version:"1.0.0",variant:"dark",tags:["dark","palette"]},rg={primary:{base:"#33B1FF",hover:"#2F9ADC",active:"#52BDFF",foreground:"#161616",muted:"#33B1FF80",emphasis:"#2F9ADC"},surface:{background:"#161616",foreground:"#F2F4F8",muted:"#222222",mutedForeground:"#8b8a8a",elevated:"#222222",elevatedForeground:"#F2F4F8",overlay:"#FFFFFF20",subtle:"#292828"},interactive:{border:"#2d2c2c",borderHover:"#4C4C4C",borderFocus:"#4589FF",selection:"#ffffff20",selectionForeground:"#FFFFFF",focus:"#4589FF",focusRing:"#4589FF40",cursor:"#FFFFFF",hover:"#ffffff12",active:"#ffffff12"},status:{error:"#FF8389",errorForeground:"#161616",errorBackground:"#FF838920",errorBorder:"#FF838950",warning:"#F1C21B",warningForeground:"#161616",warningBackground:"#F1C21B20",warningBorder:"#F1C21B50",success:"#42BE65",successForeground:"#161616",successBackground:"#42BE6520",successBorder:"#42BE6550",info:"#78A9FF",infoForeground:"#161616",infoBackground:"#78A9FF20",infoBorder:"#78A9FF50"},pr:{open:"#42BE65",draft:"#8D8D8D",blocked:"#F1C21B",merged:"#BE95FF",closed:"#FF8389"},syntax:{base:{background:"#262626",foreground:"#F2F4F8",comment:"#8D8D8D",keyword:"#78A9FF",string:"#42BE65",number:"#FF8389",function:"#78A9FF",variable:"#F2F4F8",type:"#08BDBA",operator:"#FF8389"},tokens:{boolean:"#08BDBA",class:"#78A9FF",className:"#78A9FF",commentDoc:"#7B7B7B",constant:"#BE95FF",decorator:"#08BDBA",enum:"#78A9FF",exception:"#FF8389",functionCall:"#78A9FF",interface:"#08BDBA",jsxTag:"#78A9FF",key:"#78A9FF",keywordImport:"#FF8389",label:"#FF8389",macro:"#78A9FF",method:"#42BE65",module:"#FF8389",namespace:"#08BDBA",parameter:"#F2F4F8",preprocessor:"#FF8389",punctuation:"#8D8D8D",regex:"#42BE65",storageModifier:"#78A9FF",stringEscape:"#FFFFFF",struct:"#78A9FF",tag:"#78A9FF",tagAttribute:"#08BDBA",tagAttributeValue:"#42BE65",typeParameter:"#08BDBA",url:"#33B1FF",variableGlobal:"#78A9FF",variableLocal:"#0D0D0D",variableOther:"#42BE65",variableProperty:"#BE95FF"},highlights:{diffAdded:"#42BE65",diffAddedBackground:"#0E3A22",diffModified:"#78A9FF",diffModifiedBackground:"#78A9FF20",diffRemoved:"#FF8389",diffRemovedBackground:"#4D1A1F",lineNumber:"#4C4C4C",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#F2F4F8",heading2:"#F2F4F8",heading3:"#F2F4F8",heading4:"#F2F4F8",link:"#33B1FF",linkHover:"#78A9FF",inlineCode:"#42BE65",inlineCodeBackground:"#1e1e1e",blockquote:"#8D8D8D",blockquoteBorder:"#393939",listMarker:"#33B1FF99"},chat:{userMessage:"#F2F4F8",userMessageBackground:"#262626",assistantMessage:"#F2F4F8",assistantMessageBackground:"#161616",timestamp:"#8D8D8D",divider:"#393939"},tools:{background:"#26262680",border:"#4e4c4c80",headerHover:"#000000",icon:"#8D8D8D",title:"#F2F4F8",description:"#8D8D8D",edit:{added:"#42BE65",addedBackground:"#42BE6525",removed:"#FF8389",removedBackground:"#FF838925",lineNumber:"#4C4C4C"}}},og={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},ng={metadata:tg,colors:rg,config:og},ag={id:"carbonfox-light",name:"Carbonfox",description:"Carbonfox",version:"1.0.0",variant:"light",tags:["light","palette"]},sg={primary:{base:"#0072C3",hover:"#338ECF",active:"#0061A6",foreground:"#FFFFFF",muted:"#0072C380",emphasis:"#338ECF"},surface:{background:"#FFFFFF",foreground:"#161616",muted:"#F4F4F4",mutedForeground:"#868585",elevated:"#f4f4f7",elevatedForeground:"#161616",overlay:"#00000020",subtle:"#f6f6f8"},interactive:{border:"#e3e2e2",borderHover:"#D0D0D0",borderFocus:"#0F62FE",selection:"#cacfd87f",selectionForeground:"#000000",focus:"#0F62FE",focusRing:"#0F62FE40",cursor:"#000000",hover:"#43424214",active:"#43424212"},status:{error:"#DA1E28",errorForeground:"#FFFFFF",errorBackground:"#DA1E2820",errorBorder:"#DA1E2850",warning:"#F1C21B",warningForeground:"#FFFFFF",warningBackground:"#F1C21B20",warningBorder:"#F1C21B50",success:"#198038",successForeground:"#FFFFFF",successBackground:"#19803820",successBorder:"#19803850",info:"#0043CE",infoForeground:"#FFFFFF",infoBackground:"#0043CE20",infoBorder:"#0043CE50"},pr:{open:"#42BE65",draft:"#8D8D8D",blocked:"#F1C21B",merged:"#BE95FF",closed:"#FF8389"},syntax:{base:{background:"#F4F4F4",foreground:"#161616",comment:"#525252",keyword:"#0043CE",string:"#198038",number:"#DA1E28",function:"#0043CE",variable:"#161616",type:"#007D79",operator:"#DA1E28"},tokens:{boolean:"#007D79",class:"#0043CE",className:"#0043CE",commentDoc:"#A9A9A9",constant:"#6929C4",decorator:"#007D79",enum:"#0043CE",exception:"#DA1E28",functionCall:"#0043CE",interface:"#007D79",jsxTag:"#0043CE",key:"#0043CE",keywordImport:"#DA1E28",label:"#DA1E28",macro:"#0043CE",method:"#198038",module:"#DA1E28",namespace:"#007D79",parameter:"#161616",preprocessor:"#DA1E28",punctuation:"#525252",regex:"#198038",storageModifier:"#0043CE",stringEscape:"#000000",struct:"#0043CE",tag:"#0043CE",tagAttribute:"#007D79",tagAttributeValue:"#198038",typeParameter:"#007D79",url:"#0072C3",variableGlobal:"#0043CE",variableLocal:"#E8E8E8",variableOther:"#198038",variableProperty:"#6929C4"},highlights:{diffAdded:"#198038",diffAddedBackground:"#19803820",diffModified:"#0043CE",diffModifiedBackground:"#0043CE20",diffRemoved:"#DA1E28",diffRemovedBackground:"#DA1E2820",lineNumber:"#D0D0D0",lineNumberActive:"#000000"}},markdown:{heading1:"#161616",heading2:"#161616",heading3:"#161616",heading4:"#161616",link:"#0072C3",linkHover:"#0043CE",inlineCode:"#198038",inlineCodeBackground:"#F4F4F4",blockquote:"#525252",blockquoteBorder:"#DCDCDC",listMarker:"#0072C399"},chat:{userMessage:"#161616",userMessageBackground:"#f4f4f7",assistantMessage:"#161616",assistantMessageBackground:"#FFFFFF",timestamp:"#525252",divider:"#DCDCDC"},tools:{background:"#F4F4F480",border:"#bdbbbb80",headerHover:"#DCDCDC",icon:"#525252",title:"#161616",description:"#525252",edit:{added:"#198038",addedBackground:"#19803825",removed:"#DA1E28",removedBackground:"#DA1E2825",lineNumber:"#D0D0D0"}}},ig={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},cg={metadata:ag,colors:sg,config:ig},dg={id:"catppuccin-dark",name:"Catppuccin",description:"Catppuccin",version:"1.0.0",variant:"dark",tags:["dark","palette"]},lg={primary:{base:"#7d8fff",hover:"#9EA6DF",active:"#BEC6FE",foreground:"#1E1E2E",muted:"#B4BEFE80",emphasis:"#9EA6DF"},surface:{background:"#1E1E2E",foreground:"#CDD6F4",muted:"#2a273b",mutedForeground:"#969cb1",elevated:"#282841",elevatedForeground:"#CDD6F4",overlay:"#F4F2FF20",subtle:"#26263f"},interactive:{border:"#35324A",borderHover:"#393655",borderFocus:"#575379",selection:"#8883ae5c",selectionForeground:"#F4F2FF",focus:"#B4BEFE",focusRing:"#B4BEFE40",cursor:"#F4F2FF",hover:"#a19ace20",active:"#a19ace20"},status:{error:"#F38BA8",errorForeground:"#1E1E2E",errorBackground:"#F38BA820",errorBorder:"#F38BA850",warning:"#F4B8E4",warningForeground:"#1E1E2E",warningBackground:"#F4B8E420",warningBorder:"#F4B8E450",success:"#A6D189",successForeground:"#1E1E2E",successBackground:"#A6D18920",successBorder:"#A6D18950",info:"#89DCEB",infoForeground:"#1E1E2E",infoBackground:"#89DCEB20",infoBorder:"#89DCEB50"},pr:{open:"#A6D189",draft:"#A6ADC8",blocked:"#F9E2AF",merged:"#d8b4fe",closed:"#F38BA8"},syntax:{base:{background:"#211F31",foreground:"#CDD6F4",comment:"#A6ADC8",keyword:"#B4BEFE",string:"#A6E3A1",number:"#F38BA8",function:"#B4BEFE",variable:"#CDD6F4",type:"#F9E2AF",operator:"#F38BA8"},tokens:{boolean:"#F9E2AF",class:"#B4BEFE",className:"#B4BEFE",commentDoc:"#9298B1",constant:"#89DCEB",decorator:"#F9E2AF",enum:"#B4BEFE",exception:"#F38BA8",functionCall:"#B4BEFE",interface:"#F9E2AF",jsxTag:"#B4BEFE",key:"#B4BEFE",keywordImport:"#F38BA8",label:"#F38BA8",macro:"#89DCEB",method:"#A6D189",module:"#F38BA8",namespace:"#F9E2AF",parameter:"#CDD6F4",preprocessor:"#F38BA8",punctuation:"#A6ADC8",regex:"#A6E3A1",storageModifier:"#89DCEB",stringEscape:"#F4F2FF",struct:"#B4BEFE",tag:"#B4BEFE",tagAttribute:"#F9E2AF",tagAttributeValue:"#A6E3A1",typeParameter:"#F9E2AF",url:"#89DCEB",variableGlobal:"#B4BEFE",variableLocal:"#1C1C29",variableOther:"#A6D189",variableProperty:"#89DCEB"},highlights:{diffAdded:"#A6D189",diffAddedBackground:"#1D2C30",diffModified:"#89DCEB",diffModifiedBackground:"#232538",diffRemoved:"#F38BA8",diffRemovedBackground:"#2C1F2A",lineNumber:"#47436D",lineNumberActive:"#F4F2FF"}},markdown:{heading1:"#CDD6F4",heading2:"#CDD6F4",heading3:"#CDD6F4",heading4:"#CDD6F4",link:"#89DCEB",linkHover:"#B4BEFE",inlineCode:"#A6E3A1",inlineCodeBackground:"#2d2a42",blockquote:"#F9E2AF",blockquoteBorder:"#35324A",listMarker:"#B4BEFE99"},chat:{userMessage:"#CDD6F4",userMessageBackground:"#3a3a5b",assistantMessage:"#CDD6F4",assistantMessageBackground:"#1E1E2E",timestamp:"#A6ADC8",divider:"#35324A"},tools:{background:"#211F3180",border:"#534e7180",headerHover:"#191926",icon:"#A6ADC8",title:"#CDD6F4",description:"#A6ADC8",edit:{added:"#A6D189",addedBackground:"#A6D18925",removed:"#F38BA8",removedBackground:"#F38BA825",lineNumber:"#47436D"}}},ug={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},fg={metadata:dg,colors:lg,config:ug},mg={id:"catppuccin-light",name:"Catppuccin",description:"Catppuccin",version:"1.0.0",variant:"light",tags:["light","palette"]},gg={primary:{base:"#7287FD",hover:"#8C99F6",active:"#6677DD",foreground:"#F5E0DC",muted:"#7287FD80",emphasis:"#8C99F6"},surface:{background:"#fff6f4",foreground:"#2e314a",muted:"#f8edeb",mutedForeground:"#888992",elevated:"#fbefea",elevatedForeground:"#4C4F69",overlay:"#1F1F2A20",subtle:"#fdeeee"},interactive:{border:"#e4d9dc",borderHover:"#D6C4C8",borderFocus:"#AB97A1",selection:"#ffffff",selectionForeground:"#1F1F2A",focus:"#7287FD",focusRing:"#7287FD40",cursor:"#1F1F2A",hover:"#ffffff8f",active:"#ffffff"},status:{error:"#D20F39",errorForeground:"#F5E0DC",errorBackground:"#D20F3920",errorBorder:"#D20F3950",warning:"#DF8E1D",warningForeground:"#F5E0DC",warningBackground:"#DF8E1D20",warningBorder:"#DF8E1D50",success:"#40A02B",successForeground:"#F5E0DC",successBackground:"#40A02B20",successBorder:"#40A02B50",info:"#04A5E5",infoForeground:"#F5E0DC",infoBackground:"#04A5E520",infoBorder:"#04A5E550"},pr:{open:"#40A02B",draft:"#6C6F85",blocked:"#DF8E1D",merged:"#9572fd",closed:"#D20F39"},syntax:{base:{background:"#F2D8D4",foreground:"#4C4F69",comment:"#6C6F85",keyword:"#7287FD",string:"#40A02B",number:"#D20F39",function:"#7287FD",variable:"#4C4F69",type:"#DF8E1D",operator:"#D20F39"},tokens:{boolean:"#DF8E1D",class:"#7287FD",className:"#7287FD",commentDoc:"#B1A8B1",constant:"#04A5E5",decorator:"#DF8E1D",enum:"#7287FD",exception:"#D20F39",functionCall:"#7287FD",interface:"#DF8E1D",jsxTag:"#7287FD",key:"#7287FD",keywordImport:"#D20F39",label:"#D20F39",macro:"#04A5E5",method:"#40A02B",module:"#D20F39",namespace:"#DF8E1D",parameter:"#4C4F69",preprocessor:"#D20F39",punctuation:"#6C6F85",regex:"#40A02B",storageModifier:"#04A5E5",stringEscape:"#1F1F2A",struct:"#7287FD",tag:"#7287FD",tagAttribute:"#DF8E1D",tagAttributeValue:"#40A02B",typeParameter:"#DF8E1D",url:"#04A5E5",variableGlobal:"#7287FD",variableLocal:"#F9E8E4",variableOther:"#40A02B",variableProperty:"#04A5E5"},highlights:{diffAdded:"#40A02B",diffAddedBackground:"#EDF5E6",diffModified:"#04A5E5",diffModifiedBackground:"#E4E2F6",diffRemoved:"#D20F39",diffRemovedBackground:"#FDE1E3",lineNumber:"#C2AEB4",lineNumberActive:"#1F1F2A"}},markdown:{heading1:"#2e314a",heading2:"#2e314a",heading3:"#2e314a",heading4:"#2e314a",link:"#04A5E5",linkHover:"#7287FD",inlineCode:"#40A02B",inlineCodeBackground:"#f6eeec",blockquote:"#DF8E1D",blockquoteBorder:"#E0CFD3",listMarker:"#7287FD99"},chat:{userMessage:"#2e314a",userMessageBackground:"#ffffff",assistantMessage:"#4C4F69",assistantMessageBackground:"#F5E0DC",timestamp:"#6C6F85",divider:"#E0CFD3"},tools:{background:"#F2D8D480",border:"#cbbec180",headerHover:"#FDEEEE",icon:"#6C6F85",title:"#4C4F69",description:"#6C6F85",edit:{added:"#40A02B",addedBackground:"#40A02B25",removed:"#D20F39",removedBackground:"#D20F3925",lineNumber:"#C2AEB4"}}},pg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},hg={metadata:mg,colors:gg,config:pg},Fg={id:"dracula-dark",name:"Dracula",description:"Dracula",version:"1.0.0",variant:"dark",tags:["dark","palette"]},yg={primary:{base:"#BD93F9",hover:"#A480D8",active:"#C7A3FA",foreground:"#14151F",muted:"#BD93F980",emphasis:"#A480D8"},surface:{background:"#14151F",foreground:"#F8F8F2",muted:"#181926",mutedForeground:"#7c7e9c",elevated:"#161722",elevatedForeground:"#F8F8F2",overlay:"#FFFFFF20",subtle:"#1f2030"},interactive:{border:"#292a36",borderHover:"#303244",borderFocus:"#4A4D6D",selection:"#30334b",selectionForeground:"#FFFFFF",focus:"#BD93F9",focusRing:"#BD93F940",cursor:"#FFFFFF",hover:"#30334ba3",active:"#30334b"},status:{error:"#FF5555",errorForeground:"#14151F",errorBackground:"#FF555520",errorBorder:"#FF555550",warning:"#FFB86C",warningForeground:"#14151F",warningBackground:"#FFB86C20",warningBorder:"#FFB86C50",success:"#50FA7B",successForeground:"#14151F",successBackground:"#50FA7B20",successBorder:"#50FA7B50",info:"#8BE9FD",infoForeground:"#14151F",infoBackground:"#8BE9FD20",infoBorder:"#8BE9FD50"},pr:{open:"#50FA7B",draft:"#B6B9E4",blocked:"#FFB86C",merged:"#BD93F9",closed:"#FF5555"},syntax:{base:{background:"#181926",foreground:"#F8F8F2",comment:"#B6B9E4",keyword:"#BD93F9",string:"#50FA7B",number:"#FF79C6",function:"#BD93F9",variable:"#F8F8F2",type:"#FFB86C",operator:"#FF79C6"},tokens:{boolean:"#FFB86C",class:"#BD93F9",className:"#BD93F9",commentDoc:"#9EA0C6",constant:"#8BE9FD",decorator:"#FFB86C",enum:"#BD93F9",exception:"#FF79C6",functionCall:"#BD93F9",interface:"#FFB86C",jsxTag:"#BD93F9",key:"#BD93F9",keywordImport:"#FF79C6",label:"#FF79C6",macro:"#8BE9FD",method:"#50FA7B",module:"#FF79C6",namespace:"#FFB86C",parameter:"#F8F8F2",preprocessor:"#FF79C6",punctuation:"#B6B9E4",regex:"#50FA7B",storageModifier:"#8BE9FD",stringEscape:"#FFFFFF",struct:"#BD93F9",tag:"#BD93F9",tagAttribute:"#FFB86C",tagAttributeValue:"#50FA7B",typeParameter:"#FFB86C",url:"#8BE9FD",variableGlobal:"#BD93F9",variableLocal:"#161722",variableOther:"#50FA7B",variableProperty:"#8BE9FD"},highlights:{diffAdded:"#50FA7B",diffAddedBackground:"#1F2A2F",diffModified:"#8BE9FD",diffModifiedBackground:"#24253A",diffRemoved:"#FF5555",diffRemovedBackground:"#2D1F27",lineNumber:"#3B3D55",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#F8F8F2",heading2:"#F8F8F2",heading3:"#F8F8F2",heading4:"#F8F8F2",link:"#8BE9FD",linkHover:"#BD93F9",inlineCode:"#4aeb72",inlineCodeBackground:"#202132",blockquote:"#FFB86C",blockquoteBorder:"#2D2F3C",listMarker:"#BD93F999"},chat:{userMessage:"#F8F8F2",userMessageBackground:"#222436",assistantMessage:"#F8F8F2",assistantMessageBackground:"#14151F",timestamp:"#B6B9E4",divider:"#2D2F3C"},tools:{background:"#18192680",border:"#494c6180",headerHover:"#191A26",icon:"#B6B9E4",title:"#F8F8F2",description:"#B6B9E4",edit:{added:"#50FA7B",addedBackground:"#50FA7B25",removed:"#FF5555",removedBackground:"#FF555525",lineNumber:"#3B3D55"}}},bg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Ag={metadata:Fg,colors:yg,config:bg},Eg={id:"dracula-light",name:"Dracula",description:"Dracula",version:"1.0.0",variant:"light",tags:["light","palette"]},wg={primary:{base:"#7C6BF5",hover:"#9587F4",active:"#6A5CD2",foreground:"#F8F8F2",muted:"#7C6BF580",emphasis:"#9587F4"},surface:{background:"#F8F8F2",foreground:"#1F1F2F",muted:"#eff1eb",mutedForeground:"#6c6c7a",elevated:"#eeeee5",elevatedForeground:"#1F1F2F",overlay:"#05040C20",subtle:"#edeee7"},interactive:{border:"#E2E3DA",borderHover:"#D8D9D0",borderFocus:"#B0B2A7",selection:"#c2bcea63",selectionForeground:"#05040C",focus:"#7C6BF5",focusRing:"#7C6BF540",cursor:"#05040C",hover:"#c2bcea38",active:"#c2bcea63"},status:{error:"#D9536F",errorForeground:"#F8F8F2",errorBackground:"#D9536F20",errorBorder:"#D9536F50",warning:"#F7A14D",warningForeground:"#F8F8F2",warningBackground:"#F7A14D20",warningBorder:"#F7A14D50",success:"#2FBF71",successForeground:"#F8F8F2",successBackground:"#2FBF7120",successBorder:"#2FBF7150",info:"#1D7FC5",infoForeground:"#F8F8F2",infoBackground:"#1D7FC520",infoBorder:"#1D7FC550"},pr:{open:"#2FBF71",draft:"#52526B",blocked:"#F7A14D",merged:"#7C6BF5",closed:"#D9536F"},syntax:{base:{background:"#F1F2ED",foreground:"#1F1F2F",comment:"#52526B",keyword:"#7C6BF5",string:"#2FBF71",number:"#D16090",function:"#7C6BF5",variable:"#1F1F2F",type:"#F7A14D",operator:"#D16090"},tokens:{boolean:"#F7A14D",class:"#7C6BF5",className:"#7C6BF5",commentDoc:"#A5A5AF",constant:"#1D7FC5",decorator:"#F7A14D",enum:"#7C6BF5",exception:"#D16090",functionCall:"#7C6BF5",interface:"#F7A14D",jsxTag:"#7C6BF5",key:"#7C6BF5",keywordImport:"#D16090",label:"#D16090",macro:"#1D7FC5",method:"#2FBF71",module:"#D16090",namespace:"#F7A14D",parameter:"#1F1F2F",preprocessor:"#D16090",punctuation:"#52526B",regex:"#2FBF71",storageModifier:"#1D7FC5",stringEscape:"#05040C",struct:"#7C6BF5",tag:"#7C6BF5",tagAttribute:"#F7A14D",tagAttributeValue:"#2FBF71",typeParameter:"#F7A14D",url:"#1D7FC5",variableGlobal:"#7C6BF5",variableLocal:"#F6F6F1",variableOther:"#2FBF71",variableProperty:"#1D7FC5"},highlights:{diffAdded:"#2FBF71",diffAddedBackground:"#E4F5E6",diffModified:"#1D7FC5",diffModifiedBackground:"#DEDFE9",diffRemoved:"#D9536F",diffRemovedBackground:"#FAE4EB",lineNumber:"#C4C6BC",lineNumberActive:"#05040C"}},markdown:{heading1:"#1F1F2F",heading2:"#1F1F2F",heading3:"#1F1F2F",heading4:"#1F1F2F",link:"#1D7FC5",linkHover:"#7C6BF5",inlineCode:"#2FBF71",inlineCodeBackground:"#F1F2ED",blockquote:"#F7A14D",blockquoteBorder:"#E2E3DA",listMarker:"#7C6BF599"},chat:{userMessage:"#1F1F2F",userMessageBackground:"#F1F2ED",assistantMessage:"#1F1F2F",assistantMessageBackground:"#F8F8F2",timestamp:"#52526B",divider:"#E2E3DA"},tools:{background:"#F1F2ED80",border:"#E2E3DA80",headerHover:"#F2F2EC",icon:"#52526B",title:"#1F1F2F",description:"#52526B",edit:{added:"#2FBF71",addedBackground:"#2FBF7125",removed:"#D9536F",removedBackground:"#D9536F25",lineNumber:"#C4C6BC"}}},Bg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Cg={metadata:Eg,colors:wg,config:Bg},vg={id:"gruvbox-dark",name:"Gruvbox",description:"Gruvbox",version:"1.0.0",variant:"dark",tags:["dark","palette"]},kg={primary:{base:"#83A598",hover:"#759287",active:"#95B09F",foreground:"#282828",muted:"#83A59880",emphasis:"#759287"},surface:{background:"#282828",foreground:"#EBDBB2",muted:"#32302F",mutedForeground:"#918574",elevated:"#25292b",elevatedForeground:"#EBDBB2",overlay:"#FBF1C720",subtle:"#343230"},interactive:{border:"#453f3b",borderHover:"#5A524B",borderFocus:"#7C6F64",selection:"#5a5647db",selectionForeground:"#FBF1C7",focus:"#83A598",focusRing:"#83A59840",cursor:"#FBF1C7",hover:"#5a5647d9",active:"#5a5647ec"},status:{error:"#FB4934",errorForeground:"#282828",errorBackground:"#FB493420",errorBorder:"#FB493450",warning:"#FABD2F",warningForeground:"#282828",warningBackground:"#FABD2F20",warningBorder:"#FABD2F50",success:"#B8BB26",successForeground:"#282828",successBackground:"#B8BB2620",successBorder:"#B8BB2650",info:"#D3869B",infoForeground:"#282828",infoBackground:"#D3869B20",infoBorder:"#D3869B50"},pr:{open:"#B8BB26",draft:"#A89984",blocked:"#FABD2F",merged:"#8973a8",closed:"#FB4934"},syntax:{base:{background:"#32302F",foreground:"#EBDBB2",comment:"#A89984",keyword:"#83A598",string:"#B8BB26",number:"#FB4934",function:"#83A598",variable:"#EBDBB2",type:"#FABD2F",operator:"#FB4934"},tokens:{boolean:"#FABD2F",class:"#83A598",className:"#83A598",commentDoc:"#958876",constant:"#D3869B",decorator:"#FABD2F",enum:"#83A598",exception:"#FB4934",functionCall:"#83A598",interface:"#FABD2F",jsxTag:"#83A598",key:"#83A598",keywordImport:"#FB4934",label:"#FB4934",macro:"#8EC07C",method:"#B8BB26",module:"#FB4934",namespace:"#FABD2F",parameter:"#EBDBB2",preprocessor:"#FB4934",punctuation:"#A89984",regex:"#B8BB26",storageModifier:"#8EC07C",stringEscape:"#FBF1C7",struct:"#83A598",tag:"#83A598",tagAttribute:"#FABD2F",tagAttributeValue:"#B8BB26",typeParameter:"#FABD2F",url:"#8EC07C",variableGlobal:"#83A598",variableLocal:"#1D2021",variableOther:"#B8BB26",variableProperty:"#D3869B"},highlights:{diffAdded:"#B8BB26",diffAddedBackground:"#2A3325",diffModified:"#D3869B",diffModifiedBackground:"#32302F",diffRemoved:"#FB4934",diffRemovedBackground:"#3C2222",lineNumber:"#70665D",lineNumberActive:"#FBF1C7"}},markdown:{heading1:"#EBDBB2",heading2:"#EBDBB2",heading3:"#EBDBB2",heading4:"#EBDBB2",link:"#8EC07C",linkHover:"#83A598",inlineCode:"#B8BB26",inlineCodeBackground:"#32302F",blockquote:"#928374",blockquoteBorder:"#504945",listMarker:"#83A59899"},chat:{userMessage:"#EBDBB2",userMessageBackground:"#3e3c3a",assistantMessage:"#EBDBB2",assistantMessageBackground:"#282828",timestamp:"#A89984",divider:"#504945"},tools:{background:"#32302F80",border:"#6e645e80",headerHover:"#141617",icon:"#A89984",title:"#EBDBB2",description:"#A89984",edit:{added:"#B8BB26",addedBackground:"#B8BB2625",removed:"#FB4934",removedBackground:"#FB493425",lineNumber:"#70665D"}}},Dg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Sg={metadata:vg,colors:kg,config:Dg},Mg={id:"gruvbox-light",name:"Gruvbox",description:"Gruvbox",version:"1.0.0",variant:"light",tags:["light","palette"]},Tg={primary:{base:"#076678",hover:"#388288",active:"#0C5D6C",foreground:"#FBF1C7",muted:"#07667880",emphasis:"#388288"},surface:{background:"#f8f1d5",foreground:"#3C3836",muted:"#F2E5BC",mutedForeground:"#7C6F64",elevated:"#efebcd",elevatedForeground:"#3C3836",overlay:"#28282820",subtle:"#f3efde"},interactive:{border:"#e8d7b7",borderHover:"#C9B897",borderFocus:"#A89984",selection:"#f1eaeaec",selectionForeground:"#282828",focus:"#076678",focusRing:"#07667840",cursor:"#282828",hover:"#fffdfdb3",active:"#f1eaeaec"},status:{error:"#9D0006",errorForeground:"#FBF1C7",errorBackground:"#9D000620",errorBorder:"#9D000650",warning:"#B57614",warningForeground:"#FBF1C7",warningBackground:"#B5761420",warningBorder:"#B5761450",success:"#79740E",successForeground:"#FBF1C7",successBackground:"#79740E20",successBorder:"#79740E50",info:"#8F3F71",infoForeground:"#FBF1C7",infoBackground:"#8F3F7120",infoBorder:"#8F3F7150"},pr:{open:"#79740E",draft:"#7C6F64",blocked:"#B57614",merged:"#5e4c76",closed:"#9D0006"},syntax:{base:{background:"#F2E5BC",foreground:"#3C3836",comment:"#7C6F64",keyword:"#076678",string:"#79740E",number:"#9D0006",function:"#076678",variable:"#3C3836",type:"#B57614",operator:"#9D0006"},tokens:{boolean:"#B57614",class:"#076678",className:"#076678",commentDoc:"#BCB096",constant:"#8F3F71",decorator:"#B57614",enum:"#076678",exception:"#9D0006",functionCall:"#076678",interface:"#B57614",jsxTag:"#076678",key:"#076678",keywordImport:"#9D0006",label:"#9D0006",macro:"#427B58",method:"#79740E",module:"#9D0006",namespace:"#B57614",parameter:"#3C3836",preprocessor:"#9D0006",punctuation:"#7C6F64",regex:"#79740E",storageModifier:"#427B58",stringEscape:"#282828",struct:"#076678",tag:"#076678",tagAttribute:"#B57614",tagAttributeValue:"#79740E",typeParameter:"#B57614",url:"#427B58",variableGlobal:"#076678",variableLocal:"#F9F5D7",variableOther:"#79740E",variableProperty:"#8F3F71"},highlights:{diffAdded:"#79740E",diffAddedBackground:"#DDE3B1",diffModified:"#8F3F71",diffModifiedBackground:"#EBDFB5",diffRemoved:"#9D0006",diffRemovedBackground:"#E8C7C3",lineNumber:"#B0A285",lineNumberActive:"#282828"}},markdown:{heading1:"#3C3836",heading2:"#3C3836",heading3:"#3C3836",heading4:"#3C3836",link:"#427B58",linkHover:"#076678",inlineCode:"#79740E",inlineCodeBackground:"#F2E5BC",blockquote:"#928374",blockquoteBorder:"#D5C4A1",listMarker:"#07667899"},chat:{userMessage:"#3C3836",userMessageBackground:"#FDF9E8",assistantMessage:"#3C3836",assistantMessageBackground:"#FBF1C7",timestamp:"#7C6F64",divider:"#D5C4A1"},tools:{background:"#F2E5BC80",border:"#a6997e80",headerHover:"#FDF9E8",icon:"#7C6F64",title:"#3C3836",description:"#7C6F64",edit:{added:"#79740E",addedBackground:"#79740E25",removed:"#9D0006",removedBackground:"#9D000625",lineNumber:"#B0A285"}}},Pg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Rg={metadata:Mg,colors:Tg,config:Pg},Ig={id:"jetbrains-dark",name:"JetBrains",description:"JetBrains IDE-inspired colors for PiChamber - dark variant",author:"Artem Evsevev, adapted for PiChamber",version:"1.0.0",variant:"dark",tags:["dark","jetbrains","ide","blue"]},_g={primary:{base:"#6796f5",hover:"#70AEFF",active:"#5594FA",foreground:"#1E1F22",muted:"#6796f580",emphasis:"#70AEFF"},surface:{background:"#1E1F22",foreground:"#DFE1E5",muted:"#26282B",mutedForeground:"#9fa0a2",elevated:"#2B2D30",elevatedForeground:"#DFE1E5",overlay:"#00000080",subtle:"#28292c"},interactive:{border:"#383a3f",borderHover:"#4B5059",borderFocus:"#6796f5",selection:"#43454A",selectionForeground:"#DFE1E5",focus:"#6796f5",focusRing:"#6796f550",cursor:"#CED0D6",hover:"#3C3E41",active:"#494A4D"},status:{error:"#FA6675",errorForeground:"#1E1F22",errorBackground:"#402929",errorBorder:"#FA6675",warning:"#F2C55C",warningForeground:"#1E1F22",warningBackground:"#665014",warningBorder:"#F2C55C",success:"#57965D",successForeground:"#1E1F22",successBackground:"#253627",successBorder:"#57965D",info:"#3592C4",infoForeground:"#1E1F22",infoBackground:"#243846",infoBorder:"#3592C4"},pr:{open:"#5FAD65",draft:"#868A91",blocked:"#F2C55C",merged:"#A571E6",closed:"#DB5C5C"},syntax:{base:{background:"#1E1F22",foreground:"#BCBEC4",comment:"#7A7E85",keyword:"#CF8E6D",string:"#6AAB73",number:"#2AACB8",function:"#6AA2D7",variable:"#BCBEC4",type:"#A6BB77",operator:"#BCBEC4"},tokens:{commentDoc:"#5F826B",stringEscape:"#CF8E6D",keywordImport:"#CF8E6D",storageModifier:"#CF8E6D",functionCall:"#6AA2D7",method:"#6AA2D7",functionBuiltin:"#D5A563",variableProperty:"#C77DBB",variableOther:"#BCBEC4",variableGlobal:"#E59EAE",variableLocal:"#BCBEC4",parameter:"#3CACAC",constant:"#C77DBB",class:"#57AAF7",className:"#57AAF7",interface:"#8D91DC",struct:"#A6BB77",enum:"#A6BB77",typeParameter:"#3CACAC",namespace:"#BCBEC4",module:"#8D91DC",tag:"#D5B778",jsxTag:"#D5B778",tagAttribute:"#B3AE60",tagAttributeValue:"#6AAB73",boolean:"#CF8E6D",decorator:"#B3AE60",label:"#D5A563",punctuation:"#BCBEC4",macro:"#D5A563",preprocessor:"#D5A563",regex:"#6AAB73",url:"#57AAF7",key:"#C77DBB",exception:"#E59EAE"},highlights:{diffAdded:"#549159",diffAddedBackground:"#294436",diffRemoved:"#F75464",diffRemovedBackground:"#45302B",diffModified:"#70AEFF",diffModifiedBackground:"#243C63",lineNumber:"#4B5059",lineNumberActive:"#A1A3AB"}},markdown:{heading1:"#FFFFFF",heading2:"#DFE1E5",heading3:"#CED0D6",heading4:"#BCBEC4",link:"#56A8F5",linkHover:"#6796f5",inlineCode:"#6AAB73",inlineCodeBackground:"#26282B",blockquote:"#7A7E85",blockquoteBorder:"#393B41",listMarker:"#B3AE6099"},chat:{userMessage:"#DFE1E5",userMessageBackground:"#2a3b5d76",assistantMessage:"#DFE1E5",assistantMessageBackground:"#1E1F22",timestamp:"#7A7E85",divider:"#393B41"},tools:{background:"#26282B50",border:"#393B41",headerHover:"#3C3E4150",icon:"#B0B1B3",title:"#DFE1E5",description:"#B0B1B3",edit:{added:"#549159",addedBackground:"#29443640",removed:"#F75464",removedBackground:"#45302B40",lineNumber:"#4B5059"}}},xg={fonts:{sans:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Og={metadata:Ig,colors:_g,config:xg},Ng={id:"jetbrains-light",name:"JetBrains",description:"JetBrains IDE-inspired colors for PiChamber - light variant",author:"Artem Evsevev, adapted for PiChamber",version:"1.0.0",variant:"light",tags:["light","jetbrains","ide","blue"]},Lg={primary:{base:"#195ce3",hover:"#2D61F0",active:"#0055FF",foreground:"#FFFFFF",muted:"#3573F080",emphasis:"#006DCC"},surface:{background:"#FFF",foreground:"#000000",muted:"#F7F8FA",mutedForeground:"#404040",elevated:"#FFFFFF",elevatedForeground:"#000000",overlay:"#00000025",subtle:"#f5f8fd"},interactive:{border:"#dde0ea",borderHover:"#AEB3C2",borderFocus:"#0055FF",selection:"#DFE1E5",selectionForeground:"#000000",focus:"#0055FF",focusRing:"#0055FF40",cursor:"#000000",hover:"#E6E6E8",active:"#DBDCDE"},status:{error:"#CE0606",errorForeground:"#FFFFFF",errorBackground:"#FFE8E8",errorBorder:"#CF5B56",warning:"#F49810",warningForeground:"#000000",warningBackground:"#FFF8DC",warningBorder:"#F49810",success:"#077D18",successForeground:"#FFFFFF",successBackground:"#E9F5E6",successBorder:"#55A76A",info:"#389FD6",infoForeground:"#000000",infoBackground:"#E7F4FB",infoBorder:"#389FD6"},pr:{open:"#369650",draft:"#808080",blocked:"#F49810",merged:"#834DF0",closed:"#E55765"},syntax:{base:{background:"#FFFFFF",foreground:"#080808",comment:"#8C8C8C",keyword:"#0033B3",string:"#067D17",number:"#1750EB",function:"#00627A",variable:"#000000",type:"#A04908",operator:"#080808"},tokens:{commentDoc:"#8C8C8C",stringEscape:"#0037A6",keywordImport:"#0033B3",storageModifier:"#0033B3",functionCall:"#00627A",method:"#00627A",functionBuiltin:"#C27203",variableProperty:"#871094",variableOther:"#000000",variableGlobal:"#1C5DFE",variableLocal:"#000000",parameter:"#007E8A",constant:"#871094",class:"#00627A",className:"#00627A",interface:"#835DDA",struct:"#A04908",enum:"#A04908",typeParameter:"#007E8A",namespace:"#000000",module:"#835DDA",tag:"#0033B3",jsxTag:"#0033B3",tagAttribute:"#9E880D",tagAttributeValue:"#067D17",boolean:"#0033B3",decorator:"#9E880D",label:"#C27203",punctuation:"#080808",macro:"#C27203",preprocessor:"#C27203",regex:"#067D17",url:"#00627A",key:"#871094",exception:"#1C5DFE"},highlights:{diffAdded:"#077D18",diffAddedBackground:"#BEE6BE",diffRemoved:"#FF0000",diffRemovedBackground:"#FFD5CC",diffModified:"#0133B3",diffModifiedBackground:"#DDE8FF",lineNumber:"#AEB3C2",lineNumberActive:"#767A8A"}},markdown:{heading1:"#000000",heading2:"#161617",heading3:"#404040",heading4:"#404040",link:"#006DCC",linkHover:"#3573F0",inlineCode:"#067D17",inlineCodeBackground:"#F5F7F9",blockquote:"#8C8C8C",blockquoteBorder:"#C9CCD6",listMarker:"#9E880D99"},chat:{userMessage:"#000000",userMessageBackground:"#eff4fd",assistantMessage:"#000000",assistantMessageBackground:"#F7F8FA",timestamp:"#767A8A",divider:"#C9CCD6"},tools:{background:"#F5F7F950",border:"#AEB3C280",headerHover:"#E6E6E8",icon:"#404040",title:"#000000",description:"#404040",edit:{added:"#077D18",addedBackground:"#BEE6BE50",removed:"#FF0000",removedBackground:"#FFD5CC50",lineNumber:"#AEB3C2"}}},Ug={fonts:{sans:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'"JetBrains Mono", ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Hg={metadata:Ng,colors:Lg,config:Ug},Kg={id:"kanagawa-dark",name:"Kanagawa",description:"A color scheme inspired by Japanese art and ink painting - dark variant",version:"1.0.0",variant:"dark",tags:["dark","japanese","ink","elegant"]},jg={primary:{base:"#7FB4CA",hover:"#9DC5E0",active:"#658594",foreground:"#1F1F28",muted:"#7FB4CA80",emphasis:"#7E9CD8"},surface:{background:"#1F1F28",foreground:"#DCD7BA",muted:"#23232d",mutedForeground:"#8b8b85",elevated:"#2A2A37",elevatedForeground:"#DCD7BA",overlay:"#16161DCC",subtle:"#2a2a36"},interactive:{border:"#333343",borderHover:"#54546D",borderFocus:"#7FB4CA",selection:"#729fb333",selectionForeground:"#DCD7BA",focus:"#7FB4CA",focusRing:"#7FB4CA50",cursor:"#DCD7BA",hover:"#363646",active:"#54546D"},status:{error:"#E82424",errorForeground:"#DCD7BA",errorBackground:"#E8242420",errorBorder:"#E8242450",warning:"#FF9E3B",warningForeground:"#1F1F28",warningBackground:"#FF9E3B20",warningBorder:"#FF9E3B50",success:"#98BB6C",successForeground:"#1F1F28",successBackground:"#98BB6C20",successBorder:"#98BB6C50",info:"#7E9CD8",infoForeground:"#1F1F28",infoBackground:"#7E9CD820",infoBorder:"#7E9CD850"},pr:{open:"#98BB6C",draft:"#54546D",blocked:"#FF9E3B",merged:"#957FB8",closed:"#E82424"},syntax:{base:{background:"#16161D",foreground:"#DCD7BA",comment:"#54546D",keyword:"#7E9CD8",string:"#98BB6C",number:"#FF9E3B",function:"#E6C384",variable:"#DCD7BA",type:"#C8C093",operator:"#C34043"},tokens:{commentDoc:"#727169",stringEscape:"#DCD7BA",keywordImport:"#957FB8",storageModifier:"#7E9CD8",functionCall:"#E6C384",method:"#76946A",variableProperty:"#7E9CD8",variableOther:"#76946A",variableGlobal:"#D27E99",variableLocal:"#2A2A37",parameter:"#DCD7BA",constant:"#DCD7BA",class:"#E6C384",className:"#E6C384",interface:"#C8C093",struct:"#E6C384",enum:"#E6C384",typeParameter:"#E6C384",namespace:"#C8C093",module:"#C34043",tag:"#7E9CD8",jsxTag:"#D27E99",tagAttribute:"#C8C093",tagAttributeValue:"#98BB6C",boolean:"#C8C093",decorator:"#C8C093",label:"#D27E99",punctuation:"#54546D",macro:"#7E9CD8",preprocessor:"#D27E99",regex:"#98BB6C",url:"#7E9CD8",key:"#E6C384",exception:"#D27E99"},highlights:{diffAdded:"#98BB6C",diffAddedBackground:"#76946A20",diffRemoved:"#C34043",diffRemovedBackground:"#E8242420",diffModified:"#7E9CD8",diffModifiedBackground:"#7E9CD820",lineNumber:"#363646",lineNumberActive:"#DCD7BA"}},markdown:{heading1:"#DCD7BA",heading2:"#DCD7BA",heading3:"#DCD7BA",heading4:"#DCD7BA",link:"#7FB4CA",linkHover:"#7E9CD8",inlineCode:"#98BB6C",inlineCodeBackground:"#16161D",blockquote:"#54546D",blockquoteBorder:"#363646",listMarker:"#FF9E3B99"},chat:{userMessage:"#DCD7BA",userMessageBackground:"#2A2A37",assistantMessage:"#DCD7BA",assistantMessageBackground:"#2f2f3d",timestamp:"#54546D",divider:"#363646"},tools:{background:"#16161D50",border:"#4a4a5f80",headerHover:"#36364650",icon:"#afad9c",title:"#DCD7BA",description:"#818182",edit:{added:"#98BB6C",addedBackground:"#98BB6C25",removed:"#C34043",removedBackground:"#C3404325",lineNumber:"#56566d"}}},$g={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},zg={metadata:Kg,colors:jg,config:$g},qg={id:"kanagawa-light",name:"Kanagawa",description:"A color scheme inspired by Japanese art and ink painting - light variant (Lotus)",version:"1.0.0",variant:"light",tags:["light","japanese","lotus","elegant"]},Wg={primary:{base:"#4D699B",hover:"#6693BF",active:"#5D57A3",foreground:"#f6f3d6",muted:"#4D699B80",emphasis:"#6693BF"},surface:{background:"#f6f3d6",foreground:"#545464",muted:"#ece6c8",mutedForeground:"#6c6c67",elevated:"#eae4bf",elevatedForeground:"#545464",overlay:"#54546433",subtle:"#e6f0e3"},interactive:{border:"#d7d1ba",borderHover:"#8A8980",borderFocus:"#4D699B",selection:"#e9f3e5cf",selectionForeground:"#545464",focus:"#4D699B",focusRing:"#4D699B40",cursor:"#545464",hover:"#e9f3e5a9",active:"#e9f3e5cf"},status:{error:"#E82424",errorForeground:"#f6f3d6",errorBackground:"#E8242420",errorBorder:"#E8242450",warning:"#DE9800",warningForeground:"#545464",warningBackground:"#DE980020",warningBorder:"#DE980050",success:"#6F894E",successForeground:"#f6f3d6",successBackground:"#98BB6C20",successBorder:"#6F894E50",info:"#4D699B",infoForeground:"#f6f3d6",infoBackground:"#6693BF20",infoBorder:"#4D699B50"},pr:{open:"#6F894E",draft:"#716E61",blocked:"#DE9800",merged:"#624C83",closed:"#E82424"},syntax:{base:{background:"#DCD5AC",foreground:"#545464",comment:"#716E61",keyword:"#4D699B",string:"#6F894E",number:"#836F4A",function:"#CC6D00",variable:"#545464",type:"#77713F",operator:"#C84053"},tokens:{commentDoc:"#8A8980",stringEscape:"#545464",keywordImport:"#624C83",storageModifier:"#4D699B",functionCall:"#CC6D00",method:"#6E915F",variableProperty:"#4D699B",variableOther:"#6E915F",variableGlobal:"#B35B79",variableLocal:"#D5CEA3",parameter:"#545464",constant:"#545464",class:"#CC6D00",className:"#CC6D00",interface:"#77713F",struct:"#CC6D00",enum:"#CC6D00",typeParameter:"#CC6D00",namespace:"#77713F",module:"#C84053",tag:"#4D699B",jsxTag:"#B35B79",tagAttribute:"#77713F",tagAttributeValue:"#6F894E",boolean:"#77713F",decorator:"#77713F",label:"#B35B79",punctuation:"#716E61",macro:"#4D699B",preprocessor:"#B35B79",regex:"#6F894E",url:"#4D699B",key:"#CC6D00",exception:"#B35B79"},highlights:{diffAdded:"#6F894E",diffAddedBackground:"#6F894E20",diffRemoved:"#C84053",diffRemovedBackground:"#C8405320",diffModified:"#4D699B",diffModifiedBackground:"#4D699B20",lineNumber:"#8A8980",lineNumberActive:"#545464"}},markdown:{heading1:"#545464",heading2:"#545464",heading3:"#545464",heading4:"#545464",link:"#5D57A3",linkHover:"#4D699B",inlineCode:"#6F894E",inlineCodeBackground:"#e7e2c7",blockquote:"#716E61",blockquoteBorder:"#716E61",listMarker:"#836F4A99"},chat:{userMessage:"#545464",userMessageBackground:"#e6f2e1",assistantMessage:"#545464",assistantMessageBackground:"#f6f3d6",timestamp:"#716E61",divider:"#716E61"},tools:{background:"#DCD5AC50",border:"#716E6180",headerHover:"#716E61",icon:"#8A8980",title:"#545464",description:"#8A8980",edit:{added:"#6F894E",addedBackground:"#6F894E25",removed:"#C84053",removedBackground:"#C8405325",lineNumber:"#8A8980"}}},Gg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Vg={metadata:qg,colors:Wg,config:Gg},Jg={id:"monokai-dark",name:"Monokai",description:"Monokai",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Yg={primary:{base:"#AE81FF",hover:"#9973DD",active:"#BA94FF",foreground:"#23241E",muted:"#AE81FF80",emphasis:"#9973DD"},surface:{background:"#23241E",foreground:"#F8F8F2",muted:"#282a20",mutedForeground:"#939390",elevated:"#21221a",elevatedForeground:"#F8F8F2",overlay:"#FFFFFF20",subtle:"#303126"},interactive:{border:"#343528",borderHover:"#393A2D",borderFocus:"#555741",selection:"#434d3cfe",selectionForeground:"#FFFFFF",focus:"#AE81FF",focusRing:"#AE81FF40",cursor:"#FFFFFF",hover:"#36372a",active:"#36382e"},status:{error:"#F92672",errorForeground:"#23241E",errorBackground:"#F9267220",errorBorder:"#F9267250",warning:"#FD971F",warningForeground:"#23241E",warningBackground:"#FD971F20",warningBorder:"#FD971F50",success:"#A6E22E",successForeground:"#23241E",successBackground:"#A6E22E20",successBorder:"#A6E22E50",info:"#66D9EF",infoForeground:"#23241E",infoBackground:"#66D9EF20",infoBorder:"#66D9EF50"},pr:{open:"#A6E22E",draft:"#C5C5C0",blocked:"#FD971F",merged:"#AE81FF",closed:"#F92672"},syntax:{base:{background:"#27281F",foreground:"#F8F8F2",comment:"#C5C5C0",keyword:"#AE81FF",string:"#A6E22E",number:"#F92672",function:"#AE81FF",variable:"#F8F8F2",type:"#FD971F",operator:"#F92672"},tokens:{boolean:"#FD971F",class:"#AE81FF",className:"#AE81FF",commentDoc:"#ADADA8",constant:"#66D9EF",decorator:"#FD971F",enum:"#AE81FF",exception:"#F92672",functionCall:"#AE81FF",interface:"#FD971F",jsxTag:"#AE81FF",key:"#AE81FF",keywordImport:"#F92672",label:"#F92672",macro:"#66D9EF",method:"#A6E22E",module:"#F92672",namespace:"#FD971F",parameter:"#F8F8F2",preprocessor:"#F92672",punctuation:"#C5C5C0",regex:"#A6E22E",storageModifier:"#66D9EF",stringEscape:"#FFFFFF",struct:"#AE81FF",tag:"#AE81FF",tagAttribute:"#FD971F",tagAttributeValue:"#A6E22E",typeParameter:"#FD971F",url:"#66D9EF",variableGlobal:"#AE81FF",variableLocal:"#25261F",variableOther:"#A6E22E",variableProperty:"#66D9EF"},highlights:{diffAdded:"#A6E22E",diffAddedBackground:"#1E2A1D",diffModified:"#66D9EF",diffModifiedBackground:"#2F2F24",diffRemoved:"#F92672",diffRemovedBackground:"#301C24",lineNumber:"#454639",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#F8F8F2",heading2:"#F8F8F2",heading3:"#F8F8F2",heading4:"#F8F8F2",link:"#66D9EF",linkHover:"#AE81FF",inlineCode:"#A6E22E",inlineCodeBackground:"#27281F",blockquote:"#FD971F",blockquoteBorder:"#343528",listMarker:"#AE81FF99"},chat:{userMessage:"#F8F8F2",userMessageBackground:"#36372a",assistantMessage:"#F8F8F2",assistantMessageBackground:"#23241E",timestamp:"#C5C5C0",divider:"#343528"},tools:{background:"#27281F80",border:"#4d4f3c80",headerHover:"#292A23",icon:"#C5C5C0",title:"#F8F8F2",description:"#C5C5C0",edit:{added:"#A6E22E",addedBackground:"#A6E22E25",removed:"#bd215a",removedBackground:"#F9267225",lineNumber:"#505142"}}},Xg={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Qg={metadata:Jg,colors:Yg,config:Xg},Zg={id:"monokai-light",name:"Monokai",description:"Monokai",version:"1.0.0",variant:"light",tags:["light","palette"]},ep={primary:{base:"#BF7BFF",hover:"#CB94FB",active:"#A76CDB",foreground:"#FDF8EC",muted:"#BF7BFF80",emphasis:"#CB94FB"},surface:{background:"#FDF8EC",foreground:"#292318",muted:"#F8F2E6",mutedForeground:"#887c6a",elevated:"#FBF5E8",elevatedForeground:"#292318",overlay:"#1C150C20",subtle:"#F7EFDD"},interactive:{border:"#E9E0CF",borderHover:"#DFD5C3",borderFocus:"#B6A893",selection:"#1C150C22",selectionForeground:"#1C150C",focus:"#BF7BFF",focusRing:"#BF7BFF40",cursor:"#1C150C",hover:"#e6e0d5",active:"#FBF5E8"},status:{error:"#E54B4B",errorForeground:"#FDF8EC",errorBackground:"#E54B4B20",errorBorder:"#E54B4B50",warning:"#F1A948",warningForeground:"#FDF8EC",warningBackground:"#F1A94820",warningBorder:"#F1A94850",success:"#4FB54B",successForeground:"#FDF8EC",successBackground:"#4FB54B20",successBorder:"#4FB54B50",info:"#2D9AD7",infoForeground:"#FDF8EC",infoBackground:"#2D9AD720",infoBorder:"#2D9AD750"},pr:{open:"#4FB54B",draft:"#6D5C40",blocked:"#F1A948",merged:"#BF7BFF",closed:"#E54B4B"},syntax:{base:{background:"#F8F2E6",foreground:"#292318",comment:"#6D5C40",keyword:"#BF7BFF",string:"#4FB54B",number:"#D9487C",function:"#BF7BFF",variable:"#292318",type:"#F1A948",operator:"#D9487C"},tokens:{boolean:"#F1A948",class:"#BF7BFF",className:"#BF7BFF",commentDoc:"#B5AA96",constant:"#2D9AD7",decorator:"#F1A948",enum:"#BF7BFF",exception:"#D9487C",functionCall:"#BF7BFF",interface:"#F1A948",jsxTag:"#BF7BFF",key:"#BF7BFF",keywordImport:"#D9487C",label:"#D9487C",macro:"#2D9AD7",method:"#4FB54B",module:"#D9487C",namespace:"#F1A948",parameter:"#292318",preprocessor:"#D9487C",punctuation:"#6D5C40",regex:"#4FB54B",storageModifier:"#2D9AD7",stringEscape:"#1C150C",struct:"#BF7BFF",tag:"#BF7BFF",tagAttribute:"#F1A948",tagAttributeValue:"#4FB54B",typeParameter:"#F1A948",url:"#2D9AD7",variableGlobal:"#BF7BFF",variableLocal:"#FBF5E8",variableOther:"#4FB54B",variableProperty:"#2D9AD7"},highlights:{diffAdded:"#4FB54B",diffAddedBackground:"#E8F7E1",diffModified:"#2D9AD7",diffModifiedBackground:"#E9E0D0",diffRemoved:"#E54B4B",diffRemovedBackground:"#FDE5E4",lineNumber:"#CABFAD",lineNumberActive:"#1C150C"}},markdown:{heading1:"#292318",heading2:"#292318",heading3:"#292318",heading4:"#292318",link:"#2D9AD7",linkHover:"#BF7BFF",inlineCode:"#4FB54B",inlineCodeBackground:"#F8F2E6",blockquote:"#F1A948",blockquoteBorder:"#E9E0CF",listMarker:"#BF7BFF99"},chat:{userMessage:"#292318",userMessageBackground:"#F8F2E6",assistantMessage:"#292318",assistantMessageBackground:"#FDF8EC",timestamp:"#6D5C40",divider:"#E9E0CF"},tools:{background:"#F8F2E680",border:"#d0c8b880",headerHover:"#F7EFDD",icon:"#6D5C40",title:"#292318",description:"#6D5C40",edit:{added:"#4FB54B",addedBackground:"#4FB54B25",removed:"#E54B4B",removedBackground:"#E54B4B25",lineNumber:"#bfb5a4"}}},tp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},rp={metadata:Zg,colors:ep,config:tp},op={id:"nightowl-dark",name:"Night Owl",description:"Night Owl",version:"1.0.0",variant:"dark",tags:["dark","palette"]},np={primary:{base:"#82AAFF",hover:"#6F94DF",active:"#95B7FF",foreground:"#011627",muted:"#82AAFF80",emphasis:"#6F94DF"},surface:{background:"#011627",foreground:"#D6DEEB",muted:"#0B253A",mutedForeground:"#7d8892",elevated:"#001122",elevatedForeground:"#D6DEEB",overlay:"#FFFFFF20",subtle:"#162431"},interactive:{border:"#2b3339",borderHover:"#234561",borderFocus:"#82AAFF",selection:"#555d6d94",selectionForeground:"#FFFFFF",focus:"#82AAFF",focusRing:"#82AAFF40",cursor:"#FFFFFF",hover:"#555d6d68",active:"#555d6d94"},status:{error:"#EF5350",errorForeground:"#011627",errorBackground:"#EF535020",errorBorder:"#EF535050",warning:"#ECC48D",warningForeground:"#011627",warningBackground:"#ECC48D20",warningBorder:"#ECC48D50",success:"#C5E478",successForeground:"#011627",successBackground:"#C5E47820",successBorder:"#C5E47850",info:"#82AAFF",infoForeground:"#011627",infoBackground:"#82AAFF20",infoBorder:"#82AAFF50"},pr:{open:"#C5E478",draft:"#5F7E97",blocked:"#ECC48D",merged:"#BC82FF",closed:"#EF5350"},syntax:{base:{background:"#0B253A",foreground:"#D6DEEB",comment:"#5F7E97",keyword:"#82AAFF",string:"#ECC48D",number:"#F78C6C",function:"#82AAFF",variable:"#D6DEEB",type:"#C5E478",operator:"#F78C6C"},tokens:{boolean:"#C5E478",class:"#82AAFF",className:"#82AAFF",commentDoc:"#516E86",constant:"#7FDBCA",decorator:"#C5E478",enum:"#82AAFF",exception:"#F78C6C",functionCall:"#82AAFF",interface:"#C5E478",jsxTag:"#82AAFF",key:"#82AAFF",keywordImport:"#F78C6C",label:"#F78C6C",macro:"#82AAFF",method:"#C5E478",module:"#F78C6C",namespace:"#C5E478",parameter:"#D6DEEB",preprocessor:"#F78C6C",punctuation:"#5F7E97",regex:"#ECC48D",storageModifier:"#82AAFF",stringEscape:"#FFFFFF",struct:"#82AAFF",tag:"#82AAFF",tagAttribute:"#C5E478",tagAttributeValue:"#ECC48D",typeParameter:"#C5E478",url:"#7FDBCA",variableGlobal:"#82AAFF",variableLocal:"#001122",variableOther:"#C5E478",variableProperty:"#7FDBCA"},highlights:{diffAdded:"#C5E478",diffAddedBackground:"#0A2E1A",diffModified:"#82AAFF",diffModifiedBackground:"#0B253A",diffRemoved:"#EF5350",diffRemovedBackground:"#2D1B1B",lineNumber:"#82AAFF",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#D6DEEB",heading2:"#D6DEEB",heading3:"#D6DEEB",heading4:"#D6DEEB",link:"#7FDBCA",linkHover:"#82AAFF",inlineCode:"#C5E478",inlineCodeBackground:"#0B253A",blockquote:"#5F7E97",blockquoteBorder:"#1D3B53",listMarker:"#82AAFF99"},chat:{userMessage:"#D6DEEB",userMessageBackground:"#0f283f",assistantMessage:"#D6DEEB",assistantMessageBackground:"#011627",timestamp:"#5F7E97",divider:"#1D3B53"},tools:{background:"#0B253A80",border:"#24496780",headerHover:"#000C17",icon:"#5F7E97",title:"#D6DEEB",description:"#5F7E97",edit:{added:"#C5E478",addedBackground:"#C5E47825",removed:"#EF5350",removedBackground:"#EF535025",lineNumber:"#58698f"}}},ap={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},sp={metadata:op,colors:np,config:ap},ip={id:"nightowl-light",name:"Night Owl",description:"Night Owl",version:"1.0.0",variant:"light",tags:["light","palette"]},cp={primary:{base:"#4876D6",hover:"#6C91DD",active:"#4168BA",foreground:"#FBFBFB",muted:"#4876D680",emphasis:"#6C91DD"},surface:{background:"#FBFBFB",foreground:"#403F53",muted:"#F0F0F0",mutedForeground:"#747a7a",elevated:"#FFFFFF",elevatedForeground:"#403F53",overlay:"#1A1A1A20",subtle:"#F0F0F0"},interactive:{border:"#dfdfdf",borderHover:"#CCCCCC",borderFocus:"#4876D6",selection:"#706e6e22",selectionForeground:"#1A1A1A",focus:"#4876D6",focusRing:"#4876D640",cursor:"#1A1A1A",hover:"#706e6e16",active:"#706e6e22"},status:{error:"#DE3D3B",errorForeground:"#FBFBFB",errorBackground:"#DE3D3B20",errorBorder:"#DE3D3B50",warning:"#C96765",warningForeground:"#FBFBFB",warningBackground:"#C9676520",warningBorder:"#C9676550",success:"#2AA298",successForeground:"#FBFBFB",successBackground:"#2AA29820",successBorder:"#2AA29850",info:"#4876D6",infoForeground:"#FBFBFB",infoBackground:"#4876D620",infoBorder:"#4876D650"},pr:{open:"#2AA298",draft:"#7A8181",blocked:"#c98f65",merged:"#994CC3",closed:"#DE3D3B"},syntax:{base:{background:"#F0F0F0",foreground:"#403F53",comment:"#7A8181",keyword:"#4876D6",string:"#C96765",number:"#AA0982",function:"#4876D6",variable:"#403F53",type:"#994CC3",operator:"#AA0982"},tokens:{boolean:"#994CC3",class:"#4876D6",className:"#4876D6",commentDoc:"#BBBEBE",constant:"#2AA298",decorator:"#994CC3",enum:"#4876D6",exception:"#AA0982",functionCall:"#4876D6",interface:"#994CC3",jsxTag:"#4876D6",key:"#4876D6",keywordImport:"#AA0982",label:"#AA0982",macro:"#4876D6",method:"#2AA298",module:"#AA0982",namespace:"#994CC3",parameter:"#403F53",preprocessor:"#AA0982",punctuation:"#7A8181",regex:"#C96765",storageModifier:"#4876D6",stringEscape:"#1A1A1A",struct:"#4876D6",tag:"#4876D6",tagAttribute:"#994CC3",tagAttributeValue:"#C96765",typeParameter:"#994CC3",url:"#2AA298",variableGlobal:"#4876D6",variableLocal:"#FFFFFF",variableOther:"#2AA298",variableProperty:"#2AA298"},highlights:{diffAdded:"#2AA298",diffAddedBackground:"#EAF8F6",diffModified:"#4876D6",diffModifiedBackground:"#E8F0FC",diffRemoved:"#DE3D3B",diffRemovedBackground:"#FBE9E9",lineNumber:"#4876D6",lineNumberActive:"#1A1A1A"}},markdown:{heading1:"#403F53",heading2:"#403F53",heading3:"#403F53",heading4:"#403F53",link:"#2AA298",linkHover:"#4876D6",inlineCode:"#2AA298",inlineCodeBackground:"#F0F0F0",blockquote:"#7A8181",blockquoteBorder:"#D9D9D9",listMarker:"#4876D699"},chat:{userMessage:"#403F53",userMessageBackground:"#F0F0F0",assistantMessage:"#403F53",assistantMessageBackground:"#FBFBFB",timestamp:"#7A8181",divider:"#D9D9D9"},tools:{background:"#F0F0F080",border:"#D9D9D980",headerHover:"#FFFFFF",icon:"#7A8181",title:"#403F53",description:"#7A8181",edit:{added:"#2AA298",addedBackground:"#2AA29825",removed:"#DE3D3B",removedBackground:"#DE3D3B25",lineNumber:"#4876D6"}}},dp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},lp={metadata:ip,colors:cp,config:dp},up={id:"nord-dark",name:"Nord",description:"Nord",version:"1.0.0",variant:"dark",tags:["dark","palette"]},fp={primary:{base:"#88C0D0",hover:"#78A9B8",active:"#99C9D7",foreground:"#1F2430",muted:"#88C0D080",emphasis:"#78A9B8"},surface:{background:"#1F2430",foreground:"#E5E9F0",muted:"#222938",mutedForeground:"#7c828e",elevated:"#1C202A",elevatedForeground:"#E5E9F0",overlay:"#F8FAFC20",subtle:"#252c3c"},interactive:{border:"#383d49",borderHover:"#383F50",borderFocus:"#545B78",selection:"#3e4a56fe",selectionForeground:"#F8FAFC",focus:"#88C0D0",focusRing:"#88C0D040",cursor:"#F8FAFC",hover:"#3e4a5692",active:"#3e4a56fe"},status:{error:"#BF616A",errorForeground:"#1F2430",errorBackground:"#BF616A20",errorBorder:"#BF616A50",warning:"#D08770",warningForeground:"#1F2430",warningBackground:"#D0877020",warningBorder:"#D0877050",success:"#A3BE8C",successForeground:"#1F2430",successBackground:"#A3BE8C20",successBorder:"#A3BE8C50",info:"#81A1C1",infoForeground:"#1F2430",infoBackground:"#81A1C120",infoBorder:"#81A1C150"},pr:{open:"#A3BE8C",draft:"#A4ADBF",blocked:"#D08770",merged:"#b788d0",closed:"#BF616A"},syntax:{base:{background:"#222938",foreground:"#E5E9F0",comment:"#A4ADBF",keyword:"#88C0D0",string:"#A3BE8C",number:"#D57780",function:"#88C0D0",variable:"#E5E9F0",type:"#EAC196",operator:"#D57780"},tokens:{boolean:"#EAC196",class:"#88C0D0",className:"#88C0D0",commentDoc:"#9098AA",constant:"#81A1C1",decorator:"#EAC196",enum:"#88C0D0",exception:"#D57780",functionCall:"#88C0D0",interface:"#EAC196",jsxTag:"#88C0D0",key:"#88C0D0",keywordImport:"#D57780",label:"#D57780",macro:"#81A1C1",method:"#A3BE8C",module:"#D57780",namespace:"#EAC196",parameter:"#E5E9F0",preprocessor:"#D57780",punctuation:"#A4ADBF",regex:"#A3BE8C",storageModifier:"#81A1C1",stringEscape:"#F8FAFC",struct:"#88C0D0",tag:"#88C0D0",tagAttribute:"#EAC196",tagAttributeValue:"#A3BE8C",typeParameter:"#EAC196",url:"#81A1C1",variableGlobal:"#88C0D0",variableLocal:"#1C202A",variableOther:"#A3BE8C",variableProperty:"#81A1C1"},highlights:{diffAdded:"#A3BE8C",diffAddedBackground:"#1F2E33",diffModified:"#81A1C1",diffModifiedBackground:"#222B3A",diffRemoved:"#BF616A",diffRemovedBackground:"#2E212A",lineNumber:"#434A62",lineNumberActive:"#F8FAFC"}},markdown:{heading1:"#E5E9F0",heading2:"#E5E9F0",heading3:"#E5E9F0",heading4:"#E5E9F0",link:"#81A1C1",linkHover:"#88C0D0",inlineCode:"#A3BE8C",inlineCodeBackground:"#252c3c",blockquote:"#D08770",blockquoteBorder:"#343A47",listMarker:"#88C0D099"},chat:{userMessage:"#E5E9F0",userMessageBackground:"#272f40",assistantMessage:"#E5E9F0",assistantMessageBackground:"#1F2430",timestamp:"#A4ADBF",divider:"#343A47"},tools:{background:"#22293880",border:"#454e5f80",headerHover:"#181C24",icon:"#A4ADBF",title:"#E5E9F0",description:"#A4ADBF",edit:{added:"#A3BE8C",addedBackground:"#A3BE8C25",removed:"#BF616A",removedBackground:"#BF616A25",lineNumber:"#4a526b"}}},mp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},gp={metadata:up,colors:fp,config:mp},pp={id:"nord-light",name:"Nord",description:"Nord",version:"1.0.0",variant:"light",tags:["light","palette"]},hp={primary:{base:"#5E81AC",hover:"#7A97BA",active:"#557399",foreground:"#ECEFF4",muted:"#5E81AC80",emphasis:"#7A97BA"},surface:{background:"#ECEFF4",foreground:"#2E3440",muted:"#E4E8F0",mutedForeground:"#6e7481",elevated:"#e7ebf5",elevatedForeground:"#2E3440",overlay:"#1F253020",subtle:"#e3e7ee"},interactive:{border:"#cfd5df",borderHover:"#C9D0DE",borderFocus:"#9CA4BA",selection:"#c6ccd881",selectionForeground:"#1F2530",focus:"#5E81AC",focusRing:"#5E81AC40",cursor:"#1F2530",hover:"#c6ccd84a",active:"#c6ccd881"},status:{error:"#BF616A",errorForeground:"#ECEFF4",errorBackground:"#BF616A20",errorBorder:"#BF616A50",warning:"#D08770",warningForeground:"#ECEFF4",warningBackground:"#D0877020",warningBorder:"#D0877050",success:"#8FBCBB",successForeground:"#ECEFF4",successBackground:"#8FBCBB20",successBorder:"#8FBCBB50",info:"#81A1C1",infoForeground:"#ECEFF4",infoBackground:"#81A1C120",infoBorder:"#81A1C150"},pr:{open:"#8FBCBB",draft:"#4C566A",blocked:"#D08770",merged:"#9b5eac",closed:"#BF616A"},syntax:{base:{background:"#E4E8F0",foreground:"#2E3440",comment:"#4C566A",keyword:"#5E81AC",string:"#A3BE8C",number:"#BF616A",function:"#5E81AC",variable:"#2E3440",type:"#D08770",operator:"#BF616A"},tokens:{boolean:"#D08770",class:"#5E81AC",className:"#5E81AC",commentDoc:"#9CA3AF",constant:"#81A1C1",decorator:"#D08770",enum:"#5E81AC",exception:"#BF616A",functionCall:"#5E81AC",interface:"#D08770",jsxTag:"#5E81AC",key:"#5E81AC",keywordImport:"#BF616A",label:"#BF616A",macro:"#81A1C1",method:"#8FBCBB",module:"#BF616A",namespace:"#D08770",parameter:"#2E3440",preprocessor:"#BF616A",punctuation:"#4C566A",regex:"#A3BE8C",storageModifier:"#81A1C1",stringEscape:"#1F2530",struct:"#5E81AC",tag:"#5E81AC",tagAttribute:"#D08770",tagAttributeValue:"#A3BE8C",typeParameter:"#D08770",url:"#81A1C1",variableGlobal:"#5E81AC",variableLocal:"#F1F3F8",variableOther:"#8FBCBB",variableProperty:"#81A1C1"},highlights:{diffAdded:"#8FBCBB",diffAddedBackground:"#E4F0E4",diffModified:"#81A1C1",diffModifiedBackground:"#DFE6F2",diffRemoved:"#BF616A",diffRemovedBackground:"#F4E1E4",lineNumber:"#B2BACC",lineNumberActive:"#1F2530"}},markdown:{heading1:"#2E3440",heading2:"#2E3440",heading3:"#2E3440",heading4:"#2E3440",link:"#81A1C1",linkHover:"#5E81AC",inlineCode:"#4f7034",inlineCodeBackground:"#E4E8F0",blockquote:"#D08770",blockquoteBorder:"#D5DBE7",listMarker:"#5E81AC99"},chat:{userMessage:"#2E3440",userMessageBackground:"#dee4f0",assistantMessage:"#2E3440",assistantMessageBackground:"#ECEFF4",timestamp:"#4C566A",divider:"#D5DBE7"},tools:{background:"#E4E8F080",border:"#b8bfcc80",headerHover:"#F6F8FC",icon:"#4C566A",title:"#2E3440",description:"#4C566A",edit:{added:"#8FBCBB",addedBackground:"#8FBCBB25",removed:"#BF616A",removedBackground:"#BF616A25",lineNumber:"#b7bfd1"}}},Fp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},yp={metadata:pp,colors:hp,config:Fp},bp={id:"fields-of-the-shire-dark",name:"Fields of the Shire",description:"Fields of the Shire theme - dark variant",author:"PiChamber",version:"1.0.0",variant:"dark",tags:["dark","warm","earthy","brand"]},Ap={primary:{base:"#7a8a5a",hover:"#93a56b",active:"#a4b67d",foreground:"#0c0a08",muted:"#7a8a5a80",emphasis:"#93a56b"},surface:{background:"#1b1815",foreground:"#ebe0d1",muted:"#23201c",mutedForeground:"#83796f",elevated:"#2b2622",elevatedForeground:"#ebe0d1",overlay:"#1b1815cc",subtle:"#282320"},interactive:{border:"#35322f",borderHover:"#f0e6d830",borderFocus:"#373d2c",selection:"#f0e6d81f",selectionForeground:"#ebe0d1",focus:"#7a8a5a",focusRing:"#7a8a5a4d",cursor:"#ebe0d1",hover:"#332d28",active:"#f0e6d824"},status:{error:"#b34d3b",errorForeground:"#0c0a08",errorBackground:"#b85a4a20",errorBorder:"#b85a4a50",warning:"#c47a3a",warningForeground:"#0c0a08",warningBackground:"#c47a3a20",warningBorder:"#c47a3a50",success:"#7f905e",successForeground:"#0c0a08",successBackground:"#7a8a5a20",successBorder:"#7a8a5a50",info:"#667c8a",infoForeground:"#f0e6d8",infoBackground:"#5a6d7a20",infoBorder:"#5a6d7a50"},pr:{open:"#7a8a5a",draft:"#6a5e52",blocked:"#c47a3a",merged:"#5a6d7a",closed:"#b85a4a"},syntax:{base:{background:"#23201c",foreground:"#ebe0d1",comment:"#6a5e52",keyword:"#5a6d7a",string:"#93a56b",number:"#c47a3a",function:"#c47a3a",variable:"#ebe0d1",type:"#7a8a5a",operator:"#a89888"},tokens:{commentDoc:"#4a4238",stringEscape:"#ebe0d1",keywordImport:"#5a6d7a",storageModifier:"#5a6d7a",functionCall:"#c47a3a",method:"#93a56b",variableProperty:"#5a6d7a",variableOther:"#ebe0d1",variableGlobal:"#c47a3a",variableLocal:"#a89888",parameter:"#ebe0d1",constant:"#c47a3a",class:"#7a8a5a",className:"#7a8a5a",interface:"#7a8a5a",struct:"#7a8a5a",enum:"#7a8a5a",typeParameter:"#93a56b",namespace:"#5a6d7a",module:"#5a6d7a",tag:"#c47a3a",jsxTag:"#c47a3a",tagAttribute:"#93a56b",tagAttributeValue:"#93a56b",boolean:"#7a8a5a",decorator:"#5a6d7a",label:"#c47a3a",punctuation:"#a89888",macro:"#5a6d7a",preprocessor:"#5a6d7a",regex:"#93a56b",url:"#5a6d7a",key:"#c47a3a",exception:"#b85a4a"},highlights:{diffAdded:"#7a8a5a",diffAddedBackground:"#7a8a5a20",diffRemoved:"#b85a4a",diffRemovedBackground:"#b85a4a20",diffModified:"#5a6d7a",diffModifiedBackground:"#5a6d7a20",lineNumber:"#6a5e52",lineNumberActive:"#ebe0d1"}},markdown:{heading1:"#c47a3a",heading2:"#93a56b",heading3:"#ebe0d1",heading4:"#ebe0d1",link:"#5a6d7a",linkHover:"#93a56b",inlineCode:"#93a56b",inlineCodeBackground:"#23201c",blockquote:"#a89888",blockquoteBorder:"#f0e6d830",listMarker:"#c47a3a99"},chat:{userMessage:"#ebe0d1",userMessageBackground:"#272a25",assistantMessage:"#ebe0d1",assistantMessageBackground:"#1b1815",timestamp:"#6a5e52",divider:"#f0e6d81c"},tools:{background:"#23201c80",border:"#f0e6d830",headerHover:"#2a252180",icon:"#a89888",title:"#ebe0d1",description:"#a19a96",edit:{added:"#7a8a5a",addedBackground:"#7a8a5a25",removed:"#b85a4a",removedBackground:"#b85a4a25",lineNumber:"#6a5e52"}}},Ep={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},wp={metadata:bp,colors:Ap,config:Ep},Bp={id:"fields-of-the-shire-light",name:"Fields of the Shire",description:"Fields of the Shire theme - light variant",author:"PiChamber",version:"1.0.0",variant:"light",tags:["light","warm","earthy","brand"]},Cp={primary:{base:"#4a6030",hover:"#5e773f",active:"#708a50",foreground:"#faf8f5",muted:"#4a603080",emphasis:"#5e773f"},surface:{background:"#f9f5eb",foreground:"#1a1612",muted:"#f4efe3",mutedForeground:"#5a5048",elevated:"#fcf9f0",elevatedForeground:"#1a1612",overlay:"#1a161220",subtle:"#f1ece1"},interactive:{border:"#1a16121c",borderHover:"#1a161230",borderFocus:"#4a6030",selection:"#1a16121a",selectionForeground:"#1a1612",focus:"#4a6030",focusRing:"#4a603040",cursor:"#1a1612",hover:"#efe8da",active:"#1a16121f"},status:{error:"#a24d3f",errorForeground:"#faf8f5",errorBackground:"#a24d3f20",errorBorder:"#a24d3f50",warning:"#8c5520",warningForeground:"#faf8f5",warningBackground:"#8c552020",warningBorder:"#8c552050",success:"#4a6030",successForeground:"#faf8f5",successBackground:"#4a603020",successBorder:"#4a603050",info:"#3d4f5a",infoForeground:"#faf8f5",infoBackground:"#3d4f5a20",infoBorder:"#3d4f5a50"},pr:{open:"#4a6030",draft:"#8a7e72",blocked:"#8c5520",merged:"#3d4f5a",closed:"#a24d3f"},syntax:{base:{background:"#ece5d6",foreground:"#1a1612",comment:"#8a7e72",keyword:"#3d4f5a",string:"#5e773f",number:"#8c5520",function:"#8c5520",variable:"#1a1612",type:"#4a6030",operator:"#5a5048"},tokens:{commentDoc:"#b8b0a4",stringEscape:"#1a1612",keywordImport:"#3d4f5a",storageModifier:"#3d4f5a",functionCall:"#8c5520",method:"#5e773f",variableProperty:"#3d4f5a",variableOther:"#1a1612",variableGlobal:"#8c5520",variableLocal:"#5a5048",parameter:"#1a1612",constant:"#8c5520",class:"#4a6030",className:"#4a6030",interface:"#4a6030",struct:"#4a6030",enum:"#4a6030",typeParameter:"#5e773f",namespace:"#3d4f5a",module:"#3d4f5a",tag:"#8c5520",jsxTag:"#8c5520",tagAttribute:"#4a6030",tagAttributeValue:"#5e773f",boolean:"#4a6030",decorator:"#3d4f5a",label:"#8c5520",punctuation:"#5a5048",macro:"#3d4f5a",preprocessor:"#3d4f5a",regex:"#5e773f",url:"#3d4f5a",key:"#8c5520",exception:"#a24d3f"},highlights:{diffAdded:"#4a6030",diffAddedBackground:"#4a603020",diffRemoved:"#a24d3f",diffRemovedBackground:"#a24d3f20",diffModified:"#3d4f5a",diffModifiedBackground:"#3d4f5a20",lineNumber:"#8a7e72",lineNumberActive:"#1a1612"}},markdown:{heading1:"#8c5520",heading2:"#4a6030",heading3:"#1a1612",heading4:"#1a1612",link:"#3d4f5a",linkHover:"#4a6030",inlineCode:"#4a6030",inlineCodeBackground:"#ece5d6",blockquote:"#5a5048",blockquoteBorder:"#1a161230",listMarker:"#8c552099"},chat:{userMessage:"#1a1612",userMessageBackground:"#efe8da",assistantMessage:"#1a1612",assistantMessageBackground:"#f9f5eb",timestamp:"#8a7e72",divider:"#1a16121c"},tools:{background:"#f4efe380",border:"#1a161230",headerHover:"#efe8da",icon:"#5a5048",title:"#1a1612",description:"#5a5048",edit:{added:"#4a6030",addedBackground:"#4a603025",removed:"#a24d3f",removedBackground:"#a24d3f25",lineNumber:"#8a7e72"}}},vp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},kp={metadata:Bp,colors:Cp,config:vp},Dp={id:"onedarkpro-dark",name:"One Dark Pro",description:"One Dark Pro",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Sp={primary:{base:"#61AFEF",hover:"#579AD1",active:"#77BAF1",foreground:"#1E222A",muted:"#61AFEF80",emphasis:"#579AD1"},surface:{background:"#1E222A",foreground:"#ABB2BF",muted:"#212631",mutedForeground:"#737a89",elevated:"#232832",elevatedForeground:"#ABB2BF",overlay:"#F6F7FB20",subtle:"#272c37"},interactive:{border:"#313848",borderHover:"#363D52",borderFocus:"#555C79",selection:"#a8aec533",selectionForeground:"#F6F7FB",focus:"#61AFEF",focusRing:"#61AFEF40",cursor:"#F6F7FB",hover:"#a8aec525",active:"#a8aec533"},status:{error:"#E06C75",errorForeground:"#1E222A",errorBackground:"#E06C7520",errorBorder:"#E06C7550",warning:"#E5C07B",warningForeground:"#1E222A",warningBackground:"#E5C07B20",warningBorder:"#E5C07B50",success:"#98C379",successForeground:"#1E222A",successBackground:"#98C37920",successBorder:"#98C37950",info:"#56B6C2",infoForeground:"#1E222A",infoBackground:"#56B6C220",infoBorder:"#56B6C250"},pr:{open:"#98C379",draft:"#818899",blocked:"#E5C07B",merged:"#bb61ef",closed:"#E06C75"},syntax:{base:{background:"#212631",foreground:"#ABB2BF",comment:"#818899",keyword:"#61AFEF",string:"#98C379",number:"#E06C75",function:"#61AFEF",variable:"#ABB2BF",type:"#E5C07B",operator:"#E06C75"},tokens:{boolean:"#E5C07B",class:"#61AFEF",className:"#61AFEF",commentDoc:"#727988",constant:"#56B6C2",decorator:"#E5C07B",enum:"#61AFEF",exception:"#E06C75",functionCall:"#61AFEF",interface:"#E5C07B",jsxTag:"#61AFEF",key:"#61AFEF",keywordImport:"#E06C75",label:"#E06C75",macro:"#56B6C2",method:"#98C379",module:"#E06C75",namespace:"#E5C07B",parameter:"#ABB2BF",preprocessor:"#E06C75",punctuation:"#818899",regex:"#98C379",storageModifier:"#56B6C2",stringEscape:"#F6F7FB",struct:"#61AFEF",tag:"#61AFEF",tagAttribute:"#E5C07B",tagAttributeValue:"#98C379",typeParameter:"#E5C07B",url:"#56B6C2",variableGlobal:"#61AFEF",variableLocal:"#1B1F27",variableOther:"#98C379",variableProperty:"#56B6C2"},highlights:{diffAdded:"#98C379",diffAddedBackground:"#1C2A26",diffModified:"#56B6C2",diffModifiedBackground:"#232836",diffRemoved:"#E06C75",diffRemovedBackground:"#2A1C22",lineNumber:"#424967",lineNumberActive:"#F6F7FB"}},markdown:{heading1:"#ABB2BF",heading2:"#ABB2BF",heading3:"#ABB2BF",heading4:"#ABB2BF",link:"#56B6C2",linkHover:"#61AFEF",inlineCode:"#a0c288",inlineCodeBackground:"#232937",blockquote:"#E5C07B",blockquoteBorder:"#323848",listMarker:"#61AFEF99"},chat:{userMessage:"#ABB2BF",userMessageBackground:"#2e3442",assistantMessage:"#ABB2BF",assistantMessageBackground:"#1E222A",timestamp:"#818899",divider:"#323848"},tools:{background:"#21263180",border:"#41495e80",headerHover:"#171B23",icon:"#818899",title:"#ABB2BF",description:"#818899",edit:{added:"#98C379",addedBackground:"#98C37925",removed:"#E06C75",removedBackground:"#E06C7525",lineNumber:"#545c81"}}},Mp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Tp={metadata:Dp,colors:Sp,config:Mp},Pp={id:"onedarkpro-light",name:"One Dark Pro",description:"One Dark Pro",version:"1.0.0",variant:"light",tags:["light","palette"]},Rp={primary:{base:"#528BFF",hover:"#73A0FE",active:"#4879DC",foreground:"#F5F6F8",muted:"#528BFF80",emphasis:"#73A0FE"},surface:{background:"#F5F6F8",foreground:"#2B303B",muted:"#EEF0F4",mutedForeground:"#6e727b",elevated:"#f0f5fa",elevatedForeground:"#2B303B",overlay:"#0E111820",subtle:"#edeff5"},interactive:{border:"#d5d8de",borderHover:"#D4D9E3",borderFocus:"#A6ADBF",selection:"#d8dde6",selectionForeground:"#0E1118",focus:"#528BFF",focusRing:"#528BFF40",cursor:"#0E1118",hover:"#d8dde6c2",active:"#FAFBFC"},status:{error:"#E06C75",errorForeground:"#F5F6F8",errorBackground:"#E06C7520",errorBorder:"#E06C7550",warning:"#D19A66",warningForeground:"#F5F6F8",warningBackground:"#D19A6620",warningBorder:"#D19A6650",success:"#4FA66D",successForeground:"#F5F6F8",successBackground:"#4FA66D20",successBorder:"#4FA66D50",info:"#61AFEF",infoForeground:"#F5F6F8",infoBackground:"#61AFEF20",infoBorder:"#61AFEF50"},pr:{open:"#4FA66D",draft:"#6B717F",blocked:"#D19A66",merged:"#a052ff",closed:"#E06C75"},syntax:{base:{background:"#EEF0F4",foreground:"#2B303B",comment:"#6B717F",keyword:"#528BFF",string:"#4FA66D",number:"#D85462",function:"#528BFF",variable:"#2B303B",type:"#D19A66",operator:"#D85462"},tokens:{boolean:"#D19A66",class:"#528BFF",className:"#528BFF",commentDoc:"#B0B4BC",constant:"#61AFEF",decorator:"#D19A66",enum:"#528BFF",exception:"#D85462",functionCall:"#528BFF",interface:"#D19A66",jsxTag:"#528BFF",key:"#528BFF",keywordImport:"#D85462",label:"#D85462",macro:"#61AFEF",method:"#4FA66D",module:"#D85462",namespace:"#D19A66",parameter:"#2B303B",preprocessor:"#D85462",punctuation:"#6B717F",regex:"#4FA66D",storageModifier:"#61AFEF",stringEscape:"#0E1118",struct:"#528BFF",tag:"#528BFF",tagAttribute:"#D19A66",tagAttributeValue:"#4FA66D",typeParameter:"#D19A66",url:"#61AFEF",variableGlobal:"#528BFF",variableLocal:"#FAFBFC",variableOther:"#4FA66D",variableProperty:"#61AFEF"},highlights:{diffAdded:"#4FA66D",diffAddedBackground:"#E5F4EA",diffModified:"#61AFEF",diffModifiedBackground:"#E4E8F4",diffRemoved:"#E06C75",diffRemovedBackground:"#FDE7EA",lineNumber:"#BEC4D0",lineNumberActive:"#0E1118"}},markdown:{heading1:"#2B303B",heading2:"#2B303B",heading3:"#2B303B",heading4:"#2B303B",link:"#61AFEF",linkHover:"#528BFF",inlineCode:"#327d4c",inlineCodeBackground:"#EEF0F4",blockquote:"#D19A66",blockquoteBorder:"#DEE2EB",listMarker:"#528BFF99"},chat:{userMessage:"#2B303B",userMessageBackground:"#eaedf4",assistantMessage:"#2B303B",assistantMessageBackground:"#F5F6F8",timestamp:"#6B717F",divider:"#DEE2EB"},tools:{background:"#EEF0F480",border:"#c4c8d080",headerHover:"#FFFFFF",icon:"#6B717F",title:"#2B303B",description:"#6B717F",edit:{added:"#4FA66D",addedBackground:"#4FA66D25",removed:"#E06C75",removedBackground:"#E06C7525",lineNumber:"#afb5c1"}}},Ip={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},_p={metadata:Pp,colors:Rp,config:Ip},xp={id:"solarized-dark",name:"Solarized",description:"Solarized",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Op={primary:{base:"#278BD2",hover:"#5C65AC",active:"#8285C9",foreground:"#001F27",muted:"#6C71C480",emphasis:"#5C65AC"},surface:{background:"#001e25",foreground:"#93A1A1",muted:"#02232e",mutedForeground:"#6f7475",elevated:"#052832",elevatedForeground:"#93A1A1",overlay:"#FDF6E320",subtle:"#062930"},interactive:{border:"#223a41",borderHover:"#243E47",borderFocus:"#3A5A6B",selection:"#98afbd33",selectionForeground:"#FDF6E3",focus:"#6C71C4",focusRing:"#6C71C440",cursor:"#FDF6E3",hover:"#98afbd25",active:"#98afbd33"},status:{error:"#DC322F",errorForeground:"#001F27",errorBackground:"#DC322F20",errorBorder:"#DC322F50",warning:"#B58900",warningForeground:"#001F27",warningBackground:"#B5890020",warningBorder:"#B5890050",success:"#859900",successForeground:"#001F27",successBackground:"#85990020",successBorder:"#85990050",info:"#2AA198",infoForeground:"#001F27",infoBackground:"#2AA19820",infoBorder:"#2AA19850"},pr:{open:"#859900",draft:"#6C7F80",blocked:"#B58900",merged:"#7f6cc4",closed:"#DC322F"},syntax:{base:{background:"#022733",foreground:"#93A1A1",comment:"#6C7F80",keyword:"#6C71C4",string:"#859900",number:"#D33682",function:"#6C71C4",variable:"#93A1A1",type:"#B58900",operator:"#D33682"},tokens:{boolean:"#B58900",class:"#6C71C4",className:"#6C71C4",commentDoc:"#5C7173",constant:"#2AA198",decorator:"#B58900",enum:"#6C71C4",exception:"#D33682",functionCall:"#6C71C4",interface:"#B58900",jsxTag:"#6C71C4",key:"#6C71C4",keywordImport:"#D33682",label:"#D33682",macro:"#2AA198",method:"#859900",module:"#D33682",namespace:"#B58900",parameter:"#93A1A1",preprocessor:"#D33682",punctuation:"#6C7F80",regex:"#859900",storageModifier:"#2AA198",stringEscape:"#FDF6E3",struct:"#6C71C4",tag:"#6C71C4",tagAttribute:"#B58900",tagAttributeValue:"#859900",typeParameter:"#B58900",url:"#2AA198",variableGlobal:"#6C71C4",variableLocal:"#01222B",variableOther:"#859900",variableProperty:"#2AA198"},highlights:{diffAdded:"#859900",diffAddedBackground:"#0F2F29",diffModified:"#2AA198",diffModifiedBackground:"#0F3844",diffRemoved:"#DC322F",diffRemovedBackground:"#321C1C",lineNumber:"#2D4958",lineNumberActive:"#FDF6E3"}},markdown:{heading1:"#93A1A1",heading2:"#93A1A1",heading3:"#93A1A1",heading4:"#93A1A1",link:"#2AA198",linkHover:"#6C71C4",inlineCode:"#859900",inlineCodeBackground:"#022733",blockquote:"#B58900",blockquoteBorder:"#20373F",listMarker:"#6C71C499"},chat:{userMessage:"#93A1A1",userMessageBackground:"#042B34",assistantMessage:"#93A1A1",assistantMessageBackground:"#001F27",timestamp:"#6C7F80",divider:"#20373F"},tools:{background:"#02273380",border:"#2b495380",headerHover:"#032830",icon:"#6C7F80",title:"#93A1A1",description:"#6C7F80",edit:{added:"#859900",addedBackground:"#85990025",removed:"#DC322F",removedBackground:"#DC322F25",lineNumber:"#345567"}}},Np={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Lp={metadata:xp,colors:Op,config:Np},Up={id:"solarized-light",name:"Solarized",description:"Solarized",version:"1.0.0",variant:"light",tags:["light","palette"]},Hp={primary:{base:"#268BD2",hover:"#51A0D5",active:"#217EBC",foreground:"#FDF6E3",muted:"#268BD280",emphasis:"#51A0D5"},surface:{background:"#FDF6E3",foreground:"#586E75",muted:"#F6EFDA",mutedForeground:"#7a8587",elevated:"#FAF3DC",elevatedForeground:"#586E75",overlay:"#07364220",subtle:"#F6EFDA"},interactive:{border:"#e0decc",borderHover:"#D9D4C2",borderFocus:"#ACA58F",selection:"#10647a22",selectionForeground:"#073642",focus:"#268BD2",focusRing:"#268BD240",cursor:"#073642",hover:"#10647a14",active:"#10647a22"},status:{error:"#DC322F",errorForeground:"#FDF6E3",errorBackground:"#DC322F20",errorBorder:"#DC322F50",warning:"#B58900",warningForeground:"#FDF6E3",warningBackground:"#B5890020",warningBorder:"#B5890050",success:"#859900",successForeground:"#FDF6E3",successBackground:"#85990020",successBorder:"#85990050",info:"#2AA198",infoForeground:"#FDF6E3",infoBackground:"#2AA19820",infoBorder:"#2AA19850"},pr:{open:"#859900",draft:"#7A8C8E",blocked:"#B58900",merged:"#6e26d2",closed:"#DC322F"},syntax:{base:{background:"#F6EFDA",foreground:"#586E75",comment:"#7A8C8E",keyword:"#268BD2",string:"#859900",number:"#D33682",function:"#268BD2",variable:"#586E75",type:"#B58900",operator:"#D33682"},tokens:{boolean:"#B58900",class:"#268BD2",className:"#268BD2",commentDoc:"#BCC1B9",constant:"#2AA198",decorator:"#B58900",enum:"#268BD2",exception:"#D33682",functionCall:"#268BD2",interface:"#B58900",jsxTag:"#268BD2",key:"#268BD2",keywordImport:"#D33682",label:"#D33682",macro:"#2AA198",method:"#859900",module:"#D33682",namespace:"#B58900",parameter:"#586E75",preprocessor:"#D33682",punctuation:"#7A8C8E",regex:"#859900",storageModifier:"#2AA198",stringEscape:"#073642",struct:"#268BD2",tag:"#268BD2",tagAttribute:"#B58900",tagAttributeValue:"#859900",typeParameter:"#B58900",url:"#2AA198",variableGlobal:"#268BD2",variableLocal:"#FAF3DC",variableOther:"#859900",variableProperty:"#2AA198"},highlights:{diffAdded:"#859900",diffAddedBackground:"#EEF5D6",diffModified:"#2AA198",diffModifiedBackground:"#E3ECF3",diffRemoved:"#DC322F",diffRemovedBackground:"#FDE4DD",lineNumber:"#C5C0AD",lineNumberActive:"#073642"}},markdown:{heading1:"#586E75",heading2:"#586E75",heading3:"#586E75",heading4:"#586E75",link:"#2AA198",linkHover:"#268BD2",inlineCode:"#859900",inlineCodeBackground:"#F6EFDA",blockquote:"#B58900",blockquoteBorder:"#E3E0CD",listMarker:"#268BD299"},chat:{userMessage:"#586E75",userMessageBackground:"#F6EFDA",assistantMessage:"#586E75",assistantMessageBackground:"#FDF6E3",timestamp:"#7A8C8E",divider:"#E3E0CD"},tools:{background:"#F6EFDA80",border:"#d1cebc80",headerHover:"#F6EDD4",icon:"#7A8C8E",title:"#586E75",description:"#7A8C8E",edit:{added:"#859900",addedBackground:"#85990025",removed:"#DC322F",removedBackground:"#DC322F25",lineNumber:"#c3bead"}}},Kp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},jp={metadata:Up,colors:Hp,config:Kp},$p={id:"tokyonight-dark",name:"Tokyonight",description:"Tokyonight",version:"1.0.0",variant:"dark",tags:["dark","palette"]},zp={primary:{base:"#7AA2F7",hover:"#6A8CD6",active:"#8BADF8",foreground:"#0F111A",muted:"#7AA2F780",emphasis:"#6A8CD6"},surface:{background:"#0F111A",foreground:"#C0CAF5",muted:"#111428",mutedForeground:"#8890b3",elevated:"#131629",elevatedForeground:"#C0CAF5",overlay:"#EAEAFF20",subtle:"#15192b"},interactive:{border:"#2d2f43",borderHover:"#292C43",borderFocus:"#45496F",selection:"#b3b3cc33",selectionForeground:"#EAEAFF",focus:"#7AA2F7",focusRing:"#7AA2F740",cursor:"#EAEAFF",hover:"#272E49",active:"#262C46"},status:{error:"#F7768E",errorForeground:"#0F111A",errorBackground:"#F7768E20",errorBorder:"#F7768E50",warning:"#E0AF68",warningForeground:"#0F111A",warningBackground:"#E0AF6820",warningBorder:"#E0AF6850",success:"#9ECE6A",successForeground:"#0F111A",successBackground:"#9ECE6A20",successBorder:"#9ECE6A50",info:"#7DCFFF",infoForeground:"#0F111A",infoBackground:"#7DCFFF20",infoBorder:"#7DCFFF50"},pr:{open:"#9ECE6A",draft:"#7A88CF",blocked:"#E0AF68",merged:"#BB9AF7",closed:"#F7768E"},syntax:{base:{background:"#111428",foreground:"#C0CAF5",comment:"#7A88CF",keyword:"#BB9AF7",string:"#9ECE6A",number:"#FF9E64",function:"#BB9AF7",variable:"#C0CAF5",type:"#E0AF68",operator:"#FF9E64"},tokens:{boolean:"#E0AF68",class:"#BB9AF7",className:"#BB9AF7",commentDoc:"#6A76B4",constant:"#7DCFFF",decorator:"#E0AF68",enum:"#BB9AF7",exception:"#FF9E64",functionCall:"#BB9AF7",interface:"#E0AF68",jsxTag:"#BB9AF7",key:"#BB9AF7",keywordImport:"#FF9E64",label:"#FF9E64",macro:"#7DCFFF",method:"#9ECE6A",module:"#FF9E64",namespace:"#E0AF68",parameter:"#C0CAF5",preprocessor:"#FF9E64",punctuation:"#7A88CF",regex:"#9ECE6A",storageModifier:"#7DCFFF",stringEscape:"#EAEAFF",struct:"#BB9AF7",tag:"#BB9AF7",tagAttribute:"#E0AF68",tagAttributeValue:"#9ECE6A",typeParameter:"#E0AF68",url:"#7DCFFF",variableGlobal:"#BB9AF7",variableLocal:"#101324",variableOther:"#9ECE6A",variableProperty:"#7DCFFF"},highlights:{diffAdded:"#9ECE6A",diffAddedBackground:"#1C2A38",diffModified:"#7DCFFF",diffModifiedBackground:"#24283B",diffRemoved:"#F7768E",diffRemovedBackground:"#2A1F32",lineNumber:"#343755",lineNumberActive:"#EAEAFF"}},markdown:{heading1:"#C0CAF5",heading2:"#C0CAF5",heading3:"#C0CAF5",heading4:"#C0CAF5",link:"#7DCFFF",linkHover:"#7AA2F7",inlineCode:"#9ECE6A",inlineCodeBackground:"#111428",blockquote:"#E0AF68",blockquoteBorder:"#25283B",listMarker:"#7AA2F799"},chat:{userMessage:"#C0CAF5",userMessageBackground:"#171b30",assistantMessage:"#C0CAF5",assistantMessageBackground:"#0F111A",timestamp:"#7A88CF",divider:"#25283B"},tools:{background:"#11142880",border:"#393e5c80",headerHover:"#13172A",icon:"#7A88CF",title:"#C0CAF5",description:"#a4adda",edit:{added:"#9ECE6A",addedBackground:"#9ECE6A25",removed:"#F7768E",removedBackground:"#F7768E25",lineNumber:"#3e4266"}}},qp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Wp={metadata:$p,colors:zp,config:qp},Gp={id:"tokyonight-light",name:"Tokyonight",description:"Tokyonight",version:"1.0.0",variant:"light",tags:["light","palette"]},Vp={primary:{base:"#2E7DE9",hover:"#5291E9",active:"#2B70D0",foreground:"#E1E2E7",muted:"#2E7DE980",emphasis:"#5291E9"},surface:{background:"#E1E2E7",foreground:"#273153",muted:"#DEE0EA",mutedForeground:"#686e9b",elevated:"#dee0ee",elevatedForeground:"#273153",overlay:"#1C254420",subtle:"#dadce6"},interactive:{border:"#c7c9d3",borderHover:"#C3C6D2",borderFocus:"#9599A8",selection:"#939cbf47",selectionForeground:"#1C2544",focus:"#2E7DE9",focusRing:"#2E7DE940",cursor:"#1C2544",hover:"#7b86ad2a",active:"#7b86ad47"},status:{error:"#C94060",errorForeground:"#E1E2E7",errorBackground:"#C9406020",errorBorder:"#C9406050",warning:"#8C6C3E",warningForeground:"#E1E2E7",warningBackground:"#8C6C3E20",warningBorder:"#8C6C3E50",success:"#587539",successForeground:"#E1E2E7",successBackground:"#58753920",successBorder:"#58753950",info:"#007197",infoForeground:"#E1E2E7",infoBackground:"#00719720",infoBorder:"#00719750"},pr:{open:"#587539",draft:"#5C6390",blocked:"#8C6C3E",merged:"#9854F1",closed:"#C94060"},syntax:{base:{background:"#DEE0EA",foreground:"#273153",comment:"#5C6390",keyword:"#9854F1",string:"#587539",number:"#B15C00",function:"#9854F1",variable:"#273153",type:"#3760BF",operator:"#B15C00"},tokens:{boolean:"#3760BF",class:"#9854F1",className:"#9854F1",commentDoc:"#9FA3BC",constant:"#007197",decorator:"#3760BF",enum:"#9854F1",exception:"#B15C00",functionCall:"#9854F1",interface:"#3760BF",jsxTag:"#9854F1",key:"#9854F1",keywordImport:"#B15C00",label:"#B15C00",macro:"#007197",method:"#587539",module:"#B15C00",namespace:"#3760BF",parameter:"#273153",preprocessor:"#B15C00",punctuation:"#5C6390",regex:"#587539",storageModifier:"#007197",stringEscape:"#1C2544",struct:"#9854F1",tag:"#9854F1",tagAttribute:"#3760BF",tagAttributeValue:"#587539",typeParameter:"#3760BF",url:"#007197",variableGlobal:"#9854F1",variableLocal:"#E5E6EE",variableOther:"#587539",variableProperty:"#007197"},highlights:{diffAdded:"#587539",diffAddedBackground:"#DFE7DA",diffModified:"#007197",diffModifiedBackground:"#CFD1DD",diffRemoved:"#C94060",diffRemovedBackground:"#F4DADD",lineNumber:"#AEB2BF",lineNumberActive:"#1C2544"}},markdown:{heading1:"#9854F1",heading2:"#B15C00",heading3:"#8C6C3E",heading4:"#273153",link:"#007197",linkHover:"#2E7DE9",inlineCode:"#587539",inlineCodeBackground:"#DEE0EA",blockquote:"#8C6C3E",blockquoteBorder:"#CDD0DC",listMarker:"#2E7DE999"},chat:{userMessage:"#273153",userMessageBackground:"#dcdee9",assistantMessage:"#273153",assistantMessageBackground:"#E1E2E7",timestamp:"#5C6390",divider:"#CDD0DC"},tools:{background:"#DEE0EA80",border:"#a5a8b580",headerHover:"#E9EAF1",icon:"#5C6390",title:"#273153",description:"#5C6390",edit:{added:"#587539",addedBackground:"#58753925",removed:"#C94060",removedBackground:"#C9406025",lineNumber:"#9b9ea9"}}},Jp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Yp={metadata:Gp,colors:Vp,config:Jp},Xp={id:"vesper-dark",name:"Vesper",description:"Vesper",version:"1.0.0",variant:"dark",tags:["dark","palette"]},Qp={primary:{base:"#FFC799",hover:"#DBAC84",active:"#FFCFA8",foreground:"#101010",muted:"#FFC79980",emphasis:"#DBAC84"},surface:{background:"#151515",foreground:"#e8e5e5",muted:"#1c1b1b",mutedForeground:"#848484",elevated:"#242121",elevatedForeground:"#FFFFFF",overlay:"#FFFFFF20",subtle:"#1f1f1f"},interactive:{border:"#373636",borderHover:"#202020",borderFocus:"#383838",selection:"#b1adad33",selectionForeground:"#FFFFFF",focus:"#FFC799",focusRing:"#FFC79940",cursor:"#FFFFFF",hover:"#ffffff1c",active:"#ffffff33"},status:{error:"#FF8080",errorForeground:"#101010",errorBackground:"#FF808020",errorBorder:"#FF808050",warning:"#FFC799",warningForeground:"#101010",warningBackground:"#FFC79920",warningBorder:"#FFC79950",success:"#99FFE4",successForeground:"#101010",successBackground:"#99FFE420",successBorder:"#99FFE450",info:"#FFC799",infoForeground:"#101010",infoBackground:"#FFC79920",infoBorder:"#FFC79950"},pr:{open:"#99FFE4",draft:"#A0A0A0",blocked:"#FFC799",merged:"#ca99ff",closed:"#FF8080"},syntax:{base:{background:"#141414",foreground:"#FFFFFF",comment:"#A0A0A0",keyword:"#FFC799",string:"#99FFE4",number:"#FF8080",function:"#FFC799",variable:"#FFFFFF",type:"#FFC799",operator:"#FF8080"},tokens:{boolean:"#FFC799",class:"#FFC799",className:"#FFC799",commentDoc:"#8A8A8A",constant:"#A0A0A0",decorator:"#FFC799",enum:"#FFC799",exception:"#FF8080",functionCall:"#FFC799",interface:"#FFC799",jsxTag:"#FFC799",key:"#FFC799",keywordImport:"#FF8080",label:"#FF8080",macro:"#8B8B8B",method:"#99FFE4",module:"#FF8080",namespace:"#FFC799",parameter:"#FFFFFF",preprocessor:"#FF8080",punctuation:"#A0A0A0",regex:"#99FFE4",storageModifier:"#8B8B8B",stringEscape:"#FFFFFF",struct:"#FFC799",tag:"#FFC799",tagAttribute:"#FFC799",tagAttributeValue:"#99FFE4",typeParameter:"#FFC799",url:"#A0A0A0",variableGlobal:"#FFC799",variableLocal:"#0C0C0C",variableOther:"#99FFE4",variableProperty:"#A0A0A0"},highlights:{diffAdded:"#99FFE4",diffAddedBackground:"#0D2818",diffModified:"#FFC799",diffModifiedBackground:"#141414",diffRemoved:"#FF8080",diffRemovedBackground:"#281A1A",lineNumber:"#282828",lineNumberActive:"#FFFFFF"}},markdown:{heading1:"#FFFFFF",heading2:"#FFFFFF",heading3:"#FFFFFF",heading4:"#FFFFFF",link:"#A0A0A0",linkHover:"#FFC799",inlineCode:"#bba2a2",inlineCodeBackground:"#292727",blockquote:"#FFFFFF",blockquoteBorder:"#1C1C1C",listMarker:"#FFFFFF99"},chat:{userMessage:"#FFFFFF",userMessageBackground:"#2b2a2a",assistantMessage:"#FFFFFF",assistantMessageBackground:"#101010",timestamp:"#A0A0A0",divider:"#1C1C1C"},tools:{background:"#14141480",border:"#48474780",headerHover:"#080808",icon:"#A0A0A0",title:"#FFFFFF",description:"#A0A0A0",edit:{added:"#99FFE4",addedBackground:"#99FFE425",removed:"#FF8080",removedBackground:"#FF808025",lineNumber:"#615f5f"}}},Zp={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},eh={metadata:Xp,colors:Qp,config:Zp},th={id:"vesper-light",name:"Vesper",description:"Vesper",version:"1.0.0",variant:"light",tags:["light","palette"]},rh={primary:{base:"#a06535",hover:"#FFD2AD",active:"#D9A982",foreground:"#FFFFFF",muted:"#cf9c7280",emphasis:"#FFD2AD"},surface:{background:"#FFFFFF",foreground:"#101010",muted:"#F8F8F8",mutedForeground:"#6e6d6d",elevated:"#f6f5f5",elevatedForeground:"#101010",overlay:"#00000020",subtle:"#f6f2f2"},interactive:{border:"#dfdada",borderHover:"#E0E0E0",borderFocus:"#9e9e9e",selection:"#5e5b5b22",selectionForeground:"#000000",focus:"#be875b",focusRing:"#cf9c7240",cursor:"#000000",hover:"#5e5c5c22",active:"#48474722"},status:{error:"#d46868",errorForeground:"#FFFFFF",errorBackground:"#b95f5f20",errorBorder:"#b95f5f50",warning:"#cb7f40",warningForeground:"#FFFFFF",warningBackground:"#cf9c7220",warningBorder:"#cf9c7250",success:"#109b76",successForeground:"#FFFFFF",successBackground:"#99FFE420",successBorder:"#99FFE450",info:"#62bced",infoForeground:"#FFFFFF",infoBackground:"#cf9c7220",infoBorder:"#cf9c7250"},pr:{open:"#0f926f",draft:"#888787",blocked:"#bf6f2e",merged:"#9f5fc1",closed:"#c56161"},syntax:{base:{background:"#F8F8F8",foreground:"#101010",comment:"#868686",keyword:"#cf9c72",string:"#43ae91",number:"#b95f5f",function:"#cf9c72",variable:"#101010",type:"#cf9c72",operator:"#b95f5f"},tokens:{boolean:"#cf9c72",class:"#cf9c72",className:"#cf9c72",commentDoc:"#D0D0D0",constant:"#838282",decorator:"#cf9c72",enum:"#cf9c72",exception:"#b95f5f",functionCall:"#cf9c72",interface:"#cf9c72",jsxTag:"#cf9c72",key:"#cf9c72",keywordImport:"#b95f5f",label:"#b95f5f",macro:"#717070",method:"#74e8c9",module:"#b95f5f",namespace:"#cf9c72",parameter:"#101010",preprocessor:"#b95f5f",punctuation:"#717070",regex:"#67e7c5",storageModifier:"#7b7b7b",stringEscape:"#000000",struct:"#cf9c72",tag:"#cf9c72",tagAttribute:"#cf9c72",tagAttributeValue:"#6adebf",typeParameter:"#cf9c72",url:"#797878",variableGlobal:"#cf9c72",variableLocal:"#F0F0F0",variableOther:"#49dcb5",variableProperty:"#717070"},highlights:{diffAdded:"#56d8b5",diffAddedBackground:"#E8F5E8",diffModified:"#cf9c72",diffModifiedBackground:"#F0F0F0",diffRemoved:"#b95f5f",diffRemovedBackground:"#F5E8E8",lineNumber:"#D0D0D0",lineNumberActive:"#000000"}},markdown:{heading1:"#101010",heading2:"#101010",heading3:"#101010",heading4:"#101010",link:"#717070",linkHover:"#c48959",inlineCode:"#665050",inlineCodeBackground:"#f3f1f1",blockquote:"#101010",blockquoteBorder:"#E8E8E8",listMarker:"#10101099"},chat:{userMessage:"#101010",userMessageBackground:"#f4f1f1",assistantMessage:"#101010",assistantMessageBackground:"#FFFFFF",timestamp:"#717070",divider:"#E8E8E8"},tools:{background:"#F8F8F880",border:"#d0cece80",headerHover:"#E8E8E8",icon:"#717070",title:"#101010",description:"#717070",edit:{added:"#40d7af",addedBackground:"#99FFE425",removed:"#b95f5f",removedBackground:"#b95f5f25",lineNumber:"#b4b2b2"}}},oh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},nh={metadata:th,colors:rh,config:oh},ah={id:"mono-plus-dark",name:"Mono Plus",description:"A pure monochromatic theme - dark variant with slight colors added",version:"1.0.0",variant:"dark",tags:["dark","monochrome","minimal"]},sh={primary:{base:"#a2bee8",hover:"#E5E5E5",active:"#CCCCCC",foreground:"#000000",muted:"#FFFFFF80",emphasis:"#FFFFFF"},surface:{background:"#000000",foreground:"#E5E5E5",muted:"#0A0A0A",mutedForeground:"#808080",elevated:"#141414",elevatedForeground:"#E5E5E5",overlay:"#00000080",subtle:"#1A1A1A"},interactive:{border:"#2f2f2f",borderHover:"#333333",borderFocus:"#FFFFFF",selection:"#ffffff1f",selectionForeground:"#E5E5E5",focus:"#FFFFFF",focusRing:"#FFFFFF50",cursor:"#E5E5E5",hover:"#ffffff1f",active:"#ffffff1f"},status:{error:"#9e6a6a",errorForeground:"#0a0a0a",errorBackground:"#9e6a6a20",errorBorder:"#9e6a6a50",warning:"#9e8a6a",warningForeground:"#0a0a0a",warningBackground:"#9e8a6a20",warningBorder:"#9e8a6a50",success:"#6a8e6a",successForeground:"#0a0a0a",successBackground:"#6a8e6a20",successBorder:"#6a8e6a50",info:"#6a7e9e",infoForeground:"#0a0a0a",infoBackground:"#6a7e9e20",infoBorder:"#6a7e9e50"},pr:{open:"#6a8e6a",draft:"#8c8c8c",blocked:"#9e8a6a",merged:"#bda2e8",closed:"#9e6a6a"},syntax:{base:{background:"#0a0a0a",foreground:"#d4d4d4",comment:"#8c8c8c",keyword:"#dccdbeff",string:"#b6d8e6ff",number:"#e3bdadff",function:"#a2bee8",variable:"#d4d4d4",type:"#edcbb8ff",operator:"#dccdbeff"},tokens:{commentDoc:"#8c8c8c",stringEscape:"#b6d8e6ff",keywordImport:"#dccdbeff",storageModifier:"#dccdbeff",functionCall:"#a2bee8",method:"#a2bee8",variableProperty:"#c0dcc0ff",variableOther:"#d4d4d4",class:"#edcbb8ff",className:"#edcbb8ff",interface:"#edcbb8ff",tag:"#a2bee8",boolean:"#e3bdadff",url:"#b6d8e6ff",key:"#c0dcc0ff"},highlights:{diffAdded:"#6a8e6a",diffAddedBackground:"#6a8e6a20",diffRemoved:"#9e6a6a",diffRemovedBackground:"#9e6a6a20",lineNumber:"#7c7c7c",lineNumberActive:"#d4d4d4"}},markdown:{heading1:"#FFFFFF",heading2:"#F2F2F2",heading3:"#E5E5E5",heading4:"#D9D9D9",link:"#CCCCCC",linkHover:"#a2bee8",inlineCode:"#a2bee8",inlineCodeBackground:"#1A1A1A",blockquote:"#808080",blockquoteBorder:"#333333",listMarker:"#99999999"},chat:{userMessage:"#E5E5E5",userMessageBackground:"#1A1A1A",assistantMessage:"#E5E5E5",assistantMessageBackground:"#000000",timestamp:"#808080",divider:"#333333"},tools:{background:"#0A0A0A50",border:"#4040409d",headerHover:"#33333350",icon:"#A6A6A6",title:"#E5E5E5",description:"#808080",edit:{added:"#6a8e6a",addedBackground:"#6a8e6a20",removed:"#9e6a6a",removedBackground:"#9e6a6a20",lineNumber:"#2a2a2a"}}},ih={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},ch={metadata:ah,colors:sh,config:ih},dh={id:"mono-plus-light",name:"Mono Plus",description:"A pure monochromatic theme - light variant with slight colors added",version:"1.0.0",variant:"light",tags:["light","monochrome","minimal"]},lh={primary:{base:"#4a6a9e",hover:"#1A1A1A",active:"#333333",foreground:"#FFFFFF",muted:"#00000080",emphasis:"#000000"},surface:{background:"#FFFFFF",foreground:"#1A1A1A",muted:"#F5F5F5",mutedForeground:"#6f6f6f",elevated:"#FAFAFA",elevatedForeground:"#1A1A1A",overlay:"#00000020",subtle:"#F0F0F0"},interactive:{border:"#e3e3e3",borderHover:"#B3B3B3",borderFocus:"#000000",selection:"#00000015",selectionForeground:"#1A1A1A",focus:"#000000",focusRing:"#00000040",cursor:"#1A1A1A",hover:"#00000010",active:"#00000015"},status:{error:"#8a5a5a",errorForeground:"#fafafa",errorBackground:"#8a5a5a18",errorBorder:"#8a5a5a40",warning:"#8a7a5a",warningForeground:"#fafafa",warningBackground:"#8a7a5a18",warningBorder:"#8a7a5a40",success:"#5a7a5a",successForeground:"#fafafa",successBackground:"#5a7a5a18",successBorder:"#5a7a5a40",info:"#5a6a8a",infoForeground:"#fafafa",infoBackground:"#5a6a8a18",infoBorder:"#5a6a8a40"},pr:{open:"#6a8e6a",draft:"#8c8c8c",blocked:"#8a7a5a",merged:"#8769b6",closed:"#8a5a5a"},syntax:{base:{background:"#f5f5f5",foreground:"#2a2a2a",comment:"#8c8c8c",keyword:"#6a5a4a",string:"#4a6a7a",number:"#7a5a4a",function:"#4a6a9e",variable:"#2a2a2a",type:"#6a5040",operator:"#6a5a4a"},tokens:{commentDoc:"#8c8c8c",stringEscape:"#4a6a7a",keywordImport:"#6a5a4a",storageModifier:"#6a5a4a",functionCall:"#4a6a9e",method:"#4a6a9e",variableProperty:"#4a6a4a",variableOther:"#2a2a2a",class:"#6a5040",className:"#6a5040",interface:"#6a5040",tag:"#4a6a9e",boolean:"#7a5a4a",url:"#4a6a7a",key:"#4a6a4a"},highlights:{diffAdded:"#5a7a5a",diffAddedBackground:"#5a7a5a18",diffRemoved:"#8a5a5a",diffRemovedBackground:"#8a5a5a18",lineNumber:"#b0b0b0",lineNumberActive:"#2a2a2a"}},markdown:{heading1:"#000000",heading2:"#0D0D0D",heading3:"#1A1A1A",heading4:"#262626",link:"#333333",linkHover:"#4a6a9e",inlineCode:"#4a6a9e",inlineCodeBackground:"#f1f1f1",blockquote:"#808080",blockquoteBorder:"#D9D9D9",listMarker:"#66666699"},chat:{userMessage:"#1A1A1A",userMessageBackground:"#E5E5E5",assistantMessage:"#1A1A1A",assistantMessageBackground:"#FFFFFF",timestamp:"#808080",divider:"#D9D9D9"},tools:{background:"#F5F5F550",border:"#B3B3B380",headerHover:"#D9D9D9",icon:"#666666",title:"#1A1A1A",description:"#808080",edit:{added:"#5a7a5a",addedBackground:"#5a7a5a18",removed:"#8a5a5a",removedBackground:"#8a5a5a18",lineNumber:"#d0d0d0"}}},uh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},fh={metadata:dh,colors:lh,config:uh},mh={id:"mono-dark",name:"Mono",description:"A pure monochromatic theme - dark variant with shades of grey",version:"1.0.0",variant:"dark",tags:["dark","monochrome","minimal","grayscale"]},gh={primary:{base:"#FFFFFF",hover:"#E5E5E5",active:"#CCCCCC",foreground:"#000000",muted:"#FFFFFF80",emphasis:"#FFFFFF"},surface:{background:"#000000",foreground:"#E5E5E5",muted:"#0A0A0A",mutedForeground:"#808080",elevated:"#141414",elevatedForeground:"#E5E5E5",overlay:"#00000080",subtle:"#1A1A1A"},interactive:{border:"#2f2f2f",borderHover:"#333333",borderFocus:"#FFFFFF",selection:"#ffffff1f",selectionForeground:"#E5E5E5",focus:"#FFFFFF",focusRing:"#FFFFFF50",cursor:"#E5E5E5",hover:"#ffffff1f",active:"#ffffff1f"},status:{error:"#666666",errorForeground:"#000000",errorBackground:"#ffffff10",errorBorder:"#ffffff20",warning:"#999999",warningForeground:"#000000",warningBackground:"#ffffff12",warningBorder:"#ffffff25",success:"#E5E5E5",successForeground:"#000000",successBackground:"#ffffff18",successBorder:"#ffffff30",info:"#A6A6A6",infoForeground:"#000000",infoBackground:"#ffffff14",infoBorder:"#ffffff28"},pr:{open:"#E5E5E5",draft:"#B3B3B3",blocked:"#999999",merged:"#CCCCCC",closed:"#666666"},syntax:{base:{background:"#0A0A0A",foreground:"#E5E5E5",comment:"#666666",keyword:"#FFFFFF",string:"#B3B3B3",number:"#999999",function:"#E5E5E5",variable:"#CCCCCC",type:"#D9D9D9",operator:"#808080"},tokens:{commentDoc:"#595959",stringEscape:"#E5E5E5",keywordImport:"#FFFFFF",storageModifier:"#E5E5E5",functionCall:"#D9D9D9",method:"#CCCCCC",variableProperty:"#B3B3B3",variableOther:"#CCCCCC",variableGlobal:"#999999",variableLocal:"#1A1A1A",parameter:"#CCCCCC",constant:"#E5E5E5",class:"#FFFFFF",className:"#FFFFFF",interface:"#D9D9D9",struct:"#E5E5E5",enum:"#E5E5E5",typeParameter:"#D9D9D9",namespace:"#CCCCCC",module:"#B3B3B3",tag:"#E5E5E5",jsxTag:"#FFFFFF",tagAttribute:"#B3B3B3",tagAttributeValue:"#999999",boolean:"#CCCCCC",decorator:"#999999",label:"#808080",punctuation:"#666666",macro:"#D9D9D9",preprocessor:"#B3B3B3",regex:"#A6A6A6",url:"#CCCCCC",key:"#E5E5E5",exception:"#999999"},highlights:{diffAdded:"#E5E5E5",diffAddedBackground:"#ffffff18",diffRemoved:"#666666",diffRemovedBackground:"#ffffff0d",diffModified:"#B3B3B3",diffModifiedBackground:"#ffffff12",lineNumber:"#404040",lineNumberActive:"#E5E5E5"}},markdown:{heading1:"#FFFFFF",heading2:"#F2F2F2",heading3:"#E5E5E5",heading4:"#D9D9D9",link:"#CCCCCC",linkHover:"#FFFFFF",inlineCode:"#B3B3B3",inlineCodeBackground:"#1A1A1A",blockquote:"#808080",blockquoteBorder:"#333333",listMarker:"#99999999"},chat:{userMessage:"#E5E5E5",userMessageBackground:"#1A1A1A",assistantMessage:"#E5E5E5",assistantMessageBackground:"#000000",timestamp:"#808080",divider:"#333333"},tools:{background:"#0A0A0A50",border:"#4040409d",headerHover:"#33333350",icon:"#A6A6A6",title:"#E5E5E5",description:"#808080",edit:{added:"#E5E5E5",addedBackground:"#ffffff20",removed:"#666666",removedBackground:"#ffffff10",lineNumber:"#404040"}}},ph={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},hh={metadata:mh,colors:gh,config:ph},Fh={id:"mono-light",name:"Mono",description:"A pure monochromatic theme - light variant with shades of grey",version:"1.0.0",variant:"light",tags:["light","monochrome","minimal","grayscale"]},yh={primary:{base:"#000000",hover:"#1A1A1A",active:"#333333",foreground:"#FFFFFF",muted:"#00000080",emphasis:"#000000"},surface:{background:"#FFFFFF",foreground:"#1A1A1A",muted:"#F5F5F5",mutedForeground:"#757575",elevated:"#FAFAFA",elevatedForeground:"#1A1A1A",overlay:"#00000020",subtle:"#F0F0F0"},interactive:{border:"#e3e3e3",borderHover:"#B3B3B3",borderFocus:"#000000",selection:"#00000015",selectionForeground:"#1A1A1A",focus:"#000000",focusRing:"#00000040",cursor:"#1A1A1A",hover:"#00000010",active:"#00000015"},status:{error:"#999999",errorForeground:"#FFFFFF",errorBackground:"#00000008",errorBorder:"#00000015",warning:"#666666",warningForeground:"#FFFFFF",warningBackground:"#0000000a",warningBorder:"#00000018",success:"#1A1A1A",successForeground:"#FFFFFF",successBackground:"#00000012",successBorder:"#00000020",info:"#595959",infoForeground:"#FFFFFF",infoBackground:"#0000000c",infoBorder:"#0000001a"},pr:{open:"#1A1A1A",draft:"#4D4D4D",blocked:"#999999",merged:"#333333",closed:"#666666"},syntax:{base:{background:"#F5F5F5",foreground:"#1A1A1A",comment:"#999999",keyword:"#000000",string:"#4D4D4D",number:"#666666",function:"#1A1A1A",variable:"#333333",type:"#262626",operator:"#808080"},tokens:{commentDoc:"#ABABAB",stringEscape:"#1A1A1A",keywordImport:"#000000",storageModifier:"#1A1A1A",functionCall:"#262626",method:"#333333",variableProperty:"#4D4D4D",variableOther:"#333333",variableGlobal:"#666666",variableLocal:"#E5E5E5",parameter:"#333333",constant:"#1A1A1A",class:"#000000",className:"#000000",interface:"#262626",struct:"#1A1A1A",enum:"#1A1A1A",typeParameter:"#262626",namespace:"#333333",module:"#4D4D4D",tag:"#1A1A1A",jsxTag:"#000000",tagAttribute:"#4D4D4D",tagAttributeValue:"#666666",boolean:"#333333",decorator:"#666666",label:"#808080",punctuation:"#999999",macro:"#262626",preprocessor:"#4D4D4D",regex:"#595959",url:"#333333",key:"#1A1A1A",exception:"#666666"},highlights:{diffAdded:"#1A1A1A",diffAddedBackground:"#00000012",diffRemoved:"#999999",diffRemovedBackground:"#00000008",diffModified:"#595959",diffModifiedBackground:"#0000000c",lineNumber:"#CCCCCC",lineNumberActive:"#1A1A1A"}},markdown:{heading1:"#000000",heading2:"#0D0D0D",heading3:"#1A1A1A",heading4:"#262626",link:"#333333",linkHover:"#000000",inlineCode:"#4D4D4D",inlineCodeBackground:"#f1f1f1",blockquote:"#808080",blockquoteBorder:"#D9D9D9",listMarker:"#66666699"},chat:{userMessage:"#1A1A1A",userMessageBackground:"#E5E5E5",assistantMessage:"#1A1A1A",assistantMessageBackground:"#FFFFFF",timestamp:"#808080",divider:"#D9D9D9"},tools:{background:"#F5F5F550",border:"#B3B3B380",headerHover:"#D9D9D9",icon:"#666666",title:"#1A1A1A",description:"#808080",edit:{added:"#1A1A1A",addedBackground:"#00000015",removed:"#999999",removedBackground:"#0000000a",lineNumber:"#CCCCCC"}}},bh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Ah={metadata:Fh,colors:yh,config:bh},Eh={id:"vitesse-dark-dark",name:"Vitesse Dark",description:"Converted from VS Code theme",version:"1.0.0",variant:"dark",tags:["dark","converted","vscode"]},wh={primary:{base:"#4d9375",hover:"#4d9375",active:"#5cb08c",foreground:"#121212",muted:"#4d937580",emphasis:"#64bf98"},surface:{background:"#121212",foreground:"#dbd7caee",muted:"#171717",mutedForeground:"#c0beb99c",elevated:"#1a1a1a",elevatedForeground:"#dbd7caee",overlay:"#12121280",subtle:"#1e1e1e"},interactive:{border:"#313131",borderHover:"#3c3c3c",borderFocus:"#00000000",selection:"#eeeeee18",selectionForeground:"#dbd7caee",focus:"#00000000",focusRing:"#0000000050",cursor:"#CECDC3",hover:"#eeeeee14",active:"#eeeeee18"},status:{error:"#cb7676",errorForeground:"#121212",errorBackground:"#cb767620",errorBorder:"#cb767650",warning:"#d4976c",warningForeground:"#121212",warningBackground:"#d4976c20",warningBorder:"#d4976c50",success:"#4d9375",successForeground:"#121212",successBackground:"#4d937520",successBorder:"#4d937550",info:"#6394bf",infoForeground:"#121212",infoBackground:"#6394bf20",infoBorder:"#6394bf50"},pr:{open:"#4d9375",draft:"#747f74",blocked:"#d4976c",merged:"#6c43be",closed:"#cb7676"},syntax:{base:{background:"#121212",foreground:"#dbd7caee",comment:"#758575dd",keyword:"#4d9375",string:"#c98a7d",number:"#4C9A91",function:"#80a665",variable:"#bd976a",type:"#5d99a9",operator:"#cb7676"},tokens:{commentDoc:"#575653",stringEscape:"#dbd7caee",keywordImport:"#D14D41",storageModifier:"#4385BE",functionCall:"#80a665",method:"#879A39",variableProperty:"#b8a965",variableOther:"#879A39",class:"#6872ab",className:"#6872ab",interface:"#5d99a9",tag:"#4d9375",boolean:"#4d9375",url:"#c98a7d",key:"#b8a965"},highlights:{diffAdded:"#4d9375",diffAddedBackground:"#4d937520",diffRemoved:"#cb7676",diffRemovedBackground:"#cb767620",lineNumber:"#dedcd550",lineNumberActive:"#bfbaaa"}},markdown:{heading1:"#4d9375",heading2:"#4d9375",heading3:"#4d9375",heading4:"#dbd7caee",link:"#4d9375",linkHover:"#4d9375",inlineCode:"#80a665",inlineCodeBackground:"#121212",blockquote:"#dedcd550",blockquoteBorder:"#ffffff15",listMarker:"#4d937599"},chat:{userMessage:"#dbd7caee",userMessageBackground:"#252525",assistantMessage:"#dbd7caee",assistantMessageBackground:"#121212",timestamp:"#dedcd550",divider:"#ffffff15"},tools:{background:"#12121250",border:"#2d2c2c",headerHover:"#ffffff1550",icon:"#dedcd5a4",title:"#dbd7caee",description:"#e9e8e27f",edit:{added:"#4d9375",addedBackground:"#4d937520",removed:"#cb7676",removedBackground:"#cb767620",lineNumber:"#ffffff24"}}},Bh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Ch={metadata:Eh,colors:wh,config:Bh},vh={id:"vitesse-light-light",name:"Vitesse Light",description:"Converted from VS Code theme",version:"1.0.0",variant:"light",tags:["light","converted","vscode"]},kh={primary:{base:"#1c6b48",hover:"#1c6b48",active:"#228056",foreground:"#ffffff",muted:"#1c6b4880",emphasis:"#248b5e"},surface:{background:"#ffffff",foreground:"#2c2c28",muted:"#f2f0f0",mutedForeground:"#5b5c54cb",elevated:"#f7f7f7",elevatedForeground:"#393a34",overlay:"#ffffff80",subtle:"#f6f3f3"},interactive:{border:"#dbd8d8",borderHover:"#cbc7c7",borderFocus:"#635454b8",selection:"#22222218",selectionForeground:"#393a34",focus:"#00000000",focusRing:"#0000000050",cursor:"#CECDC3",hover:"#22222218",active:"#22222218"},status:{error:"#ab5959",errorForeground:"#ffffff",errorBackground:"#ab595920",errorBorder:"#ab595950",warning:"#a65e2b",warningForeground:"#ffffff",warningBackground:"#a65e2b20",warningBorder:"#a65e2b50",success:"#1e754f",successForeground:"#ffffff",successBackground:"#1e754f20",successBorder:"#1e754f50",info:"#296aa3",infoForeground:"#ffffff",infoBackground:"#296aa320",infoBorder:"#296aa350"},pr:{open:"#1e754f",draft:"#a0ada0",blocked:"#a65e2b",merged:"#5843be",closed:"#ab5959"},syntax:{base:{background:"#ffffff",foreground:"#393a34",comment:"#a0ada0",keyword:"#1e754f",string:"#b56959",number:"#2f798a",function:"#59873a",variable:"#b07d48",type:"#2e808f",operator:"#ab5959"},tokens:{commentDoc:"#575653",stringEscape:"#393a34",keywordImport:"#D14D41",storageModifier:"#4385BE",functionCall:"#59873a",method:"#879A39",variableProperty:"#998418",variableOther:"#879A39",class:"#5a6aa6",className:"#5a6aa6",interface:"#2e808f",tag:"#1e754f",boolean:"#1e754f",url:"#b56959",key:"#998418"},highlights:{diffAdded:"#1e754f",diffAddedBackground:"#1e754f20",diffRemoved:"#ab5959",diffRemovedBackground:"#ab595920",lineNumber:"#393a3450",lineNumberActive:"#4e4f47"}},markdown:{heading1:"#2c2c28",heading2:"#2c2c28",heading3:"#2c2c28",heading4:"#2c2c28",link:"#1e754f",linkHover:"#1c6b48",inlineCode:"#3a631e",inlineCodeBackground:"#f7f3f395",blockquote:"#2c2c2850",blockquoteBorder:"#00000015",listMarker:"#1c6b4899"},chat:{userMessage:"#2c2c28",userMessageBackground:"#f4f1f1",assistantMessage:"#393a34",assistantMessageBackground:"#ffffff",timestamp:"#393a3450",divider:"#00000015"},tools:{background:"#ffffff50",border:"#dbd7d7",headerHover:"#0000001550",icon:"#21221e86",title:"#393a34",description:"#404139b6",edit:{added:"#1e754f",addedBackground:"#1e754f20",removed:"#ab5959",removedBackground:"#ab595920",lineNumber:"#b9b6b6"}}},Dh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Sh={metadata:vh,colors:kh,config:Dh},Mh=[wp,kp,jm,Wm,Ym,eg,ng,cg,fg,hg,Ag,Cg,Sg,Rg,Og,Hg,zg,Vg,Qg,rp,sp,lp,gp,yp,Tp,_p,Lp,jp,Wp,Yp,eh,nh,ch,fh,hh,Ah,Ch,Sh].map(e=>jr(e)),Th={id:"flexoki-light",name:"Flexoki",description:"An inky color scheme for prose and code - light variant",version:"1.0.0",variant:"light",tags:["light","warm","natural","paper"]},Ph={primary:{base:"#BC5215",hover:"#F9AE77",active:"#DA702C",foreground:"#fffdf4",muted:"#BC521580",emphasis:"#F9AE77"},surface:{background:"#fffdf4",foreground:"#100F0F",muted:"#f6f5ee",mutedForeground:"#686663",elevated:"#fbfaf2",elevatedForeground:"#100F0F",overlay:"#100F0F20",subtle:"#f7f4ec"},interactive:{border:"#e6e4db",borderHover:"#CECDC3",borderFocus:"#BC5215",selection:"#76736f30",selectionForeground:"#100F0F",focus:"#BC5215",focusRing:"#BC521540",cursor:"#100F0F",hover:"#76736f20",active:"#76736f20"},status:{error:"#AF3029",errorForeground:"#fffdf4",errorBackground:"#D14D4120",errorBorder:"#D14D4150",warning:"#BC5215",warningForeground:"#fffdf4",warningBackground:"#DA702C20",warningBorder:"#DA702C50",success:"#66800B",successForeground:"#fffdf4",successBackground:"#879A3920",successBorder:"#879A3950",info:"#205EA6",infoForeground:"#fffdf4",infoBackground:"#4385BE20",infoBorder:"#4385BE50"},pr:{open:"#66800B",draft:"#6F6E69",blocked:"#BC5215",merged:"#5E409D",closed:"#AF3029"},syntax:{base:{background:"#f6f5ee",foreground:"#100F0F",comment:"#6F6E69",keyword:"#205EA6",string:"#24837B",number:"#5E409D",function:"#BC5215",variable:"#100F0F",type:"#AD8301",operator:"#AF3029"},tokens:{commentDoc:"#B7B5AC",stringEscape:"#100F0F",keywordImport:"#AF3029",storageModifier:"#205EA6",functionCall:"#BC5215",method:"#66800B",variableProperty:"#205EA6",variableOther:"#66800B",variableGlobal:"#A02F6F",variableLocal:"#E6E4D9",parameter:"#100F0F",constant:"#100F0F",class:"#BC5215",className:"#BC5215",interface:"#AD8301",struct:"#BC5215",enum:"#BC5215",typeParameter:"#BC5215",namespace:"#AD8301",module:"#AF3029",tag:"#205EA6",jsxTag:"#A02F6F",tagAttribute:"#AD8301",tagAttributeValue:"#24837B",boolean:"#AD8301",decorator:"#AD8301",label:"#A02F6F",punctuation:"#6F6E69",macro:"#205EA6",preprocessor:"#A02F6F",regex:"#24837B",url:"#205EA6",key:"#BC5215",exception:"#A02F6F"},highlights:{diffAdded:"#66800B",diffAddedBackground:"#879A3920",diffRemoved:"#AF3029",diffRemovedBackground:"#D14D4120",diffModified:"#205EA6",diffModifiedBackground:"#4385BE20",lineNumber:"#CECDC3",lineNumberActive:"#100F0F"}},markdown:{heading1:"#100F0F",heading2:"#100F0F",heading3:"#100F0F",heading4:"#100F0F",link:"#205EA6",linkHover:"#4385BE",inlineCode:"#24837B",inlineCodeBackground:"#f6f5ee",blockquote:"#6F6E69",blockquoteBorder:"#DAD8CE",listMarker:"#AD830199"},chat:{userMessage:"#100F0F",userMessageBackground:"#f7f4ec",assistantMessage:"#100F0F",assistantMessageBackground:"#fffdf4",timestamp:"#6F6E69",divider:"#DAD8CE"},tools:{background:"#f6f5ee50",border:"#b4b2a980",headerHover:"#DAD8CE",icon:"#6F6E69",title:"#100F0F",description:"#6F6E69",edit:{added:"#66800B",addedBackground:"#66800B25",removed:"#AF3029",removedBackground:"#AF302925",lineNumber:"#CECDC3"}}},Rh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Ih={metadata:Th,colors:Ph,config:Rh},_h={id:"flexoki-dark",name:"Flexoki",description:"An inky color scheme for prose and code - dark variant",version:"1.0.0",variant:"dark",tags:["dark","warm","natural","ink"]},xh={primary:{base:"#DA702C",hover:"#DA702C",active:"#F9AE77",foreground:"#171515",muted:"#DA702C80",emphasis:"#F9AE77"},surface:{background:"#171515",foreground:"#CECDC3",muted:"#1C1B1A",mutedForeground:"#807e79",elevated:"#1c1a19",elevatedForeground:"#CECDC3",overlay:"#00000080",subtle:"#1e1d1c"},interactive:{border:"#2b2a28",borderHover:"#403E3C",borderFocus:"#DA702C",selection:"#f4f4f41f",selectionForeground:"#CECDC3",focus:"#DA702C",focusRing:"#DA702C50",cursor:"#CECDC3",hover:"#ffffff18",active:"#ffffff1f"},status:{error:"#D14D41",errorForeground:"#171515",errorBackground:"#AF302920",errorBorder:"#AF302950",warning:"#DA702C",warningForeground:"#171515",warningBackground:"#BC521520",warningBorder:"#BC521550",success:"#A0AF54",successForeground:"#171515",successBackground:"#66800B20",successBorder:"#66800B50",info:"#4385BE",infoForeground:"#171515",infoBackground:"#205EA620",infoBorder:"#205EA650"},pr:{open:"#A0AF54",draft:"#878580",blocked:"#DA702C",merged:"#8B7EC8",closed:"#D14D41"},syntax:{base:{background:"#1C1B1A",foreground:"#CECDC3",comment:"#878580",keyword:"#4385BE",string:"#3AA99F",number:"#8B7EC8",function:"#DA702C",variable:"#CECDC3",type:"#D0A215",operator:"#D14D41"},tokens:{commentDoc:"#575653",stringEscape:"#CECDC3",keywordImport:"#D14D41",storageModifier:"#4385BE",functionCall:"#DA702C",method:"#879A39",variableProperty:"#4385BE",variableOther:"#879A39",variableGlobal:"#CE5D97",variableLocal:"#282726",parameter:"#CECDC3",constant:"#CECDC3",class:"#DA702C",className:"#DA702C",interface:"#D0A215",struct:"#DA702C",enum:"#DA702C",typeParameter:"#DA702C",namespace:"#D0A215",module:"#D14D41",tag:"#4385BE",jsxTag:"#CE5D97",tagAttribute:"#D0A215",tagAttributeValue:"#3AA99F",boolean:"#D0A215",decorator:"#D0A215",label:"#CE5D97",punctuation:"#878580",macro:"#4385BE",preprocessor:"#CE5D97",regex:"#3AA99F",url:"#4385BE",key:"#DA702C",exception:"#CE5D97"},highlights:{diffAdded:"#879A39",diffAddedBackground:"#66800B20",diffRemoved:"#D14D41",diffRemovedBackground:"#AF302920",diffModified:"#4385BE",diffModifiedBackground:"#205EA620",lineNumber:"#403E3C",lineNumberActive:"#CECDC3"}},markdown:{heading1:"#fbf9e6",heading2:"#e6e4d2",heading3:"#CECDC3",heading4:"#CECDC3",link:"#4385BE",linkHover:"#205EA6",inlineCode:"#A0AF53",inlineCodeBackground:"#1C1B1A",blockquote:"#878580",blockquoteBorder:"#343331",listMarker:"#D0A21599"},chat:{userMessage:"#CECDC3",userMessageBackground:"#27180E",assistantMessage:"#CECDC3",assistantMessageBackground:"#171515",timestamp:"#878580",divider:"#343331"},tools:{background:"#1C1B1A50",border:"#42403e9d",headerHover:"#34333150",icon:"#aca7a1",title:"#CECDC3",description:"#878580",edit:{added:"#879A39",addedBackground:"#66800B25",removed:"#D14D41",removedBackground:"#AF302925",lineNumber:"#403E3C"}}},Oh={fonts:{sans:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',mono:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace',heading:'ui-monospace, "SFMono-Regular", "Menlo", "Cascadia Mono", "Segoe UI Mono", monospace'},transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Nh={metadata:_h,colors:xh,config:Oh},Lh={id:"pichamber-light",name:"PiChamber",description:"The PiChamber signature - crisp white surfaces with neutral typography and clean accents, inspired by Comet (light variant)",author:"PiChamber",version:"1.0.0",variant:"light",tags:["light","brand","neutral","comet"]},Uh={primary:{base:"#1e1e24",hover:"#0a0a0d",active:"#2d2d34",foreground:"#fafafc",muted:"#1e1e2480",emphasis:"#0a0a0d"},surface:{background:"#fcfcfd",foreground:"#2d2d34",muted:"#f3f3f6",mutedForeground:"#5c5c69",elevated:"#ffffff",elevatedForeground:"#2d2d34",overlay:"#00000015",subtle:"#eaeaf0"},interactive:{border:"#d8d8e0",borderHover:"#bcbccb",borderFocus:"#4f46e5",selection:"#00000014",selectionForeground:"#2d2d34",focus:"#4f46e5",focusRing:"#4f46e530",cursor:"#2d2d34",hover:"#00000008",active:"#00000010"},status:{error:"#dc2626",errorForeground:"#ffffff",errorBackground:"#dc262614",errorBorder:"#dc262635",warning:"#d97706",warningForeground:"#ffffff",warningBackground:"#d9770614",warningBorder:"#d9770635",success:"#059669",successForeground:"#ffffff",successBackground:"#05966914",successBorder:"#05966935",info:"#4f46e5",infoForeground:"#ffffff",infoBackground:"#4f46e514",infoBorder:"#4f46e535"},pr:{open:"#059669",draft:"#686875",blocked:"#d97706",merged:"#6366f1",closed:"#dc2626"},syntax:{base:{background:"#f3f3f6",foreground:"#2d2d34",comment:"#686875",keyword:"#435278",string:"#0f5b41",number:"#7c451e",function:"#4450b0",variable:"#2d2d34",type:"#7c451e",operator:"#2d2d34"},tokens:{commentDoc:"#686875",stringEscape:"#8d2f58",keywordImport:"#8d2f58",storageModifier:"#435278",functionCall:"#4450b0",method:"#4450b0",variableProperty:"#7c451e",variableOther:"#2d2d34",variableGlobal:"#0f5b41",variableLocal:"#2d2d34",parameter:"#2d2d34",constant:"#0f5b41",class:"#7c451e",className:"#7c451e",interface:"#7c451e",struct:"#7c451e",enum:"#7c451e",typeParameter:"#7c451e",namespace:"#7c451e",module:"#8d2f58",tag:"#8d2f58",jsxTag:"#8d2f58",tagAttribute:"#7c451e",tagAttributeValue:"#0f5b41",boolean:"#7c451e",decorator:"#4450b0",label:"#7c451e",punctuation:"#686875",macro:"#8d2f58",preprocessor:"#8d2f58",regex:"#0f5b41",url:"#4450b0",key:"#7c451e",exception:"#dc2626"},highlights:{diffAdded:"#059669",diffAddedBackground:"#05966918",diffRemoved:"#dc2626",diffRemovedBackground:"#dc262618",diffModified:"#4f46e5",diffModifiedBackground:"#4f46e514",lineNumber:"#9ca3af",lineNumberActive:"#2d2d34"}},markdown:{heading1:"#2d2d34",heading2:"#2d2d34",heading3:"#2d2d34",heading4:"#2d2d34",link:"#4f46e5",linkHover:"#3730a3",inlineCode:"#2d2d34",inlineCodeBackground:"#00000008",blockquote:"#686875",blockquoteBorder:"#e2e2e8",listMarker:"#4f46e590"},chat:{userMessage:"#2d2d34",userMessageBackground:"#ededf2",assistantMessage:"#2d2d34",assistantMessageBackground:"#fcfcfd",timestamp:"#8c8c9a",divider:"#e2e2e8"},tools:{background:"#f3f3f680",border:"#d8d8e0",headerHover:"#0000000d",icon:"#686875",title:"#2d2d34",description:"#686875",edit:{added:"#059669",addedBackground:"#05966920",removed:"#dc2626",removedBackground:"#dc262620",lineNumber:"#9ca3af"}}},Hh={transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},Kh={metadata:Lh,colors:Uh,config:Hh},jh={id:"pichamber-dark",name:"PiChamber",description:"The PiChamber signature - soft obsidian neutral surfaces with balanced contrast, inspired by Comet (dark variant)",author:"PiChamber",version:"1.0.0",variant:"dark",tags:["dark","brand","neutral","comet"]},$h={primary:{base:"#dcdce0",hover:"#f4f4f6",active:"#c8c8cc",foreground:"#0b0b0e",muted:"#dcdce080",emphasis:"#f4f4f6"},surface:{background:"#0f0f12",foreground:"#dcdce0",muted:"#0b0b0e",mutedForeground:"#aaaab4",elevated:"#18181d",elevatedForeground:"#dcdce0",overlay:"#000000b3",subtle:"#141418"},interactive:{border:"#29292f",borderHover:"#484853",borderFocus:"#818cf8",selection:"#ffffff24",selectionForeground:"#dcdce0",focus:"#818cf8",focusRing:"#818cf840",cursor:"#dcdce0",hover:"#ffffff0d",active:"#ffffff17"},status:{error:"#f87171",errorForeground:"#000000",errorBackground:"#f8717120",errorBorder:"#f8717145",warning:"#fbbf24",warningForeground:"#000000",warningBackground:"#fbbf2420",warningBorder:"#fbbf2445",success:"#34d399",successForeground:"#000000",successBackground:"#34d39920",successBorder:"#34d39945",info:"#818cf8",infoForeground:"#000000",infoBackground:"#818cf820",infoBorder:"#818cf845"},pr:{open:"#34d399",draft:"#aaaab4",blocked:"#fbbf24",merged:"#a5b4fc",closed:"#f87171"},syntax:{base:{background:"#0f0f12",foreground:"#dcdce0",comment:"#868693",keyword:"#a5b4fc",string:"#8fd4b0",number:"#e5c07b",function:"#a5b4fc",variable:"#dcdce0",type:"#e5c07b",operator:"#dcdce0"},tokens:{commentDoc:"#868693",stringEscape:"#f472b6",keywordImport:"#f472b6",storageModifier:"#a5b4fc",functionCall:"#a5b4fc",method:"#a5b4fc",variableProperty:"#dcdce0",variableOther:"#dcdce0",variableGlobal:"#8fd4b0",variableLocal:"#dcdce0",parameter:"#dcdce0",constant:"#8fd4b0",class:"#e5c07b",className:"#e5c07b",interface:"#e5c07b",struct:"#e5c07b",enum:"#e5c07b",typeParameter:"#e5c07b",namespace:"#e5c07b",module:"#f472b6",tag:"#f472b6",jsxTag:"#f472b6",tagAttribute:"#e5c07b",tagAttributeValue:"#8fd4b0",boolean:"#e5c07b",decorator:"#a5b4fc",label:"#e5c07b",punctuation:"#aaaab4",macro:"#f472b6",preprocessor:"#f472b6",regex:"#8fd4b0",url:"#a5b4fc",key:"#e5c07b",exception:"#f87171"},highlights:{diffAdded:"#34d399",diffAddedBackground:"#34d3991c",diffRemoved:"#f87171",diffRemovedBackground:"#f871711c",diffModified:"#818cf8",diffModifiedBackground:"#818cf81c",lineNumber:"#74747e",lineNumberActive:"#dcdce0"}},markdown:{heading1:"#dcdce0",heading2:"#dcdce0",heading3:"#dcdce0",heading4:"#dcdce0",link:"#818cf8",linkHover:"#a5b4fc",inlineCode:"#a5b4fc",inlineCodeBackground:"#818cf81f",blockquote:"#aaaab4",blockquoteBorder:"#222228",listMarker:"#818cf880"},chat:{userMessage:"#dcdce0",userMessageBackground:"#18181d",assistantMessage:"#dcdce0",assistantMessageBackground:"#0f0f12",timestamp:"#8a8a95",divider:"#222228"},tools:{background:"#18181d80",border:"#222228",headerHover:"#ffffff0d",icon:"#aaaab4",title:"#dcdce0",description:"#8a8a95",edit:{added:"#34d399",addedBackground:"#34d39920",removed:"#f87171",removedBackground:"#f8717120",lineNumber:"#666671"}}},zh={transitions:{fast:"150ms ease",normal:"250ms ease",slow:"350ms ease"}},qh={metadata:jh,colors:$h,config:zh},Ac=jr(Ih),Wh=jr(Nh),Gh=jr(Kh),Vh=jr(qh),Ec="pichamber-light",wc="pichamber-dark",In=[Gh,Vh,Ac,Wh,...Mh.filter(e=>e.metadata.id!=="pichamber-light"&&e.metadata.id!=="pichamber-dark"&&e.metadata.id!=="pichamber-light"&&e.metadata.id!=="pichamber-dark")];function Jh(e){const t=e==="app-light"||e==="pichamber-light"?"pichamber-light":e==="app-dark"||e==="pichamber-dark"?"pichamber-dark":e;return In.find(r=>r.metadata.id===t)}function _A(e){const t=e?"dark":"light",o=Jh(e?wc:Ec);return o&&o.metadata.variant===t?o:In.find(n=>n.metadata.variant===t)??In[0]??Ac}const Yh=[{id:"finder",label:"Finder",appName:"Finder"},{id:"terminal",label:"Terminal",appName:"Terminal"},{id:"iterm2",label:"iTerm2",appName:"iTerm"},{id:"ghostty",label:"Ghostty",appName:"Ghostty"},{id:"vscode",label:"VS Code",appName:"Visual Studio Code"},{id:"vscode-insiders",label:"VS Code Insiders",appName:"Visual Studio Code - Insiders"},{id:"intellij",label:"IntelliJ",appName:"IntelliJ IDEA"},{id:"visual-studio",label:"Visual Studio",appName:"Visual Studio"},{id:"cursor",label:"Cursor",appName:"Cursor"},{id:"android-studio",label:"Android Studio",appName:"Android Studio"},{id:"pycharm",label:"PyCharm",appName:"PyCharm"},{id:"xcode",label:"Xcode",appName:"Xcode"},{id:"sublime-text",label:"Sublime",appName:"Sublime Text"},{id:"webstorm",label:"WebStorm",appName:"WebStorm"},{id:"rider",label:"Rider",appName:"Rider"},{id:"zed",label:"Zed",appName:"Zed"},{id:"phpstorm",label:"PhpStorm",appName:"PhpStorm"},{id:"eclipse",label:"Eclipse",appName:"Eclipse"},{id:"windsurf",label:"Windsurf",appName:"Windsurf"},{id:"vscodium",label:"VSCodium",appName:"VSCodium"},{id:"rustrover",label:"RustRover",appName:"RustRover"},{id:"kiro",label:"Kiro",appName:"Kiro"},{id:"antigravity",label:"Antigravity",appName:"Antigravity"},{id:"trae",label:"Trae",appName:"Trae"}],Xh="finder",xA=new Set(["finder","terminal"]),Qh=e=>{if(typeof window>"u")return e;const t=window.__PICHAMBER_PLATFORM__;if(e.id==="finder"){if(t==="win32")return{...e,label:"Explorer",appName:"File Explorer"};if(t==="linux")return{...e,label:"File Manager"}}return e},OA=e=>{if(!e)return null;const t=Yh.find(r=>r.id===e)??null;return t?Qh(t):null},Zh=e=>{if(!Array.isArray(e))return;const t=[],r=new Set;for(const o of e){if(!o||typeof o!="object")continue;const n=o,a=typeof n.id=="string"?n.id.trim():"",s=typeof n.label=="string"?n.label.trim():"",i=typeof n.source=="string"?n.source.trim():"",c=typeof n.subpath=="string"?n.subpath.trim():"";!a||!s||!i||r.has(a)||(r.add(a),t.push({id:a,label:s,source:i,...c?{subpath:c}:{}}))}return t},eF=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[r,o]of Object.entries(e)){const n=typeof r=="string"?r.trim():"",a=typeof o=="string"?o.trim():"";!n||!a||(t[n]=a)}return t},_n=e=>{if(Array.isArray(e))return Array.from(new Set(e.filter(t=>typeof t=="string"&&t.length>0)))},tF=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[r,o]of Object.entries(e)){if(!r||!Array.isArray(o))continue;const n=_n(o);n&&n.length>0&&(t[r]=n.slice(0,5))}return Object.keys(t).length>0?t:void 0},rF=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,oF=e=>{if(typeof e!="string")return null;const t=e.trim();return t&&rF.test(t)?t.toLowerCase():null},nF=e=>{if(!Array.isArray(e))return;const t=[],r=new Set,o=new Set;for(const n of e){if(!n||typeof n!="object")continue;const a=n,s=typeof a.path=="string"?a.path.trim():"";if(!s)continue;const i=s==="/"?s:s.replace(/\\/g,"/").replace(/\/+$/,"");if(!i)continue;const c=xm(i);if(!c||r.has(c)||o.has(i))continue;r.add(c),o.add(i);const d={id:c,path:i};if(typeof a.label=="string"&&a.label.trim().length>0&&(d.label=a.label.trim()),typeof a.icon=="string"&&a.icon.trim().length>0&&(d.icon=a.icon.trim()),a.iconImage===null)d.iconImage=null;else if(a.iconImage&&typeof a.iconImage=="object"){const l=a.iconImage,u=typeof l.mime=="string"?l.mime.trim():"",f=typeof l.updatedAt=="number"&&Number.isFinite(l.updatedAt)?Math.max(0,Math.round(l.updatedAt)):0,m=l.source==="custom"||l.source==="auto"?l.source:null;u&&f>0&&m&&(d.iconImage={mime:u,updatedAt:f,source:m})}if(typeof a.color=="string"&&a.color.trim().length>0&&(d.color=a.color.trim()),a.iconBackground===null)d.iconBackground=null;else{const l=oF(a.iconBackground);l&&(d.iconBackground=l)}typeof a.addedAt=="number"&&Number.isFinite(a.addedAt)&&a.addedAt>=0&&(d.addedAt=a.addedAt),typeof a.lastOpenedAt=="number"&&Number.isFinite(a.lastOpenedAt)&&a.lastOpenedAt>=0&&(d.lastOpenedAt=a.lastOpenedAt),typeof a.sidebarCollapsed=="boolean"&&(d.sidebarCollapsed=a.sidebarCollapsed),t.push(d)}return t.length>0?t:void 0},aF=e=>{if(!Array.isArray(e))return;const t=[],r=new Set,o=new Set;for(const n of e){if(!n||typeof n!="object")continue;const a=n,s=typeof a.id=="string"?a.id.trim():"",i=typeof a.name=="string"?a.name.trim():"",c=typeof a.hostname=="string"?a.hostname.trim().toLowerCase():"";!s||!i||!c||r.has(s)||o.has(c)||(r.add(s),o.add(c),t.push({id:s,name:i,hostname:c}))}return t},sF=e=>{if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,r={};for(const[o,n]of Object.entries(t)){const a=o.trim(),s=typeof n=="string"?n.trim():"";!a||!s||(r[a]=s)}return Object.keys(r).length>0?r:void 0},un=(e,t)=>{if(!Array.isArray(e))return;const r=[],o=new Set;for(const n of e){if(!n||typeof n!="object")continue;const a=n,s=typeof a.providerID=="string"?a.providerID.trim():"",i=typeof a.modelID=="string"?a.modelID.trim():"";if(!s||!i)continue;const c=`${s}/${i}`;if(!o.has(c)&&(o.add(c),r.push({providerID:s,modelID:i}),r.length>=t))break}return r},iF=e=>{const t=ie.getInitialState();return{useSystemTheme:!0,lightThemeId:Ec,darkThemeId:wc,openInAppId:Xh,autoDeleteEnabled:t.autoDeleteEnabled,autoSaveEnabled:t.autoSaveEnabled,autoDeleteAfterDays:t.autoDeleteAfterDays,sessionRetentionAction:t.sessionRetentionAction,followUpBehavior:Na,showDeletionDialog:t.showDeletionDialog,nativeNotificationsEnabled:t.nativeNotificationsEnabled,notificationMode:t.notificationMode,notifyOnCompletion:t.notifyOnCompletion,notifyOnError:t.notifyOnError,notifyOnInputNeeded:t.notifyOnInputNeeded,summarizeLastMessage:t.summarizeLastMessage,summaryThreshold:t.summaryThreshold,summaryLength:t.summaryLength,maxLastMessageLength:t.maxLastMessageLength,timeFormatPreference:t.timeFormatPreference,weekStartPreference:t.weekStartPreference,sidebarViewMode:t.sidebarViewMode,sessionAutoArchiveAfterDays:t.sessionAutoArchiveAfterDays,sessionAutoDeleteAfterDays:t.sessionAutoDeleteAfterDays,expandedEditorToolbar:t.expandedEditorToolbar,wrapLinesByDefault:t.wrapLinesByDefault,draftStartersVisible:t.draftStartersVisible,draftWallpaper:t.draftWallpaper,draftWallpaperMotion:t.draftWallpaperMotion,draftWallpaperPicture:t.draftWallpaperPicture,draftWallpaperInSessions:t.draftWallpaperInSessions,draftWallpaperImageVersion:t.draftWallpaperImageVersion,fontSize:t.fontSize,terminalFontSize:t.terminalFontSize,terminalShell:t.terminalShell,terminalLoginShells:t.terminalLoginShells,editorFontSize:t.editorFontSize,uiFont:t.uiFont,monoFont:t.monoFont,padding:t.padding,cornerRadius:t.cornerRadius,inputBarOffset:t.inputBarOffset,shortcutOverrides:t.shortcutOverrides,mobileKeyboardMode:"resize-content",favoriteModels:t.favoriteModels,hiddenModels:t.hiddenModels,collapsedModelProviders:t.collapsedModelProviders,recentModels:t.recentModels,recentAgents:t.recentAgents,recentEfforts:t.recentEfforts,diffLayoutPreference:t.diffLayoutPreference,gitChangesViewMode:t.gitChangesViewMode,filesViewShowGitignored:!1,...e}},cF=(e,t)=>{const r=Object.entries(e),o=Object.entries(t);return r.length!==o.length?!1:r.every(([n,a])=>t[n]===a)},dF=(e,t)=>e.length===t.length&&e.every((r,o)=>{const n=t[o];return!!n&&r.id===n?.id&&r.label===n.label&&r.command===n.command&&r.args===n.args&&r.combo===n.combo}),fn=(e,t)=>e.length===t.length&&e.every((r,o)=>r.providerID===t[o]?.providerID&&r.modelID===t[o]?.modelID),xn=(e,t)=>e.length===t.length&&e.every((r,o)=>r===t[o]),lF=(e,t)=>{const r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(o=>Array.isArray(t[o])&&xn(e[o],t[o]))},On=e=>{if(!e||typeof e!="object")return null;const t=e,r={};typeof t.themeId=="string"&&t.themeId.length>0&&(r.themeId=t.themeId),(t.useSystemTheme===!0||t.useSystemTheme===!1)&&(r.useSystemTheme=t.useSystemTheme),typeof t.themeVariant=="string"&&(t.themeVariant==="light"||t.themeVariant==="dark")&&(r.themeVariant=t.themeVariant),typeof t.lightThemeId=="string"&&t.lightThemeId.length>0&&(r.lightThemeId=t.lightThemeId),typeof t.darkThemeId=="string"&&t.darkThemeId.length>0&&(r.darkThemeId=t.darkThemeId),typeof t.lastDirectory=="string"&&t.lastDirectory.length>0&&(r.lastDirectory=t.lastDirectory),typeof t.homeDirectory=="string"&&t.homeDirectory.length>0&&(r.homeDirectory=t.homeDirectory),typeof t.desktopLanAccessEnabled=="boolean"&&(r.desktopLanAccessEnabled=t.desktopLanAccessEnabled),typeof t.desktopKeepAwakeEnabled=="boolean"&&(r.desktopKeepAwakeEnabled=t.desktopKeepAwakeEnabled),typeof t.desktopProcessPerformanceRecordingEnabled=="boolean"&&(r.desktopProcessPerformanceRecordingEnabled=t.desktopProcessPerformanceRecordingEnabled),typeof t.desktopMinimizeToTrayEnabled=="boolean"&&(r.desktopMinimizeToTrayEnabled=t.desktopMinimizeToTrayEnabled),typeof t.desktopMacMenuBarEnabled=="boolean"&&(r.desktopMacMenuBarEnabled=t.desktopMacMenuBarEnabled),(t.desktopUpdateChannel==="stable"||t.desktopUpdateChannel==="rc")&&(r.desktopUpdateChannel=t.desktopUpdateChannel),(t.serverUpdateChannel==="stable"||t.serverUpdateChannel==="rc")&&(r.serverUpdateChannel=t.serverUpdateChannel);const o=nF(t.projects);if(o&&(r.projects=o),typeof t.activeProjectId=="string"&&t.activeProjectId.length>0&&(r.activeProjectId=t.activeProjectId),Array.isArray(t.securityScopedBookmarks)&&(r.securityScopedBookmarks=t.securityScopedBookmarks.filter(p=>typeof p=="string"&&p.length>0)),Array.isArray(t.pinnedDirectories)&&(r.pinnedDirectories=Array.from(new Set(t.pinnedDirectories.filter(p=>typeof p=="string"&&p.length>0)))),Array.isArray(t.draftStarters)&&(r.draftStarters=Ma(t.draftStarters)),typeof t.draftStartersVisible=="boolean"&&(r.draftStartersVisible=t.draftStartersVisible),Pa(t.draftWallpaper)&&(r.draftWallpaper=t.draftWallpaper),typeof t.draftWallpaperMotion=="boolean"&&(r.draftWallpaperMotion=t.draftWallpaperMotion),typeof t.draftWallpaperPicture=="boolean"&&(r.draftWallpaperPicture=t.draftWallpaperPicture),typeof t.draftWallpaperInSessions=="boolean"&&(r.draftWallpaperInSessions=t.draftWallpaperInSessions),(t.draftWallpaperImageVersion===null||sc(t.draftWallpaperImageVersion))&&(r.draftWallpaperImageVersion=t.draftWallpaperImageVersion),typeof t.draftStartersScheduleTaskAdded=="boolean"&&(r.draftStartersScheduleTaskAdded=t.draftStartersScheduleTaskAdded),typeof t.autoDeleteEnabled=="boolean"&&(r.autoDeleteEnabled=t.autoDeleteEnabled),typeof t.autoSaveEnabled=="boolean"&&(r.autoSaveEnabled=t.autoSaveEnabled),typeof t.autoDeleteAfterDays=="number"&&Number.isFinite(t.autoDeleteAfterDays)&&(r.autoDeleteAfterDays=t.autoDeleteAfterDays),(t.sessionRetentionAction==="archive"||t.sessionRetentionAction==="delete")&&(r.sessionRetentionAction=t.sessionRetentionAction),typeof t.tunnelProvider=="string"){const p=t.tunnelProvider.trim().toLowerCase();p.length>0&&(r.tunnelProvider=p)}if(typeof t.tunnelMode=="string"){const p=t.tunnelMode.trim().toLowerCase();(p==="managed-remote"||p==="managed-local")&&(r.tunnelMode=p)}if(t.tunnelBootstrapTtlMs===null?r.tunnelBootstrapTtlMs=null:typeof t.tunnelBootstrapTtlMs=="number"&&Number.isFinite(t.tunnelBootstrapTtlMs)&&(r.tunnelBootstrapTtlMs=t.tunnelBootstrapTtlMs),typeof t.tunnelSessionTtlMs=="number"&&Number.isFinite(t.tunnelSessionTtlMs)&&(r.tunnelSessionTtlMs=t.tunnelSessionTtlMs),t.managedLocalTunnelConfigPath===null)r.managedLocalTunnelConfigPath=null;else if(typeof t.managedLocalTunnelConfigPath=="string"){const p=t.managedLocalTunnelConfigPath.trim();r.managedLocalTunnelConfigPath=p.length>0?p:null}typeof t.managedRemoteTunnelHostname=="string"&&(r.managedRemoteTunnelHostname=t.managedRemoteTunnelHostname.trim()),t.managedRemoteTunnelToken===null?r.managedRemoteTunnelToken=null:typeof t.managedRemoteTunnelToken=="string"&&(r.managedRemoteTunnelToken=t.managedRemoteTunnelToken.trim());const n=aF(t.managedRemoteTunnelPresets);if(n&&(r.managedRemoteTunnelPresets=n),typeof t.managedRemoteTunnelSelectedPresetId=="string"){const p=t.managedRemoteTunnelSelectedPresetId.trim();r.managedRemoteTunnelSelectedPresetId=p.length>0?p:void 0}const a=sF(t.managedRemoteTunnelPresetTokens);if(a&&(r.managedRemoteTunnelPresetTokens=a),typeof t.defaultModel=="string"&&t.defaultModel.length>0&&(r.defaultModel=t.defaultModel),typeof t.defaultVariant=="string"&&t.defaultVariant.length>0&&(r.defaultVariant=t.defaultVariant),typeof t.smallModelUseDefault=="boolean"&&(r.smallModelUseDefault=t.smallModelUseDefault),typeof t.smallModelOverride=="string"&&t.smallModelOverride.length>0&&(r.smallModelOverride=t.smallModelOverride),typeof t.walkthroughModelOverride=="string"&&t.walkthroughModelOverride.length>0&&(r.walkthroughModelOverride=t.walkthroughModelOverride),typeof t.autoCreateWorktree=="boolean"&&(r.autoCreateWorktree=t.autoCreateWorktree),La(t.followUpBehavior)?r.followUpBehavior=t.followUpBehavior:typeof t.queueModeEnabled=="boolean"&&(r.followUpBehavior=Ua(void 0,t.queueModeEnabled)),typeof t.showDeletionDialog=="boolean"&&(r.showDeletionDialog=t.showDeletionDialog),typeof t.nativeNotificationsEnabled=="boolean"&&(r.nativeNotificationsEnabled=t.nativeNotificationsEnabled),typeof t.notificationMode=="string"&&(t.notificationMode==="always"||t.notificationMode==="hidden-only")&&(r.notificationMode=t.notificationMode),typeof t.notifyOnCompletion=="boolean"&&(r.notifyOnCompletion=t.notifyOnCompletion),typeof t.notifyOnError=="boolean"&&(r.notifyOnError=t.notifyOnError),typeof t.notifyOnInputNeeded=="boolean"&&(r.notifyOnInputNeeded=t.notifyOnInputNeeded),typeof t.summarizeLastMessage=="boolean"&&(r.summarizeLastMessage=t.summarizeLastMessage),typeof t.summaryThreshold=="number"&&Number.isFinite(t.summaryThreshold)&&(r.summaryThreshold=Math.max(0,Math.round(t.summaryThreshold))),typeof t.summaryLength=="number"&&Number.isFinite(t.summaryLength)&&(r.summaryLength=Math.max(10,Math.round(t.summaryLength))),typeof t.maxLastMessageLength=="number"&&Number.isFinite(t.maxLastMessageLength)&&(r.maxLastMessageLength=Math.max(10,Math.round(t.maxLastMessageLength))),typeof t.usageAutoRefresh=="boolean"&&(r.usageAutoRefresh=t.usageAutoRefresh),typeof t.usageRefreshIntervalMs=="number"&&Number.isFinite(t.usageRefreshIntervalMs)&&(r.usageRefreshIntervalMs=t.usageRefreshIntervalMs),(t.usageDisplayMode==="usage"||t.usageDisplayMode==="remaining")&&(r.usageDisplayMode=t.usageDisplayMode),typeof t.usageShowPredValues=="boolean"&&(r.usageShowPredValues=t.usageShowPredValues),Array.isArray(t.usageDropdownProviders)&&(r.usageDropdownProviders=t.usageDropdownProviders.filter(p=>typeof p=="string"&&p.length>0)),t.usageSelectedModels&&typeof t.usageSelectedModels=="object"){const p={};for(const[k,A]of Object.entries(t.usageSelectedModels))Array.isArray(A)&&(p[k]=A.filter(C=>typeof C=="string"));Object.keys(p).length>0&&(r.usageSelectedModels=p)}if(t.usageCollapsedFamilies&&typeof t.usageCollapsedFamilies=="object"){const p={};for(const[k,A]of Object.entries(t.usageCollapsedFamilies))Array.isArray(A)&&(p[k]=A.filter(C=>typeof C=="string"));Object.keys(p).length>0&&(r.usageCollapsedFamilies=p)}if(t.usageExpandedFamilies&&typeof t.usageExpandedFamilies=="object"){const p={};for(const[k,A]of Object.entries(t.usageExpandedFamilies))Array.isArray(A)&&(p[k]=A.filter(C=>typeof C=="string"));Object.keys(p).length>0&&(r.usageExpandedFamilies=p)}if(t.usageModelGroups&&typeof t.usageModelGroups=="object"){const p={};for(const[k,A]of Object.entries(t.usageModelGroups))if(A&&typeof A=="object"){const C=A,w={};Array.isArray(C.customGroups)&&(w.customGroups=C.customGroups.filter(B=>B&&typeof B=="object").map(B=>({id:String(B.id??""),label:String(B.label??""),models:Array.isArray(B.models)?B.models.filter(P=>typeof P=="string"):[],order:typeof B.order=="number"?B.order:0}))),C.modelAssignments&&typeof C.modelAssignments=="object"&&(w.modelAssignments=Object.fromEntries(Object.entries(C.modelAssignments).filter(([,B])=>typeof B=="string").map(([B,P])=>[B,String(P)]))),C.renamedGroups&&typeof C.renamedGroups=="object"&&(w.renamedGroups=Object.fromEntries(Object.entries(C.renamedGroups).filter(([,B])=>typeof B=="string").map(([B,P])=>[B,String(P)]))),Object.keys(w).length>0&&(p[k]=w)}Object.keys(p).length>0&&(r.usageModelGroups=p)}typeof t.timeFormatPreference=="string"&&(t.timeFormatPreference==="auto"||t.timeFormatPreference==="12h"||t.timeFormatPreference==="24h")&&(r.timeFormatPreference=t.timeFormatPreference),typeof t.weekStartPreference=="string"&&(t.weekStartPreference==="auto"||t.weekStartPreference==="sunday"||t.weekStartPreference==="monday")&&(r.weekStartPreference=t.weekStartPreference),ac(t.sidebarViewMode)&&(r.sidebarViewMode=t.sidebarViewMode);const s=t.sidebarAutoSettleAfterDays;if(typeof s=="number"&&Number.isInteger(s)&&s>=0&&s<=90&&(r.sidebarAutoSettleAfterDays=s),Jt(t.sessionAutoArchiveAfterDays)&&(r.sessionAutoArchiveAfterDays=t.sessionAutoArchiveAfterDays),Jt(t.sessionAutoDeleteAfterDays)&&(r.sessionAutoDeleteAfterDays=t.sessionAutoDeleteAfterDays),typeof t.expandedEditorToolbar=="boolean"&&(r.expandedEditorToolbar=t.expandedEditorToolbar),typeof t.wrapLinesByDefault=="boolean"&&(r.wrapLinesByDefault=t.wrapLinesByDefault),typeof t.fontSize=="number"&&Number.isFinite(t.fontSize)&&(r.fontSize=t.fontSize),typeof t.terminalFontSize=="number"&&Number.isFinite(t.terminalFontSize)&&(r.terminalFontSize=t.terminalFontSize),Co(t.terminalShell)&&(r.terminalShell=t.terminalShell),Array.isArray(t.terminalLoginShells)&&(r.terminalLoginShells=[...new Set(t.terminalLoginShells.filter(Co))]),typeof t.editorFontSize=="number"&&Number.isFinite(t.editorFontSize)&&(r.editorFontSize=t.editorFontSize),rc(t.uiFont)&&(r.uiFont=t.uiFont),oc(t.monoFont)&&(r.monoFont=t.monoFont),typeof t.padding=="number"&&Number.isFinite(t.padding)&&(r.padding=t.padding),typeof t.cornerRadius=="number"&&Number.isFinite(t.cornerRadius)&&(r.cornerRadius=t.cornerRadius),typeof t.inputBarOffset=="number"&&Number.isFinite(t.inputBarOffset)&&(r.inputBarOffset=t.inputBarOffset),typeof t.openInAppId=="string"&&t.openInAppId.length>0&&(r.openInAppId=t.openInAppId),typeof t.pwaAppName=="string"){const p=nc(t.pwaAppName,"");r.pwaAppName=p.length>0?p:""}typeof t.mobileKeyboardMode=="string"&&(t.mobileKeyboardMode==="native"||t.mobileKeyboardMode==="resize-content")&&(r.mobileKeyboardMode=t.mobileKeyboardMode);const i=eF(t.shortcutOverrides);i&&(r.shortcutOverrides=i);const c=Rm(t.commandTriggers);c&&(r.commandTriggers=c);const d=un(t.favoriteModels,50);d&&(r.favoriteModels=d);const l=un(t.hiddenModels,1e4);l&&(r.hiddenModels=l);const u=_n(t.collapsedModelProviders);u&&(r.collapsedModelProviders=u);const f=un(t.recentModels,10);f&&(r.recentModels=f);const m=_n(t.recentAgents);m&&(r.recentAgents=m.slice(0,10));const g=tF(t.recentEfforts);g&&(r.recentEfforts=g),typeof t.diffLayoutPreference=="string"&&(t.diffLayoutPreference==="dynamic"||t.diffLayoutPreference==="inline"||t.diffLayoutPreference==="side-by-side")&&(r.diffLayoutPreference=t.diffLayoutPreference),typeof t.gitChangesViewMode=="string"&&(t.gitChangesViewMode==="flat"||t.gitChangesViewMode==="tree")&&(r.gitChangesViewMode=t.gitChangesViewMode),typeof t.filesViewShowGitignored=="boolean"&&(r.filesViewShowGitignored=t.filesViewShowGitignored);const h=Zh(t.skillCatalogs);return h&&(r.skillCatalogs=h),Object.keys(r).length>0?r:null},Bc="filesViewShowGitignored",Nn="files-view-show-gitignored-change",$s=()=>{if(typeof window>"u")return!1;try{return Kr().getItem(Bc)==="true"}catch{return!1}},uF=()=>{typeof window>"u"||window.dispatchEvent(new Event(Nn))},fF=(e,t={})=>{if(!(typeof window>"u")){try{Kr().setItem(Bc,e?"true":"false"),uF()}catch{}t.persist!==!1&&Ke({filesViewShowGitignored:e})}},NA=()=>{const[e,t]=Xa.useState($s);return Xa.useEffect(()=>{if(typeof window>"u")return;const r=()=>{t($s())};return window.addEventListener("storage",r),window.addEventListener(Nn,r),()=>{window.removeEventListener("storage",r),window.removeEventListener(Nn,r)}},[]),e},Cc=e=>{if(!e||typeof e!="object")return!1;const t=e;return t.status===401||t.response?.status===401?!0:typeof t.message=="string"&&/(?:ui )?authentication required|unauthorized|\b401\b/i.test(t.message)},Ln=e=>{const t=ie.getState(),r=Am.getState();if(typeof e.autoDeleteEnabled=="boolean"&&e.autoDeleteEnabled!==t.autoDeleteEnabled&&t.setAutoDeleteEnabled(e.autoDeleteEnabled),typeof e.autoSaveEnabled=="boolean"&&e.autoSaveEnabled!==t.autoSaveEnabled&&t.setAutoSaveEnabled(e.autoSaveEnabled),typeof e.autoDeleteAfterDays=="number"&&Number.isFinite(e.autoDeleteAfterDays)){const n=Math.max(1,Math.min(365,e.autoDeleteAfterDays));n!==t.autoDeleteAfterDays&&t.setAutoDeleteAfterDays(n)}(e.sessionRetentionAction==="archive"||e.sessionRetentionAction==="delete")&&e.sessionRetentionAction!==t.sessionRetentionAction&&t.setSessionRetentionAction(e.sessionRetentionAction);let o=null;if(La(e.followUpBehavior)?o=e.followUpBehavior:typeof e.queueModeEnabled=="boolean"&&(o=Ua(void 0,e.queueModeEnabled)),o&&o!==r.followUpBehavior&&r.setFollowUpBehavior(o),typeof e.showDeletionDialog=="boolean"&&e.showDeletionDialog!==t.showDeletionDialog&&t.setShowDeletionDialog(e.showDeletionDialog),typeof e.nativeNotificationsEnabled=="boolean"&&e.nativeNotificationsEnabled!==t.nativeNotificationsEnabled&&t.setNativeNotificationsEnabled(e.nativeNotificationsEnabled),typeof e.notificationMode=="string"&&(e.notificationMode==="always"||e.notificationMode==="hidden-only")&&e.notificationMode!==t.notificationMode&&t.setNotificationMode(e.notificationMode),typeof e.notifyOnCompletion=="boolean"&&e.notifyOnCompletion!==t.notifyOnCompletion&&t.setNotifyOnCompletion(e.notifyOnCompletion),typeof e.notifyOnError=="boolean"&&e.notifyOnError!==t.notifyOnError&&t.setNotifyOnError(e.notifyOnError),typeof e.notifyOnInputNeeded=="boolean"&&e.notifyOnInputNeeded!==t.notifyOnInputNeeded&&t.setNotifyOnInputNeeded(e.notifyOnInputNeeded),typeof e.summarizeLastMessage=="boolean"&&e.summarizeLastMessage!==t.summarizeLastMessage&&t.setSummarizeLastMessage(e.summarizeLastMessage),typeof e.summaryThreshold=="number"&&Number.isFinite(e.summaryThreshold)&&t.setSummaryThreshold(e.summaryThreshold),typeof e.summaryLength=="number"&&Number.isFinite(e.summaryLength)&&t.setSummaryLength(e.summaryLength),typeof e.maxLastMessageLength=="number"&&Number.isFinite(e.maxLastMessageLength)&&t.setMaxLastMessageLength(e.maxLastMessageLength),typeof e.timeFormatPreference=="string"&&(e.timeFormatPreference==="auto"||e.timeFormatPreference==="12h"||e.timeFormatPreference==="24h")&&e.timeFormatPreference!==t.timeFormatPreference&&t.setTimeFormatPreference(e.timeFormatPreference),typeof e.weekStartPreference=="string"&&(e.weekStartPreference==="auto"||e.weekStartPreference==="sunday"||e.weekStartPreference==="monday")&&e.weekStartPreference!==t.weekStartPreference&&t.setWeekStartPreference(e.weekStartPreference),ac(e.sidebarViewMode)&&e.sidebarViewMode!==t.sidebarViewMode&&t.setSidebarViewMode(e.sidebarViewMode),Jt(e.sessionAutoArchiveAfterDays)&&e.sessionAutoArchiveAfterDays!==t.sessionAutoArchiveAfterDays&&t.setSessionAutoArchiveAfterDays(e.sessionAutoArchiveAfterDays),Jt(e.sessionAutoDeleteAfterDays)&&e.sessionAutoDeleteAfterDays!==t.sessionAutoDeleteAfterDays&&t.setSessionAutoDeleteAfterDays(e.sessionAutoDeleteAfterDays),typeof e.expandedEditorToolbar=="boolean"&&e.expandedEditorToolbar!==t.expandedEditorToolbar&&t.setExpandedEditorToolbar(e.expandedEditorToolbar),typeof e.wrapLinesByDefault=="boolean"&&e.wrapLinesByDefault!==t.wrapLinesByDefault&&t.setWrapLinesByDefault(e.wrapLinesByDefault),typeof e.fontSize=="number"&&Number.isFinite(e.fontSize)&&e.fontSize!==t.fontSize&&t.setFontSize(e.fontSize),Array.isArray(e.draftStarters)){const n=Ma(e.draftStarters);JSON.stringify(t.globalDraftStarters)!==JSON.stringify(n)&&t.setGlobalDraftStarters(n),e.draftStarters=n}if(delete e.draftStartersScheduleTaskAdded,typeof e.draftStartersVisible=="boolean"&&e.draftStartersVisible!==t.draftStartersVisible&&t.setDraftStartersVisible(e.draftStartersVisible),Pa(e.draftWallpaper)&&e.draftWallpaper!==t.draftWallpaper&&t.setDraftWallpaper(e.draftWallpaper),typeof e.draftWallpaperMotion=="boolean"&&e.draftWallpaperMotion!==t.draftWallpaperMotion&&t.setDraftWallpaperMotion(e.draftWallpaperMotion),typeof e.draftWallpaperPicture=="boolean"&&e.draftWallpaperPicture!==t.draftWallpaperPicture&&t.setDraftWallpaperPicture(e.draftWallpaperPicture),typeof e.draftWallpaperInSessions=="boolean"&&e.draftWallpaperInSessions!==t.draftWallpaperInSessions&&t.setDraftWallpaperInSessions(e.draftWallpaperInSessions),(e.draftWallpaperImageVersion===null||sc(e.draftWallpaperImageVersion))&&e.draftWallpaperImageVersion!==t.draftWallpaperImageVersion&&t.setDraftWallpaperImageVersion(e.draftWallpaperImageVersion),typeof e.terminalFontSize=="number"&&Number.isFinite(e.terminalFontSize)&&e.terminalFontSize!==t.terminalFontSize&&t.setTerminalFontSize(e.terminalFontSize),Co(e.terminalShell)&&e.terminalShell!==t.terminalShell&&t.setTerminalShell(e.terminalShell),Array.isArray(e.terminalLoginShells)&&(e.terminalLoginShells.length!==t.terminalLoginShells.length||e.terminalLoginShells.some((n,a)=>n!==t.terminalLoginShells[a]))&&t.setTerminalLoginShells(e.terminalLoginShells),typeof e.editorFontSize=="number"&&Number.isFinite(e.editorFontSize)&&e.editorFontSize!==t.editorFontSize&&t.setEditorFontSize(e.editorFontSize),rc(e.uiFont)&&e.uiFont!==t.uiFont&&t.setUiFont(e.uiFont),oc(e.monoFont)&&e.monoFont!==t.monoFont&&t.setMonoFont(e.monoFont),typeof e.padding=="number"&&Number.isFinite(e.padding)&&e.padding!==t.padding&&t.setPadding(e.padding),typeof e.cornerRadius=="number"&&Number.isFinite(e.cornerRadius)&&e.cornerRadius!==t.cornerRadius&&t.setCornerRadius(e.cornerRadius),typeof e.inputBarOffset=="number"&&Number.isFinite(e.inputBarOffset)&&e.inputBarOffset!==t.inputBarOffset&&t.setInputBarOffset(e.inputBarOffset),e.shortcutOverrides&&!cF(e.shortcutOverrides,t.shortcutOverrides)&&ie.setState({shortcutOverrides:e.shortcutOverrides}),e.commandTriggers&&!dF(e.commandTriggers,t.commandTriggers)&&ie.setState({commandTriggers:e.commandTriggers}),typeof e.mobileKeyboardMode=="string"){const n=Ta(e.mobileKeyboardMode,t.mobileKeyboardMode);n!==t.mobileKeyboardMode&&t.setMobileKeyboardMode(n)}if(Array.isArray(e.favoriteModels)){const n=t.favoriteModels,a=e.favoriteModels;fn(n,a)||ie.setState({favoriteModels:a})}if(Array.isArray(e.hiddenModels)){const n=t.hiddenModels,a=e.hiddenModels;fn(n,a)||ie.setState({hiddenModels:a})}if(Array.isArray(e.collapsedModelProviders)){const n=t.collapsedModelProviders,a=e.collapsedModelProviders;xn(n,a)||ie.setState({collapsedModelProviders:a})}if(Array.isArray(e.recentModels)){const n=t.recentModels,a=e.recentModels;fn(n,a)||ie.setState({recentModels:a})}if(Array.isArray(e.recentAgents)){const n=t.recentAgents,a=e.recentAgents;xn(n,a)||ie.setState({recentAgents:a})}if(e.recentEfforts&&typeof e.recentEfforts=="object"){const n=t.recentEfforts,a=e.recentEfforts;lF(n,a)||ie.setState({recentEfforts:a})}typeof e.diffLayoutPreference=="string"&&(e.diffLayoutPreference==="dynamic"||e.diffLayoutPreference==="inline"||e.diffLayoutPreference==="side-by-side")&&e.diffLayoutPreference!==t.diffLayoutPreference&&t.setDiffLayoutPreference(e.diffLayoutPreference),typeof e.gitChangesViewMode=="string"&&(e.gitChangesViewMode==="flat"||e.gitChangesViewMode==="tree")&&e.gitChangesViewMode!==t.gitChangesViewMode&&t.setGitChangesViewMode(e.gitChangesViewMode),typeof e.filesViewShowGitignored=="boolean"&&fF(e.filesViewShowGitignored,{persist:!1})},mF=()=>{const e=ie.persist;if(e&&typeof e=="object")return e},vc=()=>ya()?.settings??null;let Ha=0,he=null,nt=null,He=null,Re=null,qt=null,Te=null,Un=[],zs=!1;const gF=3e4,pF=200,hF=5e3;let Hn=0,Kn=0,jn=0,it=null,fo=[],Ho=!1;const FF=3e3;let $n=!1;const ro=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),zn=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((r,o)=>zn(r,t[o]));if(ro(e)||ro(t)){if(!ro(e)||!ro(t))return!1;const r=Object.entries(e).filter(([,n])=>n!==void 0),o=Object.entries(t).filter(([,n])=>n!==void 0);return r.length===o.length&&r.every(([n,a])=>{if(!Object.prototype.hasOwnProperty.call(t,n))return!1;const s=t[n];return s!==void 0&&zn(a,s)})}return!1},kc=e=>JSON.parse(JSON.stringify(e)),yF=e=>{const t={...it??{}};for(const[r,o]of Object.entries(e))if(o===void 0)delete t[r];else{const n=JSON.stringify(o);t[r]=n===void 0?o:JSON.parse(n)}it=t},bF=(e,t)=>{if(!it||fo.some(o=>Object.prototype.hasOwnProperty.call(o,e)))return!1;const r=it;return Object.prototype.hasOwnProperty.call(r,e)?zn(t,r[e]):t===void 0},AF=e=>{const t={};for(const[r,o]of Object.entries(e))bF(r,o)||(t[r]=o);return t},tr=()=>({runtimeKey:D(),generation:Ha}),Xt=(e,t)=>e.runtimeKey===t.runtimeKey&&e.generation===t.generation,Q=e=>e.generation===Ha&&e.runtimeKey===D(),Ka=()=>{zs||typeof window>"u"||(zs=!0,Al(e=>{e.runtimeKey!==e.previousRuntimeKey&&(Te&&clearTimeout(Te),Re&&vr({skipInitialLoadGate:!0}))}),Li(e=>{e.runtimeKey!==e.previousRuntimeKey&&(Ha+=1,he=null,nt=null,He=null,it=null,Ho=!1)}))},Dc=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null,ja=async(e=tr())=>{if(Ka(),he&&Xt(he.context,e)&&Date.now()-he.at<gF)return he.value;if(He&&Xt(He.context,e))return He.promise;$n=!0;const t=jn,r=(n,a)=>{Ho=!0,t===jn&&(he={value:n,at:Date.now(),context:e},nt={value:Dc(a),context:e},n&&(it=kc(n)))},o={context:e,promise:(async()=>{const n=vc();if(n)try{const a=await n.load();if(!Q(e))return null;const s=On(a.settings);return r(s,a.settings),s}catch(a){if(!Q(e)||Cc(a))return null;console.warn("Failed to load shared settings from runtime settings API:",a)}if(!Q(e))return null;try{const a=await b("/api/pi/ui-settings",{method:"GET",headers:{Accept:"application/json"}});if(!Q(e)||!a.ok)return null;const s=await a.json().catch(()=>null);if(!Q(e))return null;const i=On(s);return r(i,s),i}catch(a){return Q(e)&&console.warn("Failed to load shared settings from server:",a),null}})()};return He=o,$n=!1,o.promise.finally(()=>{He===o&&(He=null)}),o.promise},LA=async()=>{const e=tr();return await ja(e)&&nt&&Xt(nt.context,e)?nt.value:null},EF=e=>{const t=e.draftStartersScheduleTaskAdded!==!0,r=Array.isArray(e.draftStarters)&&e.draftStarters.some(o=>{if(!o||typeof o!="object")return!1;const n=o.type;return n!=="prompt"&&n!=="text"});return!t&&!r?{}:{...Array.isArray(e.draftStarters)?{draftStarters:Ma(e.draftStarters)}:{},draftStartersScheduleTaskAdded:!0}},Sc=async e=>{if(typeof window>"u")return;Ka();const t=tr(),r=Hn,o=()=>e==="refresh"&&(r!==Hn||Re!==null),n=mF(),a=()=>!n?.hasHydrated||n.hasHydrated()||!n.onFinishHydration?Promise.resolve():new Promise(i=>{let c=!1;const d=()=>{c||(c=!0,i())},l=n.onFinishHydration(()=>{l?.(),d()});n.hasHydrated?.()&&d()}),s=async i=>{if(!Q(t)||o())return;const c=typeof i.autoSaveEnabled!="boolean",d=t.runtimeKey==="local"&&typeof i.autoDeleteEnabled!="boolean",l=t.runtimeKey==="local"&&typeof i.autoDeleteAfterDays!="number",u=t.runtimeKey==="local"&&i.sessionRetentionAction!=="archive"&&i.sessionRetentionAction!=="delete",f=iF(i);if(e==="refresh")delete f.activeProjectId;else try{gm(i)}catch(h){console.warn("persistToLocalStorage failed:",h)}if(await a(),!Q(t)||o())return;const m=ie.getState();c&&(f.autoSaveEnabled=m.autoSaveEnabled),d&&(f.autoDeleteEnabled=m.autoDeleteEnabled),l&&(f.autoDeleteAfterDays=m.autoDeleteAfterDays),u&&(f.sessionRetentionAction=m.sessionRetentionAction),i.draftStarters===void 0&&ie.setState({globalDraftStarters:null});try{Ln(f)}catch(h){console.warn("applyDesktopUiPreferences failed:",h)}const g=EF(i);c&&(g.autoSaveEnabled=f.autoSaveEnabled),d&&(g.autoDeleteEnabled=f.autoDeleteEnabled),l&&(g.autoDeleteAfterDays=f.autoDeleteAfterDays),u&&(g.sessionRetentionAction=f.sessionRetentionAction),!(Object.keys(g).length>0&&(await Ke(g),!Q(t)))&&Rn(f)};try{const i=await ja(t);i&&Q(t)&&await s(i)}catch(i){console.warn("Failed to synchronise settings:",i)}},UA=()=>Sc("load"),HA=async()=>{if(typeof window>"u"||Re!==null||Kn>0)return;const e=tr();he&&Xt(he.context,e)&&Date.now()-he.at<hF||(he=null,nt=null,await Sc("refresh"))},wF=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),mn=(e,t,r)=>{if(jn+=1,wF(e)){it=kc(e),he={value:On(e),at:Date.now(),context:r},nt={value:Dc(e),context:r},Ho=!0;return}yF(t),he=null,nt=null},BF=async e=>{const t=new Promise(r=>{setTimeout(()=>r(null),FF)});await Promise.race([ja(e).then(()=>{}),t])};async function vr(e={}){Kn+=1;try{await CF(e)}finally{Kn-=1}}async function CF(e){if(!e.skipInitialLoadGate&&Re&&Object.keys(Re).length>0&&!it&&!$n){const a=qt??tr(),s=!!He&&Xt(He.context,a);Q(a)&&(s||!Ho)&&await BF(a)}const t=Re,r=qt,o=Un;Re=null,qt=null,Te=null,Un=[];let n=null;try{if(!t||!r||Object.keys(t).length===0||!Q(r)){ye("saved");return}const a=AF(t);if(Object.keys(a).length===0){ye("saved");return}n=a,fo.push(a);const s=vc();if(s)try{const i=await s.save(a);if(!Q(r))return;i&&(mn(i,a,r),Ln(i),Rn(i)),ye(i?"saved":"error");return}catch(i){if(!Q(r))return;if(Cc(i)){ye("error");return}console.warn("Failed to update settings via runtime settings API:",i)}if(!Q(r))return;try{const i=await b("/api/pi/ui-settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(a)});if(!Q(r))return;if(!i.ok){console.warn("Failed to update shared settings via API:",i.status,i.statusText),ye("error");return}const c=await i.json().catch(()=>null);if(!Q(r))return;c?(mn(c,a,r),Ln(c),Rn(c),ye("saved")):(mn(c,a,r),ye("error"))}catch(i){Q(r)&&(console.warn("Failed to update shared settings via API:",i),ye("error"))}}finally{n&&(fo=fo.filter(a=>a!==n)),o.forEach(a=>a())}}const Ke=async(e,t={})=>{if(typeof window>"u")return;Ka();const r=tr();qt&&!Xt(qt,r)&&(Te&&clearTimeout(Te),vr({skipInitialLoadGate:!0})),Hn+=1,Re={...Re??{},...e},qt=r,ye("saving"),Te&&clearTimeout(Te);const o=new Promise(n=>{Un.push(n)});return t.immediate?vr({skipInitialLoadGate:!0}):Te=setTimeout(()=>{vr()},pF),o},KA=()=>{Re!==null&&(Te&&clearTimeout(Te),vr({skipInitialLoadGate:!0}))},vF=3e4,kF=40,DF=60,SF=(e,t,r,o,n,a,s)=>{const i=t.trim(),c=r.trim().toLowerCase();return JSON.stringify([e,i,c,o,n,a,s])},qs=(e,t)=>{try{const r=JSON.parse(e);return Array.isArray(r)&&r[1]===t}catch{return!1}},MF=xr()(Or((e,t)=>({cache:{},cacheKeys:[],inFlight:{},async searchFiles(r,o,n=DF,a){if(!r||r.trim().length===0)return[];const s=r.trim(),i=D(),c=typeof o=="string"?o.trim():"",d=!!a?.includeHidden,l=a?.respectGitignore??!0,u=a?.type==="directory"?"directory":"file",f=SF(i,s,c,n,d,l,u),m=Date.now(),g=t().cache[f];if(g&&m-g.timestamp<vF)return g.files;const h=t().inFlight[f];if(h)return h;const p=sf(c,{directory:s,limit:n,includeHidden:d,respectGitignore:l,type:u}).then(k=>(e(A=>{if(A.inFlight[f]!==p)return A;const C={...A.cache,[f]:{files:k,timestamp:Date.now()}},w=A.cacheKeys.filter(B=>B!==f);for(w.push(f);w.length>kF;){const B=w.shift();B&&delete C[B]}return{cache:C,cacheKeys:w}}),k)).finally(()=>{e(k=>{if(k.inFlight[f]!==p)return k;const A={...k.inFlight};return delete A[f],{inFlight:A}})});return e(k=>({inFlight:{...k.inFlight,[f]:p}})),p},invalidateDirectory(r){if(!r||r.trim().length===0){e({cache:{},cacheKeys:[],inFlight:{}});return}const o=r.trim();e(n=>{const a={...n.cache},s=n.cacheKeys.filter(d=>qs(d,o)?(delete a[d],!1):!0),i=Object.entries(n.inFlight).filter(([d])=>!qs(d,o)),c=Object.fromEntries(i);return{cache:a,cacheKeys:s,inFlight:c}})},resetForRuntimeSwitch(){e({cache:{},cacheKeys:[],inFlight:{}})}}),{name:"file-search-store"})),qn="pichamber_perf_hud",Wn=new Set,TF=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(qn)==="1"}catch{return!1}};let Gn=TF(),Ws=!1;const PF=()=>{for(const e of Wn)e()},Mc=()=>Gn,jA=e=>(Wn.add(e),()=>{Wn.delete(e)}),Gs=e=>{const t=Gn!==e;if(Gn=e,typeof window<"u")try{e?window.localStorage.setItem(qn,"1"):window.localStorage.removeItem(qn)}catch{}t&&PF()},RF=e=>{if(typeof window>"u"&&e===void 0)return!1;const r=new URLSearchParams(window.location.search).get("perf");return r==="1"?(Gs(!0),!0):r==="0"?(Gs(!1),!0):!1},$A=e=>Ws?!1:(Ws=!0,RF(e)),IF=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem("pichamber_stream_debug")==="1"}catch{return!1}},Vn="pichamber_stream_perf",_F=()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Vn)==="1"}catch{return!1}};let Tc=_F();const Ko=()=>Tc||Mc(),Vs=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now(),Pc=()=>{if(!Ko()||typeof window>"u")return null;if(!window.__pichamberStreamPerfState){const e=Date.now();window.__pichamberStreamPerfState={counters:new Map,startedAt:e,lastUpdatedAt:e}}return window.__pichamberStreamPerfState},xF=e=>Array.from(e.entries()).map(([t,r])=>({metric:t,count:r.count,avg:r.count>0?Number((r.total/r.count).toFixed(3)):0,max:Number(r.max.toFixed(3)),total:Number(r.total.toFixed(3)),last:Number(r.last.toFixed(3))})).sort((t,r)=>r.total-t.total||r.count-t.count),$a=(e,t)=>{const r=Pc();if(!r)return;const o=r.counters.get(e)??{count:0,total:0,max:0,last:0};o.count+=1,o.total+=t,o.max=Math.max(o.max,t),o.last=t,r.counters.set(e,o),r.lastUpdatedAt=Date.now()},OF=e=>{if(Tc=e,!(typeof window>"u"))try{if(e){window.localStorage.setItem(Vn,"1"),window.__pichamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()};return}window.localStorage.removeItem(Vn),Mc()||delete window.__pichamberStreamPerfState}catch{}},NF=()=>{typeof window>"u"||Ko()&&(window.__pichamberStreamPerfState={counters:new Map,startedAt:Date.now(),lastUpdatedAt:Date.now()})},LF=()=>{if(typeof window>"u")return{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]};const e=Pc();return e?{enabled:!0,startedAt:e.startedAt,lastUpdatedAt:e.lastUpdatedAt,durationMs:Math.max(0,Date.now()-e.startedAt),entries:xF(e.counters)}:{enabled:!1,startedAt:null,lastUpdatedAt:null,durationMs:0,entries:[]}},zA=(e,t=1)=>{$a(e,t)},qA=(e,t)=>{$a(e,t)},WA=e=>{!Ko()||typeof performance>"u"||typeof performance.mark!="function"||performance.mark(`pichamber.${e}`)},GA=(e,t)=>{if(!Ko())return t();const r=Vs();try{return t()}finally{$a(e,Vs()-r)}};typeof window<"u"&&(window.__pichamberStreamPerformance={setEnabled:OF,reset:NF,getSnapshot:LF});var UF={};let ge=null,Et=0;const fe=Kr(),Js=fe.getItem("lastDirectory"),HF=typeof Js=="string"&&Js.length>0,hr=e=>{try{MF.getState().invalidateDirectory(e)}catch(t){console.warn("Failed to invalidate file search cache:",t)}},Ir=e=>{const t=e.trim();if(!t)return t;const r=t.replace(/\\/g,"/").replace(/^([a-z]):/,(o,n)=>n.toUpperCase()+":");return r.length>1?r.replace(/\/+$/,""):r},KF=(e,t)=>{const r=e.trim();return r.startsWith("~")?r==="~"?t||r:(r.startsWith("~/")||r.startsWith("~\\"))&&t?`${t}${r.slice(1)}`:r:r},mo=(e,t)=>{const r=KF(e,t);return Ir(r)},jF=()=>{const e=fe.getItem("homeDirectory");if(typeof e!="string"||e.trim().length===0)return null;const t=Ir(e);return t.length>0?t:null},$F=()=>{const e=fe.getItem("lastDirectory");if(typeof e!="string"||e.trim().length===0)return null;const t=Ir(e);return t.length>0?t:null},zF=()=>{if(typeof process>"u")return null;const e=UF,t=e?.HOME||e?.USERPROFILE||(e?.HOMEDRIVE&&e?.HOMEPATH?`${e.HOMEDRIVE}${e.HOMEPATH}`:void 0);if(typeof t=="string"&&t.trim().length>0){const o=Ir(t);return o.length>0?o:null}const r=process?.cwd?.();if(typeof r=="string"&&r.trim().length>0){const o=Ir(r);return o.length>0?o:null}return null},ko=()=>{if(typeof window<"u"){if(ge)return ge;const t=ce()&&typeof window.__PICHAMBER_HOME__=="string"&&window.__PICHAMBER_HOME__.length>0?window.__PICHAMBER_HOME__:null;if(t&&t.length>0)return ge=t,fe.setItem("homeDirectory",t),t;const r=ce()?jF():null;if(r)return ge=r,r}const e=!we()||ce()?zF():null;return e||"/"},qF=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const r=t.replace(/\\/g,"/");if(r.length>1){const o=r.replace(/\/+$/,"");if(o&&o.length>0)return o==="/"?null:o}return r==="/"||r.length===0?null:r},WF=e=>(ge=e,typeof window<"u"&&fe.setItem("homeDirectory",e),Ke({homeDirectory:e}),e),Jn=async(e=Et)=>{const t=n=>{if(e!==Et)return null;const a=qF(n);return a?WF(a):null};try{const n=await of(),a=t(n);if(a)return a}catch(n){console.warn("Failed to obtain filesystem home directory:",n)}if(ce())try{const n=await vl(),a=t(n);if(a)return a}catch(n){console.warn("Failed to obtain desktop-integrated home directory:",n)}const r=ko(),o=t(r);return o||r},_r=ko(),Do=(()=>{const e=$F();return e?mo(e,_r):_r})();Do&&At.setDirectory(Do);const GF=!!(_r&&_r!=="/"),Yn=xr()(Or((e,t)=>({currentDirectory:Do,directoryHistory:[Do],historyIndex:0,homeDirectory:_r,hasPersistedDirectory:HF,isHomeReady:GF,isSwitchingDirectory:!1,setDirectory:(r,o)=>{const n=ge||t().homeDirectory||fe.getItem("homeDirectory"),a=mo(r,n);IF()&&console.log("[DirectoryStore] setDirectory called with path:",a),At.setDirectory(a),hr(),e(s=>{const i=[...s.directoryHistory.slice(0,s.historyIndex+1),a];return fe.setItem("lastDirectory",a),Ke({lastDirectory:a}),{currentDirectory:a,directoryHistory:i,historyIndex:i.length-1,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1}})},goBack:()=>{const r=t();if(r.historyIndex>0){const o=r.historyIndex-1,n=r.directoryHistory[o];At.setDirectory(n),hr(),fe.setItem("lastDirectory",n),Ke({lastDirectory:n}),e({currentDirectory:n,historyIndex:o,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goForward:()=>{const r=t();if(r.historyIndex<r.directoryHistory.length-1){const o=r.historyIndex+1,n=r.directoryHistory[o];At.setDirectory(n),hr(),fe.setItem("lastDirectory",n),Ke({lastDirectory:n}),e({currentDirectory:n,historyIndex:o,hasPersistedDirectory:!0,isHomeReady:!0,isSwitchingDirectory:!1})}},goToParent:()=>{const{currentDirectory:r,setDirectory:o}=t(),n=ge||t().homeDirectory||ko();if(r===n||r==="/")return;const a=r.endsWith("/")?r.slice(0,-1):r,s=a.lastIndexOf("/");if(s===-1){const i=ge||ko();o(i)}else o(s===0?"/":a.substring(0,s))},goHome:async()=>{const r=ge||t().homeDirectory||await Jn();t().setDirectory(r)},resetForRuntimeSwitch:()=>{ge=null,Et+=1,fe.removeItem("lastDirectory"),fe.removeItem("homeDirectory"),hr(),At.setDirectory(""),e({currentDirectory:"",directoryHistory:[],historyIndex:-1,homeDirectory:"",hasPersistedDirectory:!1,isHomeReady:!1,isSwitchingDirectory:!1})},synchronizeHomeDirectory:r=>{const o=t(),n=r;ge=n;const a=o.homeDirectory!==n,s=fe.getItem("lastDirectory"),i=typeof s=="string"&&s.length>0,c=!i&&(o.currentDirectory==="/"||o.currentDirectory===o.homeDirectory||!o.currentDirectory);if(!a&&!c){o.isHomeReady||e({isHomeReady:!0});return}const d=typeof n=="string"&&n!==""&&n!=="/",l=o.currentDirectory?mo(o.currentDirectory,n):o.currentDirectory,u=o.directoryHistory.map(h=>mo(h,n)),f=u.some((h,p)=>h!==o.directoryHistory[p]),m=!!(l&&l!==o.currentDirectory),g={homeDirectory:n,hasPersistedDirectory:i,isHomeReady:d};if(c?(g.currentDirectory=n,g.directoryHistory=[n],g.historyIndex=0,g.isSwitchingDirectory=!1):(m||f)&&(g.currentDirectory=l,g.directoryHistory=u,g.historyIndex=Math.min(o.historyIndex,u.length-1),g.isSwitchingDirectory=!1),e(()=>g),(c||m)&&d){const h=c?n:l;At.setDirectory(h),hr(),fe.setItem("lastDirectory",h),Ke({lastDirectory:h})}Ke({homeDirectory:n})}}),{name:"directory-store"}));if(typeof window<"u"){const e=Et;Jn(e).then(t=>{e===Et&&Yn.getState().synchronizeHomeDirectory(t)}),Li(()=>{ge=null;const t=++Et;Jn().then(r=>{t===Et&&Yn.getState().synchronizeHomeDirectory(r)})})}const Rc=1,Ys=512*1024,VF=0,Je=1,JF=45e3,YF=1e4,XF=15e3,za=new TextEncoder,Ic=new TextDecoder,oo=()=>typeof document<"u"&&document.visibilityState==="hidden"||typeof navigator<"u"&&!navigator.onLine,QF=e=>{const t=za.encode(JSON.stringify(e)),r=new Uint8Array(t.length+1);return r[0]=Rc,r.set(t,1),r},ZF=async e=>{let t;if(e instanceof ArrayBuffer)t=new Uint8Array(e);else if(e instanceof Uint8Array)t=e;else if(typeof Blob<"u"&&e instanceof Blob)t=new Uint8Array(await e.arrayBuffer());else if(typeof e=="string")t=za.encode(e);else return null;t[0]===Rc&&(t=t.subarray(1));try{return JSON.parse(Ic.decode(t))}catch{return null}},qa=async(e,t)=>{const r=await e.json().catch(()=>null);return new Error(typeof r?.error=="string"?r.error:t)},e0=e=>{const t=za.encode(e);if(t.byteLength<=Ys)return e;let r=t.byteLength-Ys;for(;r<t.byteLength&&(t[r]&192)===128;)r+=1;return Ic.decode(t.subarray(r))};class _c{constructor(t={refreshAuth:Hr,openSocket:r=>Ji(Ie().websocket("/api/terminal/ws",void 0,r)),clearUrlAuthToken:Ur}){this.dependencies=t,this.installPersistentListeners()}dependencies;socket=null;opening=null;subscribers=new Map;projections=new Map;reconnectTimer=null;keepaliveTimer=null;pongDeadlineTimer=null;idleCloseTimer=null;failures=0;persistentListenersInstalled=!1;generation=0;disposed=!1;subscribe(t,r){this.cancelIdleClose();const o={handlers:r,lastSequence:-1},n=this.subscribers.get(t)??new Set,a=n.size===0;n.add(o),this.subscribers.set(t,n);const s=this.projections.get(t);s&&(o.lastSequence=s.sequence,r.onEvent({type:"snapshot",sequence:s.sequence,data:s.history,status:s.status,exitCode:s.exitCode,signal:s.signal,runtime:s.runtime,ptyBackend:s.ptyBackend}));const i=this.socket?.readyState===Je;return this.ensureConnected().then(()=>{const c=this.subscribers.get(t);a&&i&&c===n&&c.size>0&&this.send({t:"attach",v:3,s:t})}).catch(c=>{n.has(o)&&(r.onError?.(c,!1),this.scheduleReconnect())}),()=>{const c=this.subscribers.get(t);if(c?.delete(o),c?.size===0&&(this.subscribers.delete(t),this.projections.delete(t),this.send({t:"detach",v:3,s:t})),this.subscribers.size===0){if(this.cancelReconnect(),this.failures=0,this.socket?.readyState===Je){this.scheduleIdleClose();return}this.generation+=1,this.opening=null,this.closeSocket()}}}async write(t,r){if(!r)return;const o=this.generation,n=()=>this.disposed||o!==this.generation;if(await this.ensureConnected(),n())throw new Error("Terminal runtime changed");if(!this.send({t:"write",v:3,s:t,d:r})){if(this.closeSocket(),await this.ensureConnected(),n())throw new Error("Terminal runtime changed");if(!this.send({t:"write",v:3,s:t,d:r}))throw new Error("Terminal connection is unavailable")}}dispose(){this.disposed=!0,this.generation+=1,this.opening=null,this.subscribers.clear(),this.projections.clear(),this.cancelReconnect(),this.cancelIdleClose(),this.removePersistentListeners(),this.closeSocket()}forget(t){this.projections.delete(t)}installPersistentListeners(){this.persistentListenersInstalled||(this.persistentListenersInstalled=!0,typeof window<"u"&&(window.addEventListener("pichamber:system-resume",this.handleWakeSignal),window.addEventListener("online",this.handleWakeSignal)),typeof document<"u"&&document.addEventListener("visibilitychange",this.handleWakeSignal))}removePersistentListeners(){this.persistentListenersInstalled&&(this.persistentListenersInstalled=!1,typeof window<"u"&&(window.removeEventListener("pichamber:system-resume",this.handleWakeSignal),window.removeEventListener("online",this.handleWakeSignal)),typeof document<"u"&&document.removeEventListener("visibilitychange",this.handleWakeSignal))}handleWakeSignal=()=>{if(!(this.disposed||oo())){if(this.reconnectTimer!==null){this.wakeReconnect();return}this.socket?.readyState===Je&&this.sendPing()}};async ensureConnected(){if(this.disposed)throw new Error("Terminal runtime changed");if(this.socket?.readyState===Je)return;if(this.opening)return await this.opening,this.socket?.readyState===Je?void 0:this.ensureConnected();const t=this.generation,r=(async()=>{const o=await this.dependencies.refreshAuth();if(t!==this.generation||this.disposed)throw new Error("Terminal runtime changed");await new Promise((n,a)=>{let s=!1,i=!1,c=!1,d=null;const l=()=>t===this.generation&&!this.disposed&&d!==null&&this.socket===d,u=()=>{c||i||!l()||(c=!0,this.dependencies.clearUrlAuthToken?.(o))},f=g=>{s||(s=!0,clearTimeout(m),g?a(g):n())},m=setTimeout(()=>{u(),d?.close(),f(new Error("Terminal connection timed out"))},1e4);try{const g=this.dependencies.openSocket(o);d=g,g.binaryType="arraybuffer",this.socket=g,g.onopen=()=>{if(!l()){g.close(),f(new Error("Terminal runtime changed"));return}i=!0,this.failures=0,this.send({t:"hello",v:3});for(const h of this.subscribers.keys())this.send({t:"attach",v:3,s:h});this.startKeepalive(),f()},g.onmessage=h=>{this.handleMessage(h.data)},g.onerror=()=>{const h=l();h&&u(),f(new Error("Terminal WebSocket failed")),h&&this.subscribers.size>0&&this.scheduleReconnect()},g.onclose=()=>{const h=l();h&&(this.stopKeepalive(),u()),this.socket===g&&(this.socket=null),f(new Error("Terminal WebSocket closed")),h&&this.subscribers.size>0&&this.scheduleReconnect()}}catch(g){f(g instanceof Error?g:new Error("Terminal WebSocket failed")),!this.disposed&&this.subscribers.size>0&&this.scheduleReconnect()}})})();this.opening=r;try{await r}finally{this.opening===r&&(this.opening=null)}}async handleMessage(t){this.clearPongDeadline();const r=await ZF(t);if(!r||r.t==="hello"||r.t==="pong")return;if(r.t==="error"){const a=new Error(typeof r.message=="string"?r.message:"Terminal error");typeof r.code=="string"&&(a.code=r.code);const s=r.s?[r.s]:[...this.subscribers.keys()];for(const i of s)for(const c of this.subscribers.get(i)??[])c.handlers.onError?.(a,r.fatal===!0);return}if(!r.s)return;const o=this.subscribers.get(r.s);if(!o)return;if(r.t==="snapshot"){const a={sequence:typeof r.q=="number"?r.q:0,history:typeof r.history=="string"?r.history:"",status:r.status,exitCode:typeof r.exitCode=="number"?r.exitCode:void 0,signal:typeof r.signal=="number"?r.signal:null,runtime:r.runtime,ptyBackend:typeof r.ptyBackend=="string"?r.ptyBackend:void 0};this.projections.set(r.s,a);for(const s of o)s.lastSequence=a.sequence,s.handlers.onEvent({type:"snapshot",sequence:a.sequence,data:a.history,status:a.status,exitCode:a.exitCode,signal:a.signal,runtime:a.runtime,ptyBackend:a.ptyBackend});return}if(typeof r.q!="number")return;const n=this.projections.get(r.s);n&&r.q>n.sequence&&(r.t==="output"?this.projections.set(r.s,{...n,sequence:r.q,history:e0(n.history+(typeof r.r=="string"?r.r:typeof r.d=="string"?r.d:""))}):r.t==="exit"?this.projections.set(r.s,{...n,sequence:r.q,status:"exited",exitCode:typeof r.exitCode=="number"?r.exitCode:void 0,signal:typeof r.signal=="number"?r.signal:null}):r.t==="restarted"&&this.projections.set(r.s,{...n,sequence:r.q,history:typeof r.history=="string"?r.history:"",status:"running",exitCode:void 0,signal:null}));for(const a of o)r.q<=a.lastSequence||(a.lastSequence=r.q,r.t==="output"?a.handlers.onEvent({type:"data",sequence:r.q,data:typeof r.d=="string"?r.d:"",replayData:typeof r.r=="string"?r.r:void 0}):r.t==="exit"?a.handlers.onEvent({type:"exit",sequence:r.q,exitCode:typeof r.exitCode=="number"?r.exitCode:void 0,signal:typeof r.signal=="number"?r.signal:null}):r.t==="restarted"&&a.handlers.onEvent({type:"snapshot",sequence:r.q,data:typeof r.history=="string"?r.history:"",status:"running"}))}send(t){if(!this.socket||this.socket.readyState!==Je)return!1;try{return this.socket.send(QF(t)),!0}catch{return!1}}sendPing(){this.disposed||!this.socket||this.socket.readyState!==Je||oo()||this.pongDeadlineTimer===null&&this.send({t:"ping",v:3})&&this.armPongDeadline()}armPongDeadline(){this.clearPongDeadline(),this.pongDeadlineTimer=setTimeout(()=>{this.handlePongTimeout()},YF)}clearPongDeadline(){this.pongDeadlineTimer&&(clearTimeout(this.pongDeadlineTimer),this.pongDeadlineTimer=null)}handlePongTimeout(){this.clearPongDeadline();const t=this.socket;if(!t)return;const r=t.onclose;t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}r?.({code:4e3,reason:"terminal keepalive timeout"})}wakeReconnect(){this.disposed||oo()||(this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ensureConnected().catch(()=>this.scheduleReconnect()))}scheduleReconnect(){if(this.reconnectTimer||this.disposed||this.subscribers.size===0)return;this.failures+=1;const t=oo()?6e4:Math.min(500*2**Math.min(this.failures-1,10),8e3);for(const r of this.subscribers.values())for(const o of r)o.handlers.onEvent({type:"reconnecting",attempt:this.failures,maxAttempts:Number.POSITIVE_INFINITY});this.reconnectTimer=setTimeout(()=>this.wakeReconnect(),t)}scheduleIdleClose(){this.idleCloseTimer||this.disposed||(this.idleCloseTimer=setTimeout(()=>{this.idleCloseTimer=null,!(this.disposed||this.subscribers.size>0)&&(this.generation+=1,this.opening=null,this.closeSocket())},XF))}cancelIdleClose(){this.idleCloseTimer&&(clearTimeout(this.idleCloseTimer),this.idleCloseTimer=null)}startKeepalive(){this.stopKeepalive(),this.keepaliveTimer=setInterval(()=>this.sendPing(),JF)}stopKeepalive(){this.keepaliveTimer&&(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.clearPongDeadline()}cancelReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null}closeSocket(){this.stopKeepalive();const t=this.socket;this.socket=null,t&&(t.readyState===VF||t.readyState===Je)&&t.close()}}let Dt=new _c,xc=0;const Xn=new Set,VA=()=>xc,JA=e=>(Xn.add(e),()=>{Xn.delete(e)}),t0=()=>{xc+=1;for(const e of[...Xn])try{e()}catch{}};async function r0(e){const t=await b("/api/terminal/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw await qa(t,"Failed to create terminal session");return t.json()}async function o0(){const e=await b("/api/terminal/shells");if(!e.ok)throw await qa(e,"Failed to list terminal shells");const t=await e.json().catch(()=>[]);return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"&&Co(r.id)&&typeof r.name=="string"&&typeof r.supportsLogin=="boolean"):[]}function n0(e,t,r){return Dt.subscribe(e,{onEvent:t,onError:r})}async function a0(e,t){await Dt.write(e,t)}async function $r(e,t,r){const o={method:t};r!==void 0&&(o.headers={"Content-Type":"application/json"},o.body=JSON.stringify(r));const n=await b(e,o);if(!n.ok)throw await qa(n,"Terminal command failed");return n}async function s0(e,t,r){await $r(`/api/terminal/${e}/resize`,"POST",{cols:t,rows:r})}async function i0(e,t){await $r(`/api/terminal/${e}/appearance`,"POST",t)}async function c0(e){await $r(`/api/terminal/${e}`,"DELETE"),Dt.forget(e)}async function d0(e,t){return(await $r(`/api/terminal/${e}/restart`,"POST",t)).json()}async function l0(e){const r=await(await $r("/api/terminal/force-kill","POST",e)).json().catch(()=>null);if(Array.isArray(r?.killedSessionIds))for(const o of r.killedSessionIds)typeof o=="string"&&Dt.forget(o);else e.sessionId&&Dt.forget(e.sessionId)}function YA(){Dt.dispose(),Dt=new _c,t0()}const u0=()=>({async listShells(){return o0()},async createSession(e){return r0(e)},connect(e,t){const r=n0(e,t.onEvent,t.onError);return{close:()=>r()}},async sendInput(e,t){await a0(e,t)},async resize(e){await s0(e.sessionId,e.cols,e.rows)},async updateAppearance(e,t){await i0(e,t)},async close(e){await c0(e)},async restartSession(e,t){return d0(e,{cwd:t.cwd??"",cols:t.cols,rows:t.rows,themeMode:t.themeMode,terminalBackground:t.terminalBackground,terminalForeground:t.terminalForeground,shell:t.shell,loginShell:t.loginShell})},async forceKill(e){await l0(e)}}),S="/api/git",f0=1200,m0=5*6e4,g0=3e4,p0=1e4,So=new Map,Lt=new Map,Wa=new Map,Mo=new Map,Ut=new Map,Ga=new Map,To=new Map,Ht=new Map,Va=new Map,Oc=e=>e.trim(),rr=(e,t)=>JSON.stringify([e,Oc(t)]),Nc=(e,t,r)=>JSON.stringify([e,Oc(t),r??"full"]),Qn=(e,t)=>Wa.get(rr(e,t))??0,Ee=e=>{const t=D(),r=rr(t,e);Wa.set(r,Qn(t,e)+1);for(const o of[void 0,"light"]){const n=Nc(t,e,o);So.delete(n),Lt.delete(n)}},Zn=e=>Ga.get(e)??0,ea=e=>Va.get(e)??0,ta=e=>{const t=rr(D(),e);Ga.set(t,Zn(t)+1),Mo.delete(t),Ut.delete(t)},ra=e=>{const t=rr(D(),e);Va.set(t,ea(t)+1),To.delete(t),Ht.delete(t)},XA=()=>{So.clear(),Lt.clear(),Wa.clear(),Mo.clear(),Ut.clear(),Ga.clear(),To.clear(),Ht.clear(),Va.clear()};function M(e,t,r){const o={...r};return t&&(o.directory=t),Ie().api(e,o)}async function h0(e){const t=rr(D(),e),r=Date.now(),o=Mo.get(t);if(o&&o.expiresAt>r)return o.value;const n=Ut.get(t);if(n)return n;const a=(async()=>{const s=Zn(t),i=await b(M(`${S}/check`,e));if(!i.ok)throw new Error(`Failed to check git repository: ${i.statusText}`);const d=!!(await i.json()).isGitRepository;return Zn(t)===s&&Mo.set(t,{value:d,expiresAt:Date.now()+(d?m0:g0)}),d})();Ut.set(t,a);try{return await a}finally{Ut.get(t)===a&&Ut.delete(t)}}async function F0(e,t){const r=t?.mode,o=D(),n=Nc(o,e,r),a=Date.now(),s=So.get(n);if(s&&s.expiresAt>a)return s.value;const i=Lt.get(n);if(i)return i;const c=(async()=>{const d=Qn(o,e),l=await b(M(`${S}/status`,e,r?{mode:r}:void 0));if(!l.ok)throw new Error(`Failed to get git status: ${l.statusText}`);const u=await l.json();return Qn(o,e)===d&&So.set(n,{value:u,expiresAt:Date.now()+f0}),u})();Lt.set(n,c);try{return await c}finally{Lt.get(n)===c&&Lt.delete(n)}}const zr=async(e,t)=>{const r=await e.json().catch(()=>null);return new Error(typeof r?.error=="string"&&r.error?r.error:t)};async function y0(e){const t=rr(D(),e),r=Date.now(),o=To.get(t);if(o&&o.expiresAt>r)return o.value;const n=Ht.get(t);if(n)return n;const a=(async()=>{const s=ea(t),i=await b(M(`${S}/worktrees`,e));if(!i.ok)throw await zr(i,"Failed to list git worktrees");const c=await i.json();if(!Array.isArray(c.worktrees))throw new Error("Git worktree response is invalid");return ea(t)===s&&To.set(t,{value:c.worktrees,expiresAt:Date.now()+p0}),c.worktrees})();Ht.set(t,a);try{return await a}finally{Ht.get(t)===a&&Ht.delete(t)}}async function b0(e,t){const r=await b(M(`${S}/worktrees/validate`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw await zr(r,"Failed to validate git worktree");return r.json()}async function A0(e,t){const r=await b(M(`${S}/worktrees`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw await zr(r,"Failed to create git worktree");return Ee(e),ra(e),ta(e),r.json()}async function E0(e,t){const r=await b(M(`${S}/worktrees`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw await zr(r,"Failed to close git worktree");return Ee(e),Ee(t.directory),ra(e),ra(t.directory),ta(e),ta(t.directory),r.json()}async function w0(e){const t=await b(M(`${S}/worktrees/bootstrap-status`,e));if(!t.ok)throw await zr(t,"Failed to get git worktree bootstrap status");return t.json()}async function B0(e,t){const{path:r,staged:o,contextLines:n}=t;if(!r)throw new Error("path is required to fetch git diff");const a=t.source??(o?"staged":"unstaged"),s=await b(M(`${S}/diff`,e,{path:r,source:a,staged:a==="staged"?"true":void 0,context:n}));if(!s.ok)throw new Error(`Failed to get git diff: ${s.statusText}`);return s.json()}async function C0(e,t){const{base:r,head:o,path:n,contextLines:a}=t;if(!r||!o)throw new Error("base and head are required to fetch git range diff");const s=await b(M(`${S}/range-diff`,e,{base:r,head:o,path:n||void 0,context:a}));if(!s.ok)throw new Error(`Failed to get git range diff: ${s.statusText}`);return s.json()}async function v0(e,t){const{path:r,staged:o}=t;if(!r)throw new Error("path is required to fetch git file diff");const n=await b(M(`${S}/file-diff`,e,{path:r,staged:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get git file diff: ${n.statusText}`);return n.json()}async function k0(e,t,r){if(!t)throw new Error("path is required to revert git changes");const o=await b(M(`${S}/revert`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,scope:r?.scope})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to revert git changes")}Ee(e)}async function D0(e,t){await Lc(e,[t])}async function Lc(e,t){const r=t.map(n=>n.trim()).filter(Boolean);if(r.length===0)throw new Error("path is required to stage git changes");const o=await b(M(`${S}/stage`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to stage git changes")}Ee(e)}async function S0(e,t){await Uc(e,[t])}async function Uc(e,t){const r=t.map(n=>n.trim()).filter(Boolean);if(r.length===0)throw new Error("path is required to unstage git changes");const o=await b(M(`${S}/unstage`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to unstage git changes")}Ee(e)}async function M0(e,t,r){await Ja(e,t,r,"stage")}async function T0(e,t,r){await Ja(e,t,r,"unstage")}async function P0(e,t,r){await Ja(e,t,r,"discard")}async function Ja(e,t,r,o){if(!t)throw new Error("path is required to apply a git hunk");if(typeof r!="string"||!r.trim())throw new Error("patch is required to apply a git hunk");const n=await b(M(`${S}/apply-hunk`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,patch:r,action:o})});if(!n.ok){const a=await n.json().catch(()=>({error:n.statusText}));throw new Error(a.error||"Failed to apply git hunk")}Ee(e)}async function R0(e){const t=await b(M(`${S}/branches`,e));if(!t.ok)throw new Error(`Failed to get branches: ${t.statusText}`);return t.json()}async function I0(e,t){if(!t?.branch)throw new Error("branch is required to delete a branch");const r=await b(M(`${S}/branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete branch")}return r.json()}async function _0(e,t){if(!t?.branch)throw new Error("branch is required to delete remote branch");const r=await b(M(`${S}/remote-branches`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to delete remote branch")}return r.json()}async function x0(e,t){const r=t?.remote?.trim();if(!r)throw new Error("remote is required to remove a remote");const o=await b(M(`${S}/remotes`,e),{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({remote:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to remove remote")}return o.json()}async function O0(e,t,r={}){const o=await b(M(`${S}/commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t,addAll:r.addAll??!1,files:r.files,stageFiles:r.stageFiles})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to create commit")}const n=await o.json();return Ee(e),n}async function N0(e,t={}){const r=await b(M(`${S}/push`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to push")}const o=await r.json();return Ee(e),o}async function L0(e,t={}){const r=await b(M(`${S}/pull`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to pull")}const o=await r.json();return Ee(e),o}async function U0(e,t={}){const r=await b(M(`${S}/fetch`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to fetch")}const o=await r.json();return Ee(e),o}async function H0(e){const t=await b(M(`${S}/stashes`,e));if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to list stashes")}return t.json()}async function K0(e,t){const r=await b(M(`${S}/stashes/file-counts`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refs:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to count stash files")}return r.json()}async function Hc(e,t={}){const r=await b(M(`${S}/stash`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to stash changes")}return r.json()}const Ya=async(e,t,r)=>{const o=await b(M(`${S}/${t}`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||`Failed to ${t}`)}return o.json()},j0=(e,t)=>Ya(e,"stash/apply",t),Kc=(e,t)=>Ya(e,"stash/pop",t),$0=(e,t)=>Ya(e,"stash/drop",t);async function z0(e,t,r){const o=await b(M(`${S}/checkout`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t,...r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText})),a=new Error(n.error||"Failed to checkout branch");throw typeof n.code=="string"&&(a.code=n.code),(typeof n.currentBranch=="string"||n.currentBranch===null)&&(a.currentBranch=n.currentBranch),a}return o.json()}async function q0(e,t,r){const o=await b(M(`${S}/branches`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,startPoint:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to create branch")}return o.json()}async function W0(e,t,r){const o=await b(M(`${S}/branches/rename`,e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:t,newName:r})});if(!o.ok){const n=await o.json().catch(()=>({error:o.statusText}));throw new Error(n.error||"Failed to rename branch")}return o.json()}async function G0(e,t={}){const r=await b(M(`${S}/log`,e,{maxCount:t.maxCount,from:t.from,to:t.to,file:t.file,all:t.all?"true":void 0}));if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(`Failed to get git log: ${o.error||r.statusText}`)}return r.json()}async function V0(e,t){const r=await b(M(`${S}/commit-files`,e,{hash:t}));if(!r.ok)throw new Error(`Failed to get commit files: ${r.statusText}`);return r.json()}async function QA(e,t,r,o){const n=await b(M(`${S}/commit-file-diff`,e,{hash:t,path:r,binary:o?"true":void 0}));if(!n.ok)throw new Error(`Failed to get commit file diff: ${n.statusText}`);return n.json()}async function J0(e,t){return await Hc(e,{message:t?.message}),{success:!0}}async function Y0(e){return await Kc(e,{ref:"stash@{0}"}),{success:!0}}async function X0(e){const t=await b(M(`${S}/remotes`,e));if(!t.ok)throw new Error(`Failed to get remotes: ${t.statusText}`);return t.json()}async function Q0(e,t){const r=await b(M(`${S}/rebase`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to rebase")}return r.json()}async function Z0(e){const t=await b(M(`${S}/rebase/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort rebase")}return t.json()}async function ey(e,t){const r=await b(M(`${S}/merge`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to merge")}return r.json()}async function ty(e,t){const r=await b(M(`${S}/checkout-commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to checkout commit")}return r.json()}async function ry(e,t){const r=await b(M(`${S}/cherry-pick`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to cherry-pick")}return r.json()}async function oy(e,t){const r=await b(M(`${S}/revert-commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t})});if(!r.ok){const o=await r.json().catch(()=>({error:r.statusText}));throw new Error(o.error||"Failed to revert commit")}return r.json()}async function ny(e,t,r,o){const n=await b(M(`${S}/reset-to-commit`,e),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:t,mode:r,force:o})});if(!n.ok){const a=await n.json().catch(()=>({error:n.statusText}));throw new Error(a.error||"Failed to reset")}return n.json()}async function ay(e){const t=await b(M(`${S}/merge/abort`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to abort merge")}return t.json()}async function sy(e){const t=await b(M(`${S}/rebase/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue rebase")}return t.json()}async function iy(e){const t=await b(M(`${S}/merge/continue`,e),{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({error:t.statusText}));throw new Error(r.error||"Failed to continue merge")}return t.json()}async function cy(e){const t=await b(M(`${S}/conflict-details`,e));if(!t.ok)throw new Error(`Failed to get conflict details: ${t.statusText}`);return t.json()}const dy=()=>({checkIsGitRepository:h0,getGitStatus:F0,getGitDiff:B0,getGitFileDiff:v0,getGitRangeDiff:C0,revertGitFile:k0,stageGitFile:D0,stageGitFiles:Lc,unstageGitFile:S0,unstageGitFiles:Uc,stageGitHunk:M0,unstageGitHunk:T0,revertGitHunk:P0,getGitBranches:R0,listGitWorktrees:y0,validateGitWorktree:b0,createGitWorktree:A0,deleteGitWorktree:E0,getGitWorktreeBootstrapStatus:w0,deleteGitBranch:I0,deleteRemoteBranch:_0,removeRemote:x0,createGitCommit(e,t,r){return O0(e,t,r)},gitPush:N0,gitPull:L0,gitFetch:U0,listGitStashes:H0,countGitStashFiles:K0,stashGitChanges:Hc,applyGitStash:j0,popGitStash:Kc,dropGitStash:$0,checkoutBranch:z0,createBranch:q0,renameBranch:W0,getGitLog(e,t){return G0(e,t)},getCommitFiles:V0,getRemotes:X0,rebase:Q0,abortRebase:Z0,continueRebase:sy,merge:ey,abortMerge:ay,continueMerge:iy,checkoutCommit:ty,cherryPick:ry,revertCommit:oy,resetToCommit:ny,stash:J0,stashPop:Y0,getConflictDetails:cy});class ly extends Error{body;status;constructor(t,r){super(t.kind==="failed"?t.message:t.kind),this.name="GitHubAPIError",this.body=t,this.status=r}}const _="/api/github",uy=(e,t)=>{if(e&&typeof e=="object"&&"error"in e){const r=e.error;if(r&&typeof r.kind=="string")return r}return{kind:"failed",message:`GitHub request failed (HTTP ${t}).`}},x=async(e,t)=>{const r=await b(e,t),o=await r.json().catch(()=>null);if(!r.ok||o&&typeof o=="object"&&"error"in o)throw new ly(uy(o,r.status),r.status);return o},ke=(e,t,r)=>({query:{directory:e,repo:t,...r}}),fy=()=>({status:()=>x(`${_}/status`),scope:e=>x(`${_}/scope`,{query:{directory:e}}),pullsList:(e,t,r={})=>x(`${_}/pulls`,{query:{directory:e,repo:t,...r.state?{state:r.state}:{},...r.filter?{filter:r.filter}:{},...r.q?{q:r.q}:{},...r.cursor?{cursor:r.cursor}:{},...r.sort?{sort:r.sort}:{},...r.perPage!=null?{perPage:String(r.perPage)}:{}}}),pullGet:(e,t,r)=>x(`${_}/pulls/${r}`,ke(e,t)),pullFiles:(e,t,r,o)=>x(`${_}/pulls/${r}/files`,ke(e,t,o?{cursor:o}:{})),pullChecks:(e,t,r,o)=>x(`${_}/pulls/${r}/checks`,ke(e,t,o?{details:"full"}:{})),prStatus:(e,t)=>x(`${_}/pr-status`,{query:t?{directory:e,branch:t}:{directory:e}}),pullCreate:e=>x(`${_}/pulls`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),pullAction:(e,t,r,o)=>x(`${_}/pulls/${r}/actions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,action:o})}),pullUpdate:(e,t,r,o)=>x(`${_}/pulls/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...o})}),pullComment:(e,t,r,o)=>x(`${_}/pulls/${r}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,body:o})}),pullComments:(e,t,r,o)=>x(`${_}/pulls/${r}/comments`,ke(e,t,o?{cursor:o}:{})),pullReview:(e,t,r,o)=>x(`${_}/pulls/${r}/reviews`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...o})}),pullThread:(e,t,r,o,n)=>x(`${_}/pulls/${r}/threads/${encodeURIComponent(o)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...n})}),pullCheckout:(e,t,r,o="worktree")=>x(`${_}/pulls/${r}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,mode:o})}),issuesList:(e,t,r={})=>x(`${_}/issues`,{query:{directory:e,repo:t,...r.state?{state:r.state}:{},...r.filter?{filter:r.filter}:{},...r.q?{q:r.q}:{},...r.labels?{labels:r.labels}:{},...r.cursor?{cursor:r.cursor}:{},...r.sort?{sort:r.sort}:{},...r.perPage!=null?{perPage:String(r.perPage)}:{}}}),issueGet:(e,t,r)=>x(`${_}/issues/${r}`,ke(e,t)),issueComments:(e,t,r,o)=>x(`${_}/issues/${r}/comments`,ke(e,t,o?{cursor:o}:{})),issueCreate:(e,t,r)=>x(`${_}/issues`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...r})}),issueUpdate:(e,t,r,o)=>x(`${_}/issues/${r}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,...o})}),issueComment:(e,t,r,o)=>x(`${_}/issues/${r}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,body:o})}),repoMeta:(e,t,r)=>x(`${_}/meta`,ke(e,t,r?.length?{kinds:r.join(",")}:{})),issueTemplates:(e,t)=>x(`${_}/templates`,ke(e,t)),checkJobs:(e,t,r,o)=>x(`${_}/checks/jobs`,ke(e,t,{...r!=null?{runId:String(r)}:{},...o!=null?{jobId:String(o)}:{}})),checkAnnotations:(e,t,r)=>x(`${_}/checks/annotations`,ke(e,t,{checkRunId:String(r)})),checksRerun:(e,t,r)=>x(`${_}/checks/rerun`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:e,repo:t,runId:r})}),agentContext:(e,t,r,o,n)=>x(`${_}/context`,{query:{directory:e,repo:t,type:r,number:String(o),...n?.ref?{ref:n.ref}:{},...n?.includeDiff?{includeDiff:"true"}:{}}}),invalidate:e=>x(`${_}/invalidate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e??{})})});class jo extends Error{reason;status;constructor(t,r={}){super(t),this.name="FilesystemError",this.reason=r.reason??"unknown",this.status=r.status}}class jc extends jo{currentRevision;exists;filePath;constructor(t,r={}){super(t,{reason:"file-revision-conflict",status:r.status??409}),this.name="FileRevisionConflictError",this.currentRevision=r.currentRevision??null,this.exists=r.exists??r.currentRevision!=null,this.filePath=r.path??""}}const ZA=e=>e instanceof jc||my(e)&&e.reason==="file-revision-conflict",my=e=>e instanceof jo||!!(e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"),Xs=e=>{switch(e){case"os-permission":case"not-found":case"not-directory":case"invalid-response":case"file-revision-conflict":return e;default:return"unknown"}},oe=e=>e.replace(/\\/g,"/"),gy=(e,t)=>{if(!t||!Array.isArray(t.entries))throw new jo("Directory listing returned an invalid response",{reason:"invalid-response"});return{directory:oe(t?.directory||t?.path||e),entries:t.entries.filter(o=>!!(o&&typeof o.name=="string"&&typeof o.path=="string")).map(o=>({name:o.name,path:oe(o.path),isDirectory:!!o.isDirectory}))}},De=(e,t)=>{const r=t||e?.();return r?{"x-pichamber-directory":r}:void 0},py=({getDirectory:e})=>({async listDirectory(t,r){const o=oe(t),n=new URLSearchParams;o&&n.set("path",o),r?.respectGitignore&&n.set("respectGitignore","true");const a=await b("/api/fs/list",{query:n,headers:De(e)});if(!a.ok){const i=await a.json().catch(()=>({error:a.statusText}));throw new jo(i.error||"Failed to list directory",{reason:Xs(i.reason),status:a.status})}const s=await a.json();return gy(o,s)},async search(t){const r=new URLSearchParams,o=oe(t.directory);o&&r.set("directory",o),r.set("query",t.query),r.set("dirs","false"),r.set("type","file"),typeof t.maxResults=="number"&&Number.isFinite(t.maxResults)&&r.set("limit",String(t.maxResults));const n=await b("/api/find/file",{query:r,headers:De(e)});if(!n.ok){const i=await n.json().catch(()=>({error:n.statusText}));throw new Error(i.error||"Failed to search files")}const a=await n.json();return(Array.isArray(a)?a:[]).map(i=>({path:oe(`${o}/${i}`),preview:[oe(i)]}))},async createDirectory(t){const r=oe(t),o=await b("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({path:r})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to create directory")}const n=await o.json();return{success:!!n?.success,path:typeof n?.path=="string"?oe(n.path):r}},async statFile(t,r){const o=oe(t),n=new URLSearchParams({path:o});r?.allowOutsideWorkspace&&n.set("allowOutsideWorkspace","true"),r?.outsideFileGrant&&n.set("outsideFileGrant",r.outsideFileGrant),typeof r?.knownRevision=="string"&&r.knownRevision.length>0&&n.set("knownRevision",r.knownRevision);const a=await b("/api/fs/stat",{query:n,headers:De(e,r?.directory)});if(!a.ok){const c=await a.json().catch(()=>({error:a.statusText}));throw new Error(c.error||"Failed to stat file")}const s=await a.json().catch(()=>({})),i=s.exists!==!1;return{path:typeof s.path=="string"?oe(s.path):o,isFile:!!s.isFile,size:typeof s.size=="number"?s.size:0,mtimeMs:typeof s.mtimeMs=="number"?s.mtimeMs:void 0,revision:typeof s.revision=="string"?s.revision:i?void 0:null,exists:i}},async readFile(t,r){const o=oe(t),n=new URLSearchParams({path:o});r?.allowOutsideWorkspace&&n.set("allowOutsideWorkspace","true"),r?.outsideFileGrant&&n.set("outsideFileGrant",r.outsideFileGrant),r?.optional&&n.set("optional","true");const a=await b("/api/fs/read",{query:n,cache:r?.optional?"no-store":"default",headers:De(e,r?.directory)});if(!a.ok){const u=await a.json().catch(()=>({error:a.statusText}));throw new Error(u.error||"Failed to read file")}const s=await a.text(),i=a.headers?.get?.("x-pichamber-file-revision"),d=a.headers?.get?.("x-pichamber-file-exists")!=="false",l=typeof i=="string"&&i.length>0?i:d?void 0:null;return{content:s,path:o,revision:l,exists:d}},async writeFile(t,r,o){const n=oe(t),a={path:n,content:r};o&&"expectedRevision"in o&&(a.expectedRevision=o.expectedRevision??null),o?.overwrite===!0&&(a.overwrite=!0);const s=await b("/api/fs/write",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify(a)});if(!s.ok){const c=await s.json().catch(()=>({error:s.statusText}));throw s.status===409&&Xs(c.reason)==="file-revision-conflict"?new jc(c.error||"File has changed on disk",{currentRevision:typeof c.currentRevision=="string"?c.currentRevision:null,exists:typeof c.exists=="boolean"?c.exists:void 0,path:typeof c.path=="string"?c.path:n,status:s.status}):new Error(c.error||"Failed to write file")}const i=await s.json().catch(()=>({}));return{success:!!i.success,path:typeof i.path=="string"?oe(i.path):n,revision:typeof i.revision=="string"?i.revision:void 0,noop:!!i.noop||void 0}},async delete(t){const r=oe(t),o=await b("/api/fs/delete",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({path:r})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to delete file")}return{success:!!(await o.json().catch(()=>({}))).success}},async rename(t,r){const o=await b("/api/fs/rename",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({oldPath:t,newPath:r})});if(!o.ok){const a=await o.json().catch(()=>({error:o.statusText}));throw new Error(a.error||"Failed to rename file")}const n=await o.json().catch(()=>({}));return{success:!!n.success,path:typeof n.path=="string"?oe(n.path):r}},async revealPath(t){const r=await b("/api/fs/reveal",{method:"POST",headers:{"Content-Type":"application/json",...De(e)},body:JSON.stringify({path:oe(t)})});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||"Failed to reveal path")}return{success:!!(await r.json().catch(()=>({}))).success}},async downloadFile(t){const r=oe(t),o=await b("/api/fs/raw",{query:{path:r,download:!0},headers:De(e)});if(!o.ok)throw new Error(`Download failed (${o.status})`);const n=await o.blob(),a=URL.createObjectURL(n),s=document.createElement("a");s.href=a,s.download=r.split("/").pop()||"file",document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(a),100)}}),Qs="/api/pi/ui-settings",Zs=e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid settings response");return e},hy=()=>({async load(){const e=await b(Qs,{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new Error(`Failed to load settings: ${e.statusText}`);return{settings:Zs(await e.json()),source:"web"}},async save(e){const t=await b(Qs,{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!t.ok){const o=await t.json().catch(()=>({error:t.statusText}));throw new Error(o.error||"Failed to save settings")}return Zs(await t.json())}}),Fy=()=>({async requestDirectoryAccess(e){return{success:!0,path:e.path}},async startAccessingDirectory(e){return{success:!0}},async stopAccessingDirectory(e){return{success:!0}}}),yy=1500,oa=5e3,by="pichamber-notification-claim:",Ay=20,kr=new Map,Ae=new Map,ei="pichamber:input:",Ey=(e,t)=>{if(t!=="input")return!1;const r=typeof e=="string"?e.trim():"";return r.startsWith(ei)&&r.length>ei.length},wy=(e,t,r)=>{if(!Ey(e,r)||typeof e!="string"||e.length===0)return;const o=Ae.get(e);if(Ae.delete(e),o&&o!==t)try{o.close()}catch{}for(Ae.set(e,t);Ae.size>Ay;){const n=Ae.keys().next().value;if(n===void 0)break;const a=Ae.get(n);if(Ae.delete(n),a)try{a.close()}catch{}}},By=e=>{const t=typeof e?.tag=="string"?e.tag.trim():"";return t||[e?.sessionId,e?.kind,e?.title,e?.body].filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim()).join("|")},Cy=e=>{for(const[t,r]of kr)e-r>oa&&kr.delete(t)},vy=e=>{const t=By(e);if(!t)return!0;const r=Date.now();Cy(r);const o=kr.get(t)??0;if(r-o<oa)return!1;try{if(typeof window<"u"&&window.localStorage){const n=`${by}${t}`,a=Number(window.localStorage.getItem(n)??"0");if(Number.isFinite(a)&&r-a<oa)return kr.set(t,a),!1;Number.isFinite(a)&&a>0&&window.localStorage.removeItem(n),window.localStorage.setItem(n,String(r))}}catch{}return kr.set(t,r),!0},$c=async()=>{if(typeof navigator>"u"||!("serviceWorker"in navigator))return null;let e=null;try{e=await navigator.serviceWorker.getRegistration()??null}catch{e=null}if(e?.active)return e;if(!e)return null;try{return await Promise.race([navigator.serviceWorker.ready,new Promise(r=>{setTimeout(()=>r(null),yy)})])??e}catch{return e}},ky=async e=>{const t=await $c();if(!t||typeof t.showNotification!="function")return!1;try{return await t.showNotification(e?.title??"PiChamber",{body:e?.body,tag:e?.tag}),!0}catch(r){return console.warn("Failed to send notification via service worker",r),!1}},Dy=async e=>{if(e?.requireHidden&&typeof document<"u"&&document.hasFocus())return!0;if(typeof Notification>"u")return console.info("Notifications not supported in this environment",e),!1;if(Notification.permission==="default"&&await Notification.requestPermission()!=="granted"||Notification.permission!=="granted")return console.warn("Notification permission not granted"),!1;if(!vy(e))return!0;try{if(await ky(e))return!0;const t=new Notification(e?.title??"PiChamber",{body:e?.body,tag:e?.tag});return wy(e?.tag,t,e?.kind),t.onclose=()=>{e?.tag&&Ae.get(e.tag)===t&&Ae.delete(e.tag)},t.onclick=()=>{try{typeof window<"u"&&window.focus()}catch{}try{typeof window<"u"&&e?.sessionId&&window.dispatchEvent(new CustomEvent("pichamber:open-session",{detail:{sessionId:e.sessionId,directory:e.directory??""}}))}catch{}t.close()},!0}catch(t){return console.warn("Failed to send notification",t),!1}},Sy=async e=>{if(typeof window>"u")return!1;const t=window.__PICHAMBER_DESKTOP__;if(!t?.invoke)return!1;try{return await t.invoke("desktop_notify",{payload:{title:e?.title,body:e?.body,tag:e?.tag,kind:e?.kind,sessionId:e?.sessionId,directory:e?.directory,requireHidden:e?.requireHidden}}),!0}catch(r){return console.warn("Failed to send native notification (desktop)",r),!1}},My=()=>({async notify(e){return await Sy(e)||await Dy(e)},canNotify:()=>typeof window<"u"&&window.__PICHAMBER_DESKTOP__?.invoke?!0:typeof Notification<"u"?Notification.permission==="granted":!1,async close(e){if(typeof e!="string"||e.trim().length===0)return;const t=e.trim();if(typeof window<"u"){const o=window.__PICHAMBER_DESKTOP__;if(o?.invoke)try{await o.invoke("desktop_notification_close",{tag:t});return}catch(n){console.warn("Failed to close native notification (desktop)",n)}}const r=Ae.get(t);if(r){Ae.delete(t);try{r.close()}catch{}}try{const o=await $c(),n=typeof o?.getNotifications=="function"?await o.getNotifications({tag:t}):[];for(const a of n??[])try{a.close()}catch{}}catch{}},setAttentionCount(e){const t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;if(typeof window<"u"){const r=window.__PICHAMBER_DESKTOP__;if(r?.invoke){r.invoke("desktop_tray_update",{dockBadgeCount:t}).catch(o=>{console.warn("Failed to update desktop attention count",o)});return}}try{const r=typeof navigator<"u"?navigator:null;if(!r)return;t>0&&typeof r.setAppBadge=="function"?r.setAppBadge(t).catch(()=>{}):t===0&&typeof r.clearAppBadge=="function"&&r.clearAppBadge().catch(()=>{})}catch{}}}),Ty=()=>({async getAvailableTools(){const e=await b("/api/experimental/tool/ids");if(!e.ok)throw new Error(`Tools API returned ${e.status} ${e.statusText}`);const t=await e.json();if(!Array.isArray(t))throw new Error("Tools API returned invalid data format");return t.filter(r=>typeof r=="string"&&r!=="invalid").sort()}}),Ye=async e=>await e.json().catch(()=>null),Py=()=>({async listClients(){const e=await b("/api/client-auth/clients",{method:"GET",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load remote clients");return Array.isArray(t.clients)?t.clients:[]},async createClient(e={}){const t=await b("/api/client-auth/clients",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({label:e.label??""})}),r=await Ye(t);if(!t.ok||!r?.client||typeof r.token!="string")throw new Error(r?.error||t.statusText||"Failed to create remote client token");return r},async createPairingSession(e={}){const t=await b("/api/client-auth/pairing/sessions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({label:e.label??"",...e.allowedClientKinds?{allowedClientKinds:e.allowedClientKinds}:{},...e.serverUrl?{serverUrl:e.serverUrl}:{},...typeof e.includeRelay=="boolean"?{includeRelay:e.includeRelay}:{},...typeof e.includeDirect=="boolean"?{includeDirect:e.includeDirect}:{}})}),r=await Ye(t);if(!t.ok||typeof r?.pairing?.secret!="string"||!r?.server)throw new Error(r?.error||t.statusText||"Failed to create pairing session");return r},async listPendingPairings(){const e=await b("/api/client-auth/pairing/sessions",{method:"GET",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load pending pairings");return Array.isArray(t.pending)?t.pending:[]},async getPairingTransports(){const e=await b("/api/client-auth/pairing/transports",{method:"GET",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to load pairing transports");const r=t.tailscale&&typeof t.tailscale=="object"&&typeof t.tailscale.available=="boolean"?{available:t.tailscale.available,url:typeof t.tailscale.url=="string"?t.tailscale.url:null,mode:t.tailscale.mode==="public"?"public":"private"}:null;return{local:t.local??null,lan:t.lan??null,relayAvailable:t.relayAvailable!==!1,...r?{tailscale:r}:{}}},async cancelPairing(e){const t=await b(`/api/client-auth/pairing/sessions/${encodeURIComponent(e)}`,{method:"DELETE",headers:{Accept:"application/json"}}),r=await Ye(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to cancel pairing");return{cancelled:r.cancelled===!0}},async revokeClient(e){const t=await b(`/api/client-auth/clients/${encodeURIComponent(e)}`,{method:"DELETE",headers:{Accept:"application/json"}}),r=await Ye(t);if(!t.ok||!r)throw new Error(r?.error||t.statusText||"Failed to revoke remote client");return r},async purgeRevokedClients(){const e=await b("/api/client-auth/clients",{method:"DELETE",headers:{Accept:"application/json"}}),t=await Ye(e);if(!e.ok||!t)throw new Error(t?.error||e.statusText||"Failed to clear revoked clients");return t}}),Ry=(e={})=>{const t=e.urls??ma();return fl(t),{runtime:{platform:"web",isDesktop:!1,label:"web"},terminal:u0(),git:dy(),github:fy(),files:py({getDirectory:()=>Yn.getState().currentDirectory}),settings:hy(),permissions:Fy(),notifications:My(),clientAuth:Py(),tools:Ty()}},ti=(e,t)=>{if(!e||!t)return!1;try{return new URL(e).origin===new URL(t).origin}catch{return!1}},Iy=()=>{const e=t=>typeof t=="string"?t.trim():"";return{apiBaseUrl:e(window.__PICHAMBER_API_BASE_URL__),clientToken:e(window.__PICHAMBER_CLIENT_TOKEN__),localOrigin:e(window.__PICHAMBER_LOCAL_ORIGIN__),runtimeHeaders:window.__PICHAMBER_RUNTIME_HEADERS__,relayHostId:e(window.__PICHAMBER_RELAY_HOST_ID__)}};let na=Promise.resolve();const eE=()=>na,tE=e=>{const{apiBaseUrl:t,clientToken:r,localOrigin:o,runtimeHeaders:n,relayHostId:a,relay:s}=Iy(),i=ga({apiBaseUrl:t||void 0,realtimeBaseUrl:t||void 0});return bl({apiBaseUrl:t,runtimeKey:ti(t,o)?"local":null}),Ei(r||null),wi(n||null),s&&jt({apiBaseUrl:t,clientToken:r||null,requestHeaders:n||null,runtimeKey:a?`host:${a}`:null,relay:s}),Ul(),na=s?Promise.resolve():Promise.race([gu(a||void 0).catch(()=>{}),new Promise(c=>{window.setTimeout(c,1e4)})]),na.then(()=>{Hr(ze()||void 0).catch(()=>{}),o&&!ti(t,o)&&Object.keys(ua()).length>0&&Zd(o).catch(()=>{})}),Ry({urls:i})};export{QA as $,K as A,ce as B,zA as C,qA as D,pa as E,an as F,Kr as G,W as H,ze as I,jt as J,Ob as K,Wy as L,HA as M,FA as N,$y as O,Hr as P,zy as Q,Nf as R,uf as S,Kb as T,bA as U,Zy as V,NA as W,Cb as X,Dl as Y,Ie as Z,yA as _,_A as a,Uo as a$,Z as a0,fA as a1,Qf as a2,TA as a3,PA as a4,pA as a5,Qy as a6,CA as a7,AA as a8,MA as a9,xb as aA,fF as aB,Qb as aC,Ta as aD,ff as aE,hf as aF,mf as aG,Ff as aH,Co as aI,Am as aJ,jA as aK,Mc as aL,cb as aM,db as aN,Xb as aO,Gs as aP,uA as aQ,ub as aR,eb as aS,rb as aT,nb as aU,sb as aV,tb as aW,ob as aX,ab as aY,ib as aZ,vA as a_,yc as aa,YA as ab,pm as ac,Jy as ad,jy as ae,Qt as af,ia as ag,Wl as ah,Tb as ai,Ke as aj,hb as ak,pb as al,Ca as am,iu as an,su as ao,ot as ap,Ba as aq,ka as ar,gA as as,EA as at,Ab as au,kl as av,Sb as aw,Mb as ax,zi as ay,Ky as az,D as b,X as b$,DA as b0,$e as b1,js as b2,Tm as b3,Rm as b4,Db as b5,of as b6,Cl as b7,lb as b8,mb as b9,Xy as bA,Im as bB,Ib as bC,_b as bD,Ub as bE,Eo as bF,bu as bG,L as bH,xm as bI,LA as bJ,Ii as bK,Fm as bL,Au as bM,Gy as bN,Nb as bO,qy as bP,Su as bQ,In as bR,Jh as bS,wc as bT,Ec as bU,jr as bV,kb as bW,KA as bX,fn as bY,xn as bZ,lF as b_,gb as ba,jb as bb,my as bc,Al as bd,Ur as be,Ji as bf,wA as bg,WA as bh,wb as bi,Eb as bj,Ro as bk,ac as bl,Vy as bm,JA as bn,VA as bo,pf as bp,OA as bq,Yh as br,vb as bs,xA as bt,Qh as bu,Xh as bv,Bb as bw,Hb as bx,Lb as by,XA as bz,hA as c,Yy as c$,Xl as c0,Zl as c1,tu as c2,_e as c3,Da as c4,va as c5,ou as c6,au as c7,nu as c8,qi as c9,Gb as cA,zb as cB,Jb as cC,Ss as cD,Wb as cE,BA as cF,_m as cG,fb as cH,Zr as cI,GA as cJ,sc as cK,tA as cL,eA as cM,Mf as cN,oA as cO,nA as cP,sA as cQ,Zb as cR,rA as cS,Ps as cT,aA as cU,cA as cV,dA as cW,iA as cX,Ts as cY,lA as cZ,gf as c_,uu as ca,Gi as cb,ua as cc,bb as cd,Fb as ce,yb as cf,NF as cg,LF as ch,$A as ci,rt as cj,Ia as ck,im as cl,RA as cm,IA as cn,Yb as co,ur as cp,Ze as cq,ym as cr,re as cs,Zt as ct,Ma as cu,af as cv,vl as cw,Vb as cx,$b as cy,qb as cz,tE as d,Pb as d0,Rb as d1,mA as d2,er as e,we as f,Sl as g,eE as h,ZA as i,IF as j,Yn as k,ya as l,h0 as m,hm as n,_o as o,At as p,j as q,b as r,Li as s,SA as t,ie as u,xe as v,kA as w,El as x,UA as y,MF as z};