@buoy-gg/ask-buoy 7.0.39 → 7.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +4 -0
  2. package/lib/commonjs/blocks/DataBlocks.js +2 -0
  3. package/lib/commonjs/blocks/DataBlocks.js.map +1 -1
  4. package/lib/commonjs/blocks/ExtraBlocks.js +2 -0
  5. package/lib/commonjs/blocks/ExtraBlocks.js.map +1 -1
  6. package/lib/commonjs/blocks/MediaBlocks.js +2 -0
  7. package/lib/commonjs/blocks/MediaBlocks.js.map +1 -1
  8. package/lib/commonjs/blocks/ReceiptBlocks.js +9 -3
  9. package/lib/commonjs/blocks/ReceiptBlocks.js.map +1 -1
  10. package/lib/commonjs/blocks/context.js.map +1 -1
  11. package/lib/commonjs/blocks/ruleStates.js +39 -0
  12. package/lib/commonjs/blocks/ruleStates.js.map +1 -0
  13. package/lib/commonjs/components/AskBuoyModal.js +6 -2
  14. package/lib/commonjs/components/AskBuoyModal.js.map +1 -1
  15. package/lib/commonjs/components/ChangesBar.js +1 -0
  16. package/lib/commonjs/components/ChangesBar.js.map +1 -1
  17. package/lib/module/blocks/DataBlocks.js +2 -0
  18. package/lib/module/blocks/DataBlocks.js.map +1 -1
  19. package/lib/module/blocks/ExtraBlocks.js +2 -0
  20. package/lib/module/blocks/ExtraBlocks.js.map +1 -1
  21. package/lib/module/blocks/MediaBlocks.js +2 -0
  22. package/lib/module/blocks/MediaBlocks.js.map +1 -1
  23. package/lib/module/blocks/ReceiptBlocks.js +9 -3
  24. package/lib/module/blocks/ReceiptBlocks.js.map +1 -1
  25. package/lib/module/blocks/context.js.map +1 -1
  26. package/lib/module/blocks/ruleStates.js +35 -0
  27. package/lib/module/blocks/ruleStates.js.map +1 -0
  28. package/lib/module/components/AskBuoyModal.js +7 -3
  29. package/lib/module/components/AskBuoyModal.js.map +1 -1
  30. package/lib/module/components/ChangesBar.js +1 -1
  31. package/lib/module/components/ChangesBar.js.map +1 -1
  32. package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +1 -1
  33. package/lib/typescript/blocks/context.d.ts +3 -0
  34. package/lib/typescript/blocks/context.d.ts.map +1 -1
  35. package/lib/typescript/blocks/ruleStates.d.ts +15 -0
  36. package/lib/typescript/blocks/ruleStates.d.ts.map +1 -0
  37. package/lib/typescript/components/AskBuoyModal.d.ts.map +1 -1
  38. package/lib/typescript/components/ChangesBar.d.ts +2 -1
  39. package/lib/typescript/components/ChangesBar.d.ts.map +1 -1
  40. package/lib/typescript/sync/askBuoySyncAdapter.d.ts +2 -2
  41. package/lib/web/index.mjs +16 -0
  42. package/package.json +44 -11
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ var vr=Object.defineProperty;var ts=Object.getOwnPropertyDescriptor;var os=Object.getOwnPropertyNames;var rs=Object.prototype.hasOwnProperty;var ns=(e,t)=>{for(var o in t)vr(e,o,{get:t[o],enumerable:!0})},Cr=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of os(t))!rs.call(e,n)&&n!==o&&vr(e,n,{get:()=>t[n],enumerable:!(r=ts(t,n))||r.enumerable});return e},ue=(e,t,o)=>(Cr(e,t,"default"),o&&Cr(o,t,"default"));var R=process.env.NODE_ENV!=="production";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{useCallback as ot,useEffect as jt,useMemo as ho,useRef as Qt,useState as dr}from"react";var z={};ns(z,{AccessibilityInfo:()=>fs,ActivityIndicator:()=>yt,Alert:()=>Xt,Animated:()=>ee,AppRegistry:()=>bs,AppState:()=>hs,Appearance:()=>ys,BackHandler:()=>ms,Button:()=>ds,CheckBox:()=>Ps,Clipboard:()=>xs,DeviceEventEmitter:()=>_s,Dimensions:()=>ws,Easing:()=>bt,FlatList:()=>Ao,I18nManager:()=>Ts,Image:()=>Ye,ImageBackground:()=>Ds,InteractionManager:()=>ks,Keyboard:()=>Zt,KeyboardAvoidingView:()=>zs,LayoutAnimation:()=>Ss,Linking:()=>Cs,LogBox:()=>Fs,Modal:()=>cs,NativeEventEmitter:()=>vs,NativeModules:()=>gs,PanResponder:()=>Bs,Picker:()=>Vs,PixelRatio:()=>As,Platform:()=>ht,Pressable:()=>b,ProgressBar:()=>Ls,RefreshControl:()=>Hs,SafeAreaView:()=>$s,ScrollView:()=>ke,SectionList:()=>Os,Share:()=>Bo,StatusBar:()=>Es,StyleSheet:()=>y,Switch:()=>vo,Text:()=>i,TextInput:()=>ze,Touchable:()=>Ws,TouchableHighlight:()=>as,TouchableNativeFeedback:()=>Ms,TouchableOpacity:()=>Vt,TouchableWithoutFeedback:()=>ls,UIManager:()=>Is,Vibration:()=>Rs,View:()=>l,VirtualizedList:()=>Ns,YellowBox:()=>qs,findNodeHandle:()=>us,unstable_createElement:()=>ps,useColorScheme:()=>Us,useLocaleContext:()=>Ks,useWindowDimensions:()=>Io});ue(z,rd);import*as rd from"react-native-web";import{unstable_createElement as ps,NativeModules as gs,AccessibilityInfo as fs,Animated as ee,Appearance as ys,AppRegistry as bs,AppState as hs,BackHandler as ms,Clipboard as xs,Dimensions as ws,Easing as bt,I18nManager as Ts,Keyboard as Zt,InteractionManager as ks,LayoutAnimation as Ss,Linking as Cs,NativeEventEmitter as vs,PanResponder as Bs,PixelRatio as As,Platform as ht,Share as Bo,StyleSheet as y,UIManager as Is,Vibration as Rs,CheckBox as Ps,FlatList as Ao,Image as Ye,ImageBackground as Ds,KeyboardAvoidingView as zs,Picker as Vs,ProgressBar as Ls,RefreshControl as Hs,SafeAreaView as $s,SectionList as Os,StatusBar as Es,Touchable as Ws,TouchableNativeFeedback as Ms,VirtualizedList as Ns,YellowBox as qs,LogBox as Fs,DeviceEventEmitter as _s,useColorScheme as Us,useLocaleContext as Ks,useWindowDimensions as Io}from"react-native-web";import*as X from"react-native-web";import{createElement as is,forwardRef as ss}from"react";function Ue(e){let t=ss((r,n)=>{let{accessibilityState:s,accessibilityValue:a,...g}=r;for(let u of["busy","checked","disabled","expanded","selected"])s?.[u]!==void 0&&g[`aria-${u}`]===void 0&&(g[`aria-${u}`]=s[u]);for(let[u,f]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))a?.[u]!==void 0&&g[`aria-${f}`]===void 0&&(g[`aria-${f}`]=a[u]);return is(e,{...g,ref:n})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var l=Ue(X.View),i=Ue(X.Text),ze=Ue(X.TextInput),Vt=Ue(X.TouchableOpacity),as=Ue(X.TouchableHighlight),ls=Ue(X.TouchableWithoutFeedback),b=Ue(X.Pressable),ke=Ue(X.ScrollView),cs=Ue(X.Modal),vo=Ue(X.Switch),yt=Ue(X.ActivityIndicator),ds=Ue(X.Button),us=X.findNodeHandle,Xt={alert(e,t,o,r){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let s=document.createElement("h2");if(s.textContent=e,s.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(s),t){let f=document.createElement("p");f.textContent=t,f.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(f)}let a=document.createElement("div");a.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let g=o?.length?o:[{text:"OK"}],u=()=>{n.close?.(),n.remove()};for(let f of g){let m=document.createElement("button");m.type="button",m.textContent=f.text??"OK",m.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${f.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,m.onclick=()=>{u(),f.onPress?.()},a.appendChild(m)}n.addEventListener("cancel",f=>{f.preventDefault(),r?.cancelable!==!1&&(u(),r?.onDismiss?.())}),n.appendChild(a),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{isReversible as _c}from"@buoy-gg/agent-core/web";import{dispatchToolAction as Uc,FeatureGate as Kc,Info as jc,JsModal as Qc,ModalHeader as ur,night as Gt,setToolAttention as Et,useSafeAreaInsets as Gc}from"@buoy-gg/shared-ui/web";import{Component as Za}from"react";import{night as Un}from"@buoy-gg/shared-ui/web";import{useState as ua}from"react";import{Check as pa,ChevronRight as ga,night as _}from"@buoy-gg/shared-ui/web";import{createContext as js,useContext as Qs}from"react";import{jsx as Js}from"react/jsx-runtime";var Gs={answer:()=>{},runAction:()=>{},answered:{},supports:{}},Br=js(Gs);function eo({value:e,children:t}){return Js(Br.Provider,{value:e,children:t})}function K(){return Qs(Br)}function Ar(e,t){return`${e}:${t.label}`}import{AlertTriangle as Ys,Check as Xs,Clock as Zs,Database as ea,Eye as ta,Globe as oa,Image as ra,Info as na,Layers as Ir,Navigation as ia,night as Mt,User as sa}from"@buoy-gg/shared-ui/web";import{jsx as Oe}from"react/jsx-runtime";function to({name:e,size:t=14}){let o=Mt.color.textSecondary,r=(()=>{switch(e){case"network":return Oe(oa,{size:t,color:o});case"storage":return Oe(ea,{size:t,color:o});case"route":return Oe(ia,{size:t,color:o});case"screen":return Oe(ta,{size:t,color:o});case"user":return Oe(sa,{size:t,color:o});case"image":return Oe(ra,{size:t,color:o});case"check":return Oe(Xs,{size:t,color:Mt.color.accent});case"warn":return Oe(Ys,{size:t,color:Mt.color.warning});case"info":return Oe(na,{size:t,color:Mt.color.info});case"store":return Oe(Ir,{size:t,color:o});case"query":return Oe(Ir,{size:t,color:o});case"clock":return Oe(Zs,{size:t,color:o})}})();return Oe(l,{style:aa.wrap,children:r})}var aa=y.create({wrap:{width:24,height:24,borderRadius:6,backgroundColor:Mt.color.fill,alignItems:"center",justifyContent:"center"}});import{useState as Pr}from"react";import{Check as la,ChevronDown as Dr,ChevronUp as zr,night as B,X as ca}from"@buoy-gg/shared-ui/web";function Rr(e,t,o,r){let n=Math.min(o,e),s=Math.max(0,e-n),a=o>t&&e>t;return{hidden:s,next:Math.min(s,r),expanded:a,canExpand:s>0,canCollapse:a}}import{jsx as Se,jsxs as lt}from"react/jsx-runtime";function Xe(e){switch(e){case"accent":return B.color.accent;case"warning":return B.color.warning;case"danger":return B.color.danger;case"info":return B.color.info;case"muted":return B.color.textTertiary;default:return B.color.text}}function oo({source:e}){if(!e||e==="live")return null;let t=e==="changed"?"CHANGED BY ASK BUOY":e==="mocked"?"MOCKED":"FROM THE MODEL",o=e==="changed"?B.color.warning:e==="mocked"?B.color.danger:B.color.textTertiary;return Se(l,{style:[j.badge,{borderColor:o}],children:Se(i,{style:[j.badgeText,{color:o}],children:t})})}function H({title:e,source:t,children:o,testID:r,tone:n,collapsible:s,summary:a}){let[g,u]=Pr(!1),f=!!s&&!g;return lt(l,{style:[j.card,n==="warning"&&j.cardWarning,n==="danger"&&j.cardDanger,n==="info"&&j.cardInfo],testID:r,children:[(e||t&&t!=="live")&&lt(l,{style:j.titleRow,children:[e?Se(i,{style:j.title,numberOfLines:2,children:e}):Se(l,{style:j.flex}),Se(oo,{source:t})]}),s?lt(b,{testID:r?`${r}-toggle`:void 0,onPress:()=>u(m=>!m),accessibilityRole:"button",accessibilityState:{expanded:g},accessibilityLabel:`${a??"Details"}, ${g?"hide":"show"}`,style:({pressed:m})=>[j.disclosure,!f&&j.disclosureOpen,m&&j.pressed],children:[Se(i,{style:j.disclosureText,numberOfLines:1,children:a??"Details"}),f?Se(Dr,{size:12,color:B.color.textTertiary}):Se(zr,{size:12,color:B.color.textTertiary})]}):null,f?null:o]})}var da=5;function Ee(e,t,o=da){let[r,n]=Pr(t),{hidden:s,next:a,expanded:g,canExpand:u,canCollapse:f}=Rr(e.length,t,r,o);return{visible:e.slice(0,r),hidden:s,next:a,expanded:g,showMore:u?()=>n(m=>m+o):void 0,showLess:f?()=>n(t):void 0}}function We({paged:e}){let{next:t,showMore:o,showLess:r}=e;return!o&&!r?null:lt(l,{style:j.moreRow,children:[o?lt(b,{testID:"buoy-block-show-more",onPress:o,style:[j.more,j.moreCell],accessibilityRole:"button",children:[lt(i,{style:j.moreText,children:["Show ",t," more"]}),Se(Dr,{size:12,color:B.color.textTertiary})]}):null,r?lt(b,{testID:"buoy-block-show-fewer",onPress:r,style:[j.more,j.moreCell],accessibilityRole:"button",children:[Se(i,{style:j.moreText,children:"Show fewer"}),Se(zr,{size:12,color:B.color.textTertiary})]}):null]})}function Ro({shown:e,total:t}){return!t||t<=e?null:Se(l,{style:j.more,children:lt(i,{style:j.moreNote,children:[e," of ",t," shown"]})})}function he({actions:e,blockId:t,align:o="left"}){let r=K();if(!e?.length)return null;let n=e.filter(s=>s.openTool?r.supports?.openTool!==!1:s.minimize?r.supports?.minimize!==!1:s.dispatch?r.supports?.dispatch!==!1:!0);return n.length===0?null:Se(l,{style:[j.actions,o==="right"&&j.actionsRight],children:n.slice(0,2).map(s=>{let a=r.actionState?.[Ar(t,s)],g=!!r.busy||a==="running"||a==="done";return lt(b,{accessibilityRole:"button",accessibilityLabel:s.label,testID:`buoy-block-action-${s.label.toLowerCase().replace(/\s+/g,"-")}`,disabled:g,onPress:()=>void r.runAction(s,t),style:({pressed:u})=>[j.button,s.primary?j.buttonPrimary:j.buttonPlate,g&&j.buttonDisabled,u&&!g&&j.pressed],children:[a==="running"?Se(yt,{size:"small",color:s.primary?B.color.onAccent:B.color.text}):a==="done"?Se(la,{size:12,color:s.primary?B.color.onAccent:B.color.accent}):a==="failed"?Se(ca,{size:12,color:B.color.danger}):null,Se(i,{style:[j.buttonText,s.primary?j.buttonTextPrimary:j.buttonTextPlate],children:s.label})]},s.label)})})}var v=y.create({row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},rowDivider:{borderTopWidth:y.hairlineWidth,borderTopColor:B.color.separator},rowTitle:{flex:1,color:B.color.text,fontSize:B.font.body,lineHeight:19},rowSub:{color:B.color.textSecondary,fontSize:B.font.caption,lineHeight:17},rowTrailing:{color:B.color.textTertiary,fontSize:B.font.caption,maxWidth:120,textAlign:"right"},mono:{fontFamily:"Menlo",fontSize:12,color:B.color.text},pill:{paddingHorizontal:7,paddingVertical:2,borderRadius:B.radius.badge,backgroundColor:B.color.fill},pillText:{fontSize:B.font.micro,fontWeight:"700",letterSpacing:.4,color:B.color.textSecondary}}),j=y.create({card:{borderRadius:B.radius.card,borderWidth:y.hairlineWidth,borderColor:B.color.border,backgroundColor:B.color.surface,overflow:"hidden"},cardWarning:{borderColor:B.color.warning,backgroundColor:B.color.warningSoft},cardDanger:{borderColor:B.color.danger,backgroundColor:B.color.dangerSoft},cardInfo:{borderColor:B.color.accentBorderStrong,backgroundColor:B.color.accentSoft},titleRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:10,paddingBottom:6},flex:{flex:1},title:{flex:1,color:B.color.text,fontSize:B.font.caption,fontWeight:"600"},disclosure:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:9},disclosureOpen:{borderBottomWidth:y.hairlineWidth,borderBottomColor:B.color.separator},disclosureText:{flex:1,color:B.color.textSecondary,fontSize:B.font.caption},badge:{borderWidth:y.hairlineWidth,borderRadius:B.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:y.hairlineWidth,borderTopColor:B.color.separator},moreCell:{flex:1},moreText:{color:B.color.textSecondary,fontSize:B.font.caption,fontWeight:"600"},moreNote:{color:B.color.textTertiary,fontSize:B.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:B.radius.row},buttonPrimary:{backgroundColor:B.color.accent},buttonPlate:{backgroundColor:B.color.button},buttonDisabled:{opacity:.55},buttonText:{fontSize:B.font.caption,fontWeight:"600"},buttonTextPrimary:{color:B.color.onAccent},buttonTextPlate:{color:B.color.text},pressed:{opacity:.7}});import{Fragment as fa,jsx as le,jsxs as vt}from"react/jsx-runtime";function Vr({block:e}){let t=K(),o=t.answered[e.id],r=o?.kind==="choice"?o.optionId:null,n=!!o;return vt(H,{testID:`buoy-block-choice-${e.id}`,tone:n?void 0:"info",children:[le(i,{style:U.question,children:e.question}),le(l,{style:U.options,children:e.options.slice(0,5).map((s,a)=>{let g=r===s.id;return vt(b,{testID:`buoy-block-option-${s.id}`,accessibilityRole:"button",accessibilityState:{selected:g,disabled:n},disabled:n,onPress:()=>t.answer({blockId:e.id,kind:"choice",optionId:s.id,label:s.label}),style:({pressed:u})=>[U.option,a>0&&U.optionDivider,g&&U.optionChosen,n&&!g&&U.optionDimmed,u&&!n&&U.pressed],children:[s.icon?le(to,{name:s.icon}):null,vt(l,{style:U.optionText,children:[le(i,{style:[U.optionLabel,g&&U.optionLabelChosen],children:s.label}),s.detail?le(i,{style:U.optionDetail,children:s.detail}):null]}),g?le(pa,{size:14,color:_.color.accent}):n?null:le(ga,{size:14,color:_.color.textTertiary})]},s.id)})}),!n&&e.allowFreeText!==!1?le(i,{style:U.hint,children:"Or just type your answer below."}):null]})}function Lr({block:e}){let t=K(),o=t.answered[e.id],r=!!o,n=o?.kind==="confirm"?o.approved:null;return vt(H,{testID:`buoy-block-confirm-${e.id}`,tone:r?void 0:"warning",children:[le(i,{style:U.confirmTitle,children:e.title}),le(i,{style:U.confirmChange,children:e.change}),e.consequence?le(i,{style:U.confirmConsequence,children:e.consequence}):null,le(l,{style:U.confirmActions,children:r?le(i,{style:U.decided,children:n?`\u2713 ${e.approveLabel??"Done"}`:`\u2715 ${e.declineLabel??"Not now"}`}):vt(fa,{children:[le(b,{testID:"buoy-block-approve",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:!0}),style:({pressed:s})=>[U.button,U.buttonPrimary,s&&U.pressed],children:le(i,{style:U.buttonTextPrimary,children:e.approveLabel??"Do it"})}),le(b,{testID:"buoy-block-decline",accessibilityRole:"button",onPress:()=>t.answer({blockId:e.id,kind:"confirm",approved:!1}),style:({pressed:s})=>[U.button,U.buttonPlate,s&&U.pressed],children:le(i,{style:U.buttonTextPlate,children:e.declineLabel??"Not now"})})]})})]})}function Hr({block:e}){let t=K(),o=t.answered[e.id],r=!!o,[n,s]=ua(""),a=e.type==="secret",g=()=>{let u=n.trim();u&&t.answer({blockId:e.id,kind:"input",value:u})};return vt(H,{testID:`buoy-block-input-${e.id}`,tone:r?void 0:"info",children:[le(i,{style:U.question,children:e.label}),r?le(i,{style:U.decided,children:o.kind==="input"?a?"\u2022\u2022\u2022\u2022\u2022\u2022":o.value:"(skipped)"}):vt(l,{style:U.inputRow,children:[le(ze,{testID:"buoy-block-input-field",style:U.input,value:n,onChangeText:s,placeholder:e.placeholder??"",placeholderTextColor:_.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:a,autoCapitalize:"none",autoCorrect:!1,returnKeyType:"send",onSubmitEditing:g}),le(b,{testID:"buoy-block-input-submit",accessibilityRole:"button",disabled:!n.trim(),onPress:g,style:({pressed:u})=>[U.button,U.buttonPrimary,!n.trim()&&U.buttonDisabled,u&&U.pressed],children:le(i,{style:U.buttonTextPrimary,children:e.submitLabel??"Send"})})]})]})}var U=y.create({question:{color:_.color.text,fontSize:_.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},options:{marginHorizontal:8,marginBottom:8,borderRadius:_.radius.row,backgroundColor:_.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},optionDivider:{borderTopWidth:y.hairlineWidth,borderTopColor:_.color.separator},optionChosen:{backgroundColor:_.color.accentSoft},optionDimmed:{opacity:.45},optionText:{flex:1,gap:2},optionLabel:{color:_.color.text,fontSize:_.font.body,fontWeight:"500"},optionLabelChosen:{color:_.color.accent},optionDetail:{color:_.color.textSecondary,fontSize:_.font.caption,lineHeight:17},hint:{color:_.color.textTertiary,fontSize:_.font.micro,paddingHorizontal:12,paddingBottom:10},confirmTitle:{color:_.color.text,fontSize:_.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:_.color.text,fontSize:_.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6},confirmConsequence:{color:_.color.warning,fontSize:_.font.caption,lineHeight:17,paddingHorizontal:12,paddingTop:6},confirmActions:{flexDirection:"row",gap:8,paddingHorizontal:12,paddingVertical:12,alignItems:"center"},decided:{color:_.color.textSecondary,fontSize:_.font.caption,fontWeight:"600",paddingHorizontal:12,paddingVertical:10},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:_.radius.row,backgroundColor:_.color.surfaceElevated,color:_.color.text,fontSize:_.font.body},button:{paddingHorizontal:14,paddingVertical:9,borderRadius:_.radius.row},buttonPrimary:{backgroundColor:_.color.accent},buttonPlate:{backgroundColor:_.color.button},buttonDisabled:{opacity:.5},buttonTextPrimary:{color:_.color.onAccent,fontSize:_.font.caption,fontWeight:"600"},buttonTextPlate:{color:_.color.text,fontSize:_.font.caption,fontWeight:"600"},pressed:{opacity:.7}});import{useState as qr}from"react";import{AlertTriangle as Aa,Check as Ia,Info as Ra,night as V,X as Pa}from"@buoy-gg/shared-ui/web";import{DataViewer as Da,TreeDiffViewer as za}from"@buoy-gg/shared-ui/web/dataViewer";import{CAPS as Nt}from"@buoy-gg/agent-core/web";import{useState as ha}from"react";import{night as ce}from"@buoy-gg/shared-ui/web";var $r=e=>/^\s*\|.*\|\s*$/.test(e),ya=e=>/^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(e),Or=e=>e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim()),ba=/^\s*```\s*([\w+-]*)\s*$/;function Er(e){let t=[],o=[],r=()=>{o.length&&t.push({kind:"p",text:o.join(" ")}),o=[]},n=e.split(`
3
+ `);for(let s=0;s<n.length;s++){let g=n[s].replace(/\s+$/,""),u=ba.exec(g);if(u){r();let O=[],$=s+1,L=!1;for(;$<n.length;){if(/^\s*```\s*$/.test(n[$])){L=!0;break}O.push(n[$]),$++}t.push({kind:"code",lang:u[1]??"",text:O.join(`
4
+ `),closed:L}),s=L?$:n.length;continue}if(!g.trim()){r();continue}if($r(g)&&n[s+1]&&ya(n[s+1])){r();let O=Or(g),$=[],L=s+2;for(;L<n.length&&$r(n[L]);)$.push(Or(n[L])),L++;t.push({kind:"table",header:O,rows:$}),s=L-1;continue}let f=/^#{1,6}\s+(.*)$/.exec(g);if(f){r(),t.push({kind:"h",text:f[1]});continue}let m=/^(\s*)([-*•]|\d+[.)])\s+(.*)$/.exec(g);if(m){r();let O=Math.min(2,Math.floor(m[1].length/2)),$=/^\d/.test(m[2])?m[2].replace(")","."):"\u2022";t.push({kind:"li",text:m[3],marker:$,depth:O});continue}o.push(g.trim())}return r(),t}var ro=12,no=4;function Wr(e,t){let o=[];return t.length>ro&&o.push(`${ro} of ${t.length} rows`),e.length>no&&o.push(`${no} of ${e.length} columns`),o.length?`Showing ${o.join(" \xB7 ")}`:null}import{jsx as me,jsxs as io}from"react/jsx-runtime";function Bt(e,t){let o=e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1"),r=[],n=/(\*\*[^*]+\*\*|`[^`]+`|\*[^*\s][^*]*\*|_[^_\s][^_]*_)/g,s=0,a,g=0;for(;a=n.exec(o);){a.index>s&&r.push(o.slice(s,a.index));let u=a[0];u.startsWith("**")?r.push(me(i,{style:[t,G.bold],children:u.slice(2,-2)},g++)):u.startsWith("`")?r.push(me(i,{style:[t,G.code],children:u.slice(1,-1)},g++)):r.push(me(i,{style:[t,G.italic],children:u.slice(1,-1)},g++)),s=a.index+u.length}return s<o.length&&r.push(o.slice(s)),r}var ma=e=>e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1");function xa({header:e,rows:t}){let[o,r]=ha(!1),n=Wr(e,t),s=o?e:e.slice(0,no),a=o?t:t.slice(0,ro),g=io(l,{style:o&&G.tableWide,children:[me(l,{style:G.tableHead,children:s.map((u,f)=>me(i,{style:[G.th,f===0&&G.firstCol,o&&G.colFixed],numberOfLines:1,children:u.replace(/\*\*/g,"")},f))}),a.map((u,f)=>me(l,{style:[G.tr,f>0&&G.trDivider],children:s.map((m,O)=>me(i,{style:[G.td,O===0&&G.firstCol,O===0&&G.tdFirst,o&&G.colFixed],numberOfLines:o?3:2,children:Bt(ma(u[O]??""),G.td)},O))},f))]});return io(l,{style:G.table,testID:"buoy-ask-buoy-md-table",children:[o?me(ke,{style:G.tableScrollV,nestedScrollEnabled:!0,children:me(ke,{horizontal:!0,showsHorizontalScrollIndicator:!0,children:g})}):g,n?io(b,{testID:"buoy-ask-buoy-md-table-toggle",accessibilityRole:"button",accessibilityLabel:o?"Show fewer rows":"Show all rows and columns",onPress:()=>r(u=>!u),style:({pressed:u})=>[G.tfoot,u&&G.pressed],children:[me(i,{style:G.tfootText,children:o?`All ${t.length} rows \xB7 ${e.length} columns`:n}),me(i,{style:G.tfootAction,children:o?"Show fewer":"Show all"})]}):null]})}function Po({text:e,style:t}){let o=Er(e);return me(l,{style:G.wrap,children:o.map((r,n)=>r.kind==="table"?me(xa,{header:r.header,rows:r.rows},n):r.kind==="code"?me(ke,{horizontal:!0,style:G.codeBlock,contentContainerStyle:G.codeBlockContent,testID:"buoy-ask-buoy-md-code",children:me(i,{style:G.codeText,selectable:!0,children:r.text})},n):r.kind==="li"?io(l,{style:[G.li,{paddingLeft:4+r.depth*14}],children:[me(i,{style:[t,G.marker],children:r.marker}),me(i,{style:[t,G.liText],selectable:!0,children:Bt(r.text,t)})]},n):me(i,{style:[t,r.kind==="h"&&G.bold],selectable:!0,children:Bt(r.text,t)},n))})}var G=y.create({wrap:{gap:8},bold:{fontWeight:"600"},italic:{fontStyle:"italic"},code:{fontFamily:"Menlo",fontSize:13,color:ce.color.accent,backgroundColor:ce.color.fill},codeBlock:{borderRadius:ce.radius.row,borderWidth:y.hairlineWidth,borderColor:ce.color.border,backgroundColor:ce.color.surface},codeBlockContent:{paddingHorizontal:12,paddingVertical:10},codeText:{fontFamily:"Menlo",fontSize:12,lineHeight:18,color:ce.color.text},li:{flexDirection:"row",gap:8},table:{borderRadius:ce.radius.row,borderWidth:y.hairlineWidth,borderColor:ce.color.border,backgroundColor:ce.color.surface,overflow:"hidden"},tableWide:{minWidth:"100%"},tableScrollV:{maxHeight:320},tableHead:{flexDirection:"row",paddingHorizontal:10,paddingVertical:6,gap:8,backgroundColor:ce.color.fill},th:{flex:1,color:ce.color.textTertiary,fontSize:ce.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:10,paddingVertical:7,gap:8},trDivider:{borderTopWidth:y.hairlineWidth,borderTopColor:ce.color.separator},td:{flex:1,color:ce.color.textSecondary,fontSize:ce.font.caption,lineHeight:17},tdFirst:{color:ce.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:y.hairlineWidth,borderTopColor:ce.color.border},tfootText:{color:ce.color.textSecondary,fontSize:ce.font.micro},tfootAction:{color:ce.color.accent,fontSize:ce.font.micro,fontWeight:"600"},pressed:{opacity:.7},marker:{color:ce.color.textSecondary,minWidth:14,textAlign:"right"},liText:{flex:1}});import{useCallback as wa,useEffect as Ta,useRef as ka,useState as Sa}from"react";import{copyToClipboard as Ca}from"@buoy-gg/shared-ui/web";var va=1500;function Lt(e){let[t,o]=Sa(!1),r=ka(null);Ta(()=>()=>{r.current&&clearTimeout(r.current)},[]);let n=wa(()=>{let s=e();Ca(s).then(a=>{if(!a){Bo.share({message:s}).catch(()=>{});return}o(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(!1),va)}).catch(()=>{})},[e]);return{copied:t,copy:n}}var Ba=e=>typeof e=="string"?e:e.text;function Do(e){switch(e.kind){case"finding":return[e.title,...e.evidence.map(t=>`${t.label}: ${t.value}`)].join(`
5
+ `);case"keyValue":return[e.title,...e.pairs.map(t=>`${t.key}: ${typeof t.value=="string"?t.value:JSON.stringify(t.value)}`)].filter(Boolean).join(`
6
+ `);case"table":{let t=e.columns.join(" | "),o=e.rows.map(n=>n.map(Ba).join(" | ")),r=e.total&&e.total>e.rows.length?`\u2026 ${e.total-e.rows.length} more rows`:null;return[e.title,t,...o,r].filter(Boolean).join(`
7
+ `)}case"list":{let t=e.items.map(r=>`- ${r.title}${r.subtitle?` \u2014 ${r.subtitle}`:""}${r.trailing?` (${r.trailing})`:""}`),o=e.total&&e.total>e.items.length?`\u2026 ${e.total-e.items.length} more`:null;return[e.title,...t,o].filter(Boolean).join(`
8
+ `)}case"notice":return e.text;case"claim":return e.text;case"diff":case"chart":case"imageGrid":case"requestList":case"requestCard":case"logList":case"crash":case"screenElements":return`[${e.kind} card${"title"in e&&typeof e.title=="string"?`: ${e.title}`:""}]`;default:return null}}function Mr(e){return e.map(Do).filter(t=>!!t)}import{Fragment as Ea,jsx as A,jsxs as ge}from"react/jsx-runtime";function zo(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{let t=JSON.stringify(e);return t.length>120?`${t.slice(0,117)}\u2026`:t}catch{return String(e)}}function Fr({block:e}){let t=Ee(e.rows,Nt.tableRows),{visible:o}=t,r=e.columns.slice(0,4);return ge(H,{title:e.title,source:e.source,testID:`buoy-block-table-${e.id}`,children:[A(l,{style:P.tableHead,children:r.map((n,s)=>A(i,{style:[P.th,s===0&&P.firstCol],numberOfLines:1,children:n},n))}),o.map((n,s)=>A(l,{style:[P.tr,s>0&&v.rowDivider],children:r.map((a,g)=>{let u=n[g],f=typeof u=="string"?u:u?.text??"",m=typeof u=="string"?void 0:u?.tone;return A(i,{style:[P.td,g===0&&P.firstCol,g===0&&P.tdFirst,m&&{color:Xe(m)}],numberOfLines:2,children:Bt(f,P.td)},g)})},s)),A(We,{paged:t})]})}function _r({block:e}){let t=Ee(e.pairs,Nt.keyValuePairs),{visible:o}=t,[r,n]=qr(null);return ge(H,{title:e.title,source:e.source,testID:`buoy-block-keyvalue-${e.id}`,children:[o.map((s,a)=>{let g=typeof s.value=="object"&&s.value!==null,u=r===s.key;return ge(b,{onPress:g?()=>n(u?null:s.key):void 0,style:[P.kvRow,a>0&&v.rowDivider],children:[A(i,{style:P.kvKey,numberOfLines:1,children:s.key}),A(i,{style:[P.kvValue,u&&v.mono],numberOfLines:u?void 0:2,selectable:!0,children:u?JSON.stringify(s.value,null,2):zo(s.value)})]},s.key)}),A(We,{paged:t})]})}function Va(e){let t=!!e.image;return{canExpand:t,rowRunsAction:!!e.action&&!t,actionIsOwnControl:!!e.action&&t}}function Ur({block:e}){let t=K(),o=Ee(e.items,Nt.listItems),{visible:r}=o,[n,s]=qr(null);return ge(H,{title:e.title,source:e.source,testID:`buoy-block-list-${e.id}`,children:[r.map((a,g)=>{let u=`${a.id??a.title}-${g}`,f=n===u,{canExpand:m,rowRunsAction:O,actionIsOwnControl:$}=Va(a),L=m||O?b:l,oe=m?{onPress:()=>s(f?null:u),accessibilityRole:"button",accessibilityState:{expanded:f},accessibilityLabel:`${a.title}, ${f?"hide":"show"} picture`,testID:`buoy-block-list-row-${u}`}:O?{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button"}:{};return ge(l,{style:g>0?v.rowDivider:void 0,children:[f&&a.image?A(b,{onPress:()=>s(null),accessibilityRole:"button",accessibilityLabel:`Hide ${a.title}`,testID:`buoy-block-list-hero-${u}`,style:P.listHero,children:A(Ye,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:P.listHeroImage,resizeMode:"contain",accessibilityLabel:a.title})}):null,ge(L,{...oe,style:v.row,children:[a.image&&!f?A(Ye,{testID:"buoy-internal-chat-image",source:{uri:a.image},style:P.thumb,resizeMode:"contain",accessibilityLabel:a.title}):a.icon?A(to,{name:a.icon}):null,ge(l,{style:P.flex,children:[A(i,{style:[v.rowTitle,a.tone&&{color:Xe(a.tone)}],numberOfLines:f?void 0:2,children:Bt(a.title,v.rowTitle)}),a.subtitle?A(i,{style:v.rowSub,numberOfLines:f?void 0:2,children:Bt(a.subtitle,v.rowSub)}):null]}),a.trailing?A(i,{style:[v.rowTrailing,a.tone&&{color:Xe(a.tone)}],numberOfLines:1,children:a.trailing}):null,a.action?$?A(b,{onPress:()=>void t.runAction(a.action,e.id),accessibilityRole:"button",accessibilityLabel:a.action.label,hitSlop:8,children:A(i,{style:P.rowAction,children:a.action.label})}):A(i,{style:P.rowAction,children:a.action.label}):null]})]},u)}),A(We,{paged:o})]})}function Nr(e){return e!==null&&typeof e=="object"}function La(e){let t=e.map(s=>s.path),o=t.slice(0,3).join(", "),r=t.length-3;return`${t.length===1?"1 field":`${t.length} fields`} \xB7 ${o}${r>0?`, +${r}`:""}`}function Kr({block:e}){let t=Ee(e.changes,Nt.keyValuePairs);return ge(H,{title:e.title??"What changed",source:e.source,testID:`buoy-block-diff-${e.id}`,collapsible:!0,summary:La(e.changes),children:[t.visible.map((o,r)=>{let n=o.before===void 0&&o.after!==void 0,s=o.after===void 0&&o.before!==void 0;return ge(l,{style:[P.diffRow,r>0&&v.rowDivider],children:[A(i,{style:P.diffPath,numberOfLines:1,children:o.path}),Nr(o.before)||Nr(o.after)?A(l,{style:P.diffTree,children:A(za,{oldValue:o.before,newValue:o.after,showUnchanged:!1,scrollEnabled:!1})}):ge(Ea,{children:[n?null:ge(l,{style:P.diffLine,children:[A(i,{style:[P.diffMark,{color:V.color.danger}],children:"\u2212"}),A(i,{style:[P.diffValue,{color:V.color.danger}],numberOfLines:3,selectable:!0,children:zo(o.before)})]}),s?null:ge(l,{style:P.diffLine,children:[A(i,{style:[P.diffMark,{color:V.color.accent}],children:"+"}),A(i,{style:[P.diffValue,{color:V.color.accent}],numberOfLines:3,selectable:!0,children:zo(o.after)})]})]})]},`${o.path}-${r}`)}),A(We,{paged:t})]})}function jr({block:e}){let t=e.bars.slice(0,Nt.chartBars),o=e.max??Math.max(1,...t.map(r=>r.value));return A(H,{title:e.title,source:e.source,testID:`buoy-block-chart-${e.id}`,children:A(l,{style:P.chart,children:t.map((r,n)=>ge(l,{style:P.barRow,children:[A(i,{style:P.barLabel,numberOfLines:1,children:r.label}),A(l,{style:P.barTrack,children:A(l,{style:[P.bar,{width:`${Math.max(2,Math.round(r.value/o*100))}%`,backgroundColor:Xe(r.tone??"accent")}]})}),ge(i,{style:P.barValue,numberOfLines:1,children:[r.value,r.unit?` ${r.unit}`:""]})]},`${r.label}-${n}`))})})}function Qr({block:e}){return A(H,{title:e.title,testID:`buoy-block-steps-${e.id}`,children:e.steps.map((t,o)=>ge(l,{style:[P.step,o>0&&v.rowDivider],children:[A(l,{style:[P.stepMark,t.state==="done"&&P.stepDone,t.state==="failed"&&P.stepFailed],children:t.state==="done"?A(Ia,{size:10,color:V.color.onAccent}):t.state==="failed"?A(Pa,{size:10,color:V.color.text}):A(i,{style:P.stepNum,children:o+1})}),A(i,{style:[v.rowTitle,t.state==="done"&&P.stepTextDone],children:t.text})]},o))})}function Ha(e){try{let t=JSON.parse(e);return t!==null&&typeof t=="object"?t:void 0}catch{return}}function $a({block:e,value:t}){return A(H,{title:e.title,testID:`buoy-block-code-${e.id}`,children:A(l,{style:P.viewer,children:A(Da,{title:e.title??"Payload",data:t,initialExpanded:!0,showTypeFilter:!1,testIDPrefix:`buoy-block-code-${e.id}`})})})}function Oa({block:e}){return A(H,{title:e.title,testID:`buoy-block-code-${e.id}`,children:A(i,{style:[v.mono,P.code],selectable:!0,children:e.text})})}function Gr({block:e}){let t=Ha(e.text);return t===void 0?A(Oa,{block:e}):A($a,{block:e,value:t})}function Jr({block:e}){let t=e.tone==="danger"?V.color.danger:e.tone==="warning"?V.color.warning:V.color.info,o=e.tone==="info"?Ra:Aa;return ge(H,{tone:e.tone,testID:`buoy-block-notice-${e.id}`,children:[ge(l,{style:P.noticeRow,children:[A(o,{size:14,color:t}),A(i,{style:P.noticeText,children:e.text})]}),A(he,{actions:e.actions,blockId:e.id})]})}function Yr({block:e}){let{copied:t,copy:o}=Lt(()=>Do(e)??e.title);return ge(H,{title:e.title,source:e.source,testID:`buoy-block-finding-${e.id}`,tone:"warning",children:[e.evidence.map((r,n)=>ge(l,{style:[P.kvRow,n>0&&v.rowDivider],children:[A(i,{style:P.kvKey,numberOfLines:1,children:r.label}),A(i,{style:[P.kvValue,r.tone&&{color:Xe(r.tone)}],selectable:!0,children:r.value})]},`${r.label}-${n}`)),A(l,{style:P.findingFoot,children:A(b,{testID:`buoy-block-finding-copy-${e.id}`,accessibilityRole:"button",accessibilityLabel:t?"Copied":"Copy this finding",onPress:o,style:({pressed:r})=>[P.findingCopy,r&&{opacity:.7}],children:A(i,{style:[P.findingCopyText,t&&{color:V.color.accent}],children:t?"Copied":"Copy finding"})})}),A(he,{actions:e.actions,blockId:e.id})]})}var P=y.create({flex:{flex:1},tableHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,gap:8,backgroundColor:V.color.fill},th:{flex:1,color:V.color.textTertiary,fontSize:V.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},tr:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"center"},td:{flex:1,color:V.color.textSecondary,fontSize:V.font.caption,lineHeight:17},tdFirst:{color:V.color.text,fontWeight:"500"},firstCol:{flex:1.4},kvRow:{flexDirection:"row",gap:12,paddingHorizontal:12,paddingVertical:8,alignItems:"flex-start"},kvKey:{width:110,color:V.color.textSecondary,fontSize:V.font.caption,paddingTop:1},kvValue:{flex:1,color:V.color.text,fontSize:V.font.caption,lineHeight:17},findingFoot:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,borderTopWidth:y.hairlineWidth,borderTopColor:V.color.separator},findingCopy:{paddingHorizontal:10,paddingVertical:5,borderRadius:V.radius.badge,backgroundColor:V.color.fill},findingCopyText:{color:V.color.textSecondary,fontSize:V.font.micro,fontWeight:"600"},thumb:{width:40,height:40,borderRadius:8,backgroundColor:V.color.fill},listHero:{paddingHorizontal:12,paddingTop:12},listHeroImage:{width:"100%",height:240,borderRadius:V.radius.row,backgroundColor:V.color.fill},rowAction:{color:V.color.accent,fontSize:V.font.caption,fontWeight:"600"},diffRow:{paddingHorizontal:12,paddingVertical:8,gap:3},diffPath:{color:V.color.textSecondary,fontSize:V.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:V.radius.row,overflow:"hidden"},chart:{paddingHorizontal:12,paddingVertical:10,gap:8},barRow:{flexDirection:"row",alignItems:"center",gap:8},barLabel:{width:96,color:V.color.textSecondary,fontSize:V.font.caption},barTrack:{flex:1,height:10,borderRadius:5,backgroundColor:V.color.fill,overflow:"hidden"},bar:{height:10,borderRadius:5},barValue:{width:72,textAlign:"right",color:V.color.text,fontSize:V.font.caption,fontWeight:"600"},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:V.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:V.color.accent},stepFailed:{backgroundColor:V.color.danger},stepNum:{color:V.color.text,fontSize:V.font.micro,fontWeight:"700"},stepTextDone:{color:V.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:V.color.text,fontSize:V.font.caption,lineHeight:18}});import{useState as Wa}from"react";import{night as Ke}from"@buoy-gg/shared-ui/web";import{CAPS as Xr}from"@buoy-gg/agent-core/web";import{jsx as Qe,jsxs as Vo}from"react/jsx-runtime";function Zr({block:e}){let[t,o]=Wa(null),{width:r}=Io(),n=e.images.slice(0,Xr.gridMax),s=n.length>Xr.gridImages,a=Math.min(150,Math.floor((r-2*Ke.gutter-24-8)/2)),g=({img:u,i:f})=>Vo(b,{testID:`buoy-block-image-${f}`,accessibilityRole:"imagebutton",accessibilityLabel:u.alt,onPress:()=>o(t===f?null:f),style:[je.tile,{width:a},s&&je.tileCarousel],children:[Qe(Ye,{testID:"buoy-internal-chat-image",source:{uri:u.url},style:[je.image,{width:a,height:a}],resizeMode:"contain",accessibilityLabel:u.alt}),Qe(i,{style:je.name,numberOfLines:1,children:u.alt}),u.caption?Qe(i,{style:je.caption,numberOfLines:1,children:u.caption}):null]},`${u.url}-${f}`);return Vo(H,{title:e.title,source:e.source,testID:`buoy-block-imagegrid-${e.id}`,children:[t!==null&&n[t]?Vo(b,{onPress:()=>o(null),style:je.hero,accessibilityRole:"button",accessibilityLabel:`Close ${n[t].alt}`,children:[Qe(Ye,{testID:"buoy-internal-chat-image",source:{uri:n[t].url},style:je.heroImage,resizeMode:"contain",accessibilityLabel:n[t].alt}),Qe(i,{style:je.heroCaption,children:n[t].alt}),n[t].caption?Qe(i,{style:je.caption,children:n[t].caption}):null]}):null,s?Qe(ke,{horizontal:!0,showsHorizontalScrollIndicator:!1,snapToInterval:a+8,decelerationRate:"fast",contentContainerStyle:je.carousel,children:n.map((u,f)=>Qe(g,{img:u,i:f},f))}):Qe(l,{style:je.grid,children:n.map((u,f)=>Qe(g,{img:u,i:f},f))}),Qe(Ro,{shown:n.length,total:e.total})]})}var je=y.create({grid:{flexDirection:"row",flexWrap:"wrap",gap:8,padding:12},carousel:{gap:8,paddingHorizontal:12,paddingVertical:12},tile:{gap:4},tileCarousel:{},image:{borderRadius:Ke.radius.row,backgroundColor:Ke.color.fill},name:{color:Ke.color.text,fontSize:Ke.font.micro,fontWeight:"600"},caption:{color:Ke.color.textSecondary,fontSize:Ke.font.micro},hero:{alignItems:"center",padding:12,gap:6,borderBottomWidth:y.hairlineWidth,borderBottomColor:Ke.color.separator},heroImage:{width:"100%",height:240,borderRadius:Ke.radius.row,backgroundColor:Ke.color.fill},heroCaption:{color:Ke.color.text,fontSize:Ke.font.caption}});import{useState as Ma}from"react";import{AlertTriangle as Na,ChevronRight as qa,Eye as on,night as I,NightSegmented as Fa}from"@buoy-gg/shared-ui/web";import{CAPS as so}from"@buoy-gg/agent-core/web";import{jsx as M,jsxs as de}from"react/jsx-runtime";function en(e){return e===void 0?I.color.textTertiary:e>=500?I.color.danger:e>=400?I.color.warning:e>=300?I.color.info:I.color.accent}function rn(e){try{let t=new URL(e);return t.pathname+(t.search?"?\u2026":"")}catch{return e}}function nn({status:e}){return M(l,{style:[v.pill,{backgroundColor:`${en(e)}22`}],children:M(i,{style:[v.pillText,{color:en(e)}],children:e??"\u2026"})})}function sn({block:e}){let t=K(),o=t.supports?.openTool!==!1,r=Ee(e.requests,so.listItems),{visible:n}=r;return de(H,{title:e.title??"Network requests",source:e.source,testID:`buoy-block-requests-${e.id}`,children:[n.map((s,a)=>de(b,{disabled:!o,onPress:()=>void t.runAction({label:"Open in Network",openTool:{toolId:"network",select:s.id}},e.id),style:[v.row,a>0&&v.rowDivider],accessibilityRole:o?"button":void 0,children:[M(i,{style:J.method,children:s.method}),M(i,{style:v.rowTitle,numberOfLines:1,children:rn(s.url)}),s.mocked?M(i,{style:J.mockedChip,children:"MOCKED"}):null,s.durationMs!==void 0?de(i,{style:v.rowTrailing,children:[s.durationMs," ms"]}):null,M(nn,{status:s.status}),o?M(qa,{size:12,color:I.color.textTertiary}):null]},`${s.id}-${a}`)),M(We,{paged:r})]})}var _a=[{key:"response",label:"Response"},{key:"request",label:"Request"}];function an({block:e}){let[t,o]=Ma("response"),r=t==="response"?e.responseBody:e.requestBody,n=r===void 0?"(none)":typeof r=="string"?r:JSON.stringify(r,null,2),s=K();return de(H,{source:e.source,testID:`buoy-block-request-${e.id}`,children:[de(l,{style:[v.row,J.reqHead],children:[M(i,{style:J.method,children:e.request.method}),M(i,{style:v.rowTitle,numberOfLines:2,children:rn(e.request.url)}),e.request.mocked?M(i,{style:J.mockedChip,children:"MOCKED"}):null,M(nn,{status:e.request.status})]}),M(l,{style:J.tabs,children:M(Fa,{tabs:_a,activeKey:t,onChange:a=>o(a),size:"sm"})}),M(i,{style:[v.mono,J.body],numberOfLines:14,selectable:!0,children:n.length>1600?`${n.slice(0,1600)}
9
+ \u2026`:n}),M(he,{blockId:e.id,actions:[{label:"Open in Network",openTool:{toolId:"network",select:e.request.id}}]}),(s.supports?.openTool===!1,null)]})}function ln({block:e}){let o=K().rules?.[e.rule.id],r=o?.deleted===!0,n={...e.rule,enabled:r?!1:o?.enabled??e.rule.enabled},s=n.kind==="fail"?"fails (no network)":n.kind==="delay"?`delayed ${n.delayMs??0} ms`:`returns ${n.status??200}`;return de(H,{title:n.name??"Network override",source:e.source,testID:`buoy-block-rule-${e.id}`,tone:n.enabled?"warning":void 0,children:[de(l,{style:J.ruleBody,children:[de(i,{style:J.ruleLine,children:[de(i,{style:J.ruleKey,children:[n.methods?.length?n.methods.join("/"):"ANY"," "]}),M(i,{style:v.mono,children:n.urlPattern})]}),de(i,{style:J.ruleLine,children:[M(i,{style:J.ruleKey,children:"\u2192 "}),s,n.times?` \xB7 ${n.times===1?"once":`${n.times} times`}`:" \xB7 every time",n.hits!==void 0?` \xB7 ${n.hits} hit${n.hits===1?"":"s"}`:""]}),M(l,{style:[v.pill,n.enabled?J.on:J.off],children:M(i,{style:[v.pillText,{color:n.enabled?I.color.onAccent:I.color.textSecondary}],children:r?"DELETED":n.enabled?"ON":"OFF"})})]}),r?null:M(he,{blockId:e.id,actions:[n.enabled?{label:"Turn off",dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:n.id,enabled:!1}}}:{label:"Turn on",primary:!0,dispatch:{toolId:"network",action:"setOverrideRuleEnabled",params:{id:n.id,enabled:!0}}},{label:"Delete",dispatch:{toolId:"network",action:"deleteOverrideRule",params:{id:n.id}}}]})]})}function cn({block:e}){let t=K(),o=Ee(e.elements,so.chips),{visible:r}=o;return de(H,{title:e.title??"On screen right now",source:e.source,testID:`buoy-block-screen-${e.id}`,children:[r.map((n,s)=>de(b,{onPress:()=>void t.runAction({label:"Highlight",dispatch:{toolId:"highlight-updates",action:"setSpotlight",params:{nativeTag:n.nativeTag}}},e.id),disabled:t.supports?.dispatch===!1,style:[v.row,s>0&&v.rowDivider],accessibilityRole:"button",children:[M(on,{size:12,color:I.color.textTertiary}),M(i,{style:v.rowTitle,numberOfLines:1,children:n.label??n.testID??n.name}),M(i,{style:v.rowTrailing,numberOfLines:1,children:n.name})]},`${n.nativeTag}-${s}`)),M(We,{paged:o})]})}function dn({block:e}){let t=K(),o=Ee(e.routes,so.chips),r=o.visible;return de(H,{title:e.current?`Routes \xB7 you're on ${e.current}`:"Routes",source:e.source,testID:`buoy-block-routes-${e.id}`,children:[M(l,{style:J.chips,children:r.map((n,s)=>M(b,{disabled:t.supports?.dispatch===!1,onPress:()=>n.dynamic?t.answer({blockId:e.id,kind:"input",value:`Open ${n.path} \u2014 which id?`}):void t.runAction({label:`Open ${n.path}`,dispatch:{toolId:"route-events",action:"navigate",params:{path:n.path}}},e.id),style:[J.chip,n.path===e.current&&J.chipCurrent],accessibilityRole:"button",children:M(i,{style:[J.chipText,n.dynamic&&J.chipDynamic],children:n.path})},`${n.path}-${s}`))}),M(We,{paged:o})]})}var tn={error:I.color.danger,warn:I.color.warning,warning:I.color.warning,info:I.color.info};function un({block:e}){let t=Ee(e.entries,so.listItems),{visible:o}=t;return de(H,{title:"Console",source:e.source,testID:`buoy-block-logs-${e.id}`,children:[o.map((r,n)=>de(l,{style:[v.row,n>0&&v.rowDivider,J.logRow],children:[M(l,{style:[v.pill,{backgroundColor:`${tn[r.level]??I.color.textTertiary}22`}],children:M(i,{style:[v.pillText,{color:tn[r.level]??I.color.textSecondary}],children:r.level.toUpperCase()})}),M(i,{style:[v.rowTitle,v.mono],numberOfLines:3,children:r.message}),r.count>1?de(i,{style:v.rowTrailing,children:["\xD7",r.count]}):null]},`${r.level}-${r.message}-${n}`)),M(We,{paged:t})]})}function pn({block:e}){return de(H,{tone:"danger",testID:`buoy-block-crash-${e.id}`,children:[de(l,{style:J.crashHead,children:[M(Na,{size:14,color:I.color.danger}),de(i,{style:J.crashTitle,children:["The app crashed",e.route?` on ${e.route}`:""]})]}),M(i,{style:[v.mono,J.crashMsg],numberOfLines:4,selectable:!0,children:e.message}),e.suspect?de(i,{style:J.suspect,children:["Most likely cause: ",e.suspect.label]}):null,M(he,{blockId:e.id,actions:[...e.suspect?.action?[{...e.suspect.action,primary:!0}]:[],...e.actions??[]].slice(0,2)})]})}function gn({block:e}){let t=K(),o=t.supports?.minimize!==!1;return de(b,{testID:`buoy-block-peek-${e.id}`,disabled:!o,onPress:()=>void t.runAction({label:"Look",minimize:!0},e.id),style:({pressed:r})=>[J.peek,r&&{opacity:.7}],accessibilityRole:"button",accessibilityLabel:`${e.label}. Look at the app`,children:[M(i,{style:J.peekText,children:e.label}),o?de(l,{style:J.peekLook,children:[M(on,{size:12,color:I.color.accent}),M(i,{style:J.peekLookText,children:"Look"})]}):null]})}var J=y.create({method:{color:I.color.textSecondary,fontSize:I.font.micro,fontWeight:"700",letterSpacing:.4,width:44},mockedChip:{color:I.color.warning,backgroundColor:I.color.warningSoft,fontSize:9,fontWeight:"700",letterSpacing:.6,paddingHorizontal:5,paddingVertical:1,borderRadius:I.radius.badge,overflow:"hidden"},reqHead:{paddingTop:12},tabs:{paddingHorizontal:12,paddingTop:4,paddingBottom:8},tab:{paddingHorizontal:10,paddingVertical:5,borderRadius:I.radius.badge,backgroundColor:I.color.fill},tabOn:{backgroundColor:I.color.accentSoft},tabText:{color:I.color.textSecondary,fontSize:I.font.micro,fontWeight:"600"},tabTextOn:{color:I.color.accent},body:{paddingHorizontal:12,paddingBottom:4,lineHeight:16,color:I.color.textSecondary},ruleBody:{paddingHorizontal:12,paddingTop:4,paddingBottom:4,gap:4},ruleLine:{color:I.color.text,fontSize:I.font.caption,lineHeight:18},ruleKey:{color:I.color.textSecondary,fontWeight:"700"},on:{alignSelf:"flex-start",backgroundColor:I.color.accent,marginTop:4},off:{alignSelf:"flex-start",backgroundColor:I.color.fillTertiary,marginTop:4},chips:{flexDirection:"row",flexWrap:"wrap",gap:6,padding:12},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:I.radius.chip,backgroundColor:I.color.fill,borderWidth:y.hairlineWidth,borderColor:I.color.border},chipCurrent:{backgroundColor:I.color.accentSoft,borderColor:I.color.accentBorderStrong},chipText:{color:I.color.text,fontSize:I.font.caption,fontFamily:"Menlo"},chipDynamic:{color:I.color.textSecondary},logRow:{alignItems:"flex-start"},crashHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingTop:12},crashTitle:{color:I.color.danger,fontSize:I.font.row,fontWeight:"600"},crashMsg:{paddingHorizontal:12,paddingTop:6,color:I.color.text},suspect:{color:I.color.textSecondary,fontSize:I.font.caption,paddingHorizontal:12,paddingTop:6},peek:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:10,paddingLeft:12,paddingRight:10,paddingVertical:7,borderRadius:I.radius.chip,backgroundColor:I.color.fill},peekText:{color:I.color.textSecondary,fontSize:I.font.caption},peekLook:{flexDirection:"row",alignItems:"center",gap:4},peekLookText:{color:I.color.accent,fontSize:I.font.caption,fontWeight:"600"}});import{useEffect as Ua,useRef as yn,useState as Ze}from"react";import{AlertTriangle as Ka,Check as bn,ChevronDown as hn,ChevronRight as mn,night as d,NightSegmented as ja,RefreshCw as Qa,Search as Ga,X as Ja}from"@buoy-gg/shared-ui/web";import{Fragment as ao,jsx as p,jsxs as k}from"react/jsx-runtime";var fn=e=>typeof e=="string"?e:e===void 0?"\u2014":JSON.stringify(e);function xn({block:e}){let t=K();return p(l,{style:c.chips,testID:`buoy-block-suggestions-${e.id}`,children:e.chips.slice(0,4).map(o=>p(b,{disabled:!!t.busy,onPress:()=>void t.runAction({label:o.label,send:o.send??o.label},e.id),style:({pressed:r})=>[c.chip,r&&c.pressed],accessibilityRole:"button",children:p(i,{style:c.chipText,children:o.label})},o.label))})}function wn({block:e}){let t=K(),o=t.answered[e.id],r=!!o,[n,s]=Ze([]),a=o?.kind==="multi"?o.optionIds:n,g=f=>s(m=>m.includes(f)?m.filter(O=>O!==f):[...m,f]),u=n.length>=(e.min??1)&&(!e.max||n.length<=e.max);return k(H,{testID:`buoy-block-multi-${e.id}`,tone:r?void 0:"info",children:[p(i,{style:c.question,children:e.question}),p(l,{style:c.optionsBox,children:e.options.map((f,m)=>{let O=a.includes(f.id);return k(b,{disabled:r,onPress:()=>g(f.id),style:[c.option,m>0&&v.rowDivider,r&&!O&&c.dim],accessibilityRole:"checkbox",accessibilityState:{checked:O},children:[p(l,{style:[c.checkbox,O&&c.checkboxOn],children:O?p(bn,{size:11,color:d.color.onAccent}):null}),k(l,{style:c.flex,children:[p(i,{style:c.optionLabel,children:f.label}),f.detail?p(i,{style:c.optionDetail,children:f.detail}):null]})]},f.id)})}),r?null:p(l,{style:c.rowEnd,children:p(b,{testID:"buoy-block-multi-submit",disabled:!u,onPress:()=>t.answer({blockId:e.id,kind:"multi",optionIds:n,labels:e.options.filter(f=>n.includes(f.id)).map(f=>f.label)}),style:[c.button,c.buttonPrimary,!u&&c.disabled],children:p(i,{style:c.buttonTextPrimary,children:e.submitLabel??`Use ${n.length||""}`.trim()})})})]})}var Ya=8;function Tn({block:e}){let t=K(),o=t.answered[e.id],[r,n]=Ze(""),[s,a]=Ze(!1),g=o?.kind==="select"?o.label:null,u=e.options.filter(m=>!r||m.label.toLowerCase().includes(r.toLowerCase())).slice(0,8),f=e.searchable!==!1&&e.options.length>=Ya;return k(H,{testID:`buoy-block-select-${e.id}`,tone:o?void 0:"info",children:[p(i,{style:c.question,children:e.label}),g?p(i,{style:c.decided,children:g}):k(l,{style:c.selectBox,children:[k(b,{onPress:()=>a(m=>!m),style:c.selectField,accessibilityRole:"button",children:[p(i,{style:c.selectPlaceholder,children:s?"Choose\u2026":`${e.options.length} options`}),p(hn,{size:14,color:d.color.textSecondary})]}),s&&k(ao,{children:[f&&k(l,{style:c.search,children:[p(Ga,{size:12,color:d.color.textSecondary}),p(ze,{style:c.searchInput,value:r,onChangeText:n,placeholder:"Search",placeholderTextColor:d.color.placeholder,autoCapitalize:"none",autoCorrect:!1})]}),u.map((m,O)=>k(b,{onPress:()=>t.answer({blockId:e.id,kind:"select",optionId:m.id,label:m.label}),style:[c.option,O>0&&v.rowDivider],accessibilityRole:"button",children:[k(l,{style:c.flex,children:[p(i,{style:c.optionLabel,children:m.label}),m.detail?p(i,{style:c.optionDetail,children:m.detail}):null]}),p(mn,{size:12,color:d.color.textTertiary})]},m.id)),e.options.length>u.length?k(i,{style:c.hint,children:[e.options.length-u.length," more \u2014 keep typing"]}):null]})]})]})}function kn({min:e,max:t,step:o=1,value:r,unit:n,onChange:s,disabled:a}){let g=yn(0),u=t>e?(r-e)/(t-e)*100:0,f=L=>Math.min(t,Math.max(e,+(Math.round((L-e)/o)*o+e).toFixed(6))),m=L=>!a&&s(f(r+L*o)),O=L=>{if(a||g.current<=0)return;let oe=Math.min(1,Math.max(0,L.nativeEvent.locationX/g.current));s(f(e+oe*(t-e)))},$=L=>{g.current=L.nativeEvent.layout.width};return k(l,{style:c.sliderRow,children:[p(b,{disabled:a,onPress:()=>m(-1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Decrease",children:p(i,{style:c.stepText,children:"\u2212"})}),p(b,{style:c.trackHit,onLayout:$,onPress:O,disabled:a,accessibilityRole:"adjustable",accessibilityValue:{min:e,max:t,now:r},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:L=>m(L.nativeEvent.actionName==="increment"?1:-1),children:k(l,{style:c.track,pointerEvents:"none",children:[p(l,{style:[c.fill,{width:`${u}%`}]}),p(l,{style:[c.thumb,{left:`${u}%`}]})]})}),p(b,{disabled:a,onPress:()=>m(1),style:c.stepBtn,accessibilityRole:"button",accessibilityLabel:"Increase",children:p(i,{style:c.stepText,children:"+"})}),k(i,{style:c.sliderValue,children:[r,n?` ${n}`:""]})]})}function Sn({block:e}){let t=K(),o=t.answered[e.id],[r,n]=Ze(e.value??e.min);return k(H,{testID:`buoy-block-slider-${e.id}`,tone:o?void 0:"info",children:[p(i,{style:c.question,children:e.label}),p(l,{style:c.pad,children:p(kn,{min:e.min,max:e.max,step:e.step,value:o?.kind==="slider"?o.value:r,unit:e.unit,onChange:n,disabled:!!o})}),o?null:p(l,{style:c.rowEnd,children:p(b,{onPress:()=>t.answer({blockId:e.id,kind:"slider",value:r,unit:e.unit}),style:[c.button,c.buttonPrimary],children:k(i,{style:c.buttonTextPrimary,children:["Use ",r,e.unit?` ${e.unit}`:""]})})})]})}function Cn({block:e}){let t=K(),o=t.answered[e.id],[r,n]=Ze(""),s=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 k(H,{testID:`buoy-block-datetime-${e.id}`,tone:o?void 0:"info",children:[p(i,{style:c.question,children:e.label}),o?p(i,{style:c.decided,children:o.kind==="dateTime"?o.label??o.value:"(skipped)"}):k(ao,{children:[p(l,{style:[c.chips,c.pad],children:s.map(a=>p(b,{onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:a.value,label:a.label}),style:c.chip,children:p(i,{style:c.chipText,children:a.label})},a.label))}),k(l,{style:[c.inputRow,c.pad],children:[p(ze,{style:c.input,value:r,onChangeText:n,placeholder:e.mode==="time"?"14:30":"2026-09-15",placeholderTextColor:d.color.placeholder,keyboardType:"numbers-and-punctuation"}),p(b,{disabled:!r.trim(),onPress:()=>t.answer({blockId:e.id,kind:"dateTime",value:r.trim()}),style:[c.button,c.buttonPrimary,!r.trim()&&c.disabled],children:p(i,{style:c.buttonTextPrimary,children:"Use"})})]})]})]})}function vn({f:e,value:t,onChange:o,disabled:r}){return e.type==="toggle"?k(l,{style:c.fieldRow,children:[p(i,{style:c.fieldLabel,children:e.label}),p(vo,{value:!!t,onValueChange:o,disabled:r,trackColor:{true:d.color.accent,false:d.color.fillTertiary},thumbColor:d.color.knob})]}):e.type==="select"?k(l,{style:c.fieldCol,children:[p(i,{style:c.fieldLabel,children:e.label}),p(l,{style:c.chips,children:e.options.map(n=>p(b,{disabled:r,onPress:()=>o(n.id),style:[c.chip,t===n.id&&c.chipOn],children:p(i,{style:[c.chipText,t===n.id&&c.chipTextOn],children:n.label})},n.id))})]}):e.type==="slider"?k(l,{style:c.fieldCol,children:[p(i,{style:c.fieldLabel,children:e.label}),p(kn,{min:e.min,max:e.max,step:e.step,unit:e.unit,value:typeof t=="number"?t:e.min,onChange:o,disabled:r})]}):k(l,{style:c.fieldRow,children:[p(i,{style:c.fieldLabel,children:e.label}),p(ze,{style:c.fieldInput,value:t==null?"":String(t),onChangeText:o,editable:!r,placeholder:e.placeholder??"",placeholderTextColor:d.color.placeholder,keyboardType:e.type==="number"?"numeric":"ascii-capable",secureTextEntry:e.type==="secret",autoCapitalize:"none",autoCorrect:!1})]})}function Bn(e){let[t,o]=Ze(()=>Object.fromEntries(e.map(r=>[r.key,r.value])));return{values:t,set:(r,n)=>o(s=>({...s,[r]:n}))}}function An({block:e}){let t=K(),o=t.answered[e.id],{values:r,set:n}=Bn(e.fields);return k(H,{title:e.title,testID:`buoy-block-form-${e.id}`,tone:o?void 0:"info",children:[p(l,{style:c.pad,children:e.fields.map(s=>p(vn,{f:s,value:r[s.key],onChange:a=>n(s.key,a),disabled:!!o},s.key))}),o?p(i,{style:c.decided,children:"Sent"}):p(l,{style:c.rowEnd,children:p(b,{onPress:()=>t.answer({blockId:e.id,kind:"form",values:r}),style:[c.button,c.buttonPrimary],children:p(i,{style:c.buttonTextPrimary,children:e.submitLabel??"Send"})})})]})}function In({block:e}){let t=K(),o=t.answered[e.id],{values:r,set:n}=Bn(e.fields),s=o?.kind==="proposal"?o.approved:null;return k(H,{testID:`buoy-block-proposal-${e.id}`,tone:o?void 0:"warning",children:[p(i,{style:c.confirmTitle,children:e.title}),p(i,{style:c.confirmChange,children:e.change}),p(l,{style:c.pad,children:e.fields.map(a=>p(vn,{f:a,value:r[a.key],onChange:g=>n(a.key,g),disabled:!!o},a.key))}),e.consequence?p(i,{style:c.consequence,children:e.consequence}):null,p(l,{style:c.actionsRow,children:o?p(i,{style:c.decided,children:s?"\u2713 Applied with these values":"\u2715 Not applied"}):k(ao,{children:[p(b,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:!0,values:r}),style:[c.button,c.buttonPrimary],children:p(i,{style:c.buttonTextPrimary,children:e.approveLabel??"Apply"})}),p(b,{onPress:()=>t.answer({blockId:e.id,kind:"proposal",approved:!1}),style:[c.button,c.buttonPlate],children:p(i,{style:c.buttonTextPlate,children:"Not now"})})]})})]})}function Rn({block:e}){let t=K(),[o,r]=Ze(null),n=t.actionState?.[`${e.id}:${e.verify?.label??"Verify"}`],s=e.verified||n==="done";return k(l,{style:c.claim,testID:`buoy-block-claim-${e.id}`,children:[k(i,{style:c.claimText,children:[e.text,e.sources.map((a,g)=>k(i,{onPress:()=>r(o===g?null:g),style:c.cite,children:[" [",g+1,"]"]},g)),s?p(i,{style:c.verified,children:" \u2713 verified"}):null]}),o!==null&&e.sources[o]?k(l,{style:c.citeBox,children:[k(i,{style:c.citeLabel,children:["[",o+1,"] ",e.sources[o].label]}),e.sources[o].detail?p(i,{style:c.citeDetail,children:e.sources[o].detail}):null]}):null,e.verify&&!s?k(b,{onPress:()=>void t.runAction(e.verify,e.id),style:c.verifyBtn,accessibilityRole:"button",children:[p(Qa,{size:11,color:d.color.accent}),p(i,{style:c.verifyText,children:n==="running"?"Checking\u2026":e.verify.label})]}):null]})}function Pn({block:e}){let[t,o]=Ze(!!e.open);return k(H,{testID:`buoy-block-details-${e.id}`,children:[k(b,{onPress:()=>o(r=>!r),style:v.row,accessibilityRole:"button",accessibilityState:{expanded:t},children:[p(i,{style:v.rowTitle,children:e.summary}),t?p(hn,{size:12,color:d.color.textTertiary}):p(mn,{size:12,color:d.color.textTertiary})]}),t?p(i,{style:c.detailsBody,selectable:!0,children:e.body}):null]})}function Dn({block:e,renderNested:t}){let[o,r]=Ze(0),n=e.tabs.map((a,g)=>({key:String(g),label:a.label})),s=e.tabs[o];return k(l,{style:c.tabsWrap,testID:`buoy-block-tabs-${e.id}`,children:[p(ja,{tabs:n,activeKey:String(o),onChange:a=>r(Number(a)),size:"sm"}),s&&t?t(s.block):null]})}var Xa=10;function zn({block:e}){let t=Ee(e.events,Xa);return k(H,{title:e.title??"What happened",source:e.source,testID:`buoy-block-timeline-${e.id}`,children:[t.visible.map((o,r)=>k(l,{style:c.tlRow,children:[p(i,{style:c.tlAt,children:o.at}),k(l,{style:c.tlLine,children:[p(l,{style:[c.tlDot,{backgroundColor:Xe(o.tone??"muted")}]}),r<t.visible.length-1?p(l,{style:c.tlStem}):null]}),k(l,{style:c.flex,children:[p(i,{style:c.tlSource,children:o.source.toUpperCase()}),p(i,{style:v.rowTitle,numberOfLines:2,children:o.label})]})]},r)),p(We,{paged:t})]})}function Vn({block:e}){let t=e.series.slice(-60),o=Math.max(1,...t),r=Math.min(...t,0),n=44;return k(H,{title:e.title,source:e.source,testID:`buoy-block-sparkline-${e.id}`,children:[k(l,{style:c.sparkHead,children:[k(i,{style:c.sparkCurrent,children:[e.current??t[t.length-1],e.unit?k(i,{style:c.sparkUnit,children:[" ",e.unit]}):null]}),e.live?p(Lo,{}):null]}),p(l,{style:[c.spark,{height:n}],children:t.map((s,a)=>p(l,{style:[c.sparkBar,{height:Math.max(2,(s-r)/(o-r||1)*n),backgroundColor:a===t.length-1?d.color.accent:d.color.accentBorderStrong}]},a))}),e.label?p(i,{style:c.hint,children:e.label}):null]})}function Lo(){let e=yn(new ee.Value(1)).current;return Ua(()=>{let t=ee.loop(ee.sequence([ee.timing(e,{toValue:.3,duration:700,useNativeDriver:!0}),ee.timing(e,{toValue:1,duration:700,useNativeDriver:!0})]));return t.start(),()=>t.stop()},[e]),k(l,{style:c.live,children:[p(ee.View,{style:[c.liveDot,{opacity:e}]}),p(i,{style:c.liveText,children:"LIVE"})]})}function Ln({block:e}){let t=[...new Set([...e.left.pairs.map(n=>n.key),...e.right.pairs.map(n=>n.key)])],o=Object.fromEntries(e.left.pairs.map(n=>[n.key,n.value])),r=Object.fromEntries(e.right.pairs.map(n=>[n.key,n.value]));return k(H,{title:e.title,source:e.source,testID:`buoy-block-compare-${e.id}`,children:[k(l,{style:c.cmpHead,children:[p(i,{style:c.cmpKey}),p(i,{style:c.cmpCol,children:e.left.title}),p(i,{style:c.cmpCol,children:e.right.title})]}),t.map((n,s)=>{let a=JSON.stringify(o[n])!==JSON.stringify(r[n]);return k(l,{style:[c.cmpRow,s>0&&v.rowDivider,a&&c.cmpDiff],children:[p(i,{style:c.cmpKey,numberOfLines:1,children:n}),p(i,{style:[c.cmpVal,a&&{color:d.color.danger}],numberOfLines:2,children:fn(o[n])}),p(i,{style:[c.cmpVal,a&&{color:d.color.accent}],numberOfLines:2,children:fn(r[n])})]},n)})]})}function Hn({c:e,id:t}){return k(ao,{children:[e.image?p(Ye,{testID:"buoy-internal-chat-image",source:{uri:e.image},style:c.cardImage,resizeMode:"contain",accessibilityLabel:e.title}):null,k(l,{style:c.cardText,children:[p(i,{style:c.cardTitle,numberOfLines:2,children:e.title}),e.subtitle?p(i,{style:v.rowSub,numberOfLines:2,children:e.subtitle}):null,e.facts?.slice(0,4).map(o=>k(l,{style:c.fact,children:[p(i,{style:c.factLabel,children:o.label}),p(i,{style:[c.factValue,o.tone&&{color:Xe(o.tone)}],children:o.value})]},o.label))]}),p(he,{actions:e.actions,blockId:t})]})}function $n({block:e}){return p(H,{source:e.source,testID:`buoy-block-card-${e.id}`,children:p(Hn,{c:e,id:e.id})})}function On({block:e}){return k(l,{testID:`buoy-block-cardcarousel-${e.id}`,children:[e.title?p(i,{style:c.carouselTitle,children:e.title}):null,p(ke,{horizontal:!0,showsHorizontalScrollIndicator:!1,snapToInterval:232,decelerationRate:"fast",contentContainerStyle:c.carousel,children:e.cards.slice(0,8).map((t,o)=>p(l,{style:c.carouselCard,children:p(Hn,{c:t,id:`${e.id}-${o}`})},`${t.title}-${o}`))})]})}function En({block:e}){let[t,o]=Ze(!1);return k(H,{title:e.route?`Screen \xB7 ${e.route}`:"Screen",source:e.source,testID:`buoy-block-screenshot-${e.id}`,children:[p(b,{onPress:()=>o(r=>!r),accessibilityRole:"imagebutton",accessibilityLabel:e.caption??"Screenshot",children:p(Ye,{testID:"buoy-internal-chat-image",source:{uri:e.url},style:[c.shot,t&&c.shotBig],resizeMode:"contain"})}),e.caption?p(i,{style:c.hint,children:e.caption}):null]})}function Wn({block:e}){let t=e.steps.filter(o=>o.state==="done").length;return k(H,{title:e.title,testID:`buoy-block-plan-${e.id}`,tone:e.pending?"info":void 0,children:[p(l,{style:c.progress,children:p(l,{style:[c.progressFill,{width:`${t/Math.max(1,e.steps.length)*100}%`}]})}),e.steps.map((o,r)=>k(l,{style:[c.step,r>0&&v.rowDivider],children:[p(l,{style:[c.stepMark,o.state==="done"&&c.stepDone,o.state==="failed"&&c.stepFailed,o.state==="running"&&c.stepRunning],children:o.state==="done"?p(bn,{size:10,color:d.color.onAccent}):o.state==="failed"?p(Ja,{size:10,color:d.color.text}):p(i,{style:c.stepNum,children:r+1})}),k(i,{style:[v.rowTitle,o.state==="done"&&c.muted],children:[o.text,o.state==="running"?"\u2026":""]})]},r)),p(he,{actions:e.actions??(e.pending?[{label:"Go",primary:!0,send:"Go ahead with the plan."},{label:"Change it",send:"Let me change the plan first."}]:void 0),blockId:e.id})]})}function Mn({block:e}){let t=K();return k(b,{testID:`buoy-block-checkpoint-${e.id}`,disabled:!e.restore,onPress:()=>e.restore&&void t.runAction(e.restore,e.id),style:c.checkpoint,accessibilityRole:"button",children:[p(l,{style:c.cpFlag}),k(i,{style:c.cpText,children:[e.label,e.at?` \xB7 ${e.at}`:""]}),e.restore?p(i,{style:c.cpRestore,children:e.restore.label}):null]})}function Nn({block:e}){let t=e.status==="failed"?d.color.danger:e.status==="done"?d.color.accent:d.color.info;return k(H,{testID:`buoy-block-task-${e.id}`,children:[k(l,{style:c.taskHead,children:[p(i,{style:c.cardTitle,children:e.title}),p(l,{style:[v.pill,{backgroundColor:`${t}22`}],children:p(i,{style:[v.pillText,{color:t}],children:e.status.toUpperCase()})})]}),e.progress!==void 0?p(l,{style:[c.progress,c.pad],children:p(l,{style:[c.progressFill,{width:`${Math.round(e.progress*100)}%`,backgroundColor:t}]})}):null,e.detail?p(i,{style:c.hint,children:e.detail}):null,p(he,{actions:e.actions,blockId:e.id})]})}function qn({block:e}){let t=e.tone==="danger"?d.color.danger:e.tone==="warning"?d.color.warning:d.color.info;return k(l,{style:[c.banner,{borderColor:t,backgroundColor:`${t}1A`}],testID:`buoy-block-banner-${e.id}`,children:[p(Ka,{size:13,color:t}),p(i,{style:[c.bannerText,{color:t}],numberOfLines:2,children:e.text}),e.actions?.[0]?p(he,{actions:e.actions.slice(0,1),blockId:e.id,align:"right"}):null]})}function Fn({block:e}){return k(H,{testID:`buoy-block-file-${e.id}`,children:[k(l,{style:v.row,children:[p(l,{style:c.fileIcon,children:p(i,{style:c.fileExt,children:(e.type??e.name.split(".").pop()??"file").toUpperCase().slice(0,4)})}),k(l,{style:c.flex,children:[p(i,{style:v.rowTitle,numberOfLines:1,children:e.name}),e.size?p(i,{style:v.rowSub,children:e.size}):null]})]}),p(he,{actions:e.actions,blockId:e.id})]})}function _n({block:e}){let t=K(),o=t.answered[e.id];return k(H,{testID:`buoy-block-upload-${e.id}`,tone:o?void 0:"info",children:[p(i,{style:c.question,children:e.label}),o?p(i,{style:c.decided,children:o.kind==="upload"?`Attached ${o.name}`:"(skipped)"}):p(l,{style:[c.rowEnd,{justifyContent:"flex-start"}],children:p(b,{onPress:()=>t.answer({blockId:e.id,kind:"upload",name:"screenshot.png"}),style:[c.button,c.buttonPlate],children:p(i,{style:c.buttonTextPlate,children:e.accept==="image"?"Choose a screenshot":"Choose a file"})})})]})}var c=y.create({flex:{flex:1},pad:{paddingHorizontal:12,paddingBottom:8},muted:{color:d.color.textSecondary},dim:{opacity:.45},disabled:{opacity:.5},pressed:{opacity:.7},question:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",lineHeight:20,paddingHorizontal:12,paddingTop:12,paddingBottom:8},hint:{color:d.color.textTertiary,fontSize:d.font.micro,paddingHorizontal:12,paddingBottom:10},decided:{color:d.color.textSecondary,fontSize:d.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:d.radius.row},buttonPrimary:{backgroundColor:d.color.accent},buttonPlate:{backgroundColor:d.color.button},buttonTextPrimary:{color:d.color.onAccent,fontSize:d.font.caption,fontWeight:"600"},buttonTextPlate:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},chips:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill,borderWidth:y.hairlineWidth,borderColor:d.color.border},chipOn:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong},chipText:{color:d.color.text,fontSize:d.font.caption},chipTextOn:{color:d.color.accent,fontWeight:"600"},optionsBox:{marginHorizontal:8,marginBottom:8,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},option:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10},optionLabel:{color:d.color.text,fontSize:d.font.body,fontWeight:"500"},optionDetail:{color:d.color.textSecondary,fontSize:d.font.caption},checkbox:{width:20,height:20,borderRadius:6,borderWidth:1.5,borderColor:d.color.textTertiary,alignItems:"center",justifyContent:"center"},checkboxOn:{backgroundColor:d.color.accent,borderColor:d.color.accent},selectBox:{marginHorizontal:12,marginBottom:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,overflow:"hidden"},selectField:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:11},selectPlaceholder:{color:d.color.textSecondary,fontSize:d.font.body},search:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderTopWidth:y.hairlineWidth,borderTopColor:d.color.separator},searchInput:{flex:1,color:d.color.text,fontSize:d.font.caption,paddingVertical:4},sliderRow:{flexDirection:"row",alignItems:"center",gap:8},stepBtn:{width:28,height:28,borderRadius:14,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},stepText:{color:d.color.text,fontSize:16,fontWeight:"600"},trackHit:{flex:1,height:36,justifyContent:"center"},track:{height:6,borderRadius:3,backgroundColor:d.color.fillTertiary,justifyContent:"center"},fill:{height:6,borderRadius:3,backgroundColor:d.color.accent},thumb:{position:"absolute",width:20,height:20,borderRadius:10,backgroundColor:d.color.knob,marginLeft:-10,shadowColor:"#000",shadowOpacity:.35,shadowRadius:3,shadowOffset:{width:0,height:1}},sliderValue:{width:64,textAlign:"right",color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},inputRow:{flexDirection:"row",alignItems:"center",gap:8,paddingBottom:12},input:{flex:1,height:38,paddingHorizontal:12,borderRadius:d.radius.row,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.body},fieldRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:10,paddingVertical:6},fieldCol:{paddingVertical:6,gap:6},fieldLabel:{color:d.color.textSecondary,fontSize:d.font.caption,width:110},fieldInput:{flex:1,height:34,paddingHorizontal:10,borderRadius:d.radius.segment,backgroundColor:d.color.surfaceElevated,color:d.color.text,fontSize:d.font.caption},confirmTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600",paddingHorizontal:12,paddingTop:12},confirmChange:{color:d.color.text,fontSize:d.font.body,lineHeight:19,paddingHorizontal:12,paddingTop:6,paddingBottom:6},consequence:{color:d.color.warning,fontSize:d.font.caption,paddingHorizontal:12},claim:{gap:6,paddingHorizontal:2},claimText:{color:d.color.text,fontSize:d.font.row,lineHeight:22},cite:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"700"},verified:{color:d.color.accent,fontSize:d.font.caption,fontWeight:"600"},citeBox:{padding:10,borderRadius:d.radius.row,backgroundColor:d.color.surface,borderWidth:y.hairlineWidth,borderColor:d.color.border,gap:2},citeLabel:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600"},citeDetail:{color:d.color.textSecondary,fontSize:d.font.caption,fontFamily:"Menlo"},verifyBtn:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:5,paddingHorizontal:10,paddingVertical:5,borderRadius:d.radius.chip,backgroundColor:d.color.accentSoft},verifyText:{color:d.color.accent,fontSize:d.font.micro,fontWeight:"700"},detailsBody:{color:d.color.textSecondary,fontSize:d.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:12},tabsWrap:{gap:8},tabBar:{flexDirection:"row",gap:6},tab:{paddingHorizontal:12,paddingVertical:6,borderRadius:d.radius.badge,backgroundColor:d.color.fill},tabOn:{backgroundColor:d.color.accentSoft},tabText:{color:d.color.textSecondary,fontSize:d.font.caption,fontWeight:"600"},tabTextOn:{color:d.color.accent},tlRow:{flexDirection:"row",gap:10,paddingHorizontal:12,paddingVertical:4,alignItems:"flex-start"},tlAt:{width:46,color:d.color.textTertiary,fontSize:d.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:d.color.separator,marginTop:2},tlSource:{color:d.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6},sparkHead:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:8},sparkCurrent:{color:d.color.text,fontSize:22,fontWeight:"700"},sparkUnit:{color:d.color.textSecondary,fontSize:d.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:d.radius.badge,backgroundColor:d.color.dangerSoft},liveDot:{width:6,height:6,borderRadius:3,backgroundColor:d.color.danger},liveText:{color:d.color.danger,fontSize:9,fontWeight:"800",letterSpacing:.8},cmpHead:{flexDirection:"row",paddingHorizontal:12,paddingVertical:6,backgroundColor:d.color.fill,gap:8},cmpCol:{flex:1,color:d.color.textTertiary,fontSize:d.font.micro,fontWeight:"700",letterSpacing:.6,textTransform:"uppercase"},cmpRow:{flexDirection:"row",paddingHorizontal:12,paddingVertical:8,gap:8,alignItems:"flex-start"},cmpDiff:{backgroundColor:d.color.fill},cmpKey:{width:90,color:d.color.textSecondary,fontSize:d.font.caption},cmpVal:{flex:1,color:d.color.text,fontSize:d.font.caption,fontFamily:"Menlo"},cardImage:{width:"100%",height:140,backgroundColor:d.color.fill},cardText:{paddingHorizontal:12,paddingTop:10,paddingBottom:4,gap:4},cardTitle:{color:d.color.text,fontSize:d.font.row,fontWeight:"600"},fact:{flexDirection:"row",justifyContent:"space-between",gap:8},factLabel:{color:d.color.textSecondary,fontSize:d.font.caption},factValue:{color:d.color.text,fontSize:d.font.caption,fontWeight:"500"},carouselTitle:{color:d.color.text,fontSize:d.font.caption,fontWeight:"600",paddingBottom:8},carousel:{gap:8,paddingRight:8},carouselCard:{width:224,borderRadius:d.radius.card,borderWidth:y.hairlineWidth,borderColor:d.color.border,backgroundColor:d.color.surface,overflow:"hidden"},shot:{width:"100%",height:220,backgroundColor:d.color.fill},shotBig:{height:520},progress:{height:4,backgroundColor:d.color.fill,marginHorizontal:12,marginTop:6,marginBottom:8,borderRadius:2,overflow:"hidden"},progressFill:{height:4,backgroundColor:d.color.accent},step:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:9},stepMark:{width:20,height:20,borderRadius:10,backgroundColor:d.color.fillTertiary,alignItems:"center",justifyContent:"center"},stepDone:{backgroundColor:d.color.accent},stepFailed:{backgroundColor:d.color.danger},stepRunning:{backgroundColor:d.color.info},stepNum:{color:d.color.text,fontSize:d.font.micro,fontWeight:"700"},checkpoint:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:7,borderRadius:d.radius.chip,backgroundColor:d.color.fill},cpFlag:{width:8,height:8,borderRadius:2,backgroundColor:d.color.info},cpText:{color:d.color.textSecondary,fontSize:d.font.caption},cpRestore:{color:d.color.accent,fontSize:d.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:d.radius.row,borderWidth:y.hairlineWidth},bannerText:{flex:1,fontSize:d.font.caption,fontWeight:"600"},fileIcon:{width:40,height:40,borderRadius:8,backgroundColor:d.color.fill,alignItems:"center",justifyContent:"center"},fileExt:{color:d.color.textSecondary,fontSize:10,fontWeight:"800"}});import{jsx as D}from"react/jsx-runtime";var Ho=class extends Za{constructor(){super(...arguments);this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?D(i,{style:el.fallback,testID:"buoy-block-render-failed",children:"This card couldn't be drawn \u2014 the data behind it is still in the conversation."}):this.props.children}},el=y.create({fallback:{color:Un.color.textTertiary,fontSize:Un.font.micro,fontStyle:"italic",paddingVertical:6}}),tl=e=>D(Ht,{block:e});function Ht({block:e}){return D(Ho,{children:D(ol,{block:e})})}function ol({block:e}){switch(e.kind){case"choice":return D(Vr,{block:e});case"confirm":return D(Lr,{block:e});case"input":return D(Hr,{block:e});case"table":return D(Fr,{block:e});case"keyValue":return D(_r,{block:e});case"list":return D(Ur,{block:e});case"imageGrid":return D(Zr,{block:e});case"diff":return D(Kr,{block:e});case"chart":return D(jr,{block:e});case"steps":return D(Qr,{block:e});case"code":return D(Gr,{block:e});case"actions":return D(he,{actions:e.actions,blockId:e.id});case"notice":return D(Jr,{block:e});case"finding":return D(Yr,{block:e});case"requestList":return D(sn,{block:e});case"requestCard":return D(an,{block:e});case"ruleCard":return D(ln,{block:e});case"screenElements":return D(cn,{block:e});case"routeChips":return D(dn,{block:e});case"logList":return D(un,{block:e});case"crash":return D(pn,{block:e});case"peek":return D(gn,{block:e});case"suggestions":return D(xn,{block:e});case"multiSelect":return D(wn,{block:e});case"select":return D(Tn,{block:e});case"slider":return D(Sn,{block:e});case"dateTime":return D(Cn,{block:e});case"form":return D(An,{block:e});case"proposal":return D(In,{block:e});case"claim":return D(Rn,{block:e});case"details":return D(Pn,{block:e});case"tabs":return D(Dn,{block:e,renderNested:tl});case"timeline":return D(zn,{block:e});case"sparkline":return D(Vn,{block:e});case"compare":return D(Ln,{block:e});case"card":return D($n,{block:e});case"cardCarousel":return D(On,{block:e});case"screenshot":return D(En,{block:e});case"plan":return D(Wn,{block:e});case"checkpoint":return D(Mn,{block:e});case"task":return D(Nn,{block:e});case"banner":return D(qn,{block:e});case"file":return D(Fn,{block:e});case"upload":return D(_n,{block:e});default:return null}}import{useEffect as rl,useState as At}from"react";import{ChevronDown as nl,ChevronRight as il,Copy as sl,night as C,RefreshCw as al}from"@buoy-gg/shared-ui/web";import{jsx as q,jsxs as Ve}from"react/jsx-runtime";function qt({label:e,onPress:t,children:o}){return q(b,{onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:({pressed:r})=>[E.iconBtn,r&&E.pressed],children:o})}function Kn({id:e="chrome-actions"}){let t=K(),[o,r]=At(null),n=s=>void t.runAction({label:s,send:`__chrome__:${s}`},e);return Ve(l,{style:E.actions,testID:"chrome-message-actions",children:[q(qt,{label:"Copy",onPress:()=>n("copy"),children:q(sl,{size:13,color:C.color.textSecondary})}),q(qt,{label:"Retry",onPress:()=>n("retry"),children:q(al,{size:13,color:C.color.textSecondary})}),q(qt,{label:"Good answer",onPress:()=>{r("up"),n("thumbs up")},children:q(i,{style:[E.glyph,o==="up"&&E.glyphOn],children:"\u{1F44D}"})}),q(qt,{label:"Bad answer",onPress:()=>{r("down"),n("thumbs down")},children:q(i,{style:[E.glyph,o==="down"&&E.glyphOn],children:"\u{1F44E}"})}),q(qt,{label:"Export",onPress:()=>n("export transcript"),children:q(i,{style:E.textBtn,children:"Export"})})]})}function jn({text:e,live:t}){let[o,r]=At(!1);return Ve(l,{style:E.reasoning,testID:"chrome-reasoning",children:[Ve(b,{onPress:()=>r(n=>!n),style:E.reasoningHead,accessibilityRole:"button",accessibilityState:{expanded:o},children:[t?q(yt,{size:"small",color:C.color.textTertiary}):null,q(i,{style:E.reasoningTitle,children:t?"Working it out\u2026":"How I got here"}),o?q(nl,{size:12,color:C.color.textTertiary}):q(il,{size:12,color:C.color.textTertiary})]}),o?q(i,{style:E.reasoningBody,children:e}):null]})}function Qn({label:e}){let[t,o]=At(0);return rl(()=>{let r=setInterval(()=>o(n=>n+250),250);return()=>clearInterval(r)},[]),Ve(l,{style:E.elapsed,testID:"chrome-elapsed",children:[q(yt,{size:"small",color:C.color.textSecondary}),q(i,{style:E.elapsedLabel,children:e}),Ve(i,{style:E.elapsedMs,children:[(t/1e3).toFixed(1),"s"]})]})}function Gn(){let[e,t]=At(""),[o,r]=At(null);return Ve(l,{style:E.composerWrap,testID:"chrome-queue",children:[o?Ve(l,{style:E.queuedRow,children:[Ve(i,{style:E.queuedText,numberOfLines:1,children:['Queued: "',o,'"']}),q(b,{onPress:()=>r(null),children:q(i,{style:E.queuedCancel,children:"Cancel"})})]}):null,Ve(l,{style:E.composer,children:[q(ze,{style:E.composerInput,value:e,onChangeText:t,placeholder:"Agent is busy \u2014 type and it sends next",placeholderTextColor:C.color.placeholder}),q(b,{disabled:!e.trim(),onPress:()=>{r(e.trim()),t("")},style:[E.queueBtn,!e.trim()&&{opacity:.5}],children:q(i,{style:E.queueBtnText,children:"Queue"})})]})]})}function Jn({at:e}){return Ve(l,{style:E.divider,testID:"chrome-divider",children:[q(l,{style:E.dividerLine}),Ve(i,{style:E.dividerText,children:["App reloaded \xB7 ",e]}),q(l,{style:E.dividerLine})]})}function Yn({at:e}){return q(i,{style:E.timestamp,children:e})}function Xn({text:e}){let t=K(),[o,r]=At(!1),[n,s]=At(e);return q(l,{style:E.userWrap,testID:"chrome-edit-bubble",children:o?Ve(l,{style:E.editBox,children:[q(ze,{style:E.editInput,value:n,onChangeText:s,multiline:!0}),Ve(l,{style:E.editActions,children:[q(b,{onPress:()=>{r(!1),t.runAction({label:"re-run edited",send:`__chrome__:re-run "${n}"`},"chrome-edit")},style:E.editPrimary,children:q(i,{style:E.editPrimaryText,children:"Re-run from here"})}),q(b,{onPress:()=>{r(!1),t.runAction({label:"branch",send:`__chrome__:branch "${n}"`},"chrome-edit")},style:E.editPlate,children:q(i,{style:E.editPlateText,children:"Branch"})}),q(b,{onPress:()=>r(!1),style:E.editPlate,children:q(i,{style:E.editPlateText,children:"Cancel"})})]})]}):Ve(b,{onLongPress:()=>r(!0),onPress:()=>r(!0),style:E.bubble,accessibilityRole:"button",accessibilityLabel:"Edit message",children:[q(i,{style:E.bubbleText,children:n}),q(i,{style:E.bubbleHint,children:"tap to edit \xB7 2 branches"})]})})}var E=y.create({actions:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:2},iconBtn:{paddingHorizontal:8,paddingVertical:6,borderRadius:C.radius.badge},pressed:{backgroundColor:C.color.fill},glyph:{fontSize:13,opacity:.6},glyphOn:{opacity:1},textBtn:{color:C.color.textSecondary,fontSize:C.font.micro,fontWeight:"600"},reasoning:{borderRadius:C.radius.row,backgroundColor:C.color.fill,overflow:"hidden"},reasoningHead:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:8},reasoningTitle:{flex:1,color:C.color.textSecondary,fontSize:C.font.caption,fontStyle:"italic"},reasoningBody:{color:C.color.textSecondary,fontSize:C.font.caption,lineHeight:18,paddingHorizontal:12,paddingBottom:10},elapsed:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:10,borderRadius:C.radius.card,borderWidth:y.hairlineWidth,borderColor:C.color.border,backgroundColor:C.color.surface},elapsedLabel:{flex:1,color:C.color.text,fontSize:C.font.body},elapsedMs:{color:C.color.textTertiary,fontSize:C.font.caption,fontFamily:"Menlo"},composerWrap:{gap:6},queuedRow:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:6,borderRadius:C.radius.row,backgroundColor:C.color.infoSoft},queuedText:{flex:1,color:C.color.text,fontSize:C.font.caption},queuedCancel:{color:C.color.info,fontSize:C.font.caption,fontWeight:"600"},composer:{flexDirection:"row",alignItems:"center",gap:8},composerInput:{flex:1,height:40,paddingHorizontal:16,borderRadius:20,borderWidth:y.hairlineWidth,borderColor:C.color.border,backgroundColor:C.color.surfaceElevated,color:C.color.text,fontSize:C.font.body},queueBtn:{paddingHorizontal:14,height:40,borderRadius:20,backgroundColor:C.color.button,alignItems:"center",justifyContent:"center"},queueBtnText:{color:C.color.text,fontSize:C.font.caption,fontWeight:"600"},divider:{flexDirection:"row",alignItems:"center",gap:10,paddingVertical:4},dividerLine:{flex:1,height:y.hairlineWidth,backgroundColor:C.color.border},dividerText:{color:C.color.textTertiary,fontSize:C.font.micro},timestamp:{alignSelf:"center",color:C.color.textTertiary,fontSize:C.font.micro},userWrap:{alignItems:"flex-end"},bubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:C.color.accentFill,borderWidth:y.hairlineWidth,borderColor:C.color.accentBorder,gap:4},bubbleText:{color:C.color.text,fontSize:C.font.row,lineHeight:21},bubbleHint:{color:C.color.textTertiary,fontSize:10,textAlign:"right"},editBox:{width:"100%",gap:8},editInput:{minHeight:60,padding:12,borderRadius:C.radius.row,backgroundColor:C.color.surfaceElevated,color:C.color.text,fontSize:C.font.row,borderWidth:y.hairlineWidth,borderColor:C.color.accentBorderStrong},editActions:{flexDirection:"row",gap:8,justifyContent:"flex-end",flexWrap:"wrap"},editPrimary:{paddingHorizontal:12,paddingVertical:8,borderRadius:C.radius.row,backgroundColor:C.color.accent},editPrimaryText:{color:C.color.onAccent,fontSize:C.font.caption,fontWeight:"600"},editPlate:{paddingHorizontal:12,paddingVertical:8,borderRadius:C.radius.row,backgroundColor:C.color.button},editPlateText:{color:C.color.text,fontSize:C.font.caption,fontWeight:"600"}});import{useState as Zn}from"react";import{AlertTriangle as ll,ChevronDown as cl,night as N}from"@buoy-gg/shared-ui/web";import{jsx as xe,jsxs as Ft}from"react/jsx-runtime";function $o({pending:e,onAnswer:t}){let[o,r]=Zn("");return Ft(l,{style:Y.card,testID:"buoy-ask-buoy-approval",children:[Ft(l,{style:Y.titleRow,children:[xe(ll,{size:14,color:N.color.warning}),xe(i,{style:Y.title,children:"Allow this change?"})]}),e.restored?xe(i,{style:Y.restored,testID:"buoy-ask-buoy-approval-restored",children:"Asked before the app restarted \u2014 check it still applies."}):null,xe(i,{style:Y.label,children:e.label}),xe(i,{style:Y.reason,children:e.reason}),e.description?xe(dl,{text:e.description}):null,xe(ze,{testID:"buoy-ask-buoy-approval-note",value:o,onChangeText:r,placeholder:"Add a note for the agent (optional)",placeholderTextColor:N.color.textTertiary,style:Y.note,returnKeyType:"done",blurOnSubmit:!0}),Ft(l,{style:Y.actions,children:[xe(b,{testID:"buoy-ask-buoy-approve",accessibilityRole:"button",onPress:()=>t({approved:!0,reason:o}),style:({pressed:n})=>[Y.button,Y.approve,n&&Y.pressed],children:xe(i,{style:Y.approveText,children:"Allow"})}),e.restored?null:xe(b,{testID:"buoy-ask-buoy-approve-trust",accessibilityRole:"button",onPress:()=>t({approved:!0,reason:o,trust:!0}),style:({pressed:n})=>[Y.button,Y.trust,n&&Y.pressed],children:xe(i,{style:Y.trustText,children:"Allow for this chat"})}),xe(b,{testID:"buoy-ask-buoy-reject",accessibilityRole:"button",onPress:()=>t({approved:!1,reason:o}),style:({pressed:n})=>[Y.button,Y.reject,n&&Y.pressed],children:xe(i,{style:Y.rejectText,children:"Not now"})})]})]})}function dl({text:e}){let[t,o]=Zn(!1);return Ft(l,{children:[Ft(b,{testID:"buoy-ask-buoy-approval-details",accessibilityRole:"button",accessibilityState:{expanded:t},onPress:()=>o(r=>!r),style:({pressed:r})=>[Y.disclosure,r&&Y.pressed],hitSlop:6,children:[xe(l,{style:t?Y.chevronOpen:Y.chevronClosed,children:xe(cl,{size:12,color:N.color.textTertiary})}),xe(i,{style:Y.disclosureText,children:t?"Hide details":"Details"})]}),t?xe(ke,{style:Y.detail,contentContainerStyle:Y.detailContent,nestedScrollEnabled:!0,children:xe(i,{style:Y.description,children:e})}):null]})}var Y=y.create({card:{marginHorizontal:N.gutter,marginBottom:10,padding:N.cardPad,borderRadius:N.radius.card,borderWidth:y.hairlineWidth,borderColor:N.color.accentBorderStrong,backgroundColor:N.color.surface,gap:6},titleRow:{flexDirection:"row",alignItems:"center",gap:6},title:{color:N.color.text,fontSize:N.font.caption,fontWeight:"600"},label:{color:N.color.text,fontSize:N.font.row,fontWeight:"600",lineHeight:20},description:{color:N.color.textSecondary,fontSize:N.font.caption,lineHeight:18},reason:{color:N.color.warning,fontSize:N.font.caption,lineHeight:18},restored:{color:N.color.info,backgroundColor:N.color.infoSoft,fontSize:N.font.micro,lineHeight:16,paddingHorizontal:8,paddingVertical:5,borderRadius:8},disclosure:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:4},disclosureText:{color:N.color.textTertiary,fontSize:N.font.micro,fontWeight:"600"},chevronOpen:{transform:[{rotate:"0deg"}]},chevronClosed:{transform:[{rotate:"-90deg"}]},detail:{maxHeight:150,marginTop:2},detailContent:{paddingBottom:2},note:{color:N.color.text,fontSize:N.font.caption,paddingHorizontal:10,paddingVertical:7,borderRadius:N.radius.row,borderWidth:y.hairlineWidth,borderColor:N.color.border,backgroundColor:N.color.button,marginTop:2},actions:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},button:{paddingHorizontal:16,paddingVertical:9,borderRadius:N.radius.row},approve:{backgroundColor:N.color.accent},approveText:{color:N.color.onAccent,fontWeight:"600",fontSize:N.font.caption},trust:{backgroundColor:N.color.button,borderWidth:y.hairlineWidth,borderColor:N.color.accentBorderStrong},trustText:{color:N.color.accent,fontWeight:"600",fontSize:N.font.caption},reject:{backgroundColor:N.color.button},rejectText:{color:N.color.text,fontSize:N.font.caption},pressed:{opacity:.7}});import{useSyncExternalStore as ul}from"react";import{ChevronDown as pl,ChevronRight as gl,night as ie}from"@buoy-gg/shared-ui/web";import{isReversible as ei}from"@buoy-gg/agent-core/web";import{jsx as ct,jsxs as mt}from"react/jsx-runtime";var ti=[];function Oo(e){return ul(t=>e?.subscribe(t)??(()=>{}),()=>e?.list()??ti,()=>e?.list()??ti)}function Eo({ledger:e,onUndoAll:t,expanded:o,onToggle:r}){let s=Oo(e).filter($=>!$.undoneAt),a=s.filter($=>$.effect.kind!=="transient");if(a.length===0)return null;let g=a.filter($=>ei($.effect)),u=a.length-g.length,f=s.length-a.length,m=o?pl:gl,O=[g.length>0?`${g.length} undoable`:null,u>0?`${u} permanent`:null].filter(Boolean).join(" \xB7 ");return mt(l,{style:fe.wrap,children:[mt(b,{testID:"buoy-ask-buoy-changes-bar",accessibilityRole:"button",accessibilityState:{expanded:o},onPress:r,style:fe.bar,children:[ct(l,{style:fe.dot}),ct(i,{style:fe.summary,numberOfLines:1,children:"Changed this app"}),ct(i,{style:fe.counts,numberOfLines:1,children:O}),ct(m,{size:12,color:ie.color.textSecondary})]}),o&&mt(l,{style:fe.panel,children:[mt(ke,{style:fe.panelScroll,testID:"buoy-ask-buoy-changes-scroll",keyboardShouldPersistTaps:"handled",children:[a.map($=>{let L=!ei($.effect);return mt(l,{style:fe.row,children:[ct(i,{style:fe.rowLabel,children:$.effect.label}),ct(i,{style:[fe.rowTag,L&&fe.rowTagMuted],children:L?"Permanent":"Undoable"})]},$.id)}),f>0&&ct(l,{style:fe.row,children:mt(i,{style:[fe.rowLabel,fe.rowLabelMuted],children:["Also did ",f," one-shot action",f===1?"":"s"," (navigation, taps) \u2014 nothing to undo."]})})]}),mt(l,{style:fe.footer,children:[g.length>0&&ct(b,{testID:"buoy-ask-buoy-undo-all",accessibilityRole:"button",onPress:t,style:({pressed:$})=>[fe.undo,$&&fe.pressed],children:mt(i,{style:fe.undoText,children:["Undo ",g.length," change",g.length===1?"":"s"]})}),u>0&&ct(i,{style:fe.footnote,children:"Permanent changes can't be undone from here."})]})]})]})}var fe=y.create({wrap:{borderBottomWidth:y.hairlineWidth,borderBottomColor:ie.color.border,backgroundColor:ie.color.warningSoft},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:ie.gutter,paddingVertical:10},dot:{width:7,height:7,borderRadius:4,backgroundColor:ie.color.warning},summary:{color:ie.color.text,fontSize:ie.font.caption,fontWeight:"600"},counts:{flex:1,color:ie.color.textSecondary,fontSize:ie.font.caption},panel:{paddingHorizontal:ie.gutter,paddingBottom:12,gap:10},panelScroll:{maxHeight:180},row:{flexDirection:"row",alignItems:"flex-start",gap:10,paddingVertical:8,borderTopWidth:y.hairlineWidth,borderTopColor:ie.color.separator},rowLabel:{flex:1,color:ie.color.text,fontSize:ie.font.caption,lineHeight:18},rowTag:{color:ie.color.accent,fontSize:ie.font.micro,fontWeight:"600",letterSpacing:.6,textTransform:"uppercase",paddingTop:2},rowTagMuted:{color:ie.color.textTertiary},rowLabelMuted:{color:ie.color.textTertiary},footer:{flexDirection:"row",alignItems:"center",gap:12,flexWrap:"wrap"},undo:{paddingHorizontal:14,paddingVertical:8,borderRadius:ie.radius.row,backgroundColor:ie.color.button},undoText:{color:ie.color.accent,fontSize:ie.font.caption,fontWeight:"600"},footnote:{flex:1,color:ie.color.textTertiary,fontSize:ie.font.micro},pressed:{opacity:.7}});function oi(e){let t={};for(let o of e){let r=o.effect;if(r.kind==="network-override")t[r.ruleId]=o.undoneAt?{deleted:!0}:{enabled:!0};else if(r.kind==="inverse-call"&&r.toolId==="network"&&r.action==="setOverrideRuleEnabled"&&typeof r.params.id=="string"){let n=r.params.enabled===!0;if(t[r.params.id]?.deleted)continue;t[r.params.id]={enabled:o.undoneAt?n:!n}}}return t}import{useCallback as fl,useEffect as ri,useRef as yl,useState as bl}from"react";import{night as Be}from"@buoy-gg/shared-ui/web";import{jsx as xt,jsxs as xl}from"react/jsx-runtime";var ni=40,hl=120,ii=ht.OS==="ios"?10:6,ml=16;function Wo({onSend:e,onStop:t,busy:o,draft:r,onDraftTaken:n,disabled:s,placeholder:a,focusKey:g,canFocus:u=!0}){let[f,m]=bl(""),O=yl(null);ri(()=>{!g||!u||s||O.current?.focus()},[g,u,s]),ri(()=>{r&&(m(re=>re?`${re} ${r}`:r),n?.())},[r,n]);let $=fl(()=>{let re=f.trim();re&&(m(""),e(re))},[f,e]),L=f.trim().length>0&&!o&&!s,oe=f.trim().length>0&&o&&!s;return xl(l,{style:we.wrap,children:[xt(l,{style:[we.field,s&&we.fieldDisabled],children:xt(ze,{ref:O,testID:"buoy-ask-buoy-input",style:[we.input,f.length===0&&we.inputEmpty],value:f,onChangeText:m,placeholder:a??(s?"Ask Buoy isn't set up yet":"Ask, or tell it what to change\u2026"),placeholderTextColor:Be.color.placeholder,multiline:!0,editable:!s,keyboardType:"ascii-capable",autoCorrect:!0,autoCapitalize:"sentences",blurOnSubmit:!1,onSubmitEditing:$,returnKeyType:"send",maxLength:4e3})}),oe&&xt(b,{testID:"buoy-ask-buoy-queue",accessibilityRole:"button",accessibilityLabel:"Queue message",onPress:$,style:({pressed:re})=>[we.button,we.queue,re&&we.pressed],children:xt(i,{style:[we.sendGlyph,{color:Be.color.accent}],children:"\u2191"})}),o?xt(b,{testID:"buoy-ask-buoy-stop",accessibilityRole:"button",accessibilityLabel:"Stop",onPress:t,style:({pressed:re})=>[we.button,we.stop,re&&we.pressed],children:xt(l,{style:we.stopGlyph})}):xt(b,{testID:"buoy-ask-buoy-send",accessibilityRole:"button",accessibilityLabel:"Send",disabled:!L,onPress:$,style:({pressed:re})=>[we.button,L?we.sendOn:we.sendOff,re&&L&&we.pressed],children:xt(i,{style:[we.sendGlyph,{color:L?Be.color.onAccent:Be.color.textTertiary}],children:"\u2191"})})]})}var we=y.create({wrap:{flexDirection:"row",alignItems:"flex-end",gap:8,paddingHorizontal:Be.gutter,paddingTop:10,paddingBottom:6,borderTopWidth:y.hairlineWidth,borderTopColor:Be.color.border,backgroundColor:Be.color.bg},field:{flex:1,minHeight:ni,justifyContent:"center",borderRadius:20,borderWidth:y.hairlineWidth,borderColor:Be.color.border,backgroundColor:Be.color.surfaceElevated},fieldDisabled:{opacity:.6},input:{maxHeight:hl,paddingHorizontal:ml,paddingTop:ii,paddingBottom:ii,color:Be.color.text,fontSize:Be.font.row},inputEmpty:{height:ni},button:{width:40,height:40,borderRadius:20,alignItems:"center",justifyContent:"center"},sendGlyph:{fontSize:20,fontWeight:"700",lineHeight:22},sendOn:{backgroundColor:Be.color.accent},sendOff:{backgroundColor:Be.color.fill},stop:{backgroundColor:Be.color.fillTertiary},queue:{backgroundColor:"transparent",borderWidth:y.hairlineWidth,borderColor:Be.color.accentBorderStrong},stopGlyph:{width:12,height:12,borderRadius:2,backgroundColor:Be.color.text},pressed:{opacity:.7}});import{useEffect as wl,useRef as si}from"react";import{jsx as kl}from"react/jsx-runtime";function ai({children:e}){let t=si(null),o=si(new ee.Value(0)).current;return wl(()=>{if(ht.OS!=="ios")return;let r=(g,u)=>{ee.timing(o,{toValue:g,duration:u.duration||250,easing:bt.bezier(.17,.59,.4,.77),useNativeDriver:!1}).start()},n=g=>{let u=t.current;u&&u.measureInWindow((f,m,O,$)=>{let L=m+$-g.endCoordinates.screenY;r(Math.max(0,L),g)})},s=g=>r(0,g),a=[Zt.addListener("keyboardWillChangeFrame",n),Zt.addListener("keyboardWillHide",s)];return()=>a.forEach(g=>g.remove())},[o]),kl(ee.View,{ref:t,style:[Tl.flex,{paddingBottom:o}],children:e})}var Tl=y.create({flex:{flex:1}});import{useEffect as di,useState as ui}from"react";import{Check as Bl,Copy as Al,FileText as Il,ModalHeader as lo,night as et,Otto as Rl,Plus as Pl,SettingsSolid as Dl}from"@buoy-gg/shared-ui/web";import{toolTitle as Sl}from"@buoy-gg/agent-core/web";var Cl=e=>e.effect==="read"&&e.status==="ok";function li(e){let t=[],o=[],r=()=>{if(o.length!==0){if(o.length===1)t.push({kind:"call",call:o[0]});else{let n=[...new Set(o.map(s=>Sl(s.toolId)))];t.push({kind:"reads",id:o.map(s=>s.id).join("+"),calls:o,label:`Looked at ${vl(n)}`,count:o.length})}o=[]}};for(let n of e){if(Cl(n)){o.push(n);continue}r(),t.push({kind:"call",call:n})}return r(),t}function vl(e){return e.length<=1?e[0]??"":e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function ci(e){let t=[];e.startedAt!==void 0&&e.endedAt!==void 0&&e.endedAt>=e.startedAt&&t.push(Mo(e.endedAt-e.startedAt));let o=e.toolCalls.length;if(o>0){t.push(`${o} action${o===1?"":"s"}`);let r=u=>e.toolCalls.filter(f=>f.status===u).length,n=r("failed"),s=r("refused"),a=r("declined"),g=r("stopped");n&&t.push(`${n} failed`),s&&t.push(`${s} refused`),a&&t.push(`${a} declined`),g&&t.push(`${g} not run`)}return t.length?t.join(" \xB7 "):null}function Mo(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let o=Math.floor(t/60),r=t%60;return o<60?`${o}m ${String(r).padStart(2,"0")}s`:`${Math.floor(o/60)}h ${String(o%60).padStart(2,"0")}m`}import{jsx as Me,jsxs as pi}from"react/jsx-runtime";var zl=200,Vl=()=>"";function No({configured:e,busy:t,failed:o=!1,activeLabel:r,awaitingApproval:n=!1,startedAt:s=null,stopping:a=!1,readOnly:g=!1,toolCount:u,hasMessages:f,onBack:m,onReset:O,getTranscript:$,onOpenSettings:L,onTicket:oe}){let{copied:re,copy:Te}=Lt($??Vl),[rt,$e]=ui(!1);di(()=>{t?r&&$e(!0):$e(!1)},[t,r]);let nt=t&&!n&&s!==null,[it,kt]=ui(()=>Date.now());di(()=>{if(!nt)return;kt(Date.now());let ft=setInterval(()=>kt(Date.now()),1e3);return()=>clearInterval(ft)},[nt]);let St=nt&&s!==null?Mo(it-s):null,Dt=e?o?"error":t?r||rt?"robot":"thinking":"idle":"confused",Je=a?"Stopping":r??"Thinking",gt=e?n?"Waiting for you":t?St?`${Je} \xB7 ${St}`:`${Je}\u2026`:g?`Read only${u>0?` \xB7 ${u} tool${u===1?"":"s"}`:""}`:u>0?`Ready \xB7 ${u} tool${u===1?"":"s"} available`:"Ready":"Not set up in this app";return pi(lo,{children:[m?Me(lo.Navigation,{onBack:m}):null,Me(l,{style:wt.otto,testID:"buoy-ask-buoy-otto",children:Me(Rl,{state:Dt,pixelSize:2,tickMs:zl,water:!1})}),Me(lo.Content,{title:"Ask Buoy",subtitle:gt,testID:"buoy-ask-buoy-title"}),pi(lo.Actions,{children:[oe?Me(Vt,{testID:"buoy-ask-buoy-ticket",accessibilityRole:"button",accessibilityLabel:"Summarize for a ticket",disabled:!f||t,onPress:oe,style:[wt.actionBtn,(!f||t)&&wt.actionBtnDisabled],children:Me(Il,{size:14,color:f&&!t?et.color.textSecondary:et.color.textTertiary})}):null,$?Me(Vt,{testID:"buoy-ask-buoy-copy-chat",accessibilityRole:"button",accessibilityLabel:re?"Conversation copied":"Copy conversation",disabled:!f,onPress:Te,style:[wt.actionBtn,!f&&wt.actionBtnDisabled],children:re?Me(Bl,{size:14,color:et.color.accent}):Me(Al,{size:14,color:f?et.color.textSecondary:et.color.textTertiary})}):null,L?Me(Vt,{testID:"buoy-ask-buoy-settings",accessibilityRole:"button",accessibilityLabel:"Settings",onPress:L,style:wt.actionBtn,children:Me(Dl,{size:14,color:et.color.textSecondary})}):null,Me(Vt,{testID:"buoy-ask-buoy-reset",accessibilityRole:"button",accessibilityLabel:"New conversation",disabled:!f,onPress:O,style:[wt.actionBtn,!f&&wt.actionBtnDisabled],children:Me(Pl,{size:14,color:f?et.color.textSecondary:et.color.textTertiary})})]})]})}var wt=y.create({otto:{marginRight:8,justifyContent:"center"},actionBtn:{width:32,height:32,borderRadius:8,backgroundColor:et.color.buttonSurface,borderWidth:1,borderColor:et.color.border,alignItems:"center",justifyContent:"center"},actionBtnDisabled:{opacity:.55}});import{AlertTriangle as lc,night as pe,ToggleRow as tr}from"@buoy-gg/shared-ui/web";import{useSyncExternalStore as $l}from"react";import{definePersistedSetting as Ll,devToolsStorageKeys as Hl}from"@buoy-gg/shared-ui/web";var Uo={showThinking:!1,bypassApprovals:!1,readOnly:!1},qo=Ll(`${Hl.base}_ask_buoy_settings`,Uo,{sanitize:e=>({showThinking:e.showThinking===!0,bypassApprovals:e.bypassApprovals===!0,readOnly:e.readOnly===!0})}),It=Uo,Fo=!1,_o=new Set;function gi(){for(let e of _o)try{e()}catch{}}var dt={get:()=>It,subscribe(e){return _o.add(e),Fo||(Fo=!0,qo.load().then(t=>{It=t,gi()})),()=>_o.delete(e)},set(e,t){It[e]!==t&&(It={...It,[e]:t},gi(),qo.save(It))},reset(){It=Uo,Fo=!1,qo.clear()}};function tt(){return $l(dt.subscribe,dt.get,dt.get)}import{idFactory as bi}from"@buoy-gg/agent-core/web";var co=bi("m"),fi=400;function Ol(e){if(!(!e||Object.keys(e).length===0))try{let t=JSON.stringify(e);return t.length>fi?`${t.slice(0,fi)}\u2026`:t}catch{return}}var El=bi("q"),W={messages:[],busy:!1,stopping:!1,pending:null,trusted:[],notice:null,configured:!1,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0},meta:{}},jo=new Set,yi=null,Ko=null;function Z(e){W={...W,...e};for(let t of jo)try{t()}catch{}}var h={getState:()=>W,subscribe(e){return jo.add(e),()=>jo.delete(e)},setLedger(e){yi=e},getLedger(){return yi},holdSession(e,t){Ko={session:e,signature:t}},getHeldSession(){return Ko},setNotice(e){Z({notice:e})},setConfigured(e){e!==W.configured&&Z({configured:e})},setMeta(e){Object.keys(e).every(o=>W.meta[o]===e[o])||Z({meta:{...W.meta,...e}})},addUser(e){Z({messages:[...W.messages,{id:co(),role:"user",text:e,toolCalls:[],blocks:[]}],busy:!0})},beginTurn(){Z({busy:!0})},enqueue(e){let t={id:El(),text:e};return Z({queued:[...W.queued,t]}),t},removeQueued(e){W.queued.some(t=>t.id===e)&&Z({queued:W.queued.filter(t=>t.id!==e)})},shiftQueued(){let[e,...t]=W.queued;if(e)return Z({queued:t}),e},takeQueuedToDraft(e){let t=W.queued.find(o=>o.id===e);t&&Z({queued:W.queued.filter(o=>o.id!==e),draft:t.text})},requestStop(){!W.busy||W.stopping||Z({stopping:!0})},clearDraft(){W.draft!==null&&Z({draft:null})},removeMessage(e){Z({messages:W.messages.filter(t=>t.id!==e)})},recordAnswer(e){Z({answers:{...W.answers,[e.blockId]:e},awaitingBlockId:W.awaitingBlockId===e.blockId?null:W.awaitingBlockId})},setActionState(e,t){let o={...W.actionState};t===null?delete o[e]:o[e]=t,Z({actionState:o})},startAssistant(){let e=co();return Z({messages:[...W.messages,{id:e,role:"assistant",text:"",toolCalls:[],blocks:[],streaming:!0,startedAt:Date.now()}]}),e},applyEvent(e,t){if(t.type==="history-trimmed"){let r=W.messages.findIndex(a=>a.id===e),n={id:co(),role:"assistant",system:!0,text:`Older messages were trimmed from the agent's memory (${t.droppedRounds} exchange${t.droppedRounds===1?"":"s"}).`+(t.droppedPinned?` ${t.droppedPinned===1?"One of them made a change that is":`${t.droppedPinned} of them made changes that are`} still applied \u2014 the changes bar still lists ${t.droppedPinned===1?"it":"them"}, but the agent no longer remembers making ${t.droppedPinned===1?"it":"them"}.`:" It may not recall setup from earlier in this chat \u2014 the changes bar still lists what is applied."),toolCalls:[],blocks:[],endedAt:Date.now()},s=[...W.messages];s.splice(r<0?s.length:r,0,n),Z({messages:s});return}let o=W.messages.map(r=>{if(r.id!==e)return r;switch(t.type){case"retrying":{let n=Math.max(1,Math.round(t.inMs/1e3));return{...r,waiting:t.reason==="throttled"?`Endpoint busy \u2014 retrying in ${n}s (${t.attempt} of ${t.maxAttempts})`:"Request too large \u2014 trimming older messages and retrying"}}case"text":return{...r,waiting:void 0,text:(r.breakBeforeNextText||t.breakBefore)&&r.text?`${r.text.trimEnd()}
10
+
11
+ ${t.delta}`:r.text+t.delta,breakBeforeNextText:!1};case"reasoning":return{...r,breakBeforeNextText:!0,reasoning:[...r.reasoning??[],{text:t.text,afterCalls:r.toolCalls.length}]};case"tool-start":return{...r,waiting:void 0,toolCalls:[...r.toolCalls,{id:t.id,toolId:t.toolId,action:t.action,label:t.label,description:t.description,status:"running",params:Ol(t.params),effect:t.effect,startedAt:Date.now()}]};case"tool-end":return{...r,breakBeforeNextText:!0,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,status:!t.ok&&t.summary==="refused"?"refused":!t.ok&&t.summary==="declined"?"declined":!t.ok&&t.summary==="stopped"?"stopped":t.ok?"ok":"failed",summary:t.summary,durationMs:t.durationMs,result:t.result}:n)};case"tool-verified":return{...r,toolCalls:r.toolCalls.map(n=>n.id===t.id?{...n,verification:t.verification}:n)};case"block":return{...r,breakBeforeNextText:!0,blocks:[...r.blocks,{block:t.block,forToolCallId:t.forToolCallId}]};case"usage":return{...r,usage:{input:(r.usage?.input??0)+t.input,output:(r.usage?.output??0)+t.output,requests:(r.usage?.requests??0)+1}};case"error":return{...r,waiting:void 0,error:t.message};default:return r}});Z({messages:o,...t.type==="awaiting-user"?{awaitingBlockId:t.blockId}:{},...t.type==="usage"?{usage:{input:W.usage.input+t.input,output:W.usage.output+t.output,requests:W.usage.requests+1}}:{}})},markStopped(e){Z({messages:W.messages.map(t=>t.id===e?{...t,stopped:!0}:t)})},finishAssistant(e){Z({messages:W.messages.map(t=>t.id===e?{...t,streaming:!1,endedAt:Date.now()}:t),busy:!1,stopping:!1})},askApproval(e){return new Promise(t=>{Z({pending:{...e,resolve:t}})})},answerApproval(e){let t=W.pending,o=typeof e=="boolean"?e:e.approved,r=typeof e!="boolean"&&e.trust===!0&&o,n=t?`${t.toolId}.${t.action}`:"";Z({pending:null,...r&&t&&!W.trusted.some(s=>s.key===n)?{trusted:[...W.trusted,{key:n,label:t.label}]}:{}}),t?.resolve(e)},untrust(e){Ko?.session.untrust(e),Z({trusted:W.trusted.filter(t=>t.key!==e)})},restorePending(e){return W.pending||W.busy?!1:(Z({pending:{...e,restored:!0,resolve:()=>{}}}),!0)},addNote(e){Z({messages:[...W.messages,{id:co(),role:"assistant",text:e,toolCalls:[],blocks:[],endedAt:Date.now()}]})},hydrate(e){return W.messages.length>0||W.busy?!1:(Z({messages:e.messages.map(t=>({...t,restored:!0})),answers:e.answers,usage:e.usage,queued:e.queued??[]}),!0)},reset(){W.pending?.resolve(!1),Z({messages:[],busy:!1,stopping:!1,pending:null,trusted:[],notice:null,answers:{},awaitingBlockId:null,actionState:{},queued:[],draft:null,usage:{input:0,output:0,requests:0}})}};function Qo(e){return e.pending?"awaitingApproval":e.busy?e.stopping?"stopping":"running":e.awaitingBlockId?"awaitingAnswer":"idle"}function uo(e){let t=Qo(e);if(t==="running"||t==="stopping")return null;if(t==="awaitingApproval")return"Paused \u2014 answer the approval above first.";if(t==="awaitingAnswer")return"Paused \u2014 answer the question above first.";let o=e.messages[e.messages.length-1];return o?.role==="assistant"&&o.error?"Paused \u2014 the last turn failed.":o?.role==="assistant"&&o.stopped?"Paused \u2014 you stopped the last turn.":null}import{getUseIsPro as Jl,hasAccountAccess as _t,subscribeAccountAccess as Yl}from"@buoy-gg/shared-ui/web";import{useCallback as Le,useEffect as Tt,useMemo as Xl,useRef as Pt,useState as Zl,useSyncExternalStore as ec}from"react";import{dispatchToolAction as ki,listSnapshotToolIds as tc,listToolActions as oc,readToolSnapshot as rc,waitForToolRegistry as Si}from"@buoy-gg/shared-ui/web";import{answerToText as Ci,CATALOG as Zo,createAskBuoySession as nc,readTargetDigest as ic,runGatedAction as vi,SNAPSHOT_ACTION as Bi}from"@buoy-gg/agent-core/web";import{persistentStorage as Yo,devToolsStorageKeys as Ml}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as Go}from"@buoy-gg/shared-ui/web";var Wl=[{re:/\bBearer\s+[A-Za-z0-9._~+/-]{12,}=*/gi,label:"[bearer token removed]"},{re:/\beyJ[A-Za-z0-9._-]{20,}/g,label:"[jwt removed]"},{re:/\bsk-[A-Za-z0-9_-]{16,}/g,label:"[api key removed]"},{re:/\bBUOY-[A-Z0-9-]{8,}/g,label:"[license key removed]"},{re:/("|')?(authorization|x-api-key|api[_-]?key|password|secret|access_token|refresh_token)\1?\s*[:=]\s*("|')?[^\s"',}]{6,}/gi,label:"[credential removed]"}];function Rt(e){if(!e)return e;let t=e;for(let{re:o,label:r}of Wl)t=t.replace(o,r);return t}var Xo=`${Ml.base}_ask_buoy_transcript`,Jo=1,hi=60,Nl=256e3,ql="[not kept across a restart \u2014 read it again if you need it]";function ut(e){return e&&Rt(e)}function Fl(e){let t=e.streaming===!0;return{...e,text:ut(e.text),streaming:!1,reasoning:e.reasoning?.map(o=>({...o,text:ut(o.text)})),toolCalls:e.toolCalls.map(o=>{let r=o.params?ut(o.params):void 0,{result:n,...s}=o;return o.status==="running"?{...s,params:r,status:"failed",summary:"Interrupted"}:{...s,params:r}}),error:e.error??(t&&!e.text?"This answer was interrupted \u2014 the app restarted mid-turn.":void 0)}}function _l(e){return e.map(t=>t.role==="tool-results"?{...t,results:t.results.map(o=>({...o,content:ql}))}:t.role==="assistant"?{...t,text:ut(t.text)}:{...t,text:ut(t.text)})}function Ul(e){let t={...e,messages:e.messages.slice(-hi),history:e.history.slice(-hi*2)},o=JSON.stringify(t);for(;o.length>Nl&&t.messages.length>1;)t={...t,messages:t.messages.slice(1),history:t.history.slice(Math.min(2,t.history.length))},o=JSON.stringify(t);return t}function Kl(e){if(!e)return null;let t=e.params;if(!t)return null;let o;try{o=JSON.stringify(t)}catch{return null}return Rt(o)!==o?null:{id:e.id,toolId:e.toolId,action:e.action,label:ut(e.label),description:e.description?ut(e.description):void 0,reason:ut(e.reason),params:t,targetDigest:e.targetDigest}}function jl(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.id=="string"&&typeof t.toolId=="string"&&typeof t.action=="string"&&typeof t.label=="string"&&typeof t.reason=="string"&&typeof t.params=="object"&&t.params!==null}function Ql(e){if(!e?.length)return;let t=e.filter(o=>{try{let r=JSON.stringify(o);return Rt(r)===r}catch{return!1}});return t.length?t:void 0}function mi(e){return Ul({v:Jo,savedAt:Date.now(),messages:e.messages.map(Fl),history:_l(e.history),answers:e.answers,usage:e.usage,pending:Kl(e.pending),ledger:Ql(e.ledger),queued:e.queued?.length?e.queued.map(t=>({id:t.id,text:ut(t.text)})):void 0})}function Gl(e){if(!e)return null;try{let t=JSON.parse(e);return t?.v!==Jo||!Array.isArray(t.messages)||t.messages.length===0?null:{v:Jo,savedAt:typeof t.savedAt=="number"?t.savedAt:0,messages:t.messages,history:Array.isArray(t.history)?t.history:[],answers:t.answers??{},usage:t.usage??{input:0,output:0,requests:0},pending:jl(t.pending)?t.pending:null,ledger:Array.isArray(t.ledger)?t.ledger.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"):void 0,queued:Array.isArray(t.queued)?t.queued.filter(o=>typeof o=="object"&&o!==null&&typeof o.id=="string"&&typeof o.text=="string"):void 0}}catch{return null}}async function xi(){try{return Gl(await Yo.getItem(Xo))}catch{return null}}async function wi(e){try{await Yo.setItem(Xo,JSON.stringify(e))}catch{}}async function Ti(){try{await Yo.removeItem(Xo)}catch{}}function po(){h.getHeldSession()?.session.reset(),h.reset(),Ti()}async function go(e){if(h.getState().busy)return{cleared:!1,reverted:0,failed:[{label:"A turn is running",error:"Stop it first."}]};let t=h.getLedger();if(e.undoFirst&&t){let o=await t.revertAll(e.dispatch);return o.failed.length>0?{cleared:!1,reverted:o.reverted,failed:o.failed}:(po(),{cleared:!0,reverted:o.reverted,failed:[]})}return po(),{cleared:!0,reverted:0,failed:[]}}var Ut=typeof R<"u"&&!R;function sc(e){for(let t of h.getState().messages)if(t.restored)for(let o of t.blocks){let r=o.block;if(r?.id!==e)continue;let n=r.question??r.label??r.title;return typeof n=="string"&&n.trim()?n.trim():void 0}}function Ai(){try{let e=oc();for(let t of tc())e[t]||(e[t]=[]),e[t].includes(Bi)||(e[t]=[Bi,...e[t]]);return e}catch{return{}}}var ac=600;function fo(){return ec(h.subscribe,h.getState,h.getState)}function er(e){let t=fo(),o=Jl()(),r=Pt(o);r.current=o;let n=Le((...S)=>!_t()||!r.current?Promise.reject(new Error("Ask Buoy requires Pro access.")):ki(...S),[]),s=Pt(null),a=Pt(!1),g=Pt(null),u=Pt(e);u.current=e;let f=!!e?.endpoint&&!!e?.model,m=e?.persistTranscript!==!1,{bypassApprovals:O,readOnly:$}=tt(),L=Pt(O);L.current=O;let oe=Pt($);oe.current=$;let re=Le(()=>oe.current?{...e?.policy??{},readOnly:!0}:e?.policy??{},[e]),[Te,rt]=Zl(0);Tt(()=>{let S=!1;return Si().then(()=>{S||rt(F=>F+1)}),()=>{S=!0}},[]);let $e=Xl(()=>Ai(),[Te]),nt=Object.keys($e).sort().join(",");Tt(()=>{if(h.setConfigured(f),h.setMeta({model:e?.model,protocol:e?.protocol??(e?"anthropic":void 0),appName:e?.appName,platform:ht.OS,build:Ut?"release":"development"}),!f||!e){s.current=null,h.setNotice("Ask Buoy isn't set up in this app yet. A developer needs to point it at your team's AI endpoint.");return}let S=e.protocol??"anthropic";Ut&&e.apiKey?h.setNotice("This build carries a plaintext apiKey \u2014 that's dev-only and it ships to every install. Use the headers callback with your own gateway for distributed builds."):S==="anthropic"&&/^https?:\/\/api\.openai\.com\//i.test(e.endpoint)?h.setNotice('This endpoint is api.openai.com but the protocol is "anthropic". Set protocol: "openai" in the askBuoy config.'):S==="openai"&&/^https?:\/\/api\.anthropic\.com\//i.test(e.endpoint)?h.setNotice('This endpoint is api.anthropic.com but the protocol is "openai". Remove protocol or set it to "anthropic".'):h.setNotice(null);let F=[e.endpoint,e.protocol??"anthropic",e.model].join("|"),Q=h.getHeldSession();if(Q&&Q.signature===F){s.current=Q.session,Q.session.setAvailableActions($e),Q.session.setApprovalBypass(L.current),Q.session.setReadOnly(oe.current),h.setLedger(Q.session.ledger);return}let se=nc({endpoint:e.endpoint,protocol:e.protocol??"anthropic",model:e.model,headers:e.headers,apiKey:e.apiKey,maxTokens:e.maxTokens,anthropicVersion:e.anthropicVersion,requestOverrides:e.requestOverrides,catalog:e.tools?.length?[...Zo,...e.tools]:void 0,dispatch:n,readSnapshot:rc,availableActions:$e,policy:e.policy,context:e.context,isRelease:Ut,appName:e.appName,platform:ht.OS,requestApproval:ne=>h.askApproval(ne)});s.current=se,se.setApprovalBypass(L.current),se.setReadOnly(oe.current),h.holdSession(se,F),h.setLedger(se.ledger);let ve=!1;return Si().then(ne=>{ne&&!ve&&se.prime()}),m&&!a.current&&(a.current=!0,xi().then(ne=>{!ne||!h.hydrate({messages:ne.messages,answers:ne.answers,usage:ne.usage,queued:ne.queued})||(s.current?.restore(ne.history),ne.ledger?.length&&s.current?.ledger.restore(ne.ledger),ne.pending&&h.restorePending(ne.pending))})),()=>{ve=!0}},[f,e,$e,nt,m]),Tt(()=>{s.current?.setApprovalBypass(O)},[O]),Tt(()=>{s.current?.setReadOnly($)},[$]);let it=t.messages,kt=t.answers,St=t.usage,Dt=t.busy,Je=t.pending,gt=t.queued;Tt(()=>{if(!m||it.length===0)return;let S=()=>{wi(mi({messages:it,history:s.current?.messages??[],answers:kt,usage:St,pending:Je,ledger:h.getLedger()?.list(),queued:gt}))};if(!Dt){S();return}let F=setTimeout(S,ac);return()=>clearTimeout(F)},[m,Dt,it,kt,St,Je,gt]);let ft=Le(S=>{if(!_t()||!r.current)return;let F=s.current;if(!F)return;h.beginTurn();let Q=h.startAssistant(),se=new AbortController;g.current=se,F.setAvailableActions(Ai());let ve=u.current?.onEvent;(async()=>{try{for await(let ne of F.send(S,se.signal))if(h.applyEvent(Q,ne),ve)try{ve(ne)}catch{}}catch(ne){se.signal.aborted||h.applyEvent(Q,{type:"error",message:ne instanceof Error?ne.message:"Something went wrong talking to your AI endpoint."})}finally{se.signal.aborted&&h.markStopped(Q),h.finishAssistant(Q),g.current=null}})()},[]),st=Le(S=>{if(!_t()||!r.current)return;let F=S.trim();if(!s.current||!F)return;if(h.getState().busy){h.enqueue(F);return}let Q=h.getState().awaitingBlockId;Q&&h.recordAnswer({blockId:Q,kind:"skipped"}),h.addUser(F),ft(F)},[ft]),Ct=Le(()=>{let{messages:S,busy:F}=h.getState();if(F||!s.current)return;let Q=[...S].reverse().find(se=>se.role==="user");Q&&ft(Q.text)},[ft]),at=Le(()=>{h.requestStop(),h.getState().pending&&h.answerApproval(!1),g.current?.abort(),g.current=null},[]);Tt(()=>{let S=Yl(()=>{_t()||at()});return()=>{S(),at()}},[at]),Tt(()=>{o||at()},[o,at]),Tt(()=>{if(t.queued.length===0||Qo(t)!=="idle"||uo(t)!==null)return;let S=h.shiftQueued();S&&st(S.text)},[t,st]);let De=Le(S=>h.takeQueuedToDraft(S),[]),zt=Le(S=>h.removeQueued(S),[]),Jt=Le(()=>{g.current?.abort(),g.current=null,po()},[]),To=Le(()=>go({dispatch:ki,undoFirst:!0}),[]),Yt=Le(async S=>{let F=h.getLedger();if(!F){h.setNotice(`${S.label} couldn't run \u2014 no active Ask Buoy session.`);return}let Q=e?.tools?.length?[...Zo,...e.tools]:void 0;if(S.targetDigest){let ve=await ic({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:n,catalog:Q});if(ve!==void 0&&ve!==S.targetDigest){h.addNote(`\u201C${S.label}\u201D wasn't applied \u2014 what it would change has moved on since the app restarted. Nothing was written. Ask again if you still want it.`);return}}let se=await vi({toolId:S.toolId,action:S.action,params:S.params??{},dispatch:n,ledger:F,policy:re(),isRelease:Ut,catalog:Q});se.ok?h.addNote(`Applied \u201C${S.label}\u201D, which was still waiting when the app restarted. Whatever else that answer was going to do is gone \u2014 ask again if there was more to it.`):h.setNotice(`${S.label} failed \u2014 ${se.error}`)},[e,re]),ko=Le(S=>{let F=h.getState().pending,Q=typeof S=="boolean"?S:S.approved;if(h.answerApproval(S),!!F?.restored){if(!Q){h.addNote(`Skipped \u201C${F.label}\u201D. Nothing was changed.`);return}Yt(F)}},[Yt]),So=Le(S=>{h.recordAnswer(S);let F=sc(S.blockId);st(F?`${F} \u2014 ${Ci(S)}`:Ci(S))},[st]),Co=Le(async(S,F)=>{if(!_t()||!r.current){h.setNotice("Ask Buoy requires Pro access.");return}if(S.send){st(S.send);return}if(!S.dispatch)return;let Q=`${F}:${S.label}`,se=h.getLedger();if(!se){h.setNotice(`${S.label} failed \u2014 no active Ask Buoy session.`);return}h.setActionState(Q,"running");let ve=await vi({toolId:S.dispatch.toolId,action:S.dispatch.action,params:S.dispatch.params??{},dispatch:n,ledger:se,policy:re(),isRelease:Ut,catalog:e?.tools?.length?[...Zo,...e.tools]:void 0});ve.ok?h.setActionState(Q,"done"):(h.setActionState(Q,"failed"),h.setNotice(`${S.label} failed \u2014 ${ve.error}`))},[st,e,re]);return{state:t,send:st,stop:at,reset:Jt,undoThenReset:To,approve:ko,retry:Ct,answer:So,runAction:Co,editQueued:De,removeQueued:zt,configured:f,toolCount:Object.keys($e).length,availableToolIds:Object.keys($e)}}import{jsx as He,jsxs as yo}from"react/jsx-runtime";function or(){let e=tt(),t=fo().trusted;return yo(ke,{style:Ie.scroll,contentContainerStyle:Ie.content,testID:"buoy-ask-buoy-settings",children:[He(i,{style:Ie.section,children:"CHAT"}),He(tr,{testID:"buoy-ask-buoy-setting-thinking",label:"Show agent thinking",description:"Adds a collapsed strip under each answer: the model's reasoning, and every step it ran with its parameters, result, duration and token cost. Copy includes the steps and reasoning while this is on, so you can read the run outside the app.",value:e.showThinking,onValueChange:o=>dt.set("showThinking",o)}),He(i,{style:Ie.note,children:"Not every model reports reasoning. Claude thinks by default; most OpenAI models return none, and the strip then shows the steps alone."}),He(i,{style:Ie.section,children:"PERMISSIONS"}),He(tr,{testID:"buoy-ask-buoy-setting-readonly",label:"Read only",description:"Inspect the app, change nothing. Every write and simulation is refused until this is off. Undo still works \u2014 putting things back is the safe direction.",value:e.readOnly,onValueChange:o=>dt.set("readOnly",o)}),e.readOnly?He(i,{style:Ie.note,testID:"buoy-ask-buoy-readonly-note",children:"On across reloads until you turn it off here. The header says \u201CRead only\u201D while it is on. It adds to whatever this app already restricts \u2014 it never loosens anything."}):null,He(tr,{testID:"buoy-ask-buoy-setting-bypass",tone:"warning",emphasizeLabel:e.bypassApprovals,disabled:e.readOnly,label:"Skip approval prompts",description:e.readOnly?"Unavailable while Read only is on \u2014 nothing can be approved.":"Runs every action the moment the agent calls it, with no Allow card \u2014 including the destructive ones that wipe or reset data.",value:e.bypassApprovals,onValueChange:o=>dt.set("bypassApprovals",o)}),e.bypassApprovals&&!e.readOnly?yo(l,{style:Ie.warning,testID:"buoy-ask-buoy-bypass-warning",children:[He(lc,{size:14,color:pe.color.warning}),He(i,{style:Ie.warningText,children:"Nothing will ask before a change lands. A wipe or a reset runs on the model's word alone, and Undo only reverses the changes that can be reversed \u2014 the bar tells you which. This stays on across reloads and app restarts until you turn it off here, so leave it off on any device holding data you care about. It does not widen what the agent may reach: read-only mode, this app's deny list and the release-build refusals still apply."})]}):He(i,{style:Ie.note,children:"On by default for destructive actions only \u2014 reads and ordinary writes already run without asking, and the changes bar records them."}),t.length>0?yo(l,{style:Ie.trustedBox,testID:"buoy-ask-buoy-trusted",children:[He(i,{style:Ie.section,children:"ALLOWED WITHOUT ASKING \u2014 THIS CHAT"}),t.map(o=>yo(l,{style:Ie.trustedRow,children:[He(i,{style:Ie.trustedLabel,numberOfLines:2,children:o.label}),He(b,{testID:`buoy-ask-buoy-untrust-${o.key}`,accessibilityRole:"button",onPress:()=>h.untrust(o.key),style:({pressed:r})=>[Ie.forget,r&&{opacity:.7}],hitSlop:6,children:He(i,{style:Ie.forgetText,children:"Ask again"})})]},o.key))]}):null]})}var Ie=y.create({scroll:{flex:1},content:{padding:pe.gutter,gap:10,paddingBottom:32},section:{color:pe.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.6,paddingHorizontal:4,paddingTop:4},warning:{flexDirection:"row",gap:8,padding:pe.cardPad,borderRadius:pe.radius.card,borderWidth:y.hairlineWidth,borderColor:pe.color.warning,backgroundColor:pe.color.surface},warningText:{flex:1,color:pe.color.warning,fontSize:pe.font.micro,lineHeight:16},trustedBox:{gap:6,paddingTop:6},trustedRow:{flexDirection:"row",alignItems:"center",gap:10,padding:pe.cardPad,borderRadius:pe.radius.card,borderWidth:y.hairlineWidth,borderColor:pe.color.border,backgroundColor:pe.color.surface},trustedLabel:{flex:1,color:pe.color.text,fontSize:pe.font.caption,lineHeight:18},forget:{paddingHorizontal:10,paddingVertical:6,borderRadius:pe.radius.row,backgroundColor:pe.color.button},forgetText:{color:pe.color.text,fontSize:pe.font.micro,fontWeight:"600"},note:{color:pe.color.textTertiary,fontSize:pe.font.micro,lineHeight:16,paddingHorizontal:4}});import{ChevronRight as uc,night as Ce,NightSectionLabel as pc}from"@buoy-gg/shared-ui/web";var cc=[{text:"Why is this screen empty?"},{text:"What did the last few network calls return?",needs:"network"},{text:"Show me what's saved for this user",needs:"storage"},{text:"Make the next request to this screen fail with a 500",needs:"network",write:!0,devOnly:!0},{text:"Who am I signed in as right now?"},{text:"Did anything crash or log an error recently?",needs:"console"}],dc=4;function Ii(e){let t=e.availableToolIds.length>0;return cc.filter(o=>o.write&&e.readOnly||o.devOnly&&e.isRelease?!1:o.needs?t&&e.availableToolIds.includes(o.needs):!0).slice(0,dc).map(o=>o.text)}import{jsx as Ge,jsxs as Kt}from"react/jsx-runtime";var Ri=typeof R<"u"&&!R;function Pi({configured:e,onPick:t,availableToolIds:o=[],readOnly:r=!1}){let n=Ii({availableToolIds:o,readOnly:r,isRelease:Ri});return e?Kt(l,{style:Re.wrap,testID:"buoy-ask-buoy-empty",children:[Ge(i,{style:Re.title,children:"Ask about this app"}),Ge(i,{style:Re.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."}),Ge(i,{style:Re.buildLine,testID:"buoy-ask-buoy-build-line",children:Ri?"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."}),Kt(l,{style:Re.group,children:[Ge(pc,{children:"Try asking"}),Ge(l,{style:Re.card,children:n.map((s,a)=>Ge(gc,{text:s,onPick:t,last:a===n.length-1},s))})]})]}):Kt(l,{style:Re.wrap,testID:"buoy-ask-buoy-unconfigured",children:[Ge(i,{style:Re.title,children:"Not set up yet"}),Kt(i,{style:Re.body,children:["Ask Buoy talks to your own company's AI endpoint \u2014 nothing goes to Buoy. A developer needs to add the ",Ge(i,{style:Re.code,children:"askBuoy"})," prop to"," ",Ge(i,{style:Re.code,children:"<FloatingDevTools />"})," with your team's endpoint and model."]})]})}function gc({text:e,onPick:t,last:o}){return Kt(b,{testID:`buoy-ask-buoy-suggestion-${e.slice(0,12)}`,accessibilityRole:"button",onPress:()=>t(e),style:({pressed:r})=>[Re.row,!o&&Re.rowDivider,r&&Re.pressed],children:[Ge(i,{style:Re.rowText,children:e}),Ge(uc,{size:14,color:Ce.color.textTertiary})]})}var Re=y.create({wrap:{flex:1,justifyContent:"center",paddingHorizontal:Ce.gutter,paddingVertical:24,gap:8},title:{color:Ce.color.text,fontSize:22,fontWeight:"700",letterSpacing:-.3},body:{color:Ce.color.textSecondary,fontSize:Ce.font.body,lineHeight:20},code:{color:Ce.color.text,fontFamily:"Menlo"},buildLine:{marginTop:8,color:Ce.color.textTertiary,fontSize:Ce.font.micro,lineHeight:15},group:{marginTop:Ce.groupGap-8},card:{borderRadius:Ce.radius.card,borderWidth:y.hairlineWidth,borderColor:Ce.color.border,backgroundColor:Ce.color.surface,overflow:"hidden"},row:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:Ce.rowPadH,paddingVertical:13},rowDivider:{borderBottomWidth:y.hairlineWidth,borderBottomColor:Ce.color.separator},rowText:{flex:1,color:Ce.color.text,fontSize:Ce.font.body,lineHeight:19},pressed:{backgroundColor:Ce.color.fill}});import{memo as vc,useCallback as $t,useEffect as Bc,useRef as sr,useState as Oi}from"react";import{AlertTriangle as Ei,Check as Wi,ChevronDown as Mi,ChevronRight as Ni,Copy as Ac,night as w,X as Ic}from"@buoy-gg/shared-ui/web";import{toolTitle as Rc}from"@buoy-gg/agent-core/web";import{isAskBlock as fc}from"@buoy-gg/agent-core/web";function yc({block:e,forToolCallId:t}){if(!t)return!1;let o="source"in e?e.source:void 0;return o==="live"||o==="mocked"}function Di(e,t){let o=new Set(t),r=new Map,n=[],s=[];for(let a of e){if(fc(a.block)){s.push(a);continue}if(yc(a)&&o.has(a.forToolCallId)){let g=r.get(a.forToolCallId)??[];g.push(a.block),r.set(a.forToolCallId,g)}else n.push(a)}return{nested:r,afterText:n,ask:s}}import{useState as zi}from"react";import{Activity as hc,ChevronDown as mc,ChevronRight as xc,night as te}from"@buoy-gg/shared-ui/web";function bo(e){let t=[...e.reasoning??[]].sort((s,a)=>s.afterCalls-a.afterCalls),o=[],r=0,n=s=>{for(;r<t.length&&t[r].afterCalls<=s;)o.push({kind:"thought",text:t[r].text}),r+=1};return e.toolCalls.forEach((s,a)=>{n(a),o.push({kind:"step",n:a+1,call:s})}),n(e.toolCalls.length),o}function rr(e){return(e.reasoning?.length??0)>0||e.toolCalls.length>0}var bc=e=>e.status==="ok"?e.summary||"done":e.status==="running"?"running":`${e.status}${e.summary?` \u2014 ${e.summary}`:""}`;function nr(e,t=" "){let o=[];for(let r of bo(e))if(r.kind==="thought"){o.push(`${t}[thinking]`);for(let n of r.text.trim().split(`
12
+ `))o.push(`${t} ${n}`)}else{let{n,call:s}=r;o.push(`${t}[${n}] ${s.toolId}.${s.action} \u2014 ${bc(s)}`),s.params&&o.push(`${t} ${s.params}`)}return o}import{Fragment as Tc,jsx as Ne,jsxs as pt}from"react/jsx-runtime";function wc({n:e,call:t}){let[o,r]=zi(!1),n=t.status==="failed"||t.status==="refused";return pt(b,{onPress:()=>r(s=>!s),accessibilityRole:"button",accessibilityState:{expanded:o},style:ye.step,children:[pt(l,{style:ye.stepLine,children:[Ne(i,{style:ye.stepN,children:e}),pt(i,{style:[ye.stepName,n&&ye.stepFailed],numberOfLines:1,children:[t.toolId,".",t.action]}),t.durationMs!==void 0?pt(i,{style:ye.stepMs,children:[t.durationMs,"ms"]}):null,Ne(i,{style:[ye.stepStatus,n&&ye.stepFailed],numberOfLines:1,children:t.status==="ok"?t.summary||"done":t.status})]}),o?pt(l,{style:ye.detail,children:[Ne(i,{style:ye.detailLabel,children:"SENT"}),Ne(i,{style:ye.code,selectable:!0,children:t.params??"no parameters"}),t.result?pt(Tc,{children:[Ne(i,{style:ye.detailLabel,children:"RETURNED"}),Ne(i,{style:ye.code,selectable:!0,children:t.result})]}):null]}):null]})}function ir({message:e}){let[t,o]=zi(!1);if(!rr(e))return null;let r=bo(e),n=r.filter(u=>u.kind==="step").length,s=r.length-n,a=e.startedAt!==void 0&&e.endedAt!==void 0?`${((e.endedAt-e.startedAt)/1e3).toFixed(1)}s`:null,g=[n?`${n} step${n===1?"":"s"}`:null,s?`${s} thought${s===1?"":"s"}`:null,a,e.usage?`${e.usage.input+e.usage.output} tokens`:null].filter(Boolean).join(" \xB7 ");return pt(l,{style:ye.wrap,testID:"buoy-ask-buoy-thinking",children:[pt(b,{testID:"buoy-ask-buoy-thinking-toggle",onPress:()=>o(u=>!u),accessibilityRole:"button",accessibilityLabel:t?"Hide agent thinking":"Show agent thinking",accessibilityState:{expanded:t},style:ye.head,children:[Ne(hc,{size:12,color:te.color.textTertiary}),Ne(i,{style:ye.headText,children:g}),t?Ne(mc,{size:12,color:te.color.textTertiary}):Ne(xc,{size:12,color:te.color.textTertiary})]}),t?pt(l,{style:ye.body,children:[r.map((u,f)=>u.kind==="thought"?Ne(i,{style:ye.thought,selectable:!0,children:u.text.trim()},`t${f}`):Ne(wc,{n:u.n,call:u.call},u.call.id)),s===0?Ne(i,{style:ye.none,children:"This model reports no reasoning \u2014 the steps above are the whole trace."}):null]}):null]})}var ye=y.create({wrap:{marginTop:8,borderRadius:te.radius.badge,borderWidth:y.hairlineWidth,borderColor:te.color.separator,backgroundColor:te.color.fill,overflow:"hidden"},head:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:7},headText:{flex:1,color:te.color.textTertiary,fontSize:te.font.micro,fontWeight:"600"},body:{borderTopWidth:y.hairlineWidth,borderTopColor:te.color.separator},thought:{color:te.color.textSecondary,fontSize:te.font.micro,lineHeight:17,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8},step:{paddingHorizontal:10,paddingVertical:7},stepLine:{flexDirection:"row",alignItems:"center",gap:8},stepN:{color:te.color.textTertiary,fontSize:te.font.micro,width:14},stepName:{flex:1,color:te.color.textSecondary,fontSize:te.font.micro,fontWeight:"600"},stepMs:{color:te.color.textTertiary,fontSize:te.font.micro},stepStatus:{color:te.color.textTertiary,fontSize:te.font.micro,maxWidth:110},stepFailed:{color:te.color.danger},detail:{marginTop:6,marginLeft:22,gap:3},detailLabel:{color:te.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},code:{color:te.color.textSecondary,fontSize:te.font.micro,lineHeight:16,marginBottom:3},none:{color:te.color.textTertiary,fontSize:te.font.micro,fontStyle:"italic",paddingHorizontal:10,paddingVertical:8}});import{useEffect as kc,useRef as Sc}from"react";import{night as Cc}from"@buoy-gg/shared-ui/web";import{jsx as Li}from"react/jsx-runtime";function Hi(){let e=Sc([0,1,2].map(()=>new ee.Value(.25))).current;return kc(()=>{let t=e.map((o,r)=>ee.loop(ee.sequence([ee.delay(r*140),ee.timing(o,{toValue:1,duration:320,easing:bt.inOut(bt.ease),useNativeDriver:!0}),ee.timing(o,{toValue:.25,duration:320,easing:bt.inOut(bt.ease),useNativeDriver:!0}),ee.delay((2-r)*140)])));return t.forEach(o=>o.start()),()=>t.forEach(o=>o.stop())},[e]),Li(l,{style:Vi.wrap,testID:"buoy-ask-buoy-typing",accessibilityLabel:"Thinking",children:e.map((t,o)=>Li(ee.View,{style:[Vi.dot,{opacity:t}]},o))})}var Vi=y.create({wrap:{flexDirection:"row",alignItems:"center",gap:5,paddingVertical:8,paddingHorizontal:2},dot:{width:7,height:7,borderRadius:4,backgroundColor:Cc.color.textSecondary}});import{jsx as T,jsxs as Pe}from"react/jsx-runtime";function qi({status:e}){switch(e){case"running":return T(yt,{size:"small",color:w.color.textSecondary});case"ok":return T(l,{style:[x.mark,x.markOk],children:T(Wi,{size:10,color:w.color.onAccent})});case"failed":return T(l,{style:[x.mark,x.markFailed],children:T(Ic,{size:10,color:w.color.text})});case"refused":return T(l,{style:[x.mark,x.markRefused],children:T(Ei,{size:10,color:w.color.onAccent})});case"declined":case"stopped":return T(l,{style:[x.mark,x.markNotRun],children:T(l,{style:x.markNotRunBar})})}}function Pc(e){return e.status==="running"?{text:"",tone:"muted"}:e.status==="refused"?{text:"Refused",tone:"warning"}:e.status==="failed"?{text:"Failed",tone:"danger"}:e.status==="declined"?{text:"You declined",tone:"muted"}:e.status==="stopped"?{text:"Not run \u2014 stopped",tone:"muted"}:e.verification?.status==="verified"?{text:"Verified",tone:"ok"}:e.verification?.status==="unverified"?{text:"Done \xB7 not yet visible",tone:"muted"}:e.verification?.status==="failed"?{text:"Done \xB7 check failed",tone:"warning"}:{text:e.summary||"Done",tone:"muted"}}var Dc=e=>e.status==="failed"||e.status==="refused"||e.status==="declined"||e.status==="stopped";function Fi({call:e,receipts:t,last:o}){let[r,n]=Oi(!1),s=Pc(e),a=r?Mi:Ni,g=e.status==="failed"&&e.summary&&e.summary!=="Failed"?e.summary:null;return Pe(l,{style:[x.row,!o&&x.rowDivider],children:[Pe(b,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${s.text||"running"}`,accessibilityState:{expanded:r},onPress:()=>n(u=>!u),children:[Pe(l,{style:x.rowLine,children:[T(l,{style:x.markSlot,children:T(qi,{status:e.status})}),T(i,{style:x.rowTitle,children:e.label}),s.text?T(i,{style:[x.rowStatus,s.tone==="danger"&&x.rowStatusDanger,s.tone==="warning"&&x.rowStatusWarning,s.tone==="ok"&&x.rowStatusOk],numberOfLines:1,children:s.text}):null,T(a,{size:12,color:w.color.textTertiary})]}),r&&Pe(l,{style:x.rowDetail,children:[T(i,{style:x.rowTool,children:Rc(e.toolId).toUpperCase()}),e.description?T(i,{style:x.rowDescription,children:e.description}):null,g?T(i,{style:x.rowFailure,children:g}):null,e.verification?T(i,{style:[x.rowDescription,e.verification.status==="failed"&&x.rowFailure,e.verification.status==="verified"&&x.rowVerified],testID:`buoy-ask-buoy-verification-${e.verification.status}`,children:e.verification.detail}):null]})]}),r&&t.length>0&&T(l,{style:x.rowReceipts,testID:`buoy-ask-buoy-tool-receipt-${e.toolId}`,children:t.map(u=>T(Ht,{block:u},u.id))})]})}function zc({label:e,count:t,calls:o,receipts:r,last:n}){let[s,a]=Oi(!1),g=s?Mi:Ni;return Pe(l,{style:!n&&!s&&x.rowDivider,children:[T(b,{testID:"buoy-ask-buoy-reads-group",accessibilityRole:"button",accessibilityLabel:`${e}, ${t} reads`,accessibilityState:{expanded:s},onPress:()=>a(u=>!u),style:[x.row,s&&x.rowDivider],children:Pe(l,{style:x.rowLine,children:[T(l,{style:x.markSlot,children:T(qi,{status:"ok"})}),T(i,{style:x.rowTitle,children:e}),Pe(i,{style:x.rowStatus,numberOfLines:1,children:[t," reads"]}),T(g,{size:12,color:w.color.textTertiary})]})}),s&&T(l,{style:x.groupBody,children:o.map((u,f)=>T(Fi,{call:u,receipts:r.get(u.id)??[],last:n&&f===o.length-1},u.id))})]})}function Vc({calls:e,receipts:t}){let o=li(e);return T(l,{style:x.card,testID:"buoy-ask-buoy-activity",children:o.map((r,n)=>r.kind==="reads"?T(zc,{label:r.label,count:r.count,calls:r.calls,receipts:t,last:n===o.length-1},r.id):T(Fi,{call:r.call,receipts:t.get(r.call.id)??[],last:n===o.length-1},r.call.id))})}function $i({blocks:e}){return e.length===0?null:T(l,{style:x.blocks,children:e.map(({block:t})=>T(Ht,{block:t},t.id))})}function Lc({message:e}){return T(l,{style:x.systemLine,testID:"buoy-ask-buoy-system-line",children:T(i,{style:x.systemText,children:e.text})})}function Hc({message:e}){return T(l,{style:x.userWrap,children:T(l,{style:x.userBubble,children:T(i,{style:x.userText,selectable:!0,children:e.text})})})}function $c({message:e,onRetry:t,waitingOnUser:o}){let{showThinking:r}=tt(),n=!!e.streaming&&!o,{nested:s,afterText:a,ask:g}=Di(e.blocks,e.toolCalls.map(u=>u.id));return Pe(l,{style:x.assistantWrap,children:[e.toolCalls.length>0&&T(Vc,{calls:e.toolCalls,receipts:s}),e.text.length>0&&T(Po,{text:e.text,style:x.assistantText}),T($i,{blocks:a}),T($i,{blocks:g}),r&&!e.streaming&&T(ir,{message:e}),n&&Pe(l,{style:x.waitingRow,children:[T(Hi,{}),e.waiting?T(i,{style:x.waitingText,testID:"buoy-ask-buoy-waiting",children:e.waiting}):null]}),e.error&&T(Ec,{error:e.error,onRetry:t}),e.stopped&&!e.error&&T(Oc,{onRetry:t,changed:e.toolCalls.some(u=>u.status==="ok"&&!!u.effect&&u.effect!=="read")})]})}function Oc({onRetry:e,changed:t}){return Pe(l,{style:x.stoppedBox,testID:"buoy-ask-buoy-stopped",children:[T(i,{style:x.stoppedText,children:t?"Stopped. Changes already made are listed above.":"Stopped."}),e&&T(b,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:e,style:({pressed:o})=>[x.retry,o&&x.retryPressed],children:T(i,{style:x.retryText,children:"Try again"})})]})}function Ec({error:e,onRetry:t}){let r=/fetch failed|network|ECONN|timed? ?out|socket/i.test(e)?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return Pe(l,{style:x.errorBox,testID:"buoy-ask-buoy-error",children:[T(Ei,{size:14,color:w.color.danger}),Pe(l,{style:x.errorBody,children:[T(i,{style:x.errorText,children:r}),T(i,{style:x.errorDetail,selectable:!0,children:e}),t&&T(b,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",accessibilityLabel:"Try again",onPress:t,style:({pressed:n})=>[x.retry,n&&x.retryPressed],children:T(i,{style:x.retryText,children:"Try again"})})]})]})}function ar(e,t=!1){let o=[];for(let r of e){if(r.role==="user"){o.push(`You: ${r.text}`);continue}if(r.system){o.push(` \u2014 ${r.text}`);continue}if(t)o.push(...nr(r));else for(let n of r.toolCalls){let s=Dc(n)?` (${n.status})`:"";o.push(` \xB7 ${n.label}${n.summary?` \u2014 ${n.summary}`:""}${s}`)}r.text&&o.push(`Ask Buoy: ${r.text}`);for(let n of Mr(r.blocks.map(s=>s.block)))o.push(n);r.error&&o.push(` ! ${r.error}`),r.stopped&&!r.error&&o.push(" ! Stopped by the user.")}return o.join(`
13
+ `)}function Wc({testID:e,label:t,getText:o}){let{copied:r,copy:n}=Lt(o);return Pe(b,{testID:e,accessibilityRole:"button",accessibilityLabel:t,onPress:n,style:({pressed:s})=>[x.copyBtn,x.iconBtn,s&&x.copyPressed],children:[r?T(Wi,{size:11,color:w.color.accent}):T(Ac,{size:11,color:w.color.textSecondary}),T(i,{style:[x.copyText,r&&x.copiedText],children:r?"Copied":t})]})}function Mc({message:e}){let{showThinking:t}=tt(),o=$t(()=>ar(h.getState().messages,t),[t]),r=ci(e);return Pe(l,{style:x.transcriptActions,children:[r?T(i,{style:x.turnFooter,testID:"buoy-ask-buoy-turn-footer",children:r}):null,T(Wc,{testID:"buoy-ask-buoy-copy",label:"Copy conversation",getText:o})]})}var Nc=vc(function({message:t,onRetry:o,waitingOnUser:r}){if(t.role==="user")return T(Hc,{message:t});if(t.system)return T(Lc,{message:t});let n=!t.streaming&&!t.error;return Pe(l,{children:[T($c,{message:t,onRetry:o,waitingOnUser:r}),n&&T(Mc,{message:t})]})});function lr({messages:e,ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r,onRetry:n,waitingOnUser:s}){let a=sr(null),g=sr(!0),u=sr(!1),f=$t(Te=>{let{contentOffset:rt,contentSize:$e,layoutMeasurement:nt}=Te.nativeEvent,it=$e.height-nt.height-rt.y;g.current=it<80},[]),m=$t(()=>{u.current=!0},[]),O=$t(Te=>{u.current&&f(Te)},[f]),$=$t(Te=>{u.current=!1,f(Te)},[f]),L=$t(()=>{g.current&&(a.current?.scrollToEnd({animated:!1}),requestAnimationFrame(()=>a.current?.scrollToEnd({animated:!1})))},[]),oe=e[e.length-1],re=oe?`${oe.id}:${oe.text.length}:${oe.toolCalls.length}:${oe.error??""}`:"";return Bc(()=>{L()},[re,L]),T(Ao,{ref:a,testID:"buoy-ask-buoy-messages-scroll",style:x.list,contentContainerStyle:x.listContent,data:e,keyExtractor:Te=>Te.id,renderItem:({item:Te})=>T(Nc,{message:Te,onRetry:Te.id===oe?.id?n:void 0,waitingOnUser:Te.id===oe?.id?s:!1}),onScroll:O,onScrollBeginDrag:m,onScrollEndDrag:$,onMomentumScrollEnd:f,scrollEventThrottle:32,onContentSizeChange:L,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:o,ListFooterComponent:r})}var x=y.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:w.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:w.color.accentFill,borderWidth:y.hairlineWidth,borderColor:w.color.accentBorder},userText:{color:w.color.text,fontSize:w.font.row,lineHeight:21},systemLine:{alignSelf:"stretch",paddingHorizontal:12,paddingVertical:7,borderRadius:w.radius.row,backgroundColor:w.color.fill},systemText:{color:w.color.textSecondary,fontSize:w.font.micro,lineHeight:16,textAlign:"center"},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},waitingRow:{flexDirection:"row",alignItems:"center",gap:8},waitingText:{color:w.color.textSecondary,fontSize:w.font.caption},assistantText:{color:w.color.text,fontSize:w.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:w.radius.card,borderWidth:y.hairlineWidth,borderColor:w.color.border,backgroundColor:w.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:y.hairlineWidth,borderBottomColor:w.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:w.color.accent},markFailed:{backgroundColor:w.color.danger},markRefused:{backgroundColor:w.color.warning},markNotRun:{borderWidth:1.5,borderColor:w.color.textTertiary},markNotRunBar:{width:7,height:1.5,borderRadius:1,backgroundColor:w.color.textSecondary},rowTitle:{flex:1,color:w.color.text,fontSize:w.font.body,lineHeight:19},rowStatus:{color:w.color.textTertiary,fontSize:w.font.caption,maxWidth:120},rowStatusDanger:{color:w.color.danger},rowStatusWarning:{color:w.color.warning},rowStatusOk:{color:w.color.accent},rowVerified:{color:w.color.accent},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:w.color.textTertiary,fontSize:w.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:w.color.textSecondary,fontSize:w.font.caption,lineHeight:18},rowFailure:{color:w.color.danger,fontSize:w.font.caption,lineHeight:18},rowReceipts:{paddingTop:10,gap:10},groupBody:{paddingLeft:14,backgroundColor:w.color.fill},stoppedBox:{alignItems:"flex-start",gap:2,paddingHorizontal:12,paddingVertical:8},stoppedText:{color:w.color.textTertiary,fontSize:w.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:w.radius.row,backgroundColor:w.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:w.color.danger,fontSize:w.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:w.color.textSecondary,fontSize:w.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:w.radius.row,backgroundColor:w.color.button},retryPressed:{opacity:.7},retryText:{color:w.color.accent,fontSize:w.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",alignItems:"center",gap:10,marginTop:8},turnFooter:{flex:1,color:w.color.textTertiary,fontSize:w.font.micro,fontVariant:["tabular-nums"]},copyBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:w.radius.badge,backgroundColor:w.color.fill},iconBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8},copyPressed:{opacity:.7},copyText:{color:w.color.textSecondary,fontSize:w.font.micro,fontWeight:"600"},copiedText:{color:w.color.accent}});import{night as Fe,X as qc}from"@buoy-gg/shared-ui/web";import{jsx as Ot,jsxs as cr}from"react/jsx-runtime";var Fc=132;function _i({items:e,paused:t,onEdit:o,onRemove:r}){return e.length===0?null:cr(l,{style:qe.wrap,testID:"buoy-ask-buoy-queued",children:[Ot(ke,{style:qe.list,contentContainerStyle:qe.listContent,keyboardShouldPersistTaps:"handled",children:e.map((n,s)=>cr(l,{style:[qe.row,t!==null&&qe.rowPaused],children:[cr(b,{testID:`buoy-ask-buoy-queue-item-${s}`,accessibilityRole:"button",accessibilityLabel:`Edit queued message: ${n.text}`,onPress:()=>o(n.id),style:({pressed:a})=>[qe.rowBody,a&&qe.pressed],children:[Ot(i,{style:qe.ordinal,children:s===0?"NEXT":"THEN"}),Ot(i,{style:qe.text,numberOfLines:3,children:n.text})]}),Ot(b,{testID:`buoy-ask-buoy-queue-remove-${s}`,accessibilityRole:"button",accessibilityLabel:"Remove queued message",onPress:()=>r(n.id),hitSlop:8,style:({pressed:a})=>[qe.remove,a&&qe.pressed],children:Ot(qc,{size:11,color:Fe.color.textTertiary})})]},n.id))}),Ot(i,{style:[qe.hint,t!==null&&qe.hintPaused],testID:"buoy-ask-buoy-queue-hint",children:t??"Sends one at a time when this turn finishes \xB7 tap to edit"})]})}var qe=y.create({wrap:{paddingHorizontal:Fe.gutter,paddingTop:8,gap:6,backgroundColor:Fe.color.bg},list:{maxHeight:Fc},listContent:{gap:6},row:{flexDirection:"row",alignItems:"center",borderRadius:Fe.radius.row,borderWidth:y.hairlineWidth,borderColor:Fe.color.border,backgroundColor:Fe.color.surface},rowPaused:{borderColor:Fe.color.warning},rowBody:{flex:1,flexDirection:"row",alignItems:"center",gap:8,paddingVertical:7,paddingLeft:10},ordinal:{color:Fe.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.6,width:30},text:{flex:1,color:Fe.color.textSecondary,fontSize:Fe.font.caption,lineHeight:17},remove:{width:32,height:32,alignItems:"center",justifyContent:"center"},pressed:{opacity:.7},hint:{color:Fe.color.textTertiary,fontSize:Fe.font.micro},hintPaused:{color:Fe.color.warning}});var Ui="Summarize this conversation as a bug ticket, using one buoy_ui finding block and nothing else. Title it with the problem in one line. Evidence rows, in this order: Steps (what we did), Expected, Observed, Build (dev or release, platform), Evidence (the exact requests, statuses, logs or values you actually saw this conversation), Still applied (overrides or changes from your changes list that are still live, or 'none'). Only facts you observed in this conversation; write 'unknown' where you don't know rather than guessing, and put anything you inferred rather than saw in a final row labelled Inference. Do not run any tool or change anything to produce this.";import{Fragment as Jc,jsx as Ae,jsxs as mo}from"react/jsx-runtime";function xo({visible:e,onClose:t,onBack:o,onMinimize:r,persistenceKey:n,config:s}){let{state:a,send:g,stop:u,reset:f,undoThenReset:m,approve:O,retry:$,answer:L,runAction:oe,editQueued:re,removeQueued:Te,configured:rt,toolCount:$e,availableToolIds:nt}=er(s),[it,kt]=dr(!1),St=ot(()=>{u(),t()},[u,t]),Dt=ot(()=>h.clearDraft(),[]),[Je,gt]=dr(!1),ft=ot(()=>gt(!1),[]),st=ot(()=>gt(!0),[]),Ct=!e,at=!!a.pending||!!a.awaitingBlockId,De=a.messages[a.messages.length-1],zt=Qt(!1),Jt=Qt(a.busy);jt(()=>{Ct&&Jt.current&&!a.busy&&(zt.current=!0),Ct||(zt.current=!1),Jt.current=a.busy},[Ct,a.busy]),jt(()=>{if(!Ct){Et("ask-buoy",null);return}at?Et("ask-buoy",{kind:"needsInput",label:a.pending?"Needs your approval":"Has a question for you"}):zt.current&&De?.role==="assistant"&&De.error?Et("ask-buoy",{kind:"failed",label:"The last turn failed"}):zt.current&&!a.busy?Et("ask-buoy",{kind:"done",label:"Finished"}):Et("ask-buoy",null)},[Ct,at,a.busy,a.pending,De]),jt(()=>()=>Et("ask-buoy",null),[]),jt(()=>{a.pending&&Je&&gt(!1)},[a.pending,Je]);let To=Gc({minBottom:16}),[Yt,ko]=dr("bottomSheet"),So=Yt==="floating"?0:To.bottom,Co=ot(()=>{let ae=h.getLedger();ae&&(async()=>{let be=await ae.revertAll(Uc);if(be.failed.length===0){h.setNotice(null);return}let _e=be.failed.map(Wt=>`${Wt.label} (${Wt.error})`).join("; ");h.setNotice(`Couldn't undo ${be.failed.length} change${be.failed.length===1?"":"s"} \u2014 ${_e}`)})()},[]),S=ot(()=>kt(ae=>!ae),[]),F=Qt(new ee.Value(560)).current,Q=Qt(!1),se=ot(()=>{Q.current||(Q.current=!0,F.stopAnimation(ae=>{let be=typeof ae=="number"&&ae>200?ae:560;ee.timing(F,{toValue:120,duration:220,useNativeDriver:!1}).start(()=>{setTimeout(()=>{ee.spring(F,{toValue:be,friction:9,useNativeDriver:!1}).start(()=>{Q.current=!1})},2500)})}))},[F]),ve=ho(()=>{let ae=a.messages[a.messages.length-1];if(!ae||ae.role!=="assistant")return"";let be=ae.blocks.filter(_e=>_e.block.kind==="peek").length;return be>0?`${ae.id}:${be}`:""},[a.messages]),ne=Qt("");jt(()=>{ve&&ve!==ne.current&&s?.peek!==!1&&se(),ne.current=ve},[ve,se,s]);let hr=ot(()=>{let be=h.getLedger()?.list().filter(_e=>!_e.undoneAt&&_c(_e.effect)).length??0;if(be===0){f();return}Xt.alert("Undo changes first?",`Ask Buoy made ${be} change${be===1?"":"s"} that can still be undone. Clearing the conversation loses the only automatic undo for ${be===1?"it":"them"}.`,[{text:"Undo, then clear",onPress:()=>{(async()=>{let _e=await m();if(_e.cleared)return;let Wt=_e.reverted+_e.failed.length,es=_e.failed.map(Sr=>`${Sr.label} (${Sr.error})`).join(`
14
+ `);Xt.alert(`Couldn't undo ${_e.failed.length} of ${Wt} change${Wt===1?"":"s"}`,`${es}
15
+
16
+ Still applied in the app. Clear the conversation anyway?`,[{text:"Keep conversation",style:"cancel"},{text:"Clear anyway",style:"destructive",onPress:f}])})()}},{text:"Clear anyway",style:"destructive",onPress:f},{text:"Cancel",style:"cancel"}])},[f,m]),ji=ho(()=>{let ae=a.messages[a.messages.length-1];return!ae||ae.role!=="assistant"||!ae.streaming?null:ae.toolCalls.find(be=>be.status==="running")?.label??null},[a.messages]),mr=Oo(h.getLedger()),xr=ho(()=>oi(mr),[mr]),Qi=ho(()=>({answer:L,runAction:(ae,be)=>{if(ae.minimize){r?.({mode:"bottomSheet"});return}return oe(ae,be)},answered:a.answers,actionState:a.actionState,busy:a.busy,supports:{openTool:!1,minimize:!!r,dispatch:!0},rules:xr}),[L,oe,r,a.answers,a.actionState,a.busy,xr]),Gi=!a.busy&&De?.role==="assistant"&&!!De.error,wr=!a.busy&&De?.role==="assistant"&&De.stopped&&!De.error?De.id:null,Ji=uo(a),{showThinking:Tr,readOnly:kr}=tt(),Yi=ot(()=>ar(a.messages,Tr),[a.messages,Tr]),Xi=ot(()=>g(Ui),[g]),Zi=Je?mo(ur,{children:[Ae(ur.Navigation,{onBack:ft}),Ae(ur.Content,{title:"Settings",subtitle:"Ask Buoy",testID:"buoy-ask-buoy-settings-title"})]}):Ae(No,{configured:rt,busy:a.busy,failed:Gi,activeLabel:ji,awaitingApproval:!!a.pending,startedAt:De?.role==="assistant"&&De.streaming?De.startedAt??null:null,stopping:a.stopping,readOnly:kr,toolCount:$e,hasMessages:a.messages.length>0,onBack:o,onReset:hr,getTranscript:Yi,onOpenSettings:st,onTicket:Xi});return Ae(Qc,{visible:e,onClose:St,disableScrollWrapper:!0,background:!1,initialHeight:560,animatedHeight:F,header:{customContent:Zi,showToggleButton:!1},onBack:o,onMinimize:r,onModeChange:ko,persistenceKey:n??"buoy-ask-buoy",enablePersistence:!0,children:Ae(eo,{value:Qi,children:mo(l,{style:[pr.root,{paddingBottom:So}],children:[Ae(Eo,{ledger:h.getLedger(),onUndoAll:Co,expanded:it,onToggle:S}),a.notice&&mo(l,{style:pr.notice,testID:"buoy-ask-buoy-notice",children:[Ae(jc,{size:14,color:Gt.color.info}),Ae(i,{style:pr.noticeText,children:a.notice})]}),Ae(ai,{children:Ae(Kc,{featureName:"Ask Buoy",children:Je?Ae(or,{}):mo(Jc,{children:[Ae(lr,{messages:a.messages,onRetry:$,waitingOnUser:!!a.pending||!!a.awaitingBlockId,ListEmptyComponent:Ae(Pi,{configured:rt,onPick:g,availableToolIds:nt,readOnly:kr||!!s?.policy?.readOnly})}),Ae(_i,{items:a.queued,paused:Ji,onEdit:re,onRemove:Te}),a.pending&&Ae($o,{pending:a.pending,onAnswer:O}),Ae(Wo,{onSend:g,onStop:u,busy:a.busy,draft:a.draft,onDraftTaken:Dt,disabled:!rt,focusKey:wr,canFocus:e,placeholder:wr?"Tell it what to do differently\u2026":a.awaitingBlockId?"Pick an option above, or type\u2026":void 0})]})})})]})})})}var pr=y.create({root:{flex:1,backgroundColor:"transparent"},notice:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:Gt.gutter,paddingVertical:10,backgroundColor:Gt.color.infoSoft},noticeText:{flex:1,color:Gt.color.text,fontSize:Gt.font.caption,lineHeight:18}});import{AskBuoyIcon as gr,ASK_BUOY_ICON_COLOR as fr}from"@buoy-gg/floating-tools-core/web";import{jsx as Ki}from"react/jsx-runtime";var wo={id:"ask-buoy",name:"ASK BUOY",description:"Ask about this app in plain English",slot:"both",color:fr,icon:({size:e,slot:t})=>Ki(gr,{size:t==="dial"?e*1.5:e}),component:xo};function Yc(e){let{name:t,description:o,...r}=e,n=r;return{...wo,name:t??wo.name,description:o??wo.description,component:s=>Ki(xo,{...s,config:n})}}import{isReversible as yr}from"@buoy-gg/agent-core/web";var br=1,Xc={version:br,async dispose(e){let t=h.getLedger();for(let o of t?.list()??[])o.undoneAt||o.effect.kind==="network-override"&&await e("network","deleteOverrideRule",{id:o.effect.ruleId})},getSnapshot(){let e=h.getState(),r=(h.getLedger()?.list()??[]).filter(n=>!n.undoneAt);return{version:br,busy:e.busy,configured:e.configured,notice:e.notice,messageCount:e.messages.length,messages:e.messages.map(n=>({id:n.id,role:n.role,text:Rt(n.text),streaming:!!n.streaming,toolCalls:n.toolCalls.map(s=>({toolId:s.toolId,action:s.action,status:s.status}))})),usage:e.usage,pendingApproval:e.pending?{toolId:e.pending.toolId,action:e.pending.action,label:e.pending.label}:null,changes:{reversible:r.filter(n=>yr(n.effect)).length,permanent:r.filter(n=>n.effect.kind!=="transient"&&!yr(n.effect)).length,transients:r.filter(n=>n.effect.kind==="transient").length,items:r.map(n=>({kind:n.effect.kind,label:n.effect.label}))}}},subscribe(e){let t=h.subscribe(e),o=h.getLedger()?.subscribe(e);return()=>{t(),o?.()}},actions:{listChanges:()=>(h.getLedger()?.list()??[]).filter(t=>!t.undoneAt).map(t=>({id:t.id,at:t.at,toolId:t.toolId,action:t.action,kind:t.effect.kind,label:t.effect.label,reversible:yr(t.effect)})),undoAll:async()=>{let e=h.getLedger();return e?{ok:!0,...await e.revertAll(Go)}:{ok:!1,error:"No Ask Buoy session on this device."}},reset:async()=>{let e=await go({dispatch:Go,undoFirst:!0});return e.cleared?{ok:!0,reverted:e.reverted}:{ok:!1,error:`Couldn't undo ${e.failed.length} change${e.failed.length===1?"":"s"} \u2014 conversation kept.`,failed:e.failed}}}};export{br as ASK_BUOY_ADAPTER_VERSION,fr as ASK_BUOY_ICON_COLOR,$o as ApprovalCard,No as AskBuoyHeader,gr as AskBuoyIcon,xo as AskBuoyModal,or as AskBuoySettings,he as BlockActionRow,H as BlockCard,eo as BlockHandlersProvider,Ht as BlockRenderer,Eo as ChangesBar,Wo as Composer,Xn as EditableUserBubble,Qn as ElapsedRow,Lo as LivePill,Po as Markdown,Kn as MessageActions,lr as MessageList,oo as ProvenanceBadge,Gn as QueuedComposer,jn as ReasoningStrip,Jn as ReloadDivider,ir as ThinkingStrip,Yn as Timestamp,dt as askBuoySettings,h as askBuoyStore,Xc as askBuoySyncAdapter,wo as askBuoyToolPreset,Yc as createAskBuoyTool,rr as hasTrace,Rt as redactForWire,bo as traceEntries,nr as traceToText,er as useAskBuoy,tt as useAskBuoySettings,fo as useAskBuoyState,K as useBlockHandlers};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/ask-buoy",
3
- "version": "7.0.39",
3
+ "version": "7.0.41",
4
4
  "description": "In-app AI chat for supported Buoy inspection and action tools, using a configured model endpoint.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -13,7 +13,8 @@
13
13
  "sideEffects": [
14
14
  "./src/index.tsx",
15
15
  "./lib/commonjs/index.js",
16
- "./lib/module/index.js"
16
+ "./lib/module/index.js",
17
+ "./lib/web/**/*.mjs"
17
18
  ],
18
19
  "keywords": [
19
20
  "react-native",
@@ -24,27 +25,38 @@
24
25
  "buoy"
25
26
  ],
26
27
  "dependencies": {
27
- "@buoy-gg/agent-core": "^7.0.39",
28
- "@buoy-gg/floating-tools-core": "^7.0.39",
29
- "@buoy-gg/shared-ui": "^7.0.39"
28
+ "@buoy-gg/agent-core": "^7.0.41",
29
+ "@buoy-gg/floating-tools-core": "^7.0.41",
30
+ "@buoy-gg/shared-ui": "^7.0.41"
30
31
  },
31
32
  "peerDependencies": {
32
- "@buoy-gg/license": "7.0.39",
33
+ "@buoy-gg/license": "7.0.41",
33
34
  "react": "*",
34
35
  "react-native": "*",
35
- "@buoy-gg/core": "^7.0.39"
36
+ "react-native-web": "^0.21.0",
37
+ "react-dom": ">=18",
38
+ "@buoy-gg/core": "^7.0.41"
36
39
  },
37
40
  "peerDependenciesMeta": {
38
41
  "@buoy-gg/core": {
39
42
  "optional": true
43
+ },
44
+ "react-native": {
45
+ "optional": true
46
+ },
47
+ "react-native-web": {
48
+ "optional": true
49
+ },
50
+ "react-dom": {
51
+ "optional": true
40
52
  }
41
53
  },
42
54
  "devDependencies": {
43
55
  "@types/react": "^19.1.0",
44
56
  "@types/react-native": "^0.73.0",
45
57
  "typescript": "~5.8.3",
46
- "@buoy-gg/license": "^7.0.39",
47
- "@buoy-gg/core": "^7.0.39"
58
+ "@buoy-gg/core": "^7.0.41",
59
+ "@buoy-gg/license": "^7.0.41"
48
60
  },
49
61
  "react-native-builder-bob": {
50
62
  "source": "src",
@@ -73,11 +85,32 @@
73
85
  "access": "public",
74
86
  "tag": "latest"
75
87
  },
88
+ "exports": {
89
+ ".": {
90
+ "browser": {
91
+ "types": "./lib/typescript/index.d.ts",
92
+ "default": "./lib/web/index.mjs"
93
+ },
94
+ "import": {
95
+ "types": "./lib/typescript/index.d.ts",
96
+ "default": "./lib/module/index.js"
97
+ },
98
+ "require": {
99
+ "types": "./lib/typescript/index.d.ts",
100
+ "default": "./lib/commonjs/index.js"
101
+ }
102
+ },
103
+ "./web": {
104
+ "types": "./lib/typescript/index.d.ts",
105
+ "default": "./lib/web/index.mjs"
106
+ }
107
+ },
76
108
  "scripts": {
77
- "build": "bob build",
109
+ "build": "bob build && pnpm run build:web",
78
110
  "typecheck": "tsc --noEmit",
79
111
  "clean": "rimraf lib",
80
112
  "test": "pnpm run typecheck",
81
- "postinstall": "echo \"Run pnpm build to compile this package\""
113
+ "postinstall": "echo \"Run pnpm build to compile this package\"",
114
+ "build:web": "node ../../scripts/build-web.mjs ask-buoy"
82
115
  }
83
116
  }