bloby-bot 0.70.1 → 0.70.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-bloby/assets/{bloby-Dfx1hOe-.js → bloby-CXmOcb1r.js} +4 -4
- package/dist-bloby/assets/{highlighted-body-OFNGDK62-BzAQnLnm.js → highlighted-body-OFNGDK62-D7cU1Y-Z.js} +1 -1
- package/dist-bloby/assets/mermaid-GHXKKRXX-D5YxphBn.js +1 -0
- package/dist-bloby/bloby.html +1 -1
- package/package.json +3 -2
- package/supervisor/chat/bloby-main.tsx +14 -10
- package/vite.bloby.config.ts +0 -8
- package/workspace/client/index.html +1 -1
- package/workspace/client/public/manifest.json +16 -4
- package/workspace/client/public/morphy-icon-maskable-192.png +0 -0
- package/workspace/client/public/morphy-icon-maskable-512.png +0 -0
- package/dist-bloby/assets/mermaid-GHXKKRXX-CHPqkcxH.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-D7cU1Y-Z.js","assets/jsx-runtime-C0W9Wf2W.js","assets/angular-html-olSuI25H.js","assets/html-CzX0w7K_.js","assets/css-zY4NE9yA.js","assets/javascript-CzjRtS1s.js","assets/angular-ts-BJPoZ_vo.js","assets/scss-Efq7Dmbs.js","assets/apl-CyVuPSCb.js","assets/json-CdFmZMJc.js","assets/xml-BlDEvPia.js","assets/java-BqKEu7zh.js","assets/astro-CKc3-gwH.js","assets/postcss-BTQso3H9.js","assets/tsx-DrzBggF8.js","assets/typescript-COZIw7xM.js","assets/blade-DMAsVBaV.js","assets/html-derivative-D-XvNBA6.js","assets/sql-CB6kO6Km.js","assets/bsl-B1qbqNES.js","assets/sdbl-BmWYR-pI.js","assets/c-BvB8CVo8.js","assets/cairo-BDj8wWhy.js","assets/python-CKg5r0C3.js","assets/cobol-hBjMZW-R.js","assets/coffee-B4OtR3w-.js","assets/cpp-BblbpnyR.js","assets/glsl-CEMf-THb.js","assets/regexp-CvWG4lI-.js","assets/crystal-x3k4USY-.js","assets/shellscript-BbEstezf.js","assets/edge-B-9TrlZC.js","assets/elixir-CXCzbj1r.js","assets/elm-BdRiwmde.js","assets/erb-C9tvRzx3.js","assets/ruby-CXP5_4kq.js","assets/graphql-dBCd2Czl.js","assets/jsx-BL6Wh6Qw.js","assets/haml-Ck5pVAEG.js","assets/lua-B4ezzssg.js","assets/yaml-iUXljnLs.js","assets/erlang-Bc4hQuqa.js","assets/markdown-BaI9LyM4.js","assets/fortran-fixed-form-B02FOYI-.js","assets/fortran-free-form-BPTf0lbT.js","assets/fsharp-DhdR18vN.js","assets/gdresource-DgnrMPIx.js","assets/gdscript-CsadCSaZ.js","assets/gdshader-PfnN_8tR.js","assets/git-commit-DGJi7qBD.js","assets/diff-CdkWtnkL.js","assets/git-rebase-HwDSB2qJ.js","assets/glimmer-js-B6LF_BMd.js","assets/glimmer-ts-Cn42BUKe.js","assets/hack-DDEqRjBe.js","assets/handlebars-g9Qe0ao2.js","assets/http-qlhghEti.js","assets/hurl-CHIKfBKk.js","assets/csv-DNUpVBxl.js","assets/hxml-adC65L_J.js","assets/haxe-DfXTCEOz.js","assets/jinja-BHZt0_Dn.js","assets/jison-TqJYWKkW.js","assets/julia-CW07fy07.js","assets/r-CGji9_vM.js","assets/just-DBcWo9WY.js","assets/perl-DqDX-7VG.js","assets/latex-D6lXiPTF.js","assets/tex-CdJ24HJj.js","assets/liquid-DhYYAQ41.js","assets/marko-xtrIBdcL.js","assets/less-C95PyOu0.js","assets/mdc-DyZVNnwP.js","assets/nextflow-JEyYUlIq.js","assets/nextflow-groovy-wvmJO4hi.js","assets/nginx-CGgm1VOJ.js","assets/nim-Br7S817Z.js","assets/php-DYSqNNGJ.js","assets/pug-Bob3gNio.js","assets/qml-CsMafcqN.js","assets/razor-B4PzhaZX.js","assets/csharp-BDKQY1K9.js","assets/rst-BXuz-2b8.js","assets/cmake-D5rSbMir.js","assets/sas-Cov9PzAD.js","assets/shaderlab-DZ3Lsiak.js","assets/hlsl-DpuYn7pp.js","assets/shellsession-BHLVblBB.js","assets/soy-e0u3-wIA.js","assets/sparql-B9c85a_o.js","assets/turtle-CqNXyJWZ.js","assets/stata-B1mLEMrz.js","assets/surrealql-BTKo2XFY.js","assets/svelte-B7URZ-wm.js","assets/templ-DVRYIgGq.js","assets/go-DLnOLj8q.js","assets/ts-tags-CCSbelDn.js","assets/twig-Dn4ruiVl.js","assets/vue-D19cWHwY.js","assets/vue-html-_j-KC7Cs.js","assets/vue-vine-BC03MN6c.js","assets/stylus-sKwvsUaC.js","assets/xsl-DR-zOeBm.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{c as e,i as t,n,o as r,r as i,t as a}from"./jsx-runtime-C0W9Wf2W.js";import{C as o,E as s,S as c,T as l,_ as u,a as d,b as f,c as p,d as m,f as h,g,h as _,i as v,l as y,m as b,n as x,o as S,p as C,r as w,s as T,t as E,u as ee,v as D,w as te,x as ne,y as re}from"./globals-DpO5tO92.js";var ie=l(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),ae=l(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),oe=l(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),se=l(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),O=l(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ce=l(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),le=l(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),ue=l(`crosshair`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]),de=l(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),k=l(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),fe=l(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),pe=l(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),me=l(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),A=l(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),he=l(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),ge=l(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),_e=l(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),ve=l(`share`,[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]),ye=l(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),be=l(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),xe=l(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]),Se=l(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),j=e(i(),1),Ce=e(s(),1),we=class e{ws=null;handlers=new Map;statusHandlers=new Set;reconnectTimer=null;heartbeatTimer=null;url;queue=[];intentionalClose=!1;reconnectDelay=1e3;static MAX_RECONNECT_DELAY=8e3;tokenGetter=null;constructor(e,t){let n=location.protocol===`https:`?`wss:`:`ws:`,r=location.host;this.url=e??`${n}//${r}/ws`,this.tokenGetter=t??null}connect(){this.intentionalClose=!1;let t=this.url;if(this.tokenGetter){let e=this.tokenGetter();if(e){let n=t.includes(`?`)?`&`:`?`;t=`${t}${n}token=${e}`}}this.ws=new WebSocket(t),this.ws.onopen=()=>{this.reconnectDelay=1e3,this.notifyStatus(!0),this.flushQueue(),this.startHeartbeat()},this.ws.onmessage=e=>{if(e.data===`pong`)return;let t;try{t=JSON.parse(e.data)}catch{return}this.handlers.get(t.type)?.forEach(e=>e(t.data))},this.ws.onclose=()=>{this.stopHeartbeat(),this.notifyStatus(!1),this.intentionalClose||(this.reconnectTimer=setTimeout(()=>{this.reconnectDelay=Math.min(this.reconnectDelay*2,e.MAX_RECONNECT_DELAY),this.connect()},this.reconnectDelay))},this.ws.onerror=()=>this.ws?.close()}disconnect(){this.intentionalClose=!0,this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.stopHeartbeat(),this.ws?.close(),this.ws=null}on(e,t){return this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(t),()=>this.handlers.get(e)?.delete(t)}onStatus(e){return this.statusHandlers.add(e),()=>this.statusHandlers.delete(e)}send(e,t){let n={type:e,data:t};this.ws?.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(n)):this.queue.push(n)}get connected(){return this.ws?.readyState===WebSocket.OPEN}flushQueue(){for(;this.queue.length>0&&this.ws?.readyState===WebSocket.OPEN;){let e=this.queue.shift();this.ws.send(JSON.stringify(e))}}notifyStatus(e){this.statusHandlers.forEach(t=>t(e))}startHeartbeat(){this.stopHeartbeat(),this.heartbeatTimer=setInterval(()=>{this.ws?.readyState===WebSocket.OPEN&&this.ws.send(`ping`)},25e3)}stopHeartbeat(){this.heartbeatTimer&&=(clearInterval(this.heartbeatTimer),null)}};function Te(e,t,n=!0){let[r,i]=(0,j.useState)([]),[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)([]),[p,m]=(0,j.useState)(!1),h=(0,j.useRef)(!1),g=(0,j.useRef)(null),_=(0,j.useRef)(!1),y=(0,j.useRef)(!1),b=(0,j.useRef)(``),x=(0,j.useRef)(0),S=(0,j.useRef)(null),C=(0,j.useRef)(null),w=(0,j.useRef)(new URLSearchParams(location.search).has(`ext`));(0,j.useEffect)(()=>{g.current=a},[a]),(0,j.useEffect)(()=>{_.current=s},[s]),(0,j.useEffect)(()=>{if(!w.current)return;function e(e){e.data?.type===`bloby:page-context`&&(C.current=e.data.context)}return window.addEventListener(`message`,e),window.parent?.postMessage({type:`bloby:request-context`},`*`),()=>window.removeEventListener(`message`,e)},[]);let T=(0,j.useCallback)(e=>{let t;e.audio_data&&(t=e.audio_data.startsWith(`data:`)?e.audio_data:e.audio_data.includes(`/`)?`/api/files/${e.audio_data}`:`data:audio/webm;base64,${e.audio_data}`);let n;if(e.attachments)try{n=JSON.parse(e.attachments)}catch{}return{id:e.id,role:e.role,content:e.content,timestamp:e.created_at,audioData:t,hasAttachments:!!(n&&n.length>0),attachments:n}},[]),E=(0,j.useCallback)(async()=>{try{let e=await v(`/api/context/current`).then(e=>e.json());if(!e.conversationId)return;o(e.conversationId);let t=await v(`/api/conversations/${e.conversationId}/messages?limit=200`);if(!t.ok)return;let n=await t.json();if(!n?.length)return;i(n.filter(e=>e.role===`user`||e.role===`assistant`).map(T)),m(n.length>=200)}catch{}},[T]),ee=(0,j.useCallback)(async()=>{if(!(y.current||!g.current)){y.current=!0;try{let e=r[0]?.id;if(!e)return;let t=await v(`/api/conversations/${g.current}/messages?before=${e}&limit=100`);if(!t.ok)return;let n=await t.json();if(!n?.length){m(!1);return}let a=n.filter(e=>e.role===`user`||e.role===`assistant`).map(T);i(e=>[...a,...e]),n.length<100&&m(!1)}catch{}finally{y.current=!1}}},[r,T]);(0,j.useEffect)(()=>{!n||h.current||(h.current=!0,E())},[n,E]),(0,j.useEffect)(()=>{n&&t&&t>0&&E()},[n,t,E]),(0,j.useEffect)(()=>{if(!n||!t||t===0||!s)return;let e=setInterval(()=>{if(!_.current){clearInterval(e);return}E()},3e3);return()=>clearInterval(e)},[n,t,s,E]),(0,j.useEffect)(()=>{if(!e)return;let t=[e.on(`bot:typing`,()=>{c(!0),f([])}),e.on(`bot:token`,e=>{c(!0),u(t=>{let n=t+e.token;return b.current=n,n})}),e.on(`bot:tool`,e=>{let t=b.current;t&&(x.current+=t.length,i(e=>[...e,{id:`tool-`+Date.now(),role:`assistant`,content:t,timestamp:new Date().toISOString()}]),u(``),b.current=``),f(t=>t.find(t=>t.name===e.name&&t.status===`running`)?t:[...t,{name:e.name,status:`running`}])}),e.on(`bot:response`,e=>{if(g.current&&e.conversationId!==g.current)return;o(e.conversationId);let t=e.content||``;x.current>0&&(t=t.slice(x.current).replace(/^\n+/,``),x.current=0),t.trim()&&i(n=>[...n,{id:e.messageId||Date.now().toString(),role:`assistant`,content:t,timestamp:new Date().toISOString()}]),u(``),b.current=``,f([])}),e.on(`bot:task-created`,()=>{let e=b.current;e&&(x.current+=e.length,i(t=>[...t,{id:`pre-task-`+Date.now(),role:`assistant`,content:e,timestamp:new Date().toISOString()}]),u(``),b.current=``)}),e.on(`bot:idle`,()=>{c(!1)}),e.on(`bot:error`,e=>{u(``),b.current=``,c(!1),f([]),i(t=>[...t,{id:Date.now().toString(),role:`assistant`,content:`Error: ${e.error}`,timestamp:new Date().toISOString()}])}),e.on(`chat:sync`,e=>{g.current&&e.conversationId!==g.current||i(t=>[...t,{id:Date.now().toString(),role:e.message.role,content:e.message.content,timestamp:e.message.timestamp,hasAttachments:!!e.message.attachments?.length,attachments:e.message.attachments}])}),e.on(`chat:conversation-created`,e=>{o(e.conversationId)}),e.on(`chat:state`,e=>{e.streaming&&(c(!0),e.conversationId&&o(e.conversationId),e.buffer&&u(e.buffer))}),e.on(`chat:cleared`,()=>{i([]),o(null),u(``),c(!1),f([]),h.current=!1})];return()=>t.forEach(e=>e())},[e]);let D=(0,j.useCallback)(e=>{let t=`pending-audio-`+Date.now();S.current=t,i(n=>[...n,{id:t,role:`user`,content:``,timestamp:new Date().toISOString(),audioData:e.startsWith(`data:`)?e:`data:audio/webm;base64,${e}`,transcribing:!0}])},[]);return{messages:r,streaming:s,streamBuffer:l,conversationId:a,tools:d,hasMore:p,loadOlder:ee,sendMessage:(0,j.useCallback)((t,n,r)=>{if(!e||!t.trim()&&(!n||n.length===0)&&!r)return;let o=b.current;o&&(x.current+=o.length,i(e=>[...e,{id:`partial-`+Date.now(),role:`assistant`,content:o,timestamp:new Date().toISOString()}]),u(``),b.current=``);let s=S.current;if(r&&s)S.current=null,i(e=>e.map(e=>e.id===s?{...e,content:t,transcribing:!1,hasAttachments:!!(n&&n.length>0)}:e));else{let e={id:Date.now().toString(),role:`user`,content:t,timestamp:new Date().toISOString(),hasAttachments:!!(n&&n.length>0),audioData:r?r.startsWith(`data:`)?r:`data:audio/webm;base64,${r}`:void 0};i(t=>[...t,e])}let c=t;if(w.current&&C.current){let e=C.current,n=[`[Page: ${e.url}`];e.title&&(n[0]+=` | ${e.title}`),e.productName&&(n[0]+=` | ${e.productName}`),e.price&&(n[0]+=` | ${e.currency||`$`}${e.price}`),n[0]+=`]`,e.selection&&n.push(`[Selected: ${e.selection}]`),e.hasForms&&n.push(`[Page has ${e.formCount} form(s)]`),c=n.join(`
|
|
3
3
|
`)+`
|
|
4
4
|
`+t,window.parent?.postMessage({type:`bloby:request-context`},`*`)}let l={conversationId:a,content:c};r&&(l.audioData=r.includes(`,`)?r.split(`,`)[1]:r),n?.length&&(l.attachments=n.map(e=>{let t=e.preview.match(/^data:([^;]+);base64,(.+)$/);return{type:e.type,name:e.name,mediaType:t?.[1]||`application/octet-stream`,data:t?.[2]||``}})),e.send(`user:message`,l)},[e,a]),addPendingAudio:D,stopStreaming:(0,j.useCallback)(()=>{e&&(e.send(`user:stop`,{conversationId:a}),c(!1),u(``),b.current=``,x.current=0,f([]))},[e,a]),clearContext:(0,j.useCallback)(()=>{e&&e.send(`user:clear-context`,{}),i([]),o(null),u(``),b.current=``,x.current=0,c(!1),f([]),h.current=!1},[e])}}var M=a(),Ee=`bloby_login_totp`;function De({onLogin:e,totpEnabled:t}){let[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(``),[s,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(`password`),[f,p]=(0,j.useState)(``),[m,_]=(0,j.useState)(``),[v,y]=(0,j.useState)(!0),[b,S]=(0,j.useState)(!1),C=(0,j.useRef)(null);(0,j.useEffect)(()=>{try{let e=sessionStorage.getItem(Ee);if(!e)return;let t=JSON.parse(e);t.pendingToken&&t.expiresAt>Date.now()?(_(t.pendingToken),d(`totp`)):sessionStorage.removeItem(Ee)}catch{}},[]),(0,j.useEffect)(()=>{u===`totp`&&setTimeout(()=>C.current?.focus(),100)},[u]);function T(e){try{sessionStorage.setItem(Ee,JSON.stringify({pendingToken:e,expiresAt:Date.now()+4.5*60*1e3}))}catch{}}function E(){try{sessionStorage.removeItem(Ee)}catch{}}let ee=async()=>{if(!(!n.trim()||s)){l(!0),a(``);try{let t=btoa(`admin:${n}`),r=await fetch(`/api/portal/login`,{headers:{Authorization:`Basic ${t}`},credentials:`include`}),i=await r.json();r.ok&&i.token?(E(),e(i.token)):r.ok&&i.requiresTOTP?(_(i.pendingToken),T(i.pendingToken),d(`totp`),a(``)):a(i.error||`Invalid password`)}catch{a(`Could not reach server`)}finally{l(!1)}}},D=async()=>{if(!(!f.trim()||s)){l(!0),a(``);try{let t=await fetch(`/api/portal/login/totp?pending=${encodeURIComponent(m)}&code=${encodeURIComponent(f)}&trust=${v?`1`:`0`}`,{credentials:`include`}),n=await t.json();t.ok&&n.token?(E(),e(n.token)):a(n.error||`Invalid code`)}catch{a(`Could not reach server`)}finally{l(!1)}}},ne=e=>{e.key===`Enter`&&(u===`password`?ee():D())},re=()=>{d(`password`),a(``),p(``),S(!1),E()},ie=`w-full bg-white/[0.05] border border-white/[0.08] text-white rounded-xl px-4 py-3 text-base outline-none input-glow placeholder:text-white/20 transition-all`;return(0,M.jsx)(`div`,{className:`flex flex-col items-center justify-center h-dvh px-6`,children:(0,M.jsx)(`div`,{className:`w-full max-w-[320px] flex flex-col items-center`,children:(0,M.jsx)(w,{mode:`wait`,children:u===`password`?(0,M.jsxs)(x.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},className:`w-full flex flex-col items-center`,children:[(0,M.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-white/[0.04] border border-white/[0.08] flex items-center justify-center mb-5`,children:(0,M.jsx)(pe,{className:`h-6 w-6 text-white/40`})}),(0,M.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:`Welcome back`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[13px] mb-6`,children:`Enter your password to continue.`}),i&&(0,M.jsx)(`div`,{className:`w-full bg-red-500/8 border border-red-500/15 rounded-xl px-4 py-2.5 mb-4`,children:(0,M.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:i})}),(0,M.jsx)(`input`,{type:`password`,value:n,onChange:e=>r(e.target.value),onKeyDown:ne,placeholder:`Password`,autoFocus:!0,autoComplete:`current-password`,className:ie}),(0,M.jsx)(`button`,{onClick:ee,disabled:!n.trim()||s,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:s?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(g,{className:`h-4 w-4 animate-spin`}),`Signing in...`]}):(0,M.jsxs)(M.Fragment,{children:[`Sign In`,(0,M.jsx)(o,{className:`h-4 w-4`})]})})]},`password`):(0,M.jsxs)(x.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:20},transition:{duration:.2},className:`w-full flex flex-col items-center`,children:[(0,M.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-[#0069FE]/10 border border-[#0069FE]/20 flex items-center justify-center mb-5`,children:(0,M.jsx)(h,{className:`h-6 w-6 text-[#0069FE]`})}),(0,M.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:b?`Recovery code`:`Enter your 2FA code`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[13px] mb-6`,children:b?`Enter one of your recovery codes.`:`Open your authenticator app and enter the 6-digit code.`}),i&&(0,M.jsx)(`div`,{className:`w-full bg-red-500/8 border border-red-500/15 rounded-xl px-4 py-2.5 mb-4`,children:(0,M.jsx)(`p`,{className:`text-red-400/90 text-[12px]`,children:i})}),(0,M.jsx)(`input`,{ref:C,type:`text`,inputMode:b?`text`:`numeric`,autoComplete:`one-time-code`,maxLength:b?20:6,value:f,onChange:e=>{p(b?e.target.value:e.target.value.replace(/\D/g,``)),a(``)},onKeyDown:ne,placeholder:b?`Recovery code`:`000000`,autoFocus:!0,className:ie+(b?``:` tracking-[0.3em] text-center font-mono`)}),(0,M.jsxs)(`label`,{className:`flex items-center gap-2.5 mt-4 w-full cursor-pointer`,children:[(0,M.jsx)(`div`,{onClick:()=>y(e=>!e),className:`w-5 h-5 rounded-md border flex items-center justify-center transition-all ${v?`bg-[#0069FE] border-[#0069FE]`:`bg-white/[0.04] border-white/[0.12]`}`,children:v&&(0,M.jsx)(c,{className:`h-3.5 w-3.5 text-white`})}),(0,M.jsx)(`span`,{className:`text-[13px] text-white/50`,children:`Trust this device for 90 days`})]}),(0,M.jsx)(`button`,{onClick:D,disabled:!f.trim()||s,className:`w-full mt-4 py-3 bg-gradient-brand hover:opacity-90 text-white text-[14px] font-semibold rounded-full transition-colors flex items-center justify-center gap-2 disabled:opacity-40`,children:s?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(g,{className:`h-4 w-4 animate-spin`}),`Verifying...`]}):(0,M.jsxs)(M.Fragment,{children:[`Verify`,(0,M.jsx)(o,{className:`h-4 w-4`})]})}),(0,M.jsxs)(`div`,{className:`flex items-center gap-4 mt-4`,children:[(0,M.jsxs)(`button`,{onClick:re,className:`text-[12px] text-white/30 hover:text-white/50 flex items-center gap-1 transition-colors`,children:[(0,M.jsx)(te,{className:`h-3 w-3`}),`Back`]}),(0,M.jsx)(`button`,{onClick:()=>{S(e=>!e),p(``),a(``)},className:`text-[12px] text-white/30 hover:text-white/50 transition-colors`,children:b?`Use authenticator code`:`Use a recovery code`})]})]},`totp`)})})})}var Oe=(function(e){if(e==null)return Ne;if(typeof e==`function`)return Me(e);if(typeof e==`object`)return Array.isArray(e)?ke(e):Ae(e);if(typeof e==`string`)return je(e);throw Error(`Expected function, string, or object as test`)});function ke(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Oe(e[n]);return Me(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Ae(e){let t=e;return Me(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function je(e){return Me(t);function t(t){return t&&t.type===e}}function Me(e){return t;function t(t,n,r){return!!(Pe(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function Ne(){return!0}function Pe(e){return typeof e==`object`&&!!e&&`type`in e}function Fe(e){return e}var Ie=[],Le=`skip`;function Re(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Oe(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+Fe(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=Ie,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=ze(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function ze(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Ie:[e]}function Be(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),Re(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var Ve={indicator:`indicator`,textOnly:`text-only`,remove:`remove`};function He({defaultOrigin:e=``,allowedLinkPrefixes:t=[],allowedImagePrefixes:n=[],allowDataImages:r=!1,allowedProtocols:i=[],blockedImageClass:a=`inline-block bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-400 px-3 py-1 rounded text-sm`,blockedLinkClass:o=`text-gray-500`,linkBlockPolicy:s=Ve.indicator,imageBlockPolicy:c=Ve.indicator}){let l=t.length&&!t.every(e=>e===`*`),u=n.length&&!n.every(e=>e===`*`);if(!e&&(l||u))throw Error(`defaultOrigin is required when allowedLinkPrefixes or allowedImagePrefixes are provided`);return l=>{let u=Qe(e,t,n,r,i,a,o,s,c);Je(l),Be(l,u)}}function Ue(e,t){if(typeof e!=`string`)return null;try{return new URL(e)}catch{if(t)try{return new URL(e,t)}catch{return null}if(e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`))try{return new URL(e,`http://example.com`)}catch{return null}return null}}function We(e){return typeof e==`string`?e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`):!1}var Ge=new Set([`https:`,`http:`,`irc:`,`ircs:`,`mailto:`,`xmpp:`,`blob:`]),Ke=new Set([`javascript:`,`data:`,`file:`,`vbscript:`]);function qe(e,t,n,r=!1,i=!1,a=[]){if(!e)return null;if(typeof e==`string`&&e.startsWith(`#`)&&!i)try{if(new URL(e,`http://example.com`).hash===e)return e}catch{}if(typeof e==`string`&&e.startsWith(`data:`))return i&&r&&e.startsWith(`data:image/`)?e:null;if(typeof e==`string`&&e.startsWith(`blob:`)){try{if(new URL(e).protocol===`blob:`&&e.length>5){let t=e.substring(5);if(t&&t.length>0&&t!==`invalid`)return e}}catch{return null}return null}let o=Ue(e,n);if(!o||Ke.has(o.protocol)||!(Ge.has(o.protocol)||a.includes(o.protocol)||a.includes(`*`)))return null;if(o.protocol===`mailto:`||!o.protocol.match(/^https?:$/))return o.href;let s=We(e);return o&&t.some(e=>{let t=Ue(e,n);return!t||t.origin!==o.origin?!1:o.href.startsWith(t.href)})?s?o.pathname+o.search+o.hash:o.href:t.includes(`*`)?o.protocol!==`https:`&&o.protocol!==`http:`?null:s?o.pathname+o.search+o.hash:o.href:null}function Je(e){if(`children`in e&&Array.isArray(e.children)){e.children=e.children.filter(e=>e!=null);for(let t of e.children)Je(t)}}var Ye=Symbol(`node-seen`);function Xe(e,t,n){return t===Ve.remove?{type:`remove`}:t===Ve.textOnly?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[...e.children]}}:{type:`replace`,element:{type:`element`,tagName:`span`,properties:{title:`Blocked URL: `+String(e.properties.href),class:n},children:[...e.children,{type:`text`,value:` [blocked]`}]}}}function Ze(e,t,n){if(t===Ve.remove)return{type:`remove`};if(t===Ve.textOnly){let t=String(e.properties.alt||``);return t?{type:`replace`,element:{type:`element`,tagName:`span`,properties:{},children:[{type:`text`,value:t}]}}:{type:`remove`}}return{type:`replace`,element:{type:`element`,tagName:`span`,properties:{class:n},children:[{type:`text`,value:`[Image blocked: `+String(e.properties.alt||`No description`)+`]`}]}}}var Qe=(e,t,n,r,i,a,o,s,c)=>{let l=(u,d,f)=>{if(u.type!==`element`||u[Ye])return!0;if(u.tagName===`a`){let n=qe(u.properties.href,t,e,!1,!1,i);if(n===null){if(u[Ye]=!0,Be(u,l),f&&typeof d==`number`){let e=Xe(u,s,o);if(e.type===`remove`)return f.children.splice(d,1),[Le,d];f.children[d]=e.element}return Le}else return u.properties.href=n,u.properties.target=`_blank`,u.properties.rel=`noopener noreferrer`,!0}if(u.tagName===`img`){let t=qe(u.properties.src,n,e,r,!0,i);if(t===null){if(u[Ye]=!0,Be(u,l),f&&typeof d==`number`){let e=Ze(u,c,a);if(e.type===`remove`)return f.children.splice(d,1),[Le,d];f.children[d]=e.element}return Le}else return u.properties.src=t,!0}return!0};return l},$e=typeof self==`object`?self:globalThis,et=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new $e[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new $e[a](o),i)};return r},tt=e=>et(new Map,e)(0),nt=``,{toString:rt}={},{keys:it}=Object,at=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=rt.call(e).slice(8,-1);switch(n){case`Array`:return[1,nt];case`Object`:return[2,nt];case`Date`:return[3,nt];case`RegExp`:return[4,nt];case`Map`:return[5,nt];case`Set`:return[6,nt];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},ot=([e,t])=>e===0&&(t===`function`||t===`symbol`),st=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=at(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of it(r))(e||!ot(at(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(ot(at(n))||ot(at(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!ot(at(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},ct=(e,{json:t,lossy:n}={})=>{let r=[];return st(!(t||n),!!t,new Map,r)(e),r},lt=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?tt(ct(e,t)):structuredClone(e):(e,t)=>tt(ct(e,t)),ut=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ut.prototype.normal={},ut.prototype.property={},ut.prototype.space=void 0;function dt(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ut(n,r,t)}function ft(e){return e.toLowerCase()}var pt=class{constructor(e,t){this.attribute=t,this.property=e}};pt.prototype.attribute=``,pt.prototype.booleanish=!1,pt.prototype.boolean=!1,pt.prototype.commaOrSpaceSeparated=!1,pt.prototype.commaSeparated=!1,pt.prototype.defined=!1,pt.prototype.mustUseProperty=!1,pt.prototype.number=!1,pt.prototype.overloadedBoolean=!1,pt.prototype.property=``,pt.prototype.spaceSeparated=!1,pt.prototype.space=void 0;var mt=r({boolean:()=>N,booleanish:()=>gt,commaOrSpaceSeparated:()=>bt,commaSeparated:()=>yt,number:()=>P,overloadedBoolean:()=>_t,spaceSeparated:()=>vt}),ht=0,N=xt(),gt=xt(),_t=xt(),P=xt(),vt=xt(),yt=xt(),bt=xt();function xt(){return 2**++ht}var St=Object.keys(mt),Ct=class extends pt{constructor(e,t,n,r){let i=-1;if(super(e,t),wt(this,`space`,r),typeof n==`number`)for(;++i<St.length;){let e=St[i];wt(this,St[i],(n&mt[e])===mt[e])}}};Ct.prototype.defined=!0;function wt(e,t,n){n&&(e[t]=n)}function Tt(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Ct(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ft(r)]=r,n[ft(a.attribute)]=r}return new ut(t,n,e.space)}var Et=Tt({properties:{ariaActiveDescendant:null,ariaAtomic:gt,ariaAutoComplete:null,ariaBusy:gt,ariaChecked:gt,ariaColCount:P,ariaColIndex:P,ariaColSpan:P,ariaControls:vt,ariaCurrent:null,ariaDescribedBy:vt,ariaDetails:null,ariaDisabled:gt,ariaDropEffect:vt,ariaErrorMessage:null,ariaExpanded:gt,ariaFlowTo:vt,ariaGrabbed:gt,ariaHasPopup:null,ariaHidden:gt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:vt,ariaLevel:P,ariaLive:null,ariaModal:gt,ariaMultiLine:gt,ariaMultiSelectable:gt,ariaOrientation:null,ariaOwns:vt,ariaPlaceholder:null,ariaPosInSet:P,ariaPressed:gt,ariaReadOnly:gt,ariaRelevant:null,ariaRequired:gt,ariaRoleDescription:vt,ariaRowCount:P,ariaRowIndex:P,ariaRowSpan:P,ariaSelected:gt,ariaSetSize:P,ariaSort:null,ariaValueMax:P,ariaValueMin:P,ariaValueNow:P,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Dt(e,t){return t in e?e[t]:t}function Ot(e,t){return Dt(e,t.toLowerCase())}var kt=Tt({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:yt,acceptCharset:vt,accessKey:vt,action:null,allow:null,allowFullScreen:N,allowPaymentRequest:N,allowUserMedia:N,alt:null,as:null,async:N,autoCapitalize:null,autoComplete:vt,autoFocus:N,autoPlay:N,blocking:vt,capture:null,charSet:null,checked:N,cite:null,className:vt,cols:P,colSpan:null,content:null,contentEditable:gt,controls:N,controlsList:vt,coords:P|yt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:N,defer:N,dir:null,dirName:null,disabled:N,download:_t,draggable:gt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:N,formTarget:null,headers:vt,height:P,hidden:_t,high:P,href:null,hrefLang:null,htmlFor:vt,httpEquiv:vt,id:null,imageSizes:null,imageSrcSet:null,inert:N,inputMode:null,integrity:null,is:null,isMap:N,itemId:null,itemProp:vt,itemRef:vt,itemScope:N,itemType:vt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:N,low:P,manifest:null,max:null,maxLength:P,media:null,method:null,min:null,minLength:P,multiple:N,muted:N,name:null,nonce:null,noModule:N,noValidate:N,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:N,optimum:P,pattern:null,ping:vt,placeholder:null,playsInline:N,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:N,referrerPolicy:null,rel:vt,required:N,reversed:N,rows:P,rowSpan:P,sandbox:vt,scope:null,scoped:N,seamless:N,selected:N,shadowRootClonable:N,shadowRootDelegatesFocus:N,shadowRootMode:null,shape:null,size:P,sizes:null,slot:null,span:P,spellCheck:gt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:P,step:null,style:null,tabIndex:P,target:null,title:null,translate:null,type:null,typeMustMatch:N,useMap:null,value:gt,width:P,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:vt,axis:null,background:null,bgColor:null,border:P,borderColor:null,bottomMargin:P,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:N,declare:N,event:null,face:null,frame:null,frameBorder:null,hSpace:P,leftMargin:P,link:null,longDesc:null,lowSrc:null,marginHeight:P,marginWidth:P,noResize:N,noHref:N,noShade:N,noWrap:N,object:null,profile:null,prompt:null,rev:null,rightMargin:P,rules:null,scheme:null,scrolling:gt,standby:null,summary:null,text:null,topMargin:P,valueType:null,version:null,vAlign:null,vLink:null,vSpace:P,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:N,disableRemotePlayback:N,prefix:null,property:null,results:P,security:null,unselectable:null},space:`html`,transform:Ot}),At=Tt({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:bt,accentHeight:P,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:P,amplitude:P,arabicForm:null,ascent:P,attributeName:null,attributeType:null,azimuth:P,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:P,by:null,calcMode:null,capHeight:P,className:vt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:P,diffuseConstant:P,direction:null,display:null,dur:null,divisor:P,dominantBaseline:null,download:N,dx:null,dy:null,edgeMode:null,editable:null,elevation:P,enableBackground:null,end:null,event:null,exponent:P,externalResourcesRequired:null,fill:null,fillOpacity:P,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:yt,g2:yt,glyphName:yt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:P,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:P,horizOriginX:P,horizOriginY:P,id:null,ideographic:P,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:P,k:P,k1:P,k2:P,k3:P,k4:P,kernelMatrix:bt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:P,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:P,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:P,overlineThickness:P,paintOrder:null,panose1:null,path:null,pathLength:P,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:vt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:P,pointsAtY:P,pointsAtZ:P,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bt,rev:bt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bt,requiredFeatures:bt,requiredFonts:bt,requiredFormats:bt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:P,specularExponent:P,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:P,strikethroughThickness:P,string:null,stroke:null,strokeDashArray:bt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:P,strokeOpacity:P,strokeWidth:null,style:null,surfaceScale:P,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bt,tabIndex:P,tableValues:null,target:null,targetX:P,targetY:P,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:P,underlineThickness:P,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:P,values:null,vAlphabetic:P,vMathematical:P,vectorEffect:null,vHanging:P,vIdeographic:P,version:null,vertAdvY:P,vertOriginX:P,vertOriginY:P,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:P,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Dt}),jt=Tt({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Mt=Tt({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Ot}),Nt=Tt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Pt={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Ft=/[A-Z]/g,It=/-[a-z]/g,Lt=/^data[-\w.:]+$/i;function Rt(e,t){let n=ft(t),r=t,i=pt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Lt.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(It,Bt);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!It.test(e)){let n=e.replace(Ft,zt);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Ct}return new i(r,t)}function zt(e){return`-`+e.toLowerCase()}function Bt(e){return e.charAt(1).toUpperCase()}var Vt=dt([Et,kt,jt,Mt,Nt],`html`),Ht=dt([Et,At,jt,Mt,Nt],`svg`);function Ut(e){let t=[],n=String(e||``),r=n.indexOf(`,`),i=0,a=!1;for(;!a;){r===-1&&(r=n.length,a=!0);let e=n.slice(i,r).trim();(e||!a)&&t.push(e),i=r+1,r=n.indexOf(`,`,i)}return t}function Wt(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var Gt=/[#.]/g;function Kt(e,t){let n=e||``,r={},i=0,a,o;for(;i<n.length;){Gt.lastIndex=i;let e=Gt.exec(n),t=n.slice(i,e?e.index:n.length);t&&(a?a===`#`?r.id=t:Array.isArray(r.className)?r.className.push(t):r.className=[t]:o=t,i+=t.length),e&&(a=e[0],i++)}return{type:`element`,tagName:o||t||`div`,properties:r,children:[]}}function qt(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Jt(e){return e.join(` `).trim()}function Yt(e,t,n){let r=n?tn(n):void 0;function i(n,i,...a){let o;if(n==null){o={type:`root`,children:[]};let e=i;a.unshift(e)}else{o=Kt(n,t);let s=o.tagName.toLowerCase(),c=r?r.get(s):void 0;if(o.tagName=c||s,Xt(i))a.unshift(i);else for(let[t,n]of Object.entries(i))Zt(e,o.properties,t,n)}for(let e of a)Qt(o.children,e);return o.type===`element`&&o.tagName===`template`&&(o.content={type:`root`,children:o.children},o.children=[]),o}return i}function Xt(e){if(typeof e!=`object`||!e||Array.isArray(e))return!0;if(typeof e.type!=`string`)return!1;let t=e,n=Object.keys(e);for(let e of n){let n=t[e];if(n&&typeof n==`object`){if(!Array.isArray(n))return!0;let e=n;for(let t of e)if(typeof t!=`number`&&typeof t!=`string`)return!0}}return!!(`children`in e&&Array.isArray(e.children))}function Zt(e,t,n,r){let i=Rt(e,n),a;if(r!=null){if(typeof r==`number`){if(Number.isNaN(r))return;a=r}else a=typeof r==`boolean`?r:typeof r==`string`?i.spaceSeparated?qt(r):i.commaSeparated?Ut(r):i.commaOrSpaceSeparated?qt(Ut(r).join(` `)):$t(i,i.property,r):Array.isArray(r)?[...r]:i.property===`style`?en(r):String(r);if(Array.isArray(a)){let e=[];for(let t of a)e.push($t(i,i.property,t));a=e}i.property===`className`&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}function Qt(e,t){if(t!=null)if(typeof t==`number`||typeof t==`string`)e.push({type:`text`,value:String(t)});else if(Array.isArray(t))for(let n of t)Qt(e,n);else if(typeof t==`object`&&`type`in t)t.type===`root`?Qt(e,t.children):e.push(t);else throw Error("Expected node, nodes, or string, got `"+t+"`")}function $t(e,t,n){if(typeof n==`string`){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===``||ft(n)===ft(t)))return!0}return n}function en(e){let t=[];for(let[n,r]of Object.entries(e))t.push([n,r].join(`: `));return t.join(`; `)}function tn(e){let t=new Map;for(let n of e)t.set(n.toLowerCase(),n);return t}var nn=`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.solidColor.textArea.textPath`.split(`.`),rn=Yt(Vt,`div`),an=Yt(Ht,`g`,nn);function on(e){let t=String(e),n=[];return{toOffset:i,toPoint:r};function r(e){if(typeof e==`number`&&e>-1&&e<=t.length){let r=0;for(;;){let i=n[r];if(i===void 0){let e=sn(t,n[r-1]);i=e===-1?t.length+1:e+1,n[r]=i}if(i>e)return{line:r+1,column:e-(r>0?n[r-1]:0)+1,offset:e};r++}}}function i(e){if(e&&typeof e.line==`number`&&typeof e.column==`number`&&!Number.isNaN(e.line)&&!Number.isNaN(e.column)){for(;n.length<e.line;){let e=n[n.length-1],r=sn(t,e),i=r===-1?t.length+1:r+1;if(e===i)break;n.push(i)}let r=(e.line>1?n[e.line-2]:0)+e.column-1;if(r<n[e.line-1])return r}}}function sn(e,t){let n=e.indexOf(`\r`,t),r=e.indexOf(`
|
|
@@ -111,14 +111,14 @@ ${e}</tr>
|
|
|
111
111
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${mb(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=hb(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+mb(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=hb(e);if(i===null)return mb(n);e=i;let a=`<img src="${e}" alt="${mb(n)}"`;return t&&(a+=` title="${mb(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:mb(e.text)}},Tb=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Eb=class e{options;renderer;textRenderer;constructor(e){this.options=e||ny,this.options.renderer=this.options.renderer||new wb,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Tb}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Db=class{options;block;constructor(e){this.options=e||ny}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Cb.lex:Cb.lexInline}provideParser(){return this.block?Eb.parse:Eb.parseInline}},Ob=new class{defaults=ty();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Eb;Renderer=wb;TextRenderer=Tb;Lexer=Cb;Tokenizer=Sb;Hooks=Db;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new wb(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Sb(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Db;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];Db.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&Db.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Cb.lex(e,t??this.defaults)}parser(e,t){return Eb.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?Cb.lex:Cb.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?Eb.parse:Eb.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?Cb.lex:Cb.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Eb.parse:Eb.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
112
112
|
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+mb(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function kb(e,t){return Ob.parse(e,t)}kb.options=kb.setOptions=function(e){return Ob.setOptions(e),kb.defaults=Ob.defaults,ry(kb.defaults),kb},kb.getDefaults=ty,kb.defaults=ny,kb.use=function(...e){return Ob.use(...e),kb.defaults=Ob.defaults,ry(kb.defaults),kb},kb.walkTokens=function(e,t){return Ob.walkTokens(e,t)},kb.parseInline=Ob.parseInline,kb.Parser=Eb,kb.parser=Eb.parse,kb.Renderer=wb,kb.TextRenderer=Tb,kb.Lexer=Cb,kb.lexer=Cb.lex,kb.Tokenizer=Sb,kb.Hooks=Db,kb.parse=kb,kb.options,kb.setOptions,kb.use,kb.walkTokens,kb.parseInline,Eb.parse,Cb.lex;var Ab=`modulepreload`,jb=function(e){return`/bloby/`+e},Mb={},Z=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=jb(t,n),t in Mb)return;Mb[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Ab,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Nb=300,Pb=`300px`,Fb=500;function Ib(e={}){let{immediate:t=!1,debounceDelay:n=Nb,rootMargin:r=Pb,idleTimeout:i=Fb}=e,[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)(null),u=(0,j.useMemo)(()=>e=>{let t=Date.now();return window.setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)},[]),d=(0,j.useMemo)(()=>typeof window<`u`&&window.requestIdleCallback?(e,t)=>window.requestIdleCallback(e,t):u,[u]),f=(0,j.useMemo)(()=>typeof window<`u`&&window.cancelIdleCallback?e=>window.cancelIdleCallback(e):e=>{clearTimeout(e)},[]);return(0,j.useEffect)(()=>{if(t){o(!0);return}let e=s.current;if(!e)return;c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null);let a=()=>{c.current&&=(clearTimeout(c.current),null),l.current&&=(f(l.current),null)},u=e=>{l.current=d(t=>{t.timeRemaining()>0||t.didTimeout?(o(!0),e.disconnect()):l.current=d(()=>{o(!0),e.disconnect()},{timeout:i/2})},{timeout:i})},p=e=>{a(),c.current=window.setTimeout(()=>{var t;let n=e.takeRecords();(n.length===0||(t=n.at(-1)?.isIntersecting)!=null&&t)&&u(e)},n)},m=(e,t)=>{e.isIntersecting?p(t):a()},h=new IntersectionObserver(e=>{for(let t of e)m(t,h)},{rootMargin:r,threshold:0});return h.observe(e),()=>{c.current&&clearTimeout(c.current),l.current&&f(l.current),h.disconnect()}},[t,n,r,i,f,d]),{shouldRender:a,containerRef:s}}var Lb=/\s/,Rb=/^\s+$/,zb=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),Bb=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,Vb=e=>e.some(e=>Bb(e)&&zb.has(e.tagName)),Hb=e=>{let t=[],n=``,r=!1;for(let i of e){let e=Lb.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},Ub=e=>{let t=[],n=``;for(let r of e)Lb.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},Wb=(e,t,n,r,i,a)=>{let o=`--sd-animation:sd-${t};--sd-duration:${i?0:n}ms;--sd-easing:${r}`;return a&&(o+=`;--sd-delay:${a}ms`),{type:`element`,tagName:`span`,properties:{"data-sd-animate":!0,style:o},children:[{type:`text`,value:e}]}},Gb=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(Vb(t))return Le;let o=a,s=o.children.indexOf(e);if(s===-1)return;let c=e.value;if(!c.trim()){i.count+=c.length;return}let l=n.sep===`char`?Ub(c):Hb(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,Rb.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return Wb(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},Kb=0;function qb(e){let t={animation:e?.animation??`fadeIn`,duration:e?.duration??150,easing:e?.easing??`ease`,sep:e?.sep??`word`,stagger:e?.stagger??40},n={prevContentLength:0,lastRenderCharCount:0},r=Kb++,i=()=>e=>{let r={count:0,newIndex:0};Re(e,`text`,(e,i)=>Gb(e,i,t,n,r)),n.lastRenderCharCount=r.count,n.prevContentLength=0};return Object.defineProperty(i,`name`,{value:`rehypeAnimate$${r}`}),{name:`animate`,type:`animate`,rehypePlugin:i,setPrevContentLength(e){n.prevContentLength=e},getLastRenderCharCount(){let e=n.lastRenderCharCount;return n.lastRenderCharCount=0,e}}}qb();var Jb=(0,j.createContext)(!1),Yb=()=>(0,j.useContext)(Jb),Xb=(...e)=>Jh(Tm(e)),Zb=(e,t)=>{if(!e||!t)return t;let n=`${e}:`;return t.split(/\s+/).filter(Boolean).map(t=>t.startsWith(n)?t:`${e}:${t}`).join(` `)},Qb=e=>e?(...t)=>Zb(e,Jh(Tm(t))):Xb,$b=(e,t,n)=>{let r=typeof t==`string`&&n.startsWith(`text/csv`)?``:``,i=typeof t==`string`?new Blob([r+t],{type:n}):t,a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)},ex=(0,j.createContext)(Xb),Q=()=>(0,j.useContext)(ex),tx=Xb(`block`,`before:content-[counter(line)]`,`before:inline-block`,`before:[counter-increment:line]`,`before:w-6`,`before:mr-4`,`before:text-[13px]`,`before:text-right`,`before:text-muted-foreground/50`,`before:font-mono`,`before:select-none`),nx=e=>{let t={};for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}}return t},rx=(0,j.memo)(({children:e,result:t,language:n,className:r,startLine:i,lineNumbers:a=!0,...o})=>{let s=Q(),c=(0,j.useMemo)(()=>s(tx),[s]),l=(0,j.useMemo)(()=>{let e={};return t.bg&&(e[`--sdm-bg`]=t.bg),t.fg&&(e[`--sdm-fg`]=t.fg),t.rootStyle&&Object.assign(e,nx(t.rootStyle)),e},[t.bg,t.fg,t.rootStyle]);return(0,M.jsx)(`div`,{className:s(r,`overflow-x-auto rounded-md border border-border bg-background p-4 text-sm`),"data-language":n,"data-streamdown":`code-block-body`,...o,children:(0,M.jsx)(`pre`,{className:s(r,`bg-[var(--sdm-bg,inherit]`,`dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]`),style:l,children:(0,M.jsx)(`code`,{className:a?s(`[counter-increment:line_0] [counter-reset:line]`):void 0,style:a&&i&&i>1?{counterReset:`line ${i-1}`}:void 0,children:t.tokens.map((e,t)=>(0,M.jsx)(`span`,{className:a?c:void 0,children:e.length===0||e.length===1&&e[0].content===``?`
|
|
113
113
|
`:e.map((e,t)=>{let n={},r=!!e.bgColor;if(e.color&&(n[`--sdm-c`]=e.color),e.bgColor&&(n[`--sdm-tbg`]=e.bgColor),e.htmlStyle)for(let[t,i]of Object.entries(e.htmlStyle))t===`color`?n[`--sdm-c`]=i:t===`background-color`?(n[`--sdm-tbg`]=i,r=!0):n[t]=i;return(0,M.jsx)(`span`,{className:s(`text-[var(--sdm-c,inherit)]`,`dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]`,r&&`bg-[var(--sdm-tbg)]`,r&&`dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]`),style:n,...e.htmlAttrs,children:e.content},t)})},t))})})})},(e,t)=>e.result===t.result&&e.language===t.language&&e.className===t.className&&e.startLine===t.startLine&&e.lineNumbers===t.lineNumbers),ix=({className:e,language:t,style:n,isIncomplete:r,...i})=>(0,M.jsx)(`div`,{className:Q()(`my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,e),"data-incomplete":r||void 0,"data-language":t,"data-streamdown":`code-block`,style:{contentVisibility:`auto`,containIntrinsicSize:`auto 200px`,...n},...i}),ax=(0,j.createContext)({code:``}),ox=()=>(0,j.useContext)(ax),sx=({language:e})=>{let t=Q();return(0,M.jsx)(`div`,{className:t(`flex h-8 items-center text-muted-foreground text-xs`),"data-language":e,"data-streamdown":`code-block-header`,children:(0,M.jsx)(`span`,{className:t(`ml-1 font-mono lowercase`),children:e})})},cx=e=>{let t=e.length;for(;t>0&&e[t-1]===`
|
|
114
|
-
`;)t--;return e.slice(0,t)},lx=(0,j.lazy)(()=>Z(()=>import(`./highlighted-body-OFNGDK62-
|
|
114
|
+
`;)t--;return e.slice(0,t)},lx=(0,j.lazy)(()=>Z(()=>import(`./highlighted-body-OFNGDK62-D7cU1Y-Z.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),ux=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=Q(),l=(0,j.useMemo)(()=>cx(e),[e]),u=(0,j.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
|
|
115
115
|
`).map(e=>[{content:e,color:`inherit`,bgColor:`transparent`,htmlStyle:{},offset:0}])}),[l]);return(0,M.jsx)(ax.Provider,{value:{code:e},children:(0,M.jsxs)(ix,{isIncomplete:i,language:t,children:[(0,M.jsx)(sx,{language:t}),r?(0,M.jsx)(`div`,{className:c(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,M.jsx)(`div`,{className:c(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`code-block-actions`,children:r})}):null,(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(rx,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,M.jsx)(lx,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},dx={CheckIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z`,fill:`currentColor`,fillRule:`evenodd`})}),CopyIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),DownloadIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z`,fill:`currentColor`,fillRule:`evenodd`})}),ExternalLinkIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z`,fill:`currentColor`,fillRule:`evenodd`})}),Loader2Icon:e=>(0,M.jsxs)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:[(0,M.jsx)(`path`,{d:`M8 0V4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M8 16V12`,opacity:`0.5`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M3.29773 1.52783L5.64887 4.7639`,opacity:`0.9`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M12.7023 1.52783L10.3511 4.7639`,opacity:`0.1`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M12.7023 14.472L10.3511 11.236`,opacity:`0.4`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M3.29773 14.472L5.64887 11.236`,opacity:`0.6`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M15.6085 5.52783L11.8043 6.7639`,opacity:`0.2`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M0.391602 10.472L4.19583 9.23598`,opacity:`0.7`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M15.6085 10.4722L11.8043 9.2361`,opacity:`0.3`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,M.jsx)(`path`,{d:`M0.391602 5.52783L4.19583 6.7639`,opacity:`0.8`,stroke:`currentColor`,strokeWidth:`1.5`})]}),Maximize2Icon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z`,fill:`currentColor`,fillRule:`evenodd`})}),RotateCcwIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z`,fill:`currentColor`,fillRule:`evenodd`})}),XIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomInIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})}),ZoomOutIcon:e=>(0,M.jsx)(`svg`,{color:`currentColor`,height:16,strokeLinejoin:`round`,viewBox:`0 0 16 16`,width:16,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z`,fill:`currentColor`,fillRule:`evenodd`})})},fx=(0,j.createContext)(dx),px=(e,t)=>{if(e===t)return!0;if(!(e&&t))return e===t;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>e[n]===t[n]):!1},mx=({icons:e,children:t})=>{let n=(0,j.useRef)(e),r=(0,j.useRef)(e?{...dx,...e}:dx);px(n.current,e)||(n.current=e,r.current=e?{...dx,...e}:dx);let i=r.current;return(0,M.jsx)(fx.Provider,{value:i,children:t})},hx=()=>(0,j.useContext)(fx),gx={copyCode:`Copy Code`,downloadFile:`Download file`,downloadDiagram:`Download diagram`,downloadDiagramAsSvg:`Download diagram as SVG`,downloadDiagramAsPng:`Download diagram as PNG`,downloadDiagramAsMmd:`Download diagram as MMD`,viewFullscreen:`View fullscreen`,exitFullscreen:`Exit fullscreen`,mermaidFormatSvg:`SVG`,mermaidFormatPng:`PNG`,mermaidFormatMmd:`MMD`,copyTable:`Copy table`,copyTableAsMarkdown:`Copy table as Markdown`,copyTableAsCsv:`Copy table as CSV`,copyTableAsTsv:`Copy table as TSV`,downloadTable:`Download table`,downloadTableAsCsv:`Download table as CSV`,downloadTableAsMarkdown:`Download table as Markdown`,tableFormatMarkdown:`Markdown`,tableFormatCsv:`CSV`,tableFormatTsv:`TSV`,imageNotAvailable:`Image not available`,downloadImage:`Download image`,openExternalLink:`Open external link?`,externalLinkWarning:`You're about to visit an external website.`,close:`Close`,copyLink:`Copy link`,copied:`Copied`,openLink:`Open link`},_x=(0,j.createContext)(gx),vx=()=>(0,j.useContext)(_x),yx=({onCopy:e,onError:t,timeout:n=2e3,children:r,className:i,code:a,...o})=>{let s=Q(),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(0),{code:d}=ox(),{isAnimating:f}=(0,j.useContext)(TC),p=vx(),m=a??d,h=async()=>{var r;if(typeof window>`u`||!((r=navigator==null?void 0:navigator.clipboard)!=null&&r.writeText)){t?.(Error(`Clipboard API not available`));return}try{c||(await navigator.clipboard.writeText(m),l(!0),e?.(),u.current=window.setTimeout(()=>l(!1),n))}catch(e){t?.(e)}};(0,j.useEffect)(()=>()=>{window.clearTimeout(u.current)},[]);let g=hx(),_=c?g.CheckIcon:g.CopyIcon;return(0,M.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-copy-button`,disabled:f,onClick:h,title:p.copyCode,type:`button`,...o,children:r??(0,M.jsx)(_,{size:14})})},bx={"1c":`1c`,"1c-query":`1cq`,abap:`abap`,"actionscript-3":`as`,ada:`ada`,adoc:`adoc`,"angular-html":`html`,"angular-ts":`ts`,apache:`conf`,apex:`cls`,apl:`apl`,applescript:`applescript`,ara:`ara`,asciidoc:`adoc`,asm:`asm`,astro:`astro`,awk:`awk`,ballerina:`bal`,bash:`sh`,bat:`bat`,batch:`bat`,be:`be`,beancount:`beancount`,berry:`berry`,bibtex:`bib`,bicep:`bicep`,blade:`blade.php`,bsl:`bsl`,c:`c`,"c#":`cs`,"c++":`cpp`,cadence:`cdc`,cairo:`cairo`,cdc:`cdc`,clarity:`clar`,clj:`clj`,clojure:`clj`,"closure-templates":`soy`,cmake:`cmake`,cmd:`cmd`,cobol:`cob`,codeowners:`CODEOWNERS`,codeql:`ql`,coffee:`coffee`,coffeescript:`coffee`,"common-lisp":`lisp`,console:`sh`,coq:`v`,cpp:`cpp`,cql:`cql`,crystal:`cr`,cs:`cs`,csharp:`cs`,css:`css`,csv:`csv`,cue:`cue`,cypher:`cql`,d:`d`,dart:`dart`,dax:`dax`,desktop:`desktop`,diff:`diff`,docker:`dockerfile`,dockerfile:`dockerfile`,dotenv:`env`,"dream-maker":`dm`,edge:`edge`,elisp:`el`,elixir:`ex`,elm:`elm`,"emacs-lisp":`el`,erb:`erb`,erl:`erl`,erlang:`erl`,f:`f`,"f#":`fs`,f03:`f03`,f08:`f08`,f18:`f18`,f77:`f77`,f90:`f90`,f95:`f95`,fennel:`fnl`,fish:`fish`,fluent:`ftl`,for:`for`,"fortran-fixed-form":`f`,"fortran-free-form":`f90`,fs:`fs`,fsharp:`fs`,fsl:`fsl`,ftl:`ftl`,gdresource:`tres`,gdscript:`gd`,gdshader:`gdshader`,genie:`gs`,gherkin:`feature`,"git-commit":`gitcommit`,"git-rebase":`gitrebase`,gjs:`js`,gleam:`gleam`,"glimmer-js":`js`,"glimmer-ts":`ts`,glsl:`glsl`,gnuplot:`plt`,go:`go`,gql:`gql`,graphql:`graphql`,groovy:`groovy`,gts:`gts`,hack:`hack`,haml:`haml`,handlebars:`hbs`,haskell:`hs`,haxe:`hx`,hbs:`hbs`,hcl:`hcl`,hjson:`hjson`,hlsl:`hlsl`,hs:`hs`,html:`html`,"html-derivative":`html`,http:`http`,hxml:`hxml`,hy:`hy`,imba:`imba`,ini:`ini`,jade:`jade`,java:`java`,javascript:`js`,jinja:`jinja`,jison:`jison`,jl:`jl`,js:`js`,json:`json`,json5:`json5`,jsonc:`jsonc`,jsonl:`jsonl`,jsonnet:`jsonnet`,jssm:`jssm`,jsx:`jsx`,julia:`jl`,kotlin:`kt`,kql:`kql`,kt:`kt`,kts:`kts`,kusto:`kql`,latex:`tex`,lean:`lean`,lean4:`lean`,less:`less`,liquid:`liquid`,lisp:`lisp`,lit:`lit`,llvm:`ll`,log:`log`,logo:`logo`,lua:`lua`,luau:`luau`,make:`mak`,makefile:`mak`,markdown:`md`,marko:`marko`,matlab:`m`,md:`md`,mdc:`mdc`,mdx:`mdx`,mediawiki:`wiki`,mermaid:`mmd`,mips:`s`,mipsasm:`s`,mmd:`mmd`,mojo:`mojo`,move:`move`,nar:`nar`,narrat:`narrat`,nextflow:`nf`,nf:`nf`,nginx:`conf`,nim:`nim`,nix:`nix`,nu:`nu`,nushell:`nu`,objc:`m`,"objective-c":`m`,"objective-cpp":`mm`,ocaml:`ml`,pascal:`pas`,perl:`pl`,perl6:`p6`,php:`php`,plsql:`pls`,po:`po`,polar:`polar`,postcss:`pcss`,pot:`pot`,potx:`potx`,powerquery:`pq`,powershell:`ps1`,prisma:`prisma`,prolog:`pl`,properties:`properties`,proto:`proto`,protobuf:`proto`,ps:`ps`,ps1:`ps1`,pug:`pug`,puppet:`pp`,purescript:`purs`,py:`py`,python:`py`,ql:`ql`,qml:`qml`,qmldir:`qmldir`,qss:`qss`,r:`r`,racket:`rkt`,raku:`raku`,razor:`cshtml`,rb:`rb`,reg:`reg`,regex:`regex`,regexp:`regexp`,rel:`rel`,riscv:`s`,rs:`rs`,rst:`rst`,ruby:`rb`,rust:`rs`,sas:`sas`,sass:`sass`,scala:`scala`,scheme:`scm`,scss:`scss`,sdbl:`sdbl`,sh:`sh`,shader:`shader`,shaderlab:`shader`,shell:`sh`,shellscript:`sh`,shellsession:`sh`,smalltalk:`st`,solidity:`sol`,soy:`soy`,sparql:`rq`,spl:`spl`,splunk:`spl`,sql:`sql`,"ssh-config":`config`,stata:`do`,styl:`styl`,stylus:`styl`,svelte:`svelte`,swift:`swift`,"system-verilog":`sv`,systemd:`service`,talon:`talon`,talonscript:`talon`,tasl:`tasl`,tcl:`tcl`,templ:`templ`,terraform:`tf`,tex:`tex`,tf:`tf`,tfvars:`tfvars`,toml:`toml`,ts:`ts`,"ts-tags":`ts`,tsp:`tsp`,tsv:`tsv`,tsx:`tsx`,turtle:`ttl`,twig:`twig`,typ:`typ`,typescript:`ts`,typespec:`tsp`,typst:`typ`,v:`v`,vala:`vala`,vb:`vb`,verilog:`v`,vhdl:`vhdl`,vim:`vim`,viml:`vim`,vimscript:`vim`,vue:`vue`,"vue-html":`html`,"vue-vine":`vine`,vy:`vy`,vyper:`vy`,wasm:`wasm`,wenyan:`wy`,wgsl:`wgsl`,wiki:`wiki`,wikitext:`wiki`,wit:`wit`,wl:`wl`,wolfram:`wl`,xml:`xml`,xsl:`xsl`,yaml:`yaml`,yml:`yml`,zenscript:`zs`,zig:`zig`,zsh:`zsh`,文言:`wy`},xx=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=Q(),{code:c}=ox(),{isAnimating:l}=(0,j.useContext)(TC),u=vx(),d=hx(),f=a??c,p=`file.${n&&n in bx?bx[n]:`txt`}`,m=()=>{try{$b(p,f,`text/plain`),e?.()}catch(e){t?.(e)}};return(0,M.jsx)(`button`,{className:s(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),"data-streamdown":`code-block-download-button`,disabled:l,onClick:m,title:u.downloadFile,type:`button`,...o,children:r??(0,M.jsx)(d.DownloadIcon,{size:14})})},Sx=()=>{let{Loader2Icon:e}=hx(),t=Q();return(0,M.jsxs)(`div`,{className:t(`w-full divide-y divide-border overflow-hidden rounded-xl border border-border`),children:[(0,M.jsx)(`div`,{className:t(`h-[46px] w-full bg-muted/80`)}),(0,M.jsx)(`div`,{className:t(`flex w-full items-center justify-center p-4`),children:(0,M.jsx)(e,{className:t(`size-4 animate-spin`)})})]})},Cx=/\.[^/.]+$/,wx=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=hx(),c=Q(),l=(0,j.useRef)(null),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=vx(),h=o.width!=null||o.height!=null,g=(u||h)&&!f,_=f&&!h;(0,j.useEffect)(()=>{let e=l.current;if(e!=null&&e.complete){let t=e.naturalWidth>0;d(t),p(!t)}},[]);let v=(0,j.useCallback)(e=>{d(!0),p(!1),i?.(e)},[i]),y=(0,j.useCallback)(e=>{d(!1),p(!0),a?.(e)},[a]),b=async()=>{if(n)try{let e=await(await fetch(n)).blob(),t=new URL(n,window.location.origin).pathname.split(`/`).pop()||``,i=t.split(`.`).pop(),a=t.includes(`.`)&&i!==void 0&&i.length<=4,o=``;if(a)o=t;else{let n=e.type,i=`png`;n.includes(`jpeg`)||n.includes(`jpg`)?i=`jpg`:n.includes(`png`)?i=`png`:n.includes(`svg`)?i=`svg`:n.includes(`gif`)?i=`gif`:n.includes(`webp`)&&(i=`webp`),o=`${(r||t||`image`).replace(Cx,``)}.${i}`}$b(o,e,e.type)}catch{window.open(n,`_blank`)}};return n?(0,M.jsxs)(`div`,{className:c(`group relative my-4 inline-block`),"data-streamdown":`image-wrapper`,children:[(0,M.jsx)(`img`,{alt:r,className:c(`max-w-full rounded-lg`,_&&`hidden`,t),"data-streamdown":`image`,onError:y,onLoad:v,ref:l,src:n,...o}),_&&(0,M.jsx)(`span`,{className:c(`text-muted-foreground text-xs italic`),"data-streamdown":`image-fallback`,children:m.imageNotAvailable}),(0,M.jsx)(`div`,{className:c(`pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block`)}),g&&(0,M.jsx)(`button`,{className:c(`absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background`,`opacity-0 group-hover:opacity-100`),onClick:b,title:m.downloadImage,type:`button`,children:(0,M.jsx)(s,{size:14})})]}):null},Tx=0,Ex=()=>{Tx+=1,Tx===1&&(document.body.style.overflow=`hidden`)},Dx=()=>{Tx=Math.max(0,Tx-1),Tx===0&&(document.body.style.overflow=``)},Ox=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=hx(),c=Q(),[l,u]=(0,j.useState)(!1),d=vx(),f=(0,j.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),2e3)}catch{}},[e]),p=(0,j.useCallback)(()=>{r(),n()},[r,n]);return(0,j.useEffect)(()=>{if(t){Ex();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Dx()}}},[t,n]),t?(0,M.jsx)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm`),"data-streamdown":`link-safety-modal`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&n()},role:`button`,tabIndex:0,children:(0,M.jsxs)(`div`,{className:c(`relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,M.jsx)(`button`,{className:c(`absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:n,title:d.close,type:`button`,children:(0,M.jsx)(s,{size:16})}),(0,M.jsxs)(`div`,{className:c(`flex flex-col gap-2`),children:[(0,M.jsxs)(`div`,{className:c(`flex items-center gap-2 font-semibold text-lg`),children:[(0,M.jsx)(o,{size:20}),(0,M.jsx)(`span`,{children:d.openExternalLink})]}),(0,M.jsx)(`p`,{className:c(`text-muted-foreground text-sm`),children:d.externalLinkWarning})]}),(0,M.jsx)(`div`,{className:c(`break-all rounded-md bg-muted p-3 font-mono text-sm`,e.length>100&&`max-h-32 overflow-y-auto`),children:e}),(0,M.jsxs)(`div`,{className:c(`flex gap-2`),children:[(0,M.jsx)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted`),onClick:f,type:`button`,children:l?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(i,{size:14}),(0,M.jsx)(`span`,{children:d.copied})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(a,{size:14}),(0,M.jsx)(`span`,{children:d.copyLink})]})}),(0,M.jsxs)(`button`,{className:c(`flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90`),onClick:p,type:`button`,children:[(0,M.jsx)(o,{size:14}),(0,M.jsx)(`span`,{children:d.openLink})]})]})]})}):null},kx=(0,j.createContext)(null),Ax=()=>(0,j.useContext)(kx),jx=()=>Ax()?.code??null,Mx=()=>Ax()?.mermaid??null,Nx=e=>{var t;let n=Ax();return n!=null&&n.renderers&&e&&(t=n.renderers.find(t=>Array.isArray(t.language)?t.language.includes(e):t.language===e))!=null?t:null},Px=(e,t)=>new Promise((t,n)=>{let r=`data:image/svg+xml;base64,`+btoa(unescape(encodeURIComponent(e))),i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{let e=document.createElement(`canvas`),r=i.width*5,a=i.height*5;e.width=r,e.height=a;let o=e.getContext(`2d`);if(!o){n(Error(`Failed to create 2D canvas context for PNG export`));return}o.drawImage(i,0,0,r,a),e.toBlob(e=>{if(!e){n(Error(`Failed to create PNG blob`));return}t(e)},`image/png`)},i.onerror=()=>n(Error(`Failed to load SVG image`)),i.src=r}),Fx=({chart:e,children:t,className:n,onDownload:r,config:i,onError:a})=>{let o=Q(),[s,c]=(0,j.useState)(!1),l=(0,j.useRef)(null),{isAnimating:u}=(0,j.useContext)(TC),d=hx(),f=Mx(),p=vx(),m=async t=>{try{if(t===`mmd`){$b(`diagram.mmd`,e,`text/plain`),c(!1),r?.(t);return}if(!f){a?.(Error(`Mermaid plugin not available`));return}let n=f.getMermaid(i),o=e.split(``).reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0),s=`mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:l}=await n.render(s,e);if(!l){a?.(Error(`SVG not found. Please wait for the diagram to render.`));return}if(t===`svg`){$b(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){$b(`diagram.png`,await Px(l),`image/png`),r?.(t),c(!1);return}}catch(e){a?.(e)}};return(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();l.current&&!t.includes(l.current)&&c(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,M.jsxs)(`div`,{className:o(`relative`),ref:l,children:[(0,M.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,n),disabled:u,onClick:()=>c(!s),title:p.downloadDiagram,type:`button`,children:t??(0,M.jsx)(d.DownloadIcon,{size:14})}),s?(0,M.jsxs)(`div`,{className:o(`absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`svg`),title:p.downloadDiagramAsSvg,type:`button`,children:p.mermaidFormatSvg}),(0,M.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`png`),title:p.downloadDiagramAsPng,type:`button`,children:p.mermaidFormatPng}),(0,M.jsx)(`button`,{className:o(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`mmd`),title:p.downloadDiagramAsMmd,type:`button`,children:p.mermaidFormatMmd})]}):null]})},Ix=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=hx(),c=Q(),[l,u]=(0,j.useState)(!1),{isAnimating:d,controls:f}=(0,j.useContext)(TC),p=vx(),m=(()=>{if(typeof f==`boolean`)return f;let e=f.mermaid;return e===!1?!1:e===!0||e===void 0?!0:e.panZoom!==!1})(),h=()=>{u(!l)};return(0,j.useEffect)(()=>{if(l){Ex();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Dx()}}},[l]),(0,j.useEffect)(()=>{l?n?.():r&&r()},[l,n,r]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:c(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,i),disabled:d,onClick:h,title:p.viewFullscreen,type:`button`,...a,children:(0,M.jsx)(o,{size:14})}),l?(0,ey.createPortal)((0,M.jsxs)(`div`,{className:c(`fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm`),onClick:h,onKeyDown:e=>{e.key===`Escape`&&h()},role:`button`,tabIndex:0,children:[(0,M.jsx)(`button`,{className:c(`absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:h,title:p.exitFullscreen,type:`button`,children:(0,M.jsx)(s,{size:20})}),(0,M.jsx)(`div`,{className:c(`flex size-full items-center justify-center p-4`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:(0,M.jsx)(kC,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})},Lx=e=>{let t=[],n=[],r=e.querySelectorAll(`thead th`);for(let e of r)t.push(e.textContent?.trim()||``);let i=e.querySelectorAll(`tbody tr`);for(let e of i){let t=[],r=e.querySelectorAll(`td`);for(let e of r)t.push(e.textContent?.trim()||``);n.push(t)}return{headers:t,rows:n}},Rx=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1,n=!1;for(let r of e){if(r===`"`){t=!0,n=!0;break}(r===`,`||r===`
|
|
116
116
|
`)&&(t=!0)}return t?n?`"${e.replace(/"/g,`""`)}"`:`"${e}"`:e},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(`,`),o+=1);for(let e of n)a[o]=e.map(r).join(`,`),o+=1;return a.join(`
|
|
117
117
|
`)},zx=e=>{let{headers:t,rows:n}=e,r=e=>{let t=!1;for(let n of e)if(n===` `||n===`
|
|
118
118
|
`||n===`\r`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===` `?n.push(`\\t`):t===`
|
|
119
119
|
`?n.push(`\\n`):t===`\r`?n.push(`\\r`):n.push(t);return n.join(``)},i=t.length>0?n.length+1:n.length,a=Array(i),o=0;t.length>0&&(a[o]=t.map(r).join(` `),o+=1);for(let e of n)a[o]=e.map(r).join(` `),o+=1;return a.join(`
|
|
120
120
|
`)},Bx=e=>{let t=!1;for(let n of e)if(n===`\\`||n===`|`){t=!0;break}if(!t)return e;let n=[];for(let t of e)t===`\\`?n.push(`\\\\`):t===`|`?n.push(`\\|`):n.push(t);return n.join(``)},Vx=e=>{let{headers:t,rows:n}=e;if(t.length===0)return``;let r=Array(n.length+2),i=0;r[i]=`| ${t.map(e=>Bx(e)).join(` | `)} |`,i+=1;let a=Array(t.length);for(let e=0;e<t.length;e+=1)a[e]=`---`;r[i]=`| ${a.join(` | `)} |`,i+=1;for(let e of n)if(e.length<t.length){let n=Array(t.length);for(let r=0;r<t.length;r+=1)n[r]=r<e.length?Bx(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else r[i]=`| ${e.map(e=>Bx(e)).join(` | `)} |`,i+=1;return r.join(`
|
|
121
|
-
`)},Hx=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=Q(),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(0),{isAnimating:f}=(0,j.useContext)(TC),p=vx(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=Lx(t),o=({csv:Rx,tsv:zx,md:Vx}[e]||Vx)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=hx(),g=c?h.CheckIcon:h.CopyIcon;return(0,M.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,M.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,M.jsx)(g,{height:14,width:14})}),o?(0,M.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},Ux=({children:e,className:t,onDownload:n,onError:r})=>{let i=Q(),[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),{isAnimating:c}=(0,j.useContext)(TC),l=vx(),u=hx(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=Lx(t),a=e===`csv`?Rx(i):Vx(i);$b(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,M.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,M.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,M.jsx)(u.DownloadIcon,{size:14})}),a?(0,M.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},Wx=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=hx(),o=Q(),[s,c]=(0,j.useState)(!1),{isAnimating:l}=(0,j.useContext)(TC),u=vx(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,j.useEffect)(()=>{if(s){Ex();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Dx()}}},[s]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,M.jsx)(i,{size:14})}),s?(0,ey.createPortal)((0,M.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,M.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,M.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,M.jsx)(Hx,{}):null,r?(0,M.jsx)(Ux,{}):null,(0,M.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,M.jsx)(a,{size:20})})]}),(0,M.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,M.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},Gx=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=Q(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,M.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,M.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,M.jsx)(Hx,{}):null,l?(0,M.jsx)(Ux,{}):null,u?(0,M.jsx)(Wx,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,M.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,M.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},Kx=/startLine=(\d+)/,qx=/\bnoLineNumbers\b/,Jx=(0,j.lazy)(()=>Z(()=>import(`./mermaid-GHXKKRXX-CHPqkcxH.js`).then(e=>({default:e.Mermaid})),[])),Yx=/language-([^\s]+)/;function Xx(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function Zx(e,t){return e.className===t.className&&Xx(e.node,t.node)}var Qx=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,$x=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},eS=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},tS=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},nS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ol`,{className:Q()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>Zx(e,t));nS.displayName=`MarkdownOl`;var rS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`li`,{className:Q()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&Xx(e.node,t.node));rS.displayName=`MarkdownLi`;var iS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ul`,{className:Q()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>Zx(e,t));iS.displayName=`MarkdownUl`;var aS=(0,j.memo)(({className:e,node:t,...n})=>(0,M.jsx)(`hr`,{className:Q()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>Zx(e,t));aS.displayName=`MarkdownHr`;var oS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`span`,{className:Q()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>Zx(e,t));oS.displayName=`MarkdownStrong`;var sS=(0,j.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=Q(),{linkSafety:o}=(0,j.useContext)(TC),[s,c]=(0,j.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,j.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,j.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,j.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,M.jsx)(Ox,{...p})]}):(0,M.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>Zx(e,t)&&e.href===t.href);sS.displayName=`MarkdownA`;var cS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h1`,{className:Q()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>Zx(e,t));cS.displayName=`MarkdownH1`;var lS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h2`,{className:Q()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>Zx(e,t));lS.displayName=`MarkdownH2`;var uS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h3`,{className:Q()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>Zx(e,t));uS.displayName=`MarkdownH3`;var dS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h4`,{className:Q()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>Zx(e,t));dS.displayName=`MarkdownH4`;var fS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h5`,{className:Q()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>Zx(e,t));fS.displayName=`MarkdownH5`;var pS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h6`,{className:Q()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>Zx(e,t));pS.displayName=`MarkdownH6`;var mS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,j.useContext)(TC);return(0,M.jsx)(Gx,{className:t,showControls:Qx(i,`table`),showCopy:$x(i,`copy`),showDownload:$x(i,`download`),showFullscreen:$x(i,`fullscreen`),...r,children:e})},(e,t)=>Zx(e,t));mS.displayName=`MarkdownTable`;var hS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`thead`,{className:Q()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>Zx(e,t));hS.displayName=`MarkdownThead`;var gS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tbody`,{className:Q()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>Zx(e,t));gS.displayName=`MarkdownTbody`;var _S=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tr`,{className:Q()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>Zx(e,t));_S.displayName=`MarkdownTr`;var vS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`th`,{className:Q()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>Zx(e,t));vS.displayName=`MarkdownTh`;var yS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`td`,{className:Q()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>Zx(e,t));yS.displayName=`MarkdownTd`;var bS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`blockquote`,{className:Q()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>Zx(e,t));bS.displayName=`MarkdownBlockquote`;var xS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sup`,{className:Q()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>Zx(e,t));xS.displayName=`MarkdownSup`;var SS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sub`,{className:Q()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>Zx(e,t));SS.displayName=`MarkdownSub`;var CS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,j.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,j.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,j.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,j.isValidElement)(e))return e;if(e.type===nS){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,M.jsx)(`section`,{className:t,...r,children:i}):null}return(0,M.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>Zx(e,t));CS.displayName=`MarkdownSection`;var wS=(0,j.memo)(({node:e,className:t,children:n,...r})=>{let i=Q(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,j.useContext)(TC),l=Mx(),u=Yb(),d=(t?.match(Yx))?.at(1)??``,f=Nx(d);if(a)return(0,M.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(Kx),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&qx.test(p))&&c!==!1,v=``;if((0,j.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(Sx,{}),children:(0,M.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=Qx(s,`mermaid`),n=tS(s,`download`),r=tS(s,`copy`),a=tS(s,`fullscreen`),c=tS(s,`panZoom`),l=e&&(n||r||a);return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(Sx,{}),children:(0,M.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,M.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,M.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,M.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,M.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,M.jsx)(Fx,{chart:v,config:o?.config}):null,r?(0,M.jsx)(yx,{code:v}):null,a?(0,M.jsx)(Ix,{chart:v,config:o?.config}):null]})}):null,(0,M.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,M.jsx)(Jx,{chart:v,config:o?.config,showControls:c})})]})})}let y=Qx(s,`code`),b=eS(s,`download`),x=eS(s,`copy`);return(0,M.jsx)(ux,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,M.jsxs)(M.Fragment,{children:[b?(0,M.jsx)(xx,{code:v,language:d}):null,x?(0,M.jsx)(yx,{}):null]}):null})},(e,t)=>e.className===t.className&&Xx(e.node,t.node));wS.displayName=`MarkdownCode`;var TS=(0,j.memo)(wx,(e,t)=>e.className===t.className&&Xx(e.node,t.node));TS.displayName=`MarkdownImg`;var ES=(0,j.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,j.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,M.jsx)(M.Fragment,{children:e})}return(0,M.jsx)(`p`,{...n,children:e})},(e,t)=>Zx(e,t));ES.displayName=`MarkdownParagraph`;var DS={ol:nS,li:rS,ul:iS,hr:aS,strong:oS,a:sS,h1:cS,h2:lS,h3:uS,h4:dS,h5:fS,h6:pS,table:mS,thead:hS,tbody:gS,tr:_S,th:vS,td:yS,blockquote:bS,code:wS,img:TS,pre:({children:e})=>(0,j.isValidElement)(e)?(0,j.cloneElement)(e,{"data-block":`true`}):e,sup:xS,sub:SS,p:ES,section:CS},OS=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,kS=/\p{L}/u;function AS(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(OS.test(e))return`rtl`;if(kS.test(e))return`ltr`}return`ltr`}var jS=/^[ \t]{0,3}(`{3,}|~{3,})/,MS=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,NS=e=>{let t=e.split(`
|
|
121
|
+
`)},Hx=({children:e,className:t,onCopy:n,onError:r,timeout:i=2e3})=>{let a=Q(),[o,s]=(0,j.useState)(!1),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(0),{isAnimating:f}=(0,j.useContext)(TC),p=vx(),m=async e=>{var t;if(typeof window>`u`||!((t=navigator==null?void 0:navigator.clipboard)!=null&&t.write)){r?.(Error(`Clipboard API not available`));return}try{let t=(u.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let a=Lx(t),o=({csv:Rx,tsv:zx,md:Vx}[e]||Vx)(a),c=new ClipboardItem({"text/plain":new Blob([o],{type:`text/plain`}),"text/html":new Blob([t.outerHTML],{type:`text/html`})});await navigator.clipboard.write([c]),l(!0),s(!1),n?.(e),d.current=window.setTimeout(()=>l(!1),i)}catch(e){r?.(e)}};(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();u.current&&!t.includes(u.current)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e),window.clearTimeout(d.current)}},[]);let h=hx(),g=c?h.CheckIcon:h.CopyIcon;return(0,M.jsxs)(`div`,{className:a(`relative`),ref:u,children:[(0,M.jsx)(`button`,{className:a(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:f,onClick:()=>s(!o),title:p.copyTable,type:`button`,children:e??(0,M.jsx)(g,{height:14,width:14})}),o?(0,M.jsxs)(`div`,{className:a(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`md`),title:p.copyTableAsMarkdown,type:`button`,children:p.tableFormatMarkdown}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`csv`),title:p.copyTableAsCsv,type:`button`,children:p.tableFormatCsv}),(0,M.jsx)(`button`,{className:a(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>m(`tsv`),title:p.copyTableAsTsv,type:`button`,children:p.tableFormatTsv})]}):null]})},Ux=({children:e,className:t,onDownload:n,onError:r})=>{let i=Q(),[a,o]=(0,j.useState)(!1),s=(0,j.useRef)(null),{isAnimating:c}=(0,j.useContext)(TC),l=vx(),u=hx(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=Lx(t),a=e===`csv`?Rx(i):Vx(i);$b(`table.${e===`csv`?`csv`:`md`}`,a,e===`csv`?`text/csv`:`text/markdown`),o(!1),n?.(e)}catch(e){r?.(e)}};return(0,j.useEffect)(()=>{let e=e=>{let t=e.composedPath();s.current&&!t.includes(s.current)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]),(0,M.jsxs)(`div`,{className:i(`relative`),ref:s,children:[(0,M.jsx)(`button`,{className:i(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:c,onClick:()=>o(!a),title:l.downloadTable,type:`button`,children:e??(0,M.jsx)(u.DownloadIcon,{size:14})}),a?(0,M.jsxs)(`div`,{className:i(`absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg`),children:[(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`csv`),title:l.downloadTableAsCsv,type:`button`,children:l.tableFormatCsv}),(0,M.jsx)(`button`,{className:i(`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40`),onClick:()=>d(`markdown`),title:l.downloadTableAsMarkdown,type:`button`,children:l.tableFormatMarkdown})]}):null]})},Wx=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=hx(),o=Q(),[s,c]=(0,j.useState)(!1),{isAnimating:l}=(0,j.useContext)(TC),u=vx(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,j.useEffect)(()=>{if(s){Ex();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),Dx()}}},[s]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:o(`cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,t),disabled:l,onClick:d,title:u.viewFullscreen,type:`button`,children:(0,M.jsx)(i,{size:14})}),s?(0,ey.createPortal)((0,M.jsx)(`div`,{"aria-label":u.viewFullscreen,"aria-modal":`true`,className:o(`fixed inset-0 z-50 flex flex-col bg-background`),"data-streamdown":`table-fullscreen`,onClick:f,onKeyDown:e=>{e.key===`Escape`&&f()},role:`dialog`,children:(0,M.jsxs)(`div`,{className:o(`flex h-full flex-col`),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),role:`presentation`,children:[(0,M.jsxs)(`div`,{className:o(`flex items-center justify-end gap-1 p-4`),children:[n?(0,M.jsx)(Hx,{}):null,r?(0,M.jsx)(Ux,{}):null,(0,M.jsx)(`button`,{className:o(`rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground`),onClick:f,title:u.exitFullscreen,type:`button`,children:(0,M.jsx)(a,{size:20})})]}),(0,M.jsx)(`div`,{className:o(`flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10`),children:(0,M.jsx)(`table`,{className:o(`w-full border-collapse border border-border`),"data-streamdown":`table`,children:e})})]})}),document.body):null]})},Gx=({children:e,className:t,showControls:n,showCopy:r=!0,showDownload:i=!0,showFullscreen:a=!0,...o})=>{let s=Q(),c=n&&r,l=n&&i,u=n&&a,d=c||l||u;return(0,M.jsxs)(`div`,{className:s(`my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2`),"data-streamdown":`table-wrapper`,children:[d?(0,M.jsxs)(`div`,{className:s(`flex items-center justify-end gap-1`),children:[c?(0,M.jsx)(Hx,{}):null,l?(0,M.jsx)(Ux,{}):null,u?(0,M.jsx)(Wx,{showCopy:c,showDownload:l,children:e}):null]}):null,(0,M.jsx)(`div`,{className:s(`border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background`),children:(0,M.jsx)(`table`,{className:s(`w-full divide-y divide-border`,t),"data-streamdown":`table`,...o,children:e})})]})},Kx=/startLine=(\d+)/,qx=/\bnoLineNumbers\b/,Jx=(0,j.lazy)(()=>Z(()=>import(`./mermaid-GHXKKRXX-D5YxphBn.js`).then(e=>({default:e.Mermaid})),[])),Yx=/language-([^\s]+)/;function Xx(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return!0;if(!(e!=null&&e.position&&t!=null&&t.position))return!1;let n=e.position.start,r=t.position.start,i=e.position.end,a=t.position.end;return n?.line===r?.line&&n?.column===r?.column&&i?.line===a?.line&&i?.column===a?.column}function Zx(e,t){return e.className===t.className&&Xx(e.node,t.node)}var Qx=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,$x=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.table;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},eS=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.code;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},tS=(e,t)=>{if(typeof e==`boolean`)return e;let n=e.mermaid;return n===!1?!1:n===!0||n===void 0?!0:n[t]!==!1},nS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ol`,{className:Q()(`list-inside list-decimal whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`ordered-list`,...r,children:e}),(e,t)=>Zx(e,t));nS.displayName=`MarkdownOl`;var rS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`li`,{className:Q()(`py-1 [&>p]:inline`,t),"data-streamdown":`list-item`,...r,children:e}),(e,t)=>e.className===t.className&&Xx(e.node,t.node));rS.displayName=`MarkdownLi`;var iS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`ul`,{className:Q()(`list-inside list-disc whitespace-normal [li_&]:pl-6`,t),"data-streamdown":`unordered-list`,...r,children:e}),(e,t)=>Zx(e,t));iS.displayName=`MarkdownUl`;var aS=(0,j.memo)(({className:e,node:t,...n})=>(0,M.jsx)(`hr`,{className:Q()(`my-6 border-border`,e),"data-streamdown":`horizontal-rule`,...n}),(e,t)=>Zx(e,t));aS.displayName=`MarkdownHr`;var oS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`span`,{className:Q()(`font-semibold`,t),"data-streamdown":`strong`,...r,children:e}),(e,t)=>Zx(e,t));oS.displayName=`MarkdownStrong`;var sS=(0,j.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=Q(),{linkSafety:o}=(0,j.useContext)(TC),[s,c]=(0,j.useState)(!1),l=n===`streamdown:incomplete-link`,u=(0,j.useCallback)(async e=>{if(!(!(o!=null&&o.enabled&&n)||l)){if(e.preventDefault(),o.onLinkCheck&&await o.onLinkCheck(n)){window.open(n,`_blank`,`noreferrer`);return}c(!0)}},[o,n,l]),d=(0,j.useCallback)(()=>{n&&window.open(n,`_blank`,`noreferrer`)},[n]),f=(0,j.useCallback)(()=>{c(!1)},[]),p={url:n??``,isOpen:s,onClose:f,onConfirm:d};return o!=null&&o.enabled&&n?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{className:a(`wrap-anywhere appearance-none text-left font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,onClick:u,type:`button`,children:e}),o.renderModal?o.renderModal(p):(0,M.jsx)(Ox,{...p})]}):(0,M.jsx)(`a`,{className:a(`wrap-anywhere font-medium text-primary underline`,t),"data-incomplete":l,"data-streamdown":`link`,href:n,rel:`noreferrer`,target:`_blank`,...i,children:e})},(e,t)=>Zx(e,t)&&e.href===t.href);sS.displayName=`MarkdownA`;var cS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h1`,{className:Q()(`mt-6 mb-2 font-semibold text-3xl`,t),"data-streamdown":`heading-1`,...r,children:e}),(e,t)=>Zx(e,t));cS.displayName=`MarkdownH1`;var lS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h2`,{className:Q()(`mt-6 mb-2 font-semibold text-2xl`,t),"data-streamdown":`heading-2`,...r,children:e}),(e,t)=>Zx(e,t));lS.displayName=`MarkdownH2`;var uS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h3`,{className:Q()(`mt-6 mb-2 font-semibold text-xl`,t),"data-streamdown":`heading-3`,...r,children:e}),(e,t)=>Zx(e,t));uS.displayName=`MarkdownH3`;var dS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h4`,{className:Q()(`mt-6 mb-2 font-semibold text-lg`,t),"data-streamdown":`heading-4`,...r,children:e}),(e,t)=>Zx(e,t));dS.displayName=`MarkdownH4`;var fS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h5`,{className:Q()(`mt-6 mb-2 font-semibold text-base`,t),"data-streamdown":`heading-5`,...r,children:e}),(e,t)=>Zx(e,t));fS.displayName=`MarkdownH5`;var pS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`h6`,{className:Q()(`mt-6 mb-2 font-semibold text-sm`,t),"data-streamdown":`heading-6`,...r,children:e}),(e,t)=>Zx(e,t));pS.displayName=`MarkdownH6`;var mS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,j.useContext)(TC);return(0,M.jsx)(Gx,{className:t,showControls:Qx(i,`table`),showCopy:$x(i,`copy`),showDownload:$x(i,`download`),showFullscreen:$x(i,`fullscreen`),...r,children:e})},(e,t)=>Zx(e,t));mS.displayName=`MarkdownTable`;var hS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`thead`,{className:Q()(`bg-muted/80`,t),"data-streamdown":`table-header`,...r,children:e}),(e,t)=>Zx(e,t));hS.displayName=`MarkdownThead`;var gS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tbody`,{className:Q()(`divide-y divide-border`,t),"data-streamdown":`table-body`,...r,children:e}),(e,t)=>Zx(e,t));gS.displayName=`MarkdownTbody`;var _S=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`tr`,{className:Q()(`border-border`,t),"data-streamdown":`table-row`,...r,children:e}),(e,t)=>Zx(e,t));_S.displayName=`MarkdownTr`;var vS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`th`,{className:Q()(`whitespace-nowrap px-4 py-2 text-left font-semibold text-sm`,t),"data-streamdown":`table-header-cell`,...r,children:e}),(e,t)=>Zx(e,t));vS.displayName=`MarkdownTh`;var yS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`td`,{className:Q()(`px-4 py-2 text-sm`,t),"data-streamdown":`table-cell`,...r,children:e}),(e,t)=>Zx(e,t));yS.displayName=`MarkdownTd`;var bS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`blockquote`,{className:Q()(`my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic`,t),"data-streamdown":`blockquote`,...r,children:e}),(e,t)=>Zx(e,t));bS.displayName=`MarkdownBlockquote`;var xS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sup`,{className:Q()(`text-sm`,t),"data-streamdown":`superscript`,...r,children:e}),(e,t)=>Zx(e,t));xS.displayName=`MarkdownSup`;var SS=(0,j.memo)(({children:e,className:t,node:n,...r})=>(0,M.jsx)(`sub`,{className:Q()(`text-sm`,t),"data-streamdown":`subscript`,...r,children:e}),(e,t)=>Zx(e,t));SS.displayName=`MarkdownSub`;var CS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{if(`data-footnotes`in r){let n=e=>{if(!(0,j.isValidElement)(e))return!1;let t=Array.isArray(e.props.children)?e.props.children:[e.props.children],n=!1,r=!1;for(let e of t)if(e){if(typeof e==`string`)e.trim()!==``&&(n=!0);else if((0,j.isValidElement)(e))if(e.props?.[`data-footnote-backref`]!==void 0)r=!0;else{let t=Array.isArray(e.props.children)?e.props.children:[e.props.children];for(let e of t){if(typeof e==`string`&&e.trim()!==``){n=!0;break}if((0,j.isValidElement)(e)&&e.props?.[`data-footnote-backref`]===void 0){n=!0;break}}}}return r&&!n},i=Array.isArray(e)?e.map(e=>{if(!(0,j.isValidElement)(e))return e;if(e.type===nS){let t=(Array.isArray(e.props.children)?e.props.children:[e.props.children]).filter(e=>!n(e));return t.length===0?null:{...e,props:{...e.props,children:t}}}return e}):e;return(Array.isArray(i)?i.some(e=>e!==null):i!==null)?(0,M.jsx)(`section`,{className:t,...r,children:i}):null}return(0,M.jsx)(`section`,{className:t,...r,children:e})},(e,t)=>Zx(e,t));CS.displayName=`MarkdownSection`;var wS=(0,j.memo)(({node:e,className:t,children:n,...r})=>{let i=Q(),a=!(`data-block`in r),{mermaid:o,controls:s,lineNumbers:c}=(0,j.useContext)(TC),l=Mx(),u=Yb(),d=(t?.match(Yx))?.at(1)??``,f=Nx(d);if(a)return(0,M.jsx)(`code`,{className:i(`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`,t),"data-streamdown":`inline-code`,...r,children:n});let p=e?.properties?.metastring,m=p?.match(Kx),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&qx.test(p))&&c!==!1,v=``;if((0,j.isValidElement)(n)&&n.props&&typeof n.props==`object`&&`children`in n.props&&typeof n.props.children==`string`?v=n.props.children:typeof n==`string`&&(v=n),f){let e=f.component;return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(Sx,{}),children:(0,M.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=Qx(s,`mermaid`),n=tS(s,`download`),r=tS(s,`copy`),a=tS(s,`fullscreen`),c=tS(s,`panZoom`),l=e&&(n||r||a);return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(Sx,{}),children:(0,M.jsxs)(`div`,{className:i(`group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2`,t),"data-streamdown":`mermaid-block`,children:[(0,M.jsx)(`div`,{className:i(`flex h-8 items-center text-muted-foreground text-xs`),children:(0,M.jsx)(`span`,{className:i(`ml-1 font-mono lowercase`),children:`mermaid`})}),l?(0,M.jsx)(`div`,{className:i(`pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end`),children:(0,M.jsxs)(`div`,{className:i(`pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur`),"data-streamdown":`mermaid-block-actions`,children:[n?(0,M.jsx)(Fx,{chart:v,config:o?.config}):null,r?(0,M.jsx)(yx,{code:v}):null,a?(0,M.jsx)(Ix,{chart:v,config:o?.config}):null]})}):null,(0,M.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,M.jsx)(Jx,{chart:v,config:o?.config,showControls:c})})]})})}let y=Qx(s,`code`),b=eS(s,`download`),x=eS(s,`copy`);return(0,M.jsx)(ux,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,M.jsxs)(M.Fragment,{children:[b?(0,M.jsx)(xx,{code:v,language:d}):null,x?(0,M.jsx)(yx,{}):null]}):null})},(e,t)=>e.className===t.className&&Xx(e.node,t.node));wS.displayName=`MarkdownCode`;var TS=(0,j.memo)(wx,(e,t)=>e.className===t.className&&Xx(e.node,t.node));TS.displayName=`MarkdownImg`;var ES=(0,j.memo)(({children:e,node:t,...n})=>{let r=(Array.isArray(e)?e:[e]).filter(e=>e!=null&&e!==``);if(r.length===1&&(0,j.isValidElement)(r[0])){let t=r[0].props.node?.tagName;if(t===`img`||t===`code`&&`data-block`in r[0].props)return(0,M.jsx)(M.Fragment,{children:e})}return(0,M.jsx)(`p`,{...n,children:e})},(e,t)=>Zx(e,t));ES.displayName=`MarkdownParagraph`;var DS={ol:nS,li:rS,ul:iS,hr:aS,strong:oS,a:sS,h1:cS,h2:lS,h3:uS,h4:dS,h5:fS,h6:pS,table:mS,thead:hS,tbody:gS,tr:_S,th:vS,td:yS,blockquote:bS,code:wS,img:TS,pre:({children:e})=>(0,j.isValidElement)(e)?(0,j.cloneElement)(e,{"data-block":`true`}):e,sup:xS,sub:SS,p:ES,section:CS},OS=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,kS=/\p{L}/u;function AS(e){let t=e.replace(/^#{1,6}\s+/gm,``).replace(/(\*{1,3}|_{1,3})/g,``).replace(/`[^`]*`/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/^[\s>*\-+\d.]+/gm,``);for(let e of t){if(OS.test(e))return`rtl`;if(kS.test(e))return`ltr`}return`ltr`}var jS=/^[ \t]{0,3}(`{3,}|~{3,})/,MS=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,NS=e=>{let t=e.split(`
|
|
122
122
|
`),n=null,r=0;for(let e of t){let t=jS.exec(e);if(n===null){if(t){let e=t[1];n=e[0],r=e.length}}else if(t){let e=t[1],i=e[0],a=e.length;i===n&&a>=r&&(n=null,r=0)}}return n!==null},PS=e=>{let t=e.split(`
|
|
123
123
|
`);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&MS.test(t))return!0}return!1},FS=()=>e=>{Be(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},IS=[],LS={allowDangerousHtml:!0},RS=new WeakMap,zS=new class{constructor(){this.cache=new Map,this.keyCache=new WeakMap,this.maxSize=100}generateCacheKey(e){let t=this.keyCache.get(e);if(t)return t;let n=e.rehypePlugins,r=e.remarkPlugins,i=e.remarkRehypeOptions;if(!(n||r||i)){let t=`default`;return this.keyCache.set(e,t),t}let a=e=>{if(!e||e.length===0)return``;let t=``;for(let n=0;n<e.length;n+=1){let r=e[n];if(n>0&&(t+=`,`),Array.isArray(r)){let[e,n]=r;if(typeof e==`function`){let n=RS.get(e);n||(n=e.name,RS.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=RS.get(r);e||(e=r.name,RS.set(r,e)),t+=e}else t+=String(r)}return t},o=a(n),s=`${a(r)}::${o}::${i?JSON.stringify(i):``}`;return this.keyCache.set(e,s),s}get(e){let t=this.generateCacheKey(e),n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(e,t){let n=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let e=this.cache.keys().next().value;e&&this.cache.delete(e)}this.cache.set(n,t)}clear(){this.cache.clear()}},BS=e=>{let t=VS(e),n=e.children||``;return JS(t.runSync(t.parse(n),n),e)},VS=e=>{let t=zS.get(e);if(t)return t;let n=US(e);return zS.set(e,n),n},HS=e=>e.some(e=>Array.isArray(e)?e[0]===us:e===us),US=e=>{let t=e.rehypePlugins||IS,n=e.remarkPlugins||IS,r=HS(t)?n:[...n,FS],i=e.remarkRehypeOptions?{...LS,...e.remarkRehypeOptions}:LS;return Wv().use(T_).use(r).use(gv,i).use(t)},WS=e=>e,GS=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},KS=(e,t)=>{for(let n in Bg)if(Object.hasOwn(Bg,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=Bg[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},qS=(e,t,n,r,i,a)=>{let o=!1;return r?o=!r.includes(e.tagName):i&&(o=i.includes(e.tagName)),!o&&a&&typeof t==`number`&&(o=!a(e,t,n)),o},JS=(e,t)=>{let{allowElement:n,allowedElements:r,disallowedElements:i,skipHtml:a,unwrapDisallowed:o,urlTransform:s}=t;if(n||r||i||a||s){let t=s||WS;Be(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return GS(c,s,a,e.value),s;if(e.type===`element`&&(KS(e,t),qS(e,s,c,r,i,n)&&c&&typeof s==`number`))return o&&e.children?c.children.splice(s,1,...e.children):c.children.splice(s,1),s})}return vg(e,{Fragment:M.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:M.jsx,jsxs:M.jsxs,passKeys:!0,passNode:!0})},YS=/\[\^[\w-]{1,200}\](?!:)/,XS=/\[\^[\w-]{1,200}\]:/,ZS=/<(\w+)[\s>]/,QS=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),$S=new Map,eC=new Map,tC=e=>{let t=e.toLowerCase(),n=$S.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return $S.set(t,r),r},nC=e=>{let t=e.toLowerCase(),n=eC.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return eC.set(t,r),r},rC=(e,t)=>{if(QS.has(t.toLowerCase()))return 0;let n=e.match(tC(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},iC=(e,t)=>{let n=e.match(nC(t));return n?n.length:0},aC=e=>{let t=0;for(let n=0;n<e.length-1;n+=1)e[n]===`$`&&e[n+1]===`$`&&(t+=1,n+=1);return t},oC=e=>{let t=YS.test(e),n=XS.test(e);if(t||n)return[e];let r=Cb.lex(e,{gfm:!0}),i=[],a=[],o=!1;for(let e of r){let t=e.raw,n=i.length;if(a.length>0){i[n-1]+=t;let e=a.at(-1),r=rC(t,e),o=iC(t,e);for(let t=0;t<r;t+=1)a.push(e);for(let t=0;t<o;t+=1)a.length>0&&a.at(-1)===e&&a.pop();continue}if(e.type===`html`&&e.block){let e=t.match(ZS);if(e){let n=e[1];rC(t,n)>iC(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(aC(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},sC=(e,t)=>{if(!t.length)return e;let n=e;for(let e of t){let t=RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`,`gi`);n=n.replace(t,(e,t,n,r)=>{if(!n.includes(`
|
|
124
124
|
|
|
@@ -291,4 +291,4 @@ XID_Start XIDS`.split(/\s/).map(e=>[vA(e),e])),dj=new Map([[`s`,XA(383)],[XA(383
|
|
|
291
291
|
th,td{border:1px solid rgba(255,255,255,.12);padding:.6rem .85rem;text-align:left;font-size:.875rem}
|
|
292
292
|
th{background:rgba(255,255,255,.05);font-weight:600}
|
|
293
293
|
tr:hover td{background:rgba(255,255,255,.03)}
|
|
294
|
-
</style></head><body>${t}</body></html>`),n.document.close())}function eN(e){let t=e.target.closest(`[title="View fullscreen"]`);if(t){e.stopPropagation(),e.preventDefault();let n=t.closest(`[data-streamdown]`)?.querySelector(`table`)??t.closest(`.group`)?.querySelector(`table`);n&&$M(n)}}function tN({role:e,content:t,timestamp:n,hasAttachments:r,audioData:i,attachments:a,onImageClick:o,transcribing:s}){let c=e===`user`,l=n?KM(n):``,{tag:u,body:d}=qM(t),f=a?.filter(e=>e.mediaType?.startsWith(`image/`))||[],p=a?.filter(e=>!e.mediaType?.startsWith(`image/`))||[],m=f.filter(e=>e.filePath).map(e=>e.filePath.startsWith(`data:`)?e.filePath:`/api/files/${e.filePath}`);if(c)return(0,M.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`group relative max-w-[85%]`,children:[(0,M.jsx)(QM,{text:d}),(0,M.jsxs)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed whitespace-pre-wrap bg-primary text-primary-foreground break-words`,children:[m.length>0&&(0,M.jsx)(`div`,{className:`flex gap-1.5 flex-wrap mb-2`,children:m.map((e,t)=>(0,M.jsx)(MM,{src:e,alt:f[t]?.name||`attachment`,className:`w-28 h-28 rounded-lg object-cover cursor-pointer border border-white/10 hover:opacity-80 transition-opacity`,onClick:()=>o?.(m,t)},t))}),p.length>0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-primary-foreground/60 mr-1.5`,children:[(0,M.jsx)(ge,{className:`h-3 w-3`}),p.length>1&&(0,M.jsx)(`span`,{className:`text-xs`,children:p.length})]}),!a?.length&&r&&(0,M.jsx)(`span`,{className:`inline-flex items-center gap-1 text-primary-foreground/60 mr-1.5`,children:(0,M.jsx)(ge,{className:`h-3 w-3`})}),s&&(0,M.jsxs)(`div`,{className:`flex flex-col gap-1.5 mb-1`,children:[(0,M.jsx)(`div`,{className:`h-3 w-48 max-w-full rounded bg-white/15 animate-pulse`}),(0,M.jsx)(`div`,{className:`h-3 w-32 max-w-full rounded bg-white/10 animate-pulse`})]}),d,i&&(0,M.jsx)(`div`,{className:`mt-2 pt-2 border-t border-white/10`,children:(0,M.jsx)(jM,{audioData:i})})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 px-1 self-end`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] text-muted-foreground/40`,children:[(0,M.jsx)(JM,{tag:u}),u]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50`,children:l})]})]});let h=e=>(0,M.jsx)(DC,{mode:`static`,plugins:{code:OM},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!0,fullscreen:!0}},shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,components:{a({href:e,children:t}){return e?.includes(`/api/channels/whatsapp/qr-page`)?(0,M.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 my-2 px-3.5 py-2.5 rounded-xl bg-[#25D366]/10 border border-[#25D366]/20 hover:bg-[#25D366]/15 transition-colors no-underline`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-[#25D366] shrink-0`,children:(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`w-4 h-4 fill-white`,children:(0,M.jsx)(`path`,{d:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z`})})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[#25D366] font-medium text-sm`,children:`Click here to pair your WhatsApp`}),(0,M.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Opens QR code pairing page`})]}),(0,M.jsx)(re,{className:`w-3.5 h-3.5 text-muted-foreground/50 ml-auto shrink-0`})]}):e?.includes(`/api/channels/alexa/pair-page`)?(0,M.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 my-2 px-3.5 py-2.5 rounded-xl bg-[#00CAFF]/10 border border-[#00CAFF]/20 hover:bg-[#00CAFF]/15 transition-colors no-underline`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-[#00CAFF] shrink-0`,children:(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`w-4 h-4 fill-white`,children:(0,M.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z`})})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[#00CAFF] font-medium text-sm`,children:`Click here to connect Alexa`}),(0,M.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Generates a one-time linking code`})]}),(0,M.jsx)(re,{className:`w-3.5 h-3.5 text-muted-foreground/50 ml-auto shrink-0`})]}):e?.includes(`/api/channels/telegram/pair-page`)?(0,M.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 my-2 px-3.5 py-2.5 rounded-xl bg-[#229ED9]/10 border border-[#229ED9]/20 hover:bg-[#229ED9]/15 transition-colors no-underline`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-[#229ED9] shrink-0`,children:(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`w-4 h-4 fill-white`,children:(0,M.jsx)(`path`,{d:`M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.81c-.19.91-.74 1.13-1.5.71l-4.13-3.05-1.99 1.93c-.23.23-.42.42-.83.42z`})})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[#229ED9] font-medium text-sm`,children:`Click here to connect Telegram`}),(0,M.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Opens the Telegram pairing page`})]}),(0,M.jsx)(re,{className:`w-3.5 h-3.5 text-muted-foreground/50 ml-auto shrink-0`})]}):(0,M.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-[#0069FE] underline decoration-[#0069FE]/30 underline-offset-2 hover:decoration-[#0069FE] transition-colors`,children:t})}},children:YM(e)});if(ZM(d)){let e=XM(d);return(0,M.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`group relative w-full`,children:[(0,M.jsx)(QM,{text:d}),(0,M.jsx)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed bg-muted text-foreground prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 break-words`,onClickCapture:eN,children:e.map((e,t)=>e.type===`text`?(0,M.jsx)(`div`,{children:h(e.value)},t):e.type===`env`?(0,M.jsx)(NM,{group:e.group},t):e.type===`bloby-image`?(0,M.jsx)(FM,{src:e.src,alt:e.alt},t):e.type===`bloby-text`?(0,M.jsx)(RM,{title:e.title,content:e.content},t):e.type===`notch`?(0,M.jsx)(VM,{format:e.format,content:e.content,cardType:e.cardType},t):e.type===`morphy-action`?(0,M.jsx)(GM,{actionType:e.actionType,content:e.content},t):e.type===`mac-actions`?e.actions.map((e,n)=>e.type===`card`?(0,M.jsx)(VM,{format:`card`,content:JSON.stringify(e.data??{}),cardType:e.preset},`${t}-${n}`):(0,M.jsx)(GM,{actionType:e.type??`action`,content:JSON.stringify(e)},`${t}-${n}`)):null)})]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 px-1`,children:l})]})}return(0,M.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`group relative w-full`,children:[(0,M.jsx)(QM,{text:d}),(0,M.jsx)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed bg-muted text-foreground prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 break-words`,onClickCapture:eN,children:h(d)})]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 px-1`,children:l})]})}function nN({text:e,toolName:t}){return e?(0,M.jsx)(`div`,{className:`flex flex-col items-start`,children:(0,M.jsx)(`div`,{className:`w-full rounded-2xl px-4 py-2.5 text-sm leading-relaxed bg-muted text-foreground prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 break-words`,children:(0,M.jsx)(DC,{mode:`streaming`,isAnimating:!0,caret:`block`,plugins:{code:OM},controls:!1,shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,children:e})})}):(0,M.jsx)(`div`,{className:`flex justify-start`,children:(0,M.jsx)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm bg-muted text-foreground`,children:(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-5`,children:[(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-muted-foreground/60 animate-bounce`,style:{animationDelay:`0ms`}}),(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-muted-foreground/60 animate-bounce`,style:{animationDelay:`150ms`}}),(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-muted-foreground/60 animate-bounce`,style:{animationDelay:`300ms`}})]})})})}function rN({images:e,index:t,onClose:n,onNavigate:r}){let i=(0,j.useCallback)(()=>{t>0&&r(t-1)},[t,r]),a=(0,j.useCallback)(()=>{t<e.length-1&&r(t+1)},[t,e.length,r]),o=kM(e[t]);return(0,j.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n(),e.key===`ArrowLeft`&&i(),e.key===`ArrowRight`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,i,a]),(0,M.jsx)(w,{children:(0,M.jsxs)(x.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`fixed inset-0 z-50 flex items-center justify-center bg-black/90`,onClick:n,children:[(0,M.jsxs)(`div`,{className:`absolute top-4 right-4 z-10 flex gap-2`,children:[(0,M.jsx)(`button`,{onClick:async n=>{n.stopPropagation();try{let n=await(await v(e[t])).blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e[t].split(`/`).pop()||`image`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}catch{window.open(e[t],`_blank`)}},className:`p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,title:`Download`,children:(0,M.jsx)(f,{className:`h-5 w-5`})}),(0,M.jsx)(`button`,{onClick:n,className:`p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,children:(0,M.jsx)(y,{className:`h-5 w-5`})})]}),e.length>1&&(0,M.jsxs)(`div`,{className:`absolute top-4 left-1/2 -translate-x-1/2 text-white/70 text-sm tabular-nums`,children:[t+1,` / `,e.length]}),t>0&&(0,M.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},className:`absolute left-3 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,children:(0,M.jsx)(O,{className:`h-6 w-6`})}),t<e.length-1&&(0,M.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},className:`absolute right-3 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,children:(0,M.jsx)(ce,{className:`h-6 w-6`})}),o?(0,M.jsx)(`img`,{src:o,alt:``,className:`max-h-[85vh] max-w-[90vw] object-contain rounded-lg`,onClick:e=>e.stopPropagation()}):(0,M.jsx)(`div`,{className:`h-40 w-40 rounded-lg bg-white/10 animate-pulse`,onClick:e=>e.stopPropagation()})]})})}function iN({messages:e,streaming:t,streamBuffer:n,tools:r,hasMore:i,onLoadOlder:a}){let o=(0,j.useRef)(null),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)(!0),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(null),m=(0,j.useCallback)((e,t)=>{p({images:e,index:t})},[]);(0,j.useEffect)(()=>{o.current&&(l.current&&e.length>0?(o.current.scrollIntoView({behavior:`instant`}),l.current=!1):l.current||o.current.scrollIntoView({behavior:`smooth`}))},[e,n,r,t]),(0,j.useEffect)(()=>{if(!c.current||!a)return;let e=c.current,t=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&i&&!u){let e=s.current;if(!e)return;let t=e.scrollHeight;d(!0),await a(),d(!1),requestAnimationFrame(()=>{let n=e.scrollHeight;e.scrollTop+=n-t})}},{root:s.current,threshold:.1});return t.observe(e),()=>t.disconnect()},[i,u,a]);let h=r.length>0?r[r.length-1]:null,g=h?.status===`running`?h.name:void 0;return(0,M.jsxs)(`div`,{ref:s,className:`flex-1 overflow-y-auto overflow-x-hidden p-4 flex flex-col min-h-0`,children:[(0,M.jsx)(`div`,{className:`flex-1`}),i&&(0,M.jsx)(`div`,{ref:c,className:`flex justify-center py-2`,children:u&&(0,M.jsx)(`div`,{className:`w-5 h-5 border-2 border-muted-foreground/20 border-t-muted-foreground/60 rounded-full animate-spin`})}),e.length===0&&!t&&(0,M.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:`Start a conversation with your Bloby..`}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[e.map(e=>(0,M.jsx)(tN,{role:e.role,content:e.content,timestamp:e.timestamp,hasAttachments:e.hasAttachments,audioData:e.audioData,attachments:e.attachments,onImageClick:m,transcribing:e.transcribing},e.id)),t&&(0,M.jsx)(nN,{text:n.replace(/^\[(Mac|Alexa|WhatsApp|Chat|PWA|Workspace|workspace)\]\s*/i,``).replace(/<notch_card\s+type="[^"]*">[\s\S]*?<\/notch_card>/gi,``).replace(/<notch_html>[\s\S]*?<\/notch_html>/gi,``).replace(/<notch_(?:html|card)\b[\s\S]*$/i,``).replace(/<morphy_action\s+type="[^"]*">[\s\S]*?<\/morphy_action>/gi,``).replace(/<morphy_action\b[\s\S]*$/i,``).replace(/<mac_actions>[\s\S]*?<\/mac_actions>/gi,``).replace(/<mac_actions\b[\s\S]*$/i,``).trimEnd(),toolName:g})]}),(0,M.jsx)(`div`,{ref:o}),f&&(0,M.jsx)(rN,{images:f.images,index:f.index,onClose:()=>p(null),onNavigate:e=>p(t=>t?{...t,index:e}:null)})]})}var aN=()=>typeof window>`u`?null:window.SpeechRecognition??window.webkitSpeechRecognition??null,oN=aN()!==null;function sN(){let e=(0,j.useRef)(null),t=(0,j.useRef)(``),n=(0,j.useRef)(null),r=(0,j.useMemo)(()=>oN,[]);return{start:(0,j.useCallback)((r=!1)=>{let i=aN();if(!i)return;if(e.current)try{e.current.abort()}catch{}let a=new i;a.continuous=r,a.interimResults=!0,a.lang=navigator.language||`en-US`,t.current=``,e.current=a,a.onresult=e=>{t.current=e.results[e.results.length-1][0].transcript},a.onend=()=>{e.current=null,n.current&&=(n.current(t.current),null)},a.onerror=r=>{console.error(`[SpeechRecognition] error:`,r.error),e.current=null,n.current&&=(n.current(t.current),null)};try{a.start()}catch(e){console.error(`[SpeechRecognition] start failed:`,e)}},[]),stop:(0,j.useCallback)(()=>new Promise(r=>{let i=e.current;if(!i){r(t.current);return}n.current=r;try{i.stop()}catch{e.current=null,r(t.current),n.current=null}setTimeout(()=>{n.current&&(n.current(t.current),n.current=null,e.current=null)},2e3)}),[]),abort:(0,j.useCallback)(()=>{t.current=``;let r=e.current;if(r){try{r.abort()}catch{}e.current=null}n.current&&=(n.current(``),null)},[]),isSupported:r}}function cN(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function lN(e,t=4*1024*1024){return new Promise(n=>{let r=new Image;r.onload=()=>{let e=1600,{width:i,height:a}=r;if(i>e||a>e){let t=Math.min(e/i,e/a);i=Math.round(i*t),a=Math.round(a*t)}let o=document.createElement(`canvas`);o.width=i,o.height=a,o.getContext(`2d`).drawImage(r,0,0,i,a);for(let e of[.8,.6,.4,.3]){let r=o.toDataURL(`image/jpeg`,e);if(Math.round((r.length-23)*.75)<=t){n(r);return}}n(o.toDataURL(`image/jpeg`,.2))},r.onerror=()=>n(e),r.src=e})}var uN=`bloby_draft`;function dN({onSend:e,onStop:t,streaming:n,whisperEnabled:r,onTranscribe:i,onRecordingChange:a,onAudioReady:o}){let{start:s,stop:c,abort:l,isSupported:u}=sN(),d=r||u,[f,p]=(0,j.useState)(()=>{try{return localStorage.getItem(uN)||``}catch{return``}}),[m,h]=(0,j.useState)([]),g=(0,j.useRef)(null),[v,b]=(0,j.useState)(!1),S=(0,j.useCallback)(e=>{b(e),a?.(e)},[a]),[C,T]=(0,j.useState)(0),E=f.trim().length>0,D=E||m.length>0,te=(0,j.useRef)(null),ne=(0,j.useRef)(null),re=(0,j.useRef)(null),ie=(0,j.useRef)(null),ae=(0,j.useRef)(null),oe=(0,j.useRef)(0),O=(0,j.useRef)(0),ce=(0,j.useRef)(null),le=(0,j.useRef)(!1),ue=(0,j.useRef)(!1),de=(0,j.useRef)(null),k=(0,j.useRef)(null),fe=(0,j.useRef)([]),pe=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=te.current;e&&(e.style.height=`0px`,e.style.height=`${Math.min(e.scrollHeight,88)}px`)},[f]),(0,j.useEffect)(()=>(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{try{localStorage.setItem(uN,f)}catch{}},500),()=>{g.current&&clearTimeout(g.current)}),[f]),(0,j.useEffect)(()=>{if(v)return de.current=setInterval(()=>T(e=>e+1),1e3),()=>{de.current&&clearInterval(de.current)}},[v]);let me=(0,j.useCallback)(async t=>{de.current&&clearInterval(de.current),ce.current&&=(clearTimeout(ce.current),null),le.current=!1;let n=k.current,r=pe.current;if(t)r?.getTracks().forEach(e=>e.stop()),k.current=null,pe.current=null,fe.current=[],l();else if(n&&n.state!==`inactive`)n.onstop=async()=>{r?.getTracks().forEach(e=>e.stop());let t=new Blob(fe.current,{type:`audio/webm`});if(fe.current=[],k.current=null,pe.current=null,t.size<1e3)return;let n=new FileReader;n.onloadend=async()=>{let t=n.result,r=t.split(`,`)[1];if(!r)return;o?.(t);let a=m.length>0?m:void 0;try{let n;n=i?await i(r):await(await fetch(`/api/whisper/transcribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({audio:r})})).json(),e(n.transcript?.trim()||``,a,t)}catch(n){console.error(`[InputBar] Whisper transcription error:`,n),e(``,a,t)}a&&h([])},n.readAsDataURL(t)},n.stop();else{r?.getTracks().forEach(e=>e.stop()),k.current=null,pe.current=null,fe.current=[];try{let t=await c();if(t.trim()){let n=m.length>0?m:void 0;e(t.trim(),n),n&&h([])}}catch(e){console.error(`[InputBar] Web Speech stop error:`,e)}}ae.current&&(ae.current.style.transform=``),S(!1),T(0),O.current=0},[e,i,m,r,l,c]),A=(0,j.useCallback)(e=>{let t=e.type.startsWith(`image/`),n=e.type===`application/pdf`;if(!t&&!n)return;let r=new FileReader;r.onload=async n=>{let r=n.target?.result;t&&(r=await lN(r)),h(n=>[...n,{id:Math.random().toString(36).slice(2),type:t?`image`:`file`,name:e.name,preview:r}])},r.readAsDataURL(e)},[]),he=(0,j.useCallback)(e=>{let t=e.target.files;if(t){for(let e=0;e<t.length;e++)A(t[e]);e.target.value=``}},[A]),ve=(0,j.useCallback)(e=>{h(t=>t.filter(t=>t.id!==e))},[]);(0,j.useEffect)(()=>{let e=e=>{if(e.clipboardData?.items){for(let t of e.clipboardData.items)if(t.type.startsWith(`image/`)){e.preventDefault();let n=t.getAsFile();n&&A(n)}}};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[A]);let ye=()=>{if(D){e(f,m.length>0?m:void 0),p(``),h([]);try{localStorage.removeItem(uN)}catch{}requestAnimationFrame(()=>te.current?.focus())}},xe=`ontouchstart`in window||navigator.maxTouchPoints>0,Se=(0,j.useCallback)(async()=>{if(d)try{if(r){let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(!(!xe&&!ue.current)&&xe&&!ue.current){e.getTracks().forEach(e=>e.stop());return}pe.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:`audio/webm`,n=new MediaRecorder(e,{mimeType:t});fe.current=[],n.ondataavailable=e=>{e.data.size>0&&fe.current.push(e.data)},k.current=n,n.start()}else if(s(!xe),xe&&!ue.current){l();return}le.current=!0,S(!0),T(0)}catch(e){console.error(`[InputBar] recording setup failed:`,e)}},[d,r,s,l]),Ce=(0,j.useCallback)(e=>{if(e.preventDefault(),!xe){if(v){me(!1);return}ue.current=!0,Se();return}ue.current=!0,oe.current=e.clientX,O.current=0,e.currentTarget.setPointerCapture(e.pointerId),ce.current=setTimeout(()=>{try{navigator.vibrate?.(50)}catch{}Se()},200)},[xe,v,d,Se,me]),we=(0,j.useCallback)(e=>{if(!xe||!le.current)return;let t=Math.min(0,e.clientX-oe.current);if(O.current=t,ae.current&&(ae.current.style.transform=`translateX(${t}px)`),ie.current){let t=ie.current.getBoundingClientRect(),n=t.left+t.width/2;Math.abs(e.clientX-n)<36&&me(!0)}},[xe,me]),Te=(0,j.useCallback)(()=>{ue.current=!1,ce.current&&=(clearTimeout(ce.current),null),xe&&le.current&&me(!1)},[xe,me]),Ee=(0,j.useCallback)(()=>{ue.current=!1,ce.current&&=(clearTimeout(ce.current),null),le.current&&me(!0)},[me]);return(0,M.jsxs)(`div`,{className:`shrink-0 p-3 relative`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col transition-opacity duration-100 ${v?`opacity-0 pointer-events-none`:`opacity-100`}`,children:[(0,M.jsx)(w,{children:m.length>0&&(0,M.jsx)(x.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:`overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex gap-2 px-3 pt-2.5 pb-2 flex-wrap bg-white/[0.04] border border-white/[0.08] rounded-2xl mb-2`,children:m.map(e=>(0,M.jsxs)(`div`,{className:`relative group flex-shrink-0`,children:[e.type===`image`?(0,M.jsx)(`img`,{src:e.preview,alt:e.name,className:`w-14 h-14 rounded-lg object-cover border border-white/10`}):(0,M.jsxs)(`div`,{className:`w-14 h-14 rounded-lg bg-white/5 border border-white/10 flex flex-col items-center justify-center gap-0.5 px-1`,children:[(0,M.jsx)(`svg`,{className:`w-5 h-5 text-muted-foreground`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.5,children:(0,M.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z`})}),(0,M.jsx)(`span`,{className:`text-[8px] text-muted-foreground truncate w-full text-center`,children:e.name.split(`.`).pop()})]}),(0,M.jsx)(`button`,{onClick:()=>ve(e.id),className:`absolute -top-1.5 -right-1.5 w-4 h-4 bg-black/80 border border-white/20 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,M.jsx)(y,{className:`w-2.5 h-2.5 text-white`})})]},e.id))})})}),(0,M.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex-1 flex items-end bg-white rounded-2xl px-4`,children:[(0,M.jsx)(`textarea`,{ref:te,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{let t=`ontouchstart`in window||navigator.maxTouchPoints>0;e.key===`Enter`&&!e.shiftKey&&!t&&(e.preventDefault(),D&&ye())},placeholder:`Type a message...`,rows:1,className:`flex-1 resize-none bg-transparent text-gray-900 py-3 text-sm outline-none placeholder:text-gray-400 overflow-y-auto`,style:{maxHeight:88}}),(0,M.jsx)(`input`,{ref:ne,type:`file`,className:`hidden`,accept:`image/*,.pdf`,multiple:!0,onChange:he}),(0,M.jsx)(`input`,{ref:re,type:`file`,className:`hidden`,accept:`image/*`,capture:`environment`,onChange:he}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>ne.current?.click(),className:`shrink-0 p-1.5 mb-2 text-gray-400 hover:text-gray-600 transition-colors`,children:(0,M.jsx)(ge,{className:`h-4 w-4`})}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>re.current?.click(),className:`shrink-0 p-1.5 mb-2 text-gray-400 hover:text-gray-600 transition-colors`,children:(0,M.jsx)(se,{className:`h-4 w-4`})})]}),E?(0,M.jsx)(`button`,{onClick:ye,className:`flex items-center justify-center h-12 w-12 shrink-0 rounded-full bg-white text-gray-900 transition-colors hover:bg-gray-100`,children:(0,M.jsx)(_e,{className:`h-4 w-4`})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center h-12 w-12 shrink-0 rounded-full transition-colors touch-none select-none ${d?`bg-gradient-brand text-white cursor-pointer`:`bg-gray-200 text-gray-400 cursor-default`}`,title:d?void 0:`Voice input requires Chrome, Edge, or Safari. Enable Whisper in Settings for any browser.`,onPointerDown:d?Ce:void 0,onPointerMove:d?we:void 0,onPointerUp:d?Te:void 0,onPointerCancel:d?Ee:void 0,children:(0,M.jsx)(_,{className:`h-4 w-4`})})]})]}),(0,M.jsx)(w,{children:v&&(0,M.jsx)(x.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:`absolute inset-0 p-3 flex items-center touch-none`,children:(0,M.jsxs)(`div`,{className:`flex items-center w-full gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,M.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0`,children:[(0,M.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-destructive opacity-75`}),(0,M.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-destructive`})]}),(0,M.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:cN(C)})]}),(0,M.jsx)(`div`,{className:`flex-1 flex items-center bg-muted rounded-full h-12 pl-1 pr-0.5`,children:xe?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{ref:ie,className:`flex items-center justify-center h-9 w-9 shrink-0 rounded-full bg-destructive/10 text-destructive`,children:(0,M.jsx)(ee,{className:`h-4 w-4`})}),(0,M.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0`,children:(0,M.jsx)(x.span,{className:`text-[13px] whitespace-nowrap select-none font-medium`,style:{backgroundImage:`linear-gradient(90deg, #999 0%, #999 35%, #fff 50%, #999 65%, #999 100%)`,backgroundSize:`200% 100%`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`},animate:{backgroundPosition:[`200% center`,`-200% center`]},transition:{duration:2.5,repeat:1/0,ease:`linear`},children:`◄◄ slide to cancel`})}),(0,M.jsx)(`div`,{ref:ae,className:`shrink-0 touch-none select-none will-change-transform relative z-10`,style:{transition:`none`},onPointerDown:Ce,onPointerMove:we,onPointerUp:Te,onPointerCancel:Ee,children:(0,M.jsx)(`div`,{className:`flex items-center justify-center h-11 w-11 rounded-full bg-destructive text-destructive-foreground`,style:{animation:`mic-pulse-scale 2s ease-in-out infinite`},children:(0,M.jsx)(_,{className:`h-5 w-5`})})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{onClick:()=>me(!0),className:`flex items-center justify-center h-9 w-9 shrink-0 rounded-full bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors`,children:(0,M.jsx)(ee,{className:`h-4 w-4`})}),(0,M.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0`,children:(0,M.jsx)(`span`,{className:`text-[13px] whitespace-nowrap select-none font-medium text-muted-foreground`,children:`Click mic to stop`})}),(0,M.jsx)(`button`,{onClick:()=>me(!1),className:`shrink-0`,children:(0,M.jsx)(`div`,{className:`flex items-center justify-center h-11 w-11 rounded-full bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors`,children:(0,M.jsx)(be,{className:`h-4 w-4`})})})]})})]})})})]})}var fN=`/morphy/headphones.json`,pN=`/morphy/`,mN=null,hN=null;function gN(){return mN&&hN?Promise.resolve({img:mN,cfg:hN}):fetch(fN).then(e=>{if(!e.ok)throw Error(`hp config `+e.status);return e.json()}).then(e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{mN=r,hN=e,t({img:r,cfg:e})},r.onerror=n,r.src=pN+e.spritesheet}))}function _N({recording:e,height:t=36,onDone:n}){let r=(0,j.useRef)(null),i=(0,j.useRef)(mN),a=(0,j.useRef)(hN),o=(0,j.useRef)(`idle`),s=(0,j.useRef)(0),c=(0,j.useRef)(1),l=(0,j.useRef)(0),u=(0,j.useRef)(0),d=(0,j.useRef)(!1),f=(0,j.useRef)(n);f.current=n;let p=a.current,m=p?p.frame.w:180,h=p?p.frame.h:180,g=t,_=Math.round(m/h*g);(0,j.useEffect)(()=>{gN().then(({img:e,cfg:t})=>{i.current=e,a.current=t,o.current===`idle`&&(s.current=t.clips.idle.from)})},[]),(0,j.useEffect)(()=>{let t=a.current;t&&(e&&!d.current?(o.current=`activating`,s.current=t.clips.enter.from,c.current=1,l.current=performance.now()):!e&&d.current&&(o.current===`activating`?o.current=`activating_then_deactivate`:o.current===`recording`&&(o.current=`deactivating`,s.current=t.clips.exit.from,l.current=performance.now())),d.current=e)},[e]);let v=(0,j.useCallback)(e=>{let t=r.current,n=i.current,d=a.current;if(!t){u.current=requestAnimationFrame(v);return}let p=t.getContext(`2d`),m=o.current;if(!n||!d){p.clearRect(0,0,_,g),u.current=requestAnimationFrame(v);return}if(m===`idle`){let e=d.grid.cols,t=d.frame.w,r=d.frame.h,i=d.clips.idle.from,a=i%e,o=Math.floor(i/e);p.clearRect(0,0,_,g),p.imageSmoothingEnabled=!0,p.imageSmoothingQuality=`high`,p.drawImage(n,a*t,o*r,t,r,0,0,_,g),u.current=requestAnimationFrame(v);return}let h=d.fps,y=1e3/(m===`activating`||m===`activating_then_deactivate`?d.clips.enter.fps??h:m===`deactivating`?d.clips.exit.fps??h:d.clips.active.fps??h),b=e-l.current;if(b>=y){if(l.current=e-b%y,m===`activating`||m===`activating_then_deactivate`)s.current++,s.current>d.clips.enter.to&&(m===`activating_then_deactivate`?(o.current=`deactivating`,s.current=d.clips.exit.from):(o.current=`recording`,s.current=d.clips.active.from,c.current=1));else if(m===`recording`)s.current+=c.current,s.current>=d.clips.active.to?(s.current=d.clips.active.to,c.current=-1):s.current<=d.clips.active.from&&(s.current=d.clips.active.from,c.current=1);else if(m===`deactivating`&&(s.current++,s.current>d.clips.exit.to)){o.current=`idle`,s.current=d.clips.idle.from,p.clearRect(0,0,_,g),f.current?.(),u.current=requestAnimationFrame(v);return}}let x=d.grid.cols,S=d.frame.w,C=d.frame.h,w=s.current%x,T=Math.floor(s.current/x);p.clearRect(0,0,_,g),p.imageSmoothingEnabled=!0,p.imageSmoothingQuality=`high`,p.drawImage(n,w*S,T*C,S,C,0,0,_,g),u.current=requestAnimationFrame(v)},[_,g]);return(0,j.useEffect)(()=>{let e=r.current;if(!e)return;let t=window.devicePixelRatio||1;return e.width=_*t,e.height=g*t,e.getContext(`2d`).setTransform(t,0,0,t,0,0),u.current=requestAnimationFrame(v),()=>cancelAnimationFrame(u.current)},[v,_,g]),(0,M.jsx)(`canvas`,{ref:r,style:{width:_,height:g,display:`block`}})}function vN(){let e=(0,j.useRef)(null),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(`Bloby`),[l,u]=(0,j.useState)(!1),[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),[C,w]=(0,j.useState)(0),ee=(0,j.useRef)(null),D=(0,j.useRef)(!1),[ne,re]=(0,j.useState)(!0),[se,O]=(0,j.useState)(null),[ce,le]=(0,j.useState)(null),[ue,k]=(0,j.useState)(!1),[fe,pe]=(0,j.useState)(!1),[A,he]=(0,j.useState)(`loading`);function ge(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}async function _e(){try{if(await Notification.requestPermission()!==`granted`){he(`denied`);return}let t=await navigator.serviceWorker.ready,{publicKey:n}=await(await fetch(`/api/push/vapid-public-key`)).json(),r=(await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:ge(n)})).toJSON(),i=e.current;i&&i.send(`push:subscribe`,{endpoint:r.endpoint,keys:r.keys}),he(`subscribed`)}catch(e){console.error(`[push] Subscribe failed:`,e)}}async function ye(){try{let t=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(t){let n=t.endpoint;await t.unsubscribe();let r=e.current;r&&r.send(`push:unsubscribe`,{endpoint:n})}he(`unsubscribed`)}catch(e){console.error(`[push] Unsubscribe failed:`,e)}}let[be,xe]=(0,j.useState)(!1),Ce=/iPad|iPhone|iPod/.test(navigator.userAgent),Ee=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone,Oe=/Android|iPhone|iPad|iPod|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ke=window.self!==window.top;(0,j.useEffect)(()=>{let e=e=>{e.data?.type===`bloby:show-ios-install`&&xe(!0)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]);let[Ae,je]=(0,j.useState)(!1),[Me,Ne]=(0,j.useState)(!1),[Pe,Fe]=(0,j.useState)(!1),[Ie,Le]=(0,j.useState)(!1);(0,j.useEffect)(()=>{(async()=>{try{let e=await(await fetch(`/api/onboard/status`)).json();if(e.totpEnabled&&Le(!0),!e.portalConfigured){Ne(!1),Fe(!0),je(!0);return}Ne(!0);let t=S();if(t){if((await(await fetch(`/api/portal/validate-token?token=${encodeURIComponent(t)}`)).json()).valid){Fe(!0),je(!0);return}d()}Fe(!1),je(!0)}catch{Fe(!0),je(!0)}})()},[]);let Re=e=>{p(e),Fe(!0)};(0,j.useEffect)(()=>{T(()=>{Fe(!1),Ne(!0)})},[]),(0,j.useEffect)(()=>{if(!Pe)return;let e=()=>{fetch(`/app/api/health`).then(e=>re(e.ok)).catch(()=>re(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[Pe]),(0,j.useEffect)(()=>{Pe&&(async()=>{if(!(`PushManager`in window)||!(`serviceWorker`in navigator)){he(`unsupported`);return}if(Notification.permission===`denied`){he(`denied`);return}try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();he(e&&(await(await v(`/api/push/status?endpoint=${encodeURIComponent(e.endpoint)}`)).json()).subscribed?`subscribed`:`unsubscribed`)}catch{he(`unsupported`)}})()},[Pe]),(0,j.useEffect)(()=>{if(!Pe)return;let t=location.protocol===`https:`?`wss:`:`ws:`,r=location.host,a=new we(`${t}//${r}/bloby/ws`,S);e.current=a;let o=()=>{fetch(`/__bloby/version`,{cache:`no-store`}).then(e=>e.json()).then(e=>{if(!(!e?.version||e.version===`unknown`||e.version===`0.69.3`)){try{let e=Number(sessionStorage.getItem(`bloby_version_reload`)||0);if(Date.now()-e<5*6e4)return;sessionStorage.setItem(`bloby_version_reload`,String(Date.now()))}catch{}window.parent===window?location.reload():(window.parent.postMessage({type:`bloby:version-changed`},location.origin),setTimeout(()=>location.reload(),1500))}}).catch(()=>{})},s=a.onStatus(e=>{n(e),e&&(i(!1),o()),e&&D.current&&w(e=>e+1),D.current=e}),c=a.on(`agent:updating`,()=>i(!0)),l=a.on(`app:rebuilding`,()=>{window.parent?.postMessage({type:`bloby:rebuilding`},`*`)}),u=a.on(`app:rebuilt`,()=>{window.parent?.postMessage({type:`bloby:rebuilt`},`*`)}),d=a.on(`app:build-error`,e=>{window.parent?.postMessage({type:`bloby:build-error`,error:e.error},`*`)}),f=a.on(`app:hmr-update`,()=>{window.parent?.postMessage({type:`bloby:hmr-update`},`*`)}),p=a.on(`bot:response`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)}),m=a.on(`chat:sync`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)});return a.connect(),()=>{s(),c(),l(),u(),d(),f(),p(),m(),a.disconnect()}},[Pe]),(0,j.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),4*6e4);return()=>clearTimeout(e)},[r]),(0,j.useEffect)(()=>{if(!Pe)return;let e=setTimeout(()=>o(!0),3e3);return()=>clearTimeout(e)},[Pe]),(0,j.useEffect)(()=>{Pe&&(v(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&c(e.agent_name),e.whisper_enabled===`true`&&u(!0)}).catch(()=>{}),v(`/api/wallet/balance`).then(e=>e.json()).then(e=>{e.address&&(O(e.tempo??`0.00`),le(e.base??`0.00`))}).catch(()=>{}))},[Pe]),(0,j.useEffect)(()=>{if(!m)return;let e=e=>{ee.current&&!ee.current.contains(e.target)&&(h(!1),_(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[m]);let{messages:ze,streaming:Be,streamBuffer:Ve,tools:He,hasMore:Ue,loadOlder:We,sendMessage:Ge,addPendingAudio:Ke,stopStreaming:qe,clearContext:Je}=Te(e.current,C,Pe),Ye=r||!t&&a;return(0,j.useEffect)(()=>{let t=async t=>{if(t.data?.type!==`bloby:voice-record`||Ye)return;let{audio:n,transcript:r}=t.data;if(n&&l){let t=e.current;if(!t?.connected)return;try{let e=await new Promise((e,r)=>{let i=t.on(`whisper:result`,t=>{i(),clearTimeout(a),e(t)}),a=setTimeout(()=>{i(),r(Error(`Timeout`))},3e4);t.send(`whisper:transcribe`,{audio:n})});e.transcript?.trim()&&Ge(e.transcript.trim(),void 0,`data:audio/webm;base64,${n}`)}catch(e){console.error(`[BlobyApp] widget voice transcription error:`,e)}}else r?.trim()&&Ge(r.trim())};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[Ge,l,Ye]),Ae?Me&&!Pe?(0,M.jsx)(De,{onLogin:Re,totpEnabled:Ie}):(0,M.jsxs)(`div`,{className:`flex flex-col h-dvh overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex items-center px-4 py-3.5 border-b border-white/[0.06] shrink-0`,children:[(0,M.jsx)(`button`,{onClick:()=>window.parent?.postMessage({type:`bloby:close`},`*`),className:`flex items-center justify-center h-8 w-8 -ml-1 rounded-full text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,"aria-label":`Close chat`,children:(0,M.jsx)(te,{className:`h-[18px] w-[18px]`})}),(0,M.jsx)(`div`,{className:`relative ml-1.5 shrink-0 -translate-y-[5px]`,children:(0,M.jsx)(_N,{recording:fe,height:36})}),(0,M.jsxs)(`div`,{className:`flex flex-col ml-2.5 min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[15px] font-semibold leading-tight tracking-[-0.01em]`,children:s}),(0,M.jsx)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:(0,M.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,M.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-amber-400 animate-pulse`:t?`bg-emerald-500`:`bg-red-500`}`}),r?`Updating…`:t?`Online`:`Offline`]})})]}),(0,M.jsx)(`div`,{className:`flex-1`}),(se!==null||ce!==null)&&(0,M.jsxs)(`div`,{className:`relative mr-1.5`,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:[(0,M.jsxs)(`div`,{className:`flex items-center rounded-xl bg-white/[0.04] border border-white/[0.06] pl-3 pr-1 py-1`,children:[(0,M.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/70 mr-1.5`,children:[(0,M.jsx)(`span`,{className:`hidden sm:inline`,children:`My `}),`Wallet:`]}),(0,M.jsxs)(`span`,{className:`text-[13px] font-semibold font-mono tracking-tight`,children:[`$`,(Number(se??0)+Number(ce??0)).toFixed(2)]}),(0,M.jsx)(`div`,{className:`w-px h-4 bg-white/[0.08] mx-2`}),(0,M.jsxs)(`a`,{href:`https://www.bloby.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] font-semibold text-primary bg-primary/10 hover:bg-primary/20 px-2.5 py-1 rounded-lg transition-colors`,children:[(0,M.jsx)(`span`,{className:`sm:hidden`,children:`+`}),(0,M.jsx)(`span`,{className:`hidden sm:inline`,children:`+ Add`})]})]}),ue&&(0,M.jsx)(`div`,{className:`absolute right-0 top-full pt-1.5 z-50`,children:(0,M.jsxs)(`div`,{className:`min-w-[220px] rounded-xl border border-white/[0.06] bg-popover py-2 shadow-xl`,children:[(0,M.jsx)(`div`,{className:`px-3.5 pb-2 text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:`Balances`}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-3.5 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`img`,{src:`https://cdn.jsdelivr.net/gh/atomiclabs/cryptocurrency-icons@master/svg/color/usdc.svg`,alt:`USDC`,className:`h-5 w-5`}),(0,M.jsxs)(`span`,{className:`text-[13px] font-semibold font-mono tracking-tight`,children:[`$`,Number(se??0).toFixed(2)]})]}),(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`on Tempo`})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-3.5 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`img`,{src:`https://cdn.jsdelivr.net/gh/atomiclabs/cryptocurrency-icons@master/svg/color/usdc.svg`,alt:`USDC`,className:`h-5 w-5`}),(0,M.jsxs)(`span`,{className:`text-[13px] font-semibold font-mono tracking-tight`,children:[`$`,Number(ce??0).toFixed(2)]})]}),(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`on Base`})]})]})})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[A!==`loading`&&A!==`unsupported`&&(0,M.jsx)(`button`,{onClick:()=>{A===`subscribed`?ye():A===`unsubscribed`&&_e()},disabled:A===`denied`,className:`flex items-center justify-center h-8 w-8 rounded-full text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,title:A===`denied`?`Notifications blocked — enable in browser settings`:A===`subscribed`?`Disable push notifications`:`Enable push notifications`,children:A===`denied`?(0,M.jsx)(ie,{className:`h-[18px] w-[18px]`}):A===`subscribed`?(0,M.jsx)(ae,{className:`h-[18px] w-[18px] text-primary`}):(0,M.jsx)(oe,{className:`h-[18px] w-[18px]`})}),(0,M.jsxs)(`div`,{className:`relative`,ref:ee,children:[(0,M.jsx)(`button`,{onClick:()=>h(e=>{let t=!e;return t||_(!1),t}),className:`flex items-center justify-center h-8 w-8 rounded-full text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:(0,M.jsx)(de,{className:`h-[18px] w-[18px]`})}),m&&(0,M.jsxs)(`div`,{className:`absolute right-0 top-full mt-1.5 min-w-[200px] rounded-xl border border-white/[0.06] bg-popover py-1.5 shadow-xl z-50`,children:[(0,M.jsxs)(`button`,{onClick:()=>{x(!0),h(!1),_(!1)},className:`flex w-full items-center gap-2.5 px-3.5 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:[(0,M.jsx)(Se,{className:`h-4 w-4`}),`Settings`]}),g?(0,M.jsxs)(`div`,{className:`px-3.5 py-2`,children:[(0,M.jsx)(`p`,{className:`text-[12px] text-muted-foreground/70 mb-2 leading-snug`,children:`Start fresh? This clears the agent's context — your past messages stay saved.`}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{onClick:()=>{Je(),_(!1),h(!1)},className:`flex-1 text-[12px] font-medium text-white bg-[#0069FE] hover:bg-[#0069FE]/90 px-2.5 py-1.5 rounded-lg transition-colors`,children:`New chat`}),(0,M.jsx)(`button`,{onClick:()=>_(!1),className:`flex-1 text-[12px] font-medium text-muted-foreground bg-white/[0.06] hover:bg-white/[0.1] px-2.5 py-1.5 rounded-lg transition-colors`,children:`Cancel`})]})]}):(0,M.jsxs)(`button`,{onClick:()=>_(!0),className:`flex w-full items-center gap-2.5 px-3.5 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:[(0,M.jsx)(me,{className:`h-4 w-4`}),`New conversation`]}),Oe&&!Ee&&(0,M.jsxs)(`button`,{onClick:()=>{h(!1),_(!1),ke?window.parent.postMessage({type:`bloby:install-app`},`*`):xe(!0)},className:`flex w-full items-center gap-2.5 px-3.5 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:[(0,M.jsx)(f,{className:`h-4 w-4`}),`Install App`]})]})]})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,M.jsx)(iN,{messages:ze,streaming:Be,streamBuffer:Ve,tools:He,hasMore:Ue,onLoadOlder:We}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(dN,{onSend:(e,t,n)=>{Ye||Ge(e,t,n)},onStop:qe,streaming:Be,whisperEnabled:l,onTranscribe:t=>new Promise((n,r)=>{let i=e.current;if(!i?.connected){r(Error(`WebSocket not connected`));return}let a=i.on(`whisper:result`,e=>{a(),clearTimeout(o),n(e)}),o=setTimeout(()=>{a(),r(Error(`Transcription timeout`))},3e4);i.send(`whisper:transcribe`,{audio:t})}),onAudioReady:Ke,onRecordingChange:pe}),Ye&&(0,M.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/70 backdrop-blur-[2px]`,children:(0,M.jsxs)(`span`,{className:`flex items-center gap-2 text-[12px] text-muted-foreground bg-white/[0.05] border border-white/[0.08] rounded-full px-3.5 py-1.5 shadow-lg`,children:[(0,M.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r?`bg-amber-400`:`bg-red-500`}`}),r?`Updating — back in a moment…`:`Offline — waiting for connection…`]})})]})]}),b&&(0,M.jsx)(E,{onSave:t=>new Promise((n,r)=>{let i=e.current;if(!i?.connected){r(Error(`WebSocket not connected`));return}let a=i.on(`settings:saved`,e=>{a(),clearTimeout(s),n(e)}),o=i.on(`settings:save-error`,e=>{o(),clearTimeout(s),r(Error(e.error||`Save failed`))}),s=setTimeout(()=>{a(),o(),r(Error(`Save timeout`))},1e4);i.send(`settings:save`,t)}),onTunnelSwitch:t=>new Promise((n,r)=>{let i=e.current;if(!i?.connected){r(Error(`Not connected`));return}let a=i.on(`tunnel:switched`,e=>{a(),o(),clearTimeout(s),n(e)}),o=i.on(`tunnel:switch-error`,e=>{a(),o(),clearTimeout(s),r(Error(e.error))}),s=setTimeout(()=>{a(),o(),r(Error(`Timeout`))},3e4);i.send(`tunnel:switch`,{mode:t})}),onComplete:()=>{x(!1),v(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&c(e.agent_name),u(e.whisper_enabled===`true`)}).catch(()=>{}),window.parent?.postMessage({type:`bloby:onboard-complete`},`*`)}}),be&&(0,M.jsxs)(`div`,{className:`fixed inset-0 z-[300] flex items-end sm:items-center justify-center p-4`,children:[(0,M.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>xe(!1)}),(0,M.jsxs)(`div`,{className:`relative w-full max-w-[360px] bg-[#1c1c1e] border border-white/[0.08] rounded-2xl shadow-2xl overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-5 pb-2`,children:[(0,M.jsx)(`h2`,{className:`text-[17px] font-semibold text-white`,children:`Install App`}),(0,M.jsx)(`button`,{onClick:()=>xe(!1),className:`h-7 w-7 rounded-full bg-white/[0.08] flex items-center justify-center text-white/50 hover:text-white/80 transition-colors`,children:(0,M.jsx)(y,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`px-5 pb-6 pt-1`,children:[(0,M.jsx)(`p`,{className:`text-white/50 text-[13px] mb-5 leading-relaxed`,children:`Add Bloby to your home screen for a full-screen app experience.`}),Ce?(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`1`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Tap the Share button`}),(0,M.jsxs)(`p`,{className:`text-white/40 text-[12px] mt-0.5 flex items-center gap-1.5`,children:[`The `,(0,M.jsx)(ve,{className:`h-3.5 w-3.5 inline`}),` icon at the bottom of Safari`]})]})]}),(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`2`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Scroll down and tap`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`"Add to Home Screen"`})]})]}),(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`3`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Tap "Add"`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`Bloby will appear on your home screen`})]})]})]}):(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`1`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Open browser menu`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`Tap the three-dot menu in your browser`})]})]}),(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`2`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Tap "Install app" or "Add to Home screen"`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`Bloby will be installed as a standalone app`})]})]})]}),(0,M.jsx)(`button`,{onClick:()=>xe(!1),className:`w-full mt-5 py-2.5 bg-white/[0.06] hover:bg-white/[0.1] text-white text-[14px] font-medium rounded-xl transition-colors`,children:`Got it`})]})]})]})]}):(0,M.jsx)(`div`,{className:`flex items-center justify-center h-dvh`,children:(0,M.jsx)(`div`,{className:`w-6 h-6 border-2 border-white/10 border-t-white/50 rounded-full animate-spin`})})}Ce.createRoot(document.getElementById(`root`)).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(vN,{})}));export{kC as i,jx as n,TC as r,rx as t};
|
|
294
|
+
</style></head><body>${t}</body></html>`),n.document.close())}function eN(e){let t=e.target.closest(`[title="View fullscreen"]`);if(t){e.stopPropagation(),e.preventDefault();let n=t.closest(`[data-streamdown]`)?.querySelector(`table`)??t.closest(`.group`)?.querySelector(`table`);n&&$M(n)}}function tN({role:e,content:t,timestamp:n,hasAttachments:r,audioData:i,attachments:a,onImageClick:o,transcribing:s}){let c=e===`user`,l=n?KM(n):``,{tag:u,body:d}=qM(t),f=a?.filter(e=>e.mediaType?.startsWith(`image/`))||[],p=a?.filter(e=>!e.mediaType?.startsWith(`image/`))||[],m=f.filter(e=>e.filePath).map(e=>e.filePath.startsWith(`data:`)?e.filePath:`/api/files/${e.filePath}`);if(c)return(0,M.jsxs)(`div`,{className:`flex flex-col items-end gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`group relative max-w-[85%]`,children:[(0,M.jsx)(QM,{text:d}),(0,M.jsxs)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed whitespace-pre-wrap bg-primary text-primary-foreground break-words`,children:[m.length>0&&(0,M.jsx)(`div`,{className:`flex gap-1.5 flex-wrap mb-2`,children:m.map((e,t)=>(0,M.jsx)(MM,{src:e,alt:f[t]?.name||`attachment`,className:`w-28 h-28 rounded-lg object-cover cursor-pointer border border-white/10 hover:opacity-80 transition-opacity`,onClick:()=>o?.(m,t)},t))}),p.length>0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-primary-foreground/60 mr-1.5`,children:[(0,M.jsx)(ge,{className:`h-3 w-3`}),p.length>1&&(0,M.jsx)(`span`,{className:`text-xs`,children:p.length})]}),!a?.length&&r&&(0,M.jsx)(`span`,{className:`inline-flex items-center gap-1 text-primary-foreground/60 mr-1.5`,children:(0,M.jsx)(ge,{className:`h-3 w-3`})}),s&&(0,M.jsxs)(`div`,{className:`flex flex-col gap-1.5 mb-1`,children:[(0,M.jsx)(`div`,{className:`h-3 w-48 max-w-full rounded bg-white/15 animate-pulse`}),(0,M.jsx)(`div`,{className:`h-3 w-32 max-w-full rounded bg-white/10 animate-pulse`})]}),d,i&&(0,M.jsx)(`div`,{className:`mt-2 pt-2 border-t border-white/10`,children:(0,M.jsx)(jM,{audioData:i})})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 px-1 self-end`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] text-muted-foreground/40`,children:[(0,M.jsx)(JM,{tag:u}),u]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50`,children:l})]})]});let h=e=>(0,M.jsx)(DC,{mode:`static`,plugins:{code:OM},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!0,fullscreen:!0}},shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,components:{a({href:e,children:t}){return e?.includes(`/api/channels/whatsapp/qr-page`)?(0,M.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 my-2 px-3.5 py-2.5 rounded-xl bg-[#25D366]/10 border border-[#25D366]/20 hover:bg-[#25D366]/15 transition-colors no-underline`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-[#25D366] shrink-0`,children:(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`w-4 h-4 fill-white`,children:(0,M.jsx)(`path`,{d:`M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z`})})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[#25D366] font-medium text-sm`,children:`Click here to pair your WhatsApp`}),(0,M.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Opens QR code pairing page`})]}),(0,M.jsx)(re,{className:`w-3.5 h-3.5 text-muted-foreground/50 ml-auto shrink-0`})]}):e?.includes(`/api/channels/alexa/pair-page`)?(0,M.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 my-2 px-3.5 py-2.5 rounded-xl bg-[#00CAFF]/10 border border-[#00CAFF]/20 hover:bg-[#00CAFF]/15 transition-colors no-underline`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-[#00CAFF] shrink-0`,children:(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`w-4 h-4 fill-white`,children:(0,M.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z`})})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[#00CAFF] font-medium text-sm`,children:`Click here to connect Alexa`}),(0,M.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Generates a one-time linking code`})]}),(0,M.jsx)(re,{className:`w-3.5 h-3.5 text-muted-foreground/50 ml-auto shrink-0`})]}):e?.includes(`/api/channels/telegram/pair-page`)?(0,M.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 my-2 px-3.5 py-2.5 rounded-xl bg-[#229ED9]/10 border border-[#229ED9]/20 hover:bg-[#229ED9]/15 transition-colors no-underline`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-[#229ED9] shrink-0`,children:(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`w-4 h-4 fill-white`,children:(0,M.jsx)(`path`,{d:`M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.81c-.19.91-.74 1.13-1.5.71l-4.13-3.05-1.99 1.93c-.23.23-.42.42-.83.42z`})})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[#229ED9] font-medium text-sm`,children:`Click here to connect Telegram`}),(0,M.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Opens the Telegram pairing page`})]}),(0,M.jsx)(re,{className:`w-3.5 h-3.5 text-muted-foreground/50 ml-auto shrink-0`})]}):(0,M.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-[#0069FE] underline decoration-[#0069FE]/30 underline-offset-2 hover:decoration-[#0069FE] transition-colors`,children:t})}},children:YM(e)});if(ZM(d)){let e=XM(d);return(0,M.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`group relative w-full`,children:[(0,M.jsx)(QM,{text:d}),(0,M.jsx)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed bg-muted text-foreground prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 break-words`,onClickCapture:eN,children:e.map((e,t)=>e.type===`text`?(0,M.jsx)(`div`,{children:h(e.value)},t):e.type===`env`?(0,M.jsx)(NM,{group:e.group},t):e.type===`bloby-image`?(0,M.jsx)(FM,{src:e.src,alt:e.alt},t):e.type===`bloby-text`?(0,M.jsx)(RM,{title:e.title,content:e.content},t):e.type===`notch`?(0,M.jsx)(VM,{format:e.format,content:e.content,cardType:e.cardType},t):e.type===`morphy-action`?(0,M.jsx)(GM,{actionType:e.actionType,content:e.content},t):e.type===`mac-actions`?e.actions.map((e,n)=>e.type===`card`?(0,M.jsx)(VM,{format:`card`,content:JSON.stringify(e.data??{}),cardType:e.preset},`${t}-${n}`):(0,M.jsx)(GM,{actionType:e.type??`action`,content:JSON.stringify(e)},`${t}-${n}`)):null)})]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 px-1`,children:l})]})}return(0,M.jsxs)(`div`,{className:`flex flex-col items-start gap-0.5`,children:[(0,M.jsxs)(`div`,{className:`group relative w-full`,children:[(0,M.jsx)(QM,{text:d}),(0,M.jsx)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm leading-relaxed bg-muted text-foreground prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 break-words`,onClickCapture:eN,children:h(d)})]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 px-1`,children:l})]})}function nN({text:e,toolName:t}){return e?(0,M.jsx)(`div`,{className:`flex flex-col items-start`,children:(0,M.jsx)(`div`,{className:`w-full rounded-2xl px-4 py-2.5 text-sm leading-relaxed bg-muted text-foreground prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 break-words`,children:(0,M.jsx)(DC,{mode:`streaming`,isAnimating:!0,caret:`block`,plugins:{code:OM},controls:!1,shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,children:e})})}):(0,M.jsx)(`div`,{className:`flex justify-start`,children:(0,M.jsx)(`div`,{className:`rounded-2xl px-4 py-2.5 text-sm bg-muted text-foreground`,children:(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 h-5`,children:[(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-muted-foreground/60 animate-bounce`,style:{animationDelay:`0ms`}}),(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-muted-foreground/60 animate-bounce`,style:{animationDelay:`150ms`}}),(0,M.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-muted-foreground/60 animate-bounce`,style:{animationDelay:`300ms`}})]})})})}function rN({images:e,index:t,onClose:n,onNavigate:r}){let i=(0,j.useCallback)(()=>{t>0&&r(t-1)},[t,r]),a=(0,j.useCallback)(()=>{t<e.length-1&&r(t+1)},[t,e.length,r]),o=kM(e[t]);return(0,j.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n(),e.key===`ArrowLeft`&&i(),e.key===`ArrowRight`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,i,a]),(0,M.jsx)(w,{children:(0,M.jsxs)(x.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:`fixed inset-0 z-50 flex items-center justify-center bg-black/90`,onClick:n,children:[(0,M.jsxs)(`div`,{className:`absolute top-4 right-4 z-10 flex gap-2`,children:[(0,M.jsx)(`button`,{onClick:async n=>{n.stopPropagation();try{let n=await(await v(e[t])).blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e[t].split(`/`).pop()||`image`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}catch{window.open(e[t],`_blank`)}},className:`p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,title:`Download`,children:(0,M.jsx)(f,{className:`h-5 w-5`})}),(0,M.jsx)(`button`,{onClick:n,className:`p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,children:(0,M.jsx)(y,{className:`h-5 w-5`})})]}),e.length>1&&(0,M.jsxs)(`div`,{className:`absolute top-4 left-1/2 -translate-x-1/2 text-white/70 text-sm tabular-nums`,children:[t+1,` / `,e.length]}),t>0&&(0,M.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},className:`absolute left-3 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,children:(0,M.jsx)(O,{className:`h-6 w-6`})}),t<e.length-1&&(0,M.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},className:`absolute right-3 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors text-white`,children:(0,M.jsx)(ce,{className:`h-6 w-6`})}),o?(0,M.jsx)(`img`,{src:o,alt:``,className:`max-h-[85vh] max-w-[90vw] object-contain rounded-lg`,onClick:e=>e.stopPropagation()}):(0,M.jsx)(`div`,{className:`h-40 w-40 rounded-lg bg-white/10 animate-pulse`,onClick:e=>e.stopPropagation()})]})})}function iN({messages:e,streaming:t,streamBuffer:n,tools:r,hasMore:i,onLoadOlder:a}){let o=(0,j.useRef)(null),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)(!0),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(null),m=(0,j.useCallback)((e,t)=>{p({images:e,index:t})},[]);(0,j.useEffect)(()=>{o.current&&(l.current&&e.length>0?(o.current.scrollIntoView({behavior:`instant`}),l.current=!1):l.current||o.current.scrollIntoView({behavior:`smooth`}))},[e,n,r,t]),(0,j.useEffect)(()=>{if(!c.current||!a)return;let e=c.current,t=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&i&&!u){let e=s.current;if(!e)return;let t=e.scrollHeight;d(!0),await a(),d(!1),requestAnimationFrame(()=>{let n=e.scrollHeight;e.scrollTop+=n-t})}},{root:s.current,threshold:.1});return t.observe(e),()=>t.disconnect()},[i,u,a]);let h=r.length>0?r[r.length-1]:null,g=h?.status===`running`?h.name:void 0;return(0,M.jsxs)(`div`,{ref:s,className:`flex-1 overflow-y-auto overflow-x-hidden p-4 flex flex-col min-h-0`,children:[(0,M.jsx)(`div`,{className:`flex-1`}),i&&(0,M.jsx)(`div`,{ref:c,className:`flex justify-center py-2`,children:u&&(0,M.jsx)(`div`,{className:`w-5 h-5 border-2 border-muted-foreground/20 border-t-muted-foreground/60 rounded-full animate-spin`})}),e.length===0&&!t&&(0,M.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:`Start a conversation with your Bloby..`}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[e.map(e=>(0,M.jsx)(tN,{role:e.role,content:e.content,timestamp:e.timestamp,hasAttachments:e.hasAttachments,audioData:e.audioData,attachments:e.attachments,onImageClick:m,transcribing:e.transcribing},e.id)),t&&(0,M.jsx)(nN,{text:n.replace(/^\[(Mac|Alexa|WhatsApp|Chat|PWA|Workspace|workspace)\]\s*/i,``).replace(/<notch_card\s+type="[^"]*">[\s\S]*?<\/notch_card>/gi,``).replace(/<notch_html>[\s\S]*?<\/notch_html>/gi,``).replace(/<notch_(?:html|card)\b[\s\S]*$/i,``).replace(/<morphy_action\s+type="[^"]*">[\s\S]*?<\/morphy_action>/gi,``).replace(/<morphy_action\b[\s\S]*$/i,``).replace(/<mac_actions>[\s\S]*?<\/mac_actions>/gi,``).replace(/<mac_actions\b[\s\S]*$/i,``).trimEnd(),toolName:g})]}),(0,M.jsx)(`div`,{ref:o}),f&&(0,M.jsx)(rN,{images:f.images,index:f.index,onClose:()=>p(null),onNavigate:e=>p(t=>t?{...t,index:e}:null)})]})}var aN=()=>typeof window>`u`?null:window.SpeechRecognition??window.webkitSpeechRecognition??null,oN=aN()!==null;function sN(){let e=(0,j.useRef)(null),t=(0,j.useRef)(``),n=(0,j.useRef)(null),r=(0,j.useMemo)(()=>oN,[]);return{start:(0,j.useCallback)((r=!1)=>{let i=aN();if(!i)return;if(e.current)try{e.current.abort()}catch{}let a=new i;a.continuous=r,a.interimResults=!0,a.lang=navigator.language||`en-US`,t.current=``,e.current=a,a.onresult=e=>{t.current=e.results[e.results.length-1][0].transcript},a.onend=()=>{e.current=null,n.current&&=(n.current(t.current),null)},a.onerror=r=>{console.error(`[SpeechRecognition] error:`,r.error),e.current=null,n.current&&=(n.current(t.current),null)};try{a.start()}catch(e){console.error(`[SpeechRecognition] start failed:`,e)}},[]),stop:(0,j.useCallback)(()=>new Promise(r=>{let i=e.current;if(!i){r(t.current);return}n.current=r;try{i.stop()}catch{e.current=null,r(t.current),n.current=null}setTimeout(()=>{n.current&&(n.current(t.current),n.current=null,e.current=null)},2e3)}),[]),abort:(0,j.useCallback)(()=>{t.current=``;let r=e.current;if(r){try{r.abort()}catch{}e.current=null}n.current&&=(n.current(``),null)},[]),isSupported:r}}function cN(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function lN(e,t=4*1024*1024){return new Promise(n=>{let r=new Image;r.onload=()=>{let e=1600,{width:i,height:a}=r;if(i>e||a>e){let t=Math.min(e/i,e/a);i=Math.round(i*t),a=Math.round(a*t)}let o=document.createElement(`canvas`);o.width=i,o.height=a,o.getContext(`2d`).drawImage(r,0,0,i,a);for(let e of[.8,.6,.4,.3]){let r=o.toDataURL(`image/jpeg`,e);if(Math.round((r.length-23)*.75)<=t){n(r);return}}n(o.toDataURL(`image/jpeg`,.2))},r.onerror=()=>n(e),r.src=e})}var uN=`bloby_draft`;function dN({onSend:e,onStop:t,streaming:n,whisperEnabled:r,onTranscribe:i,onRecordingChange:a,onAudioReady:o}){let{start:s,stop:c,abort:l,isSupported:u}=sN(),d=r||u,[f,p]=(0,j.useState)(()=>{try{return localStorage.getItem(uN)||``}catch{return``}}),[m,h]=(0,j.useState)([]),g=(0,j.useRef)(null),[v,b]=(0,j.useState)(!1),S=(0,j.useCallback)(e=>{b(e),a?.(e)},[a]),[C,T]=(0,j.useState)(0),E=f.trim().length>0,D=E||m.length>0,te=(0,j.useRef)(null),ne=(0,j.useRef)(null),re=(0,j.useRef)(null),ie=(0,j.useRef)(null),ae=(0,j.useRef)(null),oe=(0,j.useRef)(0),O=(0,j.useRef)(0),ce=(0,j.useRef)(null),le=(0,j.useRef)(!1),ue=(0,j.useRef)(!1),de=(0,j.useRef)(null),k=(0,j.useRef)(null),fe=(0,j.useRef)([]),pe=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=te.current;e&&(e.style.height=`0px`,e.style.height=`${Math.min(e.scrollHeight,88)}px`)},[f]),(0,j.useEffect)(()=>(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{try{localStorage.setItem(uN,f)}catch{}},500),()=>{g.current&&clearTimeout(g.current)}),[f]),(0,j.useEffect)(()=>{if(v)return de.current=setInterval(()=>T(e=>e+1),1e3),()=>{de.current&&clearInterval(de.current)}},[v]);let me=(0,j.useCallback)(async t=>{de.current&&clearInterval(de.current),ce.current&&=(clearTimeout(ce.current),null),le.current=!1;let n=k.current,r=pe.current;if(t)r?.getTracks().forEach(e=>e.stop()),k.current=null,pe.current=null,fe.current=[],l();else if(n&&n.state!==`inactive`)n.onstop=async()=>{r?.getTracks().forEach(e=>e.stop());let t=new Blob(fe.current,{type:`audio/webm`});if(fe.current=[],k.current=null,pe.current=null,t.size<1e3)return;let n=new FileReader;n.onloadend=async()=>{let t=n.result,r=t.split(`,`)[1];if(!r)return;o?.(t);let a=m.length>0?m:void 0;try{let n;n=i?await i(r):await(await fetch(`/api/whisper/transcribe`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({audio:r})})).json(),e(n.transcript?.trim()||``,a,t)}catch(n){console.error(`[InputBar] Whisper transcription error:`,n),e(``,a,t)}a&&h([])},n.readAsDataURL(t)},n.stop();else{r?.getTracks().forEach(e=>e.stop()),k.current=null,pe.current=null,fe.current=[];try{let t=await c();if(t.trim()){let n=m.length>0?m:void 0;e(t.trim(),n),n&&h([])}}catch(e){console.error(`[InputBar] Web Speech stop error:`,e)}}ae.current&&(ae.current.style.transform=``),S(!1),T(0),O.current=0},[e,i,m,r,l,c]),A=(0,j.useCallback)(e=>{let t=e.type.startsWith(`image/`),n=e.type===`application/pdf`;if(!t&&!n)return;let r=new FileReader;r.onload=async n=>{let r=n.target?.result;t&&(r=await lN(r)),h(n=>[...n,{id:Math.random().toString(36).slice(2),type:t?`image`:`file`,name:e.name,preview:r}])},r.readAsDataURL(e)},[]),he=(0,j.useCallback)(e=>{let t=e.target.files;if(t){for(let e=0;e<t.length;e++)A(t[e]);e.target.value=``}},[A]),ve=(0,j.useCallback)(e=>{h(t=>t.filter(t=>t.id!==e))},[]);(0,j.useEffect)(()=>{let e=e=>{if(e.clipboardData?.items){for(let t of e.clipboardData.items)if(t.type.startsWith(`image/`)){e.preventDefault();let n=t.getAsFile();n&&A(n)}}};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[A]);let ye=()=>{if(D){e(f,m.length>0?m:void 0),p(``),h([]);try{localStorage.removeItem(uN)}catch{}requestAnimationFrame(()=>te.current?.focus())}},xe=`ontouchstart`in window||navigator.maxTouchPoints>0,Se=(0,j.useCallback)(async()=>{if(d)try{if(r){let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(!(!xe&&!ue.current)&&xe&&!ue.current){e.getTracks().forEach(e=>e.stop());return}pe.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:`audio/webm`,n=new MediaRecorder(e,{mimeType:t});fe.current=[],n.ondataavailable=e=>{e.data.size>0&&fe.current.push(e.data)},k.current=n,n.start()}else if(s(!xe),xe&&!ue.current){l();return}le.current=!0,S(!0),T(0)}catch(e){console.error(`[InputBar] recording setup failed:`,e)}},[d,r,s,l]),Ce=(0,j.useCallback)(e=>{if(e.preventDefault(),!xe){if(v){me(!1);return}ue.current=!0,Se();return}ue.current=!0,oe.current=e.clientX,O.current=0,e.currentTarget.setPointerCapture(e.pointerId),ce.current=setTimeout(()=>{try{navigator.vibrate?.(50)}catch{}Se()},200)},[xe,v,d,Se,me]),we=(0,j.useCallback)(e=>{if(!xe||!le.current)return;let t=Math.min(0,e.clientX-oe.current);if(O.current=t,ae.current&&(ae.current.style.transform=`translateX(${t}px)`),ie.current){let t=ie.current.getBoundingClientRect(),n=t.left+t.width/2;Math.abs(e.clientX-n)<36&&me(!0)}},[xe,me]),Te=(0,j.useCallback)(()=>{ue.current=!1,ce.current&&=(clearTimeout(ce.current),null),xe&&le.current&&me(!1)},[xe,me]),Ee=(0,j.useCallback)(()=>{ue.current=!1,ce.current&&=(clearTimeout(ce.current),null),le.current&&me(!0)},[me]);return(0,M.jsxs)(`div`,{className:`shrink-0 p-3 relative`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col transition-opacity duration-100 ${v?`opacity-0 pointer-events-none`:`opacity-100`}`,children:[(0,M.jsx)(w,{children:m.length>0&&(0,M.jsx)(x.div,{initial:{height:0,opacity:0},animate:{height:`auto`,opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:`overflow-hidden`,children:(0,M.jsx)(`div`,{className:`flex gap-2 px-3 pt-2.5 pb-2 flex-wrap bg-white/[0.04] border border-white/[0.08] rounded-2xl mb-2`,children:m.map(e=>(0,M.jsxs)(`div`,{className:`relative group flex-shrink-0`,children:[e.type===`image`?(0,M.jsx)(`img`,{src:e.preview,alt:e.name,className:`w-14 h-14 rounded-lg object-cover border border-white/10`}):(0,M.jsxs)(`div`,{className:`w-14 h-14 rounded-lg bg-white/5 border border-white/10 flex flex-col items-center justify-center gap-0.5 px-1`,children:[(0,M.jsx)(`svg`,{className:`w-5 h-5 text-muted-foreground`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1.5,children:(0,M.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z`})}),(0,M.jsx)(`span`,{className:`text-[8px] text-muted-foreground truncate w-full text-center`,children:e.name.split(`.`).pop()})]}),(0,M.jsx)(`button`,{onClick:()=>ve(e.id),className:`absolute -top-1.5 -right-1.5 w-4 h-4 bg-black/80 border border-white/20 rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,M.jsx)(y,{className:`w-2.5 h-2.5 text-white`})})]},e.id))})})}),(0,M.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex-1 flex items-end bg-white rounded-2xl px-4`,children:[(0,M.jsx)(`textarea`,{ref:te,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{let t=`ontouchstart`in window||navigator.maxTouchPoints>0;e.key===`Enter`&&!e.shiftKey&&!t&&(e.preventDefault(),D&&ye())},placeholder:`Type a message...`,rows:1,className:`flex-1 resize-none bg-transparent text-gray-900 py-3 text-sm outline-none placeholder:text-gray-400 overflow-y-auto`,style:{maxHeight:88}}),(0,M.jsx)(`input`,{ref:ne,type:`file`,className:`hidden`,accept:`image/*,.pdf`,multiple:!0,onChange:he}),(0,M.jsx)(`input`,{ref:re,type:`file`,className:`hidden`,accept:`image/*`,capture:`environment`,onChange:he}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>ne.current?.click(),className:`shrink-0 p-1.5 mb-2 text-gray-400 hover:text-gray-600 transition-colors`,children:(0,M.jsx)(ge,{className:`h-4 w-4`})}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>re.current?.click(),className:`shrink-0 p-1.5 mb-2 text-gray-400 hover:text-gray-600 transition-colors`,children:(0,M.jsx)(se,{className:`h-4 w-4`})})]}),E?(0,M.jsx)(`button`,{onClick:ye,className:`flex items-center justify-center h-12 w-12 shrink-0 rounded-full bg-white text-gray-900 transition-colors hover:bg-gray-100`,children:(0,M.jsx)(_e,{className:`h-4 w-4`})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center h-12 w-12 shrink-0 rounded-full transition-colors touch-none select-none ${d?`bg-gradient-brand text-white cursor-pointer`:`bg-gray-200 text-gray-400 cursor-default`}`,title:d?void 0:`Voice input requires Chrome, Edge, or Safari. Enable Whisper in Settings for any browser.`,onPointerDown:d?Ce:void 0,onPointerMove:d?we:void 0,onPointerUp:d?Te:void 0,onPointerCancel:d?Ee:void 0,children:(0,M.jsx)(_,{className:`h-4 w-4`})})]})]}),(0,M.jsx)(w,{children:v&&(0,M.jsx)(x.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},className:`absolute inset-0 p-3 flex items-center touch-none`,children:(0,M.jsxs)(`div`,{className:`flex items-center w-full gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,M.jsxs)(`span`,{className:`relative flex h-2 w-2 shrink-0`,children:[(0,M.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-destructive opacity-75`}),(0,M.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-destructive`})]}),(0,M.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:cN(C)})]}),(0,M.jsx)(`div`,{className:`flex-1 flex items-center bg-muted rounded-full h-12 pl-1 pr-0.5`,children:xe?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{ref:ie,className:`flex items-center justify-center h-9 w-9 shrink-0 rounded-full bg-destructive/10 text-destructive`,children:(0,M.jsx)(ee,{className:`h-4 w-4`})}),(0,M.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0`,children:(0,M.jsx)(x.span,{className:`text-[13px] whitespace-nowrap select-none font-medium`,style:{backgroundImage:`linear-gradient(90deg, #999 0%, #999 35%, #fff 50%, #999 65%, #999 100%)`,backgroundSize:`200% 100%`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundClip:`text`},animate:{backgroundPosition:[`200% center`,`-200% center`]},transition:{duration:2.5,repeat:1/0,ease:`linear`},children:`◄◄ slide to cancel`})}),(0,M.jsx)(`div`,{ref:ae,className:`shrink-0 touch-none select-none will-change-transform relative z-10`,style:{transition:`none`},onPointerDown:Ce,onPointerMove:we,onPointerUp:Te,onPointerCancel:Ee,children:(0,M.jsx)(`div`,{className:`flex items-center justify-center h-11 w-11 rounded-full bg-destructive text-destructive-foreground`,style:{animation:`mic-pulse-scale 2s ease-in-out infinite`},children:(0,M.jsx)(_,{className:`h-5 w-5`})})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{onClick:()=>me(!0),className:`flex items-center justify-center h-9 w-9 shrink-0 rounded-full bg-destructive/10 text-destructive hover:bg-destructive/20 transition-colors`,children:(0,M.jsx)(ee,{className:`h-4 w-4`})}),(0,M.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0`,children:(0,M.jsx)(`span`,{className:`text-[13px] whitespace-nowrap select-none font-medium text-muted-foreground`,children:`Click mic to stop`})}),(0,M.jsx)(`button`,{onClick:()=>me(!1),className:`shrink-0`,children:(0,M.jsx)(`div`,{className:`flex items-center justify-center h-11 w-11 rounded-full bg-destructive text-destructive-foreground hover:bg-destructive/90 transition-colors`,children:(0,M.jsx)(be,{className:`h-4 w-4`})})})]})})]})})})]})}var fN=`/morphy/headphones.json`,pN=`/morphy/`,mN=null,hN=null;function gN(){return mN&&hN?Promise.resolve({img:mN,cfg:hN}):fetch(fN).then(e=>{if(!e.ok)throw Error(`hp config `+e.status);return e.json()}).then(e=>new Promise((t,n)=>{let r=new Image;r.onload=()=>{mN=r,hN=e,t({img:r,cfg:e})},r.onerror=n,r.src=pN+e.spritesheet}))}function _N({recording:e,height:t=36,onDone:n}){let r=(0,j.useRef)(null),i=(0,j.useRef)(mN),a=(0,j.useRef)(hN),o=(0,j.useRef)(`idle`),s=(0,j.useRef)(0),c=(0,j.useRef)(1),l=(0,j.useRef)(0),u=(0,j.useRef)(0),d=(0,j.useRef)(!1),f=(0,j.useRef)(n);f.current=n;let p=a.current,m=p?p.frame.w:180,h=p?p.frame.h:180,g=t,_=Math.round(m/h*g);(0,j.useEffect)(()=>{gN().then(({img:e,cfg:t})=>{i.current=e,a.current=t,o.current===`idle`&&(s.current=t.clips.idle.from)})},[]),(0,j.useEffect)(()=>{let t=a.current;t&&(e&&!d.current?(o.current=`activating`,s.current=t.clips.enter.from,c.current=1,l.current=performance.now()):!e&&d.current&&(o.current===`activating`?o.current=`activating_then_deactivate`:o.current===`recording`&&(o.current=`deactivating`,s.current=t.clips.exit.from,l.current=performance.now())),d.current=e)},[e]);let v=(0,j.useCallback)(e=>{let t=r.current,n=i.current,d=a.current;if(!t){u.current=requestAnimationFrame(v);return}let p=t.getContext(`2d`),m=o.current;if(!n||!d){p.clearRect(0,0,_,g),u.current=requestAnimationFrame(v);return}if(m===`idle`){let e=d.grid.cols,t=d.frame.w,r=d.frame.h,i=d.clips.idle.from,a=i%e,o=Math.floor(i/e);p.clearRect(0,0,_,g),p.imageSmoothingEnabled=!0,p.imageSmoothingQuality=`high`,p.drawImage(n,a*t,o*r,t,r,0,0,_,g),u.current=requestAnimationFrame(v);return}let h=d.fps,y=1e3/(m===`activating`||m===`activating_then_deactivate`?d.clips.enter.fps??h:m===`deactivating`?d.clips.exit.fps??h:d.clips.active.fps??h),b=e-l.current;if(b>=y){if(l.current=e-b%y,m===`activating`||m===`activating_then_deactivate`)s.current++,s.current>d.clips.enter.to&&(m===`activating_then_deactivate`?(o.current=`deactivating`,s.current=d.clips.exit.from):(o.current=`recording`,s.current=d.clips.active.from,c.current=1));else if(m===`recording`)s.current+=c.current,s.current>=d.clips.active.to?(s.current=d.clips.active.to,c.current=-1):s.current<=d.clips.active.from&&(s.current=d.clips.active.from,c.current=1);else if(m===`deactivating`&&(s.current++,s.current>d.clips.exit.to)){o.current=`idle`,s.current=d.clips.idle.from,p.clearRect(0,0,_,g),f.current?.(),u.current=requestAnimationFrame(v);return}}let x=d.grid.cols,S=d.frame.w,C=d.frame.h,w=s.current%x,T=Math.floor(s.current/x);p.clearRect(0,0,_,g),p.imageSmoothingEnabled=!0,p.imageSmoothingQuality=`high`,p.drawImage(n,w*S,T*C,S,C,0,0,_,g),u.current=requestAnimationFrame(v)},[_,g]);return(0,j.useEffect)(()=>{let e=r.current;if(!e)return;let t=window.devicePixelRatio||1;return e.width=_*t,e.height=g*t,e.getContext(`2d`).setTransform(t,0,0,t,0,0),u.current=requestAnimationFrame(v),()=>cancelAnimationFrame(u.current)},[v,_,g]),(0,M.jsx)(`canvas`,{ref:r,style:{width:_,height:g,display:`block`}})}function vN(){let e=(0,j.useRef)(null),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(`Bloby`),[l,u]=(0,j.useState)(!1),[m,h]=(0,j.useState)(!1),[g,_]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),[C,w]=(0,j.useState)(0),ee=(0,j.useRef)(null),D=(0,j.useRef)(!1),[ne,re]=(0,j.useState)(!0),[se,O]=(0,j.useState)(null),[ce,le]=(0,j.useState)(null),[ue,k]=(0,j.useState)(!1),[fe,pe]=(0,j.useState)(!1),[A,he]=(0,j.useState)(`loading`);function ge(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}async function _e(){try{if(await Notification.requestPermission()!==`granted`){he(`denied`);return}let t=await navigator.serviceWorker.ready,{publicKey:n}=await(await fetch(`/api/push/vapid-public-key`)).json(),r=(await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:ge(n)})).toJSON(),i=e.current;i&&i.send(`push:subscribe`,{endpoint:r.endpoint,keys:r.keys}),he(`subscribed`)}catch(e){console.error(`[push] Subscribe failed:`,e)}}async function ye(){try{let t=await(await navigator.serviceWorker.ready).pushManager.getSubscription();if(t){let n=t.endpoint;await t.unsubscribe();let r=e.current;r&&r.send(`push:unsubscribe`,{endpoint:n})}he(`unsubscribed`)}catch(e){console.error(`[push] Unsubscribe failed:`,e)}}let[be,xe]=(0,j.useState)(!1),Ce=/iPad|iPhone|iPod/.test(navigator.userAgent),Ee=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone,Oe=/Android|iPhone|iPad|iPod|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),ke=window.self!==window.top;(0,j.useEffect)(()=>{let e=e=>{e.data?.type===`bloby:show-ios-install`&&xe(!0)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]);let[Ae,je]=(0,j.useState)(!1),[Me,Ne]=(0,j.useState)(!1),[Pe,Fe]=(0,j.useState)(!1),[Ie,Le]=(0,j.useState)(!1);(0,j.useEffect)(()=>{(async()=>{try{let e=await(await fetch(`/api/onboard/status`)).json();if(e.totpEnabled&&Le(!0),!e.portalConfigured){Ne(!1),Fe(!0),je(!0);return}Ne(!0);let t=S();if(t){if((await(await fetch(`/api/portal/validate-token?token=${encodeURIComponent(t)}`)).json()).valid){Fe(!0),je(!0);return}d()}Fe(!1),je(!0)}catch{Fe(!0),je(!0)}})()},[]);let Re=e=>{p(e),Fe(!0)};(0,j.useEffect)(()=>{T(()=>{Fe(!1),Ne(!0)})},[]),(0,j.useEffect)(()=>{if(!Pe)return;let e=()=>{fetch(`/app/api/health`).then(e=>re(e.ok)).catch(()=>re(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[Pe]),(0,j.useEffect)(()=>{Pe&&(async()=>{if(!(`PushManager`in window)||!(`serviceWorker`in navigator)){he(`unsupported`);return}if(Notification.permission===`denied`){he(`denied`);return}try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();he(e&&(await(await v(`/api/push/status?endpoint=${encodeURIComponent(e.endpoint)}`)).json()).subscribed?`subscribed`:`unsubscribed`)}catch{he(`unsupported`)}})()},[Pe]),(0,j.useEffect)(()=>{if(!Pe)return;let t=location.protocol===`https:`?`wss:`:`ws:`,r=location.host,a=new we(`${t}//${r}/bloby/ws`,S);e.current=a;let o=()=>{let e=``;try{e=new URL(import.meta.url).pathname.split(`/`).pop()||``}catch{return}e.startsWith(`bloby-`)&&fetch(`/bloby/`,{cache:`no-store`}).then(e=>e.ok?e.text():``).then(t=>{let n=t.match(/assets\/(bloby-[A-Za-z0-9_-]+\.js)/)?.[1];if(!(!n||n===e)){try{let e=Number(sessionStorage.getItem(`bloby_version_reload`)||0);if(Date.now()-e<5*6e4)return;sessionStorage.setItem(`bloby_version_reload`,String(Date.now()))}catch{}window.parent===window?location.reload():(window.parent.postMessage({type:`bloby:version-changed`},location.origin),setTimeout(()=>location.reload(),1500))}}).catch(()=>{})},s=a.onStatus(e=>{n(e),e&&(i(!1),o()),e&&D.current&&w(e=>e+1),D.current=e}),c=a.on(`agent:updating`,()=>i(!0)),l=a.on(`app:rebuilding`,()=>{window.parent?.postMessage({type:`bloby:rebuilding`},`*`)}),u=a.on(`app:rebuilt`,()=>{window.parent?.postMessage({type:`bloby:rebuilt`},`*`)}),d=a.on(`app:build-error`,e=>{window.parent?.postMessage({type:`bloby:build-error`,error:e.error},`*`)}),f=a.on(`app:hmr-update`,()=>{window.parent?.postMessage({type:`bloby:hmr-update`},`*`)}),p=a.on(`bot:response`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)}),m=a.on(`chat:sync`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)});return a.connect(),()=>{s(),c(),l(),u(),d(),f(),p(),m(),a.disconnect()}},[Pe]),(0,j.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),4*6e4);return()=>clearTimeout(e)},[r]),(0,j.useEffect)(()=>{if(!Pe)return;let e=setTimeout(()=>o(!0),3e3);return()=>clearTimeout(e)},[Pe]),(0,j.useEffect)(()=>{Pe&&(v(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&c(e.agent_name),e.whisper_enabled===`true`&&u(!0)}).catch(()=>{}),v(`/api/wallet/balance`).then(e=>e.json()).then(e=>{e.address&&(O(e.tempo??`0.00`),le(e.base??`0.00`))}).catch(()=>{}))},[Pe]),(0,j.useEffect)(()=>{if(!m)return;let e=e=>{ee.current&&!ee.current.contains(e.target)&&(h(!1),_(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[m]);let{messages:ze,streaming:Be,streamBuffer:Ve,tools:He,hasMore:Ue,loadOlder:We,sendMessage:Ge,addPendingAudio:Ke,stopStreaming:qe,clearContext:Je}=Te(e.current,C,Pe),Ye=r||!t&&a;return(0,j.useEffect)(()=>{let t=async t=>{if(t.data?.type!==`bloby:voice-record`||Ye)return;let{audio:n,transcript:r}=t.data;if(n&&l){let t=e.current;if(!t?.connected)return;try{let e=await new Promise((e,r)=>{let i=t.on(`whisper:result`,t=>{i(),clearTimeout(a),e(t)}),a=setTimeout(()=>{i(),r(Error(`Timeout`))},3e4);t.send(`whisper:transcribe`,{audio:n})});e.transcript?.trim()&&Ge(e.transcript.trim(),void 0,`data:audio/webm;base64,${n}`)}catch(e){console.error(`[BlobyApp] widget voice transcription error:`,e)}}else r?.trim()&&Ge(r.trim())};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[Ge,l,Ye]),Ae?Me&&!Pe?(0,M.jsx)(De,{onLogin:Re,totpEnabled:Ie}):(0,M.jsxs)(`div`,{className:`flex flex-col h-dvh overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex items-center px-4 py-3.5 border-b border-white/[0.06] shrink-0`,children:[(0,M.jsx)(`button`,{onClick:()=>window.parent?.postMessage({type:`bloby:close`},`*`),className:`flex items-center justify-center h-8 w-8 -ml-1 rounded-full text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,"aria-label":`Close chat`,children:(0,M.jsx)(te,{className:`h-[18px] w-[18px]`})}),(0,M.jsx)(`div`,{className:`relative ml-1.5 shrink-0 -translate-y-[5px]`,children:(0,M.jsx)(_N,{recording:fe,height:36})}),(0,M.jsxs)(`div`,{className:`flex flex-col ml-2.5 min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-[15px] font-semibold leading-tight tracking-[-0.01em]`,children:s}),(0,M.jsx)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:(0,M.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,M.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-amber-400 animate-pulse`:t?`bg-emerald-500`:`bg-red-500`}`}),r?`Updating…`:t?`Online`:`Offline`]})})]}),(0,M.jsx)(`div`,{className:`flex-1`}),(se!==null||ce!==null)&&(0,M.jsxs)(`div`,{className:`relative mr-1.5`,onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),children:[(0,M.jsxs)(`div`,{className:`flex items-center rounded-xl bg-white/[0.04] border border-white/[0.06] pl-3 pr-1 py-1`,children:[(0,M.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/70 mr-1.5`,children:[(0,M.jsx)(`span`,{className:`hidden sm:inline`,children:`My `}),`Wallet:`]}),(0,M.jsxs)(`span`,{className:`text-[13px] font-semibold font-mono tracking-tight`,children:[`$`,(Number(se??0)+Number(ce??0)).toFixed(2)]}),(0,M.jsx)(`div`,{className:`w-px h-4 bg-white/[0.08] mx-2`}),(0,M.jsxs)(`a`,{href:`https://www.bloby.bot/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[11px] font-semibold text-primary bg-primary/10 hover:bg-primary/20 px-2.5 py-1 rounded-lg transition-colors`,children:[(0,M.jsx)(`span`,{className:`sm:hidden`,children:`+`}),(0,M.jsx)(`span`,{className:`hidden sm:inline`,children:`+ Add`})]})]}),ue&&(0,M.jsx)(`div`,{className:`absolute right-0 top-full pt-1.5 z-50`,children:(0,M.jsxs)(`div`,{className:`min-w-[220px] rounded-xl border border-white/[0.06] bg-popover py-2 shadow-xl`,children:[(0,M.jsx)(`div`,{className:`px-3.5 pb-2 text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:`Balances`}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-3.5 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`img`,{src:`https://cdn.jsdelivr.net/gh/atomiclabs/cryptocurrency-icons@master/svg/color/usdc.svg`,alt:`USDC`,className:`h-5 w-5`}),(0,M.jsxs)(`span`,{className:`text-[13px] font-semibold font-mono tracking-tight`,children:[`$`,Number(se??0).toFixed(2)]})]}),(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`on Tempo`})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-3.5 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`img`,{src:`https://cdn.jsdelivr.net/gh/atomiclabs/cryptocurrency-icons@master/svg/color/usdc.svg`,alt:`USDC`,className:`h-5 w-5`}),(0,M.jsxs)(`span`,{className:`text-[13px] font-semibold font-mono tracking-tight`,children:[`$`,Number(ce??0).toFixed(2)]})]}),(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`on Base`})]})]})})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[A!==`loading`&&A!==`unsupported`&&(0,M.jsx)(`button`,{onClick:()=>{A===`subscribed`?ye():A===`unsubscribed`&&_e()},disabled:A===`denied`,className:`flex items-center justify-center h-8 w-8 rounded-full text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,title:A===`denied`?`Notifications blocked — enable in browser settings`:A===`subscribed`?`Disable push notifications`:`Enable push notifications`,children:A===`denied`?(0,M.jsx)(ie,{className:`h-[18px] w-[18px]`}):A===`subscribed`?(0,M.jsx)(ae,{className:`h-[18px] w-[18px] text-primary`}):(0,M.jsx)(oe,{className:`h-[18px] w-[18px]`})}),(0,M.jsxs)(`div`,{className:`relative`,ref:ee,children:[(0,M.jsx)(`button`,{onClick:()=>h(e=>{let t=!e;return t||_(!1),t}),className:`flex items-center justify-center h-8 w-8 rounded-full text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:(0,M.jsx)(de,{className:`h-[18px] w-[18px]`})}),m&&(0,M.jsxs)(`div`,{className:`absolute right-0 top-full mt-1.5 min-w-[200px] rounded-xl border border-white/[0.06] bg-popover py-1.5 shadow-xl z-50`,children:[(0,M.jsxs)(`button`,{onClick:()=>{x(!0),h(!1),_(!1)},className:`flex w-full items-center gap-2.5 px-3.5 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:[(0,M.jsx)(Se,{className:`h-4 w-4`}),`Settings`]}),g?(0,M.jsxs)(`div`,{className:`px-3.5 py-2`,children:[(0,M.jsx)(`p`,{className:`text-[12px] text-muted-foreground/70 mb-2 leading-snug`,children:`Start fresh? This clears the agent's context — your past messages stay saved.`}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{onClick:()=>{Je(),_(!1),h(!1)},className:`flex-1 text-[12px] font-medium text-white bg-[#0069FE] hover:bg-[#0069FE]/90 px-2.5 py-1.5 rounded-lg transition-colors`,children:`New chat`}),(0,M.jsx)(`button`,{onClick:()=>_(!1),className:`flex-1 text-[12px] font-medium text-muted-foreground bg-white/[0.06] hover:bg-white/[0.1] px-2.5 py-1.5 rounded-lg transition-colors`,children:`Cancel`})]})]}):(0,M.jsxs)(`button`,{onClick:()=>_(!0),className:`flex w-full items-center gap-2.5 px-3.5 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:[(0,M.jsx)(me,{className:`h-4 w-4`}),`New conversation`]}),Oe&&!Ee&&(0,M.jsxs)(`button`,{onClick:()=>{h(!1),_(!1),ke?window.parent.postMessage({type:`bloby:install-app`},`*`):xe(!0)},className:`flex w-full items-center gap-2.5 px-3.5 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-white/[0.06] transition-colors`,children:[(0,M.jsx)(f,{className:`h-4 w-4`}),`Install App`]})]})]})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,M.jsx)(iN,{messages:ze,streaming:Be,streamBuffer:Ve,tools:He,hasMore:Ue,onLoadOlder:We}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(dN,{onSend:(e,t,n)=>{Ye||Ge(e,t,n)},onStop:qe,streaming:Be,whisperEnabled:l,onTranscribe:t=>new Promise((n,r)=>{let i=e.current;if(!i?.connected){r(Error(`WebSocket not connected`));return}let a=i.on(`whisper:result`,e=>{a(),clearTimeout(o),n(e)}),o=setTimeout(()=>{a(),r(Error(`Transcription timeout`))},3e4);i.send(`whisper:transcribe`,{audio:t})}),onAudioReady:Ke,onRecordingChange:pe}),Ye&&(0,M.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center bg-background/70 backdrop-blur-[2px]`,children:(0,M.jsxs)(`span`,{className:`flex items-center gap-2 text-[12px] text-muted-foreground bg-white/[0.05] border border-white/[0.08] rounded-full px-3.5 py-1.5 shadow-lg`,children:[(0,M.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r?`bg-amber-400`:`bg-red-500`}`}),r?`Morphy is Updating…`:`Morphy is Offline`]})})]})]}),b&&(0,M.jsx)(E,{onSave:t=>new Promise((n,r)=>{let i=e.current;if(!i?.connected){r(Error(`WebSocket not connected`));return}let a=i.on(`settings:saved`,e=>{a(),clearTimeout(s),n(e)}),o=i.on(`settings:save-error`,e=>{o(),clearTimeout(s),r(Error(e.error||`Save failed`))}),s=setTimeout(()=>{a(),o(),r(Error(`Save timeout`))},1e4);i.send(`settings:save`,t)}),onTunnelSwitch:t=>new Promise((n,r)=>{let i=e.current;if(!i?.connected){r(Error(`Not connected`));return}let a=i.on(`tunnel:switched`,e=>{a(),o(),clearTimeout(s),n(e)}),o=i.on(`tunnel:switch-error`,e=>{a(),o(),clearTimeout(s),r(Error(e.error))}),s=setTimeout(()=>{a(),o(),r(Error(`Timeout`))},3e4);i.send(`tunnel:switch`,{mode:t})}),onComplete:()=>{x(!1),v(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&c(e.agent_name),u(e.whisper_enabled===`true`)}).catch(()=>{}),window.parent?.postMessage({type:`bloby:onboard-complete`},`*`)}}),be&&(0,M.jsxs)(`div`,{className:`fixed inset-0 z-[300] flex items-end sm:items-center justify-center p-4`,children:[(0,M.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>xe(!1)}),(0,M.jsxs)(`div`,{className:`relative w-full max-w-[360px] bg-[#1c1c1e] border border-white/[0.08] rounded-2xl shadow-2xl overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-5 pb-2`,children:[(0,M.jsx)(`h2`,{className:`text-[17px] font-semibold text-white`,children:`Install App`}),(0,M.jsx)(`button`,{onClick:()=>xe(!1),className:`h-7 w-7 rounded-full bg-white/[0.08] flex items-center justify-center text-white/50 hover:text-white/80 transition-colors`,children:(0,M.jsx)(y,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`px-5 pb-6 pt-1`,children:[(0,M.jsx)(`p`,{className:`text-white/50 text-[13px] mb-5 leading-relaxed`,children:`Add Bloby to your home screen for a full-screen app experience.`}),Ce?(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`1`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Tap the Share button`}),(0,M.jsxs)(`p`,{className:`text-white/40 text-[12px] mt-0.5 flex items-center gap-1.5`,children:[`The `,(0,M.jsx)(ve,{className:`h-3.5 w-3.5 inline`}),` icon at the bottom of Safari`]})]})]}),(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`2`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Scroll down and tap`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`"Add to Home Screen"`})]})]}),(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`3`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Tap "Add"`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`Bloby will appear on your home screen`})]})]})]}):(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`1`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Open browser menu`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`Tap the three-dot menu in your browser`})]})]}),(0,M.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,M.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-[#007AFF]/15 text-[#007AFF] text-[13px] font-semibold flex items-center justify-center mt-0.5`,children:`2`}),(0,M.jsxs)(`div`,{className:`flex-1`,children:[(0,M.jsx)(`p`,{className:`text-white text-[14px] font-medium`,children:`Tap "Install app" or "Add to Home screen"`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[12px] mt-0.5`,children:`Bloby will be installed as a standalone app`})]})]})]}),(0,M.jsx)(`button`,{onClick:()=>xe(!1),className:`w-full mt-5 py-2.5 bg-white/[0.06] hover:bg-white/[0.1] text-white text-[14px] font-medium rounded-xl transition-colors`,children:`Got it`})]})]})]})]}):(0,M.jsx)(`div`,{className:`flex items-center justify-center h-dvh`,children:(0,M.jsx)(`div`,{className:`w-6 h-6 border-2 border-white/10 border-t-white/50 rounded-full animate-spin`})})}Ce.createRoot(document.getElementById(`root`)).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(vN,{})}));export{kC as i,jx as n,TC as r,rx as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,r as t,t as n}from"./jsx-runtime-C0W9Wf2W.js";import{n as r,r as i,t as a}from"./bloby-
|
|
1
|
+
import{c as e,r as t,t as n}from"./jsx-runtime-C0W9Wf2W.js";import{n as r,r as i,t as a}from"./bloby-CXmOcb1r.js";var o=e(t(),1),s=n(),c=({code:e,language:t,raw:n,className:c,startLine:l,lineNumbers:u,...d})=>{let{shikiTheme:f}=(0,o.useContext)(i),p=r(),[m,h]=(0,o.useState)(n);return(0,o.useEffect)(()=>{if(!p){h(n);return}let r=p.highlight({code:e,language:t,themes:f},e=>{h(e)});r&&h(r)},[e,t,f,p,n]),(0,s.jsx)(a,{className:c,language:t,lineNumbers:u,result:m,startLine:l,...d})};export{c as HighlightedCodeBlockBody};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./bloby-CXmOcb1r.js";export{e as Mermaid};
|
package/dist-bloby/bloby.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-content" />
|
|
6
6
|
<title>Bloby Chat</title>
|
|
7
|
-
<script type="module" crossorigin src="/bloby/assets/bloby-
|
|
7
|
+
<script type="module" crossorigin src="/bloby/assets/bloby-CXmOcb1r.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/bloby/assets/jsx-runtime-C0W9Wf2W.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/bloby/assets/globals-DpO5tO92.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/bloby/assets/globals-DyeW509Y.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bloby-bot",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.4",
|
|
4
4
|
"releaseNotes": [
|
|
5
5
|
"1. Fix: agent self-update ",
|
|
6
6
|
"1",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"postinstall": "node scripts/postinstall.js",
|
|
49
49
|
"dev:workspace": "vite",
|
|
50
50
|
"dev:docs": "cd ./docs && npx fumapress",
|
|
51
|
-
"sync:pi-models": "tsx scripts/sync-pi-models.ts"
|
|
51
|
+
"sync:pi-models": "tsx scripts/sync-pi-models.ts",
|
|
52
|
+
"prepublishOnly": "vite build --config vite.bloby.config.ts"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"@anthropic-ai/claude-agent-sdk": "^0.3.169",
|
|
@@ -11,9 +11,6 @@ import InputBar from './src/components/Chat/InputBar';
|
|
|
11
11
|
import HeadphonesAnimation from './src/components/Chat/HeadphonesAnimation';
|
|
12
12
|
import './src/styles/globals.css';
|
|
13
13
|
|
|
14
|
-
// Injected at build time (vite.bloby.config.ts define) — the version this bundle shipped with.
|
|
15
|
-
declare const __BLOBY_VERSION__: string;
|
|
16
|
-
|
|
17
14
|
function BlobyApp() {
|
|
18
15
|
const clientRef = useRef<WsClient | null>(null);
|
|
19
16
|
const [connected, setConnected] = useState(false);
|
|
@@ -227,14 +224,21 @@ function BlobyApp() {
|
|
|
227
224
|
clientRef.current = client;
|
|
228
225
|
|
|
229
226
|
// Version handshake — this chat may be running inside the immortal shell, which (by
|
|
230
|
-
// design) survives self-updates. After a reconnect,
|
|
231
|
-
//
|
|
232
|
-
//
|
|
227
|
+
// design) survives self-updates. After a reconnect, ask the only question that matters:
|
|
228
|
+
// "is the bundle I'm running the one the server currently serves?" — by comparing THIS
|
|
229
|
+
// module's hashed filename (import.meta.url) against the entry referenced by the served
|
|
230
|
+
// /bloby/ HTML. NOT a baked version string: that goes stale whenever a release is
|
|
231
|
+
// published without rebuilding dist-bloby, which made every fresh tab/PWA launch reload
|
|
232
|
+
// once (0.69.3-baked bundle vs 0.70.x server, throttle keyed to per-tab sessionStorage).
|
|
233
233
|
const checkPlatformVersion = () => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
let mine = '';
|
|
235
|
+
try { mine = new URL(import.meta.url).pathname.split('/').pop() || ''; } catch { return; }
|
|
236
|
+
if (!mine.startsWith('bloby-')) return; // dev server / unexpected layout — never risk a loop
|
|
237
|
+
fetch('/bloby/', { cache: 'no-store' })
|
|
238
|
+
.then((r) => (r.ok ? r.text() : ''))
|
|
239
|
+
.then((html) => {
|
|
240
|
+
const served = html.match(/assets\/(bloby-[A-Za-z0-9_-]+\.js)/)?.[1];
|
|
241
|
+
if (!served || served === mine) return;
|
|
238
242
|
try {
|
|
239
243
|
// Throttle: one auto-reload per 5 min per tab — if something upstream keeps
|
|
240
244
|
// serving a stale bundle, never loop.
|
package/vite.bloby.config.ts
CHANGED
|
@@ -2,18 +2,10 @@ import { defineConfig } from 'vite';
|
|
|
2
2
|
import react from '@vitejs/plugin-react';
|
|
3
3
|
import tailwindcss from '@tailwindcss/vite';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import { readFileSync } from 'fs';
|
|
6
|
-
|
|
7
|
-
// Baked into the chat bundle; compared against /__bloby/version on reconnect so a chat that
|
|
8
|
-
// survived a self-update inside the immortal shell knows to trigger a one-time full reload.
|
|
9
|
-
const pkgVersion = JSON.parse(readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8')).version;
|
|
10
5
|
|
|
11
6
|
export default defineConfig({
|
|
12
7
|
root: 'supervisor/chat',
|
|
13
8
|
base: '/bloby/',
|
|
14
|
-
define: {
|
|
15
|
-
__BLOBY_VERSION__: JSON.stringify(pkgVersion),
|
|
16
|
-
},
|
|
17
9
|
resolve: {
|
|
18
10
|
alias: { '@': path.resolve(__dirname, 'supervisor/chat/src') },
|
|
19
11
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-content" />
|
|
6
|
-
<meta name="theme-color" content="#
|
|
6
|
+
<meta name="theme-color" content="#0A0A0A" />
|
|
7
7
|
<meta name="mobile-web-app-capable" content="yes" />
|
|
8
8
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
9
9
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
@@ -4,20 +4,32 @@
|
|
|
4
4
|
"description": "Your AI assistant",
|
|
5
5
|
"start_url": "/",
|
|
6
6
|
"display": "standalone",
|
|
7
|
-
"background_color": "#
|
|
8
|
-
"theme_color": "#
|
|
7
|
+
"background_color": "#0A0A0A",
|
|
8
|
+
"theme_color": "#0A0A0A",
|
|
9
9
|
"icons": [
|
|
10
10
|
{
|
|
11
11
|
"src": "/morphy-icon-192.png",
|
|
12
12
|
"sizes": "192x192",
|
|
13
13
|
"type": "image/png",
|
|
14
|
-
"purpose": "any
|
|
14
|
+
"purpose": "any"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"src": "/morphy-icon-512.png",
|
|
18
18
|
"sizes": "512x512",
|
|
19
19
|
"type": "image/png",
|
|
20
|
-
"purpose": "any
|
|
20
|
+
"purpose": "any"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"src": "/morphy-icon-maskable-192.png",
|
|
24
|
+
"sizes": "192x192",
|
|
25
|
+
"type": "image/png",
|
|
26
|
+
"purpose": "maskable"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"src": "/morphy-icon-maskable-512.png",
|
|
30
|
+
"sizes": "512x512",
|
|
31
|
+
"type": "image/png",
|
|
32
|
+
"purpose": "maskable"
|
|
21
33
|
}
|
|
22
34
|
]
|
|
23
35
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./bloby-Dfx1hOe-.js";export{e as Mermaid};
|