bloby-bot 0.55.0 → 0.56.0

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-BwjDEAOv.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]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlighted-body-OFNGDK62-DoHcZIYO.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{a as o,c as s,d as c,f as l,h as u,i as d,l as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b}from"./globals-DSmE2rZO.js";var x=p(`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`}]]),S=p(`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`}]]),C=p(`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`}]]),w=p(`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`}]]),T=p(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),E=p(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),ee=p(`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`}]]),D=p(`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`}]]),te=p(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ne=p(`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`}]]),re=p(`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`}]]),O=p(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),ie=p(`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`}]]),ae=p(`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`}]]),oe=p(`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`}]]),k=p(`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`}]]),se=p(`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`}]]),ce=p(`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`}]]),le=p(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),ue=p(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),A=p(`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`}]]),de=p(`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`}]]),fe=p(`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`}]]),pe=p(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),me=p(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),he=p(`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`}]]),ge=p(`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`}]]),_e=p(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),j=e(i(),1),ve=e(u(),1),ye=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)}},be=`bloby_token`,xe=null;function Se(){return localStorage.getItem(be)}function Ce(e){localStorage.setItem(be,e)}function we(){localStorage.removeItem(be)}function Te(e){xe=e}async function Ee(e,t={}){let n=Se(),r=new Headers(t.headers);n&&r.set(`Authorization`,`Bearer ${n}`);let i=await fetch(e,{...t,headers:r});return i.status===401&&n&&(we(),xe?.()),i}function De(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),v=(0,j.useRef)(!1),y=(0,j.useRef)(``),b=(0,j.useRef)(0),x=(0,j.useRef)(null),S=(0,j.useRef)(null),C=(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(!C.current)return;function e(e){e.data?.type===`bloby:page-context`&&(S.current=e.data.context,console.log(`[blobyChat] Extension page context:`,e.data.context?.url))}return window.addEventListener(`message`,e),window.parent?.postMessage({type:`bloby:request-context`},`*`),()=>window.removeEventListener(`message`,e)},[]);let w=(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}},[]),T=(0,j.useCallback)(async()=>{try{let e=await Ee(`/api/context/current`).then(e=>e.json());if(!e.conversationId)return;o(e.conversationId);let t=await Ee(`/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(w)),m(n.length>=200)}catch{}},[w]),E=(0,j.useCallback)(async()=>{if(!(v.current||!g.current)){v.current=!0;try{let e=r[0]?.id;if(!e)return;let t=await Ee(`/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(w);i(e=>[...a,...e]),n.length<100&&m(!1)}catch{}finally{v.current=!1}}},[r,w]);(0,j.useEffect)(()=>{!n||h.current||(h.current=!0,T())},[n,T]),(0,j.useEffect)(()=>{n&&t&&t>0&&T()},[n,t,T]),(0,j.useEffect)(()=>{if(!n||!t||t===0||!s)return;let e=setInterval(()=>{if(!_.current){clearInterval(e);return}T()},3e3);return()=>clearInterval(e)},[n,t,s,T]),(0,j.useEffect)(()=>{if(!e)return;console.log(`[blobyChat] ──── WS HANDLERS REGISTERED ────`);let t=[e.on(`bot:typing`,()=>{console.log(`[blobyChat] bot:typing → streaming=true`),c(!0),f([])}),e.on(`bot:token`,e=>{c(!0),u(t=>{let n=t+e.token;return y.current=n,n})}),e.on(`bot:tool`,e=>{let t=y.current;t&&(console.log(`[blobyChat] bot:tool (${e.name}) — committing ${t.length} chars as bubble`),b.current+=t.length,i(e=>[...e,{id:`tool-`+Date.now(),role:`assistant`,content:t,timestamp:new Date().toISOString()}]),u(``),y.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||``;b.current>0?(t=t.slice(b.current).replace(/^\n+/,``),b.current=0,console.log(`[blobyChat] bot:response — stripped partial, remaining:`,t.slice(0,60))):console.log(`[blobyChat] bot:response — new bubble`),t.trim()&&i(n=>[...n,{id:e.messageId||Date.now().toString(),role:`assistant`,content:t,timestamp:new Date().toISOString()}]),u(``),y.current=``,f([])}),e.on(`bot:task-created`,()=>{let e=y.current;e&&(console.log(`[blobyChat] bot:task-created — committing stream, showing dots`),b.current+=e.length,i(t=>[...t,{id:`pre-task-`+Date.now(),role:`assistant`,content:e,timestamp:new Date().toISOString()}]),u(``),y.current=``)}),e.on(`bot:idle`,()=>{console.log(`[blobyChat] bot:idle → streaming=false`),c(!1)}),e.on(`bot:error`,e=>{console.log(`[blobyChat] bot:error`),u(``),y.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 ee=(0,j.useCallback)(e=>{let t=`pending-audio-`+Date.now();x.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:E,sendMessage:(0,j.useCallback)((t,n,r)=>{if(!e||!t.trim()&&(!n||n.length===0)&&!r)return;let o=y.current;o&&(console.log(`[blobyChat] Committing partial —`,o.length,`chars`),b.current+=o.length,i(e=>[...e,{id:`partial-`+Date.now(),role:`assistant`,content:o,timestamp:new Date().toISOString()}]),u(``),y.current=``);let s=x.current;if(r&&s)x.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(C.current&&S.current){let e=S.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:ee,stopStreaming:(0,j.useCallback)(()=>{e&&(e.send(`user:stop`,{conversationId:a}),c(!1),u(``),y.current=``,b.current=0,f([]))},[e,a]),clearContext:(0,j.useCallback)(()=>{e&&e.send(`user:clear-context`,{}),i([]),o(null),u(``),y.current=``,b.current=0,c(!1),f([]),h.current=!1},[e])}}var M=a(),Oe=`bloby_login_totp`;function ke({onLogin:e,totpEnabled:t}){let[n,r]=(0,j.useState)(``),[i,a]=(0,j.useState)(``),[s,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(`password`),[p,h]=(0,j.useState)(``),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(!0),[C,w]=(0,j.useState)(!1),T=(0,j.useRef)(null);(0,j.useEffect)(()=>{try{let e=sessionStorage.getItem(Oe);if(!e)return;let t=JSON.parse(e);t.pendingToken&&t.expiresAt>Date.now()?(b(t.pendingToken),f(`totp`)):sessionStorage.removeItem(Oe)}catch{}},[]),(0,j.useEffect)(()=>{d===`totp`&&setTimeout(()=>T.current?.focus(),100)},[d]);function E(e){try{sessionStorage.setItem(Oe,JSON.stringify({pendingToken:e,expiresAt:Date.now()+4.5*60*1e3}))}catch{}}function ee(){try{sessionStorage.removeItem(Oe)}catch{}}let D=async()=>{if(!(!n.trim()||s)){u(!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?(ee(),e(i.token)):r.ok&&i.requiresTOTP?(b(i.pendingToken),E(i.pendingToken),f(`totp`),a(``)):a(i.error||`Invalid password`)}catch{a(`Could not reach server`)}finally{u(!1)}}},te=async()=>{if(!(!p.trim()||s)){u(!0),a(``);try{let t=await fetch(`/api/portal/login/totp?pending=${encodeURIComponent(y)}&code=${encodeURIComponent(p)}&trust=${x?`1`:`0`}`,{credentials:`include`}),n=await t.json();t.ok&&n.token?(ee(),e(n.token)):a(n.error||`Invalid code`)}catch{a(`Could not reach server`)}finally{u(!1)}}},ne=e=>{e.key===`Enter`&&(d===`password`?D():te())},re=()=>{f(`password`),a(``),h(``),w(!1),ee()},O=`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)(_,{mode:`wait`,children:d===`password`?(0,M.jsxs)(m.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)(ae,{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:O}),(0,M.jsx)(`button`,{onClick:D,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)(v,{className:`h-4 w-4 animate-spin`}),`Signing in...`]}):(0,M.jsxs)(M.Fragment,{children:[`Sign In`,(0,M.jsx)(l,{className:`h-4 w-4`})]})})]},`password`):(0,M.jsxs)(m.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)(o,{className:`h-6 w-6 text-[#0069FE]`})}),(0,M.jsx)(`h1`,{className:`text-xl font-bold text-white tracking-tight mb-1`,children:C?`Recovery code`:`Enter your 2FA code`}),(0,M.jsx)(`p`,{className:`text-white/40 text-[13px] mb-6`,children:C?`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:T,type:`text`,inputMode:C?`text`:`numeric`,autoComplete:`one-time-code`,maxLength:C?20:6,value:p,onChange:e=>{h(C?e.target.value:e.target.value.replace(/\D/g,``)),a(``)},onKeyDown:ne,placeholder:C?`Recovery code`:`000000`,autoFocus:!0,className:O+(C?``:` 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:()=>S(e=>!e),className:`w-5 h-5 rounded-md border flex items-center justify-center transition-all ${x?`bg-[#0069FE] border-[#0069FE]`:`bg-white/[0.04] border-white/[0.12]`}`,children:x&&(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:te,disabled:!p.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)(v,{className:`h-4 w-4 animate-spin`}),`Verifying...`]}):(0,M.jsxs)(M.Fragment,{children:[`Verify`,(0,M.jsx)(l,{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)(g,{className:`h-3 w-3`}),`Back`]}),(0,M.jsx)(`button`,{onClick:()=>{w(e=>!e),h(``),a(``)},className:`text-[12px] text-white/30 hover:text-white/50 transition-colors`,children:C?`Use authenticator code`:`Use a recovery code`})]})]},`totp`)})})})}var Ae=(function(e){if(e==null)return Fe;if(typeof e==`function`)return Pe(e);if(typeof e==`object`)return Array.isArray(e)?je(e):Me(e);if(typeof e==`string`)return Ne(e);throw Error(`Expected function, string, or object as test`)});function je(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Ae(e[n]);return Pe(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Me(e){let t=e;return Pe(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Ne(e){return Pe(t);function t(t){return t&&t.type===e}}function Pe(e){return t;function t(t,n,r){return!!(Ie(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function Fe(){return!0}function Ie(e){return typeof e==`object`&&!!e&&`type`in e}function Le(e){return e}var Re=[],ze=`skip`;function Be(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Ae(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 (`+Le(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=Re,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Ve(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 Ve(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Re:[e]}function He(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),Be(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 Ue={indicator:`indicator`,textOnly:`text-only`,remove:`remove`};function We({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=Ue.indicator,imageBlockPolicy:c=Ue.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=et(e,t,n,r,i,a,o,s,c);Xe(l),He(l,u)}}function Ge(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 Ke(e){return typeof e==`string`?e.startsWith(`/`)||e.startsWith(`./`)||e.startsWith(`../`):!1}var qe=new Set([`https:`,`http:`,`irc:`,`ircs:`,`mailto:`,`xmpp:`,`blob:`]),Je=new Set([`javascript:`,`data:`,`file:`,`vbscript:`]);function Ye(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=Ge(e,n);if(!o||Je.has(o.protocol)||!(qe.has(o.protocol)||a.includes(o.protocol)||a.includes(`*`)))return null;if(o.protocol===`mailto:`||!o.protocol.match(/^https?:$/))return o.href;let s=Ke(e);return o&&t.some(e=>{let t=Ge(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 Xe(e){if(`children`in e&&Array.isArray(e.children)){e.children=e.children.filter(e=>e!=null);for(let t of e.children)Xe(t)}}var Ze=Symbol(`node-seen`);function Qe(e,t,n){return t===Ue.remove?{type:`remove`}:t===Ue.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 $e(e,t,n){if(t===Ue.remove)return{type:`remove`};if(t===Ue.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 et=(e,t,n,r,i,a,o,s,c)=>{let l=(u,d,f)=>{if(u.type!==`element`||u[Ze])return!0;if(u.tagName===`a`){let n=Ye(u.properties.href,t,e,!1,!1,i);if(n===null){if(u[Ze]=!0,He(u,l),f&&typeof d==`number`){let e=Qe(u,s,o);if(e.type===`remove`)return f.children.splice(d,1),[ze,d];f.children[d]=e.element}return ze}else return u.properties.href=n,u.properties.target=`_blank`,u.properties.rel=`noopener noreferrer`,!0}if(u.tagName===`img`){let t=Ye(u.properties.src,n,e,r,!0,i);if(t===null){if(u[Ze]=!0,He(u,l),f&&typeof d==`number`){let e=$e(u,c,a);if(e.type===`remove`)return f.children.splice(d,1),[ze,d];f.children[d]=e.element}return ze}else return u.properties.src=t,!0}return!0};return l},tt=typeof self==`object`?self:globalThis,nt=(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 tt[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 tt[a](o),i)};return r},rt=e=>nt(new Map,e)(0),it=``,{toString:at}={},{keys:ot}=Object,st=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=at.call(e).slice(8,-1);switch(n){case`Array`:return[1,it];case`Object`:return[2,it];case`Date`:return[3,it];case`RegExp`:return[4,it];case`Map`:return[5,it];case`Set`:return[6,it];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},ct=([e,t])=>e===0&&(t===`function`||t===`symbol`),lt=(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]=st(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 ot(r))(e||!ct(st(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||!(ct(st(n))||ct(st(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!ct(st(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},ut=(e,{json:t,lossy:n}={})=>{let r=[];return lt(!(t||n),!!t,new Map,r)(e),r},dt=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?rt(ut(e,t)):structuredClone(e):(e,t)=>rt(ut(e,t)),ft=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ft.prototype.normal={},ft.prototype.property={},ft.prototype.space=void 0;function pt(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ft(n,r,t)}function mt(e){return e.toLowerCase()}var ht=class{constructor(e,t){this.attribute=t,this.property=e}};ht.prototype.attribute=``,ht.prototype.booleanish=!1,ht.prototype.boolean=!1,ht.prototype.commaOrSpaceSeparated=!1,ht.prototype.commaSeparated=!1,ht.prototype.defined=!1,ht.prototype.mustUseProperty=!1,ht.prototype.number=!1,ht.prototype.overloadedBoolean=!1,ht.prototype.property=``,ht.prototype.spaceSeparated=!1,ht.prototype.space=void 0;var gt=r({boolean:()=>N,booleanish:()=>vt,commaOrSpaceSeparated:()=>St,commaSeparated:()=>xt,number:()=>P,overloadedBoolean:()=>yt,spaceSeparated:()=>bt}),_t=0,N=Ct(),vt=Ct(),yt=Ct(),P=Ct(),bt=Ct(),xt=Ct(),St=Ct();function Ct(){return 2**++_t}var wt=Object.keys(gt),Tt=class extends ht{constructor(e,t,n,r){let i=-1;if(super(e,t),Et(this,`space`,r),typeof n==`number`)for(;++i<wt.length;){let e=wt[i];Et(this,wt[i],(n&gt[e])===gt[e])}}};Tt.prototype.defined=!0;function Et(e,t,n){n&&(e[t]=n)}function Dt(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Tt(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[mt(r)]=r,n[mt(a.attribute)]=r}return new ft(t,n,e.space)}var Ot=Dt({properties:{ariaActiveDescendant:null,ariaAtomic:vt,ariaAutoComplete:null,ariaBusy:vt,ariaChecked:vt,ariaColCount:P,ariaColIndex:P,ariaColSpan:P,ariaControls:bt,ariaCurrent:null,ariaDescribedBy:bt,ariaDetails:null,ariaDisabled:vt,ariaDropEffect:bt,ariaErrorMessage:null,ariaExpanded:vt,ariaFlowTo:bt,ariaGrabbed:vt,ariaHasPopup:null,ariaHidden:vt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:bt,ariaLevel:P,ariaLive:null,ariaModal:vt,ariaMultiLine:vt,ariaMultiSelectable:vt,ariaOrientation:null,ariaOwns:bt,ariaPlaceholder:null,ariaPosInSet:P,ariaPressed:vt,ariaReadOnly:vt,ariaRelevant:null,ariaRequired:vt,ariaRoleDescription:bt,ariaRowCount:P,ariaRowIndex:P,ariaRowSpan:P,ariaSelected:vt,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 kt(e,t){return t in e?e[t]:t}function At(e,t){return kt(e,t.toLowerCase())}var jt=Dt({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:xt,acceptCharset:bt,accessKey:bt,action:null,allow:null,allowFullScreen:N,allowPaymentRequest:N,allowUserMedia:N,alt:null,as:null,async:N,autoCapitalize:null,autoComplete:bt,autoFocus:N,autoPlay:N,blocking:bt,capture:null,charSet:null,checked:N,cite:null,className:bt,cols:P,colSpan:null,content:null,contentEditable:vt,controls:N,controlsList:bt,coords:P|xt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:N,defer:N,dir:null,dirName:null,disabled:N,download:yt,draggable:vt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:N,formTarget:null,headers:bt,height:P,hidden:yt,high:P,href:null,hrefLang:null,htmlFor:bt,httpEquiv:bt,id:null,imageSizes:null,imageSrcSet:null,inert:N,inputMode:null,integrity:null,is:null,isMap:N,itemId:null,itemProp:bt,itemRef:bt,itemScope:N,itemType:bt,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:bt,placeholder:null,playsInline:N,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:N,referrerPolicy:null,rel:bt,required:N,reversed:N,rows:P,rowSpan:P,sandbox:bt,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:vt,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:vt,width:P,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:bt,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:vt,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:At}),Mt=Dt({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:St,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:bt,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:xt,g2:xt,glyphName:xt,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:St,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:bt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:P,pointsAtY:P,pointsAtZ:P,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:St,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:St,rev:St,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:St,requiredFeatures:St,requiredFonts:St,requiredFormats:St,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:St,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:St,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:St,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:kt}),Nt=Dt({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()}}),Pt=Dt({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:At}),Ft=Dt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),It={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`},Lt=/[A-Z]/g,Rt=/-[a-z]/g,zt=/^data[-\w.:]+$/i;function Bt(e,t){let n=mt(t),r=t,i=ht;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&zt.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Rt,Ht);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Rt.test(e)){let n=e.replace(Lt,Vt);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Tt}return new i(r,t)}function Vt(e){return`-`+e.toLowerCase()}function Ht(e){return e.charAt(1).toUpperCase()}var Ut=pt([Ot,jt,Nt,Pt,Ft],`html`),Wt=pt([Ot,Mt,Nt,Pt,Ft],`svg`);function Gt(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 Kt(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var qt=/[#.]/g;function Jt(e,t){let n=e||``,r={},i=0,a,o;for(;i<n.length;){qt.lastIndex=i;let e=qt.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 Yt(e){let t=String(e||``).trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Xt(e){return e.join(` `).trim()}function Zt(e,t,n){let r=n?rn(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=Jt(n,t);let s=o.tagName.toLowerCase(),c=r?r.get(s):void 0;if(o.tagName=c||s,Qt(i))a.unshift(i);else for(let[t,n]of Object.entries(i))$t(e,o.properties,t,n)}for(let e of a)en(o.children,e);return o.type===`element`&&o.tagName===`template`&&(o.content={type:`root`,children:o.children},o.children=[]),o}return i}function Qt(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 $t(e,t,n,r){let i=Bt(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?Yt(r):i.commaSeparated?Gt(r):i.commaOrSpaceSeparated?Yt(Gt(r).join(` `)):tn(i,i.property,r):Array.isArray(r)?[...r]:i.property===`style`?nn(r):String(r);if(Array.isArray(a)){let e=[];for(let t of a)e.push(tn(i,i.property,t));a=e}i.property===`className`&&Array.isArray(t.className)&&(a=t.className.concat(a)),t[i.property]=a}}function en(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)en(e,n);else if(typeof t==`object`&&`type`in t)t.type===`root`?en(e,t.children):e.push(t);else throw Error("Expected node, nodes, or string, got `"+t+"`")}function tn(e,t,n){if(typeof n==`string`){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===``||mt(n)===mt(t)))return!0}return n}function nn(e){let t=[];for(let[n,r]of Object.entries(e))t.push([n,r].join(`: `));return t.join(`; `)}function rn(e){let t=new Map;for(let n of e)t.set(n.toLowerCase(),n);return t}var an=`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(`.`),on=Zt(Ut,`div`),sn=Zt(Wt,`g`,an);function cn(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=ln(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=ln(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 ln(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>${gb(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=_b(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+gb(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=_b(e);if(i===null)return gb(n);e=i;let a=`<img src="${e}" alt="${gb(n)}"`;return t&&(a+=` title="${gb(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:gb(e.text)}},Db=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}},Ob=class e{options;renderer;textRenderer;constructor(e){this.options=e||iy,this.options.renderer=this.options.renderer||new Eb,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Db}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}},kb=class{options;block;constructor(e){this.options=e||iy}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?Tb.lex:Tb.lexInline}provideParser(){return this.block?Ob.parse:Ob.parseInline}},Ab=new class{defaults=ry();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ob;Renderer=Eb;TextRenderer=Db;Lexer=Tb;Tokenizer=wb;Hooks=kb;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 Eb(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 wb(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 kb;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];kb.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&kb.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 Tb.lex(e,t??this.defaults)}parser(e,t){return Ob.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?Tb.lex:Tb.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?Ob.parse:Ob.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?Tb.lex:Tb.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?Ob.parse:Ob.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>`+gb(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function jb(e,t){return Ab.parse(e,t)}jb.options=jb.setOptions=function(e){return Ab.setOptions(e),jb.defaults=Ab.defaults,ay(jb.defaults),jb},jb.getDefaults=ry,jb.defaults=iy,jb.use=function(...e){return Ab.use(...e),jb.defaults=Ab.defaults,ay(jb.defaults),jb},jb.walkTokens=function(e,t){return Ab.walkTokens(e,t)},jb.parseInline=Ab.parseInline,jb.Parser=Ob,jb.parser=Ob.parse,jb.Renderer=Eb,jb.TextRenderer=Db,jb.Lexer=Tb,jb.lexer=Tb.lex,jb.Tokenizer=wb,jb.Hooks=kb,jb.parse=jb,jb.options,jb.setOptions,jb.use,jb.walkTokens,jb.parseInline,Ob.parse,Tb.lex;var Mb=`modulepreload`,Nb=function(e){return`/bloby/`+e},Pb={},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=Nb(t,n),t in Pb)return;Pb[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`:Mb,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)})},Fb=300,Ib=`300px`,Lb=500;function Rb(e={}){let{immediate:t=!1,debounceDelay:n=Fb,rootMargin:r=Ib,idleTimeout:i=Lb}=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 zb=/\s/,Bb=/^\s+$/,Vb=new Set([`code`,`pre`,`svg`,`math`,`annotation`]),Hb=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`element`,Ub=e=>e.some(e=>Hb(e)&&Vb.has(e.tagName)),Wb=e=>{let t=[],n=``,r=!1;for(let i of e){let e=zb.test(i);e!==r&&n&&(t.push(n),n=``),n+=i,r=e}return n&&t.push(n),t},Gb=e=>{let t=[],n=``;for(let r of e)zb.test(r)?n+=r:(n&&=(t.push(n),``),t.push(r));return n&&t.push(n),t},Kb=(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}]}},qb=(e,t,n,r,i)=>{let a=t.at(-1);if(!(a&&`children`in a))return;if(Ub(t))return ze;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`?Gb(c):Wb(c),u=r.prevContentLength,d=l.map(e=>{let t=i.count;if(i.count+=e.length,Bb.test(e))return{type:`text`,value:e};let r=u>0&&t<u,a=r?0:i.newIndex++*n.stagger;return Kb(e,n.animation,n.duration,n.easing,r,a)});return o.children.splice(s,1,...d),s+d.length},Jb=0;function Yb(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=Jb++,i=()=>e=>{let r={count:0,newIndex:0};Be(e,`text`,(e,i)=>qb(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}}}Yb();var Xb=(0,j.createContext)(!1),Zb=()=>(0,j.useContext)(Xb),Qb=(...e)=>Xh(Dm(e)),$b=(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(` `)},ex=e=>e?(...t)=>$b(e,Xh(Dm(t))):Qb,tx=(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)},nx=(0,j.createContext)(Qb),Q=()=>(0,j.useContext)(nx),rx=Qb(`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`),ix=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},ax=(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(rx),[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,ix(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),ox=({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}),sx=(0,j.createContext)({code:``}),cx=()=>(0,j.useContext)(sx),lx=({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})})},ux=e=>{let t=e.length;for(;t>0&&e[t-1]===`
114
- `;)t--;return e.slice(0,t)},dx=(0,j.lazy)(()=>Z(()=>import(`./highlighted-body-OFNGDK62-BwjDEAOv.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),fx=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=Q(),l=(0,j.useMemo)(()=>ux(e),[e]),u=(0,j.useMemo)(()=>({bg:`transparent`,fg:`inherit`,tokens:l.split(`
114
+ `;)t--;return e.slice(0,t)},dx=(0,j.lazy)(()=>Z(()=>import(`./highlighted-body-OFNGDK62-DoHcZIYO.js`).then(e=>({default:e.HighlightedCodeBlockBody})),__vite__mapDeps([0,1]))),fx=({code:e,language:t,className:n,children:r,isIncomplete:i=!1,startLine:a,lineNumbers:o,...s})=>{let c=Q(),l=(0,j.useMemo)(()=>ux(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)(sx.Provider,{value:{code:e},children:(0,M.jsxs)(ox,{isIncomplete:i,language:t,children:[(0,M.jsx)(lx,{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)(ax,{className:n,language:t,lineNumbers:o,result:u,startLine:a,...s}),children:(0,M.jsx)(dx,{className:n,code:l,language:t,lineNumbers:o,raw:u,startLine:a,...s})})]})})},px={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`})})},mx=(0,j.createContext)(px),hx=(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},gx=({icons:e,children:t})=>{let n=(0,j.useRef)(e),r=(0,j.useRef)(e?{...px,...e}:px);hx(n.current,e)||(n.current=e,r.current=e?{...px,...e}:px);let i=r.current;return(0,M.jsx)(mx.Provider,{value:i,children:t})},_x=()=>(0,j.useContext)(mx),vx={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`},yx=(0,j.createContext)(vx),bx=()=>(0,j.useContext)(yx),xx=({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}=cx(),{isAnimating:f}=(0,j.useContext)(DC),p=bx(),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=_x(),_=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})})},Sx={"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`},Cx=({onDownload:e,onError:t,language:n,children:r,className:i,code:a,...o})=>{let s=Q(),{code:c}=cx(),{isAnimating:l}=(0,j.useContext)(DC),u=bx(),d=_x(),f=a??c,p=`file.${n&&n in Sx?Sx[n]:`txt`}`,m=()=>{try{tx(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})})},wx=()=>{let{Loader2Icon:e}=_x(),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`)})})]})},Tx=/\.[^/.]+$/,Ex=({node:e,className:t,src:n,alt:r,onLoad:i,onError:a,...o})=>{let{DownloadIcon:s}=_x(),c=Q(),l=(0,j.useRef)(null),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=bx(),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(Tx,``)}.${i}`}tx(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},Dx=0,Ox=()=>{Dx+=1,Dx===1&&(document.body.style.overflow=`hidden`)},kx=()=>{Dx=Math.max(0,Dx-1),Dx===0&&(document.body.style.overflow=``)},Ax=({url:e,isOpen:t,onClose:n,onConfirm:r})=>{let{CheckIcon:i,CopyIcon:a,ExternalLinkIcon:o,XIcon:s}=_x(),c=Q(),[l,u]=(0,j.useState)(!1),d=bx(),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){Ox();let e=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),kx()}}},[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},jx=(0,j.createContext)(null),Mx=()=>(0,j.useContext)(jx),Nx=()=>Mx()?.code??null,Px=()=>Mx()?.mermaid??null,Fx=e=>{var t;let n=Mx();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},Ix=(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}),Lx=({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)(DC),d=_x(),f=Px(),p=bx(),m=async t=>{try{if(t===`mmd`){tx(`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`){tx(`diagram.svg`,l,`image/svg+xml`),c(!1),r?.(t);return}if(t===`png`){tx(`diagram.png`,await Ix(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]})},Rx=({chart:e,config:t,onFullscreen:n,onExit:r,className:i,...a})=>{let{Maximize2Icon:o,XIcon:s}=_x(),c=Q(),[l,u]=(0,j.useState)(!1),{isAnimating:d,controls:f}=(0,j.useContext)(DC),p=bx(),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){Ox();let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),kx()}}},[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,ny.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)(jC,{chart:e,className:c(`size-full [&_svg]:h-auto [&_svg]:w-auto`),config:t,fullscreen:!0,showControls:m})})]}),document.body):null]})},zx=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}},Bx=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
  `)},Vx=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
  `)},Hx=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(``)},Ux=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=>Hx(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?Hx(e[r]):``;r[i]=`| ${n.join(` | `)} |`,i+=1}else r[i]=`| ${e.map(e=>Hx(e)).join(` | `)} |`,i+=1;return r.join(`
121
- `)},Wx=({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)(DC),p=bx(),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=zx(t),o=({csv:Bx,tsv:Vx,md:Ux}[e]||Ux)(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=_x(),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]})},Gx=({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)(DC),l=bx(),u=_x(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=zx(t),a=e===`csv`?Bx(i):Ux(i);tx(`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]})},Kx=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=_x(),o=Q(),[s,c]=(0,j.useState)(!1),{isAnimating:l}=(0,j.useContext)(DC),u=bx(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,j.useEffect)(()=>{if(s){Ox();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),kx()}}},[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,ny.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)(Wx,{}):null,r?(0,M.jsx)(Gx,{}):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]})},qx=({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)(Wx,{}):null,l?(0,M.jsx)(Gx,{}):null,u?(0,M.jsx)(Kx,{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})})]})},Jx=/startLine=(\d+)/,Yx=/\bnoLineNumbers\b/,Xx=(0,j.lazy)(()=>Z(()=>import(`./mermaid-GHXKKRXX-B_2tdKu_.js`).then(e=>({default:e.Mermaid})),[])),Zx=/language-([^\s]+)/;function Qx(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 $x(e,t){return e.className===t.className&&Qx(e.node,t.node)}var eS=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,tS=(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},nS=(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},rS=(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},iS=(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)=>$x(e,t));iS.displayName=`MarkdownOl`;var aS=(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&&Qx(e.node,t.node));aS.displayName=`MarkdownLi`;var oS=(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)=>$x(e,t));oS.displayName=`MarkdownUl`;var sS=(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)=>$x(e,t));sS.displayName=`MarkdownHr`;var cS=(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)=>$x(e,t));cS.displayName=`MarkdownStrong`;var lS=(0,j.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=Q(),{linkSafety:o}=(0,j.useContext)(DC),[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)(Ax,{...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)=>$x(e,t)&&e.href===t.href);lS.displayName=`MarkdownA`;var uS=(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)=>$x(e,t));uS.displayName=`MarkdownH1`;var dS=(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)=>$x(e,t));dS.displayName=`MarkdownH2`;var fS=(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)=>$x(e,t));fS.displayName=`MarkdownH3`;var pS=(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)=>$x(e,t));pS.displayName=`MarkdownH4`;var mS=(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)=>$x(e,t));mS.displayName=`MarkdownH5`;var hS=(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)=>$x(e,t));hS.displayName=`MarkdownH6`;var gS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,j.useContext)(DC);return(0,M.jsx)(qx,{className:t,showControls:eS(i,`table`),showCopy:tS(i,`copy`),showDownload:tS(i,`download`),showFullscreen:tS(i,`fullscreen`),...r,children:e})},(e,t)=>$x(e,t));gS.displayName=`MarkdownTable`;var _S=(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)=>$x(e,t));_S.displayName=`MarkdownThead`;var vS=(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)=>$x(e,t));vS.displayName=`MarkdownTbody`;var yS=(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)=>$x(e,t));yS.displayName=`MarkdownTr`;var bS=(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)=>$x(e,t));bS.displayName=`MarkdownTh`;var xS=(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)=>$x(e,t));xS.displayName=`MarkdownTd`;var SS=(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)=>$x(e,t));SS.displayName=`MarkdownBlockquote`;var CS=(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)=>$x(e,t));CS.displayName=`MarkdownSup`;var wS=(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)=>$x(e,t));wS.displayName=`MarkdownSub`;var TS=(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===iS){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)=>$x(e,t));TS.displayName=`MarkdownSection`;var ES=(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)(DC),l=Px(),u=Zb(),d=(t?.match(Zx))?.at(1)??``,f=Fx(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(Jx),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&Yx.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)(wx,{}),children:(0,M.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=eS(s,`mermaid`),n=rS(s,`download`),r=rS(s,`copy`),a=rS(s,`fullscreen`),c=rS(s,`panZoom`),l=e&&(n||r||a);return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(wx,{}),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)(Lx,{chart:v,config:o?.config}):null,r?(0,M.jsx)(xx,{code:v}):null,a?(0,M.jsx)(Rx,{chart:v,config:o?.config}):null]})}):null,(0,M.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,M.jsx)(Xx,{chart:v,config:o?.config,showControls:c})})]})})}let y=eS(s,`code`),b=nS(s,`download`),x=nS(s,`copy`);return(0,M.jsx)(fx,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,M.jsxs)(M.Fragment,{children:[b?(0,M.jsx)(Cx,{code:v,language:d}):null,x?(0,M.jsx)(xx,{}):null]}):null})},(e,t)=>e.className===t.className&&Qx(e.node,t.node));ES.displayName=`MarkdownCode`;var DS=(0,j.memo)(Ex,(e,t)=>e.className===t.className&&Qx(e.node,t.node));DS.displayName=`MarkdownImg`;var OS=(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)=>$x(e,t));OS.displayName=`MarkdownParagraph`;var kS={ol:iS,li:aS,ul:oS,hr:sS,strong:cS,a:lS,h1:uS,h2:dS,h3:fS,h4:pS,h5:mS,h6:hS,table:gS,thead:_S,tbody:vS,tr:yS,th:bS,td:xS,blockquote:SS,code:ES,img:DS,pre:({children:e})=>(0,j.isValidElement)(e)?(0,j.cloneElement)(e,{"data-block":`true`}):e,sup:CS,sub:wS,p:OS,section:TS},AS=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,jS=/\p{L}/u;function MS(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(AS.test(e))return`rtl`;if(jS.test(e))return`ltr`}return`ltr`}var NS=/^[ \t]{0,3}(`{3,}|~{3,})/,PS=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,FS=e=>{let t=e.split(`
121
+ `)},Wx=({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)(DC),p=bx(),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=zx(t),o=({csv:Bx,tsv:Vx,md:Ux}[e]||Ux)(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=_x(),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]})},Gx=({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)(DC),l=bx(),u=_x(),d=e=>{try{let t=(s.current?.closest(`[data-streamdown="table-wrapper"]`))?.querySelector(`table`);if(!t){r?.(Error(`Table not found`));return}let i=zx(t),a=e===`csv`?Bx(i):Ux(i);tx(`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]})},Kx=({children:e,className:t,showCopy:n=!0,showDownload:r=!0})=>{let{Maximize2Icon:i,XIcon:a}=_x(),o=Q(),[s,c]=(0,j.useState)(!1),{isAnimating:l}=(0,j.useContext)(DC),u=bx(),d=()=>{c(!0)},f=()=>{c(!1)};return(0,j.useEffect)(()=>{if(s){Ox();let e=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e),kx()}}},[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,ny.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)(Wx,{}):null,r?(0,M.jsx)(Gx,{}):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]})},qx=({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)(Wx,{}):null,l?(0,M.jsx)(Gx,{}):null,u?(0,M.jsx)(Kx,{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})})]})},Jx=/startLine=(\d+)/,Yx=/\bnoLineNumbers\b/,Xx=(0,j.lazy)(()=>Z(()=>import(`./mermaid-GHXKKRXX-hIqAdC54.js`).then(e=>({default:e.Mermaid})),[])),Zx=/language-([^\s]+)/;function Qx(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 $x(e,t){return e.className===t.className&&Qx(e.node,t.node)}var eS=(e,t)=>typeof e==`boolean`?e:e[t]!==!1,tS=(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},nS=(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},rS=(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},iS=(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)=>$x(e,t));iS.displayName=`MarkdownOl`;var aS=(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&&Qx(e.node,t.node));aS.displayName=`MarkdownLi`;var oS=(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)=>$x(e,t));oS.displayName=`MarkdownUl`;var sS=(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)=>$x(e,t));sS.displayName=`MarkdownHr`;var cS=(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)=>$x(e,t));cS.displayName=`MarkdownStrong`;var lS=(0,j.memo)(({children:e,className:t,href:n,node:r,...i})=>{let a=Q(),{linkSafety:o}=(0,j.useContext)(DC),[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)(Ax,{...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)=>$x(e,t)&&e.href===t.href);lS.displayName=`MarkdownA`;var uS=(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)=>$x(e,t));uS.displayName=`MarkdownH1`;var dS=(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)=>$x(e,t));dS.displayName=`MarkdownH2`;var fS=(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)=>$x(e,t));fS.displayName=`MarkdownH3`;var pS=(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)=>$x(e,t));pS.displayName=`MarkdownH4`;var mS=(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)=>$x(e,t));mS.displayName=`MarkdownH5`;var hS=(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)=>$x(e,t));hS.displayName=`MarkdownH6`;var gS=(0,j.memo)(({children:e,className:t,node:n,...r})=>{let{controls:i}=(0,j.useContext)(DC);return(0,M.jsx)(qx,{className:t,showControls:eS(i,`table`),showCopy:tS(i,`copy`),showDownload:tS(i,`download`),showFullscreen:tS(i,`fullscreen`),...r,children:e})},(e,t)=>$x(e,t));gS.displayName=`MarkdownTable`;var _S=(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)=>$x(e,t));_S.displayName=`MarkdownThead`;var vS=(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)=>$x(e,t));vS.displayName=`MarkdownTbody`;var yS=(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)=>$x(e,t));yS.displayName=`MarkdownTr`;var bS=(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)=>$x(e,t));bS.displayName=`MarkdownTh`;var xS=(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)=>$x(e,t));xS.displayName=`MarkdownTd`;var SS=(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)=>$x(e,t));SS.displayName=`MarkdownBlockquote`;var CS=(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)=>$x(e,t));CS.displayName=`MarkdownSup`;var wS=(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)=>$x(e,t));wS.displayName=`MarkdownSub`;var TS=(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===iS){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)=>$x(e,t));TS.displayName=`MarkdownSection`;var ES=(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)(DC),l=Px(),u=Zb(),d=(t?.match(Zx))?.at(1)??``,f=Fx(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(Jx),h=m?Number.parseInt(m[1],10):void 0,g=h!==void 0&&h>=1?h:void 0,_=!(p&&Yx.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)(wx,{}),children:(0,M.jsx)(e,{code:v,isIncomplete:u,language:d,meta:p})})}if(d===`mermaid`&&l){let e=eS(s,`mermaid`),n=rS(s,`download`),r=rS(s,`copy`),a=rS(s,`fullscreen`),c=rS(s,`panZoom`),l=e&&(n||r||a);return(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(wx,{}),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)(Lx,{chart:v,config:o?.config}):null,r?(0,M.jsx)(xx,{code:v}):null,a?(0,M.jsx)(Rx,{chart:v,config:o?.config}):null]})}):null,(0,M.jsx)(`div`,{className:i(`rounded-md border border-border bg-background`),children:(0,M.jsx)(Xx,{chart:v,config:o?.config,showControls:c})})]})})}let y=eS(s,`code`),b=nS(s,`download`),x=nS(s,`copy`);return(0,M.jsx)(fx,{className:t,code:v,isIncomplete:u,language:d,lineNumbers:_,startLine:g,children:y?(0,M.jsxs)(M.Fragment,{children:[b?(0,M.jsx)(Cx,{code:v,language:d}):null,x?(0,M.jsx)(xx,{}):null]}):null})},(e,t)=>e.className===t.className&&Qx(e.node,t.node));ES.displayName=`MarkdownCode`;var DS=(0,j.memo)(Ex,(e,t)=>e.className===t.className&&Qx(e.node,t.node));DS.displayName=`MarkdownImg`;var OS=(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)=>$x(e,t));OS.displayName=`MarkdownParagraph`;var kS={ol:iS,li:aS,ul:oS,hr:sS,strong:cS,a:lS,h1:uS,h2:dS,h3:fS,h4:pS,h5:mS,h6:hS,table:gS,thead:_S,tbody:vS,tr:yS,th:bS,td:xS,blockquote:SS,code:ES,img:DS,pre:({children:e})=>(0,j.isValidElement)(e)?(0,j.cloneElement)(e,{"data-block":`true`}):e,sup:CS,sub:wS,p:OS,section:TS},AS=/[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/,jS=/\p{L}/u;function MS(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(AS.test(e))return`rtl`;if(jS.test(e))return`ltr`}return`ltr`}var NS=/^[ \t]{0,3}(`{3,}|~{3,})/,PS=/^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/,FS=e=>{let t=e.split(`
122
122
  `),n=null,r=0;for(let e of t){let t=NS.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},IS=e=>{let t=e.split(`
123
123
  `);for(let e of t){let t=e.trim();if(t.length>0&&t.includes(`|`)&&PS.test(t))return!0}return!1},LS=()=>e=>{He(e,`html`,(e,t,n)=>{!n||typeof t!=`number`||(n.children[t]={type:`text`,value:e.value})})},RS=[],zS={allowDangerousHtml:!0},BS=new WeakMap,VS=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=BS.get(e);n||(n=e.name,BS.set(e,n)),t+=n}else t+=String(e);t+=`:`,t+=JSON.stringify(n)}else if(typeof r==`function`){let e=BS.get(r);e||(e=r.name,BS.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()}},HS=e=>{let t=US(e),n=e.children||``;return XS(t.runSync(t.parse(n),n),e)},US=e=>{let t=VS.get(e);if(t)return t;let n=GS(e);return VS.set(e,n),n},WS=e=>e.some(e=>Array.isArray(e)?e[0]===fs:e===fs),GS=e=>{let t=e.rehypePlugins||RS,n=e.remarkPlugins||RS,r=WS(t)?n:[...n,LS],i=e.remarkRehypeOptions?{...zS,...e.remarkRehypeOptions}:zS;return Kv().use(D_).use(r).use(vv,i).use(t)},KS=e=>e,qS=(e,t,n,r)=>{n?e.children.splice(t,1):e.children[t]={type:`text`,value:r}},JS=(e,t)=>{for(let n in Hg)if(Object.hasOwn(Hg,n)&&Object.hasOwn(e.properties,n)){let r=e.properties[n],i=Hg[n];(i===null||i.includes(e.tagName))&&(e.properties[n]=t(String(r||``),n,e)??void 0)}},YS=(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},XS=(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||KS;He(e,(e,s,c)=>{if(e.type===`raw`&&c&&typeof s==`number`)return qS(c,s,a,e.value),s;if(e.type===`element`&&(JS(e,t),YS(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 bg(e,{Fragment:M.Fragment,components:t.components,ignoreInvalidStyle:!0,jsx:M.jsx,jsxs:M.jsxs,passKeys:!0,passNode:!0})},ZS=/\[\^[\w-]{1,200}\](?!:)/,QS=/\[\^[\w-]{1,200}\]:/,$S=/<(\w+)[\s>]/,eC=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),tC=new Map,nC=new Map,rC=e=>{let t=e.toLowerCase(),n=tC.get(t);if(n)return n;let r=RegExp(`<${t}(?=[\\s>/])[^>]*>`,`gi`);return tC.set(t,r),r},iC=e=>{let t=e.toLowerCase(),n=nC.get(t);if(n)return n;let r=RegExp(`</${t}(?=[\\s>])[^>]*>`,`gi`);return nC.set(t,r),r},aC=(e,t)=>{if(eC.has(t.toLowerCase()))return 0;let n=e.match(rC(t));if(!n)return 0;let r=0;for(let e of n)e.trimEnd().endsWith(`/>`)||(r+=1);return r},oC=(e,t)=>{let n=e.match(iC(t));return n?n.length:0},sC=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},cC=e=>{let t=ZS.test(e),n=QS.test(e);if(t||n)return[e];let r=Tb.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=aC(t,e),o=oC(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($S);if(e){let n=e[1];aC(t,n)>oC(t,n)&&a.push(n)}}if(n>0&&!o){let e=i[n-1];if(sC(e)%2==1){i[n-1]=e+t;continue}}i.push(t),e.type!==`space`&&(o=e.type===`code`)}return i},lC=(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
 
@@ -284,11 +284,11 @@ XID_Start XIDS`.split(/\s/).map(e=>[bA(e),e])),pj=new Map([[`s`,QA(383)],[QA(383
284
284
  \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${QA(e.codePointAt(0)-1)}${QA(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Wj(Vj(`[${e}]`),t))}else n(Wj(Hj(Vj(gj.get(u)),l),t));else if(c===`property`)fj.has(bA(u))||(e.key=`sc`);else if(c===`space`)n(Uj(fA(`space`,{negate:l}),t));else if(c===`word`)n(Wj(Hj(Vj(uj),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=aA({flags:c});e.body[0].body=o(),i(Wj(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&Ik(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error($`Uses "\K" in a way that's unsupported`);let o=oA({behind:!0});o.body[0].body=a(),i(Wj(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Wj(oA({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=aA();t.body[0].body.push(e.body),e.body=Wj(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=Fj(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error($`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Bj(n)&&(n=jj(n,t),e.ref=n)}},Cj={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=Uj(kj(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&nj(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=nj(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=tj(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?kj(0):Oj(o,r.groupOriginByCopy,null),l=c;if(!s){let e=Mj(Aj(o,e=>e.type===`Group`&&!!e.flags)),t=e?tj(r.globalFlags,e):r.globalFlags;Ej(t,r.currentFlags)||(l=aA({flags:Nj(t)}),l.body[0].body.push(c))}n(Wj(l,t),{traverse:!s})}},wj={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>Dj(t,e));i.length?i.length>1?n(Wj(aA({atomic:!0,body:i.reverse().map(e=>Yk({body:[Zk(e.number)]}))}),t)):e.ref=i[0].number:n(Wj(oA({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=Qk();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function Tj(e){CA(e,{"*"({node:e,parent:t}){e.parent=t}})}function Ej(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Dj(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=Pj(n.parent);for(let r of t){if(r===n)break;if(r===e||Ij(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function Oj(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=Oj(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function kj(e){let t=dA(e);return t.isRecursive=!0,t}function Aj(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function jj(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function Mj(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Nj({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Pj(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Fj(e){let t=e.find(e=>e.kind===`search_start`||zj(e,{negate:!1})||!Lj(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=Fj(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Ij(e,t){let n=Pj(e)??[];for(let e of n)if(e===t||Ij(e,t))return!0;return!1}function Lj({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function Rj(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function zj(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&Ik(e.body[0],{type:`Assertion`,kind:`search_start`})}function Bj(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Vj(e,t){let n=zk(e,{...t,unicodePropertyMap:fj}).body;return n.length>1||n[0].body.length>1?aA({body:n}):n[0].body[0]}function Hj(e,t){return e.negate=t,e}function Uj(e,t){return e.parent=t,e}function Wj(e,t){return Tj(e),e.parent=t,e}function Gj(e,t){let n=sj(t),r=rj(n.target,`ES2024`),i=rj(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];CA(e,Kj,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,ij(qj[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&nj(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Kj={"*":{enter({node:e},t){if(aM(e)){let n=t.getCurrentModI();t.pushModI(e.flags?tj({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){aM(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){$j(QA(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),eM(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&bj.has(e.value)&&t.setHasCasedChar()}},qj={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?$`\B`:$`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=QA(e),r=tM(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&$j(n)){let e=dj(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);$A.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(sM)&&(o=[$k(45),...o.filter(e=>!sM(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||$A.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=aA(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=Yk({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!($A.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=tM(n,i),o=tM(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&nM(eM(e)).forEach(e=>{s.add(Array.isArray(e)?`${tM(e[0],i)}-${tM(e[1],i)}`:tM(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:$`[^\n]`;if(e===`digit`)return t?$`\D`:$`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&bj.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?$`\P`:$`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?$`\W`:$`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=tj(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${rM(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+iM(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:$`\g<${t}&R=${r}>`}},Jj=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),Yj=new Set([`-`,`\\`,`]`,`^`,`[`]),Xj=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),Zj=new Map([[9,$`\t`],[10,$`\n`],[11,$`\v`],[12,$`\f`],[13,$`\r`],[8232,$`\u2028`],[8233,$`\u2029`],[65279,$`\uFEFF`]]),Qj=/^\p{Cased}$/u;function $j(e){return Qj.test(e)}function eM(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=QA(e);if(!$j(t))continue;let o=dj(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function tM(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Zj.has(e))return Zj.get(e);if(e<32||e>126&&e<160||e>262143||t&&oM(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?Xj:Yj:Jj,a=QA(e);return(i.has(a)?`\\`:``)+a}function nM(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function rM(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function iM({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function aM({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function oM(e){return e>47&&e<58}function sM({type:e,value:t}){return e===`Character`&&t===45}var cM=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=uM(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(lM(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=dM(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function lM(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function uM(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)nj(n,t,{}).transferTo=e;return n}function dM(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function fM(e,t){let n=pM(e,t);return n.options?new cM(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function pM(e,t){let n=sj(t),r=xj(zk(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:fj}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Gj(r,n),a=KA(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=IA(zA(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}var mM=4294967295,hM=class{constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}regexps;findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=[];function a(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>e==null?{start:mM,end:mM,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{n.lastIndex=t;let o=n.exec(r);if(!o)continue;if(o.index===t)return a(e,o,0);i.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,n,r]of i)if(n.index===e)return a(t,n,r)}return null}};function gM(e,t){return fM(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function _M(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>gM(e,{target:t.target}),{createScanner(e){return new hM(e,t)},createString(e){return{content:e}}}}var vM=_M({forgiving:!0}),yM=Object.fromEntries(cO.flatMap(e=>(e.aliases??[]).map(t=>[t,e.id]))),bM=new Set(Object.keys(dO)),xM=e=>{let t=e.trim().toLowerCase();return yM[t]||(bM.has(t),t)},SM=new Map,CM=new Map,wM=new Map,TM=e=>typeof e==`string`?e:e.name??`custom`,EM=(e,t)=>`${e}-${TM(t[0])}-${TM(t[1])}`,DM=(e,t,n)=>{let r=e.slice(0,100),i=e.length>100?e.slice(-100):``;return`${t}:${n[0]}:${n[1]}:${e.length}:${r}:${i}`},OM=(e,t)=>{let n=EM(e,t);if(SM.has(n))return SM.get(n);let r=RO({themes:t,langs:[e],engine:vM});return SM.set(n,r),r};function kM(e={}){let t=e.themes??[`github-light`,`github-dark`];return{name:`shiki`,type:`code-highlighter`,supportsLanguage(e){let t=xM(e);return bM.has(t)},getSupportedLanguages(){return Array.from(bM)},getThemes(){return t},highlight({code:e,language:t,themes:n},r){let i=xM(t),a=[TM(n[0]),TM(n[1])],o=DM(e,i,a);return CM.has(o)?CM.get(o):(r&&(wM.has(o)||wM.set(o,new Set),wM.get(o).add(r)),OM(bM.has(i)?i:`text`,n).then(t=>{let n=t.getLoadedLanguages().includes(i)?i:`text`,r=t.codeToTokens(e,{lang:n,themes:{light:a[0],dark:a[1]}});CM.set(o,r);let s=wM.get(o);if(s){for(let e of s)e(r);wM.delete(o)}}).catch(e=>{console.error(`[Streamdown Code] Failed to highlight code:`,e),wM.delete(o)}),null)}}}var AM=kM();function jM(e){let[t,n]=(0,j.useState)(e&&e.startsWith(`/api/files/`)?void 0:e);return(0,j.useEffect)(()=>{if(!e||!e.startsWith(`/api/files/`)){n(e);return}let t=null,r=!1;return n(void 0),(async()=>{try{let i=await Ee(e);if(!i.ok)return;let a=await i.blob();if(r)return;t=URL.createObjectURL(a),n(t)}catch{}})(),()=>{r=!0,t&&URL.revokeObjectURL(t)}},[e]),t}function MM(e){return!isFinite(e)||isNaN(e)?`0:00`:`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`}function NM({audioData:e}){let[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(0),[a,o]=(0,j.useState)(0),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=jM(e);(0,j.useEffect)(()=>{if(!l)return;let e=new Audio(l);return e.addEventListener(`durationchange`,()=>{isFinite(e.duration)&&o(e.duration)}),e.addEventListener(`timeupdate`,()=>{isFinite(e.duration)&&e.duration>0&&(i(e.currentTime/e.duration),a===0&&o(e.duration))}),e.addEventListener(`ended`,()=>{n(!1),i(0)}),e.addEventListener(`loadedmetadata`,()=>{isFinite(e.duration)||(e.currentTime=1e10,e.addEventListener(`timeupdate`,function t(){isFinite(e.duration)&&(o(e.duration),e.currentTime=0,e.removeEventListener(`timeupdate`,t))}))}),s.current=e,()=>{e.pause(),e.src=``}},[l]);let u=(0,j.useCallback)(()=>{let e=s.current;e&&(t?(e.pause(),n(!1)):(e.play(),n(!0)))},[t]),d=(0,j.useCallback)(e=>{let t=s.current,n=c.current;if(!t||!n||!isFinite(t.duration))return;let r=n.getBoundingClientRect(),a=Math.max(0,Math.min(1,(e.clientX-r.left)/r.width));t.currentTime=a*t.duration,i(a)},[]);return(0,M.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-[180px]`,children:[(0,M.jsx)(`button`,{onClick:u,className:`flex items-center justify-center h-8 w-8 shrink-0 rounded-full bg-white/20 hover:bg-white/30 transition-colors`,children:t?(0,M.jsx)(le,{className:`h-3.5 w-3.5 fill-current`}):(0,M.jsx)(ue,{className:`h-3.5 w-3.5 fill-current ml-0.5`})}),(0,M.jsxs)(`div`,{className:`flex-1 flex flex-col gap-1`,children:[(0,M.jsx)(`div`,{ref:c,onClick:d,className:`h-1 bg-white/20 rounded-full cursor-pointer relative`,children:(0,M.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-white/70 rounded-full transition-[width] duration-100`,style:{width:`${r*100}%`}})}),(0,M.jsx)(`span`,{className:`text-[10px] opacity-60 tabular-nums`,children:MM(t?r*a:a)})]})]})}function PM({src:e,alt:t,className:n,onClick:r}){let i=jM(e);return i?(0,M.jsx)(`img`,{src:i,alt:t,className:n,onClick:r}):(0,M.jsx)(`div`,{className:`${n??``} bg-white/10 animate-pulse`,onClick:r})}function FM({group:e}){let[t,n]=(0,j.useState)({}),[r,i]=(0,j.useState)(`idle`),[a,o]=(0,j.useState)(``),s=(e,t)=>{n(n=>({...n,[e]:t}))},l=async()=>{let e=Object.entries(t).filter(([,e])=>e.trim());if(e.length!==0){i(`submitting`),o(``);try{let t=await Ee(`/api/env`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({vars:Object.fromEntries(e)})});if(!t.ok){let e=await t.json().catch(()=>({error:`Request failed`}));throw Error(e.error||`Request failed`)}i(`submitted`)}catch(e){o(e.message||`Failed to save`),i(`error`)}}},u=Object.values(t).filter(e=>e.trim()).length;return r===`submitted`?(0,M.jsx)(`div`,{className:`my-3 rounded-xl border border-emerald-500/20 bg-emerald-500/5 overflow-hidden`,children:(0,M.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 rounded-lg bg-emerald-500 shrink-0`,children:(0,M.jsx)(c,{className:`w-4 h-4 text-white`,strokeWidth:3})}),(0,M.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,M.jsx)(`span`,{className:`text-emerald-400 font-medium text-sm`,children:e.title}),(0,M.jsxs)(`span`,{className:`text-muted-foreground text-xs`,children:[u,` variable`,u===1?``:`s`,` saved — backend restarting`]})]})]})}):(0,M.jsxs)(`div`,{className:`my-3 rounded-xl border border-border/60 bg-card/50 overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-3 border-b border-border/40 bg-muted/30`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-center w-7 h-7 rounded-lg bg-primary/10 shrink-0`,children:(0,M.jsx)(O,{className:`w-3.5 h-3.5 text-primary`})}),(0,M.jsx)(`span`,{className:`font-medium text-sm text-foreground`,children:e.title})]}),(0,M.jsx)(`div`,{className:`px-4 py-3 space-y-3`,children:e.fields.map(e=>(0,M.jsxs)(`div`,{className:`space-y-1`,children:[(0,M.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,M.jsx)(`span`,{children:e.label}),(0,M.jsx)(`code`,{className:`text-[10px] px-1 py-0.5 rounded bg-muted text-muted-foreground/70`,children:e.name})]}),(0,M.jsx)(`input`,{type:`text`,placeholder:e.placeholder,value:t[e.name]||``,onChange:t=>s(e.name,t.target.value),disabled:r===`submitting`,className:`w-full px-3 py-2 rounded-lg text-sm bg-background border border-border/60 text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary/50 disabled:opacity-50 transition-colors font-mono`,spellCheck:!1,autoComplete:`off`})]},e.name))}),r===`error`&&(0,M.jsxs)(`div`,{className:`px-4 pb-2 flex items-center gap-1.5 text-xs text-red-400`,children:[(0,M.jsx)(ee,{className:`w-3 h-3 shrink-0`}),(0,M.jsx)(`span`,{children:a})]}),(0,M.jsxs)(`div`,{className:`px-4 py-3 border-t border-border/40 bg-muted/20 flex items-center justify-between`,children:[(0,M.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60`,children:[`Values are written to `,(0,M.jsx)(`code`,{className:`text-[10px]`,children:`.env`})]}),(0,M.jsx)(`button`,{onClick:l,disabled:u===0||r===`submitting`,className:`inline-flex items-center gap-1.5 px-4 py-1.5 rounded-lg text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all`,children:r===`submitting`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(v,{className:`w-3 h-3 animate-spin`}),`Saving...`]}):`Submit`})]})]})}function IM(e){let t=e.split(`/`);return t[t.length-1]||`bloby-image`}function LM({src:e,alt:t}){let[n,r]=(0,j.useState)(!1),i=jM(e);return n?(0,M.jsxs)(`div`,{className:`my-2 flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl border border-border/30 bg-black/10 text-muted-foreground/50 text-xs`,children:[(0,M.jsx)(re,{className:`h-4 w-4 shrink-0`}),(0,M.jsx)(`span`,{className:`truncate`,children:t||`Image not found`})]}):(0,M.jsxs)(`div`,{className:`relative group/img my-2 rounded-xl overflow-hidden border border-border/30 bg-black/20 w-fit max-w-full`,children:[i?(0,M.jsx)(`img`,{src:i,alt:t||`Generated image`,className:`max-w-full max-h-80 object-contain`,loading:`lazy`,onError:()=>r(!0)}):(0,M.jsx)(`div`,{className:`h-40 w-40 bg-white/10 animate-pulse`}),(0,M.jsx)(`div`,{className:`absolute top-2 right-2 flex gap-1.5 opacity-0 group-hover/img:opacity-100 transition-opacity`,children:(0,M.jsx)(`button`,{onClick:async()=>{try{let t=await(e.startsWith(`/api/files/`)?await Ee(e):await fetch(e)).blob(),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=IM(e),document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{window.open(e,`_blank`)}},className:`p-1.5 rounded-lg bg-black/60 hover:bg-black/80 text-white/80 hover:text-white transition-colors backdrop-blur-sm`,title:`Download original`,children:(0,M.jsx)(te,{className:`h-4 w-4`})})}),t&&(0,M.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-muted-foreground/70 truncate`,children:t})]})}function RM(e){return e.split(`
285
285
  `).join(`
286
286
 
287
- `)}function zM(e){return e<1024?`${e} chars`:`${(e/1024).toFixed(1)} KB`}function BM({title:e,content:t}){let[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(!1);return(0,M.jsxs)(`div`,{className:`my-2 rounded-xl border border-border/30 overflow-hidden`,children:[(0,M.jsxs)(`div`,{onClick:()=>r(e=>!e),className:`flex items-center gap-2.5 px-3.5 py-2.5 bg-white/[0.03] hover:bg-white/[0.05] transition-colors cursor-pointer select-none`,children:[(0,M.jsx)(E,{className:`h-3.5 w-3.5 text-muted-foreground/50 shrink-0 transition-transform duration-200 ${n?`rotate-90`:``}`}),(0,M.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/80 truncate min-w-0`,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground/35 tabular-nums`,children:zM(t.length)}),(0,M.jsx)(`button`,{onClick:async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},className:`p-1 rounded-md hover:bg-white/[0.08] text-muted-foreground/40 hover:text-muted-foreground/70 transition-colors`,title:`Copy text`,children:i?(0,M.jsx)(c,{className:`h-3.5 w-3.5`}):(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]})]}),n&&(0,M.jsx)(`div`,{className:`border-t border-border/15 max-h-[500px] overflow-y-auto px-4 py-3 text-sm leading-relaxed prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,M.jsx)(kC,{mode:`static`,plugins:{code:AM},controls:{code:{copy:!0,download:!1}},shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,children:RM(t)})})]})}function VM(e){return`<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html,body{margin:0;padding:0;background:#000;color:#fff;font-family:-apple-system,BlinkMacSystemFont,system-ui,sans-serif;}*{box-sizing:border-box;}</style></head><body>${e}</body></html>`}function HM(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e.trim()}}function UM({format:e,content:t,cardType:n}){let[r,i]=(0,j.useState)(!1),a=n?`Sent to your Mac · ${n}`:`Sent to your Mac`;return(0,M.jsxs)(`div`,{className:`my-2 rounded-xl border border-[#0069FE]/25 overflow-hidden`,children:[(0,M.jsxs)(`div`,{onClick:()=>i(e=>!e),className:`flex items-center gap-2.5 px-3.5 py-2.5 bg-[#0069FE]/10 hover:bg-[#0069FE]/[0.16] transition-colors cursor-pointer select-none`,children:[(0,M.jsx)(E,{className:`h-3.5 w-3.5 text-[#4AA8FF] shrink-0 transition-transform duration-200 ${r?`rotate-90`:``}`}),(0,M.jsx)(ie,{className:`h-4 w-4 text-[#4AA8FF] shrink-0`}),(0,M.jsx)(`span`,{className:`text-[13px] font-medium text-[#9ecbff] truncate min-w-0`,children:a})]}),r&&(0,M.jsx)(`div`,{className:`border-t border-[#0069FE]/15 p-3 bg-black/40`,children:e===`html`?(0,M.jsx)(`iframe`,{title:`Mac notch card preview`,sandbox:``,srcDoc:VM(t),className:`w-full rounded-lg border border-white/10 bg-black block`,style:{height:147}}):(0,M.jsx)(`pre`,{className:`text-[12px] leading-relaxed text-foreground/80 overflow-x-auto whitespace-pre-wrap break-words font-mono max-h-[300px]`,children:HM(t)})})]})}var WM={spotlight:{label:`Spotlight`,icon:D},point:{label:`Point`,icon:se}};function GM(e){return e.charAt(0).toUpperCase()+e.slice(1)}function KM(e){try{let t=JSON.parse(e);return typeof t?.screen==`number`?t.screen:null}catch{return null}}function qM({actionType:e,content:t}){let n=WM[e.toLowerCase()]??{label:GM(e),icon:fe},r=KM(t),i=n.icon;return(0,M.jsxs)(`div`,{className:`my-2 inline-flex items-center gap-2 rounded-xl border border-[#0069FE]/25 bg-[#0069FE]/10 px-3 py-1.5`,children:[(0,M.jsx)(i,{className:`h-3.5 w-3.5 text-[#4AA8FF] shrink-0`}),(0,M.jsxs)(`span`,{className:`text-[13px] text-[#9ecbff]`,children:[(0,M.jsx)(`span`,{className:`text-[#9ecbff]/55`,children:`Agent actions:`}),` `,(0,M.jsx)(`span`,{className:`font-medium`,children:n.label}),r!==null&&(0,M.jsxs)(`span`,{className:`text-[#9ecbff]/80`,children:[` at screen `,r]})]})]})}function JM(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function YM(e){let t=e.match(/^\[([^\]]+)\]\n([\s\S]*)$/),n,r=`Chat`;if(t){n=t[2];let e=t[1].split(`|`)[0].trim();r=e===`PWA`?`Chat`:e.toLowerCase()===`workspace`?`Workspace`:e}else n=e;return n.startsWith(`[voice] `)&&(n=n.slice(8)),n=n.replace(/^\[(Mac|Alexa|WhatsApp|Chat|PWA|Workspace|workspace)\]\s*/i,``),{tag:r,body:n}}function XM({tag:e}){let t=`h-3 w-3 opacity-60`;return e===`Mac`?(0,M.jsx)(ie,{className:t}):e===`WhatsApp`?(0,M.jsx)(d,{className:t}):e===`Workspace`?(0,M.jsx)(k,{className:t}):e===`Chat`?(0,M.jsx)(s,{className:t}):e===`Alexa`?(0,M.jsx)(he,{className:t}):(0,M.jsx)(s,{className:t})}function ZM(e){let t=e,n=`[pair-whatsapp](/api/channels/whatsapp/qr-page)`;t.includes(n)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/whatsapp\/qr-page`?/g,n));let r=`[connect-alexa](/api/channels/alexa/pair-page)`;return t.includes(r)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/alexa\/pair-page`?/g,r)),t}function QM(e){let t=[],n=/<EnvGroup\s+title="([^"]+)">([\s\S]*?)<\/EnvGroup>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],i=[],a=/<EnvInput\s+name="([^"]+)"\s+label="([^"]+)"\s+placeholder="([^"]+)"\s*\/>/g,o;for(;(o=a.exec(n))!==null;)i.push({name:o[1],label:o[2],placeholder:o[3]});i.length>0&&t.push({start:r.index,end:r.index+r[0].length,segment:{type:`env`,group:{title:e,fields:i}}})}let i=/<BlobyImage\s+src="([^"]+)"(?:\s+alt="([^"]*)")?\s*\/>/g;for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-image`,src:r[1],alt:r[2]||``}});let a=/<BlobyText\s+title="([^"]+)">([\s\S]*?)<\/BlobyText>/g;for(;(r=a.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-text`,title:r[1],content:r[2].trim()}});let o=/<notch_html>([\s\S]*?)<\/notch_html>/gi;for(;(r=o.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`notch`,format:`html`,content:r[1].trim()}});let s=/<notch_card\s+type="([^"]+)">([\s\S]*?)<\/notch_card>/gi;for(;(r=s.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`notch`,format:`card`,content:r[2].trim(),cardType:r[1]}});let c=/<morphy_action\s+type="([^"]+)">([\s\S]*?)<\/morphy_action>/gi;for(;(r=c.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`morphy-action`,actionType:r[1],content:r[2].trim()}});t.sort((e,t)=>e.start-t.start);let l=[],u=0;for(let n of t){if(n.start>u){let t=e.slice(u,n.start).trim();t&&l.push({type:`text`,value:t})}l.push(n.segment),u=n.end}if(u<e.length){let t=e.slice(u).trim();t&&l.push({type:`text`,value:t})}return l}function $M(e){return/<EnvGroup\s+title="[^"]+">/i.test(e)||/<BlobyImage\s+src="/i.test(e)||/<BlobyText\s+title="/i.test(e)||/<notch_html>/i.test(e)||/<notch_card\s+type="/i.test(e)||/<morphy_action\s+type="/i.test(e)}function eN({text:e}){let[t,n]=(0,j.useState)(!1);return(0,M.jsx)(`button`,{onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},className:`absolute -top-2.5 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded-md bg-background/80 border border-border/40 shadow-sm hover:bg-muted text-muted-foreground/60 hover:text-muted-foreground`,title:`Copy message`,children:t?(0,M.jsx)(c,{className:`h-3 w-3`}):(0,M.jsx)(b,{className:`h-3 w-3`})})}function tN(e){let t=e.outerHTML,n=window.open(``,`_blank`);n&&(n.document.write(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Table</title>
287
+ `)}function zM(e){return e<1024?`${e} chars`:`${(e/1024).toFixed(1)} KB`}function BM({title:e,content:t}){let[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(!1);return(0,M.jsxs)(`div`,{className:`my-2 rounded-xl border border-border/30 overflow-hidden`,children:[(0,M.jsxs)(`div`,{onClick:()=>r(e=>!e),className:`flex items-center gap-2.5 px-3.5 py-2.5 bg-white/[0.03] hover:bg-white/[0.05] transition-colors cursor-pointer select-none`,children:[(0,M.jsx)(E,{className:`h-3.5 w-3.5 text-muted-foreground/50 shrink-0 transition-transform duration-200 ${n?`rotate-90`:``}`}),(0,M.jsx)(`span`,{className:`text-[13px] font-medium text-foreground/80 truncate min-w-0`,children:e}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-muted-foreground/35 tabular-nums`,children:zM(t.length)}),(0,M.jsx)(`button`,{onClick:async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch{}},className:`p-1 rounded-md hover:bg-white/[0.08] text-muted-foreground/40 hover:text-muted-foreground/70 transition-colors`,title:`Copy text`,children:i?(0,M.jsx)(c,{className:`h-3.5 w-3.5`}):(0,M.jsx)(b,{className:`h-3.5 w-3.5`})})]})]}),n&&(0,M.jsx)(`div`,{className:`border-t border-border/15 max-h-[500px] overflow-y-auto px-4 py-3 text-sm leading-relaxed prose prose-sm prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,children:(0,M.jsx)(kC,{mode:`static`,plugins:{code:AM},controls:{code:{copy:!0,download:!1}},shikiTheme:[`github-dark`,`github-dark`],lineNumbers:!1,children:RM(t)})})]})}function VM(e){return`<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html,body{margin:0;padding:0;background:#000;color:#fff;font-family:-apple-system,BlinkMacSystemFont,system-ui,sans-serif;}*{box-sizing:border-box;}</style></head><body>${e}</body></html>`}function HM(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e.trim()}}function UM({format:e,content:t,cardType:n}){let[r,i]=(0,j.useState)(!1),a=n?`Sent to your Mac · ${n}`:`Sent to your Mac`;return(0,M.jsxs)(`div`,{className:`my-2 rounded-xl border border-[#0069FE]/25 overflow-hidden`,children:[(0,M.jsxs)(`div`,{onClick:()=>i(e=>!e),className:`flex items-center gap-2.5 px-3.5 py-2.5 bg-[#0069FE]/10 hover:bg-[#0069FE]/[0.16] transition-colors cursor-pointer select-none`,children:[(0,M.jsx)(E,{className:`h-3.5 w-3.5 text-[#4AA8FF] shrink-0 transition-transform duration-200 ${r?`rotate-90`:``}`}),(0,M.jsx)(ie,{className:`h-4 w-4 text-[#4AA8FF] shrink-0`}),(0,M.jsx)(`span`,{className:`text-[13px] font-medium text-[#9ecbff] truncate min-w-0`,children:a})]}),r&&(0,M.jsx)(`div`,{className:`border-t border-[#0069FE]/15 p-3 bg-black/40`,children:e===`html`?(0,M.jsx)(`iframe`,{title:`Mac notch card preview`,sandbox:``,srcDoc:VM(t),className:`w-full rounded-lg border border-white/10 bg-black block`,style:{height:147}}):(0,M.jsx)(`pre`,{className:`text-[12px] leading-relaxed text-foreground/80 overflow-x-auto whitespace-pre-wrap break-words font-mono max-h-[300px]`,children:HM(t)})})]})}var WM={spotlight:{label:`Spotlight`,icon:D},point:{label:`Point`,icon:se}};function GM(e){return e.charAt(0).toUpperCase()+e.slice(1)}function KM(e){try{let t=JSON.parse(e);return typeof t?.screen==`number`?t.screen:null}catch{return null}}function qM({actionType:e,content:t}){let n=WM[e.toLowerCase()]??{label:GM(e),icon:fe},r=KM(t),i=n.icon;return(0,M.jsxs)(`div`,{className:`my-2 inline-flex items-center gap-2 rounded-xl border border-[#0069FE]/25 bg-[#0069FE]/10 px-3 py-1.5`,children:[(0,M.jsx)(i,{className:`h-3.5 w-3.5 text-[#4AA8FF] shrink-0`}),(0,M.jsxs)(`span`,{className:`text-[13px] text-[#9ecbff]`,children:[(0,M.jsx)(`span`,{className:`text-[#9ecbff]/55`,children:`Agent actions:`}),` `,(0,M.jsx)(`span`,{className:`font-medium`,children:n.label}),r!==null&&(0,M.jsxs)(`span`,{className:`text-[#9ecbff]/80`,children:[` at screen `,r]})]})]})}function JM(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function YM(e){let t=e.match(/^\[([^\]]+)\]\n([\s\S]*)$/),n,r=`Chat`;if(t){n=t[2];let e=t[1].split(`|`)[0].trim();r=e===`PWA`?`Chat`:e.toLowerCase()===`workspace`?`Workspace`:e}else n=e;return n.startsWith(`[voice] `)&&(n=n.slice(8)),n=n.replace(/^\[(Mac|Alexa|WhatsApp|Chat|PWA|Workspace|workspace)\]\s*/i,``),{tag:r,body:n}}function XM({tag:e}){let t=`h-3 w-3 opacity-60`;return e===`Mac`?(0,M.jsx)(ie,{className:t}):e===`WhatsApp`?(0,M.jsx)(d,{className:t}):e===`Workspace`?(0,M.jsx)(k,{className:t}):e===`Chat`?(0,M.jsx)(s,{className:t}):e===`Alexa`?(0,M.jsx)(he,{className:t}):(0,M.jsx)(s,{className:t})}function ZM(e){let t=e,n=`[pair-whatsapp](/api/channels/whatsapp/qr-page)`;t.includes(n)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/whatsapp\/qr-page`?/g,n));let r=`[connect-alexa](/api/channels/alexa/pair-page)`;return t.includes(r)||(t=t.replace(/`?(?:http:\/\/localhost:\d+)?\/api\/channels\/alexa\/pair-page`?/g,r)),t}function QM(e){let t=[],n=/<EnvGroup\s+title="([^"]+)">([\s\S]*?)<\/EnvGroup>/g,r;for(;(r=n.exec(e))!==null;){let e=r[1],n=r[2],i=[],a=/<EnvInput\s+name="([^"]+)"\s+label="([^"]+)"\s+placeholder="([^"]+)"\s*\/>/g,o;for(;(o=a.exec(n))!==null;)i.push({name:o[1],label:o[2],placeholder:o[3]});i.length>0&&t.push({start:r.index,end:r.index+r[0].length,segment:{type:`env`,group:{title:e,fields:i}}})}let i=/<BlobyImage\s+src="([^"]+)"(?:\s+alt="([^"]*)")?\s*\/>/g;for(;(r=i.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-image`,src:r[1],alt:r[2]||``}});let a=/<BlobyText\s+title="([^"]+)">([\s\S]*?)<\/BlobyText>/g;for(;(r=a.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`bloby-text`,title:r[1],content:r[2].trim()}});let o=/<notch_html>([\s\S]*?)<\/notch_html>/gi;for(;(r=o.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`notch`,format:`html`,content:r[1].trim()}});let s=/<notch_card\s+type="([^"]+)">([\s\S]*?)<\/notch_card>/gi;for(;(r=s.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`notch`,format:`card`,content:r[2].trim(),cardType:r[1]}});let c=/<morphy_action\s+type="([^"]+)">([\s\S]*?)<\/morphy_action>/gi;for(;(r=c.exec(e))!==null;)t.push({start:r.index,end:r.index+r[0].length,segment:{type:`morphy-action`,actionType:r[1],content:r[2].trim()}});let l=/<mac_actions>([\s\S]*?)<\/mac_actions>/gi;for(;(r=l.exec(e))!==null;){let e=[];try{let t=JSON.parse(r[1].trim());Array.isArray(t)&&(e=t)}catch{}t.push({start:r.index,end:r.index+r[0].length,segment:{type:`mac-actions`,actions:e}})}t.sort((e,t)=>e.start-t.start);let u=[],d=0;for(let n of t){if(n.start>d){let t=e.slice(d,n.start).trim();t&&u.push({type:`text`,value:t})}u.push(n.segment),d=n.end}if(d<e.length){let t=e.slice(d).trim();t&&u.push({type:`text`,value:t})}return u}function $M(e){return/<EnvGroup\s+title="[^"]+">/i.test(e)||/<BlobyImage\s+src="/i.test(e)||/<BlobyText\s+title="/i.test(e)||/<notch_html>/i.test(e)||/<notch_card\s+type="/i.test(e)||/<morphy_action\s+type="/i.test(e)||/<mac_actions>/i.test(e)}function eN({text:e}){let[t,n]=(0,j.useState)(!1);return(0,M.jsx)(`button`,{onClick:async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},className:`absolute -top-2.5 right-2 z-10 opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded-md bg-background/80 border border-border/40 shadow-sm hover:bg-muted text-muted-foreground/60 hover:text-muted-foreground`,title:`Copy message`,children:t?(0,M.jsx)(c,{className:`h-3 w-3`}):(0,M.jsx)(b,{className:`h-3 w-3`})})}function tN(e){let t=e.outerHTML,n=window.open(``,`_blank`);n&&(n.document.write(`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Table</title>
288
288
  <style>
289
289
  body{background:#1a1a1a;color:#f5f5f5;font-family:system-ui,-apple-system,sans-serif;padding:2rem;margin:0}
290
290
  table{border-collapse:collapse;width:100%}
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 nN(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&&tN(n)}}function rN({role:e,content:t,timestamp:n,hasAttachments:r,audioData:i,attachments:a,onImageClick:o,transcribing:s}){let c=e===`user`,l=n?JM(n):``,{tag:u,body:d}=YM(t),p=a?.filter(e=>e.mediaType?.startsWith(`image/`))||[],m=a?.filter(e=>!e.mediaType?.startsWith(`image/`))||[],h=p.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)(eN,{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:[h.length>0&&(0,M.jsx)(`div`,{className:`flex gap-1.5 flex-wrap mb-2`,children:h.map((e,t)=>(0,M.jsx)(PM,{src:e,alt:p[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?.(h,t)},t))}),m.length>0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-primary-foreground/60 mr-1.5`,children:[(0,M.jsx)(ce,{className:`h-3 w-3`}),m.length>1&&(0,M.jsx)(`span`,{className:`text-xs`,children:m.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)(ce,{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)(NM,{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)(XM,{tag:u}),u]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50`,children:l})]})]});let g=e=>(0,M.jsx)(kC,{mode:`static`,plugins:{code:AM},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)(f,{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)(f,{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:ZM(e)});if($M(d)){let e=QM(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)(eN,{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:nN,children:e.map((e,t)=>e.type===`text`?(0,M.jsx)(`div`,{children:g(e.value)},t):e.type===`env`?(0,M.jsx)(FM,{group:e.group},t):e.type===`bloby-image`?(0,M.jsx)(LM,{src:e.src,alt:e.alt},t):e.type===`bloby-text`?(0,M.jsx)(BM,{title:e.title,content:e.content},t):e.type===`notch`?(0,M.jsx)(UM,{format:e.format,content:e.content,cardType:e.cardType},t):e.type===`morphy-action`?(0,M.jsx)(qM,{actionType:e.actionType,content:e.content},t):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)(eN,{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:nN,children:g(d)})]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 px-1`,children:l})]})}function iN({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)(kC,{mode:`streaming`,isAnimating:!0,caret:`block`,plugins:{code:AM},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 aN({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=jM(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)(_,{children:(0,M.jsxs)(m.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 Ee(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)(te,{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)(_e,{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)(T,{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)(E,{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 oN({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)(rN,{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)(iN,{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,``).trimEnd(),toolName:g})]}),(0,M.jsx)(`div`,{ref:o}),f&&(0,M.jsx)(aN,{images:f.images,index:f.index,onClose:()=>p(null),onNavigate:e=>p(t=>t?{...t,index:e}:null)})]})}var sN=()=>typeof window>`u`?null:window.SpeechRecognition??window.webkitSpeechRecognition??null,cN=sN()!==null;function lN(){let e=(0,j.useRef)(null),t=(0,j.useRef)(``),n=(0,j.useRef)(null),r=(0,j.useMemo)(()=>cN,[]);return{start:(0,j.useCallback)((r=!1)=>{let i=sN();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 uN(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function dN(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 fN=`bloby_draft`;function pN({onSend:e,onStop:t,streaming:n,whisperEnabled:r,onTranscribe:i,onRecordingChange:a,onAudioReady:o}){let{start:s,stop:c,abort:l,isSupported:u}=lN(),d=r||u,[f,p]=(0,j.useState)(()=>{try{return localStorage.getItem(fN)||``}catch{return``}}),[g,v]=(0,j.useState)([]),y=(0,j.useRef)(null),[b,x]=(0,j.useState)(!1),S=(0,j.useCallback)(e=>{x(e),a?.(e)},[a]),[C,T]=(0,j.useState)(0),E=f.trim().length>0,ee=E||g.length>0,D=(0,j.useRef)(null),te=(0,j.useRef)(null),ne=(0,j.useRef)(null),re=(0,j.useRef)(null),O=(0,j.useRef)(null),ie=(0,j.useRef)(0),ae=(0,j.useRef)(0),oe=(0,j.useRef)(null),k=(0,j.useRef)(!1),se=(0,j.useRef)(!1),le=(0,j.useRef)(null),ue=(0,j.useRef)(null),de=(0,j.useRef)([]),fe=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=D.current;e&&(e.style.height=`0px`,e.style.height=`${Math.min(e.scrollHeight,88)}px`)},[f]),(0,j.useEffect)(()=>(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{try{localStorage.setItem(fN,f)}catch{}},500),()=>{y.current&&clearTimeout(y.current)}),[f]),(0,j.useEffect)(()=>{if(b)return le.current=setInterval(()=>T(e=>e+1),1e3),()=>{le.current&&clearInterval(le.current)}},[b]);let he=(0,j.useCallback)(async t=>{le.current&&clearInterval(le.current),oe.current&&=(clearTimeout(oe.current),null),k.current=!1;let n=ue.current,r=fe.current;if(t)r?.getTracks().forEach(e=>e.stop()),ue.current=null,fe.current=null,de.current=[],l();else if(n&&n.state!==`inactive`)n.onstop=async()=>{r?.getTracks().forEach(e=>e.stop());let t=new Blob(de.current,{type:`audio/webm`});if(de.current=[],ue.current=null,fe.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=g.length>0?g: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&&v([])},n.readAsDataURL(t)},n.stop();else{r?.getTracks().forEach(e=>e.stop()),ue.current=null,fe.current=null,de.current=[];try{let t=await c();if(t.trim()){let n=g.length>0?g:void 0;e(t.trim(),n),n&&v([])}}catch(e){console.error(`[InputBar] Web Speech stop error:`,e)}}O.current&&(O.current.style.transform=``),S(!1),T(0),ae.current=0},[e,i,g,r,l,c]),ge=(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 dN(r)),v(n=>[...n,{id:Math.random().toString(36).slice(2),type:t?`image`:`file`,name:e.name,preview:r}])},r.readAsDataURL(e)},[]),ve=(0,j.useCallback)(e=>{let t=e.target.files;if(t){for(let e=0;e<t.length;e++)ge(t[e]);e.target.value=``}},[ge]),ye=(0,j.useCallback)(e=>{v(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&&ge(n)}}};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[ge]);let be=()=>{if(ee){e(f,g.length>0?g:void 0),p(``),v([]);try{localStorage.removeItem(fN)}catch{}requestAnimationFrame(()=>D.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&&!se.current)&&xe&&!se.current){e.getTracks().forEach(e=>e.stop());return}fe.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:`audio/webm`,n=new MediaRecorder(e,{mimeType:t});de.current=[],n.ondataavailable=e=>{e.data.size>0&&de.current.push(e.data)},ue.current=n,n.start()}else if(s(!xe),xe&&!se.current){l();return}k.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(b){he(!1);return}se.current=!0,Se();return}se.current=!0,ie.current=e.clientX,ae.current=0,e.currentTarget.setPointerCapture(e.pointerId),oe.current=setTimeout(()=>{try{navigator.vibrate?.(50)}catch{}Se()},200)},[xe,b,d,Se,he]),we=(0,j.useCallback)(e=>{if(!xe||!k.current)return;let t=Math.min(0,e.clientX-ie.current);if(ae.current=t,O.current&&(O.current.style.transform=`translateX(${t}px)`),re.current){let t=re.current.getBoundingClientRect(),n=t.left+t.width/2;Math.abs(e.clientX-n)<36&&he(!0)}},[xe,he]),Te=(0,j.useCallback)(()=>{se.current=!1,oe.current&&=(clearTimeout(oe.current),null),xe&&k.current&&he(!1)},[xe,he]),Ee=(0,j.useCallback)(()=>{se.current=!1,oe.current&&=(clearTimeout(oe.current),null),k.current&&he(!0)},[he]);return(0,M.jsxs)(`div`,{className:`shrink-0 p-3 relative`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col transition-opacity duration-100 ${b?`opacity-0 pointer-events-none`:`opacity-100`}`,children:[(0,M.jsx)(_,{children:g.length>0&&(0,M.jsx)(m.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:g.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:()=>ye(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)(_e,{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:D,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(),ee&&be())},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:te,type:`file`,className:`hidden`,accept:`image/*,.pdf`,multiple:!0,onChange:ve}),(0,M.jsx)(`input`,{ref:ne,type:`file`,className:`hidden`,accept:`image/*`,capture:`environment`,onChange:ve}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>te.current?.click(),className:`shrink-0 p-1.5 mb-2 text-gray-400 hover:text-gray-600 transition-colors`,children:(0,M.jsx)(ce,{className:`h-4 w-4`})}),(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)(w,{className:`h-4 w-4`})})]}),E?(0,M.jsx)(`button`,{onClick:be,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)(A,{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)(h,{className:`h-4 w-4`})})]})]}),(0,M.jsx)(_,{children:b&&(0,M.jsx)(m.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:uN(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:re,className:`flex items-center justify-center h-9 w-9 shrink-0 rounded-full bg-destructive/10 text-destructive`,children:(0,M.jsx)(me,{className:`h-4 w-4`})}),(0,M.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0`,children:(0,M.jsx)(m.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:O,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)(h,{className:`h-5 w-5`})})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{onClick:()=>he(!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)(me,{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:()=>he(!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)(pe,{className:`h-4 w-4`})})})]})})]})})})]})}var mN=`/morphy/headphones.json`,hN=`/morphy/`,gN=null,_N=null;function vN(){return gN&&_N?Promise.resolve({img:gN,cfg:_N}):fetch(mN).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=()=>{gN=r,_N=e,t({img:r,cfg:e})},r.onerror=n,r.src=hN+e.spritesheet}))}function yN({recording:e,height:t=36,onDone:n}){let r=(0,j.useRef)(null),i=(0,j.useRef)(gN),a=(0,j.useRef)(_N),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)(()=>{vN().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 bN(){let e=(0,j.useRef)(null),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(`Bloby`),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(0),h=(0,j.useRef)(null),_=(0,j.useRef)(!1),[v,b]=(0,j.useState)(!0),[w,T]=(0,j.useState)(null),[E,ee]=(0,j.useState)(null),[D,re]=(0,j.useState)(!1),[O,ie]=(0,j.useState)(!1),[ae,k]=(0,j.useState)(`loading`);function se(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 ce(){try{if(await Notification.requestPermission()!==`granted`){k(`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:se(n)})).toJSON(),i=e.current;i&&i.send(`push:subscribe`,{endpoint:r.endpoint,keys:r.keys}),k(`subscribed`)}catch(e){console.error(`[push] Subscribe failed:`,e)}}async function le(){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})}k(`unsubscribed`)}catch(e){console.error(`[push] Unsubscribe failed:`,e)}}let[ue,A]=(0,j.useState)(!1),fe=/iPad|iPhone|iPod/.test(navigator.userAgent),pe=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone,me=/Android|iPhone|iPad|iPod|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),he=window.self!==window.top;(0,j.useEffect)(()=>{let e=e=>{e.data?.type===`bloby:show-ios-install`&&A(!0)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]);let[ve,be]=(0,j.useState)(!1),[xe,Oe]=(0,j.useState)(!1),[Ae,je]=(0,j.useState)(!1),[Me,Ne]=(0,j.useState)(!1);(0,j.useEffect)(()=>{(async()=>{try{let e=await(await fetch(`/api/onboard/status`)).json();if(e.totpEnabled&&Ne(!0),!e.portalConfigured){Oe(!1),je(!0),be(!0);return}Oe(!0);let t=Se();if(t){if((await(await fetch(`/api/portal/validate-token?token=${encodeURIComponent(t)}`)).json()).valid){je(!0),be(!0);return}we()}je(!1),be(!0)}catch{je(!0),be(!0)}})()},[]);let Pe=e=>{Ce(e),je(!0)};(0,j.useEffect)(()=>{Te(()=>{je(!1),Oe(!0)})},[]),(0,j.useEffect)(()=>{if(!Ae)return;let e=()=>{fetch(`/app/api/health`).then(e=>b(e.ok)).catch(()=>b(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[Ae]),(0,j.useEffect)(()=>{Ae&&(async()=>{if(!(`PushManager`in window)||!(`serviceWorker`in navigator)){k(`unsupported`);return}if(Notification.permission===`denied`){k(`denied`);return}try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();k(e&&(await(await Ee(`/api/push/status?endpoint=${encodeURIComponent(e.endpoint)}`)).json()).subscribed?`subscribed`:`unsubscribed`)}catch{k(`unsupported`)}})()},[Ae]),(0,j.useEffect)(()=>{if(!Ae)return;let t=location.protocol===`https:`?`wss:`:`ws:`,r=location.host,i=new ye(`${t}//${r}/bloby/ws`,Se);e.current=i;let a=i.onStatus(e=>{n(e),e&&_.current&&m(e=>e+1),_.current=e}),o=i.on(`app:rebuilding`,()=>{window.parent?.postMessage({type:`bloby:rebuilding`},`*`)}),s=i.on(`app:rebuilt`,()=>{window.parent?.postMessage({type:`bloby:rebuilt`},`*`)}),c=i.on(`app:build-error`,e=>{window.parent?.postMessage({type:`bloby:build-error`,error:e.error},`*`)}),l=i.on(`app:hmr-update`,()=>{window.parent?.postMessage({type:`bloby:hmr-update`},`*`)}),u=i.on(`bot:response`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)}),d=i.on(`chat:sync`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)});return i.connect(),()=>{a(),o(),s(),c(),l(),u(),d(),i.disconnect()}},[Ae]),(0,j.useEffect)(()=>{Ae&&(Ee(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&i(e.agent_name),e.whisper_enabled===`true`&&o(!0)}).catch(()=>{}),Ee(`/api/wallet/balance`).then(e=>e.json()).then(e=>{e.address&&(T(e.tempo??`0.00`),ee(e.base??`0.00`))}).catch(()=>{}))},[Ae]),(0,j.useEffect)(()=>{if(!s)return;let e=e=>{h.current&&!h.current.contains(e.target)&&(c(!1),u(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let{messages:Fe,streaming:Ie,streamBuffer:Le,tools:Re,hasMore:ze,loadOlder:Be,sendMessage:Ve,addPendingAudio:He,stopStreaming:Ue,clearContext:We}=De(e.current,p,Ae);return(0,j.useEffect)(()=>{let t=async t=>{if(t.data?.type!==`bloby:voice-record`)return;let{audio:n,transcript:r}=t.data;if(n&&a){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()&&Ve(e.transcript.trim(),void 0,`data:audio/webm;base64,${n}`)}catch(e){console.error(`[BlobyApp] widget voice transcription error:`,e)}}else r?.trim()&&Ve(r.trim())};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[Ve,a]),ve?xe&&!Ae?(0,M.jsx)(ke,{onLogin:Pe,totpEnabled:Me}):(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)(g,{className:`h-[18px] w-[18px]`})}),(0,M.jsx)(`div`,{className:`relative ml-1.5 shrink-0 -translate-y-[5px]`,children:(0,M.jsx)(yN,{recording:O,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:r}),(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 ${t?`bg-emerald-500`:`bg-red-500`}`}),t?`Online`:`Offline`]})})]}),(0,M.jsx)(`div`,{className:`flex-1`}),(w!==null||E!==null)&&(0,M.jsxs)(`div`,{className:`relative mr-1.5`,onMouseEnter:()=>re(!0),onMouseLeave:()=>re(!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(w??0)+Number(E??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`})]})]}),D&&(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(w??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(E??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:[ae!==`loading`&&ae!==`unsupported`&&(0,M.jsx)(`button`,{onClick:()=>{ae===`subscribed`?le():ae===`unsubscribed`&&ce()},disabled:ae===`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:ae===`denied`?`Notifications blocked — enable in browser settings`:ae===`subscribed`?`Disable push notifications`:`Enable push notifications`,children:ae===`denied`?(0,M.jsx)(x,{className:`h-[18px] w-[18px]`}):ae===`subscribed`?(0,M.jsx)(S,{className:`h-[18px] w-[18px] text-primary`}):(0,M.jsx)(C,{className:`h-[18px] w-[18px]`})}),(0,M.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,M.jsx)(`button`,{onClick:()=>c(e=>{let t=!e;return t||u(!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)(ne,{className:`h-[18px] w-[18px]`})}),s&&(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:()=>{f(!0),c(!1),u(!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)(ge,{className:`h-4 w-4`}),`Settings`]}),l?(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:()=>{We(),u(!1),c(!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:()=>u(!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:()=>u(!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)(oe,{className:`h-4 w-4`}),`New conversation`]}),me&&!pe&&(0,M.jsxs)(`button`,{onClick:()=>{c(!1),u(!1),he?window.parent.postMessage({type:`bloby:install-app`},`*`):A(!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)(te,{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)(oN,{messages:Fe,streaming:Ie,streamBuffer:Le,tools:Re,hasMore:ze,onLoadOlder:Be}),(0,M.jsx)(pN,{onSend:Ve,onStop:Ue,streaming:Ie,whisperEnabled:a,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:He,onRecordingChange:ie})]}),d&&(0,M.jsx)(y,{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:()=>{f(!1),Ee(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&i(e.agent_name),o(e.whisper_enabled===`true`)}).catch(()=>{}),window.parent?.postMessage({type:`bloby:onboard-complete`},`*`)}}),ue&&(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:()=>A(!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:()=>A(!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)(_e,{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.`}),fe?(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)(de,{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:()=>A(!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`})})}ve.createRoot(document.getElementById(`root`)).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(bN,{})}));export{jC as i,Nx as n,DC as r,ax as t};
294
+ </style></head><body>${t}</body></html>`),n.document.close())}function nN(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&&tN(n)}}function rN({role:e,content:t,timestamp:n,hasAttachments:r,audioData:i,attachments:a,onImageClick:o,transcribing:s}){let c=e===`user`,l=n?JM(n):``,{tag:u,body:d}=YM(t),p=a?.filter(e=>e.mediaType?.startsWith(`image/`))||[],m=a?.filter(e=>!e.mediaType?.startsWith(`image/`))||[],h=p.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)(eN,{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:[h.length>0&&(0,M.jsx)(`div`,{className:`flex gap-1.5 flex-wrap mb-2`,children:h.map((e,t)=>(0,M.jsx)(PM,{src:e,alt:p[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?.(h,t)},t))}),m.length>0&&(0,M.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-primary-foreground/60 mr-1.5`,children:[(0,M.jsx)(ce,{className:`h-3 w-3`}),m.length>1&&(0,M.jsx)(`span`,{className:`text-xs`,children:m.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)(ce,{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)(NM,{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)(XM,{tag:u}),u]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50`,children:l})]})]});let g=e=>(0,M.jsx)(kC,{mode:`static`,plugins:{code:AM},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)(f,{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)(f,{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:ZM(e)});if($M(d)){let e=QM(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)(eN,{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:nN,children:e.map((e,t)=>e.type===`text`?(0,M.jsx)(`div`,{children:g(e.value)},t):e.type===`env`?(0,M.jsx)(FM,{group:e.group},t):e.type===`bloby-image`?(0,M.jsx)(LM,{src:e.src,alt:e.alt},t):e.type===`bloby-text`?(0,M.jsx)(BM,{title:e.title,content:e.content},t):e.type===`notch`?(0,M.jsx)(UM,{format:e.format,content:e.content,cardType:e.cardType},t):e.type===`morphy-action`?(0,M.jsx)(qM,{actionType:e.actionType,content:e.content},t):e.type===`mac-actions`?e.actions.map((e,n)=>e.type===`card`?(0,M.jsx)(UM,{format:`card`,content:JSON.stringify(e.data??{}),cardType:e.preset},`${t}-${n}`):(0,M.jsx)(qM,{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)(eN,{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:nN,children:g(d)})]}),l&&(0,M.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 px-1`,children:l})]})}function iN({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)(kC,{mode:`streaming`,isAnimating:!0,caret:`block`,plugins:{code:AM},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 aN({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=jM(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)(_,{children:(0,M.jsxs)(m.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 Ee(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)(te,{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)(_e,{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)(T,{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)(E,{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 oN({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)(rN,{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)(iN,{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)(aN,{images:f.images,index:f.index,onClose:()=>p(null),onNavigate:e=>p(t=>t?{...t,index:e}:null)})]})}var sN=()=>typeof window>`u`?null:window.SpeechRecognition??window.webkitSpeechRecognition??null,cN=sN()!==null;function lN(){let e=(0,j.useRef)(null),t=(0,j.useRef)(``),n=(0,j.useRef)(null),r=(0,j.useMemo)(()=>cN,[]);return{start:(0,j.useCallback)((r=!1)=>{let i=sN();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 uN(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function dN(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 fN=`bloby_draft`;function pN({onSend:e,onStop:t,streaming:n,whisperEnabled:r,onTranscribe:i,onRecordingChange:a,onAudioReady:o}){let{start:s,stop:c,abort:l,isSupported:u}=lN(),d=r||u,[f,p]=(0,j.useState)(()=>{try{return localStorage.getItem(fN)||``}catch{return``}}),[g,v]=(0,j.useState)([]),y=(0,j.useRef)(null),[b,x]=(0,j.useState)(!1),S=(0,j.useCallback)(e=>{x(e),a?.(e)},[a]),[C,T]=(0,j.useState)(0),E=f.trim().length>0,ee=E||g.length>0,D=(0,j.useRef)(null),te=(0,j.useRef)(null),ne=(0,j.useRef)(null),re=(0,j.useRef)(null),O=(0,j.useRef)(null),ie=(0,j.useRef)(0),ae=(0,j.useRef)(0),oe=(0,j.useRef)(null),k=(0,j.useRef)(!1),se=(0,j.useRef)(!1),le=(0,j.useRef)(null),ue=(0,j.useRef)(null),de=(0,j.useRef)([]),fe=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=D.current;e&&(e.style.height=`0px`,e.style.height=`${Math.min(e.scrollHeight,88)}px`)},[f]),(0,j.useEffect)(()=>(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{try{localStorage.setItem(fN,f)}catch{}},500),()=>{y.current&&clearTimeout(y.current)}),[f]),(0,j.useEffect)(()=>{if(b)return le.current=setInterval(()=>T(e=>e+1),1e3),()=>{le.current&&clearInterval(le.current)}},[b]);let he=(0,j.useCallback)(async t=>{le.current&&clearInterval(le.current),oe.current&&=(clearTimeout(oe.current),null),k.current=!1;let n=ue.current,r=fe.current;if(t)r?.getTracks().forEach(e=>e.stop()),ue.current=null,fe.current=null,de.current=[],l();else if(n&&n.state!==`inactive`)n.onstop=async()=>{r?.getTracks().forEach(e=>e.stop());let t=new Blob(de.current,{type:`audio/webm`});if(de.current=[],ue.current=null,fe.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=g.length>0?g: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&&v([])},n.readAsDataURL(t)},n.stop();else{r?.getTracks().forEach(e=>e.stop()),ue.current=null,fe.current=null,de.current=[];try{let t=await c();if(t.trim()){let n=g.length>0?g:void 0;e(t.trim(),n),n&&v([])}}catch(e){console.error(`[InputBar] Web Speech stop error:`,e)}}O.current&&(O.current.style.transform=``),S(!1),T(0),ae.current=0},[e,i,g,r,l,c]),ge=(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 dN(r)),v(n=>[...n,{id:Math.random().toString(36).slice(2),type:t?`image`:`file`,name:e.name,preview:r}])},r.readAsDataURL(e)},[]),ve=(0,j.useCallback)(e=>{let t=e.target.files;if(t){for(let e=0;e<t.length;e++)ge(t[e]);e.target.value=``}},[ge]),ye=(0,j.useCallback)(e=>{v(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&&ge(n)}}};return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)},[ge]);let be=()=>{if(ee){e(f,g.length>0?g:void 0),p(``),v([]);try{localStorage.removeItem(fN)}catch{}requestAnimationFrame(()=>D.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&&!se.current)&&xe&&!se.current){e.getTracks().forEach(e=>e.stop());return}fe.current=e;let t=MediaRecorder.isTypeSupported(`audio/webm;codecs=opus`)?`audio/webm;codecs=opus`:`audio/webm`,n=new MediaRecorder(e,{mimeType:t});de.current=[],n.ondataavailable=e=>{e.data.size>0&&de.current.push(e.data)},ue.current=n,n.start()}else if(s(!xe),xe&&!se.current){l();return}k.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(b){he(!1);return}se.current=!0,Se();return}se.current=!0,ie.current=e.clientX,ae.current=0,e.currentTarget.setPointerCapture(e.pointerId),oe.current=setTimeout(()=>{try{navigator.vibrate?.(50)}catch{}Se()},200)},[xe,b,d,Se,he]),we=(0,j.useCallback)(e=>{if(!xe||!k.current)return;let t=Math.min(0,e.clientX-ie.current);if(ae.current=t,O.current&&(O.current.style.transform=`translateX(${t}px)`),re.current){let t=re.current.getBoundingClientRect(),n=t.left+t.width/2;Math.abs(e.clientX-n)<36&&he(!0)}},[xe,he]),Te=(0,j.useCallback)(()=>{se.current=!1,oe.current&&=(clearTimeout(oe.current),null),xe&&k.current&&he(!1)},[xe,he]),Ee=(0,j.useCallback)(()=>{se.current=!1,oe.current&&=(clearTimeout(oe.current),null),k.current&&he(!0)},[he]);return(0,M.jsxs)(`div`,{className:`shrink-0 p-3 relative`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col transition-opacity duration-100 ${b?`opacity-0 pointer-events-none`:`opacity-100`}`,children:[(0,M.jsx)(_,{children:g.length>0&&(0,M.jsx)(m.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:g.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:()=>ye(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)(_e,{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:D,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(),ee&&be())},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:te,type:`file`,className:`hidden`,accept:`image/*,.pdf`,multiple:!0,onChange:ve}),(0,M.jsx)(`input`,{ref:ne,type:`file`,className:`hidden`,accept:`image/*`,capture:`environment`,onChange:ve}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>te.current?.click(),className:`shrink-0 p-1.5 mb-2 text-gray-400 hover:text-gray-600 transition-colors`,children:(0,M.jsx)(ce,{className:`h-4 w-4`})}),(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)(w,{className:`h-4 w-4`})})]}),E?(0,M.jsx)(`button`,{onClick:be,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)(A,{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)(h,{className:`h-4 w-4`})})]})]}),(0,M.jsx)(_,{children:b&&(0,M.jsx)(m.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:uN(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:re,className:`flex items-center justify-center h-9 w-9 shrink-0 rounded-full bg-destructive/10 text-destructive`,children:(0,M.jsx)(me,{className:`h-4 w-4`})}),(0,M.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0`,children:(0,M.jsx)(m.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:O,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)(h,{className:`h-5 w-5`})})})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{onClick:()=>he(!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)(me,{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:()=>he(!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)(pe,{className:`h-4 w-4`})})})]})})]})})})]})}var mN=`/morphy/headphones.json`,hN=`/morphy/`,gN=null,_N=null;function vN(){return gN&&_N?Promise.resolve({img:gN,cfg:_N}):fetch(mN).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=()=>{gN=r,_N=e,t({img:r,cfg:e})},r.onerror=n,r.src=hN+e.spritesheet}))}function yN({recording:e,height:t=36,onDone:n}){let r=(0,j.useRef)(null),i=(0,j.useRef)(gN),a=(0,j.useRef)(_N),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)(()=>{vN().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 bN(){let e=(0,j.useRef)(null),[t,n]=(0,j.useState)(!1),[r,i]=(0,j.useState)(`Bloby`),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(0),h=(0,j.useRef)(null),_=(0,j.useRef)(!1),[v,b]=(0,j.useState)(!0),[w,T]=(0,j.useState)(null),[E,ee]=(0,j.useState)(null),[D,re]=(0,j.useState)(!1),[O,ie]=(0,j.useState)(!1),[ae,k]=(0,j.useState)(`loading`);function se(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 ce(){try{if(await Notification.requestPermission()!==`granted`){k(`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:se(n)})).toJSON(),i=e.current;i&&i.send(`push:subscribe`,{endpoint:r.endpoint,keys:r.keys}),k(`subscribed`)}catch(e){console.error(`[push] Subscribe failed:`,e)}}async function le(){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})}k(`unsubscribed`)}catch(e){console.error(`[push] Unsubscribe failed:`,e)}}let[ue,A]=(0,j.useState)(!1),fe=/iPad|iPhone|iPod/.test(navigator.userAgent),pe=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone,me=/Android|iPhone|iPad|iPod|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),he=window.self!==window.top;(0,j.useEffect)(()=>{let e=e=>{e.data?.type===`bloby:show-ios-install`&&A(!0)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]);let[ve,be]=(0,j.useState)(!1),[xe,Oe]=(0,j.useState)(!1),[Ae,je]=(0,j.useState)(!1),[Me,Ne]=(0,j.useState)(!1);(0,j.useEffect)(()=>{(async()=>{try{let e=await(await fetch(`/api/onboard/status`)).json();if(e.totpEnabled&&Ne(!0),!e.portalConfigured){Oe(!1),je(!0),be(!0);return}Oe(!0);let t=Se();if(t){if((await(await fetch(`/api/portal/validate-token?token=${encodeURIComponent(t)}`)).json()).valid){je(!0),be(!0);return}we()}je(!1),be(!0)}catch{je(!0),be(!0)}})()},[]);let Pe=e=>{Ce(e),je(!0)};(0,j.useEffect)(()=>{Te(()=>{je(!1),Oe(!0)})},[]),(0,j.useEffect)(()=>{if(!Ae)return;let e=()=>{fetch(`/app/api/health`).then(e=>b(e.ok)).catch(()=>b(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[Ae]),(0,j.useEffect)(()=>{Ae&&(async()=>{if(!(`PushManager`in window)||!(`serviceWorker`in navigator)){k(`unsupported`);return}if(Notification.permission===`denied`){k(`denied`);return}try{let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();k(e&&(await(await Ee(`/api/push/status?endpoint=${encodeURIComponent(e.endpoint)}`)).json()).subscribed?`subscribed`:`unsubscribed`)}catch{k(`unsupported`)}})()},[Ae]),(0,j.useEffect)(()=>{if(!Ae)return;let t=location.protocol===`https:`?`wss:`:`ws:`,r=location.host,i=new ye(`${t}//${r}/bloby/ws`,Se);e.current=i;let a=i.onStatus(e=>{n(e),e&&_.current&&m(e=>e+1),_.current=e}),o=i.on(`app:rebuilding`,()=>{window.parent?.postMessage({type:`bloby:rebuilding`},`*`)}),s=i.on(`app:rebuilt`,()=>{window.parent?.postMessage({type:`bloby:rebuilt`},`*`)}),c=i.on(`app:build-error`,e=>{window.parent?.postMessage({type:`bloby:build-error`,error:e.error},`*`)}),l=i.on(`app:hmr-update`,()=>{window.parent?.postMessage({type:`bloby:hmr-update`},`*`)}),u=i.on(`bot:response`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)}),d=i.on(`chat:sync`,()=>{window.parent?.postMessage({type:`bloby:new-message`},`*`)});return i.connect(),()=>{a(),o(),s(),c(),l(),u(),d(),i.disconnect()}},[Ae]),(0,j.useEffect)(()=>{Ae&&(Ee(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&i(e.agent_name),e.whisper_enabled===`true`&&o(!0)}).catch(()=>{}),Ee(`/api/wallet/balance`).then(e=>e.json()).then(e=>{e.address&&(T(e.tempo??`0.00`),ee(e.base??`0.00`))}).catch(()=>{}))},[Ae]),(0,j.useEffect)(()=>{if(!s)return;let e=e=>{h.current&&!h.current.contains(e.target)&&(c(!1),u(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[s]);let{messages:Fe,streaming:Ie,streamBuffer:Le,tools:Re,hasMore:ze,loadOlder:Be,sendMessage:Ve,addPendingAudio:He,stopStreaming:Ue,clearContext:We}=De(e.current,p,Ae);return(0,j.useEffect)(()=>{let t=async t=>{if(t.data?.type!==`bloby:voice-record`)return;let{audio:n,transcript:r}=t.data;if(n&&a){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()&&Ve(e.transcript.trim(),void 0,`data:audio/webm;base64,${n}`)}catch(e){console.error(`[BlobyApp] widget voice transcription error:`,e)}}else r?.trim()&&Ve(r.trim())};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[Ve,a]),ve?xe&&!Ae?(0,M.jsx)(ke,{onLogin:Pe,totpEnabled:Me}):(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)(g,{className:`h-[18px] w-[18px]`})}),(0,M.jsx)(`div`,{className:`relative ml-1.5 shrink-0 -translate-y-[5px]`,children:(0,M.jsx)(yN,{recording:O,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:r}),(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 ${t?`bg-emerald-500`:`bg-red-500`}`}),t?`Online`:`Offline`]})})]}),(0,M.jsx)(`div`,{className:`flex-1`}),(w!==null||E!==null)&&(0,M.jsxs)(`div`,{className:`relative mr-1.5`,onMouseEnter:()=>re(!0),onMouseLeave:()=>re(!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(w??0)+Number(E??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`})]})]}),D&&(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(w??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(E??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:[ae!==`loading`&&ae!==`unsupported`&&(0,M.jsx)(`button`,{onClick:()=>{ae===`subscribed`?le():ae===`unsubscribed`&&ce()},disabled:ae===`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:ae===`denied`?`Notifications blocked — enable in browser settings`:ae===`subscribed`?`Disable push notifications`:`Enable push notifications`,children:ae===`denied`?(0,M.jsx)(x,{className:`h-[18px] w-[18px]`}):ae===`subscribed`?(0,M.jsx)(S,{className:`h-[18px] w-[18px] text-primary`}):(0,M.jsx)(C,{className:`h-[18px] w-[18px]`})}),(0,M.jsxs)(`div`,{className:`relative`,ref:h,children:[(0,M.jsx)(`button`,{onClick:()=>c(e=>{let t=!e;return t||u(!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)(ne,{className:`h-[18px] w-[18px]`})}),s&&(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:()=>{f(!0),c(!1),u(!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)(ge,{className:`h-4 w-4`}),`Settings`]}),l?(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:()=>{We(),u(!1),c(!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:()=>u(!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:()=>u(!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)(oe,{className:`h-4 w-4`}),`New conversation`]}),me&&!pe&&(0,M.jsxs)(`button`,{onClick:()=>{c(!1),u(!1),he?window.parent.postMessage({type:`bloby:install-app`},`*`):A(!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)(te,{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)(oN,{messages:Fe,streaming:Ie,streamBuffer:Le,tools:Re,hasMore:ze,onLoadOlder:Be}),(0,M.jsx)(pN,{onSend:Ve,onStop:Ue,streaming:Ie,whisperEnabled:a,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:He,onRecordingChange:ie})]}),d&&(0,M.jsx)(y,{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:()=>{f(!1),Ee(`/api/settings`).then(e=>e.json()).then(e=>{e.agent_name&&i(e.agent_name),o(e.whisper_enabled===`true`)}).catch(()=>{}),window.parent?.postMessage({type:`bloby:onboard-complete`},`*`)}}),ue&&(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:()=>A(!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:()=>A(!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)(_e,{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.`}),fe?(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)(de,{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:()=>A(!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`})})}ve.createRoot(document.getElementById(`root`)).render((0,M.jsx)(j.StrictMode,{children:(0,M.jsx)(bN,{})}));export{jC as i,Nx as n,DC as r,ax 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-C0cl8nq4.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};
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-pIi5JIgB.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-pIi5JIgB.js";export{e as Mermaid};
@@ -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-C0cl8nq4.js"></script>
7
+ <script type="module" crossorigin src="/bloby/assets/bloby-pIi5JIgB.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-DSmE2rZO.js">
10
10
  <link rel="stylesheet" crossorigin href="/bloby/assets/globals-BqjrOUer.css">
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "bloby-bot",
3
- "version": "0.55.0",
3
+ "version": "0.56.0",
4
4
  "releaseNotes": [
5
5
  "1. Fix: image (and audio) attachments now render in chat again — /api/files is fetched with the auth token instead of a raw <img> src that 401'd after the endpoint hardening",
6
6
  "2. Affects chat thumbnails, the image lightbox, voice-note playback, and agent image cards",
7
- "3. Chat now renders <morphy_action> Mac actions as a clean \"Agent actions: Spotlight at screen N\" chip instead of the raw tag"
7
+ "3. Chat now renders Mac actions instead of raw tags: <mac_actions> arrays (and legacy <morphy_action>) fan out to clean \"Agent actions: Point at screen N\" chips, and card actions render as notch cards"
8
8
  ],
9
9
  "description": "Self-hosted, self-evolving AI agent with its own dashboard.",
10
10
  "type": "module",
@@ -91,7 +91,13 @@ function preprocessContent(text: string): string {
91
91
  return out;
92
92
  }
93
93
 
94
- type ContentSegment = { type: 'text'; value: string } | { type: 'env'; group: EnvGroupData } | { type: 'bloby-image'; src: string; alt: string } | { type: 'bloby-text'; title: string; content: string } | { type: 'notch'; format: 'html' | 'card'; content: string; cardType?: string } | { type: 'morphy-action'; actionType: string; content: string };
94
+ /** One entry from a <mac_actions> JSON array (the current Mac action-registry format).
95
+ * `card` actions carry a preset + data (rendered as a notch card); the screen-acting
96
+ * verbs (point/spotlight/…) carry coordinates we don't surface. Kept loose so unknown
97
+ * future verbs still parse. */
98
+ type MacAction = { type?: string; preset?: string; data?: unknown; screen?: number; [key: string]: unknown };
99
+
100
+ type ContentSegment = { type: 'text'; value: string } | { type: 'env'; group: EnvGroupData } | { type: 'bloby-image'; src: string; alt: string } | { type: 'bloby-text'; title: string; content: string } | { type: 'notch'; format: 'html' | 'card'; content: string; cardType?: string } | { type: 'morphy-action'; actionType: string; content: string } | { type: 'mac-actions'; actions: MacAction[] };
95
101
 
96
102
  /** Extract <EnvGroup> and <BlobyImage> tags from content, splitting into typed segments */
97
103
  function extractContentSegments(text: string): ContentSegment[] {
@@ -139,13 +145,27 @@ function extractContentSegments(text: string): ContentSegment[] {
139
145
  matches.push({ start: match.index, end: match.index + match[0].length, segment: { type: 'notch', format: 'card', content: match[2].trim(), cardType: match[1] } });
140
146
  }
141
147
 
142
- // Find <morphy_action type="..."> blocks — Mac screen actions (spotlight/point/…),
143
- // shown as a compact "Agent actions" chip rather than the raw tag + coordinates.
148
+ // Find <morphy_action type="..."> blocks — legacy single Mac screen action (spotlight/
149
+ // point/…), shown as a compact "Agent actions" chip rather than the raw tag + coordinates.
144
150
  const morphyActionRegex = /<morphy_action\s+type="([^"]+)">([\s\S]*?)<\/morphy_action>/gi;
145
151
  while ((match = morphyActionRegex.exec(text)) !== null) {
146
152
  matches.push({ start: match.index, end: match.index + match[0].length, segment: { type: 'morphy-action', actionType: match[1], content: match[2].trim() } });
147
153
  }
148
154
 
155
+ // Find <mac_actions> blocks — the current action-registry format: a JSON array of
156
+ // actions. Each entry is fanned out at render time — `card` → a notch card, every
157
+ // screen-acting verb (point/spotlight/…) → an "Agent actions" chip. A malformed/
158
+ // non-array payload yields no actions (nothing rendered) rather than raw JSON.
159
+ const macActionsRegex = /<mac_actions>([\s\S]*?)<\/mac_actions>/gi;
160
+ while ((match = macActionsRegex.exec(text)) !== null) {
161
+ let actions: MacAction[] = [];
162
+ try {
163
+ const parsed = JSON.parse(match[1].trim());
164
+ if (Array.isArray(parsed)) actions = parsed;
165
+ } catch { /* malformed JSON — render nothing for this block */ }
166
+ matches.push({ start: match.index, end: match.index + match[0].length, segment: { type: 'mac-actions', actions } });
167
+ }
168
+
149
169
  // Sort by position in text
150
170
  matches.sort((a, b) => a.start - b.start);
151
171
 
@@ -170,7 +190,7 @@ function extractContentSegments(text: string): ContentSegment[] {
170
190
 
171
191
  /** Check if content has any custom tags that need special rendering */
172
192
  function hasCustomTags(text: string): boolean {
173
- return /<EnvGroup\s+title="[^"]+">/i.test(text) || /<BlobyImage\s+src="/i.test(text) || /<BlobyText\s+title="/i.test(text) || /<notch_html>/i.test(text) || /<notch_card\s+type="/i.test(text) || /<morphy_action\s+type="/i.test(text);
193
+ return /<EnvGroup\s+title="[^"]+">/i.test(text) || /<BlobyImage\s+src="/i.test(text) || /<BlobyText\s+title="/i.test(text) || /<notch_html>/i.test(text) || /<notch_card\s+type="/i.test(text) || /<morphy_action\s+type="/i.test(text) || /<mac_actions>/i.test(text);
174
194
  }
175
195
 
176
196
  function CopyButton({ text }: { text: string }) {
@@ -397,6 +417,17 @@ export default function MessageBubble({ role, content, timestamp, hasAttachments
397
417
  if (seg.type === 'bloby-text') return <BlobyTextCard key={i} title={seg.title} content={seg.content} />;
398
418
  if (seg.type === 'notch') return <NotchCard key={i} format={seg.format} content={seg.content} cardType={seg.cardType} />;
399
419
  if (seg.type === 'morphy-action') return <MorphyActionCard key={i} actionType={seg.actionType} content={seg.content} />;
420
+ if (seg.type === 'mac-actions') {
421
+ // Fan each action out: `card` → notch card (preset+data, same as a legacy
422
+ // <notch_card>); every screen-acting verb → an "Agent actions" chip.
423
+ return seg.actions.map((action, j) =>
424
+ action.type === 'card' ? (
425
+ <NotchCard key={`${i}-${j}`} format="card" content={JSON.stringify(action.data ?? {})} cardType={action.preset} />
426
+ ) : (
427
+ <MorphyActionCard key={`${i}-${j}`} actionType={action.type ?? 'action'} content={JSON.stringify(action)} />
428
+ ),
429
+ );
430
+ }
400
431
  return null;
401
432
  })}
402
433
  </div>
@@ -120,6 +120,9 @@ export default function MessageList({ messages, streaming, streamBuffer, tools,
120
120
  // Same for <morphy_action> Mac screen actions (complete blocks, then a trailing unclosed one)
121
121
  .replace(/<morphy_action\s+type="[^"]*">[\s\S]*?<\/morphy_action>/gi, '')
122
122
  .replace(/<morphy_action\b[\s\S]*$/i, '')
123
+ // Same for the current <mac_actions> JSON-array blocks
124
+ .replace(/<mac_actions>[\s\S]*?<\/mac_actions>/gi, '')
125
+ .replace(/<mac_actions\b[\s\S]*$/i, '')
123
126
  .trimEnd()}
124
127
  toolName={currentToolName}
125
128
  />
@@ -120,7 +120,7 @@ const SW_JS = `// Service worker — app-shell caching + push notifications
120
120
  // cached shell that masks a broken (or just-fixed) frontend and produces the confusing
121
121
  // "normal refresh is broken but hard refresh works" split. Cache is a pure offline fallback.
122
122
 
123
- var CACHE = 'bloby-v19';
123
+ var CACHE = 'bloby-v20';
124
124
  var HASHED_RE = new RegExp('/assets/.+-[a-zA-Z0-9]{6,}[.](js|css)$');
125
125
 
126
126
  // Precache the HTML shell on install so the cache is never empty.
@@ -1 +0,0 @@
1
- import{i as e}from"./bloby-C0cl8nq4.js";export{e as Mermaid};