@buoy-gg/ask-buoy 7.0.63 → 7.0.64

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 +1 @@
1
- "use strict";import{useState as z}from"react";import{Image as T,Pressable as w,StyleSheet as R,Text as c,View as d}from"react-native";import{AlertTriangle as A,Check as M,Info as k,night as i,X as F}from"@buoy-gg/shared-ui";import{DataViewer as W,TreeDiffViewer as j}from"@buoy-gg/shared-ui/dataViewer";import{CAPS as x}from"@buoy-gg/agent-core";import{ActionRow as H,blockStyles as h,Card as g,More as D,toneColor as S,useBlockHandlers as B,usePaged as I}from"./primitivesIndex";import{renderInline as C}from"../components/Markdown";import{useCopyAction as N}from"../components/useCopyAction";import{blockToText as J}from"./blockText";import{BlockIcon as E}from"./icons";import{jsx as t,jsxs as u,Fragment as K}from"react/jsx-runtime";function $(e){if(e===void 0)return"\u2014";if(e===null)return"null";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);try{const o=JSON.stringify(e);return o.length>120?`${o.slice(0,117)}\u2026`:o}catch{return String(e)}}export function Table({block:e}){const o=I(e.rows,x.tableRows);const{visible:r}=o;const a=e.columns.slice(0,4);return u(g,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[t(d,{style:n.tableHead,children:a.map((f,s)=>t(c,{style:[n.th,s===0&&n.firstCol],numberOfLines:1,children:f},f))}),r.map((f,s)=>t(d,{style:[n.tr,s>0&&h.rowDivider],children:a.map((l,y)=>{const p=f[y];const b=typeof p==="string"?p:p?.text??"";const m=typeof p==="string"?void 0:p?.tone;return t(c,{style:[n.td,y===0&&n.firstCol,y===0&&n.tdFirst,m&&{color:S(m)}],numberOfLines:2,children:C(b,n.td)},y)})},s)),t(D,{paged:o})]})}export function KeyValue({block:e}){const o=I(e.pairs,x.keyValuePairs);const{visible:r}=o;const[a,f]=z(null);return u(g,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[r.map((s,l)=>{const y=typeof s.value==="object"&&s.value!==null;const p=a===s.key;return u(w,{onPress:y?()=>f(p?null:s.key):void 0,style:[n.kvRow,l>0&&h.rowDivider],children:[t(c,{style:n.kvKey,numberOfLines:1,children:s.key}),t(c,{style:[n.kvValue,p&&h.mono],numberOfLines:p?void 0:2,selectable:true,children:p?JSON.stringify(s.value,null,2):$(s.value)})]},s.key)}),t(D,{paged:o})]})}export function listRowBehaviour(e){const o=Boolean(e.image);return{canExpand:o,rowRunsAction:Boolean(e.action)&&!o,actionIsOwnControl:Boolean(e.action)&&o}}export function List({block:e}){const o=B();const r=I(e.items,x.listItems);const{visible:a}=r;const[f,s]=z(null);return u(g,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[a.map((l,y)=>{const p=`${l.id??l.title}-${y}`;const b=f===p;const{canExpand:m,rowRunsAction:v,actionIsOwnControl:V}=listRowBehaviour(l);const O=m||v?w:d;const P=m?{onPress:()=>s(b?null:p),accessibilityRole:"button",accessibilityState:{expanded:b},accessibilityLabel:`${l.title}, ${b?"hide":"show"} picture`,testID:`buoy-block-list-row-${p}`}:v?{onPress:()=>void o.runAction(l.action,e.id),accessibilityRole:"button"}:{};return u(d,{style:y>0?h.rowDivider:void 0,children:[b&&l.image?t(w,{onPress:()=>s(null),accessibilityRole:"button",accessibilityLabel:`Hide ${l.title}`,testID:`buoy-block-list-hero-${p}`,style:n.listHero,children:t(T,{testID:"buoy-internal-chat-image",source:{uri:l.image},style:n.listHeroImage,resizeMode:"contain",accessibilityLabel:l.title})}):null,u(O,{...P,style:h.row,children:[l.image&&!b?t(T,{testID:"buoy-internal-chat-image",source:{uri:l.image},style:n.thumb,resizeMode:"contain",accessibilityLabel:l.title}):l.icon?t(E,{name:l.icon}):null,u(d,{style:n.flex,children:[t(c,{style:[h.rowTitle,l.tone&&{color:S(l.tone)}],numberOfLines:b?void 0:2,children:C(l.title,h.rowTitle)}),l.subtitle?t(c,{style:h.rowSub,numberOfLines:b?void 0:2,children:C(l.subtitle,h.rowSub)}):null]}),l.trailing?t(c,{style:[h.rowTrailing,l.tone&&{color:S(l.tone)}],numberOfLines:1,children:l.trailing}):null,l.action?V?t(w,{onPress:()=>void o.runAction(l.action,e.id),accessibilityRole:"button",accessibilityLabel:l.action.label,hitSlop:8,children:t(c,{style:n.rowAction,children:l.action.label})}):t(c,{style:n.rowAction,children:l.action.label}):null]})]},p)}),t(D,{paged:r})]})}function L(e){return e!==null&&typeof e==="object"}function _(e){const o=e.map(s=>s.path);const r=o.slice(0,3).join(", ");const a=o.length-3;const f=o.length===1?"1 field":`${o.length} fields`;return`${f} \xB7 ${r}${a>0?`, +${a}`:""}`}export function Diff({block:e}){const o=I(e.changes,x.keyValuePairs);return u(g,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:_(e.changes),children:[o.visible.map((r,a)=>{const f=r.before===void 0&&r.after!==void 0;const s=r.after===void 0&&r.before!==void 0;return u(d,{style:[n.diffRow,a>0&&h.rowDivider],children:[t(c,{style:n.diffPath,numberOfLines:1,children:r.path}),L(r.before)||L(r.after)?t(d,{style:n.diffTree,children:t(j,{oldValue:r.before,newValue:r.after,showUnchanged:false,scrollEnabled:false})}):u(K,{children:[!f?u(d,{style:n.diffLine,children:[t(c,{style:[n.diffMark,{color:i.color.danger}],children:"\u2212"}),t(c,{style:[n.diffValue,{color:i.color.danger}],numberOfLines:3,selectable:true,children:$(r.before)})]}):null,!s?u(d,{style:n.diffLine,children:[t(c,{style:[n.diffMark,{color:i.color.accent}],children:"+"}),t(c,{style:[n.diffValue,{color:i.color.accent}],numberOfLines:3,selectable:true,children:$(r.after)})]}):null]})]},`${r.path}-${a}`)}),t(D,{paged:o})]})}export function Chart({block:e}){const o=e.bars.slice(0,x.chartBars);const r=e.max??Math.max(1,...o.map(a=>a.value));return t(g,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:t(d,{style:n.chart,children:o.map((a,f)=>u(d,{style:n.barRow,children:[t(c,{style:n.barLabel,numberOfLines:1,children:a.label}),t(d,{style:n.barTrack,children:t(d,{style:[n.bar,{width:`${Math.max(2,Math.round(a.value/r*100))}%`,backgroundColor:S(a.tone??"accent")}]})}),u(c,{style:n.barValue,numberOfLines:1,children:[a.value,a.unit?` ${a.unit}`:""]})]},`${a.label}-${f}`))})})}export function Steps({block:e}){return t(g,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((o,r)=>u(d,{style:[n.step,r>0&&h.rowDivider],children:[t(d,{style:[n.stepMark,o.state==="done"&&n.stepDone,o.state==="failed"&&n.stepFailed],children:o.state==="done"?t(M,{size:10,color:i.color.onAccent}):o.state==="failed"?t(F,{size:10,color:i.color.text}):t(c,{style:n.stepNum,children:r+1})}),t(c,{style:[h.rowTitle,o.state==="done"&&n.stepTextDone],children:o.text})]},r))})}function U(e){try{const o=JSON.parse(e);return o!==null&&typeof o==="object"?o:void 0}catch{return void 0}}function X({block:e,value:o}){return t(g,{title:e.title,testID:`buoy-block-code-${e.id}`,children:t(d,{style:n.viewer,children:t(W,{title:e.title??"Payload",data:o,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function q({block:e}){return t(g,{title:e.title,testID:`buoy-block-code-${e.id}`,children:t(c,{style:[h.mono,n.code],selectable:true,children:e.text})})}export function Code({block:e}){const o=U(e.text);if(o===void 0)return t(q,{block:e});return t(X,{block:e,value:o})}export function Notice({block:e}){const o=e.tone==="danger"?i.color.danger:e.tone==="warning"?i.color.warning:i.color.info;const r=e.tone==="info"?k:A;return u(g,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[u(d,{style:n.noticeRow,children:[t(r,{size:14,color:o}),t(c,{style:n.noticeText,children:e.text})]}),t(H,{actions:e.actions,blockId:e.id})]})}export function Finding({block:e}){const{copied:o,copy:r}=N(()=>J(e)??e.title);return u(g,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((a,f)=>u(d,{style:[n.kvRow,f>0&&h.rowDivider],children:[t(c,{style:n.kvKey,numberOfLines:1,children:a.label}),t(c,{style:[n.kvValue,a.tone&&{color:S(a.tone)}],selectable:true,children:a.value})]},`${a.label}-${f}`)),t(d,{style:n.findingFoot,children:t(w,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:o?"Copied":"Copy this finding",onPress:r,style:({pressed:a})=>[n.findingCopy,a&&{opacity:.7}],children:t(c,{style:[n.findingCopyText,o&&{color:i.color.accent}],children:o?"Copied":"Copy finding"})})}),t(H,{actions:e.actions,blockId:e.id})]})}const n=R.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:i.color.fill},th:{flex:1,color:i.color.textTertiary,fontSize:i.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:i.color.textSecondary,fontSize:i.font.caption,lineHeight:17},tdFirst:{color:i.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:i.color.textSecondary,fontSize:i.font.caption,paddingTop:1},kvValue:{flex:1,color:i.color.text,fontSize:i.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:R.hairlineWidth,borderTopColor:i.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:i.radius.badge,backgroundColor:i.color.fill},findingCopyText:{color:i.color.textSecondary,fontSize:i.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:i.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:i.radius.row,backgroundColor:i.color.fill},rowAction:{color:i.color.accent,fontSize:i.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:i.color.textSecondary,fontSize:i.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:i.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:i.color.textSecondary,fontSize:i.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:i.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:i.color.text,fontSize:i.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:i.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:i.color.accent},stepFailed:{backgroundColor:i.color.danger},stepNum:{color:i.color.text,fontSize:i.font.micro,fontWeight:"700"},stepTextDone:{color:i.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:i.color.text,fontSize:i.font.caption,lineHeight:18}});
1
+ "use strict";import{monoFont as z}from"@buoy-gg/shared-ui";import{Platform as T}from"react-native";import{useState as R}from"react";import{Image as H,Pressable as w,StyleSheet as L,Text as c,View as d}from"react-native";import{AlertTriangle as M,Check as k,Info as W,night as i,X as j}from"@buoy-gg/shared-ui";import{DataViewer as B,TreeDiffViewer as N}from"@buoy-gg/shared-ui/dataViewer";import{CAPS as x}from"@buoy-gg/agent-core";import{ActionRow as V,blockStyles as h,Card as g,More as D,toneColor as S,useBlockHandlers as J,usePaged as I}from"./primitivesIndex";import{renderInline as C}from"../components/Markdown";import{useCopyAction as E}from"../components/useCopyAction";import{blockToText as K}from"./blockText";import{BlockIcon as _}from"./icons";import{jsx as t,jsxs as f,Fragment as U}from"react/jsx-runtime";function $(e){if(e===void 0)return"\u2014";if(e===null)return"null";if(typeof e==="string")return e;if(typeof e==="number"||typeof e==="boolean")return String(e);try{const o=JSON.stringify(e);return o.length>120?`${o.slice(0,117)}\u2026`:o}catch{return String(e)}}export function Table({block:e}){const o=I(e.rows,x.tableRows);const{visible:r}=o;const a=e.columns.slice(0,4);return f(g,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[t(d,{style:n.tableHead,children:a.map((u,s)=>t(c,{style:[n.th,s===0&&n.firstCol],numberOfLines:1,children:u},u))}),r.map((u,s)=>t(d,{style:[n.tr,s>0&&h.rowDivider],children:a.map((l,y)=>{const p=u[y];const b=typeof p==="string"?p:p?.text??"";const m=typeof p==="string"?void 0:p?.tone;return t(c,{style:[n.td,y===0&&n.firstCol,y===0&&n.tdFirst,m&&{color:S(m)}],numberOfLines:2,children:C(b,n.td)},y)})},s)),t(D,{paged:o})]})}export function KeyValue({block:e}){const o=I(e.pairs,x.keyValuePairs);const{visible:r}=o;const[a,u]=R(null);return f(g,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[r.map((s,l)=>{const y=typeof s.value==="object"&&s.value!==null;const p=a===s.key;return f(w,{onPress:y?()=>u(p?null:s.key):void 0,style:[n.kvRow,l>0&&h.rowDivider],children:[t(c,{style:n.kvKey,numberOfLines:1,children:s.key}),t(c,{style:[n.kvValue,p&&h.mono],numberOfLines:p?void 0:2,selectable:true,children:p?JSON.stringify(s.value,null,2):$(s.value)})]},s.key)}),t(D,{paged:o})]})}export function listRowBehaviour(e){const o=Boolean(e.image);return{canExpand:o,rowRunsAction:Boolean(e.action)&&!o,actionIsOwnControl:Boolean(e.action)&&o}}export function List({block:e}){const o=J();const r=I(e.items,x.listItems);const{visible:a}=r;const[u,s]=R(null);return f(g,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[a.map((l,y)=>{const p=`${l.id??l.title}-${y}`;const b=u===p;const{canExpand:m,rowRunsAction:v,actionIsOwnControl:P}=listRowBehaviour(l);const A=m||v?w:d;const F=m?{onPress:()=>s(b?null:p),accessibilityRole:"button",accessibilityState:{expanded:b},accessibilityLabel:`${l.title}, ${b?"hide":"show"} picture`,testID:`buoy-block-list-row-${p}`}:v?{onPress:()=>void o.runAction(l.action,e.id),accessibilityRole:"button"}:{};return f(d,{style:y>0?h.rowDivider:void 0,children:[b&&l.image?t(w,{onPress:()=>s(null),accessibilityRole:"button",accessibilityLabel:`Hide ${l.title}`,testID:`buoy-block-list-hero-${p}`,style:n.listHero,children:t(H,{testID:"buoy-internal-chat-image",source:{uri:l.image},style:n.listHeroImage,resizeMode:"contain",accessibilityLabel:l.title})}):null,f(A,{...F,style:h.row,children:[l.image&&!b?t(H,{testID:"buoy-internal-chat-image",source:{uri:l.image},style:n.thumb,resizeMode:"contain",accessibilityLabel:l.title}):l.icon?t(_,{name:l.icon}):null,f(d,{style:n.flex,children:[t(c,{style:[h.rowTitle,l.tone&&{color:S(l.tone)}],numberOfLines:b?void 0:2,children:C(l.title,h.rowTitle)}),l.subtitle?t(c,{style:h.rowSub,numberOfLines:b?void 0:2,children:C(l.subtitle,h.rowSub)}):null]}),l.trailing?t(c,{style:[h.rowTrailing,l.tone&&{color:S(l.tone)}],numberOfLines:1,children:l.trailing}):null,l.action?P?t(w,{onPress:()=>void o.runAction(l.action,e.id),accessibilityRole:"button",accessibilityLabel:l.action.label,hitSlop:8,children:t(c,{style:n.rowAction,children:l.action.label})}):t(c,{style:n.rowAction,children:l.action.label}):null]})]},p)}),t(D,{paged:r})]})}function O(e){return e!==null&&typeof e==="object"}function X(e){const o=e.map(s=>s.path);const r=o.slice(0,3).join(", ");const a=o.length-3;const u=o.length===1?"1 field":`${o.length} fields`;return`${u} \xB7 ${r}${a>0?`, +${a}`:""}`}export function Diff({block:e}){const o=I(e.changes,x.keyValuePairs);return f(g,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:true,summary:X(e.changes),children:[o.visible.map((r,a)=>{const u=r.before===void 0&&r.after!==void 0;const s=r.after===void 0&&r.before!==void 0;return f(d,{style:[n.diffRow,a>0&&h.rowDivider],children:[t(c,{style:n.diffPath,numberOfLines:1,children:r.path}),O(r.before)||O(r.after)?t(d,{style:n.diffTree,children:t(N,{oldValue:r.before,newValue:r.after,showUnchanged:false,scrollEnabled:false})}):f(U,{children:[!u?f(d,{style:n.diffLine,children:[t(c,{style:[n.diffMark,{color:i.color.danger}],children:"\u2212"}),t(c,{style:[n.diffValue,{color:i.color.danger}],numberOfLines:3,selectable:true,children:$(r.before)})]}):null,!s?f(d,{style:n.diffLine,children:[t(c,{style:[n.diffMark,{color:i.color.accent}],children:"+"}),t(c,{style:[n.diffValue,{color:i.color.accent}],numberOfLines:3,selectable:true,children:$(r.after)})]}):null]})]},`${r.path}-${a}`)}),t(D,{paged:o})]})}export function Chart({block:e}){const o=e.bars.slice(0,x.chartBars);const r=e.max??Math.max(1,...o.map(a=>a.value));return t(g,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:t(d,{style:n.chart,children:o.map((a,u)=>f(d,{style:n.barRow,children:[t(c,{style:n.barLabel,numberOfLines:1,children:a.label}),t(d,{style:n.barTrack,children:t(d,{style:[n.bar,{width:`${Math.max(2,Math.round(a.value/r*100))}%`,backgroundColor:S(a.tone??"accent")}]})}),f(c,{style:n.barValue,numberOfLines:1,children:[a.value,a.unit?` ${a.unit}`:""]})]},`${a.label}-${u}`))})})}export function Steps({block:e}){return t(g,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((o,r)=>f(d,{style:[n.step,r>0&&h.rowDivider],children:[t(d,{style:[n.stepMark,o.state==="done"&&n.stepDone,o.state==="failed"&&n.stepFailed],children:o.state==="done"?t(k,{size:10,color:i.color.onAccent}):o.state==="failed"?t(j,{size:10,color:i.color.text}):t(c,{style:n.stepNum,children:r+1})}),t(c,{style:[h.rowTitle,o.state==="done"&&n.stepTextDone],children:o.text})]},r))})}function q(e){try{const o=JSON.parse(e);return o!==null&&typeof o==="object"?o:void 0}catch{return void 0}}function G({block:e,value:o}){return t(g,{title:e.title,testID:`buoy-block-code-${e.id}`,children:t(d,{style:n.viewer,children:t(B,{title:e.title??"Payload",data:o,initialExpanded:true,showTypeFilter:false,testIDPrefix:`buoy-block-code-${e.id}`})})})}function Q({block:e}){return t(g,{title:e.title,testID:`buoy-block-code-${e.id}`,children:t(c,{style:[h.mono,n.code],selectable:true,children:e.text})})}export function Code({block:e}){const o=q(e.text);if(o===void 0)return t(Q,{block:e});return t(G,{block:e,value:o})}export function Notice({block:e}){const o=e.tone==="danger"?i.color.danger:e.tone==="warning"?i.color.warning:i.color.info;const r=e.tone==="info"?W:M;return f(g,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[f(d,{style:n.noticeRow,children:[t(r,{size:14,color:o}),t(c,{style:n.noticeText,children:e.text})]}),t(V,{actions:e.actions,blockId:e.id})]})}export function Finding({block:e}){const{copied:o,copy:r}=E(()=>K(e)??e.title);return f(g,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((a,u)=>f(d,{style:[n.kvRow,u>0&&h.rowDivider],children:[t(c,{style:n.kvKey,numberOfLines:1,children:a.label}),t(c,{style:[n.kvValue,a.tone&&{color:S(a.tone)}],selectable:true,children:a.value})]},`${a.label}-${u}`)),t(d,{style:n.findingFoot,children:t(w,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:o?"Copied":"Copy this finding",onPress:r,style:({pressed:a})=>[n.findingCopy,a&&{opacity:.7}],children:t(c,{style:[n.findingCopyText,o&&{color:i.color.accent}],children:o?"Copied":"Copy finding"})})}),t(V,{actions:e.actions,blockId:e.id})]})}const n=L.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:i.color.fill},th:{flex:1,color:i.color.textTertiary,fontSize:i.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:i.color.textSecondary,fontSize:i.font.caption,lineHeight:17},tdFirst:{color:i.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:i.color.textSecondary,fontSize:i.font.caption,paddingTop:1},kvValue:{flex:1,color:i.color.text,fontSize:i.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:L.hairlineWidth,borderTopColor:i.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:i.radius.badge,backgroundColor:i.color.fill},findingCopyText:{color:i.color.textSecondary,fontSize:i.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:i.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:i.radius.row,backgroundColor:i.color.fill},rowAction:{color:i.color.accent,fontSize:i.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:i.color.textSecondary,fontSize:i.font.micro,fontWeight:"600",letterSpacing:.3},diffLine:{flexDirection:"row",gap:8,alignItems:"flex-start"},diffMark:{fontFamily:T.OS==="web"?z:"Menlo",fontSize:12,width:10},diffValue:{flex:1,fontFamily:T.OS==="web"?z:"Menlo",fontSize:12,lineHeight:16},diffTree:{borderRadius:i.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:i.color.textSecondary,fontSize:i.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:i.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:i.color.text,fontSize:i.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:i.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:i.color.accent},stepFailed:{backgroundColor:i.color.danger},stepNum:{color:i.color.text,fontSize:i.font.micro,fontWeight:"700"},stepTextDone:{color:i.color.textSecondary},viewer:{paddingHorizontal:4,paddingBottom:8},code:{paddingHorizontal:12,paddingVertical:10,lineHeight:17},noticeRow:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:4},noticeText:{flex:1,color:i.color.text,fontSize:i.font.caption,lineHeight:18}});
@@ -1 +1 @@
1
- "use strict";import{useEffect as q,useRef as H,useState as w}from"react";import{Animated as T,Image as P,Pressable as f,ScrollView as N,StyleSheet as I,Switch as U,Text as l,TextInput as R,View as s}from"react-native";import{AlertTriangle as _,Check as W,ChevronDown as $,ChevronRight as V,night as o,NightSegmented as K,RefreshCw as J,Search as G,X}from"@buoy-gg/shared-ui";import{useBlockHandlers as S}from"./context";import{ActionRow as D,blockStyles as b,Card as m,More as Q,toneColor as L,usePaged as Y}from"./primitives";import{jsx as n,jsxs as a,Fragment as v}from"react/jsx-runtime";const B=e=>typeof e==="string"?e:e===void 0?"\u2014":JSON.stringify(e);export function Suggestions({block:e}){const r=S();return n(s,{style:t.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(i=>n(f,{disabled:!!r.busy,onPress:()=>void r.runAction({label:i.label,send:i.send??i.label},e.id),style:({pressed:d})=>[t.chip,d&&t.pressed],accessibilityRole:"button",children:n(l,{style:t.chipText,children:i.label})},i.label))})}export function MultiSelect({block:e}){const r=S();const i=r.answered[e.id];const d=!!i;const[c,p]=w([]);const u=i?.kind==="multi"?i.optionIds:c;const y=g=>p(h=>h.includes(g)?h.filter(x=>x!==g):[...h,g]);const C=c.length>=(e.min??1)&&(!e.max||c.length<=e.max);return a(m,{testID:`buoy-block-multi-${e.id}`,tone:d?void 0:"info",children:[n(l,{style:t.question,children:e.question}),n(s,{style:t.optionsBox,children:e.options.map((g,h)=>{const x=u.includes(g.id);return a(f,{disabled:d,onPress:()=>y(g.id),style:[t.option,h>0&&b.rowDivider,d&&!x&&t.dim],accessibilityRole:"checkbox",accessibilityState:{checked:x},children:[n(s,{style:[t.checkbox,x&&t.checkboxOn],children:x?n(W,{size:11,color:o.color.onAccent}):null}),a(s,{style:t.flex,children:[n(l,{style:t.optionLabel,children:g.label}),g.detail?n(l,{style:t.optionDetail,children:g.detail}):null]})]},g.id)})}),d?null:n(s,{style:t.rowEnd,children:n(f,{testID:"buoy-block-multi-submit",disabled:!C,onPress:()=>r.answer({blockId:e.id,kind:"multi",optionIds:c,labels:e.options.filter(g=>c.includes(g.id)).map(g=>g.label)}),style:[t.button,t.buttonPrimary,!C&&t.disabled],children:n(l,{style:t.buttonTextPrimary,children:e.submitLabel??`Use ${c.length||""}`.trim()})})})]})}const Z=8;export function Select({block:e}){const r=S();const i=r.answered[e.id];const[d,c]=w("");const[p,u]=w(false);const y=i?.kind==="select"?i.label:null;const C=e.options.filter(h=>!d||h.label.toLowerCase().includes(d.toLowerCase())).slice(0,8);const g=e.searchable!==false&&e.options.length>=Z;return a(m,{testID:`buoy-block-select-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),y?n(l,{style:t.decided,children:y}):a(s,{style:t.selectBox,children:[a(f,{onPress:()=>u(h=>!h),style:t.selectField,accessibilityRole:"button",children:[n(l,{style:t.selectPlaceholder,children:p?"Choose\u2026":`${e.options.length} options`}),n($,{size:14,color:o.color.textSecondary})]}),p&&a(v,{children:[g&&a(s,{style:t.search,children:[n(G,{size:12,color:o.color.textSecondary}),n(R,{style:t.searchInput,value:d,onChangeText:c,placeholder:"Search",placeholderTextColor:o.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),C.map((h,x)=>a(f,{onPress:()=>r.answer({blockId:e.id,kind:"select",optionId:h.id,label:h.label}),style:[t.option,x>0&&b.rowDivider],accessibilityRole:"button",children:[a(s,{style:t.flex,children:[n(l,{style:t.optionLabel,children:h.label}),h.detail?n(l,{style:t.optionDetail,children:h.detail}):null]}),n(V,{size:12,color:o.color.textTertiary})]},h.id)),e.options.length>C.length?a(l,{style:t.hint,children:[e.options.length-C.length," more \u2014 keep typing"]}):null]})]})]})}function O({min:e,max:r,step:i=1,value:d,unit:c,onChange:p,disabled:u}){const y=H(0);const C=r>e?(d-e)/(r-e)*100:0;const g=z=>Math.min(r,Math.max(e,+(Math.round((z-e)/i)*i+e).toFixed(6)));const h=z=>!u&&p(g(d+z*i));const x=z=>{if(u||y.current<=0)return;const F=Math.min(1,Math.max(0,z.nativeEvent.locationX/y.current));p(g(e+F*(r-e)))};const M=z=>{y.current=z.nativeEvent.layout.width};return a(s,{style:t.sliderRow,children:[n(f,{disabled:u,onPress:()=>h(-1),style:t.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:n(l,{style:t.stepText,children:"\u2212"})}),n(f,{style:t.trackHit,onLayout:M,onPress:x,disabled:u,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:r,now:d},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:z=>h(z.nativeEvent.actionName==="increment"?1:-1),children:a(s,{style:t.track,pointerEvents:"none",children:[n(s,{style:[t.fill,{width:`${C}%`}]}),n(s,{style:[t.thumb,{left:`${C}%`}]})]})}),n(f,{disabled:u,onPress:()=>h(1),style:t.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:n(l,{style:t.stepText,children:"+"})}),a(l,{style:t.sliderValue,children:[d,c?` ${c}`:""]})]})}export function Slider({block:e}){const r=S();const i=r.answered[e.id];const[d,c]=w(e.value??e.min);return a(m,{testID:`buoy-block-slider-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),n(s,{style:t.pad,children:n(O,{min:e.min,max:e.max,step:e.step,value:i?.kind==="slider"?i.value:d,unit:e.unit,onChange:c,disabled:!!i})}),i?null:n(s,{style:t.rowEnd,children:n(f,{onPress:()=>r.answer({blockId:e.id,kind:"slider",value:d,unit:e.unit}),style:[t.button,t.buttonPrimary],children:a(l,{style:t.buttonTextPrimary,children:["Use ",d,e.unit?` ${e.unit}`:""]})})})]})}export function DateTime({block:e}){const r=S();const i=r.answered[e.id];const[d,c]=w("");const p=e.presets??[{label:"Now",value:new Date().toISOString()},{label:"Tomorrow",value:new Date(Date.now()+864e5).toISOString()},{label:"+7 days",value:new Date(Date.now()+7*864e5).toISOString()},{label:"+30 days",value:new Date(Date.now()+30*864e5).toISOString()}];return a(m,{testID:`buoy-block-datetime-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),i?n(l,{style:t.decided,children:i.kind==="dateTime"?i.label??i.value:"(skipped)"}):a(v,{children:[n(s,{style:[t.chips,t.pad],children:p.map(u=>n(f,{onPress:()=>r.answer({blockId:e.id,kind:"dateTime",value:u.value,label:u.label}),style:t.chip,children:n(l,{style:t.chipText,children:u.label})},u.label))}),a(s,{style:[t.inputRow,t.pad],children:[n(R,{style:t.input,value:d,onChangeText:c,placeholder:e.mode==="time"?"14:30":"2026-09-15",placeholderTextColor:o.color.placeholder,keyboardType:"numbers-and-punctuation"}),n(f,{disabled:!d.trim(),onPress:()=>r.answer({blockId:e.id,kind:"dateTime",value:d.trim()}),style:[t.button,t.buttonPrimary,!d.trim()&&t.disabled],children:n(l,{style:t.buttonTextPrimary,children:"Use"})})]})]})]})}function E({f:e,value:r,onChange:i,disabled:d}){if(e.type==="toggle"){return a(s,{style:t.fieldRow,children:[n(l,{style:t.fieldLabel,children:e.label}),n(U,{value:!!r,onValueChange:i,disabled:d,trackColor:{true:o.color.accent,false:o.color.fillTertiary},thumbColor:o.color.knob})]})}if(e.type==="select"){return a(s,{style:t.fieldCol,children:[n(l,{style:t.fieldLabel,children:e.label}),n(s,{style:t.chips,children:e.options.map(c=>n(f,{disabled:d,onPress:()=>i(c.id),style:[t.chip,r===c.id&&t.chipOn],children:n(l,{style:[t.chipText,r===c.id&&t.chipTextOn],children:c.label})},c.id))})]})}if(e.type==="slider"){return a(s,{style:t.fieldCol,children:[n(l,{style:t.fieldLabel,children:e.label}),n(O,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof r==="number"?r:e.min,onChange:i,disabled:d})]})}return a(s,{style:t.fieldRow,children:[n(l,{style:t.fieldLabel,children:e.label}),n(R,{style:t.fieldInput,value:r===void 0||r===null?"":String(r),onChangeText:i,editable:!d,placeholder:e.placeholder??"",placeholderTextColor:o.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function j(e){const[r,i]=w(()=>Object.fromEntries(e.map(d=>[d.key,d.value])));return{values:r,set:(d,c)=>i(p=>({...p,[d]:c}))}}export function Form({block:e}){const r=S();const i=r.answered[e.id];const{values:d,set:c}=j(e.fields);return a(m,{title:e.title,testID:`buoy-block-form-${e.id}`,tone:i?void 0:"info",children:[n(s,{style:t.pad,children:e.fields.map(p=>n(E,{f:p,value:d[p.key],onChange:u=>c(p.key,u),disabled:!!i},p.key))}),i?n(l,{style:t.decided,children:"Sent"}):n(s,{style:t.rowEnd,children:n(f,{onPress:()=>r.answer({blockId:e.id,kind:"form",values:d}),style:[t.button,t.buttonPrimary],children:n(l,{style:t.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}export function Proposal({block:e}){const r=S();const i=r.answered[e.id];const{values:d,set:c}=j(e.fields);const p=i?.kind==="proposal"?i.approved:null;return a(m,{testID:`buoy-block-proposal-${e.id}`,tone:i?void 0:"warning",children:[n(l,{style:t.confirmTitle,children:e.title}),n(l,{style:t.confirmChange,children:e.change}),n(s,{style:t.pad,children:e.fields.map(u=>n(E,{f:u,value:d[u.key],onChange:y=>c(u.key,y),disabled:!!i},u.key))}),e.consequence?n(l,{style:t.consequence,children:e.consequence}):null,n(s,{style:t.actionsRow,children:i?n(l,{style:t.decided,children:p?"\u2713 Applied with these values":"\u2715 Not applied"}):a(v,{children:[n(f,{onPress:()=>r.answer({blockId:e.id,kind:"proposal",approved:true,values:d}),style:[t.button,t.buttonPrimary],children:n(l,{style:t.buttonTextPrimary,children:e.approveLabel??"Apply"})}),n(f,{onPress:()=>r.answer({blockId:e.id,kind:"proposal",approved:false}),style:[t.button,t.buttonPlate],children:n(l,{style:t.buttonTextPlate,children:"Not now"})})]})})]})}export function Claim({block:e}){const r=S();const[i,d]=w(null);const c=r.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`];const p=e.verified||c==="done";return a(s,{style:t.claim,testID:`buoy-block-claim-${e.id}`,children:[a(l,{style:t.claimText,children:[e.text,e.sources.map((u,y)=>a(l,{onPress:()=>d(i===y?null:y),style:t.cite,children:[" [",y+1,"]"]},y)),p?n(l,{style:t.verified,children:" \u2713 verified"}):null]}),i!==null&&e.sources[i]?a(s,{style:t.citeBox,children:[a(l,{style:t.citeLabel,children:["[",i+1,"] ",e.sources[i].label]}),e.sources[i].detail?n(l,{style:t.citeDetail,children:e.sources[i].detail}):null]}):null,e.verify&&!p?a(f,{onPress:()=>void r.runAction(e.verify,e.id),style:t.verifyBtn,accessibilityRole:"button",children:[n(J,{size:11,color:o.color.accent}),n(l,{style:t.verifyText,children:c==="running"?"Checking\u2026":e.verify.label})]}):null]})}export function Details({block:e}){const[r,i]=w(!!e.open);return a(m,{testID:`buoy-block-details-${e.id}`,children:[a(f,{onPress:()=>i(d=>!d),style:b.row,accessibilityRole:"button",accessibilityState:{expanded:r},children:[n(l,{style:b.rowTitle,children:e.summary}),r?n($,{size:12,color:o.color.textTertiary}):n(V,{size:12,color:o.color.textTertiary})]}),r?n(l,{style:t.detailsBody,selectable:true,children:e.body}):null]})}export function Tabs({block:e,renderNested:r}){const[i,d]=w(0);const c=e.tabs.map((u,y)=>({key:String(y),label:u.label}));const p=e.tabs[i];return a(s,{style:t.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[n(K,{tabs:c,activeKey:String(i),onChange:u=>d(Number(u)),size:"sm"}),p&&r?r(p.block):null]})}const k=10;export function Timeline({block:e}){const r=Y(e.events,k);return a(m,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[r.visible.map((i,d)=>a(s,{style:t.tlRow,children:[n(l,{style:t.tlAt,children:i.at}),a(s,{style:t.tlLine,children:[n(s,{style:[t.tlDot,{backgroundColor:L(i.tone??"muted")}]}),d<r.visible.length-1?n(s,{style:t.tlStem}):null]}),a(s,{style:t.flex,children:[n(l,{style:t.tlSource,children:i.source.toUpperCase()}),n(l,{style:b.rowTitle,numberOfLines:2,children:i.label})]})]},d)),n(Q,{paged:r})]})}export function Sparkline({block:e}){const r=e.series.slice(-60);const i=Math.max(1,...r);const d=Math.min(...r,0);const c=44;return a(m,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[a(s,{style:t.sparkHead,children:[a(l,{style:t.sparkCurrent,children:[e.current??r[r.length-1],e.unit?a(l,{style:t.sparkUnit,children:[" ",e.unit]}):null]}),e.live?n(LivePill,{}):null]}),n(s,{style:[t.spark,{height:c}],children:r.map((p,u)=>n(s,{style:[t.sparkBar,{height:Math.max(2,(p-d)/(i-d||1)*c),backgroundColor:u===r.length-1?o.color.accent:o.color.accentBorderStrong}]},u))}),e.label?n(l,{style:t.hint,children:e.label}):null]})}export function LivePill(){const e=H(new T.Value(1)).current;q(()=>{const r=T.loop(T.sequence([T.timing(e,{toValue:.3,duration:700,useNativeDriver:true}),T.timing(e,{toValue:1,duration:700,useNativeDriver:true})]));r.start();return()=>r.stop()},[e]);return a(s,{style:t.live,children:[n(T.View,{style:[t.liveDot,{opacity:e}]}),n(l,{style:t.liveText,children:"LIVE"})]})}export function Compare({block:e}){const r=[...new Set([...e.left.pairs.map(c=>c.key),...e.right.pairs.map(c=>c.key)])];const i=Object.fromEntries(e.left.pairs.map(c=>[c.key,c.value]));const d=Object.fromEntries(e.right.pairs.map(c=>[c.key,c.value]));return a(m,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[a(s,{style:t.cmpHead,children:[n(l,{style:t.cmpKey}),n(l,{style:t.cmpCol,children:e.left.title}),n(l,{style:t.cmpCol,children:e.right.title})]}),r.map((c,p)=>{const u=JSON.stringify(i[c])!==JSON.stringify(d[c]);return a(s,{style:[t.cmpRow,p>0&&b.rowDivider,u&&t.cmpDiff],children:[n(l,{style:t.cmpKey,numberOfLines:1,children:c}),n(l,{style:[t.cmpVal,u&&{color:o.color.danger}],numberOfLines:2,children:B(i[c])}),n(l,{style:[t.cmpVal,u&&{color:o.color.accent}],numberOfLines:2,children:B(d[c])})]},c)})]})}function A({c:e,id:r}){return a(v,{children:[e.image?n(P,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:t.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,a(s,{style:t.cardText,children:[n(l,{style:t.cardTitle,numberOfLines:2,children:e.title}),e.subtitle?n(l,{style:b.rowSub,numberOfLines:2,children:e.subtitle}):null,e.facts?.slice(0,4).map(i=>a(s,{style:t.fact,children:[n(l,{style:t.factLabel,children:i.label}),n(l,{style:[t.factValue,i.tone&&{color:L(i.tone)}],children:i.value})]},i.label))]}),n(D,{actions:e.actions,blockId:r})]})}export function CardView({block:e}){return n(m,{source:e.source,testID:`buoy-block-card-${e.id}`,children:n(A,{c:e,id:e.id})})}export function CardCarousel({block:e}){return a(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?n(l,{style:t.carouselTitle,children:e.title}):null,n(N,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:232,decelerationRate:"fast",contentContainerStyle:t.carousel,children:e.cards.slice(0,8).map((r,i)=>n(s,{style:t.carouselCard,children:n(A,{c:r,id:`${e.id}-${i}`})},`${r.title}-${i}`))})]})}export function Screenshot({block:e}){const[r,i]=w(false);return a(m,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[n(f,{onPress:()=>i(d=>!d),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:n(P,{testID:"buoy-internal-chat-image",source:{uri:e.url},style:[t.shot,r&&t.shotBig],resizeMode:"contain"})}),e.caption?n(l,{style:t.hint,children:e.caption}):null]})}export function Plan({block:e}){const r=e.steps.filter(i=>i.state==="done").length;return a(m,{title:e.title,testID:`buoy-block-plan-${e.id}`,tone:e.pending?"info":void 0,children:[n(s,{style:t.progress,children:n(s,{style:[t.progressFill,{width:`${r/Math.max(1,e.steps.length)*100}%`}]})}),e.steps.map((i,d)=>a(s,{style:[t.step,d>0&&b.rowDivider],children:[n(s,{style:[t.stepMark,i.state==="done"&&t.stepDone,i.state==="failed"&&t.stepFailed,i.state==="running"&&t.stepRunning],children:i.state==="done"?n(W,{size:10,color:o.color.onAccent}):i.state==="failed"?n(X,{size:10,color:o.color.text}):n(l,{style:t.stepNum,children:d+1})}),a(l,{style:[b.rowTitle,i.state==="done"&&t.muted],children:[i.text,i.state==="running"?"\u2026":""]})]},d)),n(D,{actions:e.actions??(e.pending?[{label:"Go",primary:true,send:"Go ahead with the plan."},{label:"Change it",send:"Let me change the plan first."}]:void 0),blockId:e.id})]})}export function Checkpoint({block:e}){const r=S();return a(f,{testID:`buoy-block-checkpoint-${e.id}`,disabled:!e.restore,onPress:()=>e.restore&&void r.runAction(e.restore,e.id),style:t.checkpoint,accessibilityRole:"button",children:[n(s,{style:t.cpFlag}),a(l,{style:t.cpText,children:[e.label,e.at?` \xB7 ${e.at}`:""]}),e.restore?n(l,{style:t.cpRestore,children:e.restore.label}):null]})}export function Task({block:e}){const r=e.status==="failed"?o.color.danger:e.status==="done"?o.color.accent:o.color.info;return a(m,{testID:`buoy-block-task-${e.id}`,children:[a(s,{style:t.taskHead,children:[n(l,{style:t.cardTitle,children:e.title}),n(s,{style:[b.pill,{backgroundColor:`${r}22`}],children:n(l,{style:[b.pillText,{color:r}],children:e.status.toUpperCase()})})]}),e.progress!==void 0?n(s,{style:[t.progress,t.pad],children:n(s,{style:[t.progressFill,{width:`${Math.round(e.progress*100)}%`,backgroundColor:r}]})}):null,e.detail?n(l,{style:t.hint,children:e.detail}):null,n(D,{actions:e.actions,blockId:e.id})]})}export function Banner({block:e}){const r=e.tone==="danger"?o.color.danger:e.tone==="warning"?o.color.warning:o.color.info;return a(s,{style:[t.banner,{borderColor:r,backgroundColor:`${r}1A`}],testID:`buoy-block-banner-${e.id}`,children:[n(_,{size:13,color:r}),n(l,{style:[t.bannerText,{color:r}],numberOfLines:2,children:e.text}),e.actions?.[0]?n(D,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}export function File({block:e}){return a(m,{testID:`buoy-block-file-${e.id}`,children:[a(s,{style:b.row,children:[n(s,{style:t.fileIcon,children:n(l,{style:t.fileExt,children:(e.type??e.name.split(".").pop()??"file").toUpperCase().slice(0,4)})}),a(s,{style:t.flex,children:[n(l,{style:b.rowTitle,numberOfLines:1,children:e.name}),e.size?n(l,{style:b.rowSub,children:e.size}):null]})]}),n(D,{actions:e.actions,blockId:e.id})]})}export function Upload({block:e}){const r=S();const i=r.answered[e.id];return a(m,{testID:`buoy-block-upload-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),i?n(l,{style:t.decided,children:i.kind==="upload"?`Attached ${i.name}`:"(skipped)"}):n(s,{style:[t.rowEnd,{justifyContent:"flex-start"}],children:n(f,{onPress:()=>r.answer({blockId:e.id,kind:"upload",name:"screenshot.png"}),style:[t.button,t.buttonPlate],children:n(l,{style:t.buttonTextPlate,children:e.accept==="image"?"Choose a screenshot":"Choose a file"})})})]})}const t=I.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:o.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:o.color.text,fontSize:o.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:o.color.textTertiary,fontSize:o.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},rowEnd:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:12,paddingBottom:12,gap:8},actionsRow:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:o.radius.row},buttonPrimary:{backgroundColor:o.color.accent},buttonPlate:{backgroundColor:o.color.button},buttonTextPrimary:{color:o.color.onAccent,fontSize:o.font.caption,fontWeight:"600"},buttonTextPlate:{color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:o.radius.chip,backgroundColor:o.color.fill,borderWidth:I.hairlineWidth,borderColor:o.color.border},chipOn:{backgroundColor:o.color.accentSoft,borderColor:o.color.accentBorderStrong},chipText:{color:o.color.text,fontSize:o.font.caption},chipTextOn:{color:o.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:o.radius.row,backgroundColor:o.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:o.color.text,fontSize:o.font.body,fontWeight:"500"},optionDetail:{color:o.color.textSecondary,fontSize:o.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:o.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:o.color.accent,borderColor:o.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:o.radius.row,backgroundColor:o.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:o.color.textSecondary,fontSize:o.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:I.hairlineWidth,borderTopColor:o.color.separator},searchInput:{flex:1,color:o.color.text,fontSize:o.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:o.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:o.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:o.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:o.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:o.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:o.radius.row,backgroundColor:o.color.surfaceElevated,color:o.color.text,fontSize:o.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:o.color.textSecondary,fontSize:o.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:o.radius.segment,backgroundColor:o.color.surfaceElevated,color:o.color.text,fontSize:o.font.caption},confirmTitle:{color:o.color.text,fontSize:o.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:o.color.text,fontSize:o.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:o.color.warning,fontSize:o.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:o.color.text,fontSize:o.font.row,lineHeight:22},cite:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"700"},verified:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:o.radius.row,backgroundColor:o.color.surface,borderWidth:I.hairlineWidth,borderColor:o.color.border,gap:2},citeLabel:{color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},citeDetail:{color:o.color.textSecondary,fontSize:o.font.caption,fontFamily:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:o.radius.chip,backgroundColor:o.color.accentSoft},verifyText:{color:o.color.accent,fontSize:o.font.micro,fontWeight:"700"},detailsBody:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:o.radius.badge,backgroundColor:o.color.fill},tabOn:{backgroundColor:o.color.accentSoft},tabText:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"600"},tabTextOn:{color:o.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:o.color.textTertiary,fontSize:o.font.micro,fontFamily:"Menlo",paddingTop:3},tlLine:{width:12,alignItems:"center"},tlDot:{width:8,height:8,borderRadius:4,marginTop:5},tlStem:{width:1,flex:1,minHeight:18,backgroundColor:o.color.separator,marginTop:2},tlSource:{color:o.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:o.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"500"},spark:{flexDirection:"row",alignItems:"flex-end",gap:2,paddingHorizontal:12,paddingTop:6,paddingBottom:6},sparkBar:{flex:1,borderRadius:1},live:{flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:8,paddingVertical:3,borderRadius:o.radius.badge,backgroundColor:o.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:o.color.danger},liveText:{color:o.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:o.color.fill,gap:8},cmpCol:{flex:1,color:o.color.textTertiary,fontSize:o.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:o.color.fill},cmpKey:{width:90,color:o.color.textSecondary,fontSize:o.font.caption},cmpVal:{flex:1,color:o.color.text,fontSize:o.font.caption,fontFamily:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:o.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:o.color.text,fontSize:o.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:o.color.textSecondary,fontSize:o.font.caption},factValue:{color:o.color.text,fontSize:o.font.caption,fontWeight:"500"},carouselTitle:{color:o.color.text,fontSize:o.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:o.radius.card,borderWidth:I.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:o.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:o.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:o.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:o.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:o.color.accent},stepFailed:{backgroundColor:o.color.danger},stepRunning:{backgroundColor:o.color.info},stepNum:{color:o.color.text,fontSize:o.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:o.radius.chip,backgroundColor:o.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:o.color.info},cpText:{color:o.color.textSecondary,fontSize:o.font.caption},cpRestore:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"600"},taskHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:12,paddingTop:12},banner:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:12,paddingRight:4,paddingVertical:4,borderRadius:o.radius.row,borderWidth:I.hairlineWidth},bannerText:{flex:1,fontSize:o.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:o.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:o.color.textSecondary,fontSize:10,fontWeight:"800"}});
1
+ "use strict";import{monoFont as R}from"@buoy-gg/shared-ui";import{Platform as H}from"react-native";import{useEffect as U,useRef as W,useState as w}from"react";import{Animated as T,Image as $,Pressable as f,ScrollView as _,StyleSheet as I,Switch as K,Text as l,TextInput as P,View as s}from"react-native";import{AlertTriangle as J,Check as V,ChevronDown as L,ChevronRight as B,night as o,NightSegmented as G,RefreshCw as X,Search as Q,X as Y}from"@buoy-gg/shared-ui";import{useBlockHandlers as S}from"./context";import{ActionRow as D,blockStyles as b,Card as m,More as Z,toneColor as O,usePaged as k}from"./primitives";import{jsx as n,jsxs as a,Fragment as v}from"react/jsx-runtime";const E=e=>typeof e==="string"?e:e===void 0?"\u2014":JSON.stringify(e);export function Suggestions({block:e}){const r=S();return n(s,{style:t.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(i=>n(f,{disabled:!!r.busy,onPress:()=>void r.runAction({label:i.label,send:i.send??i.label},e.id),style:({pressed:d})=>[t.chip,d&&t.pressed],accessibilityRole:"button",children:n(l,{style:t.chipText,children:i.label})},i.label))})}export function MultiSelect({block:e}){const r=S();const i=r.answered[e.id];const d=!!i;const[c,p]=w([]);const u=i?.kind==="multi"?i.optionIds:c;const y=g=>p(h=>h.includes(g)?h.filter(x=>x!==g):[...h,g]);const C=c.length>=(e.min??1)&&(!e.max||c.length<=e.max);return a(m,{testID:`buoy-block-multi-${e.id}`,tone:d?void 0:"info",children:[n(l,{style:t.question,children:e.question}),n(s,{style:t.optionsBox,children:e.options.map((g,h)=>{const x=u.includes(g.id);return a(f,{disabled:d,onPress:()=>y(g.id),style:[t.option,h>0&&b.rowDivider,d&&!x&&t.dim],accessibilityRole:"checkbox",accessibilityState:{checked:x},children:[n(s,{style:[t.checkbox,x&&t.checkboxOn],children:x?n(V,{size:11,color:o.color.onAccent}):null}),a(s,{style:t.flex,children:[n(l,{style:t.optionLabel,children:g.label}),g.detail?n(l,{style:t.optionDetail,children:g.detail}):null]})]},g.id)})}),d?null:n(s,{style:t.rowEnd,children:n(f,{testID:"buoy-block-multi-submit",disabled:!C,onPress:()=>r.answer({blockId:e.id,kind:"multi",optionIds:c,labels:e.options.filter(g=>c.includes(g.id)).map(g=>g.label)}),style:[t.button,t.buttonPrimary,!C&&t.disabled],children:n(l,{style:t.buttonTextPrimary,children:e.submitLabel??`Use ${c.length||""}`.trim()})})})]})}const ee=8;export function Select({block:e}){const r=S();const i=r.answered[e.id];const[d,c]=w("");const[p,u]=w(false);const y=i?.kind==="select"?i.label:null;const C=e.options.filter(h=>!d||h.label.toLowerCase().includes(d.toLowerCase())).slice(0,8);const g=e.searchable!==false&&e.options.length>=ee;return a(m,{testID:`buoy-block-select-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),y?n(l,{style:t.decided,children:y}):a(s,{style:t.selectBox,children:[a(f,{onPress:()=>u(h=>!h),style:t.selectField,accessibilityRole:"button",children:[n(l,{style:t.selectPlaceholder,children:p?"Choose\u2026":`${e.options.length} options`}),n(L,{size:14,color:o.color.textSecondary})]}),p&&a(v,{children:[g&&a(s,{style:t.search,children:[n(Q,{size:12,color:o.color.textSecondary}),n(P,{style:t.searchInput,value:d,onChangeText:c,placeholder:"Search",placeholderTextColor:o.color.placeholder,autoCapitalize:"none",autoCorrect:false})]}),C.map((h,x)=>a(f,{onPress:()=>r.answer({blockId:e.id,kind:"select",optionId:h.id,label:h.label}),style:[t.option,x>0&&b.rowDivider],accessibilityRole:"button",children:[a(s,{style:t.flex,children:[n(l,{style:t.optionLabel,children:h.label}),h.detail?n(l,{style:t.optionDetail,children:h.detail}):null]}),n(B,{size:12,color:o.color.textTertiary})]},h.id)),e.options.length>C.length?a(l,{style:t.hint,children:[e.options.length-C.length," more \u2014 keep typing"]}):null]})]})]})}function j({min:e,max:r,step:i=1,value:d,unit:c,onChange:p,disabled:u}){const y=W(0);const C=r>e?(d-e)/(r-e)*100:0;const g=z=>Math.min(r,Math.max(e,+(Math.round((z-e)/i)*i+e).toFixed(6)));const h=z=>!u&&p(g(d+z*i));const x=z=>{if(u||y.current<=0)return;const N=Math.min(1,Math.max(0,z.nativeEvent.locationX/y.current));p(g(e+N*(r-e)))};const q=z=>{y.current=z.nativeEvent.layout.width};return a(s,{style:t.sliderRow,children:[n(f,{disabled:u,onPress:()=>h(-1),style:t.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:n(l,{style:t.stepText,children:"\u2212"})}),n(f,{style:t.trackHit,onLayout:q,onPress:x,disabled:u,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:r,now:d},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:z=>h(z.nativeEvent.actionName==="increment"?1:-1),children:a(s,{style:t.track,pointerEvents:"none",children:[n(s,{style:[t.fill,{width:`${C}%`}]}),n(s,{style:[t.thumb,{left:`${C}%`}]})]})}),n(f,{disabled:u,onPress:()=>h(1),style:t.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:n(l,{style:t.stepText,children:"+"})}),a(l,{style:t.sliderValue,children:[d,c?` ${c}`:""]})]})}export function Slider({block:e}){const r=S();const i=r.answered[e.id];const[d,c]=w(e.value??e.min);return a(m,{testID:`buoy-block-slider-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),n(s,{style:t.pad,children:n(j,{min:e.min,max:e.max,step:e.step,value:i?.kind==="slider"?i.value:d,unit:e.unit,onChange:c,disabled:!!i})}),i?null:n(s,{style:t.rowEnd,children:n(f,{onPress:()=>r.answer({blockId:e.id,kind:"slider",value:d,unit:e.unit}),style:[t.button,t.buttonPrimary],children:a(l,{style:t.buttonTextPrimary,children:["Use ",d,e.unit?` ${e.unit}`:""]})})})]})}export function DateTime({block:e}){const r=S();const i=r.answered[e.id];const[d,c]=w("");const p=e.presets??[{label:"Now",value:new Date().toISOString()},{label:"Tomorrow",value:new Date(Date.now()+864e5).toISOString()},{label:"+7 days",value:new Date(Date.now()+7*864e5).toISOString()},{label:"+30 days",value:new Date(Date.now()+30*864e5).toISOString()}];return a(m,{testID:`buoy-block-datetime-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),i?n(l,{style:t.decided,children:i.kind==="dateTime"?i.label??i.value:"(skipped)"}):a(v,{children:[n(s,{style:[t.chips,t.pad],children:p.map(u=>n(f,{onPress:()=>r.answer({blockId:e.id,kind:"dateTime",value:u.value,label:u.label}),style:t.chip,children:n(l,{style:t.chipText,children:u.label})},u.label))}),a(s,{style:[t.inputRow,t.pad],children:[n(P,{style:t.input,value:d,onChangeText:c,placeholder:e.mode==="time"?"14:30":"2026-09-15",placeholderTextColor:o.color.placeholder,keyboardType:"numbers-and-punctuation"}),n(f,{disabled:!d.trim(),onPress:()=>r.answer({blockId:e.id,kind:"dateTime",value:d.trim()}),style:[t.button,t.buttonPrimary,!d.trim()&&t.disabled],children:n(l,{style:t.buttonTextPrimary,children:"Use"})})]})]})]})}function A({f:e,value:r,onChange:i,disabled:d}){if(e.type==="toggle"){return a(s,{style:t.fieldRow,children:[n(l,{style:t.fieldLabel,children:e.label}),n(K,{value:!!r,onValueChange:i,disabled:d,trackColor:{true:o.color.accent,false:o.color.fillTertiary},thumbColor:o.color.knob})]})}if(e.type==="select"){return a(s,{style:t.fieldCol,children:[n(l,{style:t.fieldLabel,children:e.label}),n(s,{style:t.chips,children:e.options.map(c=>n(f,{disabled:d,onPress:()=>i(c.id),style:[t.chip,r===c.id&&t.chipOn],children:n(l,{style:[t.chipText,r===c.id&&t.chipTextOn],children:c.label})},c.id))})]})}if(e.type==="slider"){return a(s,{style:t.fieldCol,children:[n(l,{style:t.fieldLabel,children:e.label}),n(j,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof r==="number"?r:e.min,onChange:i,disabled:d})]})}return a(s,{style:t.fieldRow,children:[n(l,{style:t.fieldLabel,children:e.label}),n(P,{style:t.fieldInput,value:r===void 0||r===null?"":String(r),onChangeText:i,editable:!d,placeholder:e.placeholder??"",placeholderTextColor:o.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:false})]})}function F(e){const[r,i]=w(()=>Object.fromEntries(e.map(d=>[d.key,d.value])));return{values:r,set:(d,c)=>i(p=>({...p,[d]:c}))}}export function Form({block:e}){const r=S();const i=r.answered[e.id];const{values:d,set:c}=F(e.fields);return a(m,{title:e.title,testID:`buoy-block-form-${e.id}`,tone:i?void 0:"info",children:[n(s,{style:t.pad,children:e.fields.map(p=>n(A,{f:p,value:d[p.key],onChange:u=>c(p.key,u),disabled:!!i},p.key))}),i?n(l,{style:t.decided,children:"Sent"}):n(s,{style:t.rowEnd,children:n(f,{onPress:()=>r.answer({blockId:e.id,kind:"form",values:d}),style:[t.button,t.buttonPrimary],children:n(l,{style:t.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}export function Proposal({block:e}){const r=S();const i=r.answered[e.id];const{values:d,set:c}=F(e.fields);const p=i?.kind==="proposal"?i.approved:null;return a(m,{testID:`buoy-block-proposal-${e.id}`,tone:i?void 0:"warning",children:[n(l,{style:t.confirmTitle,children:e.title}),n(l,{style:t.confirmChange,children:e.change}),n(s,{style:t.pad,children:e.fields.map(u=>n(A,{f:u,value:d[u.key],onChange:y=>c(u.key,y),disabled:!!i},u.key))}),e.consequence?n(l,{style:t.consequence,children:e.consequence}):null,n(s,{style:t.actionsRow,children:i?n(l,{style:t.decided,children:p?"\u2713 Applied with these values":"\u2715 Not applied"}):a(v,{children:[n(f,{onPress:()=>r.answer({blockId:e.id,kind:"proposal",approved:true,values:d}),style:[t.button,t.buttonPrimary],children:n(l,{style:t.buttonTextPrimary,children:e.approveLabel??"Apply"})}),n(f,{onPress:()=>r.answer({blockId:e.id,kind:"proposal",approved:false}),style:[t.button,t.buttonPlate],children:n(l,{style:t.buttonTextPlate,children:"Not now"})})]})})]})}export function Claim({block:e}){const r=S();const[i,d]=w(null);const c=r.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`];const p=e.verified||c==="done";return a(s,{style:t.claim,testID:`buoy-block-claim-${e.id}`,children:[a(l,{style:t.claimText,children:[e.text,e.sources.map((u,y)=>a(l,{onPress:()=>d(i===y?null:y),style:t.cite,children:[" [",y+1,"]"]},y)),p?n(l,{style:t.verified,children:" \u2713 verified"}):null]}),i!==null&&e.sources[i]?a(s,{style:t.citeBox,children:[a(l,{style:t.citeLabel,children:["[",i+1,"] ",e.sources[i].label]}),e.sources[i].detail?n(l,{style:t.citeDetail,children:e.sources[i].detail}):null]}):null,e.verify&&!p?a(f,{onPress:()=>void r.runAction(e.verify,e.id),style:t.verifyBtn,accessibilityRole:"button",children:[n(X,{size:11,color:o.color.accent}),n(l,{style:t.verifyText,children:c==="running"?"Checking\u2026":e.verify.label})]}):null]})}export function Details({block:e}){const[r,i]=w(!!e.open);return a(m,{testID:`buoy-block-details-${e.id}`,children:[a(f,{onPress:()=>i(d=>!d),style:b.row,accessibilityRole:"button",accessibilityState:{expanded:r},children:[n(l,{style:b.rowTitle,children:e.summary}),r?n(L,{size:12,color:o.color.textTertiary}):n(B,{size:12,color:o.color.textTertiary})]}),r?n(l,{style:t.detailsBody,selectable:true,children:e.body}):null]})}export function Tabs({block:e,renderNested:r}){const[i,d]=w(0);const c=e.tabs.map((u,y)=>({key:String(y),label:u.label}));const p=e.tabs[i];return a(s,{style:t.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[n(G,{tabs:c,activeKey:String(i),onChange:u=>d(Number(u)),size:"sm"}),p&&r?r(p.block):null]})}const te=10;export function Timeline({block:e}){const r=k(e.events,te);return a(m,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[r.visible.map((i,d)=>a(s,{style:t.tlRow,children:[n(l,{style:t.tlAt,children:i.at}),a(s,{style:t.tlLine,children:[n(s,{style:[t.tlDot,{backgroundColor:O(i.tone??"muted")}]}),d<r.visible.length-1?n(s,{style:t.tlStem}):null]}),a(s,{style:t.flex,children:[n(l,{style:t.tlSource,children:i.source.toUpperCase()}),n(l,{style:b.rowTitle,numberOfLines:2,children:i.label})]})]},d)),n(Z,{paged:r})]})}export function Sparkline({block:e}){const r=e.series.slice(-60);const i=Math.max(1,...r);const d=Math.min(...r,0);const c=44;return a(m,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[a(s,{style:t.sparkHead,children:[a(l,{style:t.sparkCurrent,children:[e.current??r[r.length-1],e.unit?a(l,{style:t.sparkUnit,children:[" ",e.unit]}):null]}),e.live?n(LivePill,{}):null]}),n(s,{style:[t.spark,{height:c}],children:r.map((p,u)=>n(s,{style:[t.sparkBar,{height:Math.max(2,(p-d)/(i-d||1)*c),backgroundColor:u===r.length-1?o.color.accent:o.color.accentBorderStrong}]},u))}),e.label?n(l,{style:t.hint,children:e.label}):null]})}export function LivePill(){const e=W(new T.Value(1)).current;U(()=>{const r=T.loop(T.sequence([T.timing(e,{toValue:.3,duration:700,useNativeDriver:true}),T.timing(e,{toValue:1,duration:700,useNativeDriver:true})]));r.start();return()=>r.stop()},[e]);return a(s,{style:t.live,children:[n(T.View,{style:[t.liveDot,{opacity:e}]}),n(l,{style:t.liveText,children:"LIVE"})]})}export function Compare({block:e}){const r=[...new Set([...e.left.pairs.map(c=>c.key),...e.right.pairs.map(c=>c.key)])];const i=Object.fromEntries(e.left.pairs.map(c=>[c.key,c.value]));const d=Object.fromEntries(e.right.pairs.map(c=>[c.key,c.value]));return a(m,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[a(s,{style:t.cmpHead,children:[n(l,{style:t.cmpKey}),n(l,{style:t.cmpCol,children:e.left.title}),n(l,{style:t.cmpCol,children:e.right.title})]}),r.map((c,p)=>{const u=JSON.stringify(i[c])!==JSON.stringify(d[c]);return a(s,{style:[t.cmpRow,p>0&&b.rowDivider,u&&t.cmpDiff],children:[n(l,{style:t.cmpKey,numberOfLines:1,children:c}),n(l,{style:[t.cmpVal,u&&{color:o.color.danger}],numberOfLines:2,children:E(i[c])}),n(l,{style:[t.cmpVal,u&&{color:o.color.accent}],numberOfLines:2,children:E(d[c])})]},c)})]})}function M({c:e,id:r}){return a(v,{children:[e.image?n($,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:t.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,a(s,{style:t.cardText,children:[n(l,{style:t.cardTitle,numberOfLines:2,children:e.title}),e.subtitle?n(l,{style:b.rowSub,numberOfLines:2,children:e.subtitle}):null,e.facts?.slice(0,4).map(i=>a(s,{style:t.fact,children:[n(l,{style:t.factLabel,children:i.label}),n(l,{style:[t.factValue,i.tone&&{color:O(i.tone)}],children:i.value})]},i.label))]}),n(D,{actions:e.actions,blockId:r})]})}export function CardView({block:e}){return n(m,{source:e.source,testID:`buoy-block-card-${e.id}`,children:n(M,{c:e,id:e.id})})}export function CardCarousel({block:e}){return a(s,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?n(l,{style:t.carouselTitle,children:e.title}):null,n(_,{horizontal:true,showsHorizontalScrollIndicator:false,snapToInterval:232,decelerationRate:"fast",contentContainerStyle:t.carousel,children:e.cards.slice(0,8).map((r,i)=>n(s,{style:t.carouselCard,children:n(M,{c:r,id:`${e.id}-${i}`})},`${r.title}-${i}`))})]})}export function Screenshot({block:e}){const[r,i]=w(false);return a(m,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[n(f,{onPress:()=>i(d=>!d),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:n($,{testID:"buoy-internal-chat-image",source:{uri:e.url},style:[t.shot,r&&t.shotBig],resizeMode:"contain"})}),e.caption?n(l,{style:t.hint,children:e.caption}):null]})}export function Plan({block:e}){const r=e.steps.filter(i=>i.state==="done").length;return a(m,{title:e.title,testID:`buoy-block-plan-${e.id}`,tone:e.pending?"info":void 0,children:[n(s,{style:t.progress,children:n(s,{style:[t.progressFill,{width:`${r/Math.max(1,e.steps.length)*100}%`}]})}),e.steps.map((i,d)=>a(s,{style:[t.step,d>0&&b.rowDivider],children:[n(s,{style:[t.stepMark,i.state==="done"&&t.stepDone,i.state==="failed"&&t.stepFailed,i.state==="running"&&t.stepRunning],children:i.state==="done"?n(V,{size:10,color:o.color.onAccent}):i.state==="failed"?n(Y,{size:10,color:o.color.text}):n(l,{style:t.stepNum,children:d+1})}),a(l,{style:[b.rowTitle,i.state==="done"&&t.muted],children:[i.text,i.state==="running"?"\u2026":""]})]},d)),n(D,{actions:e.actions??(e.pending?[{label:"Go",primary:true,send:"Go ahead with the plan."},{label:"Change it",send:"Let me change the plan first."}]:void 0),blockId:e.id})]})}export function Checkpoint({block:e}){const r=S();return a(f,{testID:`buoy-block-checkpoint-${e.id}`,disabled:!e.restore,onPress:()=>e.restore&&void r.runAction(e.restore,e.id),style:t.checkpoint,accessibilityRole:"button",children:[n(s,{style:t.cpFlag}),a(l,{style:t.cpText,children:[e.label,e.at?` \xB7 ${e.at}`:""]}),e.restore?n(l,{style:t.cpRestore,children:e.restore.label}):null]})}export function Task({block:e}){const r=e.status==="failed"?o.color.danger:e.status==="done"?o.color.accent:o.color.info;return a(m,{testID:`buoy-block-task-${e.id}`,children:[a(s,{style:t.taskHead,children:[n(l,{style:t.cardTitle,children:e.title}),n(s,{style:[b.pill,{backgroundColor:`${r}22`}],children:n(l,{style:[b.pillText,{color:r}],children:e.status.toUpperCase()})})]}),e.progress!==void 0?n(s,{style:[t.progress,t.pad],children:n(s,{style:[t.progressFill,{width:`${Math.round(e.progress*100)}%`,backgroundColor:r}]})}):null,e.detail?n(l,{style:t.hint,children:e.detail}):null,n(D,{actions:e.actions,blockId:e.id})]})}export function Banner({block:e}){const r=e.tone==="danger"?o.color.danger:e.tone==="warning"?o.color.warning:o.color.info;return a(s,{style:[t.banner,{borderColor:r,backgroundColor:`${r}1A`}],testID:`buoy-block-banner-${e.id}`,children:[n(J,{size:13,color:r}),n(l,{style:[t.bannerText,{color:r}],numberOfLines:2,children:e.text}),e.actions?.[0]?n(D,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}export function File({block:e}){return a(m,{testID:`buoy-block-file-${e.id}`,children:[a(s,{style:b.row,children:[n(s,{style:t.fileIcon,children:n(l,{style:t.fileExt,children:(e.type??e.name.split(".").pop()??"file").toUpperCase().slice(0,4)})}),a(s,{style:t.flex,children:[n(l,{style:b.rowTitle,numberOfLines:1,children:e.name}),e.size?n(l,{style:b.rowSub,children:e.size}):null]})]}),n(D,{actions:e.actions,blockId:e.id})]})}export function Upload({block:e}){const r=S();const i=r.answered[e.id];return a(m,{testID:`buoy-block-upload-${e.id}`,tone:i?void 0:"info",children:[n(l,{style:t.question,children:e.label}),i?n(l,{style:t.decided,children:i.kind==="upload"?`Attached ${i.name}`:"(skipped)"}):n(s,{style:[t.rowEnd,{justifyContent:"flex-start"}],children:n(f,{onPress:()=>r.answer({blockId:e.id,kind:"upload",name:"screenshot.png"}),style:[t.button,t.buttonPlate],children:n(l,{style:t.buttonTextPlate,children:e.accept==="image"?"Choose a screenshot":"Choose a file"})})})]})}const t=I.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:o.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:o.color.text,fontSize:o.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:o.color.textTertiary,fontSize:o.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},rowEnd:{flexDirection:"row",justifyContent:"flex-end",paddingHorizontal:12,paddingBottom:12,gap:8},actionsRow:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:o.radius.row},buttonPrimary:{backgroundColor:o.color.accent},buttonPlate:{backgroundColor:o.color.button},buttonTextPrimary:{color:o.color.onAccent,fontSize:o.font.caption,fontWeight:"600"},buttonTextPlate:{color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:o.radius.chip,backgroundColor:o.color.fill,borderWidth:I.hairlineWidth,borderColor:o.color.border},chipOn:{backgroundColor:o.color.accentSoft,borderColor:o.color.accentBorderStrong},chipText:{color:o.color.text,fontSize:o.font.caption},chipTextOn:{color:o.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:o.radius.row,backgroundColor:o.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:o.color.text,fontSize:o.font.body,fontWeight:"500"},optionDetail:{color:o.color.textSecondary,fontSize:o.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:o.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:o.color.accent,borderColor:o.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:o.radius.row,backgroundColor:o.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:o.color.textSecondary,fontSize:o.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:I.hairlineWidth,borderTopColor:o.color.separator},searchInput:{flex:1,color:o.color.text,fontSize:o.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:o.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:o.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:o.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:o.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:o.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:o.radius.row,backgroundColor:o.color.surfaceElevated,color:o.color.text,fontSize:o.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:o.color.textSecondary,fontSize:o.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:o.radius.segment,backgroundColor:o.color.surfaceElevated,color:o.color.text,fontSize:o.font.caption},confirmTitle:{color:o.color.text,fontSize:o.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:o.color.text,fontSize:o.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:o.color.warning,fontSize:o.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:o.color.text,fontSize:o.font.row,lineHeight:22},cite:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"700"},verified:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:o.radius.row,backgroundColor:o.color.surface,borderWidth:I.hairlineWidth,borderColor:o.color.border,gap:2},citeLabel:{color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},citeDetail:{color:o.color.textSecondary,fontSize:o.font.caption,fontFamily:H.OS==="web"?R:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:o.radius.chip,backgroundColor:o.color.accentSoft},verifyText:{color:o.color.accent,fontSize:o.font.micro,fontWeight:"700"},detailsBody:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:o.radius.badge,backgroundColor:o.color.fill},tabOn:{backgroundColor:o.color.accentSoft},tabText:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"600"},tabTextOn:{color:o.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:o.color.textTertiary,fontSize:o.font.micro,fontFamily:H.OS==="web"?R:"Menlo",paddingTop:3},tlLine:{width:12,alignItems:"center"},tlDot:{width:8,height:8,borderRadius:4,marginTop:5},tlStem:{width:1,flex:1,minHeight:18,backgroundColor:o.color.separator,marginTop:2},tlSource:{color:o.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:o.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"500"},spark:{flexDirection:"row",alignItems:"flex-end",gap:2,paddingHorizontal:12,paddingTop:6,paddingBottom:6},sparkBar:{flex:1,borderRadius:1},live:{flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:8,paddingVertical:3,borderRadius:o.radius.badge,backgroundColor:o.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:o.color.danger},liveText:{color:o.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:o.color.fill,gap:8},cmpCol:{flex:1,color:o.color.textTertiary,fontSize:o.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:o.color.fill},cmpKey:{width:90,color:o.color.textSecondary,fontSize:o.font.caption},cmpVal:{flex:1,color:o.color.text,fontSize:o.font.caption,fontFamily:H.OS==="web"?R:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:o.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:o.color.text,fontSize:o.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:o.color.textSecondary,fontSize:o.font.caption},factValue:{color:o.color.text,fontSize:o.font.caption,fontWeight:"500"},carouselTitle:{color:o.color.text,fontSize:o.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:o.radius.card,borderWidth:I.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:o.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:o.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:o.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:o.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:o.color.accent},stepFailed:{backgroundColor:o.color.danger},stepRunning:{backgroundColor:o.color.info},stepNum:{color:o.color.text,fontSize:o.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:o.radius.chip,backgroundColor:o.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:o.color.info},cpText:{color:o.color.textSecondary,fontSize:o.font.caption},cpRestore:{color:o.color.accent,fontSize:o.font.caption,fontWeight:"600"},taskHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,paddingHorizontal:12,paddingTop:12},banner:{flexDirection:"row",alignItems:"center",gap:8,paddingLeft:12,paddingRight:4,paddingVertical:4,borderRadius:o.radius.row,borderWidth:I.hairlineWidth},bannerText:{flex:1,fontSize:o.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:o.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:o.color.textSecondary,fontSize:10,fontWeight:"800"}});
@@ -1,2 +1,2 @@
1
- "use strict";import{useState as R}from"react";import{Pressable as y,StyleSheet as w,Text as l,View as p}from"react-native";import{AlertTriangle as I,ChevronRight as O,Eye as S,night as t,NightSegmented as z}from"@buoy-gg/shared-ui";import{CAPS as m}from"@buoy-gg/agent-core";import{useBlockHandlers as g}from"./context";import{ActionRow as T,blockStyles as s,Card as h,More as b,usePaged as x}from"./primitives";import{jsx as r,jsxs as d}from"react/jsx-runtime";function C(e){if(e===void 0)return t.color.textTertiary;if(e>=500)return t.color.danger;if(e>=400)return t.color.warning;if(e>=300)return t.color.info;return t.color.accent}function $(e){try{const a=new URL(e);return a.pathname+(a.search?"?\u2026":"")}catch{return e}}function v({status:e}){return r(p,{style:[s.pill,{backgroundColor:`${C(e)}22`}],children:r(l,{style:[s.pillText,{color:C(e)}],children:e??"\u2026"})})}export function RequestList({block:e}){const a=g();const c=a.supports?.openTool!==false;const i=x(e.requests,m.listItems);const{visible:o}=i;return d(h,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[o.map((u,f)=>d(y,{disabled:!c,onPress:()=>void a.runAction({label:"Open in Network",openTool:{toolId:"network",select:u.id}},e.id),style:[s.row,f>0&&s.rowDivider],accessibilityRole:c?"button":void 0,children:[r(l,{style:n.method,children:u.method}),r(l,{style:s.rowTitle,numberOfLines:1,children:$(u.url)}),u.mocked?r(l,{style:n.mockedChip,children:"MOCKED"}):null,u.durationMs!==void 0?d(l,{style:s.rowTrailing,children:[u.durationMs," ms"]}):null,r(v,{status:u.status}),c?r(O,{size:12,color:t.color.textTertiary}):null]},`${u.id}-${f}`)),r(b,{paged:i})]})}const D=[{key:"response",label:"Response"},{key:"request",label:"Request"}];export function RequestCard({block:e}){const[a,c]=R("response");const i=a==="response"?e.responseBody:e.requestBody;const o=i===void 0?"(none)":typeof i==="string"?i:JSON.stringify(i,null,2);const u=g();return d(h,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[d(p,{style:[s.row,n.reqHead],children:[r(l,{style:n.method,children:e.request.method}),r(l,{style:s.rowTitle,numberOfLines:2,children:$(e.request.url)}),e.request.mocked?r(l,{style:n.mockedChip,children:"MOCKED"}):null,r(v,{status:e.request.status})]}),r(p,{style:n.tabs,children:r(z,{tabs:D,activeKey:a,onChange:f=>c(f),size:"sm"})}),r(l,{style:[s.mono,n.body],numberOfLines:14,selectable:true,children:o.length>1600?`${o.slice(0,1600)}
2
- \u2026`:o}),r(T,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),u.supports?.openTool===false?null:null]})}export function RuleCard({block:e}){const a=g();const c=a.rules?.[e.rule.id];const i=c?.deleted===true;const o={...e.rule,enabled:i?false:c?.enabled??e.rule.enabled};const u=o.kind==="fail"?"fails (no network)":o.kind==="delay"?`delayed ${o.delayMs??0} ms`:`returns ${o.status??200}`;return d(h,{title:o.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:o.enabled?"warning":void 0,children:[d(p,{style:n.ruleBody,children:[d(l,{style:n.ruleLine,children:[d(l,{style:n.ruleKey,children:[o.methods?.length?o.methods.join("/"):"ANY"," "]}),r(l,{style:s.mono,children:o.urlPattern})]}),d(l,{style:n.ruleLine,children:[r(l,{style:n.ruleKey,children:"\u2192 "}),u,o.times?` \xB7 ${o.times===1?"once":`${o.times} times`}`:" \xB7 every time",o.hits!==void 0?` \xB7 ${o.hits} hit${o.hits===1?"":"s"}`:""]}),r(p,{style:[s.pill,o.enabled?n.on:n.off],children:r(l,{style:[s.pillText,{color:o.enabled?t.color.onAccent:t.color.textSecondary}],children:i?"DELETED":o.enabled?"ON":"OFF"})})]}),i?null:r(T,{blockId:e.id,actions:[o.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:o.id,enabled:false}}}:{label:"Turn on",primary:true,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:o.id,enabled:true}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:o.id}}}]})]})}export function ScreenElements({block:e}){const a=g();const c=x(e.elements,m.chips);const{visible:i}=c;return d(h,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[i.map((o,u)=>d(y,{onPress:()=>void a.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:o.nativeTag}}},e.id),disabled:a.supports?.dispatch===false,style:[s.row,u>0&&s.rowDivider],accessibilityRole:"button",children:[r(S,{size:12,color:t.color.textTertiary}),r(l,{style:s.rowTitle,numberOfLines:1,children:o.label??o.testID??o.name}),r(l,{style:s.rowTrailing,numberOfLines:1,children:o.name})]},`${o.nativeTag}-${u}`)),r(b,{paged:c})]})}export function RouteChips({block:e}){const a=g();const c=x(e.routes,m.chips);const i=c.visible;return d(h,{title:e.current?`Routes \xB7 you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[r(p,{style:n.chips,children:i.map((o,u)=>r(y,{disabled:a.supports?.dispatch===false,onPress:()=>o.dynamic?a.answer({blockId:e.id,kind:"input",value:`Open ${o.path} \u2014 which id?`}):void a.runAction({label:`Open ${o.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:o.path}}},e.id),style:[n.chip,o.path===e.current&&n.chipCurrent],accessibilityRole:"button",children:r(l,{style:[n.chipText,o.dynamic&&n.chipDynamic],children:o.path})},`${o.path}-${u}`))}),r(b,{paged:c})]})}const L={error:t.color.danger,warn:t.color.warning,warning:t.color.warning,info:t.color.info};export function LogList({block:e}){const a=x(e.entries,m.listItems);const{visible:c}=a;return d(h,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[c.map((i,o)=>d(p,{style:[s.row,o>0&&s.rowDivider,n.logRow],children:[r(p,{style:[s.pill,{backgroundColor:`${L[i.level]??t.color.textTertiary}22`}],children:r(l,{style:[s.pillText,{color:L[i.level]??t.color.textSecondary}],children:i.level.toUpperCase()})}),r(l,{style:[s.rowTitle,s.mono],numberOfLines:3,children:i.message}),i.count>1?d(l,{style:s.rowTrailing,children:["\xD7",i.count]}):null]},`${i.level}-${i.message}-${o}`)),r(b,{paged:a})]})}export function Crash({block:e}){return d(h,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[d(p,{style:n.crashHead,children:[r(I,{size:14,color:t.color.danger}),d(l,{style:n.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),r(l,{style:[s.mono,n.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?d(l,{style:n.suspect,children:["Most likely cause: ",e.suspect.label]}):null,r(T,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:true}]:[],...e.actions??[]].slice(0,2)})]})}export function Peek({block:e}){const a=g();const c=a.supports?.minimize!==false;return d(y,{testID:`buoy-block-peek-${e.id}`,disabled:!c,onPress:()=>void a.runAction({label:"Look",minimize:true},e.id),style:({pressed:i})=>[n.peek,i&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[r(l,{style:n.peekText,children:e.label}),c?d(p,{style:n.peekLook,children:[r(S,{size:12,color:t.color.accent}),r(l,{style:n.peekLookText,children:"Look"})]}):null]})}const n=w.create({method:{color:t.color.textSecondary,fontSize:t.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:t.color.warning,backgroundColor:t.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:t.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:t.radius.badge,backgroundColor:t.color.fill},tabOn:{backgroundColor:t.color.accentSoft},tabText:{color:t.color.textSecondary,fontSize:t.font.micro,fontWeight:"600"},tabTextOn:{color:t.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:t.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:t.color.text,fontSize:t.font.caption,lineHeight:18},ruleKey:{color:t.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:t.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:t.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:t.radius.chip,backgroundColor:t.color.fill,borderWidth:w.hairlineWidth,borderColor:t.color.border},chipCurrent:{backgroundColor:t.color.accentSoft,borderColor:t.color.accentBorderStrong},chipText:{color:t.color.text,fontSize:t.font.caption,fontFamily:"Menlo"},chipDynamic:{color:t.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:t.color.danger,fontSize:t.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:t.color.text},suspect:{color:t.color.textSecondary,fontSize:t.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:t.radius.chip,backgroundColor:t.color.fill},peekText:{color:t.color.textSecondary,fontSize:t.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:t.color.accent,fontSize:t.font.caption,fontWeight:"600"}});
1
+ "use strict";import{monoFont as O}from"@buoy-gg/shared-ui";import{Platform as R}from"react-native";import{useState as I}from"react";import{Pressable as y,StyleSheet as T,Text as l,View as p}from"react-native";import{AlertTriangle as z,ChevronRight as D,Eye as S,night as t,NightSegmented as k}from"@buoy-gg/shared-ui";import{CAPS as m}from"@buoy-gg/agent-core";import{useBlockHandlers as g}from"./context";import{ActionRow as w,blockStyles as s,Card as h,More as b,usePaged as x}from"./primitives";import{jsx as r,jsxs as d}from"react/jsx-runtime";function C(e){if(e===void 0)return t.color.textTertiary;if(e>=500)return t.color.danger;if(e>=400)return t.color.warning;if(e>=300)return t.color.info;return t.color.accent}function $(e){try{const a=new URL(e);return a.pathname+(a.search?"?\u2026":"")}catch{return e}}function v({status:e}){return r(p,{style:[s.pill,{backgroundColor:`${C(e)}22`}],children:r(l,{style:[s.pillText,{color:C(e)}],children:e??"\u2026"})})}export function RequestList({block:e}){const a=g();const c=a.supports?.openTool!==false;const i=x(e.requests,m.listItems);const{visible:o}=i;return d(h,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[o.map((u,f)=>d(y,{disabled:!c,onPress:()=>void a.runAction({label:"Open in Network",openTool:{toolId:"network",select:u.id}},e.id),style:[s.row,f>0&&s.rowDivider],accessibilityRole:c?"button":void 0,children:[r(l,{style:n.method,children:u.method}),r(l,{style:s.rowTitle,numberOfLines:1,children:$(u.url)}),u.mocked?r(l,{style:n.mockedChip,children:"MOCKED"}):null,u.durationMs!==void 0?d(l,{style:s.rowTrailing,children:[u.durationMs," ms"]}):null,r(v,{status:u.status}),c?r(D,{size:12,color:t.color.textTertiary}):null]},`${u.id}-${f}`)),r(b,{paged:i})]})}const H=[{key:"response",label:"Response"},{key:"request",label:"Request"}];export function RequestCard({block:e}){const[a,c]=I("response");const i=a==="response"?e.responseBody:e.requestBody;const o=i===void 0?"(none)":typeof i==="string"?i:JSON.stringify(i,null,2);const u=g();return d(h,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[d(p,{style:[s.row,n.reqHead],children:[r(l,{style:n.method,children:e.request.method}),r(l,{style:s.rowTitle,numberOfLines:2,children:$(e.request.url)}),e.request.mocked?r(l,{style:n.mockedChip,children:"MOCKED"}):null,r(v,{status:e.request.status})]}),r(p,{style:n.tabs,children:r(k,{tabs:H,activeKey:a,onChange:f=>c(f),size:"sm"})}),r(l,{style:[s.mono,n.body],numberOfLines:14,selectable:true,children:o.length>1600?`${o.slice(0,1600)}
2
+ \u2026`:o}),r(w,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),u.supports?.openTool===false?null:null]})}export function RuleCard({block:e}){const a=g();const c=a.rules?.[e.rule.id];const i=c?.deleted===true;const o={...e.rule,enabled:i?false:c?.enabled??e.rule.enabled};const u=o.kind==="fail"?"fails (no network)":o.kind==="delay"?`delayed ${o.delayMs??0} ms`:`returns ${o.status??200}`;return d(h,{title:o.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:o.enabled?"warning":void 0,children:[d(p,{style:n.ruleBody,children:[d(l,{style:n.ruleLine,children:[d(l,{style:n.ruleKey,children:[o.methods?.length?o.methods.join("/"):"ANY"," "]}),r(l,{style:s.mono,children:o.urlPattern})]}),d(l,{style:n.ruleLine,children:[r(l,{style:n.ruleKey,children:"\u2192 "}),u,o.times?` \xB7 ${o.times===1?"once":`${o.times} times`}`:" \xB7 every time",o.hits!==void 0?` \xB7 ${o.hits} hit${o.hits===1?"":"s"}`:""]}),r(p,{style:[s.pill,o.enabled?n.on:n.off],children:r(l,{style:[s.pillText,{color:o.enabled?t.color.onAccent:t.color.textSecondary}],children:i?"DELETED":o.enabled?"ON":"OFF"})})]}),i?null:r(w,{blockId:e.id,actions:[o.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:o.id,enabled:false}}}:{label:"Turn on",primary:true,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:o.id,enabled:true}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:o.id}}}]})]})}export function ScreenElements({block:e}){const a=g();const c=x(e.elements,m.chips);const{visible:i}=c;return d(h,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[i.map((o,u)=>d(y,{onPress:()=>void a.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:o.nativeTag}}},e.id),disabled:a.supports?.dispatch===false,style:[s.row,u>0&&s.rowDivider],accessibilityRole:"button",children:[r(S,{size:12,color:t.color.textTertiary}),r(l,{style:s.rowTitle,numberOfLines:1,children:o.label??o.testID??o.name}),r(l,{style:s.rowTrailing,numberOfLines:1,children:o.name})]},`${o.nativeTag}-${u}`)),r(b,{paged:c})]})}export function RouteChips({block:e}){const a=g();const c=x(e.routes,m.chips);const i=c.visible;return d(h,{title:e.current?`Routes \xB7 you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[r(p,{style:n.chips,children:i.map((o,u)=>r(y,{disabled:a.supports?.dispatch===false,onPress:()=>o.dynamic?a.answer({blockId:e.id,kind:"input",value:`Open ${o.path} \u2014 which id?`}):void a.runAction({label:`Open ${o.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:o.path}}},e.id),style:[n.chip,o.path===e.current&&n.chipCurrent],accessibilityRole:"button",children:r(l,{style:[n.chipText,o.dynamic&&n.chipDynamic],children:o.path})},`${o.path}-${u}`))}),r(b,{paged:c})]})}const L={error:t.color.danger,warn:t.color.warning,warning:t.color.warning,info:t.color.info};export function LogList({block:e}){const a=x(e.entries,m.listItems);const{visible:c}=a;return d(h,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[c.map((i,o)=>d(p,{style:[s.row,o>0&&s.rowDivider,n.logRow],children:[r(p,{style:[s.pill,{backgroundColor:`${L[i.level]??t.color.textTertiary}22`}],children:r(l,{style:[s.pillText,{color:L[i.level]??t.color.textSecondary}],children:i.level.toUpperCase()})}),r(l,{style:[s.rowTitle,s.mono],numberOfLines:3,children:i.message}),i.count>1?d(l,{style:s.rowTrailing,children:["\xD7",i.count]}):null]},`${i.level}-${i.message}-${o}`)),r(b,{paged:a})]})}export function Crash({block:e}){return d(h,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[d(p,{style:n.crashHead,children:[r(z,{size:14,color:t.color.danger}),d(l,{style:n.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),r(l,{style:[s.mono,n.crashMsg],numberOfLines:4,selectable:true,children:e.message}),e.suspect?d(l,{style:n.suspect,children:["Most likely cause: ",e.suspect.label]}):null,r(w,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:true}]:[],...e.actions??[]].slice(0,2)})]})}export function Peek({block:e}){const a=g();const c=a.supports?.minimize!==false;return d(y,{testID:`buoy-block-peek-${e.id}`,disabled:!c,onPress:()=>void a.runAction({label:"Look",minimize:true},e.id),style:({pressed:i})=>[n.peek,i&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[r(l,{style:n.peekText,children:e.label}),c?d(p,{style:n.peekLook,children:[r(S,{size:12,color:t.color.accent}),r(l,{style:n.peekLookText,children:"Look"})]}):null]})}const n=T.create({method:{color:t.color.textSecondary,fontSize:t.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:t.color.warning,backgroundColor:t.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:t.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:t.radius.badge,backgroundColor:t.color.fill},tabOn:{backgroundColor:t.color.accentSoft},tabText:{color:t.color.textSecondary,fontSize:t.font.micro,fontWeight:"600"},tabTextOn:{color:t.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:t.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:t.color.text,fontSize:t.font.caption,lineHeight:18},ruleKey:{color:t.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:t.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:t.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:t.radius.chip,backgroundColor:t.color.fill,borderWidth:T.hairlineWidth,borderColor:t.color.border},chipCurrent:{backgroundColor:t.color.accentSoft,borderColor:t.color.accentBorderStrong},chipText:{color:t.color.text,fontSize:t.font.caption,fontFamily:R.OS==="web"?O:"Menlo"},chipDynamic:{color:t.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:t.color.danger,fontSize:t.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:t.color.text},suspect:{color:t.color.textSecondary,fontSize:t.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:t.radius.chip,backgroundColor:t.color.fill},peekText:{color:t.color.textSecondary,fontSize:t.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:t.color.accent,fontSize:t.font.caption,fontWeight:"600"}});
@@ -1 +1 @@
1
- "use strict";import{useState as m}from"react";import{ActivityIndicator as S,Pressable as y,StyleSheet as f,Text as g,View as p}from"react-native";import{Check as C,ChevronDown as w,ChevronUp as T,night as o,X as z}from"@buoy-gg/shared-ui";import{actionKey as D,useBlockHandlers as W}from"./context";import{pageState as P}from"./pageState";import{jsx as l,jsxs as u}from"react/jsx-runtime";export function toneColor(r){switch(r){case"accent":return o.color.accent;case"warning":return o.color.warning;case"danger":return o.color.danger;case"info":return o.color.info;case"muted":return o.color.textTertiary;default:return o.color.text}}export function ProvenanceBadge({source:r}){if(!r||r==="live")return null;const n=r==="changed"?"CHANGED BY ASK BUOY":r==="mocked"?"MOCKED":"FROM THE MODEL";const c=r==="changed"?o.color.warning:r==="mocked"?o.color.danger:o.color.textTertiary;return l(p,{style:[e.badge,{borderColor:c}],children:l(g,{style:[e.badgeText,{color:c}],children:n})})}export function Card({title:r,source:n,children:c,testID:i,tone:d,collapsible:t,summary:a}){const[s,b]=m(false);const h=!!t&&!s;return u(p,{style:[e.card,d==="warning"&&e.cardWarning,d==="danger"&&e.cardDanger,d==="info"&&e.cardInfo],testID:i,children:[(r||n&&n!=="live")&&u(p,{style:e.titleRow,children:[r?l(g,{style:e.title,numberOfLines:2,children:r}):l(p,{style:e.flex}),l(ProvenanceBadge,{source:n})]}),t?u(y,{testID:i?`${i}-toggle`:void 0,onPress:()=>b(x=>!x),accessibilityRole:"button",accessibilityState:{expanded:s},accessibilityLabel:`${a??"Details"}, ${s?"hide":"show"}`,style:({pressed:x})=>[e.disclosure,!h&&e.disclosureOpen,x&&e.pressed],children:[l(g,{style:e.disclosureText,numberOfLines:1,children:a??"Details"}),h?l(w,{size:12,color:o.color.textTertiary}):l(T,{size:12,color:o.color.textTertiary})]}):null,h?null:c]})}const R=5;export function usePaged(r,n,c=R){const[i,d]=m(n);const{hidden:t,next:a,expanded:s,canExpand:b,canCollapse:h}=P(r.length,n,i,c);return{visible:r.slice(0,i),hidden:t,next:a,expanded:s,showMore:b?()=>d(x=>x+c):void 0,showLess:h?()=>d(n):void 0}}export function More({paged:r}){const{next:n,showMore:c,showLess:i}=r;if(!c&&!i)return null;return u(p,{style:e.moreRow,children:[c?u(y,{testID:"buoy-block-show-more",onPress:c,style:[e.more,e.moreCell],accessibilityRole:"button",children:[u(g,{style:e.moreText,children:["Show ",n," more"]}),l(w,{size:12,color:o.color.textTertiary})]}):null,i?u(y,{testID:"buoy-block-show-fewer",onPress:i,style:[e.more,e.moreCell],accessibilityRole:"button",children:[l(g,{style:e.moreText,children:"Show fewer"}),l(T,{size:12,color:o.color.textTertiary})]}):null]})}export function MoreNote({shown:r,total:n}){if(!n||n<=r)return null;return l(p,{style:e.more,children:u(g,{style:e.moreNote,children:[r," of ",n," shown"]})})}export function ActionRow({actions:r,blockId:n,align:c="left"}){const i=W();if(!r?.length)return null;const d=r.filter(t=>{if(t.openTool)return i.supports?.openTool!==false;if(t.minimize)return i.supports?.minimize!==false;if(t.dispatch)return i.supports?.dispatch!==false;return true});if(d.length===0)return null;return l(p,{style:[e.actions,c==="right"&&e.actionsRight],children:d.slice(0,2).map(t=>{const a=i.actionState?.[D(n,t)];const s=!!i.busy||a==="running"||a==="done";return u(y,{accessibilityRole:"button",accessibilityLabel:t.label,testID:`buoy-block-action-${t.label.toLowerCase().replace(/\s+/g,"-")}`,disabled:s,onPress:()=>void i.runAction(t,n),style:({pressed:b})=>[e.button,t.primary?e.buttonPrimary:e.buttonPlate,s&&e.buttonDisabled,b&&!s&&e.pressed],children:[a==="running"?l(S,{size:"small",color:t.primary?o.color.onAccent:o.color.text}):a==="done"?l(C,{size:12,color:t.primary?o.color.onAccent:o.color.accent}):a==="failed"?l(z,{size:12,color:o.color.danger}):null,l(g,{style:[e.buttonText,t.primary?e.buttonTextPrimary:e.buttonTextPlate],children:t.label})]},t.label)})})}export const blockStyles=f.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:f.hairlineWidth,borderTopColor:o.color.separator},rowTitle:{flex:1,color:o.color.text,fontSize:o.font.body,lineHeight:19},rowSub:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:17},rowTrailing:{color:o.color.textTertiary,fontSize:o.font.caption,maxWidth:120,textAlign:"right"},mono:{fontFamily:"Menlo",fontSize:12,color:o.color.text},pill:{paddingHorizontal:7,paddingVertical:2,borderRadius:o.radius.badge,backgroundColor:o.color.fill},pillText:{fontSize:o.font.micro,fontWeight:"700",letterSpacing:.4,color:o.color.textSecondary}});const e=f.create({card:{borderRadius:o.radius.card,borderWidth:f.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},cardWarning:{borderColor:o.color.warning,backgroundColor:o.color.warningSoft},cardDanger:{borderColor:o.color.danger,backgroundColor:o.color.dangerSoft},cardInfo:{borderColor:o.color.accentBorderStrong,backgroundColor:o.color.accentSoft},titleRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:6},flex:{flex:1},title:{flex:1,color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},disclosure:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:9},disclosureOpen:{borderBottomWidth:f.hairlineWidth,borderBottomColor:o.color.separator},disclosureText:{flex:1,color:o.color.textSecondary,fontSize:o.font.caption},badge:{borderWidth:f.hairlineWidth,borderRadius:o.radius.badge,paddingHorizontal:6,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.6},moreRow:{flexDirection:"row"},more:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:4,paddingVertical:9,paddingHorizontal:8,borderTopWidth:f.hairlineWidth,borderTopColor:o.color.separator},moreCell:{flex:1},moreText:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"600"},moreNote:{color:o.color.textTertiary,fontSize:o.font.caption},actions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:10,flexWrap:"wrap"},actionsRight:{justifyContent:"flex-end"},button:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:14,paddingVertical:9,borderRadius:o.radius.row},buttonPrimary:{backgroundColor:o.color.accent},buttonPlate:{backgroundColor:o.color.button},buttonDisabled:{opacity:.55},buttonText:{fontSize:o.font.caption,fontWeight:"600"},buttonTextPrimary:{color:o.color.onAccent},buttonTextPlate:{color:o.color.text},pressed:{opacity:.7}});
1
+ "use strict";import{monoFont as T}from"@buoy-gg/shared-ui";import{Platform as C}from"react-native";import{useState as y}from"react";import{ActivityIndicator as z,Pressable as m,StyleSheet as f,Text as g,View as p}from"react-native";import{Check as D,ChevronDown as w,ChevronUp as S,night as o,X as W}from"@buoy-gg/shared-ui";import{actionKey as P,useBlockHandlers as R}from"./context";import{pageState as k}from"./pageState";import{jsx as l,jsxs as u}from"react/jsx-runtime";export function toneColor(r){switch(r){case"accent":return o.color.accent;case"warning":return o.color.warning;case"danger":return o.color.danger;case"info":return o.color.info;case"muted":return o.color.textTertiary;default:return o.color.text}}export function ProvenanceBadge({source:r}){if(!r||r==="live")return null;const n=r==="changed"?"CHANGED BY ASK BUOY":r==="mocked"?"MOCKED":"FROM THE MODEL";const c=r==="changed"?o.color.warning:r==="mocked"?o.color.danger:o.color.textTertiary;return l(p,{style:[e.badge,{borderColor:c}],children:l(g,{style:[e.badgeText,{color:c}],children:n})})}export function Card({title:r,source:n,children:c,testID:i,tone:d,collapsible:t,summary:a}){const[s,b]=y(false);const h=!!t&&!s;return u(p,{style:[e.card,d==="warning"&&e.cardWarning,d==="danger"&&e.cardDanger,d==="info"&&e.cardInfo],testID:i,children:[(r||n&&n!=="live")&&u(p,{style:e.titleRow,children:[r?l(g,{style:e.title,numberOfLines:2,children:r}):l(p,{style:e.flex}),l(ProvenanceBadge,{source:n})]}),t?u(m,{testID:i?`${i}-toggle`:void 0,onPress:()=>b(x=>!x),accessibilityRole:"button",accessibilityState:{expanded:s},accessibilityLabel:`${a??"Details"}, ${s?"hide":"show"}`,style:({pressed:x})=>[e.disclosure,!h&&e.disclosureOpen,x&&e.pressed],children:[l(g,{style:e.disclosureText,numberOfLines:1,children:a??"Details"}),h?l(w,{size:12,color:o.color.textTertiary}):l(S,{size:12,color:o.color.textTertiary})]}):null,h?null:c]})}const H=5;export function usePaged(r,n,c=H){const[i,d]=y(n);const{hidden:t,next:a,expanded:s,canExpand:b,canCollapse:h}=k(r.length,n,i,c);return{visible:r.slice(0,i),hidden:t,next:a,expanded:s,showMore:b?()=>d(x=>x+c):void 0,showLess:h?()=>d(n):void 0}}export function More({paged:r}){const{next:n,showMore:c,showLess:i}=r;if(!c&&!i)return null;return u(p,{style:e.moreRow,children:[c?u(m,{testID:"buoy-block-show-more",onPress:c,style:[e.more,e.moreCell],accessibilityRole:"button",children:[u(g,{style:e.moreText,children:["Show ",n," more"]}),l(w,{size:12,color:o.color.textTertiary})]}):null,i?u(m,{testID:"buoy-block-show-fewer",onPress:i,style:[e.more,e.moreCell],accessibilityRole:"button",children:[l(g,{style:e.moreText,children:"Show fewer"}),l(S,{size:12,color:o.color.textTertiary})]}):null]})}export function MoreNote({shown:r,total:n}){if(!n||n<=r)return null;return l(p,{style:e.more,children:u(g,{style:e.moreNote,children:[r," of ",n," shown"]})})}export function ActionRow({actions:r,blockId:n,align:c="left"}){const i=R();if(!r?.length)return null;const d=r.filter(t=>{if(t.openTool)return i.supports?.openTool!==false;if(t.minimize)return i.supports?.minimize!==false;if(t.dispatch)return i.supports?.dispatch!==false;return true});if(d.length===0)return null;return l(p,{style:[e.actions,c==="right"&&e.actionsRight],children:d.slice(0,2).map(t=>{const a=i.actionState?.[P(n,t)];const s=!!i.busy||a==="running"||a==="done";return u(m,{accessibilityRole:"button",accessibilityLabel:t.label,testID:`buoy-block-action-${t.label.toLowerCase().replace(/\s+/g,"-")}`,disabled:s,onPress:()=>void i.runAction(t,n),style:({pressed:b})=>[e.button,t.primary?e.buttonPrimary:e.buttonPlate,s&&e.buttonDisabled,b&&!s&&e.pressed],children:[a==="running"?l(z,{size:"small",color:t.primary?o.color.onAccent:o.color.text}):a==="done"?l(D,{size:12,color:t.primary?o.color.onAccent:o.color.accent}):a==="failed"?l(W,{size:12,color:o.color.danger}):null,l(g,{style:[e.buttonText,t.primary?e.buttonTextPrimary:e.buttonTextPlate],children:t.label})]},t.label)})})}export const blockStyles=f.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:f.hairlineWidth,borderTopColor:o.color.separator},rowTitle:{flex:1,color:o.color.text,fontSize:o.font.body,lineHeight:19},rowSub:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:17},rowTrailing:{color:o.color.textTertiary,fontSize:o.font.caption,maxWidth:120,textAlign:"right"},mono:{fontFamily:C.OS==="web"?T:"Menlo",fontSize:12,color:o.color.text},pill:{paddingHorizontal:7,paddingVertical:2,borderRadius:o.radius.badge,backgroundColor:o.color.fill},pillText:{fontSize:o.font.micro,fontWeight:"700",letterSpacing:.4,color:o.color.textSecondary}});const e=f.create({card:{borderRadius:o.radius.card,borderWidth:f.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},cardWarning:{borderColor:o.color.warning,backgroundColor:o.color.warningSoft},cardDanger:{borderColor:o.color.danger,backgroundColor:o.color.dangerSoft},cardInfo:{borderColor:o.color.accentBorderStrong,backgroundColor:o.color.accentSoft},titleRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:6},flex:{flex:1},title:{flex:1,color:o.color.text,fontSize:o.font.caption,fontWeight:"600"},disclosure:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:9},disclosureOpen:{borderBottomWidth:f.hairlineWidth,borderBottomColor:o.color.separator},disclosureText:{flex:1,color:o.color.textSecondary,fontSize:o.font.caption},badge:{borderWidth:f.hairlineWidth,borderRadius:o.radius.badge,paddingHorizontal:6,paddingVertical:2},badgeText:{fontSize:9,fontWeight:"700",letterSpacing:.6},moreRow:{flexDirection:"row"},more:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:4,paddingVertical:9,paddingHorizontal:8,borderTopWidth:f.hairlineWidth,borderTopColor:o.color.separator},moreCell:{flex:1},moreText:{color:o.color.textSecondary,fontSize:o.font.caption,fontWeight:"600"},moreNote:{color:o.color.textTertiary,fontSize:o.font.caption},actions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:10,flexWrap:"wrap"},actionsRight:{justifyContent:"flex-end"},button:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:14,paddingVertical:9,borderRadius:o.radius.row},buttonPrimary:{backgroundColor:o.color.accent},buttonPlate:{backgroundColor:o.color.button},buttonDisabled:{opacity:.55},buttonText:{fontSize:o.font.caption,fontWeight:"600"},buttonTextPrimary:{color:o.color.onAccent},buttonTextPlate:{color:o.color.text},pressed:{opacity:.7}});
@@ -1 +1 @@
1
- "use strict";import{Pressable as p,StyleSheet as c,Text as r,View as l}from"react-native";import{ChevronRight as b,night as e,NightSectionLabel as f}from"@buoy-gg/shared-ui";import{pickSuggestions as m}from"../store/suggestions";import{jsx as t,jsxs as n}from"react/jsx-runtime";const h=typeof __DEV__!=="undefined"&&!__DEV__;export function EmptyState({configured:i,onPick:s,availableToolIds:a=[],readOnly:d=false}){const u=m({availableToolIds:a,readOnly:d,isRelease:h});if(!i){return n(l,{style:o.wrap,testID:"buoy-ask-buoy-unconfigured",children:[t(r,{style:o.title,children:"Not set up yet"}),n(r,{style:o.body,children:["Ask Buoy talks to your own company's AI endpoint \u2014 nothing goes to Buoy. A developer needs to add the ",t(r,{style:o.code,children:"askBuoy"})," prop to"," ",t(r,{style:o.code,children:"<FloatingDevTools />"})," with your team's endpoint and model."]})]})}return n(l,{style:o.wrap,testID:"buoy-ask-buoy-empty",children:[t(r,{style:o.title,children:"Ask about this app"}),t(r,{style:o.body,children:"Ask what the app is doing right now, or tell it to change something. Anything it changes shows up in a bar at the top, with what can be undone."}),t(r,{style:o.buildLine,testID:"buoy-ask-buoy-build-line",children:h?"Release build \u2014 reading, impersonation and navigation work; simulations (forcing server responses, driving the screen) need a dev build.":"Dev build \u2014 full simulation available."}),n(l,{style:o.group,children:[t(f,{children:"Try asking"}),t(l,{style:o.card,children:u.map((g,y)=>t(w,{text:g,onPick:s,last:y===u.length-1},g))})]})]})}function w({text:i,onPick:s,last:a}){return n(p,{testID:`buoy-ask-buoy-suggestion-${i.slice(0,12)}`,accessibilityRole:"button",onPress:()=>s(i),style:({pressed:d})=>[o.row,!a&&o.rowDivider,d&&o.pressed],children:[t(r,{style:o.rowText,children:i}),t(b,{size:14,color:e.color.textTertiary})]})}const o=c.create({wrap:{flex:1,justifyContent:"center",paddingHorizontal:e.gutter,paddingVertical:24,gap:8},title:{color:e.color.text,fontSize:22,fontWeight:"700",letterSpacing:-.3},body:{color:e.color.textSecondary,fontSize:e.font.body,lineHeight:20},code:{color:e.color.text,fontFamily:"Menlo"},buildLine:{marginTop:8,color:e.color.textTertiary,fontSize:e.font.micro,lineHeight:15},group:{marginTop:e.groupGap-8},card:{borderRadius:e.radius.card,borderWidth:c.hairlineWidth,borderColor:e.color.border,backgroundColor:e.color.surface,overflow:"hidden"},row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:e.rowPadH,paddingVertical:13},rowDivider:{borderBottomWidth:c.hairlineWidth,borderBottomColor:e.color.separator},rowText:{flex:1,color:e.color.text,fontSize:e.font.body,lineHeight:19},pressed:{backgroundColor:e.color.fill}});
1
+ "use strict";import{monoFont as y}from"@buoy-gg/shared-ui";import{Platform as b}from"react-native";import{Pressable as f,StyleSheet as c,Text as r,View as l}from"react-native";import{ChevronRight as m,night as o,NightSectionLabel as w}from"@buoy-gg/shared-ui";import{pickSuggestions as x}from"../store/suggestions";import{jsx as t,jsxs as n}from"react/jsx-runtime";const h=typeof __DEV__!=="undefined"&&!__DEV__;export function EmptyState({configured:i,onPick:s,availableToolIds:a=[],readOnly:d=false}){const u=x({availableToolIds:a,readOnly:d,isRelease:h});if(!i){return n(l,{style:e.wrap,testID:"buoy-ask-buoy-unconfigured",children:[t(r,{style:e.title,children:"Not set up yet"}),n(r,{style:e.body,children:["Ask Buoy talks to your own company's AI endpoint \u2014 nothing goes to Buoy. A developer needs to add the ",t(r,{style:e.code,children:"askBuoy"})," prop to"," ",t(r,{style:e.code,children:"<FloatingDevTools />"})," with your team's endpoint and model."]})]})}return n(l,{style:e.wrap,testID:"buoy-ask-buoy-empty",children:[t(r,{style:e.title,children:"Ask about this app"}),t(r,{style:e.body,children:"Ask what the app is doing right now, or tell it to change something. Anything it changes shows up in a bar at the top, with what can be undone."}),t(r,{style:e.buildLine,testID:"buoy-ask-buoy-build-line",children:h?"Release build \u2014 reading, impersonation and navigation work; simulations (forcing server responses, driving the screen) need a dev build.":"Dev build \u2014 full simulation available."}),n(l,{style:e.group,children:[t(w,{children:"Try asking"}),t(l,{style:e.card,children:u.map((g,p)=>t(k,{text:g,onPick:s,last:p===u.length-1},g))})]})]})}function k({text:i,onPick:s,last:a}){return n(f,{testID:`buoy-ask-buoy-suggestion-${i.slice(0,12)}`,accessibilityRole:"button",onPress:()=>s(i),style:({pressed:d})=>[e.row,!a&&e.rowDivider,d&&e.pressed],children:[t(r,{style:e.rowText,children:i}),t(m,{size:14,color:o.color.textTertiary})]})}const e=c.create({wrap:{flex:1,justifyContent:"center",paddingHorizontal:o.gutter,paddingVertical:24,gap:8},title:{color:o.color.text,fontSize:22,fontWeight:"700",letterSpacing:-.3},body:{color:o.color.textSecondary,fontSize:o.font.body,lineHeight:20},code:{color:o.color.text,fontFamily:b.OS==="web"?y:"Menlo"},buildLine:{marginTop:8,color:o.color.textTertiary,fontSize:o.font.micro,lineHeight:15},group:{marginTop:o.groupGap-8},card:{borderRadius:o.radius.card,borderWidth:c.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:o.rowPadH,paddingVertical:13},rowDivider:{borderBottomWidth:c.hairlineWidth,borderBottomColor:o.color.separator},rowText:{flex:1,color:o.color.text,fontSize:o.font.body,lineHeight:19},pressed:{backgroundColor:o.color.fill}});
@@ -1 +1 @@
1
- "use strict";import{useState as m}from"react";import{Pressable as w,ScrollView as y,StyleSheet as x,Text as c,View as p}from"react-native";import{night as t}from"@buoy-gg/shared-ui";import{parseBlocks as S,TABLE_PREVIEW_COLS as W,TABLE_PREVIEW_ROWS as k,tableTruncation as T}from"./markdownParse";import{jsx as r,jsxs as g}from"react/jsx-runtime";export function renderInline(d,i){const l=d.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");const o=[];const s=/(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g;let a=0;let h;let f=0;while(h=s.exec(l)){if(h.index>a)o.push(l.slice(a,h.index));const n=h[0];if(n.startsWith("**")){o.push(r(c,{style:[i,e.bold],children:n.slice(2,-2)},f++))}else if(n.startsWith("`")){o.push(r(c,{style:[i,e.code],children:n.slice(1,-1)},f++))}else{o.push(r(c,{style:[i,e.italic],children:n.slice(1,-1)},f++))}a=h.index+n.length}if(a<l.length)o.push(l.slice(a));return o}const C=d=>d.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");function z({header:d,rows:i}){const[l,o]=m(false);const s=T(d,i);const a=l?d:d.slice(0,W);const h=l?i:i.slice(0,k);const f=g(p,{style:l&&e.tableWide,children:[r(p,{style:e.tableHead,children:a.map((n,u)=>r(c,{style:[e.th,u===0&&e.firstCol,l&&e.colFixed],numberOfLines:1,children:n.replace(/\*\*/g,"")},u))}),h.map((n,u)=>r(p,{style:[e.tr,u>0&&e.trDivider],children:a.map((_,b)=>r(c,{style:[e.td,b===0&&e.firstCol,b===0&&e.tdFirst,l&&e.colFixed],numberOfLines:l?3:2,children:renderInline(C(n[b]??""),e.td)},b))},u))]});return g(p,{style:e.table,testID:"buoy-ask-buoy-md-table",children:[l?r(y,{style:e.tableScrollV,nestedScrollEnabled:true,children:r(y,{horizontal:true,showsHorizontalScrollIndicator:true,children:f})}):f,s?g(w,{testID:"buoy-ask-buoy-md-table-toggle",accessibilityRole:"button",accessibilityLabel:l?"Show fewer rows":"Show all rows and columns",onPress:()=>o(n=>!n),style:({pressed:n})=>[e.tfoot,n&&e.pressed],children:[r(c,{style:e.tfootText,children:l?`All ${i.length} rows \xB7 ${d.length} columns`:s}),r(c,{style:e.tfootAction,children:l?"Show fewer":"Show all"})]}):null]})}export function Markdown({text:d,style:i}){const l=S(d);return r(p,{style:e.wrap,children:l.map((o,s)=>{if(o.kind==="table")return r(z,{header:o.header,rows:o.rows},s);if(o.kind==="code"){return r(y,{horizontal:true,style:e.codeBlock,contentContainerStyle:e.codeBlockContent,testID:"buoy-ask-buoy-md-code",children:r(c,{style:e.codeText,selectable:true,children:o.text})},s)}if(o.kind==="li"){return g(p,{style:[e.li,{paddingLeft:4+o.depth*14}],children:[r(c,{style:[i,e.marker],children:o.marker}),r(c,{style:[i,e.liText],selectable:true,children:renderInline(o.text,i)})]},s)}return r(c,{style:[i,o.kind==="h"&&e.bold],selectable:true,children:renderInline(o.text,i)},s)})})}const e=x.create({wrap:{gap:8},bold:{fontWeight:"600"},italic:{fontStyle:"italic"},code:{fontFamily:"Menlo",fontSize:13,color:t.color.accent,backgroundColor:t.color.fill},codeBlock:{borderRadius:t.radius.row,borderWidth:x.hairlineWidth,borderColor:t.color.border,backgroundColor:t.color.surface},codeBlockContent:{paddingHorizontal:12,paddingVertical:10},codeText:{fontFamily:"Menlo",fontSize:12,lineHeight:18,color:t.color.text},li:{flexDirection:"row",gap:8},table:{borderRadius:t.radius.row,borderWidth:x.hairlineWidth,borderColor:t.color.border,backgroundColor:t.color.surface,overflow:"hidden"},tableWide:{minWidth:"100%"},tableScrollV:{maxHeight:320},tableHead:{flexDirection:"row",paddingHorizontal:10,paddingVertical:6,gap:8,backgroundColor:t.color.fill},th:{flex:1,color:t.color.textTertiary,fontSize:t.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:10,paddingVertical:7,gap:8},trDivider:{borderTopWidth:x.hairlineWidth,borderTopColor:t.color.separator},td:{flex:1,color:t.color.textSecondary,fontSize:t.font.caption,lineHeight:17},tdFirst:{color:t.color.text,fontWeight:"500"},firstCol:{flex:1.3},colFixed:{flex:0,width:110},tfoot:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:10,paddingVertical:8,borderTopWidth:x.hairlineWidth,borderTopColor:t.color.border},tfootText:{color:t.color.textSecondary,fontSize:t.font.micro},tfootAction:{color:t.color.accent,fontSize:t.font.micro,fontWeight:"600"},pressed:{opacity:.7},marker:{color:t.color.textSecondary,minWidth:14,textAlign:"right"},liText:{flex:1}});
1
+ "use strict";import{monoFont as y}from"@buoy-gg/shared-ui";import{Platform as w}from"react-native";import{useState as S}from"react";import{Pressable as W,ScrollView as g,StyleSheet as x,Text as c,View as p}from"react-native";import{night as o}from"@buoy-gg/shared-ui";import{parseBlocks as k,TABLE_PREVIEW_COLS as T,TABLE_PREVIEW_ROWS as C,tableTruncation as z}from"./markdownParse";import{jsx as r,jsxs as m}from"react/jsx-runtime";export function renderInline(d,i){const l=d.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");const t=[];const s=/(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g;let a=0;let h;let f=0;while(h=s.exec(l)){if(h.index>a)t.push(l.slice(a,h.index));const n=h[0];if(n.startsWith("**")){t.push(r(c,{style:[i,e.bold],children:n.slice(2,-2)},f++))}else if(n.startsWith("`")){t.push(r(c,{style:[i,e.code],children:n.slice(1,-1)},f++))}else{t.push(r(c,{style:[i,e.italic],children:n.slice(1,-1)},f++))}a=h.index+n.length}if(a<l.length)t.push(l.slice(a));return t}const _=d=>d.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");function H({header:d,rows:i}){const[l,t]=S(false);const s=z(d,i);const a=l?d:d.slice(0,T);const h=l?i:i.slice(0,C);const f=m(p,{style:l&&e.tableWide,children:[r(p,{style:e.tableHead,children:a.map((n,u)=>r(c,{style:[e.th,u===0&&e.firstCol,l&&e.colFixed],numberOfLines:1,children:n.replace(/\*\*/g,"")},u))}),h.map((n,u)=>r(p,{style:[e.tr,u>0&&e.trDivider],children:a.map((V,b)=>r(c,{style:[e.td,b===0&&e.firstCol,b===0&&e.tdFirst,l&&e.colFixed],numberOfLines:l?3:2,children:renderInline(_(n[b]??""),e.td)},b))},u))]});return m(p,{style:e.table,testID:"buoy-ask-buoy-md-table",children:[l?r(g,{style:e.tableScrollV,nestedScrollEnabled:true,children:r(g,{horizontal:true,showsHorizontalScrollIndicator:true,children:f})}):f,s?m(W,{testID:"buoy-ask-buoy-md-table-toggle",accessibilityRole:"button",accessibilityLabel:l?"Show fewer rows":"Show all rows and columns",onPress:()=>t(n=>!n),style:({pressed:n})=>[e.tfoot,n&&e.pressed],children:[r(c,{style:e.tfootText,children:l?`All ${i.length} rows \xB7 ${d.length} columns`:s}),r(c,{style:e.tfootAction,children:l?"Show fewer":"Show all"})]}):null]})}export function Markdown({text:d,style:i}){const l=k(d);return r(p,{style:e.wrap,children:l.map((t,s)=>{if(t.kind==="table")return r(H,{header:t.header,rows:t.rows},s);if(t.kind==="code"){return r(g,{horizontal:true,style:e.codeBlock,contentContainerStyle:e.codeBlockContent,testID:"buoy-ask-buoy-md-code",children:r(c,{style:e.codeText,selectable:true,children:t.text})},s)}if(t.kind==="li"){return m(p,{style:[e.li,{paddingLeft:4+t.depth*14}],children:[r(c,{style:[i,e.marker],children:t.marker}),r(c,{style:[i,e.liText],selectable:true,children:renderInline(t.text,i)})]},s)}return r(c,{style:[i,t.kind==="h"&&e.bold],selectable:true,children:renderInline(t.text,i)},s)})})}const e=x.create({wrap:{gap:8},bold:{fontWeight:"600"},italic:{fontStyle:"italic"},code:{fontFamily:w.OS==="web"?y:"Menlo",fontSize:13,color:o.color.accent,backgroundColor:o.color.fill},codeBlock:{borderRadius:o.radius.row,borderWidth:x.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface},codeBlockContent:{paddingHorizontal:12,paddingVertical:10},codeText:{fontFamily:w.OS==="web"?y:"Menlo",fontSize:12,lineHeight:18,color:o.color.text},li:{flexDirection:"row",gap:8},table:{borderRadius:o.radius.row,borderWidth:x.hairlineWidth,borderColor:o.color.border,backgroundColor:o.color.surface,overflow:"hidden"},tableWide:{minWidth:"100%"},tableScrollV:{maxHeight:320},tableHead:{flexDirection:"row",paddingHorizontal:10,paddingVertical:6,gap:8,backgroundColor:o.color.fill},th:{flex:1,color:o.color.textTertiary,fontSize:o.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:10,paddingVertical:7,gap:8},trDivider:{borderTopWidth:x.hairlineWidth,borderTopColor:o.color.separator},td:{flex:1,color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:17},tdFirst:{color:o.color.text,fontWeight:"500"},firstCol:{flex:1.3},colFixed:{flex:0,width:110},tfoot:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:10,paddingVertical:8,borderTopWidth:x.hairlineWidth,borderTopColor:o.color.border},tfootText:{color:o.color.textSecondary,fontSize:o.font.micro},tfootAction:{color:o.color.accent,fontSize:o.font.micro,fontWeight:"600"},pressed:{opacity:.7},marker:{color:o.color.textSecondary,minWidth:14,textAlign:"right"},liText:{flex:1}});