better-grill 0.4.0 → 0.4.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "better-grill",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Run grill sessions in a local browser UI instead of the terminal: rounds of questions with options and a recommendation, a discussion thread per question, driven by your open Claude Code session.",
5
5
  "author": {
6
6
  "name": "Jakub Stastny",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-grill",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Grill sessions for Claude Code, in your browser instead of the terminal.",
5
5
  "keywords": [
6
6
  "ai",
@@ -47,7 +47,7 @@ Error generating stack: `+e.message+`
47
47
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
48
48
  `,...a.current()});return/^[\t ]/.test(l)&&(l=_R(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}CR.peek=wR;function CR(e){return e.value||``}function wR(){return`<`}TR.peek=ER;function TR(e,t,n,r){let i=mR(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function ER(){return`!`}DR.peek=OR;function DR(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function OR(){return`!`}kR.peek=AR;function kR(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function AR(){return"`"}function jR(e,t){let n=nM(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}MR.peek=NR;function MR(e,t,n,r){let i=mR(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(jR(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function NR(e,t,n){return jR(e,n)?`<`:`[`}PR.peek=FR;function PR(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function FR(){return`[`}function IR(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function LR(e){let t=IR(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function RR(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function zR(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function BR(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?RR(n):IR(n),s=e.ordered?o===`.`?`)`:`.`:LR(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),zR(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function VR(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function HR(e,t,n,r){let i=VR(n),a=n.bulletCurrent||IR(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function UR(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var WR=ZF([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function GR(e,t,n,r){return(e.children.some(function(e){return WR(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function KR(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}qR.peek=JR;function qR(e,t,n,r){let i=KR(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=vR(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=_R(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=vR(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+_R(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function JR(e,t,n){return n.options.strong||`*`}function YR(e,t,n,r){return n.safe(e.value,r)}function XR(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function ZR(e,t,n){let r=(zR(n)+(n.options.ruleSpaces?` `:``)).repeat(XR(n));return n.options.ruleSpaces?r.slice(0,-1):r}var QR={blockquote:iR,break:cR,code:fR,definition:hR,emphasis:yR,hardBreak:cR,heading:SR,html:CR,image:TR,imageReference:DR,inlineCode:kR,link:MR,linkReference:PR,list:BR,listItem:HR,paragraph:UR,root:GR,strong:qR,text:YR,thematicBreak:ZR};function $R(){return{enter:{table:ez,tableData:iz,tableHeader:iz,tableRow:nz},exit:{codeText:az,table:tz,tableData:rz,tableHeader:rz,tableRow:rz}}}function ez(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function tz(e){this.exit(e),this.data.inTable=void 0}function nz(e){this.enter({type:`tableRow`,children:[]},e)}function rz(e){this.exit(e)}function iz(e){this.enter({type:`tableCell`,children:[]},e)}function az(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,oz));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function oz(e,t){return t===`|`?t:e}function sz(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
49
49
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
50
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return tR(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=QR.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function cz(){return{exit:{taskListCheckValueChecked:uz,taskListCheckValueUnchecked:uz,paragraph:dz}}}function lz(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:fz}}}function uz(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function dz(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function fz(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=QR.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function pz(){return[yL(),UL(),JL(),$R(),cz()]}function mz(e){return{extensions:[bL(),WL(e),YL(),sz(e),lz()]}}var hz={tokenize:kz,partial:!0},gz={tokenize:Az,partial:!0},_z={tokenize:jz,partial:!0},vz={tokenize:Mz,partial:!0},yz={tokenize:Nz,partial:!0},bz={name:`wwwAutolink`,tokenize:Dz,previous:Pz},xz={name:`protocolAutolink`,tokenize:Oz,previous:Fz},Sz={name:`emailAutolink`,tokenize:Ez,previous:Iz},Cz={};function wz(){return{text:Cz}}for(var Tz=48;Tz<123;)Cz[Tz]=Sz,Tz++,Tz===58?Tz=65:Tz===91&&(Tz=97);Cz[43]=Sz,Cz[45]=Sz,Cz[46]=Sz,Cz[95]=Sz,Cz[72]=[Sz,xz],Cz[104]=[Sz,xz],Cz[87]=[Sz,bz],Cz[119]=[Sz,bz];function Ez(e,t,n){let r=this,i,a;return o;function o(t){return!Lz(t)||!Iz.call(r,r.previous)||Rz(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Lz(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(yz,u,l)(t):t===45||t===95||_M(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&gM(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Dz(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Pz.call(r,r.previous)||Rz(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(hz,e.attempt(gz,e.attempt(_z,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Oz(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Fz.call(r,r.previous)&&!Rz(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(gM(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||yM(t)||CM(t)||EM(t)||TM(t)?n(t):e.attempt(gz,e.attempt(_z,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function kz(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Az(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(vz,c,s)(t):t===null||CM(t)||EM(t)||t!==45&&TM(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function jz(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(vz,t,a)(o):o===null||CM(o)||EM(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Mz(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||CM(o)||EM(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||CM(e)||EM(e)?t(e):r(e)}function a(e){return gM(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):gM(t)?(e.consume(t),o):n(t)}}function Nz(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return _M(e)?n(e):t(e)}}function Pz(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||CM(e)}function Fz(e){return!gM(e)}function Iz(e){return!(e===47||Lz(e))}function Lz(e){return e===43||e===45||e===46||e===95||_M(e)}function Rz(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var zz={tokenize:qz,partial:!0};function Bz(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Wz,continuation:{tokenize:Gz},exit:Kz}},text:{91:{name:`gfmFootnoteCall`,tokenize:Uz},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Vz,resolveTo:Hz}}}}function Vz(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=hM(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Hz(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Uz(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||CM(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(hM(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return CM(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Wz(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||CM(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=hM(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return CM(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),kM(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Gz(e,t,n){return e.check(WM,t,e.attempt(zz,t,n))}function Kz(e){e.exit(`gfmFootnoteDefinition`)}function qz(e,t,n){let r=this;return kM(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Jz(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&cM(o,o.length,0,LM(s,e.slice(r+1,n),t)),cM(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),cM(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=IM(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=IM(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Yz=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Xz(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Xz(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function Zz(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Qz(){return{flow:{null:{name:`table`,tokenize:$z,resolveAll:eB}}}}function $z(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):wM(t)?kM(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||CM(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,wM(t)?kM(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return wM(t)?kM(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return wM(t)?kM(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):wM(n)?kM(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||CM(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function eB(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Yz;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(nB(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=tB(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=tB(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=tB(f,t,o,i,n,d)):(o[0]=o[1],d=tB(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&nB(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Zz(t.events,n))}return e}function tB(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},rB(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=rB(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=rB(t.events,n[2]),a=rB(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},rB(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function nB(e,t,n,r,i){let a=[],o=rB(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function rB(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var iB={name:`tasklistCheck`,tokenize:oB};function aB(){return{text:{91:iB}}}function oB(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return CM(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):wM(r)?e.check({tokenize:sB},t,n)(r):n(r)}}function sB(e,t,n){return kM(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function cB(e){return dM([wz(),Bz(),Jz(e),Qz(),aB()])}var lB={};function uB(e){let t=this,n=e||lB,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(cB(n)),a.push(pz()),o.push(mz(n))}function dB({children:e,className:t}){return(0,V.jsx)(`div`,{className:B(`md`,t),children:(0,V.jsx)(oL,{remarkPlugins:[uB],components:{a:e=>(0,V.jsx)(`a`,{...e,target:`_blank`,rel:`noreferrer`})},children:e})})}function fB({message:e}){return e.role===`user`?(0,V.jsx)(`div`,{className:`flex justify-end animate-in fade-in-0 slide-in-from-bottom-1`,children:(0,V.jsx)(`div`,{className:`max-w-[85%] rounded-2xl rounded-br-sm bg-primary px-3.5 py-2 text-sm whitespace-pre-wrap text-primary-foreground`,children:(0,V.jsx)(SA,{text:e.text,images:e.images,tone:`inverse`})})}):(0,V.jsxs)(`div`,{className:`flex gap-2.5 animate-in fade-in-0 slide-in-from-bottom-1`,children:[(0,V.jsx)(mB,{}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Claude`}),(0,V.jsx)(dB,{className:`text-sm`,children:e.text})]})]})}function pB({queued:e}){return(0,V.jsxs)(`div`,{role:`status`,className:`flex items-end gap-2.5 animate-in fade-in-0 slide-in-from-bottom-1`,children:[(0,V.jsx)(mB,{}),(0,V.jsxs)(`span`,{className:`flex h-7 items-center rounded-2xl rounded-bl-sm bg-muted px-3 text-base text-primary`,children:[(0,V.jsx)(xm,{}),(0,V.jsx)(`span`,{className:`sr-only`,children:e?`Queued. Claude is busy and will answer next.`:`Claude is reading your message.`})]})]})}function mB(){return(0,V.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,V.jsx)(He,{className:`size-3.5`})})}function hB({question:e,lock:t,claude:n,onClose:r}){let[i,a]=(0,O.useState)(Rk),[o,s]=(0,O.useState)(null),c=lA(xA),l=(0,O.useRef)(null),u=(0,O.useRef)(null),d=dA({disabled:!!t,onFiles:e=>u.current?.insertFiles(e),onReject:s}),f=bA(e),p=c.pending,m=!i.empty,h=m&&!i.uploading&&!p&&!t;(0,O.useEffect)(()=>{l.current?.scrollTo({top:l.current.scrollHeight,behavior:`smooth`})},[e.chat.length,f]),(0,O.useEffect)(()=>{u.current?.focus()},[e.id]);let g=async(n=i)=>{n.empty||n.uploading||p||t||await c.run(e.id,{text:n.text.trim(),images:n.images})&&u.current?.clear()};return Ef(pm.closeChat,()=>{document.querySelector(`[role="dialog"], [role="alertdialog"]`)||r()},{enabled:!m,preventDefault:!1,stopPropagation:!1}),(0,V.jsxs)(`aside`,{className:`relative flex h-full flex-col bg-background`,...d.dropZone,children:[(0,V.jsx)(Em,{show:d.dragging}),(0,V.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b px-3`,children:[(0,V.jsx)(Yk,{className:`font-mono`,children:e.id}),(0,V.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold`,title:e.title,children:e.title}),e.status===`answered`&&(e.answer?.by===`claude`?(0,V.jsx)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:`Resolved by Claude`}):(0,V.jsx)(Yk,{variant:`secondary`,className:`bg-success/10 text-success`,children:`Answered`})),e.status===`dropped`&&(0,V.jsx)(Yk,{variant:`outline`,children:`Dropped`}),(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)(Rr,{variant:`ghost`,size:`icon-sm`,onClick:r,"aria-label":`Close discussion`}),children:(0,V.jsx)(Qe,{})}),(0,V.jsxs)(Bu,{children:[`Close `,(0,V.jsx)(Tm,{hotkey:pm.closeChat})]})]})]}),e.status===`dropped`&&(0,V.jsxs)(`p`,{className:`border-b bg-muted/50 px-4 py-2 text-sm text-muted-foreground`,children:[`Claude dropped this question`,e.dropReason?`: ${e.dropReason}`:`.`,` You can still talk about it.`]}),(0,V.jsxs)(`div`,{ref:l,className:`flex-1 space-y-5 overflow-y-auto px-4 py-5`,"aria-live":`polite`,children:[e.chat.length===0&&(0,V.jsx)(Xk,{className:`h-full p-4 pb-[12svh]`,children:(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{variant:`icon`,children:(0,V.jsx)(we,{})}),(0,V.jsx)(eA,{children:`Push back, ask why`}),(0,V.jsx)(tA,{children:`Claude answers with this question in mind, and can settle it for you.`})]})}),e.chat.map(e=>(0,V.jsx)(fB,{message:e},e.id)),f&&!t&&(0,V.jsx)(pB,{queued:n!==`listening`}),f&&t===`ended`&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The session ended before Claude replied.`})]}),(0,V.jsxs)(`div`,{className:`border-t p-3`,children:[c.error&&(0,V.jsx)(Sm,{className:`mb-2`,message:c.error,onRetry:()=>void g(),onDismiss:c.clearError}),o&&(0,V.jsx)(Sm,{className:`mb-2`,message:o,onDismiss:()=>s(null)}),(0,V.jsxs)(iA,{className:B(`bg-background`,!t&&`has-disabled:bg-background has-disabled:opacity-100 dark:has-disabled:bg-input/30`),children:[(0,V.jsx)(zk,{ref:u,disabled:!!t,invalid:!!c.error,onChange:e=>{e.empty||c.clearError(),a(e)},onSubmit:e=>void g(e),onError:s,placeholder:t?pA[t]:`Ask about this question… (paste or drop images)`,className:`max-h-40 min-h-14`}),(0,V.jsxs)(oA,{align:`block-end`,children:[(0,V.jsx)(`span`,{className:`self-end text-xs text-muted-foreground`,children:p?`Sending…`:i.uploading?`Uploading image…`:`Enter to send · ${Bd(pm.newLine)} for new line`}),(0,V.jsx)(cA,{variant:`default`,size:`icon-sm`,className:`ml-auto rounded-full`,onClick:()=>void g(),disabled:!h,"aria-label":p?`Sending`:`Send`,children:p?(0,V.jsx)(xm,{}):(0,V.jsx)(P,{})})]})]})]})]})}function gB(e){let[t,n]=(0,O.useState)({}),r=e?.id,i=e?yA(e):0;return(0,O.useEffect)(()=>{r&&n(e=>({...e,[r]:i}))},[r,i]),(0,O.useCallback)(e=>yA(e)-(t[e.id]??0),[t])}function _B(){let{resolved:e,setTheme:t}=Ju(),n=e===`dark`?`light`:`dark`,r=n===`dark`?`Dark theme`:`Light theme`;return(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:r,onClick:()=>t(n),"aria-label":`Switch to ${n} theme`,children:[n===`dark`?(0,V.jsx)(Ee,{}):(0,V.jsx)(We,{}),(0,V.jsx)(`span`,{children:r})]})})}var vB={round:e=>`round-${e}`,question:e=>`q-${e}`,summary:`summary`};function yB(){let{toggleSidebar:e}=Xp();Ef(pm.toggleSidebar,e)}var bB={min:240,initial:320,max:520};function xB(){let[e,t]=Wu(Vu.sidebarWidth,bB.initial),n=Math.min(Math.max(e,bB.min),bB.max);return hm(`--app-sidebar-w`,`${n}px`),[n,t]}function SB({value:e,className:t}){let n=Math.min(Math.max(e,0),1)*100;return(0,V.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,strokeWidth:2,"aria-hidden":!0,className:B(`-rotate-90`,t),children:[(0,V.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,className:`stroke-current opacity-20`}),(0,V.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,pathLength:100,strokeDasharray:100,strokeDashoffset:100-n,strokeLinecap:`round`,className:B(`stroke-current transition-[stroke-dashoffset] duration-500 ease-out`,n===0&&`opacity-0`)})]})}function CB(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=Jf({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=$c(a,!0,!0),u=$l(),[d,f]=O.useState(),p=d===null?void 0:d??u,m=H(e=>{let t=!a,n=la(ea,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return O.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var wB=O.createContext(void 0);function TB(){let e=O.useContext(wB);if(e===void 0)throw Error(er(15));return e}var EB=`data-open`,DB=`data-closed`,OB=wi,kB=`data-panel-open`,AB={[EB]:``},jB={[DB]:``},MB={open(e){return e?{[kB]:``}:null}},NB={open(e){return e?AB:jB},...Oi},PB=O.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=H(o),d=CB({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=O.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=O.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=wr(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:NB});return(0,V.jsx)(wB.Provider,{value:p,children:m})}),FB={...MB,...Oi},IB=O.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=TB(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=or({disabled:c,focusableWhenDisabled:!0,native:u});return wr(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:FB})}),LB={height:void 0,width:void 0};function RB(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=O.useRef(null),f=O.useRef(null),[p,m]=O.useState(LB),h=O.useRef(LB),g=O.useRef(!1),_=O.useRef(s),v=O.useRef(!1),[y,b]=O.useState(!1),x=O.useRef(null),S=lr(t,d),C=ha(s),w=nl(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),k=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,A=n&&T&&f.current!==`css-animation`,j=H((e,t=!0)=>{t&&(h.current=e),m(e)}),M=H(()=>{x.current?.(),x.current=null}),N=H(e=>{M(),x.current=()=>{x.current=null,e()}}),P=H(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});U(()=>{y&&u!==`starting`&&b(!1)},[y,u]),O.useEffect(()=>()=>{P(),M()},[P,M]),U(()=>{let e=d.current;if(!e)return;!s&&x.current&&M();let t=BB(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=zB(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){j(zB(e)),b(!0);return}if(t===`css-transition`){let t=UB(e);if(j(zB(e)),!n)return t;let r=HB(e,`transition-duration`,`0s`);return N(r),b(!0),t}j(zB(e));let r=HB(e,`animation-name`,`none`);if(!n){r();return}let i=HB(e,`animation-duration`,`0s`);r(),N(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(_.current=!1,v.current=!1,t===`none`){j(LB,!1),c(!1);return}j(zB(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=zB(e);if(!(n.height>0||n.width>0)){c(!1);return}j(n),t===`css-animation`&&HB(e,`animation-name`,`none`)()},[a,s,M,j,c,N,D,u]),rl({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&j(LB,!1)}}),O.useEffect(()=>{if(s||!a||E!==`ending`||!d.current)return;let e=new AbortController,t=-1;function n(){C.current||(c(!1),j(LB,!1))}return t=ya.request(()=>{w(n,e.signal)}),()=>{ya.cancel(t),e.abort()}},[C,a,s,E,w,j,c]),U(()=>{let e=d.current;e&&n&&T&&e.setAttribute(`hidden`,`until-found`)},[T,n]),O.useEffect(function(){let e=d.current;if(!e)return;function t(e){let t=la($i,e);o(!0,t),!t.isCanceled&&(g.current=!0,l(!0))}return G(e,`beforematch`,t)},[o,l]);let F=i||n||a||s;return{height:k.height,props:{...A?{[OB]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:F,transitionStatus:E,width:k.width}}function zB(e){return{height:e.scrollHeight,width:e.scrollWidth}}function BB(e,t){let n=sn(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&VB(n.animationDuration),i=VB(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function VB(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function HB(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function UB(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=ya.request(n);return()=>{ya.cancel(r),n()}}var WB=`--collapsible-panel-height`,GB=`--collapsible-panel-width`,KB=O.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=TB(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;U(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=RB({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=Cr(s,k),j=wr(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[WB]:S===void 0?`auto`:`${S}px`,[GB]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:NB});return E?j:null});function qB({...e}){return(0,V.jsx)(PB,{"data-slot":`collapsible`,...e})}function JB({...e}){return(0,V.jsx)(IB,{"data-slot":`collapsible-trigger`,...e})}function YB({...e}){return(0,V.jsx)(KB,{"data-slot":`collapsible-content`,...e})}function XB(e){return String(e).padStart(2,`0`)}function ZB(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,`0`)}s`}function QB(e){return e.status===`dropped`?`border border-dashed border-muted-foreground/40 text-muted-foreground line-through`:e.status===`answered`?e.answer?.sent?`bg-success text-background`:`bg-success/15 text-success`:`border-[1.5px] border-muted-foreground/40 text-muted-foreground`}function $B({question:e,attention:t=!1,pending:n=!1}){return(0,V.jsxs)(`span`,{className:B(`relative flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold tabular-nums`,QB(e)),children:[e.id.replace(/^\D+/,``),t&&(0,V.jsx)(`span`,{className:B(`absolute -top-1 -right-1 hidden size-2 rounded-full bg-primary ring-2 ring-sidebar group-data-[collapsible=icon]:block`,n&&`animate-pulse`)})]})}function eV({question:e,active:t,unread:n,onJump:r,onOpenChat:i}){let a=bA(e),o=a||n>0,s=e.chat.length>0||a;return(0,V.jsxs)(cm,{children:[(0,V.jsxs)(um,{isActive:t,tooltip:`${e.id} · ${e.title}`,onClick:r,className:`h-auto items-start py-1.5 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:p-1.5!`,children:[(0,V.jsx)($B,{question:e,attention:o,pending:a}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 group-data-[collapsible=icon]:hidden`,children:[(0,V.jsx)(`span`,{className:B(`line-clamp-2 leading-snug`,e.status===`dropped`&&`text-muted-foreground line-through`,e.status===`answered`&&`text-muted-foreground`),children:e.title}),e.status===`answered`&&(0,V.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-muted-foreground/80`,children:vA(e)})]})]}),s&&(0,V.jsxs)(dm,{onClick:i,"aria-label":`Open discussion for ${e.id}`,className:`top-1.5!`,children:[(0,V.jsx)(we,{className:B(!o&&`text-muted-foreground`)}),o&&(0,V.jsx)(`span`,{className:B(`absolute -top-0.5 -right-0.5 size-2 rounded-full bg-primary ring-2 ring-sidebar`,a&&`animate-pulse`)})]})]})}function tV({round:e,questions:t,current:n,chatFor:r,unread:i,onJump:a,onOpenChat:o,toggled:s,onToggle:c}){let l=mA(t),u=l.filter(e=>e.status===`answered`).length,d=l.length>0&&u===l.length,f=vB.round(e.number),p=n===f||e.questionIds.some(e=>n===vB.question(e)),m=s??(!d||p),h=e.title??`Round ${e.number}`;return(0,V.jsx)(qB,{open:m,onOpenChange:c,children:(0,V.jsxs)(am,{children:[(0,V.jsxs)(om,{render:(0,V.jsx)(JB,{}),className:`mb-1 gap-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:pointer-events-none`,children:[(0,V.jsx)(`span`,{className:B(`font-semibold tabular-nums`,d?`text-success`:`text-primary`),children:XB(e.number)}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:h}),(0,V.jsxs)(`span`,{className:B(`flex items-center gap-1 tabular-nums`,d&&`text-success`),children:[d&&(0,V.jsx)(oe,{className:`size-3.5`}),u,`/`,l.length]}),(0,V.jsx)(ne,{className:B(`size-3.5 transition-transform duration-200`,m&&`rotate-90`)})]}),(0,V.jsx)(`p`,{className:B(`mb-1 hidden text-center text-[10px] font-semibold tabular-nums group-data-[collapsible=icon]:block`,d?`text-success`:`text-primary`),children:XB(e.number)}),!m&&(0,V.jsx)(sm,{className:`hidden group-data-[collapsible=icon]:flex`,children:(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:`${h} · ${u}/${l.length} settled`,onClick:()=>{if(!d)return c(!0);c(void 0),a(f)},className:d?`text-success hover:text-success`:`text-primary hover:text-primary`,children:[d?(0,V.jsx)(oe,{}):(0,V.jsx)(se,{}),(0,V.jsx)(`span`,{children:h})]})})}),(0,V.jsx)(YB,{className:`h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-200 ease-out data-ending-style:h-0 data-starting-style:h-0`,children:(0,V.jsxs)(sm,{className:`gap-0.5`,children:[t.map(e=>(0,V.jsx)(eV,{question:e,active:n===vB.question(e.id)||r===e.id,unread:i(e),onJump:()=>a(vB.question(e.id)),onOpenChat:()=>o(e.id)},e.id)),d&&(0,V.jsx)(cm,{className:`animate-in fade-in-0 slide-in-from-top-1 animation-duration-200`,children:(0,V.jsxs)(um,{tooltip:`Round ${XB(e.number)} review`,isActive:n===f,onClick:()=>a(f),className:`text-primary hover:text-primary data-active:text-primary`,children:[(0,V.jsx)(Ie,{}),(0,V.jsx)(`span`,{children:`Review`})]})})]})})]})})}function nV({state:e,current:t,onJump:n,chatFor:r,unread:i,onOpenChat:a}){let{isMobile:o,setOpenMobile:s,state:c}=Xp(),[l,u]=xB(),[d,f]=(0,O.useState)({});yB();let p=e=>{n(e),o&&s(!1)};return(0,V.jsxs)(Qp,{variant:`floating`,collapsible:`icon`,"aria-label":`Rounds and questions`,children:[(0,V.jsxs)(tm,{className:`h-12 flex-row items-center border-b px-2`,children:[(0,V.jsx)(nn,{}),(0,V.jsx)(`span`,{className:`truncate text-sm font-semibold tracking-tight group-data-[collapsible=icon]:hidden`,children:`better grill`})]}),(0,V.jsxs)(im,{className:`group-data-[collapsible=icon]:overflow-x-hidden group-data-[collapsible=icon]:overflow-y-auto`,children:[e.rounds.length===0&&(0,V.jsx)(iV,{ended:e.ended}),e.rounds.map((n,o)=>(0,V.jsxs)(O.Fragment,{children:[o>0&&(0,V.jsx)(rm,{}),(0,V.jsx)(tV,{round:n,questions:hA(e,n.questionIds),current:t,chatFor:r,unread:i,onJump:p,onOpenChat:a,toggled:d[n.number],onToggle:e=>f(t=>({...t,[n.number]:e}))})]},n.number)),e.summary&&(0,V.jsx)(am,{children:(0,V.jsx)(sm,{children:(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:`Summary`,isActive:t===vB.summary,onClick:()=>p(vB.summary),className:`text-primary hover:text-primary data-active:text-primary`,children:[(0,V.jsx)(le,{}),(0,V.jsx)(`span`,{children:`Summary`})]})})})})]}),(0,V.jsx)(nm,{className:`border-t`,children:(0,V.jsxs)(sm,{className:`gap-0.5`,children:[(0,V.jsx)(rV,{state:e,onJump:p}),(0,V.jsx)(_B,{})]})}),!o&&c===`expanded`&&(0,V.jsx)(mm,{side:`left`,cssVar:`--app-sidebar-w`,width:l,min:bB.min,max:bB.max,initial:bB.initial,onResize:u,label:`Resize panel`,className:`right-0`})]})}function rV({state:e,onJump:t}){let n=mA(Object.values(e.questions));if(n.length===0)return null;let r=n.filter(e=>e.status===`answered`).length,i=r===n.length,a=n.find(e=>e.status===`open`),o=a?vB.question(a.id):e.summary?vB.summary:null;return(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:`${r}/${n.length} settled`,disabled:!o,onClick:()=>o&&t(o),"aria-label":`${r} of ${n.length} settled`,children:[(0,V.jsx)(SB,{value:r/n.length,className:i?`text-success`:`text-primary`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`truncate`,children:i?`All settled`:`Settled`}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[r,`/`,n.length]})]})]})})}function iV({ended:e}){return(0,V.jsx)(am,{children:e?(0,V.jsx)(`p`,{className:`px-2 pt-2 text-xs text-muted-foreground group-data-[collapsible=icon]:hidden`,children:`No rounds were posted.`}):(0,V.jsx)(sm,{children:[0,1,2].map(e=>(0,V.jsx)(cm,{children:(0,V.jsx)(fm,{showIcon:!0})},e))})})}function aV({hotkey:e,...t}){return e?(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)(oV,{...t})}),(0,V.jsxs)(Bu,{children:[t.active?`Close discussion`:`Discuss`,` `,(0,V.jsx)(Tm,{hotkey:e})]})]}):(0,V.jsx)(oV,{...t})}function oV({count:e,unread:t,active:n,onClick:r,compact:i=!1,...a}){let o=i&&e===0;return(0,V.jsxs)(Rr,{...a,variant:n?`secondary`:`outline`,size:o?`icon-sm`:i?`sm`:`default`,onClick:r,"aria-pressed":n,"aria-label":i?`Discuss`:void 0,className:B(`relative`,n&&`border-primary/40 bg-primary/10 text-primary hover:bg-primary/15`),children:[(0,V.jsx)(we,{"data-icon":o?void 0:`inline-start`}),!i&&`Discuss`,e>0&&(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:e}),t>0&&(0,V.jsxs)(`span`,{className:`absolute -top-1 -right-1 flex size-2.5`,children:[(0,V.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-primary opacity-60`}),(0,V.jsx)(`span`,{className:`relative inline-flex size-2.5 rounded-full bg-primary ring-2 ring-background`})]})]})}function sV({children:e}){return(0,V.jsxs)(`section`,{className:`mt-10`,children:[(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium tracking-wide text-primary uppercase`,children:[(0,V.jsx)(Me,{className:`size-3.5`}),`Also sending`]}),(0,V.jsx)(`h3`,{className:`mt-0.5 text-lg font-semibold tracking-tight`,children:`Changed from earlier rounds`})]}),(0,V.jsx)(`div`,{className:`grid gap-4`,children:e})]})}function cV({question:e}){return(0,V.jsxs)(`article`,{id:vB.question(e.id),className:`scroll-mt-20 rounded-xl border border-dashed px-5 py-4 text-muted-foreground`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,V.jsx)(Yk,{variant:`outline`,className:`font-mono text-muted-foreground`,children:e.id}),(0,V.jsx)(`span`,{className:`text-sm font-medium line-through decoration-muted-foreground/60`,children:e.title}),(0,V.jsx)(Yk,{variant:`ghost`,className:`ml-auto`,children:`Dropped`})]}),e.dropReason&&(0,V.jsx)(`p`,{className:`mt-2 text-sm italic`,children:e.dropReason})]})}function lV({children:e,className:t}){return(0,V.jsxs)(`p`,{className:B(`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,t),children:[(0,V.jsx)(Se,{className:`size-3 shrink-0`}),e]})}function uV({pending:e,label:t,pendingLabel:n}){return e?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xm,{}),n]}):(0,V.jsx)(V.Fragment,{children:t})}function dV({slot:e,children:t}){return(0,Ko.createPortal)((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute -inset-x-3 -top-24 -bottom-3 canvas [mask-image:linear-gradient(to_bottom,transparent,black_65%)]`}),(0,V.jsx)(`div`,{className:`relative flex items-center gap-2 rounded-xl border bg-popover/95 px-4 py-3 shadow-lg backdrop-blur-md sm:px-5`,children:t})]}),e)}function fV({className:e,size:t=`default`,...n}){return(0,V.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:B(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function pV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-header`,className:B(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function mV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-title`,className:B(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function hV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-description`,className:B(`text-sm text-muted-foreground`,e),...t})}function gV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-content`,className:B(`px-(--card-spacing)`,e),...t})}function _V({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-footer`,className:B(`flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)`,e),...t})}function vV(e,t){let n=window.getSelection();if(!n?.rangeCount||!n.isCollapsed)return!1;let r=n.getRangeAt(0);if(!e.contains(r.startContainer))return!1;let i=document.createRange();return i.selectNodeContents(e),t===-1?i.setEnd(r.startContainer,r.startOffset):i.setStart(r.endContainer,r.endOffset),i.toString().length===0}var yV=(e,t)=>$O(`/api/questions/${e}/answer`,t),bV=`[data-answer-item]:not(:disabled)`;function xV(e){e.focus({preventScroll:!0,focusVisible:!0}),e.scrollIntoView({block:`nearest`,behavior:`smooth`})}function SV(){let e=document.activeElement;return!!e&&e!==document.body&&!!e.closest(`input, textarea, [contenteditable=true]`)}function CV(e,t){let n=[...document.querySelectorAll(bV)],r=n[n.indexOf(e)+t];return!n.includes(e)||!r?!1:(xV(r),!0)}function wV(e){let t=e.querySelector(bV);return t&&xV(t),!!t}function TV(){if(SV())return;let e=document.querySelector(`${bV}[aria-checked=true]`);e?xV(e):wV(document)}var EV=null,DV=new Set;function OV(e){if(EV!==e){EV=e;for(let e of DV)e()}}function kV(e){return DV.add(e),()=>DV.delete(e)}function AV(e){return(0,O.useSyncExternalStore)(kV,()=>EV===e)}function jV({question:e,selected:t,disabled:n,onToggle:r}){let i=e.multiSelect;return(0,V.jsx)(`div`,{role:i?`group`:`radiogroup`,className:`grid gap-2`,children:e.options.map((a,o)=>{let s=t.includes(a.id),c=e.recommended===a.id;return(0,V.jsxs)(`button`,{type:`button`,role:i?`checkbox`:`radio`,"aria-checked":s,disabled:n,onClick:()=>r(a.id),"data-answer-item":!0,"data-option-id":a.id,className:B(`group/option flex scroll-mt-20 scroll-mb-32 items-start gap-3 rounded-lg border bg-background p-3 text-left transition-[color,background-color,border-color,box-shadow] outline-none`,`hover:bg-muted/50 focus:border-ring focus:ring-3 focus:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-60`,`dark:bg-input/20 dark:hover:bg-input/40`,s&&`border-primary bg-primary/5 ring-1 ring-primary hover:bg-primary/5 dark:bg-primary/10 dark:hover:bg-primary/10`),children:[(0,V.jsx)(`span`,{"aria-hidden":!0,className:B(`mt-0.5 flex size-5 shrink-0 items-center justify-center border text-[10px] font-medium text-muted-foreground transition-colors`,i?`rounded-md`:`rounded-full`,s?`border-primary bg-primary text-primary-foreground`:`border-input group-hover/option:border-foreground/30`),children:s?(0,V.jsx)(te,{className:`size-3`,strokeWidth:3}):String.fromCharCode(65+o)}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium`,children:a.label}),c&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Recommended`]})]}),a.description&&(0,V.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:a.description})]})]},a.id)})})}function MV({question:e,lock:t,discussing:n,unread:r,onDiscuss:i,onLockedIn:a,actionsSlot:o,extraActions:s,hidden:c=!1}){let l=t!==null,[u,d]=(0,O.useState)(e.answer?.optionIds??[]),[f,p]=(0,O.useState)(()=>NV(e)),[m,h]=(0,O.useState)(null),g=lA(yV),_=(0,O.useRef)(null),v=dA({disabled:l,onFiles:e=>_.current?.insertFiles(e),onReject:h}),y=t=>{g.clearError(),d(n=>e.multiSelect?n.includes(t)?n.filter(e=>e!==t):[...n,t]:n[0]===t?[]:[t])},b=e.answer,x=e.status===`answered`,S=(e,t=f)=>PV(e,b?.optionIds??[])&&t.text.trim()===(b?.text??``).trim()&&PV(t.images,b?.images??[])&&!t.uploading,C=x&&!S(u),w=g.pending,T=u.length>0||!f.empty,E=!l&&!w&&!f.uploading&&T&&(!x||C),D=()=>{g.clearError(),d(b?.optionIds??[]),_.current?.reset(b?.text??``,b?.images??[])},k=(0,O.useRef)(null),[A,j]=(0,O.useState)(null),M=async(t=u,n=f)=>{if(!(l||w||n.uploading||t.length===0&&n.empty)){if(x&&S(t,n)){a();return}await g.run(e.id,{optionIds:t,text:n.text.trim()||void 0,images:n.images})&&a()}},N=t=>{let n=e.multiSelect&&u.length>0?u:[t];d(n),M(n)},P=AV(e.id);Ef(pm.lockIn,e=>{e.target.closest(`input, textarea, [contenteditable=true]`)||M()},{enabled:P&&E&&!c,conflictBehavior:`allow`});let F=()=>OV(e.id),I={target:k,ignoreInputs:!1,preventDefault:!1,stopPropagation:!1},ee=(e,t)=>{let n=e.target;n.matches(`[data-answer-item]`)&&(!n.isContentEditable||vV(n,t))&&CV(n,t)&&e.preventDefault()};Ef(pm.nextAnswer,e=>ee(e,1),I),Ef(pm.previousAnswer,e=>ee(e,-1),I),Ef(pm.submitAnswer,e=>{let t=e.target;t.dataset.optionId&&(e.preventDefault(),N(t.dataset.optionId))},I);let te=e=>{let t=e.target;j(t.dataset.optionId?`option`:t.isContentEditable?`text`:null)},L=e.options.length===0?`Open answer`:e.multiSelect?`Pick any`:`Pick one`,ne=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(aV,{count:e.chat.length,unread:r,active:n,onClick:i,hotkey:pm.discuss}),s,(0,V.jsx)(`div`,{className:`flex-1`}),t?(0,V.jsx)(lV,{children:pA[t]}):A===`option`?(0,V.jsxs)(FV,{children:[(0,V.jsx)(Tm,{hotkey:pm.previousAnswer}),(0,V.jsx)(Tm,{hotkey:pm.nextAnswer}),` move`,(0,V.jsx)(Tm,{hotkey:pm.submitAnswer,className:`ml-1.5`}),` lock in`]}):A===`text`?(0,V.jsxs)(FV,{children:[(0,V.jsx)(Tm,{hotkey:pm.submitAnswer}),` lock in`,(0,V.jsx)(Tm,{hotkey:pm.newLine,className:`ml-1.5`}),` new line`]}):P&&T?(0,V.jsxs)(FV,{children:[(0,V.jsx)(Tm,{hotkey:pm.lockIn}),` lock in`]}):(0,V.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:e.options.length>0?`Pick, type or drop an image`:`Type an answer or drop an image`}),C&&(0,V.jsx)(Rr,{variant:`ghost`,disabled:w,onClick:D,children:`Discard changes`}),(0,V.jsx)(Rr,{disabled:!E,onClick:()=>void M(),children:(0,V.jsx)(uV,{pending:w,pendingLabel:`Locking in…`,label:x?`Update answer`:`Lock in`})})]}),re=(0,V.jsxs)(fV,{ref:k,id:vB.question(e.id),"data-question-editor":!0,onPointerDownCapture:F,onFocusCapture:e=>{F(),te(e)},onBlurCapture:e=>{k.current?.contains(e.relatedTarget)||j(null)},...v.dropZone,className:B(`relative scroll-mt-20 gap-5 pt-5 shadow-xs transition-shadow`,n?`ring-1 ring-primary/45`:`hover:shadow-sm`),children:[(0,V.jsx)(Em,{show:v.dragging}),(0,V.jsxs)(pV,{className:`grid-cols-1 gap-2 px-5 sm:px-6`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(Yk,{className:`font-mono`,children:e.id}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:L}),e.editedAt&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Edited by Claude`]}),x&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-success/10 text-success`,children:[(0,V.jsx)(oe,{"data-icon":`inline-start`}),b?.sent?`Sent to Claude`:`Locked in`]}),b?.by===`claude`&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Resolved in discussion by Claude`]})]}),(0,V.jsx)(mV,{className:`text-xl font-semibold tracking-tight text-balance`,children:e.title}),e.body&&(0,V.jsx)(hV,{children:(0,V.jsx)(dB,{children:e.body})})]}),(0,V.jsxs)(gV,{className:`grid grid-cols-1 gap-4 px-5 sm:px-6`,children:[e.options.length>0&&(0,V.jsx)(jV,{question:e,selected:u,disabled:l||w,onToggle:y}),e.recommendation&&(0,V.jsxs)(Of,{className:`border-primary/20 bg-primary/5`,children:[(0,V.jsx)(He,{className:`text-primary`}),(0,V.jsx)(kf,{className:`text-primary`,children:`Claude's pick`}),(0,V.jsx)(Af,{className:`text-foreground/80`,children:(0,V.jsx)(dB,{children:e.recommendation})})]}),(0,V.jsx)(iA,{className:`h-auto`,children:(0,V.jsx)(zk,{ref:_,initialText:b?.text,initialImages:b?.images,disabled:l||w,invalid:!!g.error,editableProps:{"data-answer-item":!(l||w)||void 0},onChange:e=>{e.text!==f.text&&g.clearError(),p(e)},onSubmit:e=>void M(u,e),onError:h,placeholder:e.options.length===0?`Your answer… (paste or drop images)`:u.length>0?`Add a note to your pick (optional)…`:`Or write your own answer…`,className:`max-h-80 min-h-20 scroll-mt-20 scroll-mb-32`})}),m&&(0,V.jsx)(Sm,{message:m,onDismiss:()=>h(null)}),g.error&&(0,V.jsx)(Sm,{message:g.error,onRetry:()=>void M(),onDismiss:g.clearError})]})]});return o?(0,V.jsxs)(V.Fragment,{children:[re,(0,V.jsx)(dV,{slot:o,children:ne})]}):re}function NV(e){let t=e.answer?.text??``,n=e.answer?.images??[];return{text:t,images:n,uploading:!1,empty:!t.trim()&&n.length===0}}function PV(e,t){return e.length===t.length&&e.every(e=>t.includes(e))}function FV({children:e}){return(0,V.jsx)(`span`,{className:`hidden items-center gap-1 text-xs text-muted-foreground sm:inline-flex`,children:e})}function IV(e){let{question:t}=e;return t.status===`dropped`?(0,V.jsx)(cV,{question:t}):(0,V.jsx)(MV,{...e},t.answer?.at??`open`)}function LV({question:e,discussing:t,unread:n,onDiscuss:r,onOpen:i}){if(e.status===`dropped`)return(0,V.jsx)(cV,{question:e});let a=e.answer,o=_A(e),s=e.status===`open`,c=!!a?.sent,l=s?`Not answered yet`:c?`Sent to Claude`:`Locked in, not sent yet`;return(0,V.jsx)(fV,{id:vB.question(e.id),size:`sm`,className:B(`scroll-mt-20 px-4 transition-shadow`,t&&`ring-1 ring-primary/45`),children:(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)(`span`,{}),className:B(`mt-0.5 shrink-0`,s?`text-muted-foreground`:`text-success`),"aria-label":l,children:s?(0,V.jsx)(se,{className:`size-5`}):c?(0,V.jsx)(oe,{className:`size-5 fill-success text-background`}):(0,V.jsx)(oe,{className:`size-5`})}),(0,V.jsx)(Bu,{children:l})]}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id}),(0,V.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:e.title})]}),s&&(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground italic`,children:`Not answered yet`}),a?.by===`claude`&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`mt-1.5 bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Resolved in discussion by Claude · change it if that's wrong`]}),o.length>0&&(0,V.jsx)(`p`,{className:`mt-1 text-sm font-semibold`,children:o.join(` + `)}),a?.text&&(a.by===`claude`?(0,V.jsx)(dB,{className:`mt-1 text-sm`,children:a.text}):(0,V.jsx)(`p`,{className:`mt-1 text-sm whitespace-pre-wrap text-muted-foreground italic`,children:(0,V.jsx)(SA,{text:a.text,images:a.images})}))]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,V.jsx)(aV,{count:e.chat.length,unread:n,active:t,onClick:r,compact:!0}),(0,V.jsxs)(Rr,{variant:`ghost`,size:`sm`,onClick:i,children:[!s&&(0,V.jsx)(Ae,{"data-icon":`inline-start`}),s?`Answer`:`Change`]})]})]})})}function RV({questions:e}){let t=mA(e),n=t.filter(e=>e.status===`answered`);return t.length===0?null:n.length===t.length&&n.every(e=>e.answer?.sent)?(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-success/10 text-success`,children:[(0,V.jsx)(Re,{"data-icon":`inline-start`}),`Sent to Claude`]}):(0,V.jsx)(Yk,{variant:`outline`,className:`text-muted-foreground tabular-nums`,children:(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`span`,{className:`text-foreground`,children:n.length}),`/`,t.length,` locked in`]})})}function zV({round:e,questions:t,review:n=!1,children:r}){return(0,V.jsxs)(`section`,{id:vB.round(e.number),className:`scroll-mt-20`,children:[(0,V.jsxs)(`div`,{className:`mb-4 flex items-end gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`p`,{className:`text-xs font-medium tracking-wide text-primary uppercase`,children:[`Round `,XB(e.number),n&&` · Review`]}),(0,V.jsx)(`h2`,{className:`mt-0.5 truncate text-2xl font-semibold tracking-tight`,children:e.title??`Round ${e.number}`})]}),(0,V.jsx)(RV,{questions:t})]}),(0,V.jsx)(`div`,{className:`grid gap-4`,children:r})]})}var BV=()=>$O(`/api/send`,{});function VV(e,t){let n=lA(BV),r=mA(Object.values(e.questions)),i=r.filter(e=>e.status===`open`),a=r.filter(e=>e.status===`answered`&&!e.answer?.sent);return{open:i,unsent:a,changes:gA(e).length,ready:!e.ended&&i.length===0&&a.length>0&&!t&&!n.pending,idle:i.length===0&&a.length===0,action:n,send:()=>void n.run()}}function HV(e=1e3){let[t,n]=(0,O.useState)(()=>Date.now());return(0,O.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function UV({since:e,lock:t}){let n=HV()-e;return(0,V.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`mb-12 animate-in fade-in-0 slide-in-from-bottom-1 animation-duration-300`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-dashed px-4 py-3 font-mono text-xs`,children:[(0,V.jsx)(Ak,{className:`size-4 text-primary`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:[`Claude is working through your answers`,(0,V.jsx)(`span`,{className:`ml-1 inline-block h-3 w-1.5 translate-y-0.5 bg-primary motion-safe:animate-blink`})]}),(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:ZB(n)})]}),t===`offline`&&(0,V.jsx)(lV,{className:`mt-2 px-1 text-destructive`,children:`Bridge unreachable. The next round shows up once it reconnects.`}),!t&&n>=12e4&&(0,V.jsx)(lV,{className:`mt-2 px-1`,children:`Taking a while. Claude may be researching facts with sub-agents. The terminal shows what it is doing.`})]})}function WV({state:e,lock:t,onJump:n,showBar:r}){let{open:i,unsent:a,changes:o,ready:s,idle:c,action:l,send:u}=VV(e,t),d=l.pending,f=(0,O.useRef)(null);return(0,O.useEffect)(()=>{s&&document.activeElement===document.body&&f.current?.focus({preventScroll:!0})},[s]),e.ended?null:c?e.awaitingSince?(0,V.jsx)(UV,{since:e.awaitingSince,lock:t}):null:r?(0,V.jsx)(`div`,{className:`mb-12`,children:(0,V.jsxs)(`div`,{className:B(`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-xl border bg-popover/95 px-4 py-3 shadow-lg backdrop-blur-md transition-[border-color,box-shadow] sm:px-5`,s&&`border-primary/50 shadow-primary/15 ring-4 ring-primary/10`),children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,V.jsx)(se,{className:`size-4 text-primary`}),(0,V.jsx)(`span`,{className:`tabular-nums`,children:i.length}),` still open`]}),(0,V.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:i.map(e=>(0,V.jsx)(Yk,{variant:`outline`,className:`font-mono text-muted-foreground hover:bg-muted hover:text-foreground`,render:(0,V.jsx)(`button`,{type:`button`,onClick:()=>n(vB.question(e.id))}),children:e.id},e.id))})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-sm font-semibold`,children:`All locked in.`}),(0,V.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[a.length,` `,a.length===1?`answer`:`answers`,o>0&&` · ${o} changed from earlier rounds`,` · you can still change anything`]})]}),t&&(0,V.jsx)(lV,{className:`mt-1.5`,children:pA[t]}),l.error&&(0,V.jsx)(Sm,{className:`mt-2`,message:l.error,onRetry:u,onDismiss:l.clearError})]}),(0,V.jsxs)(Rr,{ref:f,size:`lg`,disabled:!s,onClick:u,className:`px-4`,children:[!d&&(0,V.jsx)(Re,{"data-icon":`inline-start`}),(0,V.jsx)(uV,{pending:d,pendingLabel:`Sending…`,label:`Send to Claude`})]})]})}):null}function GV({state:e,lock:t,onJump:n}){let{open:r,unsent:i,ready:a,idle:o,action:s,send:c}=VV(e,t);if(e.ended||o)return null;let l=r[0],u=s.error??(t?pA[t]:l?`Next open: ${l.id}`:`${i.length} locked in, ready to send`);return(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:l?(0,V.jsx)(Rr,{variant:`outline`,size:`sm`,onClick:()=>n(vB.question(l.id))}):(0,V.jsx)(Rr,{size:`sm`,disabled:!a,onClick:c,className:B(s.error&&`ring-2 ring-destructive/50`)}),children:l?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(se,{"data-icon":`inline-start`,className:`text-primary`}),(0,V.jsx)(`span`,{className:`tabular-nums`,children:r.length}),` open`]}):(0,V.jsxs)(V.Fragment,{children:[!s.pending&&(0,V.jsx)(Re,{"data-icon":`inline-start`}),(0,V.jsx)(uV,{pending:s.pending,pendingLabel:`Sending…`,label:`Send ${i.length}`})]})}),(0,V.jsx)(Bu,{side:`bottom`,children:u})]})}function KV(){let[e,t]=(0,O.useState)(null),[n,r]=(0,O.useState)(()=>({status:`connecting`,since:Date.now(),attempts:0,everOpened:!1})),i=(0,O.useRef)(!1);return(0,O.useEffect)(()=>{let e=null,n,a=0,o=!1,s=()=>{e=new EventSource(`/api/stream`),e.onopen=()=>{a=0,r({status:`open`,since:Date.now(),attempts:0,everOpened:!0})},e.onmessage=e=>{try{let n=JSON.parse(e.data);i.current=n.ended,t(n)}catch(e){console.error(`Bad frame from bridge`,e)}},e.onerror=()=>{if(e?.close(),!o){if(i.current){r(e=>({...e,status:`closed`,since:Date.now()}));return}a+=1,r(e=>({status:`reconnecting`,since:e.status===`reconnecting`?e.since:Date.now(),attempts:a,everOpened:e.everOpened})),n=setTimeout(s,Uu[Math.min(a-1,Uu.length-1)])}}};return s(),()=>{o=!0,clearTimeout(n),e?.close()}},[]),{state:e,connection:n}}var qV=3,JV=300,YV=34,XV=2*Math.PI*YV;function ZV({title:e}){let[t,n]=(0,O.useState)(qV),[r,i]=(0,O.useState)(!1),a=(0,O.useRef)(null),o=()=>{window.close(),setTimeout(()=>i(!0),300)};return(0,O.useEffect)(()=>{let e=a.current?.animate([{strokeDashoffset:0},{strokeDashoffset:XV}],{duration:qV*1e3,easing:`linear`,fill:`forwards`});return()=>e?.cancel()},[]),(0,O.useEffect)(()=>{let e=t>0?setTimeout(()=>n(e=>e-1),1e3):setTimeout(o,JV);return()=>clearTimeout(e)},[t]),(0,V.jsx)(`div`,{className:`fixed inset-0 z-[90] grid place-items-center bg-background/95 backdrop-blur-md animate-in fade-in-0`,children:(0,V.jsxs)(`div`,{className:`px-4 text-center`,children:[(0,V.jsxs)(`div`,{className:`relative mx-auto size-20`,children:[(0,V.jsxs)(`svg`,{viewBox:`0 0 80 80`,className:`size-20 -rotate-90`,"aria-hidden":!0,children:[(0,V.jsx)(`circle`,{cx:`40`,cy:`40`,r:YV,fill:`none`,stroke:`var(--border)`,strokeWidth:`4`}),(0,V.jsx)(`circle`,{ref:a,cx:`40`,cy:`40`,r:YV,fill:`none`,stroke:`var(--primary)`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:XV})]}),(0,V.jsx)(`span`,{className:`absolute inset-0 grid place-items-center text-2xl font-semibold tabular-nums`,children:r?(0,V.jsx)(te,{className:`size-7 text-success`}):t})]}),(0,V.jsx)(`h2`,{className:`mt-6 text-3xl font-semibold tracking-tight`,children:e}),(0,V.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:r?`Your browser kept this tab open. Close it whenever you like.`:`Back to your terminal. This tab closes in ${t}s.`}),!r&&(0,V.jsx)(Rr,{variant:`ghost`,size:`sm`,className:`mt-4 text-muted-foreground`,onClick:o,children:`Close now`})]})})}function QV({state:e,connection:t}){let[n,r]=(0,O.useState)(!1),i=(0,O.useRef)(t.status);if((0,O.useEffect)(()=>{let e=i.current;if(i.current=t.status,e===`reconnecting`&&t.status===`open`){r(!0);let e=setTimeout(()=>r(!1),2500);return()=>clearTimeout(e)}},[t.status]),e.ended){let t=e.summary?.status===`confirmed`;return(0,V.jsxs)(eH,{tone:`muted`,children:[(0,V.jsx)(ve,{className:`size-3.5`}),t?`Summary confirmed. Claude takes it from here in the terminal.`:`Session closed. Back to your terminal.`]})}if(t.status===`reconnecting`){let e=t.attempts>=6;return(0,V.jsxs)(eH,{tone:`alert`,children:[(0,V.jsx)(xm,{className:`text-sm`}),(0,V.jsx)(`span`,{children:e?(0,V.jsxs)(V.Fragment,{children:[`The bridge has been gone for a while. If its Claude Code session was closed, run`,` `,(0,V.jsx)(`code`,{className:`font-mono font-medium`,children:`/better-grill`}),` again. Still retrying.`]}):(0,V.jsxs)(V.Fragment,{children:[`Lost the bridge. Reconnecting`,t.attempts>1?` (attempt ${t.attempts})`:``,`… Everything you locked in is kept in the bridge.`]})}),(0,V.jsx)(Rr,{variant:`link`,size:`xs`,className:`h-auto px-0 text-current`,onClick:()=>window.location.reload(),children:`Reload`})]})}return n?(0,V.jsxs)(eH,{tone:`ok`,children:[(0,V.jsx)(te,{className:`size-3.5`}),`Reconnected. You're up to date.`]}):null}var $V={muted:`bg-muted/80 text-muted-foreground`,alert:`bg-destructive/10 text-destructive`,ok:`bg-success/10 text-success`};function eH({tone:e,children:t}){return(0,V.jsx)(`div`,{role:e===`alert`?`alert`:`status`,className:B(`flex items-center justify-center gap-2 rounded-lg border px-4 py-2 text-center text-xs font-medium shadow-sm backdrop-blur-md animate-in fade-in-0 slide-in-from-top-1`,$V[e]),children:t})}function tH(e){return Mp(`alert-dialog`,e)}function nH({...e}){return(0,V.jsx)(tH,{"data-slot":`alert-dialog`,...e})}function rH({...e}){return(0,V.jsx)(hp,{"data-slot":`alert-dialog-portal`,...e})}function iH({className:e,...t}){return(0,V.jsx)(ip,{"data-slot":`alert-dialog-overlay`,className:B(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function aH({className:e,size:t=`default`,...n}){return(0,V.jsxs)(rH,{children:[(0,V.jsx)(iH,{}),(0,V.jsx)(pp,{"data-slot":`alert-dialog-content`,"data-size":t,className:B(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function oH({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:B(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function sH({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:B(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function cH({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`alert-dialog-media`,className:B(`mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6`,e),...t})}function lH({className:e,...t}){return(0,V.jsx)(Pp,{"data-slot":`alert-dialog-title`,className:B(`font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function uH({className:e,...t}){return(0,V.jsx)(op,{"data-slot":`alert-dialog-description`,className:B(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function dH({className:e,...t}){return(0,V.jsx)(Rr,{"data-slot":`alert-dialog-action`,className:B(e),...t})}function fH({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,V.jsx)(ap,{"data-slot":`alert-dialog-cancel`,className:B(e),render:(0,V.jsx)(Rr,{variant:t,size:n}),...r})}var pH=()=>$O(`/api/end`,{});function mH({open:e,unsent:t,openCount:n,onCancel:r,onEnded:i}){let a=lA(pH),o=a.pending,s=async()=>{await a.run()&&i()};return(0,V.jsx)(nH,{open:e,onOpenChange:e=>{!e&&!o&&r()},onOpenChangeComplete:e=>{e&&a.clearError()},children:(0,V.jsxs)(aH,{children:[(0,V.jsxs)(oH,{children:[(0,V.jsx)(cH,{className:`bg-destructive/10 text-destructive`,children:(0,V.jsx)(fe,{})}),(0,V.jsx)(lH,{children:`Stop the grill here?`}),(0,V.jsx)(uH,{children:`Claude gets everything you have locked in and wraps up in the terminal. This tab closes itself afterwards.`})]}),(t>0||n>0)&&(0,V.jsxs)(`ul`,{className:`space-y-1 rounded-lg bg-muted/60 px-3 py-2 text-sm text-muted-foreground`,children:[t>0&&(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground tabular-nums`,children:t}),` locked-in`,` `,t===1?`answer`:`answers`,` not sent yet, will be sent`]}),n>0&&(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground tabular-nums`,children:n}),` `,n===1?`question`:`questions`,` still open, will stay unanswered`]})]}),a.error&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(Sm,{message:a.error,onRetry:()=>void s()}),(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`If the bridge is gone, there is nothing left to end.`,` `,(0,V.jsx)(Rr,{variant:`link`,className:`h-auto p-0`,onClick:i,children:`Close this tab anyway`})]})]}),(0,V.jsxs)(sH,{children:[(0,V.jsx)(fH,{disabled:o,children:`Keep grilling`}),(0,V.jsx)(dH,{variant:`destructive`,disabled:o,onClick:()=>void s(),children:(0,V.jsx)(uV,{pending:o,pendingLabel:`Ending…`,label:`End session`})})]})]})})}var hH=[{stage:`connecting`,active:`Connecting to your session`,done:`Connected to your session`},{stage:`reading`,active:`Claude is reading your request`}],gH={connecting:performance.timeOrigin},_H=``;function vH(e,t){if(_H!==`${e}:${t}`){_H=`${e}:${t}`;try{let t=JSON.parse(localStorage.getItem(Vu.warmUp)??`null`);if(t?.session===e)for(let[e,n]of Object.entries(t.reached))gH[e]=Math.min(gH[e]??n,n);localStorage.setItem(Vu.warmUp,JSON.stringify({session:e,reached:gH}))}catch{}}}var yH=[`M4.5 14Q6.7 11.8 8.7 13.1V17H4.5Z`,`M9.3 13.1Q12 11.1 14.7 13.1V17H9.3Z`,`M15.3 13.1Q17.3 11.8 19.5 14V17H15.3Z`],bH=`M4.5 11a7.5 5.5 0 0 0 15 0Z`,xH=[[34,-10,2.6,0],[46,8,2.2,.7],[58,-6,2.9,1.3],[66,12,2.4,.3],[40,14,3.1,1.9],[52,-14,2.7,2.4],[30,6,2.3,1.6],[62,-10,3.3,.9]],SH=900,CH=!1;function wH({stage:e,session:t,className:n}){let[r]=(0,O.useState)(()=>!CH),[i,a]=(0,O.useState)(CH);(0,O.useEffect)(()=>{if(CH=!0,i)return;let e=setTimeout(()=>a(!0),SH);return()=>clearTimeout(e)},[i]),gH[e]??=Date.now(),t!==void 0&&vH(t,e);let o=hH.findIndex(t=>t.stage===e);return(0,V.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:B(`flex w-full flex-col items-center text-center`,r&&`animate-in fill-mode-both fade-in-0 zoom-in-95 animation-duration-700`,n),children:[(0,V.jsxs)(`div`,{className:`relative size-40`,children:[(0,V.jsx)(`div`,{"aria-hidden":!0,className:B(`absolute -inset-8 transition-opacity duration-1000`,i?`opacity-100`:`opacity-0`),children:(0,V.jsx)(`div`,{className:`size-full bg-[radial-gradient(closest-side,color-mix(in_oklab,var(--primary)_28%,transparent),transparent)] motion-safe:animate-glow`})}),(0,V.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-x-0 top-[18%] h-[30%] motion-reduce:hidden`,children:i&&xH.map(([e,t,n,r])=>(0,V.jsx)(`span`,{className:`absolute bottom-0 size-1 rounded-full bg-primary animate-ember`,style:{left:`${e}%`,"--ember-drift":`${t}px`,animationDuration:`${n}s`,animationDelay:`${r}s`}},e))}),(0,V.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,className:`absolute inset-0 size-full overflow-visible`,children:[(0,V.jsx)(`clipPath`,{id:`warm-up-bowl`,children:(0,V.jsx)(`path`,{d:bH})}),(0,V.jsx)(`g`,{clipPath:`url(#warm-up-bowl)`,children:yH.map((e,t)=>(0,V.jsx)(`path`,{d:e,className:`fill-primary`,style:{transformBox:`fill-box`,transformOrigin:`bottom`,animation:[r&&`ignite 500ms ease-out ${150+t*200}ms both`,`flicker ${2+t*.4}s ease-in-out ${r?700+t*200:0}ms infinite`].filter(Boolean).join(`, `)}},e))})]}),(0,V.jsx)(tn,{hot:i,strokeWidth:1.1,className:`absolute inset-0 size-full text-foreground`})]}),(0,V.jsx)(`h2`,{className:`mt-2 text-xl font-semibold tracking-tight`,children:`Firing up the grill`}),(0,V.jsxs)(`div`,{className:`mt-6 w-full max-w-md overflow-hidden rounded-xl border bg-card text-left shadow-sm`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b bg-muted/40 px-3 py-2`,children:[[0,1,2].map(e=>(0,V.jsx)(`span`,{className:`size-2 rounded-full bg-border`},e)),(0,V.jsx)(`span`,{className:`ml-2 font-mono text-[11px] text-muted-foreground`,children:`better-grill`})]}),(0,V.jsx)(`ol`,{className:`min-h-[4.375rem] space-y-1.5 px-3.5 py-3 font-mono text-xs`,children:hH.slice(0,o+1).map(({stage:e,...t},n)=>{let r=gH[e];if(r===void 0)return null;let i=hH.slice(n+1,o+1).find(e=>gH[e.stage]!==void 0),a=i&&gH[i.stage];return(0,V.jsxs)(`li`,{className:`flex min-h-5 items-center gap-3 animate-in fill-mode-both fade-in-0 slide-in-from-bottom-1 animation-duration-300`,children:[(0,V.jsx)(`time`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:EH(r)}),a===void 0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ak,{className:`size-3 text-primary`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:[t.active,(0,V.jsx)(`span`,{className:`ml-1 inline-block h-3 w-1.5 translate-y-0.5 bg-primary motion-safe:animate-blink`})]}),(0,V.jsx)(TH,{since:r})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(te,{className:`size-3 shrink-0 text-success`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:t.done}),(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:ZB(a-r)})]})]},e)})})]})]})}function TH({since:e}){let t=HV();return(0,V.jsx)(Yk,{variant:`outline`,className:`text-muted-foreground tabular-nums`,children:ZB(t-e)})}var EH=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function DH(){return(0,V.jsxs)(`div`,{className:`flex min-h-svh`,"aria-busy":!0,children:[(0,V.jsx)(`div`,{className:`hidden w-80 shrink-0 p-3 md:flex`,children:(0,V.jsxs)(`aside`,{className:`flex flex-1 flex-col rounded-xl bg-sidebar shadow-md ring-1 ring-sidebar-border`,children:[(0,V.jsxs)(`div`,{className:`flex h-12 items-center gap-2 border-b px-2`,children:[(0,V.jsx)(nn,{}),(0,V.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`better grill`})]}),(0,V.jsx)(`div`,{className:`p-2`,children:[0,1,2].map(e=>(0,V.jsx)(fm,{showIcon:!0},e))})]})}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col pt-3 pr-3`,children:[(0,V.jsx)(`header`,{className:`h-12 shrink-0 rounded-xl border bg-background/80 shadow-md`}),(0,V.jsx)(`main`,{className:`grid flex-1 place-items-center px-4 pt-8 pb-[16svh]`,children:(0,V.jsx)(wH,{stage:`connecting`})})]})]})}function OH({state:e}){return(0,V.jsx)(wH,{stage:`reading`,session:e.startedAt})}function kH(){return(0,V.jsx)(Xk,{className:`animate-in fade-in-0 animation-duration-500`,children:(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{variant:`icon`,className:`size-10`,children:(0,V.jsx)(ge,{className:`size-5`})}),(0,V.jsx)(eA,{className:`text-base`,children:`No questions this time`}),(0,V.jsxs)(tA,{children:[`Run `,(0,V.jsx)(`code`,{className:`font-mono whitespace-nowrap text-foreground`,children:`/better-grill`}),` to start again.`]})]})})}function AH(e,t){return e.ended?{label:`Session closed`,dot:`bg-muted-foreground/50`}:t.status===`reconnecting`?{label:`Reconnecting`,dot:`bg-destructive`,ping:!0}:e.claude===`listening`?{label:`Claude listening`,dot:`bg-success`,ping:!0}:{label:`Claude thinking`,dot:`bg-primary animate-pulse`}}function jH({state:e,connection:t}){let{label:n,dot:r,ping:i}=AH(e,t);return(0,V.jsxs)(Yk,{variant:`outline`,className:`h-6 gap-2 px-2.5 text-muted-foreground`,children:[(0,V.jsxs)(`span`,{className:`relative flex size-2`,children:[i&&(0,V.jsx)(`span`,{className:B(`absolute inline-flex size-full animate-ping rounded-full opacity-60`,r)}),(0,V.jsx)(`span`,{className:B(`relative inline-flex size-2 rounded-full`,r)})]}),n]})}function MH({state:e,connection:t,onEnd:n,actions:r}){return(0,V.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 rounded-xl border bg-background/80 px-3 shadow-md backdrop-blur-md supports-backdrop-filter:bg-background/60`,children:[(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)($p,{})}),(0,V.jsxs)(Bu,{side:`bottom`,children:[`Toggle panel `,(0,V.jsx)(Tm,{hotkey:pm.toggleSidebar})]})]}),(0,V.jsx)(tp,{orientation:`vertical`,className:`h-4 data-vertical:self-center`}),(0,V.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-medium`,children:e.title}),e.mode===`docs`&&(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsxs)(Yk,{variant:`outline`,className:`hidden text-muted-foreground sm:inline-flex`,children:[(0,V.jsx)(I,{"data-icon":`inline-start`}),`With docs`]})}),(0,V.jsx)(Bu,{side:`bottom`,children:`Claude records the glossary and ADRs as decisions settle`})]}),(0,V.jsx)(`div`,{className:`flex-1`}),(0,V.jsx)(jH,{state:e,connection:t}),!e.ended&&(0,V.jsxs)(Rr,{variant:`outline`,size:`sm`,onClick:n,children:[(0,V.jsx)(fe,{"data-icon":`inline-start`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`End session`})]}),r]})}function NH({connection:e}){return(0,V.jsx)(`div`,{className:`grid min-h-svh place-items-center bg-background px-4`,children:(0,V.jsxs)(Xk,{className:`animate-in fade-in-0 animation-duration-300`,children:[(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{className:`size-10 rounded-lg bg-destructive/10 text-destructive`,children:(0,V.jsx)(Xe,{className:`size-5`})}),(0,V.jsx)(eA,{className:`text-base`,children:`Can't reach this session`}),(0,V.jsxs)(tA,{children:[`It has probably ended. Run `,(0,V.jsx)(`code`,{className:`font-mono whitespace-nowrap text-foreground`,children:`/better-grill`}),` to start a new one.`]})]}),(0,V.jsxs)(nA,{children:[(0,V.jsxs)(Rr,{onClick:()=>window.location.reload(),children:[(0,V.jsx)(Pe,{"data-icon":`inline-start`}),`Retry`]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retrying automatically · attempt `,e.attempts]})]})]})})}function PH(e){let t=e.rounds.flatMap(t=>[...t.questionIds.filter(t=>e.questions[t]).map(e=>({key:vB.question(e),kind:`question`,id:e,round:t.number})),{key:vB.round(t.number),kind:`review`,round:t.number}]);return e.summary&&t.push({key:vB.summary,kind:`summary`}),t}var FH=e=>e.kind===`question`,IH=e=>t=>e.questions[t.id]?.status===`open`;function LH(e,t){return t.filter(FH).find(IH(e))??t.find(e=>e.kind===`summary`)??t.at(-1)}function RH(e,t,n){let r=t.filter(e=>e.kind!==`summary`&&e.round===n);return r.filter(FH).find(IH(e))??r.find(e=>e.kind===`review`)}function zH(e,t,n){let r=t.filter(FH),i=r.findIndex(e=>e.id===n),a=[...r.slice(i+1),...r.slice(0,Math.max(i,0))],o=r[i]?.round;return a.find(IH(e))??t.find(e=>e.kind===`review`&&e.round===o)}function BH(e){let[t,n]=(0,O.useState)(null),[r,i]=(0,O.useState)(null),a=e?PH(e):[],o=e?.rounds.length??0,s=!!e?.summary;if(e&&(r?.rounds!==o||r.summary!==s)){i({rounds:o,summary:s});let t=r?s&&!r.summary?a.find(e=>e.key===vB.summary):o>r.rounds?RH(e,a,o):void 0:LH(e,a);t&&n(t.key)}return{current:a.find(e=>e.key===t)??(e?LH(e,a):void 0),go:n,lockedIn:(0,O.useCallback)(t=>{if(!e)return;let r=zH(e,PH(e),t);n(e=>r&&(e===null||e===vB.question(t))?r.key:e)},[e])}}var VH=(e,t)=>$O(`/api/summary/respond`,{confirmed:e,text:t});function HH({summary:e,lock:t,onConfirmed:n}){let[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(null),l=lA(VH),u=l.pending,d=async e=>{c(e),await l.run(e,e?void 0:a.trim()||void 0)&&(i(!1),o(``),e&&n())},f=e.status===`pending`&&!t;return(0,V.jsxs)(fV,{id:vB.summary,className:`scroll-mt-20 gap-5 pt-5 ring-primary/30 animate-in fade-in-0 slide-in-from-bottom-2 animation-duration-500`,children:[(0,V.jsxs)(pV,{className:`px-5 sm:px-6`,children:[(0,V.jsx)(`div`,{className:`mb-2 flex size-10 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,V.jsx)(le,{className:`size-5`})}),(0,V.jsx)(hV,{className:`font-medium text-primary`,children:`Shared understanding?`}),(0,V.jsx)(mV,{className:`text-2xl font-semibold tracking-tight`,children:`Here is what we settled`})]}),(0,V.jsxs)(gV,{className:`space-y-4 px-5 sm:px-6`,children:[(0,V.jsx)(dB,{className:`text-sm`,children:e.markdown}),e.status===`confirmed`&&(0,V.jsxs)(Of,{className:`border-success/30 bg-success/5 text-success`,children:[(0,V.jsx)(te,{}),(0,V.jsx)(Af,{className:`text-success`,children:`Confirmed. Claude takes it from here.`})]}),e.status===`rejected`&&(0,V.jsxs)(Of,{children:[(0,V.jsx)(Je,{}),(0,V.jsxs)(Af,{children:[`Sent back to Claude`,e.feedback?`: “${e.feedback}”`:`.`]})]}),e.status===`pending`&&t&&(0,V.jsxs)(lV,{children:[pA[t],` The summary can't be answered now.`]}),f&&r&&(0,V.jsx)(rA,{value:a,disabled:u,onChange:e=>{l.clearError(),o(e.target.value)},autoFocus:!0,rows:3,placeholder:`What is missing or wrong?`}),f&&l.error&&(0,V.jsx)(Sm,{message:l.error,onRetry:s===null?void 0:()=>void d(s),onDismiss:l.clearError})]}),f&&(0,V.jsx)(_V,{className:`flex-wrap gap-2 px-5 sm:px-6`,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Rr,{disabled:u||!a.trim(),onClick:()=>void d(!1),children:(0,V.jsx)(uV,{pending:u,pendingLabel:`Sending back…`,label:`Send back to Claude`})}),(0,V.jsx)(Rr,{variant:`ghost`,disabled:u,onClick:()=>i(!1),children:`Cancel`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(Rr,{disabled:u,onClick:()=>void d(!0),children:[!u&&(0,V.jsx)(te,{"data-icon":`inline-start`}),(0,V.jsx)(uV,{pending:u,pendingLabel:`Confirming…`,label:`Yes, that's it`})]}),(0,V.jsx)(Rr,{variant:`outline`,disabled:u,onClick:()=>i(!0),children:`Not yet`})]})})]})}var UH=(e,t)=>$O(`/api/questions/${e}/visualize`,t),WH=new Map;function GH(e,t){let n=`${e}@${t}`,r=WH.get(n);return r||(r=ek(`/api/questions/${e}/visualization`),r.catch(()=>WH.delete(n)),WH.set(n,r)),r}function KH(e,t){let[n,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(null),[o,s]=(0,O.useState)(0);return(0,O.useEffect)(()=>{if(t===0)return;let n=!0;return a(null),GH(e,t).then(e=>n&&r(e.html),e=>n&&a(e instanceof Error?e.message:String(e))),()=>{n=!1}},[e,t,o]),{html:t===0?null:n,error:i,retry:()=>s(e=>e+1)}}var qH=`better-grill:size`,JH=2e4,YH=[`default-src 'none'`,`script-src 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net`,`style-src 'unsafe-inline'`,`img-src data: blob:`,`media-src data: blob:`,`font-src data:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'none'`].join(`; `),XH={"--background":`--card`,"--foreground":`--card-foreground`,"--card":`--popover`,"--muted":`--muted`,"--muted-foreground":`--muted-foreground`,"--border":`--border`,"--primary":`--primary`,"--primary-foreground":`--primary-foreground`,"--success":`--success`,"--destructive":`--destructive`,"--series-1":`--series-1`,"--series-2":`--series-2`,"--series-3":`--series-3`,"--series-4":`--series-4`,"--series-5":`--series-5`,"--radius":`--radius`},ZH=`--font-sans: "Geist Variable", ui-sans-serif, system-ui, sans-serif; --font-mono: "Geist Mono Variable", ui-monospace, monospace;`,QH=`(() => {
50
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return tR(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=QR.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function cz(){return{exit:{taskListCheckValueChecked:uz,taskListCheckValueUnchecked:uz,paragraph:dz}}}function lz(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:fz}}}function uz(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function dz(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function fz(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=QR.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function pz(){return[yL(),UL(),JL(),$R(),cz()]}function mz(e){return{extensions:[bL(),WL(e),YL(),sz(e),lz()]}}var hz={tokenize:kz,partial:!0},gz={tokenize:Az,partial:!0},_z={tokenize:jz,partial:!0},vz={tokenize:Mz,partial:!0},yz={tokenize:Nz,partial:!0},bz={name:`wwwAutolink`,tokenize:Dz,previous:Pz},xz={name:`protocolAutolink`,tokenize:Oz,previous:Fz},Sz={name:`emailAutolink`,tokenize:Ez,previous:Iz},Cz={};function wz(){return{text:Cz}}for(var Tz=48;Tz<123;)Cz[Tz]=Sz,Tz++,Tz===58?Tz=65:Tz===91&&(Tz=97);Cz[43]=Sz,Cz[45]=Sz,Cz[46]=Sz,Cz[95]=Sz,Cz[72]=[Sz,xz],Cz[104]=[Sz,xz],Cz[87]=[Sz,bz],Cz[119]=[Sz,bz];function Ez(e,t,n){let r=this,i,a;return o;function o(t){return!Lz(t)||!Iz.call(r,r.previous)||Rz(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Lz(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(yz,u,l)(t):t===45||t===95||_M(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&gM(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Dz(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Pz.call(r,r.previous)||Rz(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(hz,e.attempt(gz,e.attempt(_z,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Oz(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&Fz.call(r,r.previous)&&!Rz(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(gM(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||yM(t)||CM(t)||EM(t)||TM(t)?n(t):e.attempt(gz,e.attempt(_z,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function kz(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Az(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(vz,c,s)(t):t===null||CM(t)||EM(t)||t!==45&&TM(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function jz(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(vz,t,a)(o):o===null||CM(o)||EM(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Mz(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||CM(o)||EM(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||CM(e)||EM(e)?t(e):r(e)}function a(e){return gM(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):gM(t)?(e.consume(t),o):n(t)}}function Nz(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return _M(e)?n(e):t(e)}}function Pz(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||CM(e)}function Fz(e){return!gM(e)}function Iz(e){return!(e===47||Lz(e))}function Lz(e){return e===43||e===45||e===46||e===95||_M(e)}function Rz(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var zz={tokenize:qz,partial:!0};function Bz(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Wz,continuation:{tokenize:Gz},exit:Kz}},text:{91:{name:`gfmFootnoteCall`,tokenize:Uz},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Vz,resolveTo:Hz}}}}function Vz(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=hM(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Hz(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Uz(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||CM(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(hM(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return CM(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Wz(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||CM(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=hM(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return CM(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),kM(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Gz(e,t,n){return e.check(WM,t,e.attempt(zz,t,n))}function Kz(e){e.exit(`gfmFootnoteDefinition`)}function qz(e,t,n){let r=this;return kM(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Jz(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&cM(o,o.length,0,LM(s,e.slice(r+1,n),t)),cM(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),cM(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=IM(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=IM(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Yz=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){Xz(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function Xz(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function Zz(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Qz(){return{flow:{null:{name:`table`,tokenize:$z,resolveAll:eB}}}}function $z(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):wM(t)?kM(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||CM(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,wM(t)?kM(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return wM(t)?kM(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return wM(t)?kM(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):wM(n)?kM(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||CM(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function eB(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Yz;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(nB(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=tB(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=tB(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=tB(f,t,o,i,n,d)):(o[0]=o[1],d=tB(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&nB(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Zz(t.events,n))}return e}function tB(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},rB(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=rB(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=rB(t.events,n[2]),a=rB(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},rB(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function nB(e,t,n,r,i){let a=[],o=rB(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function rB(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var iB={name:`tasklistCheck`,tokenize:oB};function aB(){return{text:{91:iB}}}function oB(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return CM(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):wM(r)?e.check({tokenize:sB},t,n)(r):n(r)}}function sB(e,t,n){return kM(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function cB(e){return dM([wz(),Bz(),Jz(e),Qz(),aB()])}var lB={};function uB(e){let t=this,n=e||lB,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(cB(n)),a.push(pz()),o.push(mz(n))}function dB({children:e,className:t}){return(0,V.jsx)(`div`,{className:B(`md`,t),children:(0,V.jsx)(oL,{remarkPlugins:[uB],components:{a:e=>(0,V.jsx)(`a`,{...e,target:`_blank`,rel:`noreferrer`})},children:e})})}function fB({message:e}){return e.role===`user`?(0,V.jsx)(`div`,{className:`flex justify-end animate-in fade-in-0 slide-in-from-bottom-1`,children:(0,V.jsx)(`div`,{className:`max-w-[85%] rounded-2xl rounded-br-sm bg-primary px-3.5 py-2 text-sm whitespace-pre-wrap text-primary-foreground`,children:(0,V.jsx)(SA,{text:e.text,images:e.images,tone:`inverse`})})}):(0,V.jsxs)(`div`,{className:`flex gap-2.5 animate-in fade-in-0 slide-in-from-bottom-1`,children:[(0,V.jsx)(mB,{}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsx)(`p`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Claude`}),(0,V.jsx)(dB,{className:`text-sm`,children:e.text})]})]})}function pB({queued:e}){return(0,V.jsxs)(`div`,{role:`status`,className:`flex items-end gap-2.5 animate-in fade-in-0 slide-in-from-bottom-1`,children:[(0,V.jsx)(mB,{}),(0,V.jsxs)(`span`,{className:`flex h-7 items-center rounded-2xl rounded-bl-sm bg-muted px-3 text-base text-primary`,children:[(0,V.jsx)(xm,{}),(0,V.jsx)(`span`,{className:`sr-only`,children:e?`Queued. Claude is busy and will answer next.`:`Claude is reading your message.`})]})]})}function mB(){return(0,V.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary`,children:(0,V.jsx)(He,{className:`size-3.5`})})}function hB({question:e,lock:t,claude:n,onClose:r}){let[i,a]=(0,O.useState)(Rk),[o,s]=(0,O.useState)(null),c=lA(xA),l=(0,O.useRef)(null),u=(0,O.useRef)(null),d=dA({disabled:!!t,onFiles:e=>u.current?.insertFiles(e),onReject:s}),f=bA(e),p=c.pending,m=!i.empty,h=m&&!i.uploading&&!p&&!t;(0,O.useEffect)(()=>{l.current?.scrollTo({top:l.current.scrollHeight,behavior:`smooth`})},[e.chat.length,f]),(0,O.useEffect)(()=>{u.current?.focus()},[e.id]);let g=async(n=i)=>{n.empty||n.uploading||p||t||await c.run(e.id,{text:n.text.trim(),images:n.images})&&u.current?.clear()};return Ef(pm.closeChat,()=>{document.querySelector(`[role="dialog"], [role="alertdialog"]`)||r()},{enabled:!m,preventDefault:!1,stopPropagation:!1}),(0,V.jsxs)(`aside`,{className:`relative flex h-full flex-col bg-background`,...d.dropZone,children:[(0,V.jsx)(Em,{show:d.dragging}),(0,V.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-2 border-b px-3`,children:[(0,V.jsx)(Yk,{className:`font-mono`,children:e.id}),(0,V.jsx)(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold`,title:e.title,children:e.title}),e.status===`answered`&&(e.answer?.by===`claude`?(0,V.jsx)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:`Resolved by Claude`}):(0,V.jsx)(Yk,{variant:`secondary`,className:`bg-success/10 text-success`,children:`Answered`})),e.status===`dropped`&&(0,V.jsx)(Yk,{variant:`outline`,children:`Dropped`}),(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)(Rr,{variant:`ghost`,size:`icon-sm`,onClick:r,"aria-label":`Close discussion`}),children:(0,V.jsx)(Qe,{})}),(0,V.jsxs)(Bu,{children:[`Close `,(0,V.jsx)(Tm,{hotkey:pm.closeChat})]})]})]}),e.status===`dropped`&&(0,V.jsxs)(`p`,{className:`border-b bg-muted/50 px-4 py-2 text-sm text-muted-foreground`,children:[`Claude dropped this question`,e.dropReason?`: ${e.dropReason}`:`.`,` You can still talk about it.`]}),(0,V.jsxs)(`div`,{ref:l,className:`flex-1 space-y-5 overflow-y-auto px-4 py-5`,"aria-live":`polite`,children:[e.chat.length===0&&(0,V.jsx)(Xk,{className:`h-full p-4 pb-[12svh]`,children:(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{variant:`icon`,children:(0,V.jsx)(we,{})}),(0,V.jsx)(eA,{children:`Push back, ask why`}),(0,V.jsx)(tA,{children:`Claude answers with this question in mind, and can settle it for you.`})]})}),e.chat.map(e=>(0,V.jsx)(fB,{message:e},e.id)),f&&!t&&(0,V.jsx)(pB,{queued:n!==`listening`}),f&&t===`ended`&&(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The session ended before Claude replied.`})]}),(0,V.jsxs)(`div`,{className:`border-t p-3`,children:[c.error&&(0,V.jsx)(Sm,{className:`mb-2`,message:c.error,onRetry:()=>void g(),onDismiss:c.clearError}),o&&(0,V.jsx)(Sm,{className:`mb-2`,message:o,onDismiss:()=>s(null)}),(0,V.jsxs)(iA,{className:B(`bg-background`,!t&&`has-disabled:bg-background has-disabled:opacity-100 dark:has-disabled:bg-input/30`),children:[(0,V.jsx)(zk,{ref:u,disabled:!!t,invalid:!!c.error,onChange:e=>{e.empty||c.clearError(),a(e)},onSubmit:e=>void g(e),onError:s,placeholder:t?pA[t]:`Ask about this question… (paste or drop images)`,className:`max-h-40 min-h-14`}),(0,V.jsxs)(oA,{align:`block-end`,children:[(0,V.jsx)(`span`,{className:`self-end text-xs text-muted-foreground`,children:p?`Sending…`:i.uploading?`Uploading image…`:`Enter to send · ${Bd(pm.newLine)} for new line`}),(0,V.jsx)(cA,{variant:`default`,size:`icon-sm`,className:`ml-auto rounded-full`,onClick:()=>void g(),disabled:!h,"aria-label":p?`Sending`:`Send`,children:p?(0,V.jsx)(xm,{}):(0,V.jsx)(P,{})})]})]})]})]})}function gB(e){let[t,n]=(0,O.useState)({}),r=e?.id,i=e?yA(e):0;return(0,O.useEffect)(()=>{r&&n(e=>({...e,[r]:i}))},[r,i]),(0,O.useCallback)(e=>yA(e)-(t[e.id]??0),[t])}function _B(){let{resolved:e,setTheme:t}=Ju(),n=e===`dark`?`light`:`dark`,r=n===`dark`?`Dark theme`:`Light theme`;return(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:r,onClick:()=>t(n),"aria-label":`Switch to ${n} theme`,children:[n===`dark`?(0,V.jsx)(Ee,{}):(0,V.jsx)(We,{}),(0,V.jsx)(`span`,{children:r})]})})}var vB={round:e=>`round-${e}`,question:e=>`q-${e}`,summary:`summary`};function yB(){let{toggleSidebar:e}=Xp();Ef(pm.toggleSidebar,e)}var bB={min:240,initial:320,max:520};function xB(){let[e,t]=Wu(Vu.sidebarWidth,bB.initial),n=Math.min(Math.max(e,bB.min),bB.max);return hm(`--app-sidebar-w`,`${n}px`),[n,t]}function SB({value:e,className:t}){let n=Math.min(Math.max(e,0),1)*100;return(0,V.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,strokeWidth:2,"aria-hidden":!0,className:B(`-rotate-90`,t),children:[(0,V.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,className:`stroke-current opacity-20`}),(0,V.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6`,pathLength:100,strokeDasharray:100,strokeDashoffset:100-n,strokeLinecap:`round`,className:B(`stroke-current transition-[stroke-dashoffset] duration-500 ease-out`,n===0&&`opacity-0`)})]})}function CB(e){let{open:t,defaultOpen:n=!1,onOpenChange:r,disabled:i}=e,[a,o]=Jf({controlled:t,default:n,name:`Collapsible`,state:`open`}),{mounted:s,setMounted:c,transitionStatus:l}=$c(a,!0,!0),u=$l(),[d,f]=O.useState(),p=d===null?void 0:d??u,m=H(e=>{let t=!a,n=la(ea,e.nativeEvent);r(t,n),!n.isCanceled&&o(t)});return O.useMemo(()=>({defaultPanelId:u,disabled:i,handleTrigger:m,mounted:s,open:a,panelId:p,setMounted:c,setOpen:o,setPanelIdState:f,transitionStatus:l}),[u,i,m,s,a,p,c,o,f,l])}var wB=O.createContext(void 0);function TB(){let e=O.useContext(wB);if(e===void 0)throw Error(er(15));return e}var EB=`data-open`,DB=`data-closed`,OB=wi,kB=`data-panel-open`,AB={[EB]:``},jB={[DB]:``},MB={open(e){return e?{[kB]:``}:null}},NB={open(e){return e?AB:jB},...Oi},PB=O.forwardRef(function(e,t){let{render:n,className:r,defaultOpen:i=!1,disabled:a=!1,onOpenChange:o,open:s,style:c,...l}=e,u=H(o),d=CB({open:s,defaultOpen:i,onOpenChange:u,disabled:a}),f=O.useMemo(()=>({open:d.open,disabled:d.disabled,transitionStatus:d.transitionStatus}),[d.open,d.disabled,d.transitionStatus]),p=O.useMemo(()=>({...d,onOpenChange:u,state:f}),[d,u,f]),m=wr(`div`,e,{state:f,ref:t,props:l,stateAttributesMapping:NB});return(0,V.jsx)(wB.Provider,{value:p,children:m})}),FB={...MB,...Oi},IB=O.forwardRef(function(e,t){let{panelId:n,open:r,handleTrigger:i,state:a,disabled:o}=TB(),{className:s,disabled:c=o,render:l,nativeButton:u=!0,style:d,...f}=e,{getButtonProps:p,buttonRef:m}=or({disabled:c,focusableWhenDisabled:!0,native:u});return wr(`button`,e,{state:a,ref:[t,m],props:[{"aria-controls":r?n:void 0,"aria-expanded":r,onClick:i},f,p],stateAttributesMapping:FB})}),LB={height:void 0,width:void 0};function RB(e){let{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:a,onOpenChange:o,open:s,setMounted:c,setOpen:l,transitionStatus:u}=e,d=O.useRef(null),f=O.useRef(null),[p,m]=O.useState(LB),h=O.useRef(LB),g=O.useRef(!1),_=O.useRef(s),v=O.useRef(!1),[y,b]=O.useState(!1),x=O.useRef(null),S=lr(t,d),C=ha(s),w=nl(d),T=!s&&!a,E=y?`idle`:u,D=s&&(_.current||v.current),k=!s&&a&&f.current===`css-animation`&&p.height===void 0&&p.width===void 0?h.current:p,A=n&&T&&f.current!==`css-animation`,j=H((e,t=!0)=>{t&&(h.current=e),m(e)}),M=H(()=>{x.current?.(),x.current=null}),N=H(e=>{M(),x.current=()=>{x.current=null,e()}}),P=H(()=>{s&&a&&f.current===`css-animation`&&(v.current=!0)});U(()=>{y&&u!==`starting`&&b(!1)},[y,u]),O.useEffect(()=>()=>{P(),M()},[P,M]),U(()=>{let e=d.current;if(!e)return;!s&&x.current&&M();let t=BB(e,D);if(f.current=t,s&&u===`idle`&&_.current&&t===`css-animation`){h.current=zB(e);return}if(s&&u===`starting`){let n=g.current;if(g.current=!1,t===`none`){j(zB(e)),b(!0);return}if(t===`css-transition`){let t=UB(e);if(j(zB(e)),!n)return t;let r=HB(e,`transition-duration`,`0s`);return N(r),b(!0),t}j(zB(e));let r=HB(e,`animation-name`,`none`);if(!n){r();return}let i=HB(e,`animation-duration`,`0s`);r(),N(i),b(!0);return}if(!s&&a&&(u===`idle`||u===`starting`)){if(_.current=!1,v.current=!1,t===`none`){j(LB,!1),c(!1);return}j(zB(e));return}if(u!==`ending`)return;if(t===`none`){c(!1);return}let n=zB(e);if(!(n.height>0||n.width>0)){c(!1);return}j(n),t===`css-animation`&&HB(e,`animation-name`,`none`)()},[a,s,M,j,c,N,D,u]),rl({enabled:s&&a&&E===`idle`,open:!0,ref:d,onComplete(){s&&j(LB,!1)}}),O.useEffect(()=>{if(s||!a||E!==`ending`||!d.current)return;let e=new AbortController,t=-1;function n(){C.current||(c(!1),j(LB,!1))}return t=ya.request(()=>{w(n,e.signal)}),()=>{ya.cancel(t),e.abort()}},[C,a,s,E,w,j,c]),U(()=>{let e=d.current;e&&n&&T&&e.setAttribute(`hidden`,`until-found`)},[T,n]),O.useEffect(function(){let e=d.current;if(!e)return;function t(e){let t=la($i,e);o(!0,t),!t.isCanceled&&(g.current=!0,l(!0))}return G(e,`beforematch`,t)},[o,l]);let F=i||n||a||s;return{height:k.height,props:{...A?{[OB]:``}:void 0,hidden:T,id:r},ref:S,shouldPreventOpenAnimation:D,shouldRender:F,transitionStatus:E,width:k.width}}function zB(e){return{height:e.scrollHeight,width:e.scrollWidth}}function BB(e,t){let n=sn(e).getComputedStyle(e),r=(n.animationName.split(`,`).map(e=>e.trim()).some(e=>e!==``&&e!==`none`)||t)&&VB(n.animationDuration),i=VB(n.transitionDuration);return r&&i||i?`css-transition`:r?`css-animation`:`none`}function VB(e){return e.split(`,`).map(e=>e.trim()).some(e=>e!==``&&Number.parseFloat(e)>0)}function HB(e,t,n){let r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===``){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function UB(e){let t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(t=>{e.style.setProperty(t,`initial`,`important`)});function n(){Object.entries(t).forEach(([t,n])=>{if(n===``){e.style.removeProperty(t);return}e.style.setProperty(t,n)})}let r=ya.request(n);return()=>{ya.cancel(r),n()}}var WB=`--collapsible-panel-height`,GB=`--collapsible-panel-width`,KB=O.forwardRef(function(e,t){let{className:n,hiddenUntilFound:r,keepMounted:i,render:a,id:o,style:s,...c}=e,{defaultPanelId:l,mounted:u,onOpenChange:d,open:f,setMounted:p,setPanelIdState:m,setOpen:h,state:g,transitionStatus:_}=TB(),v=r??!1,y=i??!1,b=o||void 0,x=b??l;U(()=>(m(e=>b??(e===null?void 0:e)),()=>{m(e=>e===b?null:e)}),[b,m]);let{height:S,props:C,ref:w,shouldPreventOpenAnimation:T,shouldRender:E,transitionStatus:D,width:O}=RB({externalRef:t,hiddenUntilFound:v,id:x,keepMounted:y,mounted:u,onOpenChange:d,open:f,setMounted:p,setOpen:h,transitionStatus:_}),k={...g,transitionStatus:D},A=Cr(s,k),j=wr(`div`,{...e,style:void 0},{state:k,ref:w,props:[C,{style:{[WB]:S===void 0?`auto`:`${S}px`,[GB]:O===void 0?`auto`:`${O}px`}},c,A?{style:A}:void 0,T?{style:{animationName:`none`}}:void 0],stateAttributesMapping:NB});return E?j:null});function qB({...e}){return(0,V.jsx)(PB,{"data-slot":`collapsible`,...e})}function JB({...e}){return(0,V.jsx)(IB,{"data-slot":`collapsible-trigger`,...e})}function YB({...e}){return(0,V.jsx)(KB,{"data-slot":`collapsible-content`,...e})}function XB(e){return String(e).padStart(2,`0`)}function ZB(e){let t=Math.max(0,Math.floor(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,`0`)}s`}function QB(e){return e.status===`dropped`?`border border-dashed border-muted-foreground/40 text-muted-foreground line-through`:e.status===`answered`?e.answer?.sent?`bg-success text-background`:`bg-success/15 text-success`:`border-[1.5px] border-muted-foreground/40 text-muted-foreground`}function $B({question:e,attention:t=!1,pending:n=!1}){return(0,V.jsxs)(`span`,{className:B(`relative flex size-5 shrink-0 items-center justify-center rounded-full text-[10px] font-semibold tabular-nums`,QB(e)),children:[e.id.replace(/^\D+/,``),t&&(0,V.jsx)(`span`,{className:B(`absolute -top-1 -right-1 hidden size-2 rounded-full bg-primary ring-2 ring-sidebar group-data-[collapsible=icon]:block`,n&&`animate-pulse`)})]})}function eV({question:e,active:t,unread:n,onJump:r,onOpenChat:i}){let a=bA(e),o=a||n>0,s=e.chat.length>0||a;return(0,V.jsxs)(cm,{children:[(0,V.jsxs)(um,{isActive:t,tooltip:`${e.id} · ${e.title}`,onClick:r,className:`h-auto items-start py-1.5 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:p-1.5!`,children:[(0,V.jsx)($B,{question:e,attention:o,pending:a}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 group-data-[collapsible=icon]:hidden`,children:[(0,V.jsx)(`span`,{className:B(`line-clamp-2 leading-snug`,e.status===`dropped`&&`text-muted-foreground line-through`,e.status===`answered`&&`text-muted-foreground`),children:e.title}),e.status===`answered`&&(0,V.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-muted-foreground/80`,children:vA(e)})]})]}),s&&(0,V.jsxs)(dm,{onClick:i,"aria-label":`Open discussion for ${e.id}`,className:`top-1.5!`,children:[(0,V.jsx)(we,{className:B(!o&&`text-muted-foreground`)}),o&&(0,V.jsx)(`span`,{className:B(`absolute -top-0.5 -right-0.5 size-2 rounded-full bg-primary ring-2 ring-sidebar`,a&&`animate-pulse`)})]})]})}function tV({round:e,questions:t,current:n,chatFor:r,unread:i,onJump:a,onOpenChat:o,toggled:s,onToggle:c}){let l=mA(t),u=l.filter(e=>e.status===`answered`).length,d=l.length>0&&u===l.length,f=vB.round(e.number),p=n===f||e.questionIds.some(e=>n===vB.question(e)),m=s??(!d||p),h=e.title??`Round ${e.number}`;return(0,V.jsx)(qB,{open:m,onOpenChange:c,children:(0,V.jsxs)(am,{children:[(0,V.jsxs)(om,{render:(0,V.jsx)(JB,{}),className:`mb-1 gap-2 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:pointer-events-none`,children:[(0,V.jsx)(`span`,{className:B(`font-semibold tabular-nums`,d?`text-success`:`text-primary`),children:XB(e.number)}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:h}),(0,V.jsxs)(`span`,{className:B(`flex items-center gap-1 tabular-nums`,d&&`text-success`),children:[d&&(0,V.jsx)(oe,{className:`size-3.5`}),u,`/`,l.length]}),(0,V.jsx)(ne,{className:B(`size-3.5 transition-transform duration-200`,m&&`rotate-90`)})]}),(0,V.jsx)(`p`,{className:B(`mb-1 hidden text-center text-[10px] font-semibold tabular-nums group-data-[collapsible=icon]:block`,d?`text-success`:`text-primary`),children:XB(e.number)}),!m&&(0,V.jsx)(sm,{className:`hidden group-data-[collapsible=icon]:flex`,children:(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:`${h} · ${u}/${l.length} settled`,onClick:()=>{if(!d)return c(!0);c(void 0),a(f)},className:d?`text-success hover:text-success`:`text-primary hover:text-primary`,children:[d?(0,V.jsx)(oe,{}):(0,V.jsx)(se,{}),(0,V.jsx)(`span`,{children:h})]})})}),(0,V.jsx)(YB,{className:`h-(--collapsible-panel-height) overflow-hidden transition-[height] duration-200 ease-out data-ending-style:h-0 data-starting-style:h-0`,children:(0,V.jsxs)(sm,{className:`gap-0.5`,children:[t.map(e=>(0,V.jsx)(eV,{question:e,active:n===vB.question(e.id)||r===e.id,unread:i(e),onJump:()=>a(vB.question(e.id)),onOpenChat:()=>o(e.id)},e.id)),d&&(0,V.jsx)(cm,{className:`animate-in fade-in-0 slide-in-from-top-1 animation-duration-200`,children:(0,V.jsxs)(um,{tooltip:`Round ${XB(e.number)} review`,isActive:n===f,onClick:()=>a(f),className:`text-primary hover:text-primary data-active:text-primary`,children:[(0,V.jsx)(Ie,{}),(0,V.jsx)(`span`,{children:`Review`})]})})]})})]})})}function nV({state:e,current:t,onJump:n,chatFor:r,unread:i,onOpenChat:a}){let{isMobile:o,setOpenMobile:s,state:c}=Xp(),[l,u]=xB(),[d,f]=(0,O.useState)({});yB();let p=e=>{n(e),o&&s(!1)};return(0,V.jsxs)(Qp,{variant:`floating`,collapsible:`icon`,"aria-label":`Rounds and questions`,children:[(0,V.jsxs)(tm,{className:`h-12 flex-row items-center border-b px-2`,children:[(0,V.jsx)(nn,{}),(0,V.jsx)(`span`,{className:`truncate text-sm font-semibold tracking-tight group-data-[collapsible=icon]:hidden`,children:`better grill`})]}),(0,V.jsxs)(im,{className:`group-data-[collapsible=icon]:overflow-x-hidden group-data-[collapsible=icon]:overflow-y-auto`,children:[e.rounds.length===0&&(0,V.jsx)(iV,{ended:e.ended}),e.rounds.map((n,o)=>(0,V.jsxs)(O.Fragment,{children:[o>0&&(0,V.jsx)(rm,{}),(0,V.jsx)(tV,{round:n,questions:hA(e,n.questionIds),current:t,chatFor:r,unread:i,onJump:p,onOpenChat:a,toggled:d[n.number],onToggle:e=>f(t=>({...t,[n.number]:e}))})]},n.number)),e.summary&&(0,V.jsx)(am,{children:(0,V.jsx)(sm,{children:(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:`Summary`,isActive:t===vB.summary,onClick:()=>p(vB.summary),className:`text-primary hover:text-primary data-active:text-primary`,children:[(0,V.jsx)(le,{}),(0,V.jsx)(`span`,{children:`Summary`})]})})})})]}),(0,V.jsx)(nm,{className:`border-t`,children:(0,V.jsxs)(sm,{className:`gap-0.5`,children:[(0,V.jsx)(rV,{state:e,onJump:p}),(0,V.jsx)(_B,{})]})}),!o&&c===`expanded`&&(0,V.jsx)(mm,{side:`left`,cssVar:`--app-sidebar-w`,width:l,min:bB.min,max:bB.max,initial:bB.initial,onResize:u,label:`Resize panel`,className:`right-0`})]})}function rV({state:e,onJump:t}){let n=mA(Object.values(e.questions));if(n.length===0)return null;let r=n.filter(e=>e.status===`answered`).length,i=r===n.length,a=n.find(e=>e.status===`open`),o=a?vB.question(a.id):e.summary?vB.summary:null;return(0,V.jsx)(cm,{children:(0,V.jsxs)(um,{tooltip:`${r}/${n.length} settled`,disabled:!o,onClick:()=>o&&t(o),"aria-label":`${r} of ${n.length} settled`,children:[(0,V.jsx)(SB,{value:r/n.length,className:i?`text-success`:`text-primary`}),(0,V.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-2`,children:[(0,V.jsx)(`span`,{className:`truncate`,children:i?`All settled`:`Settled`}),(0,V.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:[r,`/`,n.length]})]})]})})}function iV({ended:e}){return(0,V.jsx)(am,{children:e?(0,V.jsx)(`p`,{className:`px-2 pt-2 text-xs text-muted-foreground group-data-[collapsible=icon]:hidden`,children:`No rounds were posted.`}):(0,V.jsx)(sm,{children:[0,1,2].map(e=>(0,V.jsx)(cm,{children:(0,V.jsx)(fm,{showIcon:!0})},e))})})}function aV({hotkey:e,...t}){return e?(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)(oV,{...t})}),(0,V.jsxs)(Bu,{children:[t.active?`Close discussion`:`Discuss`,` `,(0,V.jsx)(Tm,{hotkey:e})]})]}):(0,V.jsx)(oV,{...t})}function oV({count:e,unread:t,active:n,onClick:r,compact:i=!1,...a}){let o=i&&e===0;return(0,V.jsxs)(Rr,{...a,variant:n?`secondary`:`outline`,size:o?`icon-sm`:i?`sm`:`default`,onClick:r,"aria-pressed":n,"aria-label":i?`Discuss`:void 0,className:B(`relative`,n&&`border-primary/40 bg-primary/10 text-primary hover:bg-primary/15`),children:[(0,V.jsx)(we,{"data-icon":o?void 0:`inline-start`}),!i&&`Discuss`,e>0&&(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:e}),t>0&&(0,V.jsxs)(`span`,{className:`absolute -top-1 -right-1 flex size-2.5`,children:[(0,V.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-primary opacity-60`}),(0,V.jsx)(`span`,{className:`relative inline-flex size-2.5 rounded-full bg-primary ring-2 ring-background`})]})]})}function sV({children:e}){return(0,V.jsxs)(`section`,{className:`mt-10`,children:[(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs font-medium tracking-wide text-primary uppercase`,children:[(0,V.jsx)(Me,{className:`size-3.5`}),`Also sending`]}),(0,V.jsx)(`h3`,{className:`mt-0.5 text-lg font-semibold tracking-tight`,children:`Changed from earlier rounds`})]}),(0,V.jsx)(`div`,{className:`grid gap-4`,children:e})]})}function cV({question:e}){return(0,V.jsxs)(`article`,{id:vB.question(e.id),className:`scroll-mt-20 rounded-xl border border-dashed px-5 py-4 text-muted-foreground`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,V.jsx)(Yk,{variant:`outline`,className:`font-mono text-muted-foreground`,children:e.id}),(0,V.jsx)(`span`,{className:`text-sm font-medium line-through decoration-muted-foreground/60`,children:e.title}),(0,V.jsx)(Yk,{variant:`ghost`,className:`ml-auto`,children:`Dropped`})]}),e.dropReason&&(0,V.jsx)(`p`,{className:`mt-2 text-sm italic`,children:e.dropReason})]})}function lV({children:e,className:t}){return(0,V.jsxs)(`p`,{className:B(`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,t),children:[(0,V.jsx)(Se,{className:`size-3 shrink-0`}),e]})}function uV({pending:e,label:t,pendingLabel:n}){return e?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xm,{}),n]}):(0,V.jsx)(V.Fragment,{children:t})}function dV({slot:e,children:t}){return(0,Ko.createPortal)((0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute -inset-x-3 -top-24 -bottom-3 canvas [mask-image:linear-gradient(to_bottom,transparent,black_65%)]`}),(0,V.jsx)(`div`,{className:`relative flex items-center gap-2 rounded-xl border bg-popover/95 px-4 py-3 shadow-lg backdrop-blur-md sm:px-5`,children:t})]}),e)}function fV({className:e,size:t=`default`,...n}){return(0,V.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:B(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function pV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-header`,className:B(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function mV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-title`,className:B(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function hV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-description`,className:B(`text-sm text-muted-foreground`,e),...t})}function gV({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-content`,className:B(`px-(--card-spacing)`,e),...t})}function _V({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`card-footer`,className:B(`flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)`,e),...t})}function vV(e,t){let n=window.getSelection();if(!n?.rangeCount||!n.isCollapsed)return!1;let r=n.getRangeAt(0);if(!e.contains(r.startContainer))return!1;let i=document.createRange();return i.selectNodeContents(e),t===-1?i.setEnd(r.startContainer,r.startOffset):i.setStart(r.endContainer,r.endOffset),i.toString().length===0}var yV=(e,t)=>$O(`/api/questions/${e}/answer`,t),bV=`[data-answer-item]:not(:disabled)`;function xV(e){e.focus({preventScroll:!0,focusVisible:!0}),e.scrollIntoView({block:`nearest`,behavior:`smooth`})}function SV(){let e=document.activeElement;return!!e&&e!==document.body&&!!e.closest(`input, textarea, [contenteditable=true]`)}function CV(e,t){let n=[...document.querySelectorAll(bV)],r=n[n.indexOf(e)+t];return!n.includes(e)||!r?!1:(xV(r),!0)}function wV(e){let t=e.querySelector(bV);return t&&xV(t),!!t}function TV(){if(SV())return;let e=document.querySelector(`${bV}[aria-checked=true]`);e?xV(e):wV(document)}var EV=null,DV=new Set;function OV(e){if(EV!==e){EV=e;for(let e of DV)e()}}function kV(e){return DV.add(e),()=>DV.delete(e)}function AV(e){return(0,O.useSyncExternalStore)(kV,()=>EV===e)}function jV({question:e,selected:t,disabled:n,onToggle:r}){let i=e.multiSelect;return(0,V.jsx)(`div`,{role:i?`group`:`radiogroup`,className:`grid gap-2`,children:e.options.map((a,o)=>{let s=t.includes(a.id),c=e.recommended===a.id;return(0,V.jsxs)(`button`,{type:`button`,role:i?`checkbox`:`radio`,"aria-checked":s,disabled:n,onClick:()=>r(a.id),"data-answer-item":!0,"data-option-id":a.id,className:B(`group/option flex scroll-mt-20 scroll-mb-32 items-start gap-3 rounded-lg border bg-background p-3 text-left transition-[color,background-color,border-color,box-shadow] outline-none`,`hover:bg-muted/50 focus:border-ring focus:ring-3 focus:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-60`,`dark:bg-input/20 dark:hover:bg-input/40`,s&&`border-primary bg-primary/5 ring-1 ring-primary hover:bg-primary/5 dark:bg-primary/10 dark:hover:bg-primary/10`),children:[(0,V.jsx)(`span`,{"aria-hidden":!0,className:B(`mt-0.5 flex size-5 shrink-0 items-center justify-center border text-[10px] font-medium text-muted-foreground transition-colors`,i?`rounded-md`:`rounded-full`,s?`border-primary bg-primary text-primary-foreground`:`border-input group-hover/option:border-foreground/30`),children:s?(0,V.jsx)(te,{className:`size-3`,strokeWidth:3}):String.fromCharCode(65+o)}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,V.jsx)(`span`,{className:`text-sm font-medium`,children:a.label}),c&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Recommended`]})]}),a.description&&(0,V.jsx)(`span`,{className:`mt-0.5 block text-sm text-muted-foreground`,children:a.description})]})]},a.id)})})}function MV({question:e,lock:t,discussing:n,unread:r,onDiscuss:i,onLockedIn:a,actionsSlot:o,extraActions:s,hidden:c=!1}){let l=t!==null,[u,d]=(0,O.useState)(e.answer?.optionIds??[]),[f,p]=(0,O.useState)(()=>NV(e)),[m,h]=(0,O.useState)(null),g=lA(yV),_=(0,O.useRef)(null),v=dA({disabled:l,onFiles:e=>_.current?.insertFiles(e),onReject:h}),y=t=>{g.clearError(),d(n=>e.multiSelect?n.includes(t)?n.filter(e=>e!==t):[...n,t]:n[0]===t?[]:[t])},b=e.answer,x=e.status===`answered`,S=(e,t=f)=>PV(e,b?.optionIds??[])&&t.text.trim()===(b?.text??``).trim()&&PV(t.images,b?.images??[])&&!t.uploading,C=x&&!S(u),w=g.pending,T=u.length>0||!f.empty,E=!l&&!w&&!f.uploading&&T&&(!x||C),D=()=>{g.clearError(),d(b?.optionIds??[]),_.current?.reset(b?.text??``,b?.images??[])},k=(0,O.useRef)(null),[A,j]=(0,O.useState)(null),M=async(t=u,n=f)=>{if(!(l||w||n.uploading||t.length===0&&n.empty)){if(x&&S(t,n)){a();return}await g.run(e.id,{optionIds:t,text:n.text.trim()||void 0,images:n.images})&&a()}},N=t=>{let n=e.multiSelect&&u.length>0?u:[t];d(n),M(n)},P=AV(e.id);Ef(pm.lockIn,e=>{e.target.closest(`input, textarea, [contenteditable=true]`)||M()},{enabled:P&&E&&!c,conflictBehavior:`allow`});let F=()=>OV(e.id),I={target:k,ignoreInputs:!1,preventDefault:!1,stopPropagation:!1},ee=(e,t)=>{let n=e.target;n.matches(`[data-answer-item]`)&&(!n.isContentEditable||vV(n,t))&&CV(n,t)&&e.preventDefault()};Ef(pm.nextAnswer,e=>ee(e,1),I),Ef(pm.previousAnswer,e=>ee(e,-1),I),Ef(pm.submitAnswer,e=>{let t=e.target;t.dataset.optionId&&(e.preventDefault(),N(t.dataset.optionId))},I);let te=e=>{let t=e.target;j(t.dataset.optionId?`option`:t.isContentEditable?`text`:null)},L=e.options.length===0?`Open answer`:e.multiSelect?`Pick any`:`Pick one`,ne=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(aV,{count:e.chat.length,unread:r,active:n,onClick:i,hotkey:pm.discuss}),s,(0,V.jsx)(`div`,{className:`flex-1`}),t?(0,V.jsx)(lV,{children:pA[t]}):A===`option`?(0,V.jsxs)(FV,{children:[(0,V.jsx)(Tm,{hotkey:pm.previousAnswer}),(0,V.jsx)(Tm,{hotkey:pm.nextAnswer}),` move`,(0,V.jsx)(Tm,{hotkey:pm.submitAnswer,className:`ml-1.5`}),` lock in`]}):A===`text`?(0,V.jsxs)(FV,{children:[(0,V.jsx)(Tm,{hotkey:pm.submitAnswer}),` lock in`,(0,V.jsx)(Tm,{hotkey:pm.newLine,className:`ml-1.5`}),` new line`]}):P&&T?(0,V.jsxs)(FV,{children:[(0,V.jsx)(Tm,{hotkey:pm.lockIn}),` lock in`]}):(0,V.jsx)(`span`,{className:`hidden text-xs text-muted-foreground sm:inline`,children:e.options.length>0?`Pick, type or drop an image`:`Type an answer or drop an image`}),C&&(0,V.jsx)(Rr,{variant:`ghost`,disabled:w,onClick:D,children:`Discard changes`}),(0,V.jsx)(Rr,{disabled:!E,onClick:()=>void M(),children:(0,V.jsx)(uV,{pending:w,pendingLabel:`Locking in…`,label:x?`Update answer`:`Lock in`})})]}),re=(0,V.jsxs)(fV,{ref:k,id:vB.question(e.id),"data-question-editor":!0,onPointerDownCapture:F,onFocusCapture:e=>{F(),te(e)},onBlurCapture:e=>{k.current?.contains(e.relatedTarget)||j(null)},...v.dropZone,className:B(`relative scroll-mt-20 gap-5 pt-5 shadow-xs transition-shadow`,n?`ring-1 ring-primary/45`:`hover:shadow-sm`),children:[(0,V.jsx)(Em,{show:v.dragging}),(0,V.jsxs)(pV,{className:`grid-cols-1 gap-2 px-5 sm:px-6`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(Yk,{className:`font-mono`,children:e.id}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:L}),e.editedAt&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Edited by Claude`]}),x&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-success/10 text-success`,children:[(0,V.jsx)(oe,{"data-icon":`inline-start`}),b?.sent?`Sent to Claude`:`Locked in`]}),b?.by===`claude`&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Resolved in discussion by Claude`]})]}),(0,V.jsx)(mV,{className:`text-xl font-semibold tracking-tight text-balance`,children:e.title}),e.body&&(0,V.jsx)(hV,{children:(0,V.jsx)(dB,{children:e.body})})]}),(0,V.jsxs)(gV,{className:`grid grid-cols-1 gap-4 px-5 sm:px-6`,children:[e.options.length>0&&(0,V.jsx)(jV,{question:e,selected:u,disabled:l||w,onToggle:y}),e.recommendation&&(0,V.jsxs)(Of,{className:`border-primary/20 bg-primary/5`,children:[(0,V.jsx)(He,{className:`text-primary`}),(0,V.jsx)(kf,{className:`text-primary`,children:`Claude's pick`}),(0,V.jsx)(Af,{className:`text-foreground/80`,children:(0,V.jsx)(dB,{children:e.recommendation})})]}),(0,V.jsx)(iA,{className:`h-auto`,children:(0,V.jsx)(zk,{ref:_,initialText:b?.text,initialImages:b?.images,disabled:l||w,invalid:!!g.error,editableProps:{"data-answer-item":!(l||w)||void 0},onChange:e=>{e.text!==f.text&&g.clearError(),p(e)},onSubmit:e=>void M(u,e),onError:h,placeholder:e.options.length===0?`Your answer… (paste or drop images)`:u.length>0?`Add a note to your pick (optional)…`:`Or write your own answer…`,className:`max-h-80 min-h-20 scroll-mt-20 scroll-mb-32`})}),m&&(0,V.jsx)(Sm,{message:m,onDismiss:()=>h(null)}),g.error&&(0,V.jsx)(Sm,{message:g.error,onRetry:()=>void M(),onDismiss:g.clearError})]})]});return o?(0,V.jsxs)(V.Fragment,{children:[re,(0,V.jsx)(dV,{slot:o,children:ne})]}):re}function NV(e){let t=e.answer?.text??``,n=e.answer?.images??[];return{text:t,images:n,uploading:!1,empty:!t.trim()&&n.length===0}}function PV(e,t){return e.length===t.length&&e.every(e=>t.includes(e))}function FV({children:e}){return(0,V.jsx)(`span`,{className:`hidden items-center gap-1 text-xs text-muted-foreground sm:inline-flex`,children:e})}function IV(e){let{question:t}=e;return t.status===`dropped`?(0,V.jsx)(cV,{question:t}):(0,V.jsx)(MV,{...e},t.answer?.at??`open`)}function LV({question:e,discussing:t,unread:n,onDiscuss:r,onOpen:i}){if(e.status===`dropped`)return(0,V.jsx)(cV,{question:e});let a=e.answer,o=_A(e),s=e.status===`open`,c=!!a?.sent,l=s?`Not answered yet`:c?`Sent to Claude`:`Locked in, not sent yet`;return(0,V.jsx)(fV,{id:vB.question(e.id),size:`sm`,className:B(`scroll-mt-20 px-4 transition-shadow`,t&&`ring-1 ring-primary/45`),children:(0,V.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)(`span`,{}),className:B(`mt-0.5 shrink-0`,s?`text-muted-foreground`:`text-success`),"aria-label":l,children:s?(0,V.jsx)(se,{className:`size-5`}):c?(0,V.jsx)(oe,{className:`size-5 fill-success text-background`}):(0,V.jsx)(oe,{className:`size-5`})}),(0,V.jsx)(Bu,{children:l})]}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id}),(0,V.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:e.title})]}),s&&(0,V.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground italic`,children:`Not answered yet`}),a?.by===`claude`&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`mt-1.5 bg-primary/10 text-primary`,children:[(0,V.jsx)(He,{"data-icon":`inline-start`}),`Resolved in discussion by Claude · change it if that's wrong`]}),o.length>0&&(0,V.jsx)(`p`,{className:`mt-1 text-sm font-semibold`,children:o.join(` + `)}),a?.text&&(a.by===`claude`?(0,V.jsx)(dB,{className:`mt-1 text-sm`,children:a.text}):(0,V.jsx)(`p`,{className:`mt-1 text-sm whitespace-pre-wrap text-muted-foreground italic`,children:(0,V.jsx)(SA,{text:a.text,images:a.images})}))]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,V.jsx)(aV,{count:e.chat.length,unread:n,active:t,onClick:r,compact:!0}),(0,V.jsxs)(Rr,{variant:`ghost`,size:`sm`,onClick:i,children:[!s&&(0,V.jsx)(Ae,{"data-icon":`inline-start`}),s?`Answer`:`Change`]})]})]})})}function RV({questions:e}){let t=mA(e),n=t.filter(e=>e.status===`answered`);return t.length===0?null:n.length===t.length&&n.every(e=>e.answer?.sent)?(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-success/10 text-success`,children:[(0,V.jsx)(Re,{"data-icon":`inline-start`}),`Sent to Claude`]}):(0,V.jsx)(Yk,{variant:`outline`,className:`text-muted-foreground tabular-nums`,children:(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`span`,{className:`text-foreground`,children:n.length}),`/`,t.length,` locked in`]})})}function zV({round:e,questions:t,review:n=!1,children:r}){return(0,V.jsxs)(`section`,{id:vB.round(e.number),className:`scroll-mt-20`,children:[(0,V.jsxs)(`div`,{className:`mb-4 flex items-end gap-4`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`p`,{className:`text-xs font-medium tracking-wide text-primary uppercase`,children:[`Round `,XB(e.number),n&&` · Review`]}),(0,V.jsx)(`h2`,{className:`mt-0.5 truncate text-2xl font-semibold tracking-tight`,children:e.title??`Round ${e.number}`})]}),(0,V.jsx)(RV,{questions:t})]}),(0,V.jsx)(`div`,{className:`grid gap-4`,children:r})]})}var BV=()=>$O(`/api/send`,{});function VV(e,t){let n=lA(BV),r=mA(Object.values(e.questions)),i=r.filter(e=>e.status===`open`),a=r.filter(e=>e.status===`answered`&&!e.answer?.sent);return{open:i,unsent:a,changes:gA(e).length,ready:!e.ended&&i.length===0&&a.length>0&&!t&&!n.pending,idle:i.length===0&&a.length===0,action:n,send:()=>void n.run()}}function HV(e=1e3){let[t,n]=(0,O.useState)(()=>Date.now());return(0,O.useEffect)(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function UV({since:e,lock:t}){let n=HV()-e;return(0,V.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`mb-12 animate-in fade-in-0 slide-in-from-bottom-1 animation-duration-300`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-dashed px-4 py-3 font-mono text-xs`,children:[(0,V.jsx)(Ak,{className:`size-4 text-primary`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:[`Claude is working through your answers`,(0,V.jsx)(`span`,{className:`ml-1 inline-block h-3 w-1.5 translate-y-0.5 bg-primary motion-safe:animate-blink`})]}),(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:ZB(n)})]}),t===`offline`&&(0,V.jsx)(lV,{className:`mt-2 px-1 text-destructive`,children:`Bridge unreachable. The next round shows up once it reconnects.`}),!t&&n>=12e4&&(0,V.jsx)(lV,{className:`mt-2 px-1`,children:`Taking a while. Claude may be researching facts with sub-agents. The terminal shows what it is doing.`})]})}function WV({state:e,lock:t,onJump:n,showBar:r}){let{open:i,unsent:a,changes:o,ready:s,idle:c,action:l,send:u}=VV(e,t),d=l.pending,f=(0,O.useRef)(null);return(0,O.useEffect)(()=>{s&&r&&document.activeElement===document.body&&f.current?.focus({preventScroll:!0,focusVisible:!0})},[s,r]),e.ended?null:c?e.awaitingSince?(0,V.jsx)(UV,{since:e.awaitingSince,lock:t}):null:r?(0,V.jsx)(`div`,{className:`mb-12`,children:(0,V.jsxs)(`div`,{className:B(`flex flex-wrap items-center gap-x-4 gap-y-3 rounded-xl border bg-popover/95 px-4 py-3 shadow-lg backdrop-blur-md transition-[border-color,box-shadow] sm:px-5`,s&&`border-primary/50 shadow-primary/15 ring-4 ring-primary/10`),children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i.length>0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,V.jsx)(se,{className:`size-4 text-primary`}),(0,V.jsx)(`span`,{className:`tabular-nums`,children:i.length}),` still open`]}),(0,V.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:i.map(e=>(0,V.jsx)(Yk,{variant:`outline`,className:`font-mono text-muted-foreground hover:bg-muted hover:text-foreground`,render:(0,V.jsx)(`button`,{type:`button`,onClick:()=>n(vB.question(e.id))}),children:e.id},e.id))})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-sm font-semibold`,children:`All locked in.`}),(0,V.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[a.length,` `,a.length===1?`answer`:`answers`,o>0&&` · ${o} changed from earlier rounds`,` · you can still change anything`]})]}),t&&(0,V.jsx)(lV,{className:`mt-1.5`,children:pA[t]}),l.error&&(0,V.jsx)(Sm,{className:`mt-2`,message:l.error,onRetry:u,onDismiss:l.clearError})]}),(0,V.jsxs)(Rr,{ref:f,size:`lg`,disabled:!s,onClick:u,className:`px-4`,children:[!d&&(0,V.jsx)(Re,{"data-icon":`inline-start`}),(0,V.jsx)(uV,{pending:d,pendingLabel:`Sending…`,label:`Send to Claude`})]})]})}):null}function GV({state:e,lock:t,onJump:n}){let{open:r,unsent:i,ready:a,idle:o,action:s,send:c}=VV(e,t);if(e.ended||o)return null;let l=r[0],u=s.error??(t?pA[t]:l?`Next open: ${l.id}`:`${i.length} locked in, ready to send`);return(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:l?(0,V.jsx)(Rr,{variant:`outline`,size:`sm`,onClick:()=>n(vB.question(l.id))}):(0,V.jsx)(Rr,{size:`sm`,disabled:!a,onClick:c,className:B(s.error&&`ring-2 ring-destructive/50`)}),children:l?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(se,{"data-icon":`inline-start`,className:`text-primary`}),(0,V.jsx)(`span`,{className:`tabular-nums`,children:r.length}),` open`]}):(0,V.jsxs)(V.Fragment,{children:[!s.pending&&(0,V.jsx)(Re,{"data-icon":`inline-start`}),(0,V.jsx)(uV,{pending:s.pending,pendingLabel:`Sending…`,label:`Send ${i.length}`})]})}),(0,V.jsx)(Bu,{side:`bottom`,children:u})]})}function KV(){let[e,t]=(0,O.useState)(null),[n,r]=(0,O.useState)(()=>({status:`connecting`,since:Date.now(),attempts:0,everOpened:!1})),i=(0,O.useRef)(!1);return(0,O.useEffect)(()=>{let e=null,n,a=0,o=!1,s=()=>{e=new EventSource(`/api/stream`),e.onopen=()=>{a=0,r({status:`open`,since:Date.now(),attempts:0,everOpened:!0})},e.onmessage=e=>{try{let n=JSON.parse(e.data);i.current=n.ended,t(n)}catch(e){console.error(`Bad frame from bridge`,e)}},e.onerror=()=>{if(e?.close(),!o){if(i.current){r(e=>({...e,status:`closed`,since:Date.now()}));return}a+=1,r(e=>({status:`reconnecting`,since:e.status===`reconnecting`?e.since:Date.now(),attempts:a,everOpened:e.everOpened})),n=setTimeout(s,Uu[Math.min(a-1,Uu.length-1)])}}};return s(),()=>{o=!0,clearTimeout(n),e?.close()}},[]),{state:e,connection:n}}var qV=3,JV=300,YV=34,XV=2*Math.PI*YV;function ZV({title:e}){let[t,n]=(0,O.useState)(qV),[r,i]=(0,O.useState)(!1),a=(0,O.useRef)(null),o=()=>{window.close(),setTimeout(()=>i(!0),300)};return(0,O.useEffect)(()=>{let e=a.current?.animate([{strokeDashoffset:0},{strokeDashoffset:XV}],{duration:qV*1e3,easing:`linear`,fill:`forwards`});return()=>e?.cancel()},[]),(0,O.useEffect)(()=>{let e=t>0?setTimeout(()=>n(e=>e-1),1e3):setTimeout(o,JV);return()=>clearTimeout(e)},[t]),(0,V.jsx)(`div`,{className:`fixed inset-0 z-[90] grid place-items-center bg-background/95 backdrop-blur-md animate-in fade-in-0`,children:(0,V.jsxs)(`div`,{className:`px-4 text-center`,children:[(0,V.jsxs)(`div`,{className:`relative mx-auto size-20`,children:[(0,V.jsxs)(`svg`,{viewBox:`0 0 80 80`,className:`size-20 -rotate-90`,"aria-hidden":!0,children:[(0,V.jsx)(`circle`,{cx:`40`,cy:`40`,r:YV,fill:`none`,stroke:`var(--border)`,strokeWidth:`4`}),(0,V.jsx)(`circle`,{ref:a,cx:`40`,cy:`40`,r:YV,fill:`none`,stroke:`var(--primary)`,strokeWidth:`4`,strokeLinecap:`round`,strokeDasharray:XV})]}),(0,V.jsx)(`span`,{className:`absolute inset-0 grid place-items-center text-2xl font-semibold tabular-nums`,children:r?(0,V.jsx)(te,{className:`size-7 text-success`}):t})]}),(0,V.jsx)(`h2`,{className:`mt-6 text-3xl font-semibold tracking-tight`,children:e}),(0,V.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:r?`Your browser kept this tab open. Close it whenever you like.`:`Back to your terminal. This tab closes in ${t}s.`}),!r&&(0,V.jsx)(Rr,{variant:`ghost`,size:`sm`,className:`mt-4 text-muted-foreground`,onClick:o,children:`Close now`})]})})}function QV({state:e,connection:t}){let[n,r]=(0,O.useState)(!1),i=(0,O.useRef)(t.status);if((0,O.useEffect)(()=>{let e=i.current;if(i.current=t.status,e===`reconnecting`&&t.status===`open`){r(!0);let e=setTimeout(()=>r(!1),2500);return()=>clearTimeout(e)}},[t.status]),e.ended){let t=e.summary?.status===`confirmed`;return(0,V.jsxs)(eH,{tone:`muted`,children:[(0,V.jsx)(ve,{className:`size-3.5`}),t?`Summary confirmed. Claude takes it from here in the terminal.`:`Session closed. Back to your terminal.`]})}if(t.status===`reconnecting`){let e=t.attempts>=6;return(0,V.jsxs)(eH,{tone:`alert`,children:[(0,V.jsx)(xm,{className:`text-sm`}),(0,V.jsx)(`span`,{children:e?(0,V.jsxs)(V.Fragment,{children:[`The bridge has been gone for a while. If its Claude Code session was closed, run`,` `,(0,V.jsx)(`code`,{className:`font-mono font-medium`,children:`/better-grill`}),` again. Still retrying.`]}):(0,V.jsxs)(V.Fragment,{children:[`Lost the bridge. Reconnecting`,t.attempts>1?` (attempt ${t.attempts})`:``,`… Everything you locked in is kept in the bridge.`]})}),(0,V.jsx)(Rr,{variant:`link`,size:`xs`,className:`h-auto px-0 text-current`,onClick:()=>window.location.reload(),children:`Reload`})]})}return n?(0,V.jsxs)(eH,{tone:`ok`,children:[(0,V.jsx)(te,{className:`size-3.5`}),`Reconnected. You're up to date.`]}):null}var $V={muted:`bg-muted/80 text-muted-foreground`,alert:`bg-destructive/10 text-destructive`,ok:`bg-success/10 text-success`};function eH({tone:e,children:t}){return(0,V.jsx)(`div`,{role:e===`alert`?`alert`:`status`,className:B(`flex items-center justify-center gap-2 rounded-lg border px-4 py-2 text-center text-xs font-medium shadow-sm backdrop-blur-md animate-in fade-in-0 slide-in-from-top-1`,$V[e]),children:t})}function tH(e){return Mp(`alert-dialog`,e)}function nH({...e}){return(0,V.jsx)(tH,{"data-slot":`alert-dialog`,...e})}function rH({...e}){return(0,V.jsx)(hp,{"data-slot":`alert-dialog-portal`,...e})}function iH({className:e,...t}){return(0,V.jsx)(ip,{"data-slot":`alert-dialog-overlay`,className:B(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function aH({className:e,size:t=`default`,...n}){return(0,V.jsxs)(rH,{children:[(0,V.jsx)(iH,{}),(0,V.jsx)(pp,{"data-slot":`alert-dialog-content`,"data-size":t,className:B(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function oH({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:B(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function sH({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:B(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function cH({className:e,...t}){return(0,V.jsx)(`div`,{"data-slot":`alert-dialog-media`,className:B(`mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6`,e),...t})}function lH({className:e,...t}){return(0,V.jsx)(Pp,{"data-slot":`alert-dialog-title`,className:B(`font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function uH({className:e,...t}){return(0,V.jsx)(op,{"data-slot":`alert-dialog-description`,className:B(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function dH({className:e,...t}){return(0,V.jsx)(Rr,{"data-slot":`alert-dialog-action`,className:B(e),...t})}function fH({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,V.jsx)(ap,{"data-slot":`alert-dialog-cancel`,className:B(e),render:(0,V.jsx)(Rr,{variant:t,size:n}),...r})}var pH=()=>$O(`/api/end`,{});function mH({open:e,unsent:t,openCount:n,onCancel:r,onEnded:i}){let a=lA(pH),o=a.pending,s=async()=>{await a.run()&&i()};return(0,V.jsx)(nH,{open:e,onOpenChange:e=>{!e&&!o&&r()},onOpenChangeComplete:e=>{e&&a.clearError()},children:(0,V.jsxs)(aH,{children:[(0,V.jsxs)(oH,{children:[(0,V.jsx)(cH,{className:`bg-destructive/10 text-destructive`,children:(0,V.jsx)(fe,{})}),(0,V.jsx)(lH,{children:`Stop the grill here?`}),(0,V.jsx)(uH,{children:`Claude gets everything you have locked in and wraps up in the terminal. This tab closes itself afterwards.`})]}),(t>0||n>0)&&(0,V.jsxs)(`ul`,{className:`space-y-1 rounded-lg bg-muted/60 px-3 py-2 text-sm text-muted-foreground`,children:[t>0&&(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground tabular-nums`,children:t}),` locked-in`,` `,t===1?`answer`:`answers`,` not sent yet, will be sent`]}),n>0&&(0,V.jsxs)(`li`,{children:[(0,V.jsx)(`span`,{className:`font-medium text-foreground tabular-nums`,children:n}),` `,n===1?`question`:`questions`,` still open, will stay unanswered`]})]}),a.error&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(Sm,{message:a.error,onRetry:()=>void s()}),(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`If the bridge is gone, there is nothing left to end.`,` `,(0,V.jsx)(Rr,{variant:`link`,className:`h-auto p-0`,onClick:i,children:`Close this tab anyway`})]})]}),(0,V.jsxs)(sH,{children:[(0,V.jsx)(fH,{disabled:o,children:`Keep grilling`}),(0,V.jsx)(dH,{variant:`destructive`,disabled:o,onClick:()=>void s(),children:(0,V.jsx)(uV,{pending:o,pendingLabel:`Ending…`,label:`End session`})})]})]})})}var hH=[{stage:`connecting`,active:`Connecting to your session`,done:`Connected to your session`},{stage:`reading`,active:`Claude is reading your request`}],gH={connecting:performance.timeOrigin},_H=``;function vH(e,t){if(_H!==`${e}:${t}`){_H=`${e}:${t}`;try{let t=JSON.parse(localStorage.getItem(Vu.warmUp)??`null`);if(t?.session===e)for(let[e,n]of Object.entries(t.reached))gH[e]=Math.min(gH[e]??n,n);localStorage.setItem(Vu.warmUp,JSON.stringify({session:e,reached:gH}))}catch{}}}var yH=[`M4.5 14Q6.7 11.8 8.7 13.1V17H4.5Z`,`M9.3 13.1Q12 11.1 14.7 13.1V17H9.3Z`,`M15.3 13.1Q17.3 11.8 19.5 14V17H15.3Z`],bH=`M4.5 11a7.5 5.5 0 0 0 15 0Z`,xH=[[34,-10,2.6,0],[46,8,2.2,.7],[58,-6,2.9,1.3],[66,12,2.4,.3],[40,14,3.1,1.9],[52,-14,2.7,2.4],[30,6,2.3,1.6],[62,-10,3.3,.9]],SH=900,CH=!1;function wH({stage:e,session:t,className:n}){let[r]=(0,O.useState)(()=>!CH),[i,a]=(0,O.useState)(CH);(0,O.useEffect)(()=>{if(CH=!0,i)return;let e=setTimeout(()=>a(!0),SH);return()=>clearTimeout(e)},[i]),gH[e]??=Date.now(),t!==void 0&&vH(t,e);let o=hH.findIndex(t=>t.stage===e);return(0,V.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:B(`flex w-full flex-col items-center text-center`,r&&`animate-in fill-mode-both fade-in-0 zoom-in-95 animation-duration-700`,n),children:[(0,V.jsxs)(`div`,{className:`relative size-40`,children:[(0,V.jsx)(`div`,{"aria-hidden":!0,className:B(`absolute -inset-8 transition-opacity duration-1000`,i?`opacity-100`:`opacity-0`),children:(0,V.jsx)(`div`,{className:`size-full bg-[radial-gradient(closest-side,color-mix(in_oklab,var(--primary)_28%,transparent),transparent)] motion-safe:animate-glow`})}),(0,V.jsx)(`div`,{"aria-hidden":!0,className:`absolute inset-x-0 top-[18%] h-[30%] motion-reduce:hidden`,children:i&&xH.map(([e,t,n,r])=>(0,V.jsx)(`span`,{className:`absolute bottom-0 size-1 rounded-full bg-primary animate-ember`,style:{left:`${e}%`,"--ember-drift":`${t}px`,animationDuration:`${n}s`,animationDelay:`${r}s`}},e))}),(0,V.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 24 24`,className:`absolute inset-0 size-full overflow-visible`,children:[(0,V.jsx)(`clipPath`,{id:`warm-up-bowl`,children:(0,V.jsx)(`path`,{d:bH})}),(0,V.jsx)(`g`,{clipPath:`url(#warm-up-bowl)`,children:yH.map((e,t)=>(0,V.jsx)(`path`,{d:e,className:`fill-primary`,style:{transformBox:`fill-box`,transformOrigin:`bottom`,animation:[r&&`ignite 500ms ease-out ${150+t*200}ms both`,`flicker ${2+t*.4}s ease-in-out ${r?700+t*200:0}ms infinite`].filter(Boolean).join(`, `)}},e))})]}),(0,V.jsx)(tn,{hot:i,strokeWidth:1.1,className:`absolute inset-0 size-full text-foreground`})]}),(0,V.jsx)(`h2`,{className:`mt-2 text-xl font-semibold tracking-tight`,children:`Firing up the grill`}),(0,V.jsxs)(`div`,{className:`mt-6 w-full max-w-md overflow-hidden rounded-xl border bg-card text-left shadow-sm`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b bg-muted/40 px-3 py-2`,children:[[0,1,2].map(e=>(0,V.jsx)(`span`,{className:`size-2 rounded-full bg-border`},e)),(0,V.jsx)(`span`,{className:`ml-2 font-mono text-[11px] text-muted-foreground`,children:`better-grill`})]}),(0,V.jsx)(`ol`,{className:`min-h-[4.375rem] space-y-1.5 px-3.5 py-3 font-mono text-xs`,children:hH.slice(0,o+1).map(({stage:e,...t},n)=>{let r=gH[e];if(r===void 0)return null;let i=hH.slice(n+1,o+1).find(e=>gH[e.stage]!==void 0),a=i&&gH[i.stage];return(0,V.jsxs)(`li`,{className:`flex min-h-5 items-center gap-3 animate-in fill-mode-both fade-in-0 slide-in-from-bottom-1 animation-duration-300`,children:[(0,V.jsx)(`time`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:EH(r)}),a===void 0?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ak,{className:`size-3 text-primary`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:[t.active,(0,V.jsx)(`span`,{className:`ml-1 inline-block h-3 w-1.5 translate-y-0.5 bg-primary motion-safe:animate-blink`})]}),(0,V.jsx)(TH,{since:r})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(te,{className:`size-3 shrink-0 text-success`}),(0,V.jsx)(`span`,{className:`min-w-0 flex-1 text-muted-foreground`,children:t.done}),(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:ZB(a-r)})]})]},e)})})]})]})}function TH({since:e}){let t=HV();return(0,V.jsx)(Yk,{variant:`outline`,className:`text-muted-foreground tabular-nums`,children:ZB(t-e)})}var EH=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1});function DH(){return(0,V.jsxs)(`div`,{className:`flex min-h-svh`,"aria-busy":!0,children:[(0,V.jsx)(`div`,{className:`hidden w-80 shrink-0 p-3 md:flex`,children:(0,V.jsxs)(`aside`,{className:`flex flex-1 flex-col rounded-xl bg-sidebar shadow-md ring-1 ring-sidebar-border`,children:[(0,V.jsxs)(`div`,{className:`flex h-12 items-center gap-2 border-b px-2`,children:[(0,V.jsx)(nn,{}),(0,V.jsx)(`span`,{className:`text-sm font-semibold tracking-tight`,children:`better grill`})]}),(0,V.jsx)(`div`,{className:`p-2`,children:[0,1,2].map(e=>(0,V.jsx)(fm,{showIcon:!0},e))})]})}),(0,V.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col pt-3 pr-3`,children:[(0,V.jsx)(`header`,{className:`h-12 shrink-0 rounded-xl border bg-background/80 shadow-md`}),(0,V.jsx)(`main`,{className:`grid flex-1 place-items-center px-4 pt-8 pb-[16svh]`,children:(0,V.jsx)(wH,{stage:`connecting`})})]})]})}function OH({state:e}){return(0,V.jsx)(wH,{stage:`reading`,session:e.startedAt})}function kH(){return(0,V.jsx)(Xk,{className:`animate-in fade-in-0 animation-duration-500`,children:(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{variant:`icon`,className:`size-10`,children:(0,V.jsx)(ge,{className:`size-5`})}),(0,V.jsx)(eA,{className:`text-base`,children:`No questions this time`}),(0,V.jsxs)(tA,{children:[`Run `,(0,V.jsx)(`code`,{className:`font-mono whitespace-nowrap text-foreground`,children:`/better-grill`}),` to start again.`]})]})})}function AH(e,t){return e.ended?{label:`Session closed`,dot:`bg-muted-foreground/50`}:t.status===`reconnecting`?{label:`Reconnecting`,dot:`bg-destructive`,ping:!0}:e.claude===`listening`?{label:`Claude listening`,dot:`bg-success`,ping:!0}:{label:`Claude thinking`,dot:`bg-primary animate-pulse`}}function jH({state:e,connection:t}){let{label:n,dot:r,ping:i}=AH(e,t);return(0,V.jsxs)(Yk,{variant:`outline`,className:`h-6 gap-2 px-2.5 text-muted-foreground`,children:[(0,V.jsxs)(`span`,{className:`relative flex size-2`,children:[i&&(0,V.jsx)(`span`,{className:B(`absolute inline-flex size-full animate-ping rounded-full opacity-60`,r)}),(0,V.jsx)(`span`,{className:B(`relative inline-flex size-2 rounded-full`,r)})]}),n]})}function MH({state:e,connection:t,onEnd:n,actions:r}){return(0,V.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 rounded-xl border bg-background/80 px-3 shadow-md backdrop-blur-md supports-backdrop-filter:bg-background/60`,children:[(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsx)($p,{})}),(0,V.jsxs)(Bu,{side:`bottom`,children:[`Toggle panel `,(0,V.jsx)(Tm,{hotkey:pm.toggleSidebar})]})]}),(0,V.jsx)(tp,{orientation:`vertical`,className:`h-4 data-vertical:self-center`}),(0,V.jsx)(`h1`,{className:`min-w-0 truncate text-sm font-medium`,children:e.title}),e.mode===`docs`&&(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsxs)(Yk,{variant:`outline`,className:`hidden text-muted-foreground sm:inline-flex`,children:[(0,V.jsx)(I,{"data-icon":`inline-start`}),`With docs`]})}),(0,V.jsx)(Bu,{side:`bottom`,children:`Claude records the glossary and ADRs as decisions settle`})]}),(0,V.jsx)(`div`,{className:`flex-1`}),(0,V.jsx)(jH,{state:e,connection:t}),!e.ended&&(0,V.jsxs)(Rr,{variant:`outline`,size:`sm`,onClick:n,children:[(0,V.jsx)(fe,{"data-icon":`inline-start`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`End session`})]}),r]})}function NH({connection:e}){return(0,V.jsx)(`div`,{className:`grid min-h-svh place-items-center bg-background px-4`,children:(0,V.jsxs)(Xk,{className:`animate-in fade-in-0 animation-duration-300`,children:[(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{className:`size-10 rounded-lg bg-destructive/10 text-destructive`,children:(0,V.jsx)(Xe,{className:`size-5`})}),(0,V.jsx)(eA,{className:`text-base`,children:`Can't reach this session`}),(0,V.jsxs)(tA,{children:[`It has probably ended. Run `,(0,V.jsx)(`code`,{className:`font-mono whitespace-nowrap text-foreground`,children:`/better-grill`}),` to start a new one.`]})]}),(0,V.jsxs)(nA,{children:[(0,V.jsxs)(Rr,{onClick:()=>window.location.reload(),children:[(0,V.jsx)(Pe,{"data-icon":`inline-start`}),`Retry`]}),(0,V.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Retrying automatically · attempt `,e.attempts]})]})]})})}function PH(e){let t=e.rounds.flatMap(t=>[...t.questionIds.filter(t=>e.questions[t]).map(e=>({key:vB.question(e),kind:`question`,id:e,round:t.number})),{key:vB.round(t.number),kind:`review`,round:t.number}]);return e.summary&&t.push({key:vB.summary,kind:`summary`}),t}var FH=e=>e.kind===`question`,IH=e=>t=>e.questions[t.id]?.status===`open`;function LH(e,t){return t.filter(FH).find(IH(e))??t.find(e=>e.kind===`summary`)??t.at(-1)}function RH(e,t,n){let r=t.filter(e=>e.kind!==`summary`&&e.round===n);return r.filter(FH).find(IH(e))??r.find(e=>e.kind===`review`)}function zH(e,t,n){let r=t.filter(FH),i=r.findIndex(e=>e.id===n),a=[...r.slice(i+1),...r.slice(0,Math.max(i,0))],o=r[i]?.round;return a.find(IH(e))??t.find(e=>e.kind===`review`&&e.round===o)}function BH(e){let[t,n]=(0,O.useState)(null),[r,i]=(0,O.useState)(null),a=e?PH(e):[],o=e?.rounds.length??0,s=!!e?.summary;if(e&&(r?.rounds!==o||r.summary!==s)){i({rounds:o,summary:s});let t=r?s&&!r.summary?a.find(e=>e.key===vB.summary):o>r.rounds?RH(e,a,o):void 0:LH(e,a);t&&n(t.key)}return{current:a.find(e=>e.key===t)??(e?LH(e,a):void 0),go:n,lockedIn:(0,O.useCallback)(t=>{if(!e)return;let r=zH(e,PH(e),t);n(e=>r&&(e===null||e===vB.question(t))?r.key:e)},[e])}}var VH=(e,t)=>$O(`/api/summary/respond`,{confirmed:e,text:t});function HH({summary:e,lock:t,onConfirmed:n}){let[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(``),[s,c]=(0,O.useState)(null),l=lA(VH),u=l.pending,d=async e=>{c(e),await l.run(e,e?void 0:a.trim()||void 0)&&(i(!1),o(``),e&&n())},f=e.status===`pending`&&!t;return(0,V.jsxs)(fV,{id:vB.summary,className:`scroll-mt-20 gap-5 pt-5 ring-primary/30 animate-in fade-in-0 slide-in-from-bottom-2 animation-duration-500`,children:[(0,V.jsxs)(pV,{className:`px-5 sm:px-6`,children:[(0,V.jsx)(`div`,{className:`mb-2 flex size-10 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,V.jsx)(le,{className:`size-5`})}),(0,V.jsx)(hV,{className:`font-medium text-primary`,children:`Shared understanding?`}),(0,V.jsx)(mV,{className:`text-2xl font-semibold tracking-tight`,children:`Here is what we settled`})]}),(0,V.jsxs)(gV,{className:`space-y-4 px-5 sm:px-6`,children:[(0,V.jsx)(dB,{className:`text-sm`,children:e.markdown}),e.status===`confirmed`&&(0,V.jsxs)(Of,{className:`border-success/30 bg-success/5 text-success`,children:[(0,V.jsx)(te,{}),(0,V.jsx)(Af,{className:`text-success`,children:`Confirmed. Claude takes it from here.`})]}),e.status===`rejected`&&(0,V.jsxs)(Of,{children:[(0,V.jsx)(Je,{}),(0,V.jsxs)(Af,{children:[`Sent back to Claude`,e.feedback?`: “${e.feedback}”`:`.`]})]}),e.status===`pending`&&t&&(0,V.jsxs)(lV,{children:[pA[t],` The summary can't be answered now.`]}),f&&r&&(0,V.jsx)(rA,{value:a,disabled:u,onChange:e=>{l.clearError(),o(e.target.value)},autoFocus:!0,rows:3,placeholder:`What is missing or wrong?`}),f&&l.error&&(0,V.jsx)(Sm,{message:l.error,onRetry:s===null?void 0:()=>void d(s),onDismiss:l.clearError})]}),f&&(0,V.jsx)(_V,{className:`flex-wrap gap-2 px-5 sm:px-6`,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Rr,{disabled:u||!a.trim(),onClick:()=>void d(!1),children:(0,V.jsx)(uV,{pending:u,pendingLabel:`Sending back…`,label:`Send back to Claude`})}),(0,V.jsx)(Rr,{variant:`ghost`,disabled:u,onClick:()=>i(!1),children:`Cancel`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(Rr,{disabled:u,onClick:()=>void d(!0),children:[!u&&(0,V.jsx)(te,{"data-icon":`inline-start`}),(0,V.jsx)(uV,{pending:u,pendingLabel:`Confirming…`,label:`Yes, that's it`})]}),(0,V.jsx)(Rr,{variant:`outline`,disabled:u,onClick:()=>i(!0),children:`Not yet`})]})})]})}var UH=(e,t)=>$O(`/api/questions/${e}/visualize`,t),WH=new Map;function GH(e,t){let n=`${e}@${t}`,r=WH.get(n);return r||(r=ek(`/api/questions/${e}/visualization`),r.catch(()=>WH.delete(n)),WH.set(n,r)),r}function KH(e,t){let[n,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(null),[o,s]=(0,O.useState)(0);return(0,O.useEffect)(()=>{if(t===0)return;let n=!0;return a(null),GH(e,t).then(e=>n&&r(e.html),e=>n&&a(e instanceof Error?e.message:String(e))),()=>{n=!1}},[e,t,o]),{html:t===0?null:n,error:i,retry:()=>s(e=>e+1)}}var qH=`better-grill:size`,JH=2e4,YH=[`default-src 'none'`,`script-src 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net`,`style-src 'unsafe-inline'`,`img-src data: blob:`,`media-src data: blob:`,`font-src data:`,`connect-src 'none'`,`form-action 'none'`,`base-uri 'none'`].join(`; `),XH={"--background":`--card`,"--foreground":`--card-foreground`,"--card":`--popover`,"--muted":`--muted`,"--muted-foreground":`--muted-foreground`,"--border":`--border`,"--primary":`--primary`,"--primary-foreground":`--primary-foreground`,"--success":`--success`,"--destructive":`--destructive`,"--series-1":`--series-1`,"--series-2":`--series-2`,"--series-3":`--series-3`,"--series-4":`--series-4`,"--series-5":`--series-5`,"--radius":`--radius`},ZH=`--font-sans: "Geist Variable", ui-sans-serif, system-ui, sans-serif; --font-mono: "Geist Mono Variable", ui-monospace, monospace;`,QH=`(() => {
51
51
  let last = -1;
52
52
  const post = () => {
53
53
  const body = document.body;
@@ -83,4 +83,4 @@ img, svg, video, canvas { max-width: 100%; }
83
83
  <body>
84
84
  ${e}
85
85
  </body>
86
- </html>`}var tU=`modulepreload`,nU=function(e){return`/`+e},rU={},iU=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}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=nU(t,n),t=s(t),t in rU)return;rU[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:tU,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}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)})},aU,oU=()=>aU??=iU(()=>import(`./fonts-CJmUTqBe.js`).then(e=>e.FONT_FACES),[]);function sU({html:e,title:t,className:n}){let{resolved:r}=Ju(),i=(0,O.useRef)(null),[a,o]=(0,O.useState)(null),[s,c]=(0,O.useState)(null);return(0,O.useEffect)(()=>{let t=!0;return oU().then(n=>{t&&o(eU({fragment:e,theme:r,tokens:$H(),fontFaces:n}))}),()=>{t=!1}},[e,r]),(0,O.useEffect)(()=>{let e=e=>{if(e.source!==i.current?.contentWindow)return;let t=e.data;t?.type===`better-grill:size`&&typeof t.height==`number`&&Number.isFinite(t.height)&&c(Math.min(Math.max(Math.round(t.height),0),JH))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),(0,V.jsxs)(`div`,{className:B(`relative`,n),children:[s===null&&(0,V.jsx)(`div`,{className:`grid h-48 place-items-center`,children:(0,V.jsx)(Ak,{className:`size-5 text-muted-foreground`})}),a&&(0,V.jsx)(`iframe`,{ref:i,title:t,srcDoc:a,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,style:s===null?void 0:{height:s},className:B(`block w-full border-0`,s===null&&`pointer-events-none absolute inset-0 h-48 opacity-0`)})]})}function cU({question:e,lock:t,actionsSlot:n,actions:r}){let i=e.visualization,a=i?.version??0,o=i?.status===`pending`,s=KH(e.id,a),c=!!i?.readyAt&&!!e.editedAt&&e.editedAt>i.readyAt,l=(0,V.jsxs)(fV,{className:`relative gap-5 pt-5 shadow-xs`,children:[(0,V.jsxs)(pV,{className:`grid-cols-1 gap-2 px-5 sm:px-6`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(Yk,{className:`font-mono`,children:e.id}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Visualization`}),o&&a>0&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(Ak,{"data-icon":`inline-start`}),`Regenerating`]}),c&&(0,V.jsxs)(Yk,{variant:`secondary`,children:[(0,V.jsx)(Ke,{"data-icon":`inline-start`}),`Made before Claude's last edit`]})]}),(0,V.jsx)(mV,{className:`text-xl font-semibold tracking-tight text-balance`,children:e.title})]}),(0,V.jsxs)(gV,{className:`grid grid-cols-1 gap-4 px-5 sm:px-6`,children:[a>0?s.html===null?s.error?(0,V.jsx)(Sm,{message:s.error,onRetry:s.retry}):(0,V.jsx)(`div`,{className:`grid h-48 place-items-center`,children:(0,V.jsx)(Ak,{className:`size-5 text-muted-foreground`})}):(0,V.jsx)(sU,{html:s.html,title:`Visualization of ${e.id}: ${e.title}`}):o?(0,V.jsx)(lU,{since:i.requestedAt,note:i.note,lock:t}):i?.status===`failed`?null:(0,V.jsxs)(Xk,{className:`border`,children:[(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{variant:`icon`,children:(0,V.jsx)(Be,{})}),(0,V.jsx)(eA,{children:`No visualization yet`}),(0,V.jsx)(tA,{children:`Claude visualizes the question right here, so it's easier to understand. It takes a minute or two, and you can keep answering meanwhile.`})]}),(0,V.jsx)(nA,{className:`max-w-md`,children:(0,V.jsx)(uU,{question:e,lock:t,label:`Visualize`})})]}),i?.status===`failed`&&(0,V.jsxs)(Of,{children:[(0,V.jsx)(ie,{}),(0,V.jsx)(kf,{children:`No visualization for this one`}),(0,V.jsx)(Af,{children:i.reason})]}),(a>0||i?.status===`failed`)&&!o&&(0,V.jsx)(uU,{question:e,lock:t,label:a>0?`Regenerate`:`Try again`,className:`border-t pt-4`})]})]});return n?(0,V.jsxs)(V.Fragment,{children:[l,(0,V.jsxs)(dV,{slot:n,children:[r,(0,V.jsx)(`div`,{className:`flex-1`}),t&&(0,V.jsx)(lV,{children:pA[t]})]})]}):l}function lU({since:e,note:t,lock:n}){let r=HV();return(0,V.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`grid gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-dashed px-4 py-3 font-mono text-xs`,children:[(0,V.jsx)(Ak,{className:`size-4 text-primary`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:[`Claude is visualizing this question`,(0,V.jsx)(`span`,{className:`ml-1 inline-block h-3 w-1.5 translate-y-0.5 bg-primary motion-safe:animate-blink`})]}),(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:ZB(r-e)})]}),t&&(0,V.jsxs)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:[`You asked: `,t]}),n===`offline`&&(0,V.jsx)(lV,{className:`px-1 text-destructive`,children:`Bridge unreachable. The visualization shows up once it reconnects.`})]})}function uU({question:e,lock:t,label:n,className:r}){let[i,a]=(0,O.useState)(``),o=lA(UH),s=!!t||o.pending,c=async t=>{t.preventDefault(),!s&&await o.run(e.id,{note:i.trim()||void 0})&&a(``)};return(0,V.jsxs)(`form`,{onSubmit:e=>void c(e),className:B(`grid w-full gap-2`,r),children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)($f,{value:i,onChange:e=>{o.clearError(),a(e.target.value)},disabled:s,maxLength:2e3,"aria-label":`What the visualization should show`,placeholder:n===`Regenerate`?`What should change? (optional)`:`What to focus on (optional)`,className:`min-w-48 flex-1`}),(0,V.jsx)(Rr,{type:`submit`,variant:n===`Visualize`?`default`:`outline`,disabled:s,children:(0,V.jsx)(uV,{pending:o.pending,label:n,pendingLabel:`Asking…`})})]}),o.error&&(0,V.jsx)(Sm,{message:o.error,onDismiss:o.clearError})]})}function dU({active:e,working:t,unseen:n,onClick:r,hotkey:i}){return(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsxs)(Rr,{variant:e?`secondary`:`outline`,onClick:r,"aria-pressed":e,className:B(`relative`,e&&`border-primary/40 bg-primary/10 text-primary hover:bg-primary/15`),children:[t?(0,V.jsx)(Ak,{"data-icon":`inline-start`}):(0,V.jsx)(Be,{"data-icon":`inline-start`}),`Visualization`,n&&!e&&(0,V.jsxs)(`span`,{className:`absolute -top-1 -right-1 flex size-2.5`,children:[(0,V.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-primary opacity-60`}),(0,V.jsx)(`span`,{className:`relative inline-flex size-2.5 rounded-full bg-primary ring-2 ring-background`})]})]})}),(0,V.jsxs)(Bu,{children:[e?`Back to the question`:t?`Claude is visualizing it`:`Show the visualization`,` `,(0,V.jsx)(Tm,{hotkey:i})]})]})}function fU(e){let[t,n]=(0,O.useState)({}),[r,i]=(0,O.useState)({}),a=(0,O.useCallback)(e=>!!t[e],[t]),o=(0,O.useCallback)(e=>n(t=>({...t,[e]:!t[e]})),[]),s=e&&t[e.id]?e.id:null,c=e?.visualization?.version??0;return(0,O.useEffect)(()=>{s&&i(e=>e[s]===c?e:{...e,[s]:c})},[s,c]),{showing:a,toggle:o,unseen:(0,O.useCallback)(e=>(e.visualization?.version??0)>(r[e.id]??0),[r])}}function pU(e,t){let[n,r]=(0,O.useState)(e);return e!==null&&e!==n&&r(e),(0,O.useEffect)(()=>{if(e!==null)return;let n=setTimeout(()=>r(null),t);return()=>clearTimeout(n)},[e,t]),e??n}function mU(){let{state:e,connection:t}=KV(),[n,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(null),[c,l]=Wu(Vu.sidebarOpen,!0),[u,d]=(0,O.useState)(null),f=n?e?.questions[n]:void 0,p=pU(n,200),m=p?e?.questions[p]:void 0,h=(0,O.useCallback)(()=>r(null),[]),g=gB(f),{current:_,go:v,lockedIn:y}=BH(e),b=_?.kind===`question`?_.id:null,x=b?e?.questions[b]:void 0,S=fU(x);if((0,O.useEffect)(()=>{b&&r(e=>e&&e!==b?b:e)},[b]),Ef(pm.discuss,()=>r(e=>b&&e!==b?b:null)),Ef(pm.visualize,()=>b&&S.toggle(b),{enabled:!!x&&x.status!==`dropped`}),(0,O.useEffect)(()=>{window.scrollTo({top:0}),TV()},[_?.key]),!e)return t.status===`reconnecting`&&t.attempts>=2?(0,V.jsx)(NH,{connection:t}):(0,V.jsx)(DH,{});let C=fA(e,t),w=mA(Object.values(e.questions)),T=_?.kind===`summary`?void 0:e.rounds.find(e=>e.number===_?.round),E=_?.kind===`question`,D=_?.kind===`review`&&T===e.rounds.at(-1)?gA(e):[],k=e=>({question:e,discussing:n===e.id,unread:g(e),onDiscuss:()=>r(t=>t===e.id?null:e.id)}),A=t=>{let n=e.questions[t];if(!n)return null;let r=S.showing(t)&&n.status!==`dropped`,{discussing:i,unread:a,onDiscuss:o}=k(n),s=(0,V.jsx)(dU,{active:r,working:n.visualization?.status===`pending`,unseen:S.unseen(n),onClick:()=>S.toggle(t),hotkey:pm.visualize});return(0,V.jsxs)(Br,{fallback:(e,n)=>(0,V.jsx)(jf,{what:`Question ${t}`,error:e,onReset:n}),children:[(0,V.jsx)(`div`,{hidden:r,children:(0,V.jsx)(IV,{...k(n),lock:C,onLockedIn:()=>y(t),actionsSlot:r?null:u,extraActions:s,hidden:r})}),(r||n.visualization)&&(0,V.jsx)(`div`,{hidden:!r,children:(0,V.jsx)(cU,{question:n,lock:C,actionsSlot:r?u:null,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(aV,{count:n.chat.length,unread:a,active:i,onClick:o,hotkey:pm.discuss}),s]})})})]},`${t}-${n.editedAt??0}`)},j=t=>{let n=e.questions[t];return n?(0,V.jsx)(Br,{fallback:(e,n)=>(0,V.jsx)(jf,{what:`Question ${t}`,error:e,onReset:n}),children:(0,V.jsx)(LV,{...k(n),onOpen:()=>v(vB.question(t))})},t):null};return(0,V.jsxs)(Zp,{open:c,onOpenChange:l,style:{"--sidebar-width":`var(--app-sidebar-w, 20rem)`},children:[(0,V.jsx)(nV,{state:e,current:_?.key??null,onJump:v,chatFor:n,unread:g,onOpenChat:r}),(0,V.jsxs)(em,{className:B(`min-w-0 bg-transparent pr-3 transition-[padding] duration-200 ease-linear`,f&&`pr-[calc(var(--chat-w)+0.75rem)]`),children:[(0,V.jsxs)(`div`,{className:`pointer-events-none sticky top-0 z-30 space-y-2 pt-3 *:pointer-events-auto before:absolute before:inset-x-0 before:top-0 before:h-3 before:canvas`,children:[(0,V.jsx)(MH,{state:e,connection:t,onEnd:()=>a(!0),actions:(0,V.jsx)(GV,{state:e,lock:C,onJump:v})}),(0,V.jsx)(QV,{state:e,connection:t})]}),e.rounds.length===0?(0,V.jsx)(`div`,{className:`grid flex-1 place-items-center px-4 pt-8 pb-[16svh]`,children:e.ended?(0,V.jsx)(kH,{}):(0,V.jsx)(OH,{state:e})}):(0,V.jsx)(`div`,{className:B(`px-8 pt-8`,E?`flex flex-1 flex-col pb-3`:`pb-32`),children:(0,V.jsxs)(`div`,{className:B(`mx-auto max-w-3xl`,E&&`flex w-full flex-1 flex-col`),children:[_&&(0,V.jsxs)(`div`,{className:`mb-6 animate-in fill-mode-both fade-in-0 slide-in-from-bottom-2 animation-duration-300`,children:[_.kind===`summary`&&e.summary&&(0,V.jsx)(Br,{fallback:(e,t)=>(0,V.jsx)(jf,{what:`Summary`,error:e,onReset:t}),children:(0,V.jsx)(HH,{summary:e.summary,lock:C,onConfirmed:()=>s(`Summary confirmed`)})}),T&&_.kind!==`summary`&&(0,V.jsx)(zV,{round:T,questions:hA(e,T.questionIds),review:_.kind===`review`,children:_.kind===`question`?A(_.id):T.questionIds.map(j)}),D.length>0&&(0,V.jsx)(sV,{children:D.map(e=>j(e.id))})]},_.key),(0,V.jsx)(WV,{state:e,lock:C,onJump:v,showBar:_?.kind===`review`}),E&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{"aria-hidden":!0,className:`min-h-20 flex-1`}),(0,V.jsx)(`div`,{ref:d,className:`sticky bottom-3 z-20`})]})]})})]}),(0,V.jsx)(bm,{open:!!f,children:m&&(0,V.jsx)(Br,{fallback:(e,t)=>(0,V.jsx)(`div`,{className:`h-full bg-background p-4`,children:(0,V.jsx)(jf,{what:`Discussion`,error:e,onReset:t})}),children:(0,V.jsx)(hB,{question:m,lock:C,claude:e.claude,onClose:h})},m.id)}),(0,V.jsx)(mH,{open:i,unsent:w.filter(e=>e.status===`answered`&&!e.answer?.sent).length,openCount:w.filter(e=>e.status===`open`).length,onCancel:()=>a(!1),onEnded:()=>{a(!1),s(`Session ended`)}}),o&&(0,V.jsx)(ZV,{title:o})]})}function hU(){return(0,V.jsx)(Yu,{children:(0,V.jsx)(mU,{})})}(0,$e.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(O.StrictMode,{children:(0,V.jsx)(hU,{})}));
86
+ </html>`}var tU=`modulepreload`,nU=function(e){return`/`+e},rU={},iU=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}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=nU(t,n),t=s(t),t in rU)return;rU[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:tU,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}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)})},aU,oU=()=>aU??=iU(()=>import(`./fonts-CJmUTqBe.js`).then(e=>e.FONT_FACES),[]);function sU({html:e,title:t,className:n}){let{resolved:r}=Ju(),i=(0,O.useRef)(null),[a,o]=(0,O.useState)(null),[s,c]=(0,O.useState)(null);return(0,O.useEffect)(()=>{let t=!0;return oU().then(n=>{if(!t)return;let i=eU({fragment:e,theme:r,tokens:$H(),fontFaces:n});o(e=>({srcDoc:i,build:(e?.build??0)+1}))}),()=>{t=!1}},[e,r]),(0,O.useEffect)(()=>{let e=e=>{if(e.source!==i.current?.contentWindow)return;let t=e.data;t?.type===`better-grill:size`&&typeof t.height==`number`&&Number.isFinite(t.height)&&c(Math.min(Math.max(Math.round(t.height),0),JH))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),(0,V.jsxs)(`div`,{className:B(`relative`,n),children:[s===null&&(0,V.jsx)(`div`,{className:`grid h-48 place-items-center`,children:(0,V.jsx)(Ak,{className:`size-5 text-muted-foreground`})}),a&&(0,V.jsx)(`iframe`,{ref:i,title:t,srcDoc:a.srcDoc,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,style:s===null?void 0:{height:s},className:B(`block w-full border-0`,s===null&&`pointer-events-none absolute inset-0 h-48 opacity-0`)},a.build)]})}function cU({question:e,lock:t,actionsSlot:n,actions:r}){let i=e.visualization,a=i?.version??0,o=i?.status===`pending`,s=KH(e.id,a),c=!!i?.readyAt&&!!e.editedAt&&e.editedAt>i.readyAt,l=(0,V.jsxs)(fV,{className:`relative gap-5 pt-5 shadow-xs`,children:[(0,V.jsxs)(pV,{className:`grid-cols-1 gap-2 px-5 sm:px-6`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(Yk,{className:`font-mono`,children:e.id}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Visualization`}),o&&a>0&&(0,V.jsxs)(Yk,{variant:`secondary`,className:`bg-primary/10 text-primary`,children:[(0,V.jsx)(Ak,{"data-icon":`inline-start`}),`Regenerating`]}),c&&(0,V.jsxs)(Yk,{variant:`secondary`,children:[(0,V.jsx)(Ke,{"data-icon":`inline-start`}),`Made before Claude's last edit`]})]}),(0,V.jsx)(mV,{className:`text-xl font-semibold tracking-tight text-balance`,children:e.title})]}),(0,V.jsxs)(gV,{className:`grid grid-cols-1 gap-4 px-5 sm:px-6`,children:[a>0?s.html===null?s.error?(0,V.jsx)(Sm,{message:s.error,onRetry:s.retry}):(0,V.jsx)(`div`,{className:`grid h-48 place-items-center`,children:(0,V.jsx)(Ak,{className:`size-5 text-muted-foreground`})}):(0,V.jsx)(sU,{html:s.html,title:`Visualization of ${e.id}: ${e.title}`}):o?(0,V.jsx)(lU,{since:i.requestedAt,note:i.note,lock:t}):i?.status===`failed`?null:(0,V.jsxs)(Xk,{className:`border`,children:[(0,V.jsxs)(Zk,{children:[(0,V.jsx)($k,{variant:`icon`,children:(0,V.jsx)(Be,{})}),(0,V.jsx)(eA,{children:`No visualization yet`}),(0,V.jsx)(tA,{children:`Claude visualizes the question right here, so it's easier to understand. It takes a minute or two, and you can keep answering meanwhile.`})]}),(0,V.jsx)(nA,{className:`max-w-md`,children:(0,V.jsx)(uU,{question:e,lock:t,label:`Visualize`})})]}),i?.status===`failed`&&(0,V.jsxs)(Of,{children:[(0,V.jsx)(ie,{}),(0,V.jsx)(kf,{children:`No visualization for this one`}),(0,V.jsx)(Af,{children:i.reason})]}),(a>0||i?.status===`failed`)&&!o&&(0,V.jsx)(uU,{question:e,lock:t,label:a>0?`Regenerate`:`Try again`,className:`border-t pt-4`})]})]});return n?(0,V.jsxs)(V.Fragment,{children:[l,(0,V.jsxs)(dV,{slot:n,children:[r,(0,V.jsx)(`div`,{className:`flex-1`}),t&&(0,V.jsx)(lV,{children:pA[t]})]})]}):l}function lU({since:e,note:t,lock:n}){let r=HV();return(0,V.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`grid gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-dashed px-4 py-3 font-mono text-xs`,children:[(0,V.jsx)(Ak,{className:`size-4 text-primary`}),(0,V.jsxs)(`span`,{className:`min-w-0 flex-1 text-foreground`,children:[`Claude is visualizing this question`,(0,V.jsx)(`span`,{className:`ml-1 inline-block h-3 w-1.5 translate-y-0.5 bg-primary motion-safe:animate-blink`})]}),(0,V.jsx)(`span`,{className:`shrink-0 text-muted-foreground tabular-nums`,children:ZB(r-e)})]}),t&&(0,V.jsxs)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:[`You asked: `,t]}),n===`offline`&&(0,V.jsx)(lV,{className:`px-1 text-destructive`,children:`Bridge unreachable. The visualization shows up once it reconnects.`})]})}function uU({question:e,lock:t,label:n,className:r}){let[i,a]=(0,O.useState)(``),o=lA(UH),s=!!t||o.pending,c=async t=>{t.preventDefault(),!s&&await o.run(e.id,{note:i.trim()||void 0})&&a(``)};return(0,V.jsxs)(`form`,{onSubmit:e=>void c(e),className:B(`grid w-full gap-2`,r),children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)($f,{value:i,onChange:e=>{o.clearError(),a(e.target.value)},disabled:s,maxLength:2e3,"aria-label":`What the visualization should show`,placeholder:n===`Regenerate`?`What should change? (optional)`:`What to focus on (optional)`,className:`min-w-48 flex-1`}),(0,V.jsx)(Rr,{type:`submit`,variant:n===`Visualize`?`default`:`outline`,disabled:s,children:(0,V.jsx)(uV,{pending:o.pending,label:n,pendingLabel:`Asking…`})})]}),o.error&&(0,V.jsx)(Sm,{message:o.error,onDismiss:o.clearError})]})}function dU({active:e,working:t,unseen:n,onClick:r,hotkey:i}){return(0,V.jsxs)(Ru,{children:[(0,V.jsx)(zu,{render:(0,V.jsxs)(Rr,{variant:e?`secondary`:`outline`,onClick:r,"aria-pressed":e,className:B(`relative`,e&&`border-primary/40 bg-primary/10 text-primary hover:bg-primary/15`),children:[t?(0,V.jsx)(Ak,{"data-icon":`inline-start`}):(0,V.jsx)(Be,{"data-icon":`inline-start`}),`Visualization`,n&&!e&&(0,V.jsxs)(`span`,{className:`absolute -top-1 -right-1 flex size-2.5`,children:[(0,V.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-primary opacity-60`}),(0,V.jsx)(`span`,{className:`relative inline-flex size-2.5 rounded-full bg-primary ring-2 ring-background`})]})]})}),(0,V.jsxs)(Bu,{children:[e?`Back to the question`:t?`Claude is visualizing it`:`Show the visualization`,` `,(0,V.jsx)(Tm,{hotkey:i})]})]})}function fU(e){let[t,n]=(0,O.useState)({}),[r,i]=(0,O.useState)({}),a=(0,O.useCallback)(e=>!!t[e],[t]),o=(0,O.useCallback)(e=>n(t=>({...t,[e]:!t[e]})),[]),s=e&&t[e.id]?e.id:null,c=e?.visualization?.version??0;return(0,O.useEffect)(()=>{s&&i(e=>e[s]===c?e:{...e,[s]:c})},[s,c]),{showing:a,toggle:o,unseen:(0,O.useCallback)(e=>(e.visualization?.version??0)>(r[e.id]??0),[r])}}function pU(e,t){let[n,r]=(0,O.useState)(e);return e!==null&&e!==n&&r(e),(0,O.useEffect)(()=>{if(e!==null)return;let n=setTimeout(()=>r(null),t);return()=>clearTimeout(n)},[e,t]),e??n}function mU(){let{state:e,connection:t}=KV(),[n,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(!1),[o,s]=(0,O.useState)(null),[c,l]=Wu(Vu.sidebarOpen,!0),[u,d]=(0,O.useState)(null),f=n?e?.questions[n]:void 0,p=pU(n,200),m=p?e?.questions[p]:void 0,h=(0,O.useCallback)(()=>r(null),[]),g=gB(f),{current:_,go:v,lockedIn:y}=BH(e),b=_?.kind===`question`?_.id:null,x=b?e?.questions[b]:void 0,S=fU(x);if((0,O.useEffect)(()=>{b&&r(e=>e&&e!==b?b:e)},[b]),Ef(pm.discuss,()=>r(e=>b&&e!==b?b:null)),Ef(pm.visualize,()=>b&&S.toggle(b),{enabled:!!x&&x.status!==`dropped`}),(0,O.useEffect)(()=>{window.scrollTo({top:0}),TV()},[_?.key]),!e)return t.status===`reconnecting`&&t.attempts>=2?(0,V.jsx)(NH,{connection:t}):(0,V.jsx)(DH,{});let C=fA(e,t),w=mA(Object.values(e.questions)),T=_?.kind===`summary`?void 0:e.rounds.find(e=>e.number===_?.round),E=_?.kind===`question`,D=_?.kind===`review`&&T===e.rounds.at(-1)?gA(e):[],k=e=>({question:e,discussing:n===e.id,unread:g(e),onDiscuss:()=>r(t=>t===e.id?null:e.id)}),A=t=>{let n=e.questions[t];if(!n)return null;let r=S.showing(t)&&n.status!==`dropped`,{discussing:i,unread:a,onDiscuss:o}=k(n),s=(0,V.jsx)(dU,{active:r,working:n.visualization?.status===`pending`,unseen:S.unseen(n),onClick:()=>S.toggle(t),hotkey:pm.visualize});return(0,V.jsxs)(Br,{fallback:(e,n)=>(0,V.jsx)(jf,{what:`Question ${t}`,error:e,onReset:n}),children:[(0,V.jsx)(`div`,{hidden:r,children:(0,V.jsx)(IV,{...k(n),lock:C,onLockedIn:()=>y(t),actionsSlot:r?null:u,extraActions:s,hidden:r})}),(r||n.visualization)&&(0,V.jsx)(`div`,{hidden:!r,children:(0,V.jsx)(cU,{question:n,lock:C,actionsSlot:r?u:null,actions:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(aV,{count:n.chat.length,unread:a,active:i,onClick:o,hotkey:pm.discuss}),s]})})})]},`${t}-${n.editedAt??0}`)},j=t=>{let n=e.questions[t];return n?(0,V.jsx)(Br,{fallback:(e,n)=>(0,V.jsx)(jf,{what:`Question ${t}`,error:e,onReset:n}),children:(0,V.jsx)(LV,{...k(n),onOpen:()=>v(vB.question(t))})},t):null};return(0,V.jsxs)(Zp,{open:c,onOpenChange:l,style:{"--sidebar-width":`var(--app-sidebar-w, 20rem)`},children:[(0,V.jsx)(nV,{state:e,current:_?.key??null,onJump:v,chatFor:n,unread:g,onOpenChat:r}),(0,V.jsxs)(em,{className:B(`min-w-0 bg-transparent pr-3 transition-[padding] duration-200 ease-linear`,f&&`pr-[calc(var(--chat-w)+0.75rem)]`),children:[(0,V.jsxs)(`div`,{className:`pointer-events-none sticky top-0 z-30 space-y-2 pt-3 *:pointer-events-auto before:absolute before:inset-x-0 before:top-0 before:h-3 before:canvas`,children:[(0,V.jsx)(MH,{state:e,connection:t,onEnd:()=>a(!0),actions:(0,V.jsx)(GV,{state:e,lock:C,onJump:v})}),(0,V.jsx)(QV,{state:e,connection:t})]}),e.rounds.length===0?(0,V.jsx)(`div`,{className:`grid flex-1 place-items-center px-4 pt-8 pb-[16svh]`,children:e.ended?(0,V.jsx)(kH,{}):(0,V.jsx)(OH,{state:e})}):(0,V.jsx)(`div`,{className:B(`px-8 pt-8`,E?`flex flex-1 flex-col pb-3`:`pb-32`),children:(0,V.jsxs)(`div`,{className:B(`mx-auto max-w-3xl`,E&&`flex w-full flex-1 flex-col`),children:[_&&(0,V.jsxs)(`div`,{className:`mb-6 animate-in fill-mode-both fade-in-0 slide-in-from-bottom-2 animation-duration-300`,children:[_.kind===`summary`&&e.summary&&(0,V.jsx)(Br,{fallback:(e,t)=>(0,V.jsx)(jf,{what:`Summary`,error:e,onReset:t}),children:(0,V.jsx)(HH,{summary:e.summary,lock:C,onConfirmed:()=>s(`Summary confirmed`)})}),T&&_.kind!==`summary`&&(0,V.jsx)(zV,{round:T,questions:hA(e,T.questionIds),review:_.kind===`review`,children:_.kind===`question`?A(_.id):T.questionIds.map(j)}),D.length>0&&(0,V.jsx)(sV,{children:D.map(e=>j(e.id))})]},_.key),(0,V.jsx)(WV,{state:e,lock:C,onJump:v,showBar:_?.kind===`review`}),E&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{"aria-hidden":!0,className:`min-h-20 flex-1`}),(0,V.jsx)(`div`,{ref:d,className:`sticky bottom-3 z-20`})]})]})})]}),(0,V.jsx)(bm,{open:!!f,children:m&&(0,V.jsx)(Br,{fallback:(e,t)=>(0,V.jsx)(`div`,{className:`h-full bg-background p-4`,children:(0,V.jsx)(jf,{what:`Discussion`,error:e,onReset:t})}),children:(0,V.jsx)(hB,{question:m,lock:C,claude:e.claude,onClose:h})},m.id)}),(0,V.jsx)(mH,{open:i,unsent:w.filter(e=>e.status===`answered`&&!e.answer?.sent).length,openCount:w.filter(e=>e.status===`open`).length,onCancel:()=>a(!1),onEnded:()=>{a(!1),s(`Session ended`)}}),o&&(0,V.jsx)(ZV,{title:o})]})}function hU(){return(0,V.jsx)(Yu,{children:(0,V.jsx)(mU,{})})}(0,$e.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(O.StrictMode,{children:(0,V.jsx)(hU,{})}));
@@ -13,7 +13,7 @@
13
13
  document.documentElement.classList.toggle("dark", dark);
14
14
  } catch {}
15
15
  </script>
16
- <script type="module" crossorigin src="/assets/index-DQsP0Vpp.js"></script>
16
+ <script type="module" crossorigin src="/assets/index-DitML0ry.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-B5A56OtT.css">
18
18
  </head>
19
19
  <body>