@buoy-gg/core 7.0.48 → 7.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useDevToolsSettings=exports.DevToolsSettingsModal=void 0;var _react=require("react");var _reactNative=require("react-native");var _settingsBus=require("./settingsBus.js");var _useDesktopSyncStatus=require("./useDesktopSyncStatus");var _sharedUi=require("@buoy-gg/shared-ui");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _AppIcon=require("./AppIcon");var _jsxRuntime=require("react/jsx-runtime");const STORAGE_KEY="@react_buoy_dev_tools_settings";const MAX_DIAL_SLOTS=6;const enforceDialLimit=r=>{let a=MAX_DIAL_SLOTS;const n={};for(const[c,s]of Object.entries(r)){if(s&&a>0){n[c]=true;a-=1}else{n[c]=false}}return n};const sanitizeFloating=(r,a)=>{const{userStatus:n,environment:c,...s}=r;const l=a?Object.entries(s).filter(([d])=>a.includes(d)):Object.entries(s);return{...Object.fromEntries(l),environment:c??false}};const mergeWithDefaults=(r,a,n)=>{if(!a)return r;const c={...r.dialTools,...a.dialTools??{}};const s=n?.allowedDialKeys?Object.entries(c).filter(([d])=>n.allowedDialKeys?.includes(d)):Object.entries(c);const l=enforceDialLimit(Object.fromEntries(s));return{dialTools:l,floatingTools:sanitizeFloating({...r.floatingTools,...a.floatingTools??{}},n?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...a.globalSettings??{}}}};const generateDefaultSettings=(r=[],a,n)=>{const c={};const s={};const l=new Set(a??[]);const d=new Set(n??[]);const g=!n||n.length===0;for(const x of r){const{id:i,slot:S="both"}=x;if(S==="dial"||S==="both"){c[i]=g?true:d.has(i)}if(S==="row"||S==="both"){s[i]=l.has(i)}}return{dialTools:enforceDialLimit(c),floatingTools:{...s,environment:l.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}};const DevToolsSettingsModal=({visible:r,onClose:a,onSettingsChange:n,initialSettings:c,availableApps:s=[],storage:l=_sharedUi.persistentStorage,zIndex:d})=>{const{defaultFloatingTools:g,defaultDialTools:x}=(0,_DefaultConfigContext.useDefaultConfig)();const i=(0,_react.useMemo)(()=>generateDefaultSettings(s,g,x),[s,g,x]);const S=(0,_react.useMemo)(()=>Object.keys(i.dialTools),[i]);const E=(0,_react.useMemo)(()=>Object.keys(i.floatingTools).filter(e=>e!=="environment"),[i]);const[f,b]=(0,_react.useState)(c||cachedSettings||i);const[w,F]=(0,_react.useState)(cachedActiveTab??"floating");const[N,G]=(0,_react.useState)(cachedActiveTab!==null);const[C,Y]=(0,_react.useState)(new Set);const[$,I]=(0,_react.useState)(false);const[Q,X]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{const e=requestAnimationFrame(()=>X(true));return()=>cancelAnimationFrame(e)},[]);const h=(0,_useDesktopSyncStatus.useDesktopSyncStatus)();(0,_react.useEffect)(()=>{const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.settings.activeTab());if(t&&["floating","settings","pro"].includes(t)){const o=t;cachedActiveTab=o;F(y=>y===o?y:o)}}catch(t){}finally{G(true)}};e()},[]);(0,_react.useEffect)(()=>{if(!N)return;_sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.settings.activeTab(),w).catch(e=>{console.warn("Failed to save settings active tab:",e)})},[w,N]);const Z=(0,_sharedUi.getUseLicense)();const m=Z?.();const j=m?.isPro??false;const z=!j&&m?.licenseKey?m.error:null;const ee=m?.errorKind==="transport";const[u,te]=(0,_react.useState)(cachedStorageBackend);const[B,O]=(0,_react.useState)(false);const[D,L]=(0,_react.useState)(false);const[T,oe]=(0,_react.useState)(false);const[R,k]=(0,_react.useState)([]);const[V,P]=(0,_react.useState)(false);const M=(0,_sharedUi.useSafeAreaInsets)();const H=_reactNative.Dimensions.get("window").height;const K=_reactNative.Dimensions.get("window").width;const ne=Math.floor(H*.33);const se=Math.min(K-32,400);const _=(0,_react.useCallback)(async()=>{try{const e=await l.getItem(STORAGE_KEY);if(e){const t=JSON.parse(e);const o=mergeWithDefaults(i,t,{allowedDialKeys:S,allowedFloatingKeys:E});cachedSettings=o;b(y=>sameSettings(y,o)?y:o);return}cachedSettings=i;b(t=>sameSettings(t,i)?t:i)}catch(e){console.error("Failed to load dev tools settings:",e);b(i)}},[i,S,E,l]);(0,_react.useEffect)(()=>{_()},[_]);(0,_react.useEffect)(()=>{(0,_sharedUi.getStorageBackendType)().then(e=>{cachedStorageBackend=e;te(t=>t===e?t:e)})},[]);(0,_react.useEffect)(()=>{if(T){P(true);_sharedUi.persistentStorage.getAllKeys().then(e=>{k(e.sort())}).catch(()=>{k([])}).finally(()=>{P(false)})}},[T]);const A=async e=>{try{const t={...e,dialTools:enforceDialLimit(e.dialTools)};await l.setItem(STORAGE_KEY,JSON.stringify(t));cachedSettings=t;b(t);n?.(t);_settingsBus.settingsBus.emit(t)}catch(t){console.error("Failed to save dev tools settings:",t)}};const ie=e=>{const t={...f,floatingTools:{...f.floatingTools,[e]:!f.floatingTools[e]}};A(t)};const re=e=>{const t={...f,globalSettings:{...f.globalSettings,[e]:!f.globalSettings?.[e]}};A(t)};const ae=async()=>{O(true);L(false);try{await _sharedUi.persistentStorage.clear();L(true);b(i);if(l!==_sharedUi.persistentStorage)await l.setItem(STORAGE_KEY,JSON.stringify(i));n?.(i);_settingsBus.settingsBus.emit(i);setTimeout(()=>L(false),2e3)}catch(e){console.error("Failed to clear storage:",e)}finally{O(false)}};const le=(0,_react.useCallback)(e=>{},[]);const ce=e=>{const t=s.find(o=>o.id===e);if(t?.description){return t.description}if(e==="environment"){return"Environment badge."}return""};const W=e=>{if(e==="environment"){return"Env Badge"}const t=s.find(o=>o.id===e);return t?.name??e.toUpperCase().replace(/_/g," ")};const de=e=>{if(!Q)return null;switch(e){case"query":return(0,_jsxRuntime.jsx)(_floatingToolsCore.QueryIcon,{size:18});case"env":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"sentry":return(0,_jsxRuntime.jsx)(_sharedUi.SentryIcon,{size:18,color:"#9945FF"});case"storage":return(0,_jsxRuntime.jsx)(_floatingToolsCore.StorageIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"wifi":case"query-wifi-toggle":return(0,_jsxRuntime.jsx)(_sharedUi.WifiCircuitIcon,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.RoutesIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"network":return(0,_jsxRuntime.jsx)(_floatingToolsCore.NetworkIcon,{size:18});case"environment":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"debug-borders":return(0,_jsxRuntime.jsx)(_sharedUi.Layers,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates":return(0,_jsxRuntime.jsx)(_sharedUi.RenderCountIcon,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates-modal":return(0,_jsxRuntime.jsx)(_floatingToolsCore.HighlighterIcon,{size:18});case"redux":return(0,_jsxRuntime.jsx)(_floatingToolsCore.ReduxIcon,{size:18});case"image-overlay":return(0,_jsxRuntime.jsx)(_sharedUi.ImageOverlayIcon,{size:18});case"events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EventsIcon,{size:18});case"zustand":try{const{ZustandIcon:t}=require("@buoy-gg/zustand");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}case"jotai":try{const{JotaiIcon:t}=require("@buoy-gg/jotai");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}default:{const t=s.find(o=>o.id===e);if(t?.icon!=null){return(0,_AppIcon.renderAppIcon)(t.icon,{slot:"row",size:18,color:t.color})}return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}}};const ge=(e,t,o,y)=>{const v=ce(e);return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:o?1:.7,onPress:()=>!o&&y(),accessibilityLabel:W(e),accessibilityRole:"button",style:[styles.toolRow,o&&styles.rowDisabled],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.toolIconSlot,children:de(e)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.rowLabel,children:[W(e),o?" \xB7 max 6":""]}),v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:1,children:v}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:t,disabled:o,onValueChange:()=>y()})]},e)};const q=e=>{Y(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})};const J=(e,t,o,y,v)=>{const ye=f.globalSettings?.[e]??false;const U=C.has(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q(e),accessibilityLabel:t,style:styles.settingRow,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:t}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:U?0:1,children:o})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:ye,onValueChange:()=>re(e)})]}),U&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:y}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyHint,children:v})]})]},e)};const p=(e,t,o)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:e}),t,o]});const he=u==="filesystem"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"File System",tone:"accent"}):u==="asyncstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Async Storage",tone:"warning"}):u==="localstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Local Storage",tone:"accent"}):u==="memory"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Memory",tone:"danger"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Loading\u2026",tone:"neutral"});const ue=()=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:styles.scrollContainer,children:[w==="floating"&&(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:p("Floating Tools",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:Object.entries(f.floatingTools).map(([e,t])=>ge(e,t,false,()=>ie(e)))})}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:"Tools switched on here appear in the floating bubble row."}))}),w==="settings"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("Background",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,padded:true,children:(0,_jsxRuntime.jsx)(_sharedUi.BackgroundSwitcher,{embedded:true})})),p("Storage",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>oe(!T),accessibilityLabel:"Storage Type",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Storage Type"})}),he,T?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),T&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:u==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":u==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":u==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":u==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),u==="asyncstorage"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),u==="memory"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSeparator,{}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpanded,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpandedHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedTitle,children:"SAVED SETTINGS"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedCount,children:V?"\u2026":`${R.length} keys`})]}),V?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"Loading\u2026"}):R.length===0?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"No settings saved yet"}):(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:R.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.storageKeyItem,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyText,numberOfLines:1,children:e.replace("@react_buoy_","")})},e))})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.cardButtonWrap,children:(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:D?"Cleared":B?"Clearing\u2026":"Clear All Settings",variant:D?"secondary":"destructive",size:"md",disabled:B,onPress:ae,icon:D?(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:15,color:_sharedUi.night.color.accent}):(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:15,color:B?_sharedUi.night.color.textTertiary:_sharedUi.night.color.danger})})})]})]})),h&&h.state!=="idle"&&p("Desktop Sync",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q("desktopSync"),accessibilityLabel:"Buoy Desktop",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Buoy Desktop"})}),h.state==="connected"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connected",tone:"accent"}):h.state==="connecting"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connecting\u2026",tone:"neutral"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Retrying",tone:"warning"}),C.has("desktopSync")?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),C.has("desktopSync")&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.settingRowBodyText,children:[h.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.footnoteMono,children:h.targetURL??"(unknown URL)"}),h.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),h.state==="retrying"&&h.lastError&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:["Last error: ",h.lastError]})]})]})),p("Modal Behavior",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[J("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),_reactNative.Platform.OS!=="web"?J("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),w==="pro"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("License",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"License Status"})}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"buoy-settings-license-status",accessibilityLabel:j?"License: Active":"License: Free",children:j?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Active",tone:"accent"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Free",tone:"neutral"})})]}),m?.tierSource==="session"?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Signed in with Buoy"})}),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void(0,_sharedUi.signOutOfBuoy)(),testID:"buoy-settings-signout"})]}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:j?"You have full access to all Buoy DevTools features.":z?ee?`Couldn't reach the license server (${z}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${z}.`:"Upgrade to Pro to unlock all features and support development."})),!j&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("Pro Features",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:["Advanced Settings","Priority Support"].map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.featureRow,children:[(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:16,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:e})]},e))})})),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>I(true)})]})]})]}),(0,_jsxRuntime.jsx)(_sharedUi.LicenseEntryModal,{visible:$,onClose:()=>I(false),onSuccess:()=>I(false)})]});return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:r,onClose:a,zIndex:d,variant:"night",header:{showToggleButton:false,customContent:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerRow,children:(0,_jsxRuntime.jsx)(_sharedUi.NightSegmented,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:w,onChange:e=>F(e)})})},initialMode:"bottomSheet",onModeChange:le,persistenceKey:_sharedUi.devToolsStorageKeys.settings.root(),enablePersistence:true,maxHeight:H-M.top,initialHeight:ne,initialFloatingPosition:{x:(K-se)/2,y:M.top+20},enableGlitchEffects:true,children:ue()})};exports.DevToolsSettingsModal=DevToolsSettingsModal;const basicDefaultSettings={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}};const createDefaultsFromConfig=(r,a)=>{const n=new Set(r??[]);const c=new Set(a??[]);const s={};for(const d of c){s[d]=true}const l={environment:n.has("environment")};for(const d of n){if(d!=="environment"){l[d]=true}}return{dialTools:enforceDialLimit(s),floatingTools:l,globalSettings:{enableSharedModalDimensions:false}}};let cachedSettings=null;let cachedActiveTab=null;let cachedStorageBackend=null;const sameSettings=(r,a)=>JSON.stringify(r)===JSON.stringify(a);_settingsBus.settingsBus.addListener(r=>{if(r)cachedSettings=r});const useDevToolsSettings=()=>{const{defaultFloatingTools:r,defaultDialTools:a}=(0,_DefaultConfigContext.useDefaultConfig)();const n=(0,_react.useMemo)(()=>{if(!r&&!a){return basicDefaultSettings}return createDefaultsFromConfig(r,a)},[r,a]);const[c,s]=(0,_react.useState)(n);const l=(0,_react.useCallback)(async()=>{try{const g=await _sharedUi.persistentStorage.getItem(STORAGE_KEY);if(g){const x=JSON.parse(g);const i=mergeWithDefaults(n,x);s(i);return}s(n)}catch(g){console.error("Failed to load dev tools settings:",g);s(n)}},[n]);(0,_react.useEffect)(()=>{l();const g=_settingsBus.settingsBus.addListener(x=>{try{if(x){s(x)}}catch(i){}});return()=>{g()}},[l]);const d=(0,_react.useCallback)(()=>{l()},[l]);return{settings:c,refreshSettings:d}};exports.useDevToolsSettings=useDevToolsSettings;const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:_sharedUi.night.gutter,paddingRight:_sharedUi.night.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:8,paddingBottom:24,gap:_sharedUi.night.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:_sharedUi.night.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,fontWeight:"500"},rowCaption:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.label},settingRowBody:{paddingHorizontal:_sharedUi.night.rowPadH,paddingBottom:_sharedUi.night.rowPadV,gap:6},settingRowBodyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},settingRowBodyHint:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},bodyWarning:{color:_sharedUi.night.color.warning},bodyDanger:{color:_sharedUi.night.color.danger},cardButtonWrap:{paddingHorizontal:_sharedUi.night.cardPad,paddingTop:10,paddingBottom:_sharedUi.night.cardPad},storageExpanded:{paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:_sharedUi.night.color.glassElevated,borderRadius:_sharedUi.night.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontFamily:_sharedUi.monoFont},storageKeyEmpty:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:_sharedUi.monoFont,fontSize:_sharedUi.night.font.label,color:_sharedUi.night.color.textSecondary}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useDevToolsSettings=exports.DevToolsSettingsModal=void 0;var _react=require("react");var _reactNative=require("react-native");var _settingsBus=require("./settingsBus.js");var _useDesktopSyncStatus=require("./useDesktopSyncStatus");var _sharedUi=require("@buoy-gg/shared-ui");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _AppIcon=require("./AppIcon");var _jsxRuntime=require("react/jsx-runtime");const STORAGE_KEY="@react_buoy_dev_tools_settings";const MAX_DIAL_SLOTS=6;const enforceDialLimit=r=>{let a=MAX_DIAL_SLOTS;const n={};for(const[c,s]of Object.entries(r)){if(s&&a>0){n[c]=true;a-=1}else{n[c]=false}}return n};const sanitizeFloating=(r,a)=>{const{userStatus:n,environment:c,...s}=r;const l=a?Object.entries(s).filter(([d])=>a.includes(d)):Object.entries(s);return{...Object.fromEntries(l),environment:c??false}};const mergeWithDefaults=(r,a,n)=>{if(!a)return r;const c={...r.dialTools,...a.dialTools??{}};const s=n?.allowedDialKeys?Object.entries(c).filter(([d])=>n.allowedDialKeys?.includes(d)):Object.entries(c);const l=enforceDialLimit(Object.fromEntries(s));return{dialTools:l,floatingTools:sanitizeFloating({...r.floatingTools,...a.floatingTools??{}},n?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...a.globalSettings??{}}}};const generateDefaultSettings=(r=[],a,n)=>{const c={};const s={};const l=new Set(a??[]);const d=new Set(n??[]);const g=!n||n.length===0;for(const x of r){const{id:i,slot:S="both"}=x;if(S==="dial"||S==="both"){c[i]=g?true:d.has(i)}if(S==="row"||S==="both"){s[i]=l.has(i)}}return{dialTools:enforceDialLimit(c),floatingTools:{...s,environment:l.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}};const DevToolsSettingsModal=({visible:r,onClose:a,onSettingsChange:n,initialSettings:c,availableApps:s=[],storage:l=_sharedUi.persistentStorage,zIndex:d})=>{const{defaultFloatingTools:g,defaultDialTools:x}=(0,_DefaultConfigContext.useDefaultConfig)();const i=(0,_react.useMemo)(()=>generateDefaultSettings(s,g,x),[s,g,x]);const S=(0,_react.useMemo)(()=>Object.keys(i.dialTools),[i]);const R=(0,_react.useMemo)(()=>Object.keys(i.floatingTools).filter(e=>e!=="environment"),[i]);const[f,b]=(0,_react.useState)(c||cachedSettings||i);const[w,F]=(0,_react.useState)(cachedActiveTab??"floating");const[N,G]=(0,_react.useState)(cachedActiveTab!==null);const[C,Y]=(0,_react.useState)(new Set);const[$,I]=(0,_react.useState)(false);const[Q,X]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{const e=requestAnimationFrame(()=>X(true));return()=>cancelAnimationFrame(e)},[]);const h=(0,_useDesktopSyncStatus.useDesktopSyncStatus)();(0,_react.useEffect)(()=>{const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.settings.activeTab());if(t&&["floating","settings","pro"].includes(t)){const o=t;cachedActiveTab=o;F(y=>y===o?y:o)}}catch(t){}finally{G(true)}};e()},[]);(0,_react.useEffect)(()=>{if(!N)return;_sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.settings.activeTab(),w).catch(e=>{console.warn("Failed to save settings active tab:",e)})},[w,N]);const Z=(0,_sharedUi.getUseLicense)();const m=Z?.();const j=m?.isPro??false;const z=!j&&m?.licenseKey?m.error:null;const ee=m?.errorKind==="transport";const[u,te]=(0,_react.useState)(cachedStorageBackend);const[B,O]=(0,_react.useState)(false);const[D,L]=(0,_react.useState)(false);const[T,oe]=(0,_react.useState)(false);const[E,k]=(0,_react.useState)([]);const[V,P]=(0,_react.useState)(false);const M=(0,_sharedUi.useSafeAreaInsets)();const H=_reactNative.Dimensions.get("window").height;const K=_reactNative.Dimensions.get("window").width;const ne=Math.floor(H*.33);const se=Math.min(K-32,400);const _=(0,_react.useCallback)(async()=>{try{const e=await l.getItem(STORAGE_KEY);if(e){const t=JSON.parse(e);const o=mergeWithDefaults(i,t,{allowedDialKeys:S,allowedFloatingKeys:R});cachedSettings=o;b(y=>sameSettings(y,o)?y:o);return}cachedSettings=i;b(t=>sameSettings(t,i)?t:i)}catch(e){console.error("Failed to load dev tools settings:",e);b(i)}},[i,S,R,l]);(0,_react.useEffect)(()=>{_()},[_]);(0,_react.useEffect)(()=>{(0,_sharedUi.getStorageBackendType)().then(e=>{cachedStorageBackend=e;te(t=>t===e?t:e)})},[]);(0,_react.useEffect)(()=>{if(T){P(true);_sharedUi.persistentStorage.getAllKeys().then(e=>{k(e.sort())}).catch(()=>{k([])}).finally(()=>{P(false)})}},[T]);const A=async e=>{try{const t={...e,dialTools:enforceDialLimit(e.dialTools)};await l.setItem(STORAGE_KEY,JSON.stringify(t));cachedSettings=t;b(t);n?.(t);_settingsBus.settingsBus.emit(t)}catch(t){console.error("Failed to save dev tools settings:",t)}};const ie=e=>{const t={...f,floatingTools:{...f.floatingTools,[e]:!f.floatingTools[e]}};A(t)};const re=e=>{const t={...f,globalSettings:{...f.globalSettings,[e]:!f.globalSettings?.[e]}};A(t)};const ae=async()=>{O(true);L(false);try{await _sharedUi.persistentStorage.clear();L(true);b(i);if(l!==_sharedUi.persistentStorage)await l.setItem(STORAGE_KEY,JSON.stringify(i));n?.(i);_settingsBus.settingsBus.emit(i);setTimeout(()=>L(false),2e3)}catch(e){console.error("Failed to clear storage:",e)}finally{O(false)}};const le=(0,_react.useCallback)(e=>{},[]);const ce=e=>{const t=s.find(o=>o.id===e);if(t?.description){return t.description}if(e==="environment"){return"Environment badge."}return""};const W=e=>{if(e==="environment"){return"Env Badge"}const t=s.find(o=>o.id===e);return t?.name??e.toUpperCase().replace(/_/g," ")};const de=e=>{if(!Q)return null;switch(e){case"query":return(0,_jsxRuntime.jsx)(_floatingToolsCore.QueryIcon,{size:18});case"env":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"sentry":return(0,_jsxRuntime.jsx)(_sharedUi.SentryIcon,{size:18,color:"#9945FF"});case"storage":return(0,_jsxRuntime.jsx)(_floatingToolsCore.StorageIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"wifi":case"query-wifi-toggle":return(0,_jsxRuntime.jsx)(_sharedUi.WifiCircuitIcon,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.RoutesIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"network":return(0,_jsxRuntime.jsx)(_floatingToolsCore.NetworkIcon,{size:18});case"environment":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"debug-borders":return(0,_jsxRuntime.jsx)(_sharedUi.Layers,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates":return(0,_jsxRuntime.jsx)(_sharedUi.RenderCountIcon,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates-modal":return(0,_jsxRuntime.jsx)(_floatingToolsCore.HighlighterIcon,{size:18});case"redux":return(0,_jsxRuntime.jsx)(_floatingToolsCore.ReduxIcon,{size:18});case"image-overlay":return(0,_jsxRuntime.jsx)(_sharedUi.ImageOverlayIcon,{size:18});case"events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EventsIcon,{size:18});case"zustand":try{const{ZustandIcon:t}=require("@buoy-gg/zustand");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}case"jotai":try{const{JotaiIcon:t}=require("@buoy-gg/jotai");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}default:{const t=s.find(o=>o.id===e);if(t?.icon!=null){return(0,_AppIcon.renderAppIcon)(t.icon,{slot:"row",size:18,color:t.color})}return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}}};const ge=(e,t,o,y)=>{const v=ce(e);return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:o?1:.7,onPress:()=>!o&&y(),accessibilityLabel:W(e),accessibilityRole:"button",style:[styles.toolRow,o&&styles.rowDisabled],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.toolIconSlot,children:de(e)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.rowLabel,children:[W(e),o?" \xB7 max 6":""]}),v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:1,children:v}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:t,disabled:o,onValueChange:()=>y()})]},e)};const q=e=>{Y(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})};const J=(e,t,o,y,v)=>{const ye=f.globalSettings?.[e]??false;const U=C.has(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q(e),accessibilityLabel:t,style:styles.settingRow,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:t}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:U?0:1,children:o})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:ye,onValueChange:()=>re(e)})]}),U&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:y}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyHint,children:v})]})]},e)};const p=(e,t,o)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:e}),t,o]});const he=u==="filesystem"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"File System",tone:"accent"}):u==="asyncstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Async Storage",tone:"warning"}):u==="localstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Local Storage",tone:"accent"}):u==="memory"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Memory",tone:"danger"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Loading\u2026",tone:"neutral"});const ue=()=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:styles.scrollContainer,children:[w==="floating"&&(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:p("Floating Tools",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:Object.entries(f.floatingTools).map(([e,t])=>ge(e,t,false,()=>ie(e)))})}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:"Tools switched on here appear in the floating bubble row."}))}),w==="settings"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("Background",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,padded:true,children:(0,_jsxRuntime.jsx)(_sharedUi.BackgroundSwitcher,{embedded:true})})),p("Storage",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>oe(!T),accessibilityLabel:"Storage Type",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Storage Type"})}),he,T?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),T&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:u==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":u==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":u==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":u==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),u==="asyncstorage"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),u==="memory"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSeparator,{}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpanded,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpandedHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedTitle,children:"SAVED SETTINGS"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedCount,children:V?"\u2026":`${E.length} keys`})]}),V?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"Loading\u2026"}):E.length===0?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"No settings saved yet"}):(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:E.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.storageKeyItem,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyText,numberOfLines:1,children:e.replace("@react_buoy_","")})},e))})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.cardButtonWrap,children:(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:D?"Cleared":B?"Clearing\u2026":"Clear All Settings",variant:D?"secondary":"destructive",size:"md",disabled:B,onPress:ae,icon:D?(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:15,color:_sharedUi.night.color.accent}):(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:15,color:B?_sharedUi.night.color.textTertiary:_sharedUi.night.color.danger})})})]})]})),h&&h.state!=="idle"&&p("Desktop Sync",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q("desktopSync"),accessibilityLabel:"Buoy Desktop",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Buoy Desktop"})}),h.state==="connected"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connected",tone:"accent"}):h.state==="connecting"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connecting\u2026",tone:"neutral"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Retrying",tone:"warning"}),C.has("desktopSync")?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),C.has("desktopSync")&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.settingRowBodyText,children:[h.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.footnoteMono,children:h.targetURL??"(unknown URL)"}),h.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),h.state==="retrying"&&h.lastError&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:["Last error: ",h.lastError]})]})]})),p("Modal Behavior",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[J("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),_reactNative.Platform.OS!=="web"?J("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),w==="pro"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("License",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"License Status"})}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"buoy-settings-license-status",accessibilityLabel:j?"License: Active":"License: Free",children:j?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Active",tone:"accent"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Free",tone:"neutral"})})]}),m?.tierSource==="session"?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Signed in with Buoy"})}),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void(0,_sharedUi.signOutOfBuoy)(),testID:"buoy-settings-signout"})]}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:j?"You have full access to all Buoy DevTools features.":z?ee?`Couldn't reach the license server (${z}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${z}.`:"Upgrade to Pro to unlock all features and support development."})),!j&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("Pro Features",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:["Advanced Settings","Priority Support"].map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.featureRow,children:[(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:16,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:e})]},e))})})),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>I(true)})]})]})]}),(0,_jsxRuntime.jsx)(_sharedUi.LicenseEntryModal,{visible:$,onClose:()=>I(false),onSuccess:()=>I(false)})]});return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:r,onClose:a,zIndex:d,variant:"night",header:{showToggleButton:false,customContent:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerRow,children:(0,_jsxRuntime.jsx)(_sharedUi.NightSegmented,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:w,onChange:e=>F(e)})})},initialMode:"bottomSheet",onModeChange:le,persistenceKey:_sharedUi.devToolsStorageKeys.settings.root(),enablePersistence:true,maxHeight:H-M.top,initialHeight:ne,initialFloatingPosition:{x:(K-se)/2,y:M.top+20},enableGlitchEffects:true,children:ue()})};exports.DevToolsSettingsModal=DevToolsSettingsModal;const basicDefaultSettings={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}};const createDefaultsFromConfig=(r,a)=>{const n=new Set(r??[]);const c=new Set(a??[]);const s={};for(const d of c){s[d]=true}const l={environment:n.has("environment")};for(const d of n){if(d!=="environment"){l[d]=true}}return{dialTools:enforceDialLimit(s),floatingTools:l,globalSettings:{enableSharedModalDimensions:false}}};let cachedSettings=null;let cachedActiveTab=null;let cachedStorageBackend=null;const sameSettings=(r,a)=>JSON.stringify(r)===JSON.stringify(a);_settingsBus.settingsBus.addListener(r=>{if(r)cachedSettings=r});const useDevToolsSettings=()=>{const{defaultFloatingTools:r,defaultDialTools:a}=(0,_DefaultConfigContext.useDefaultConfig)();const n=(0,_react.useMemo)(()=>{if(!r&&!a){return basicDefaultSettings}return createDefaultsFromConfig(r,a)},[r,a]);const[c,s]=(0,_react.useState)(n);const l=(0,_react.useCallback)(async()=>{try{const g=await _sharedUi.persistentStorage.getItem(STORAGE_KEY);if(g){const x=JSON.parse(g);const i=mergeWithDefaults(n,x);s(i);return}s(n)}catch(g){console.error("Failed to load dev tools settings:",g);s(n)}},[n]);(0,_react.useEffect)(()=>(0,_sharedUi.onSettingsApplied)(g=>{if(g.includes(STORAGE_KEY))void l()}),[l]);(0,_react.useEffect)(()=>{l();const g=_settingsBus.settingsBus.addListener(x=>{try{if(x){s(x)}}catch(i){}});return()=>{g()}},[l]);const d=(0,_react.useCallback)(()=>{l()},[l]);return{settings:c,refreshSettings:d}};exports.useDevToolsSettings=useDevToolsSettings;const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:_sharedUi.night.gutter,paddingRight:_sharedUi.night.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:8,paddingBottom:24,gap:_sharedUi.night.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:_sharedUi.night.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,fontWeight:"500"},rowCaption:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.label},settingRowBody:{paddingHorizontal:_sharedUi.night.rowPadH,paddingBottom:_sharedUi.night.rowPadV,gap:6},settingRowBodyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},settingRowBodyHint:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},bodyWarning:{color:_sharedUi.night.color.warning},bodyDanger:{color:_sharedUi.night.color.danger},cardButtonWrap:{paddingHorizontal:_sharedUi.night.cardPad,paddingTop:10,paddingBottom:_sharedUi.night.cardPad},storageExpanded:{paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:_sharedUi.night.color.glassElevated,borderRadius:_sharedUi.night.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontFamily:_sharedUi.monoFont},storageKeyEmpty:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:_sharedUi.monoFont,fontSize:_sharedUi.night.font.label,color:_sharedUi.night.color.textSecondary}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;const SDK_VERSION=exports.SDK_VERSION="7.0.48";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;const SDK_VERSION=exports.SDK_VERSION="7.0.49";
@@ -1 +1 @@
1
- "use strict";import{useState as m,useEffect as L,useCallback as K,useMemo as W}from"react";import{View as u,Text as y,StyleSheet as Xe,ScrollView as Se,TouchableOpacity as j,Dimensions as be,Platform as Ze}from"react-native";import{settingsBus as A}from"./settingsBus.js";import{useDesktopSyncStatus as et}from"./useDesktopSyncStatus";import{SentryIcon as tt,WifiCircuitIcon as ot,ImageOverlayIcon as nt,RenderCountIcon as rt,Info as Q,Layers as st,ChevronRightIcon as we,ChevronDown as Te,getStorageBackendType as it,getUseLicense as at,signOutOfBuoy as lt,persistentStorage as D,Trash2 as ct,CheckCircle2 as ve,LicenseEntryModal as dt,BackgroundSwitcher as gt,night as o,NightCard as R,NightRows as X,NightSectionLabel as ut,NightFootnote as xe,NightSwitch as ze,NightButton as Z,NightSegmented as yt,NightBadge as v,NightSeparator as ht,monoFont as Ie}from"@buoy-gg/shared-ui";import{EnvIcon as Ce,StorageIcon as ft,RoutesIcon as pt,NetworkIcon as mt,QueryIcon as St,HighlighterIcon as bt,ReduxIcon as wt,EventsIcon as Tt}from"@buoy-gg/floating-tools-core";import{useDefaultConfig as Le}from"./DefaultConfigContext.js";import{renderAppIcon as vt}from"./AppIcon";import{JsModal as xt,devToolsStorageKeys as ee}from"@buoy-gg/shared-ui";import{useSafeAreaInsets as zt}from"@buoy-gg/shared-ui";import{jsx as e,jsxs as s,Fragment as P}from"react/jsx-runtime";const N="@react_buoy_dev_tools_settings";const It=6;const V=d=>{let g=It;const a={};for(const[f,l]of Object.entries(d)){if(l&&g>0){a[f]=true;g-=1}else{a[f]=false}}return a};const Ct=(d,g)=>{const{userStatus:a,environment:f,...l}=d;const h=g?Object.entries(l).filter(([p])=>g.includes(p)):Object.entries(l);return{...Object.fromEntries(h),environment:f??false}};const De=(d,g,a)=>{if(!g)return d;const f={...d.dialTools,...g.dialTools??{}};const l=a?.allowedDialKeys?Object.entries(f).filter(([p])=>a.allowedDialKeys?.includes(p)):Object.entries(f);const h=V(Object.fromEntries(l));return{dialTools:h,floatingTools:Ct({...d.floatingTools,...g.floatingTools??{}},a?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...g.globalSettings??{}}}};const Lt=(d=[],g,a)=>{const f={};const l={};const h=new Set(g??[]);const p=new Set(a??[]);const S=!a||a.length===0;for(const x of d){const{id:c,slot:I="both"}=x;if(I==="dial"||I==="both"){f[c]=S?true:p.has(c)}if(I==="row"||I==="both"){l[c]=h.has(c)}}return{dialTools:V(f),floatingTools:{...l,environment:h.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}};export const DevToolsSettingsModal=({visible:d,onClose:g,onSettingsChange:a,initialSettings:f,availableApps:l=[],storage:h=D,zIndex:p})=>{const{defaultFloatingTools:S,defaultDialTools:x}=Le();const c=W(()=>Lt(l,S,x),[l,S,x]);const I=W(()=>Object.keys(c.dialTools),[c]);const oe=W(()=>Object.keys(c.floatingTools).filter(t=>t!=="environment"),[c]);const[z,E]=m(f||H||c);const[B,ne]=m(te??"floating");const[re,Ee]=m(te!==null);const[_,Fe]=m(new Set);const[Oe,J]=m(false);const[ke,Pe]=m(false);L(()=>{const t=requestAnimationFrame(()=>Pe(true));return()=>cancelAnimationFrame(t)},[]);const b=et();L(()=>{const t=async()=>{try{const r=await D.getItem(ee.settings.activeTab());if(r&&["floating","settings","pro"].includes(r)){const i=r;te=i;ne(T=>T===i?T:i)}}catch(r){}finally{Ee(true)}};t()},[]);L(()=>{if(!re)return;D.setItem(ee.settings.activeTab(),B).catch(t=>{console.warn("Failed to save settings active tab:",t)})},[B,re]);const He=at();const F=He?.();const O=F?.isPro??false;const U=!O&&F?.licenseKey?F.error:null;const Me=F?.errorKind==="transport";const[w,Ke]=m(Re);const[G,se]=m(false);const[q,Y]=m(false);const[k,We]=m(false);const[$,ie]=m([]);const[ae,le]=m(false);const ce=zt();const de=be.get("window").height;const ge=be.get("window").width;const je=Math.floor(de*.33);const Ae=Math.min(ge-32,400);const ue=K(async()=>{try{const t=await h.getItem(N);if(t){const r=JSON.parse(t);const i=De(c,r,{allowedDialKeys:I,allowedFloatingKeys:oe});H=i;E(T=>Be(T,i)?T:i);return}H=c;E(r=>Be(r,c)?r:c)}catch(t){console.error("Failed to load dev tools settings:",t);E(c)}},[c,I,oe,h]);L(()=>{ue()},[ue]);L(()=>{it().then(t=>{Re=t;Ke(r=>r===t?r:t)})},[]);L(()=>{if(k){le(true);D.getAllKeys().then(t=>{ie(t.sort())}).catch(()=>{ie([])}).finally(()=>{le(false)})}},[k]);const ye=async t=>{try{const r={...t,dialTools:V(t.dialTools)};await h.setItem(N,JSON.stringify(r));H=r;E(r);a?.(r);A.emit(r)}catch(r){console.error("Failed to save dev tools settings:",r)}};const Ne=t=>{const r={...z,floatingTools:{...z.floatingTools,[t]:!z.floatingTools[t]}};ye(r)};const Ve=t=>{const r={...z,globalSettings:{...z.globalSettings,[t]:!z.globalSettings?.[t]}};ye(r)};const _e=async()=>{se(true);Y(false);try{await D.clear();Y(true);E(c);if(h!==D)await h.setItem(N,JSON.stringify(c));a?.(c);A.emit(c);setTimeout(()=>Y(false),2e3)}catch(t){console.error("Failed to clear storage:",t)}finally{se(false)}};const Je=K(t=>{},[]);const Ue=t=>{const r=l.find(i=>i.id===t);if(r?.description){return r.description}if(t==="environment"){return"Environment badge."}return""};const he=t=>{if(t==="environment"){return"Env Badge"}const r=l.find(i=>i.id===t);return r?.name??t.toUpperCase().replace(/_/g," ")};const Ge=t=>{if(!ke)return null;switch(t){case"query":return e(St,{size:18});case"env":return e(Ce,{size:18});case"sentry":return e(tt,{size:18,color:"#9945FF"});case"storage":return e(ft,{size:18,bgColor:o.color.surface});case"wifi":case"query-wifi-toggle":return e(ot,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return e(pt,{size:18,bgColor:o.color.surface});case"network":return e(mt,{size:18});case"environment":return e(Ce,{size:18});case"debug-borders":return e(st,{size:18,color:o.color.accent});case"highlight-updates":return e(rt,{size:18,color:o.color.accent});case"highlight-updates-modal":return e(bt,{size:18});case"redux":return e(wt,{size:18});case"image-overlay":return e(nt,{size:18});case"events":return e(Tt,{size:18});case"zustand":try{const{ZustandIcon:r}=require("@buoy-gg/zustand");return e(r,{size:18})}catch{return e(Q,{size:18,color:o.color.textSecondary})}case"jotai":try{const{JotaiIcon:r}=require("@buoy-gg/jotai");return e(r,{size:18})}catch{return e(Q,{size:18,color:o.color.textSecondary})}default:{const r=l.find(i=>i.id===t);if(r?.icon!=null){return vt(r.icon,{slot:"row",size:18,color:r.color})}return e(Q,{size:18,color:o.color.textSecondary})}}};const qe=(t,r,i,T)=>{const M=Ue(t);return s(j,{activeOpacity:i?1:.7,onPress:()=>!i&&T(),accessibilityLabel:he(t),accessibilityRole:"button",style:[n.toolRow,i&&n.rowDisabled],children:[e(u,{style:n.toolIconSlot,children:Ge(t)}),s(u,{style:n.rowInfo,children:[s(y,{style:n.rowLabel,children:[he(t),i?" \xB7 max 6":""]}),M?e(y,{style:n.rowCaption,numberOfLines:1,children:M}):null]}),e(ze,{value:r,disabled:i,onValueChange:()=>T()})]},t)};const fe=t=>{Fe(r=>{const i=new Set(r);if(i.has(t)){i.delete(t)}else{i.add(t)}return i})};const pe=(t,r,i,T,M)=>{const Qe=z.globalSettings?.[t]??false;const me=_.has(t);return s(u,{children:[s(j,{activeOpacity:.7,onPress:()=>fe(t),accessibilityLabel:r,style:n.settingRow,children:[s(u,{style:n.rowInfo,children:[e(y,{style:n.rowLabel,children:r}),e(y,{style:n.rowCaption,numberOfLines:me?0:1,children:i})]}),e(ze,{value:Qe,onValueChange:()=>Ve(t)})]}),me&&s(u,{style:n.settingRowBody,children:[e(y,{style:n.settingRowBodyText,children:T}),e(y,{style:n.settingRowBodyHint,children:M})]})]},t)};const C=(t,r,i)=>s(u,{children:[e(ut,{children:t}),r,i]});const Ye=w==="filesystem"?e(v,{label:"File System",tone:"accent"}):w==="asyncstorage"?e(v,{label:"Async Storage",tone:"warning"}):w==="localstorage"?e(v,{label:"Local Storage",tone:"accent"}):w==="memory"?e(v,{label:"Memory",tone:"danger"}):e(v,{label:"Loading\u2026",tone:"neutral"});const $e=()=>s(u,{style:n.container,children:[s(Se,{style:n.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:n.scrollContainer,children:[B==="floating"&&e(P,{children:C("Floating Tools",e(R,{glass:true,children:e(X,{children:Object.entries(z.floatingTools).map(([t,r])=>qe(t,r,false,()=>Ne(t)))})}),e(xe,{children:"Tools switched on here appear in the floating bubble row."}))}),B==="settings"&&s(P,{children:[C("Background",e(R,{glass:true,padded:true,children:e(gt,{embedded:true})})),C("Storage",s(R,{glass:true,children:[s(j,{activeOpacity:.7,onPress:()=>We(!k),accessibilityLabel:"Storage Type",style:n.settingRow,children:[e(u,{style:n.rowInfo,children:e(y,{style:n.rowLabel,children:"Storage Type"})}),Ye,k?e(Te,{size:16,color:o.color.textTertiary}):e(we,{size:16,color:o.color.textTertiary})]}),k&&s(P,{children:[s(u,{style:n.settingRowBody,children:[e(y,{style:n.settingRowBodyText,children:w==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":w==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":w==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":w==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),w==="asyncstorage"&&e(y,{style:[n.settingRowBodyText,n.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),w==="memory"&&e(y,{style:[n.settingRowBodyText,n.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),e(ht,{}),s(u,{style:n.storageExpanded,children:[s(u,{style:n.storageExpandedHeader,children:[e(y,{style:n.storageExpandedTitle,children:"SAVED SETTINGS"}),e(y,{style:n.storageExpandedCount,children:ae?"\u2026":`${$.length} keys`})]}),ae?e(y,{style:n.storageKeyEmpty,children:"Loading\u2026"}):$.length===0?e(y,{style:n.storageKeyEmpty,children:"No settings saved yet"}):e(Se,{style:n.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:$.map(t=>e(u,{style:n.storageKeyItem,children:e(y,{style:n.storageKeyText,numberOfLines:1,children:t.replace("@react_buoy_","")})},t))})]}),e(u,{style:n.cardButtonWrap,children:e(Z,{label:q?"Cleared":G?"Clearing\u2026":"Clear All Settings",variant:q?"secondary":"destructive",size:"md",disabled:G,onPress:_e,icon:q?e(ve,{size:15,color:o.color.accent}):e(ct,{size:15,color:G?o.color.textTertiary:o.color.danger})})})]})]})),b&&b.state!=="idle"&&C("Desktop Sync",s(R,{glass:true,children:[s(j,{activeOpacity:.7,onPress:()=>fe("desktopSync"),accessibilityLabel:"Buoy Desktop",style:n.settingRow,children:[e(u,{style:n.rowInfo,children:e(y,{style:n.rowLabel,children:"Buoy Desktop"})}),b.state==="connected"?e(v,{label:"Connected",tone:"accent"}):b.state==="connecting"?e(v,{label:"Connecting\u2026",tone:"neutral"}):e(v,{label:"Retrying",tone:"warning"}),_.has("desktopSync")?e(Te,{size:16,color:o.color.textTertiary}):e(we,{size:16,color:o.color.textTertiary})]}),_.has("desktopSync")&&s(u,{style:n.settingRowBody,children:[s(y,{style:n.settingRowBodyText,children:[b.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",e(y,{style:n.footnoteMono,children:b.targetURL??"(unknown URL)"}),b.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),b.state==="retrying"&&b.lastError&&s(y,{style:[n.settingRowBodyText,n.bodyWarning],children:["Last error: ",b.lastError]})]})]})),C("Modal Behavior",e(R,{glass:true,children:s(X,{children:[pe("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),Ze.OS!=="web"?pe("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),B==="pro"&&s(P,{children:[C("License",s(R,{glass:true,children:[s(u,{style:n.settingRow,children:[e(u,{style:n.rowInfo,children:e(y,{style:n.rowLabel,children:"License Status"})}),e(u,{testID:"buoy-settings-license-status",accessibilityLabel:O?"License: Active":"License: Free",children:O?e(v,{label:"Active",tone:"accent"}):e(v,{label:"Free",tone:"neutral"})})]}),F?.tierSource==="session"?s(u,{style:n.settingRow,children:[e(u,{style:n.rowInfo,children:e(y,{style:n.rowLabel,children:"Signed in with Buoy"})}),e(Z,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void lt(),testID:"buoy-settings-signout"})]}):null]}),e(xe,{children:O?"You have full access to all Buoy DevTools features.":U?Me?`Couldn't reach the license server (${U}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${U}.`:"Upgrade to Pro to unlock all features and support development."})),!O&&s(P,{children:[C("Pro Features",e(R,{glass:true,children:e(X,{children:["Advanced Settings","Priority Support"].map(t=>s(u,{style:n.featureRow,children:[e(ve,{size:16,color:o.color.accent}),e(y,{style:n.rowLabel,children:t})]},t))})})),e(Z,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>J(true)})]})]})]}),e(dt,{visible:Oe,onClose:()=>J(false),onSuccess:()=>J(false)})]});return e(xt,{visible:d,onClose:g,zIndex:p,variant:"night",header:{showToggleButton:false,customContent:e(u,{style:n.headerRow,children:e(yt,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:B,onChange:t=>ne(t)})})},initialMode:"bottomSheet",onModeChange:Je,persistenceKey:ee.settings.root(),enablePersistence:true,maxHeight:de-ce.top,initialHeight:je,initialFloatingPosition:{x:(ge-Ae)/2,y:ce.top+20},enableGlitchEffects:true,children:$e()})};const Dt={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}};const Rt=(d,g)=>{const a=new Set(d??[]);const f=new Set(g??[]);const l={};for(const p of f){l[p]=true}const h={environment:a.has("environment")};for(const p of a){if(p!=="environment"){h[p]=true}}return{dialTools:V(l),floatingTools:h,globalSettings:{enableSharedModalDimensions:false}}};let H=null;let te=null;let Re=null;const Be=(d,g)=>JSON.stringify(d)===JSON.stringify(g);A.addListener(d=>{if(d)H=d});export const useDevToolsSettings=()=>{const{defaultFloatingTools:d,defaultDialTools:g}=Le();const a=W(()=>{if(!d&&!g){return Dt}return Rt(d,g)},[d,g]);const[f,l]=m(a);const h=K(async()=>{try{const S=await D.getItem(N);if(S){const x=JSON.parse(S);const c=De(a,x);l(c);return}l(a)}catch(S){console.error("Failed to load dev tools settings:",S);l(a)}},[a]);L(()=>{h();const S=A.addListener(x=>{try{if(x){l(x)}}catch(c){}});return()=>{S()}},[h]);const p=K(()=>{h()},[h]);return{settings:f,refreshSettings:p}};const n=Xe.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:o.gutter,paddingRight:o.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:o.gutter,paddingTop:8,paddingBottom:24,gap:o.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:o.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:o.rowPadH,paddingVertical:o.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:o.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:o.color.text,fontSize:o.font.row,fontWeight:"500"},rowCaption:{color:o.color.textTertiary,fontSize:o.font.label},settingRowBody:{paddingHorizontal:o.rowPadH,paddingBottom:o.rowPadV,gap:6},settingRowBodyText:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:o.font.caption*1.45},settingRowBodyHint:{color:o.color.textTertiary,fontSize:o.font.caption,lineHeight:o.font.caption*1.45},bodyWarning:{color:o.color.warning},bodyDanger:{color:o.color.danger},cardButtonWrap:{paddingHorizontal:o.cardPad,paddingTop:10,paddingBottom:o.cardPad},storageExpanded:{paddingHorizontal:o.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:o.color.textSecondary,fontSize:o.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:o.color.textTertiary,fontSize:o.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:o.color.glassElevated,borderRadius:o.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:o.color.textSecondary,fontSize:o.font.micro,fontFamily:Ie},storageKeyEmpty:{color:o.color.textTertiary,fontSize:o.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:Ie,fontSize:o.font.label,color:o.color.textSecondary}});
1
+ "use strict";import{useState as S,useEffect as I,useCallback as A,useMemo as W}from"react";import{View as y,Text as h,StyleSheet as Xe,ScrollView as Se,TouchableOpacity as j,Dimensions as be,Platform as Ze}from"react-native";import{settingsBus as N}from"./settingsBus.js";import{useDesktopSyncStatus as et}from"./useDesktopSyncStatus";import{SentryIcon as tt,WifiCircuitIcon as ot,ImageOverlayIcon as nt,RenderCountIcon as st,Info as Q,Layers as rt,ChevronRightIcon as we,ChevronDown as Te,getStorageBackendType as it,getUseLicense as at,signOutOfBuoy as lt,persistentStorage as D,Trash2 as ct,CheckCircle2 as ve,LicenseEntryModal as dt,BackgroundSwitcher as gt,night as o,NightCard as R,NightRows as X,NightSectionLabel as ut,NightFootnote as xe,NightSwitch as ze,NightButton as Z,NightSegmented as yt,NightBadge as v,NightSeparator as ht,monoFont as Ie}from"@buoy-gg/shared-ui";import{EnvIcon as Ce,StorageIcon as ft,RoutesIcon as pt,NetworkIcon as mt,QueryIcon as St,HighlighterIcon as bt,ReduxIcon as wt,EventsIcon as Tt}from"@buoy-gg/floating-tools-core";import{useDefaultConfig as Le}from"./DefaultConfigContext.js";import{renderAppIcon as vt}from"./AppIcon";import{JsModal as xt,devToolsStorageKeys as ee,onSettingsApplied as zt}from"@buoy-gg/shared-ui";import{useSafeAreaInsets as It}from"@buoy-gg/shared-ui";import{jsx as e,jsxs as r,Fragment as P}from"react/jsx-runtime";const H="@react_buoy_dev_tools_settings";const Ct=6;const V=d=>{let g=Ct;const a={};for(const[f,l]of Object.entries(d)){if(l&&g>0){a[f]=true;g-=1}else{a[f]=false}}return a};const Lt=(d,g)=>{const{userStatus:a,environment:f,...l}=d;const u=g?Object.entries(l).filter(([p])=>g.includes(p)):Object.entries(l);return{...Object.fromEntries(u),environment:f??false}};const De=(d,g,a)=>{if(!g)return d;const f={...d.dialTools,...g.dialTools??{}};const l=a?.allowedDialKeys?Object.entries(f).filter(([p])=>a.allowedDialKeys?.includes(p)):Object.entries(f);const u=V(Object.fromEntries(l));return{dialTools:u,floatingTools:Lt({...d.floatingTools,...g.floatingTools??{}},a?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...g.globalSettings??{}}}};const Dt=(d=[],g,a)=>{const f={};const l={};const u=new Set(g??[]);const p=new Set(a??[]);const m=!a||a.length===0;for(const x of d){const{id:c,slot:C="both"}=x;if(C==="dial"||C==="both"){f[c]=m?true:p.has(c)}if(C==="row"||C==="both"){l[c]=u.has(c)}}return{dialTools:V(f),floatingTools:{...l,environment:u.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}};export const DevToolsSettingsModal=({visible:d,onClose:g,onSettingsChange:a,initialSettings:f,availableApps:l=[],storage:u=D,zIndex:p})=>{const{defaultFloatingTools:m,defaultDialTools:x}=Le();const c=W(()=>Dt(l,m,x),[l,m,x]);const C=W(()=>Object.keys(c.dialTools),[c]);const oe=W(()=>Object.keys(c.floatingTools).filter(t=>t!=="environment"),[c]);const[z,E]=S(f||M||c);const[B,ne]=S(te??"floating");const[se,Ee]=S(te!==null);const[_,Fe]=S(new Set);const[Oe,J]=S(false);const[ke,Pe]=S(false);I(()=>{const t=requestAnimationFrame(()=>Pe(true));return()=>cancelAnimationFrame(t)},[]);const b=et();I(()=>{const t=async()=>{try{const s=await D.getItem(ee.settings.activeTab());if(s&&["floating","settings","pro"].includes(s)){const i=s;te=i;ne(T=>T===i?T:i)}}catch(s){}finally{Ee(true)}};t()},[]);I(()=>{if(!se)return;D.setItem(ee.settings.activeTab(),B).catch(t=>{console.warn("Failed to save settings active tab:",t)})},[B,se]);const He=at();const F=He?.();const O=F?.isPro??false;const U=!O&&F?.licenseKey?F.error:null;const Me=F?.errorKind==="transport";const[w,Ke]=S(Re);const[G,re]=S(false);const[q,Y]=S(false);const[k,Ae]=S(false);const[$,ie]=S([]);const[ae,le]=S(false);const ce=It();const de=be.get("window").height;const ge=be.get("window").width;const We=Math.floor(de*.33);const je=Math.min(ge-32,400);const ue=A(async()=>{try{const t=await u.getItem(H);if(t){const s=JSON.parse(t);const i=De(c,s,{allowedDialKeys:C,allowedFloatingKeys:oe});M=i;E(T=>Be(T,i)?T:i);return}M=c;E(s=>Be(s,c)?s:c)}catch(t){console.error("Failed to load dev tools settings:",t);E(c)}},[c,C,oe,u]);I(()=>{ue()},[ue]);I(()=>{it().then(t=>{Re=t;Ke(s=>s===t?s:t)})},[]);I(()=>{if(k){le(true);D.getAllKeys().then(t=>{ie(t.sort())}).catch(()=>{ie([])}).finally(()=>{le(false)})}},[k]);const ye=async t=>{try{const s={...t,dialTools:V(t.dialTools)};await u.setItem(H,JSON.stringify(s));M=s;E(s);a?.(s);N.emit(s)}catch(s){console.error("Failed to save dev tools settings:",s)}};const Ne=t=>{const s={...z,floatingTools:{...z.floatingTools,[t]:!z.floatingTools[t]}};ye(s)};const Ve=t=>{const s={...z,globalSettings:{...z.globalSettings,[t]:!z.globalSettings?.[t]}};ye(s)};const _e=async()=>{re(true);Y(false);try{await D.clear();Y(true);E(c);if(u!==D)await u.setItem(H,JSON.stringify(c));a?.(c);N.emit(c);setTimeout(()=>Y(false),2e3)}catch(t){console.error("Failed to clear storage:",t)}finally{re(false)}};const Je=A(t=>{},[]);const Ue=t=>{const s=l.find(i=>i.id===t);if(s?.description){return s.description}if(t==="environment"){return"Environment badge."}return""};const he=t=>{if(t==="environment"){return"Env Badge"}const s=l.find(i=>i.id===t);return s?.name??t.toUpperCase().replace(/_/g," ")};const Ge=t=>{if(!ke)return null;switch(t){case"query":return e(St,{size:18});case"env":return e(Ce,{size:18});case"sentry":return e(tt,{size:18,color:"#9945FF"});case"storage":return e(ft,{size:18,bgColor:o.color.surface});case"wifi":case"query-wifi-toggle":return e(ot,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return e(pt,{size:18,bgColor:o.color.surface});case"network":return e(mt,{size:18});case"environment":return e(Ce,{size:18});case"debug-borders":return e(rt,{size:18,color:o.color.accent});case"highlight-updates":return e(st,{size:18,color:o.color.accent});case"highlight-updates-modal":return e(bt,{size:18});case"redux":return e(wt,{size:18});case"image-overlay":return e(nt,{size:18});case"events":return e(Tt,{size:18});case"zustand":try{const{ZustandIcon:s}=require("@buoy-gg/zustand");return e(s,{size:18})}catch{return e(Q,{size:18,color:o.color.textSecondary})}case"jotai":try{const{JotaiIcon:s}=require("@buoy-gg/jotai");return e(s,{size:18})}catch{return e(Q,{size:18,color:o.color.textSecondary})}default:{const s=l.find(i=>i.id===t);if(s?.icon!=null){return vt(s.icon,{slot:"row",size:18,color:s.color})}return e(Q,{size:18,color:o.color.textSecondary})}}};const qe=(t,s,i,T)=>{const K=Ue(t);return r(j,{activeOpacity:i?1:.7,onPress:()=>!i&&T(),accessibilityLabel:he(t),accessibilityRole:"button",style:[n.toolRow,i&&n.rowDisabled],children:[e(y,{style:n.toolIconSlot,children:Ge(t)}),r(y,{style:n.rowInfo,children:[r(h,{style:n.rowLabel,children:[he(t),i?" \xB7 max 6":""]}),K?e(h,{style:n.rowCaption,numberOfLines:1,children:K}):null]}),e(ze,{value:s,disabled:i,onValueChange:()=>T()})]},t)};const fe=t=>{Fe(s=>{const i=new Set(s);if(i.has(t)){i.delete(t)}else{i.add(t)}return i})};const pe=(t,s,i,T,K)=>{const Qe=z.globalSettings?.[t]??false;const me=_.has(t);return r(y,{children:[r(j,{activeOpacity:.7,onPress:()=>fe(t),accessibilityLabel:s,style:n.settingRow,children:[r(y,{style:n.rowInfo,children:[e(h,{style:n.rowLabel,children:s}),e(h,{style:n.rowCaption,numberOfLines:me?0:1,children:i})]}),e(ze,{value:Qe,onValueChange:()=>Ve(t)})]}),me&&r(y,{style:n.settingRowBody,children:[e(h,{style:n.settingRowBodyText,children:T}),e(h,{style:n.settingRowBodyHint,children:K})]})]},t)};const L=(t,s,i)=>r(y,{children:[e(ut,{children:t}),s,i]});const Ye=w==="filesystem"?e(v,{label:"File System",tone:"accent"}):w==="asyncstorage"?e(v,{label:"Async Storage",tone:"warning"}):w==="localstorage"?e(v,{label:"Local Storage",tone:"accent"}):w==="memory"?e(v,{label:"Memory",tone:"danger"}):e(v,{label:"Loading\u2026",tone:"neutral"});const $e=()=>r(y,{style:n.container,children:[r(Se,{style:n.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:n.scrollContainer,children:[B==="floating"&&e(P,{children:L("Floating Tools",e(R,{glass:true,children:e(X,{children:Object.entries(z.floatingTools).map(([t,s])=>qe(t,s,false,()=>Ne(t)))})}),e(xe,{children:"Tools switched on here appear in the floating bubble row."}))}),B==="settings"&&r(P,{children:[L("Background",e(R,{glass:true,padded:true,children:e(gt,{embedded:true})})),L("Storage",r(R,{glass:true,children:[r(j,{activeOpacity:.7,onPress:()=>Ae(!k),accessibilityLabel:"Storage Type",style:n.settingRow,children:[e(y,{style:n.rowInfo,children:e(h,{style:n.rowLabel,children:"Storage Type"})}),Ye,k?e(Te,{size:16,color:o.color.textTertiary}):e(we,{size:16,color:o.color.textTertiary})]}),k&&r(P,{children:[r(y,{style:n.settingRowBody,children:[e(h,{style:n.settingRowBodyText,children:w==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":w==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":w==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":w==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),w==="asyncstorage"&&e(h,{style:[n.settingRowBodyText,n.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),w==="memory"&&e(h,{style:[n.settingRowBodyText,n.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),e(ht,{}),r(y,{style:n.storageExpanded,children:[r(y,{style:n.storageExpandedHeader,children:[e(h,{style:n.storageExpandedTitle,children:"SAVED SETTINGS"}),e(h,{style:n.storageExpandedCount,children:ae?"\u2026":`${$.length} keys`})]}),ae?e(h,{style:n.storageKeyEmpty,children:"Loading\u2026"}):$.length===0?e(h,{style:n.storageKeyEmpty,children:"No settings saved yet"}):e(Se,{style:n.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:$.map(t=>e(y,{style:n.storageKeyItem,children:e(h,{style:n.storageKeyText,numberOfLines:1,children:t.replace("@react_buoy_","")})},t))})]}),e(y,{style:n.cardButtonWrap,children:e(Z,{label:q?"Cleared":G?"Clearing\u2026":"Clear All Settings",variant:q?"secondary":"destructive",size:"md",disabled:G,onPress:_e,icon:q?e(ve,{size:15,color:o.color.accent}):e(ct,{size:15,color:G?o.color.textTertiary:o.color.danger})})})]})]})),b&&b.state!=="idle"&&L("Desktop Sync",r(R,{glass:true,children:[r(j,{activeOpacity:.7,onPress:()=>fe("desktopSync"),accessibilityLabel:"Buoy Desktop",style:n.settingRow,children:[e(y,{style:n.rowInfo,children:e(h,{style:n.rowLabel,children:"Buoy Desktop"})}),b.state==="connected"?e(v,{label:"Connected",tone:"accent"}):b.state==="connecting"?e(v,{label:"Connecting\u2026",tone:"neutral"}):e(v,{label:"Retrying",tone:"warning"}),_.has("desktopSync")?e(Te,{size:16,color:o.color.textTertiary}):e(we,{size:16,color:o.color.textTertiary})]}),_.has("desktopSync")&&r(y,{style:n.settingRowBody,children:[r(h,{style:n.settingRowBodyText,children:[b.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",e(h,{style:n.footnoteMono,children:b.targetURL??"(unknown URL)"}),b.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),b.state==="retrying"&&b.lastError&&r(h,{style:[n.settingRowBodyText,n.bodyWarning],children:["Last error: ",b.lastError]})]})]})),L("Modal Behavior",e(R,{glass:true,children:r(X,{children:[pe("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),Ze.OS!=="web"?pe("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),B==="pro"&&r(P,{children:[L("License",r(R,{glass:true,children:[r(y,{style:n.settingRow,children:[e(y,{style:n.rowInfo,children:e(h,{style:n.rowLabel,children:"License Status"})}),e(y,{testID:"buoy-settings-license-status",accessibilityLabel:O?"License: Active":"License: Free",children:O?e(v,{label:"Active",tone:"accent"}):e(v,{label:"Free",tone:"neutral"})})]}),F?.tierSource==="session"?r(y,{style:n.settingRow,children:[e(y,{style:n.rowInfo,children:e(h,{style:n.rowLabel,children:"Signed in with Buoy"})}),e(Z,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void lt(),testID:"buoy-settings-signout"})]}):null]}),e(xe,{children:O?"You have full access to all Buoy DevTools features.":U?Me?`Couldn't reach the license server (${U}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${U}.`:"Upgrade to Pro to unlock all features and support development."})),!O&&r(P,{children:[L("Pro Features",e(R,{glass:true,children:e(X,{children:["Advanced Settings","Priority Support"].map(t=>r(y,{style:n.featureRow,children:[e(ve,{size:16,color:o.color.accent}),e(h,{style:n.rowLabel,children:t})]},t))})})),e(Z,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>J(true)})]})]})]}),e(dt,{visible:Oe,onClose:()=>J(false),onSuccess:()=>J(false)})]});return e(xt,{visible:d,onClose:g,zIndex:p,variant:"night",header:{showToggleButton:false,customContent:e(y,{style:n.headerRow,children:e(yt,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:B,onChange:t=>ne(t)})})},initialMode:"bottomSheet",onModeChange:Je,persistenceKey:ee.settings.root(),enablePersistence:true,maxHeight:de-ce.top,initialHeight:We,initialFloatingPosition:{x:(ge-je)/2,y:ce.top+20},enableGlitchEffects:true,children:$e()})};const Rt={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}};const Bt=(d,g)=>{const a=new Set(d??[]);const f=new Set(g??[]);const l={};for(const p of f){l[p]=true}const u={environment:a.has("environment")};for(const p of a){if(p!=="environment"){u[p]=true}}return{dialTools:V(l),floatingTools:u,globalSettings:{enableSharedModalDimensions:false}}};let M=null;let te=null;let Re=null;const Be=(d,g)=>JSON.stringify(d)===JSON.stringify(g);N.addListener(d=>{if(d)M=d});export const useDevToolsSettings=()=>{const{defaultFloatingTools:d,defaultDialTools:g}=Le();const a=W(()=>{if(!d&&!g){return Rt}return Bt(d,g)},[d,g]);const[f,l]=S(a);const u=A(async()=>{try{const m=await D.getItem(H);if(m){const x=JSON.parse(m);const c=De(a,x);l(c);return}l(a)}catch(m){console.error("Failed to load dev tools settings:",m);l(a)}},[a]);I(()=>zt(m=>{if(m.includes(H))void u()}),[u]);I(()=>{u();const m=N.addListener(x=>{try{if(x){l(x)}}catch(c){}});return()=>{m()}},[u]);const p=A(()=>{u()},[u]);return{settings:f,refreshSettings:p}};const n=Xe.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:o.gutter,paddingRight:o.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:o.gutter,paddingTop:8,paddingBottom:24,gap:o.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:o.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:o.rowPadH,paddingVertical:o.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:o.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:o.color.text,fontSize:o.font.row,fontWeight:"500"},rowCaption:{color:o.color.textTertiary,fontSize:o.font.label},settingRowBody:{paddingHorizontal:o.rowPadH,paddingBottom:o.rowPadV,gap:6},settingRowBodyText:{color:o.color.textSecondary,fontSize:o.font.caption,lineHeight:o.font.caption*1.45},settingRowBodyHint:{color:o.color.textTertiary,fontSize:o.font.caption,lineHeight:o.font.caption*1.45},bodyWarning:{color:o.color.warning},bodyDanger:{color:o.color.danger},cardButtonWrap:{paddingHorizontal:o.cardPad,paddingTop:10,paddingBottom:o.cardPad},storageExpanded:{paddingHorizontal:o.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:o.color.textSecondary,fontSize:o.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:o.color.textTertiary,fontSize:o.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:o.color.glassElevated,borderRadius:o.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:o.color.textSecondary,fontSize:o.font.micro,fontFamily:Ie},storageKeyEmpty:{color:o.color.textTertiary,fontSize:o.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:Ie,fontSize:o.font.label,color:o.color.textSecondary}});
@@ -1 +1 @@
1
- "use strict";export const SDK_VERSION="7.0.48";
1
+ "use strict";export const SDK_VERSION="7.0.49";
@@ -9,5 +9,5 @@
9
9
  * Drift is prevented by a test that fails when this disagrees with
10
10
  * package.json, so a version bump that forgets this file cannot ship.
11
11
  */
12
- export declare const SDK_VERSION = "7.0.48";
12
+ export declare const SDK_VERSION = "7.0.49";
13
13
  //# sourceMappingURL=version.d.ts.map
@@ -9,5 +9,5 @@
9
9
  * Drift is prevented by a test that fails when this disagrees with
10
10
  * package.json, so a version bump that forgets this file cannot ship.
11
11
  */
12
- export declare const SDK_VERSION = "7.0.48";
12
+ export declare const SDK_VERSION = "7.0.49";
13
13
  //# sourceMappingURL=version.d.ts.map
package/lib/web/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- "use client";import{$ as En,A as Bn,Aa as On,B as Fn,Ba as Ln,C as Pn,Ca as $n,D as jn,Da as Hn,E as Wn,Ea as Nn,F as Vn,Fa as Un,G as Kn,Ga as _n,H as Gn,Ha as qn,I as Jn,Ia as Xn,J as Yn,Ja as Qn,K as Zn,Ka as ea,L as ta,La as oa,M as na,Ma as aa,N as ia,Na as ra,O as sa,Oa as la,P as ca,Pa as da,Q as ua,Qa as pa,R as ma,Ra as ga,S as fa,Sa as ha,T as ya,Ta as ba,U as Sa,Ua as va,V as wa,Va as xa,W as Ca,Wa as Ta,X as za,Xa as ka,Y as Ia,Ya as Ma,Z as Ra,_ as Aa,a as H,aa as Da,b as N,ba as Ea,c as et,ca as Ba,d as Nt,da as Oa,e as oc,ea as Fa,f as xe,fa as La,g as Vt,ga as Pa,h as Be,ha as $a,i as Ut,ia as ja,j as Ha,ja as Wa,k as Na,ka as Va,l as Ua,la as Ka,m as _a,ma as Ga,n as qa,na as Ja,o as Xa,oa as Ya,p as Qa,pa as Za,q as ei,qa as ti,r as oi,ra as ni,s as ai,sa as ii,t as ri,ta as si,u as li,ua as ci,v as di,va as ui,w as pi,wa as mi,x as gi,xa as fi,y as hi,ya as yi,z as bi,za as Si}from"./chunks/chunk-QZDVCMCT.mjs";import{b as vi,c as Kt}from"./chunks/chunk-5SGL6QL4.mjs";import{a as _t,d as tt}from"./chunks/chunk-R7RGRTY5.mjs";import{FloatingToolHost as wi}from"@buoy-gg/shared-ui/web/floating";import{LicenseManager as xi,useLicense as Ci,sameLicenseKey as Ti}from"@buoy-gg/license/web";import{AccountSetup as zi,startSettingsSync as ki}from"@buoy-gg/shared-ui/web";import{useState as wt,useMemo as Oe,useCallback as Fe,useEffect as le,useRef as Ii}from"react";import{useSettings as Mi,getToolLabel as ot,getToolDescription as Ri,getToolColor as Gt}from"@buoy-gg/floating-tools-react/web";import{persistentStorage as Ce,devToolsStorageKeys as nt,EnvironmentIndicator as Ai,EnvironmentSelectorInline as Di}from"@buoy-gg/shared-ui/web";var Ei=[];function Bi(){return[]}function qt(e=[]){return[...new Map(e.map(t=>[t.id,t])).values()]}function xt(e,t){return e.filter(o=>{let a=o.slot||"both";return a==="both"||a===t})}function Oi(e,t){let o=t instanceof Set?t:new Set(t);return e.filter(a=>o.has(a.id))}import{FloatingTool as Jt,FloatingToolDivider as Fi,FloatingToolUserStatus as Xt,getBubbleAnchorPosition as Li}from"@buoy-gg/shared-ui/web/floating";import{useState as Q,useEffect as Te,useMemo as at,useRef as it,useCallback as rt}from"react";import{getDialLayout as Pi,getAllIconPositions as $i,getGridLineRotations as ji,getIconStaggerInputRange as Hi,MAX_DIAL_SLOTS as We,DIAL_ICON_SIZE as Wi,dialAnimationConfig as Yt,getDialCSSKeyframesString as Ni,getDialCSSAnimationStyles as Vi,dialColors as F,dialStyles as S,withAlpha as Qt,floatingToolsColors as Ui}from"@buoy-gg/floating-tools-react/web";import{persistentStorage as Zt,monoFont as eo,ToolBackground as Ki,useToolBackground as _i}from"@buoy-gg/shared-ui/web";import{memo as Gi}from"react";import{RasterLayer as qi,scatter as Ji,useLoop as Xi,withBgAlpha as Yi}from"@buoy-gg/shared-ui/web";import{Fragment as Qi,jsx as Ne}from"react/jsx-runtime";var Zi=.94,er=6,tr=2400,st=3,to=16,or=Array.from({length:st},(e,t)=>Ji(22343^t*40503,to*4)),oo=["#FFFFFF","#B3D9FF","#8CB3FF"],no=Math.PI/3,ao=14*Math.PI/180;function nr(e){let t=Math.min(5,Math.floor(e*6)),o=e*6-t;return t*no+ao/2+o*(no-ao)}function ar(e){return Math.min(er,1/(1-e*Zi))}function ir(e){let t=.15+.85*e*e;return e<.06?t*=e/.06:e>.94&&(t*=(1-e)/.06),Math.min(.7,t)}function rr(e){let t=e/st,o=[],a=12;for(let d=0;d<=a;d++)o.push(d/a);let n=(1-t)%1;n>.001&&n<1-.001&&o.push(n-1e-4,n+1e-4),o.sort((d,p)=>d-p);let i=[],l=[],u=[];for(let d of o){let p=t===0&&d===1?1:(d+t)%1;i.push(d),l.push(ar(p)),u.push(ir(p))}return{input:i,scale:l,opacity:u}}var sr=Array.from({length:st},(e,t)=>rr(t)),lr=Gi(function({size:e}){let t=Xi(tr),o=e/2,a=[];for(let n=0;n<st;n++){let i=or[n],l=sr[n],u=[];for(let d=0;d<to;d++){let p=nr(i[d*4]),m=(.15+.85*Math.sqrt(i[d*4+1]))*.5*o,x=oo[Math.floor(i[d*4+3]*oo.length)%3],g=o+Math.cos(p)*m,R=o+Math.sin(p)*m,v=.6,I=v*2.4;u.push(Ne(H,{style:{position:"absolute",left:g-I/2,top:R-I/2,width:I,height:I,borderRadius:I/2,backgroundColor:Yi(x,.3)}},`${d}-h`),Ne(H,{style:{position:"absolute",left:g-v/2,top:R-v/2,width:v,height:v,borderRadius:v/2,backgroundColor:x}},d))}a.push(Ne(xe.View,{style:{position:"absolute",left:0,top:0,width:e,height:e,opacity:t.interpolate({inputRange:l.input,outputRange:l.opacity}),transform:[{scale:t.interpolate({inputRange:l.input,outputRange:l.scale})}]},pointerEvents:"none",children:Ne(qi,{style:{width:e,height:e},raster:false,children:u})},n))}return Ne(Qi,{children:a})});import{useEffect as cr,useState as io}from"react";import{dialColors as Le,withAlpha as ro}from"@buoy-gg/floating-tools-react/web";import{ARROW_BOTTOM_OFFSET as dr,ARROW_HEIGHT as ur,SPACING_GAP as wc,getScreenCenterY as xc,calculateTooltipPosition as pr,calculateTargetPosition as Cc}from"@buoy-gg/shared-ui/web/floating";import{monoFont as so}from"@buoy-gg/shared-ui/web";import{jsx as Pe,jsxs as lo}from"react/jsx-runtime";var co=false;function mr(){if(co||typeof document>"u")return;let e=document.createElement("style");e.textContent=`
1
+ "use client";import{$ as En,A as Bn,Aa as On,B as Fn,Ba as Ln,C as Pn,Ca as $n,D as jn,Da as Hn,E as Wn,Ea as Nn,F as Vn,Fa as Un,G as Kn,Ga as _n,H as qn,Ha as Gn,I as Jn,Ia as Xn,J as Yn,Ja as Qn,K as Zn,Ka as ea,L as ta,La as oa,M as na,Ma as aa,N as ia,Na as ra,O as sa,Oa as la,P as ca,Pa as da,Q as ua,Qa as pa,R as ma,Ra as ga,S as fa,Sa as ha,T as ya,Ta as ba,U as Sa,Ua as va,V as wa,Va as xa,W as Ca,Wa as Ta,X as za,Xa as ka,Y as Ia,Ya as Ma,Z as Ra,_ as Aa,a as H,aa as Da,b as N,ba as Ea,c as tt,ca as Ba,d as Nt,da as Oa,e as nc,ea as Fa,f as Ce,fa as La,g as Vt,ga as Pa,h as Be,ha as $a,i as Ut,ia as ja,j as Ha,ja as Wa,k as Na,ka as Va,l as Ua,la as Ka,m as _a,ma as qa,n as Ga,na as Ja,o as Xa,oa as Ya,p as Qa,pa as Za,q as ei,qa as ti,r as oi,ra as ni,s as ai,sa as ii,t as ri,ta as si,u as li,ua as ci,v as di,va as ui,w as pi,wa as mi,x as gi,xa as fi,y as hi,ya as yi,z as bi,za as Si}from"./chunks/chunk-QZDVCMCT.mjs";import{b as vi,c as Kt}from"./chunks/chunk-5SGL6QL4.mjs";import{a as _t,d as ot}from"./chunks/chunk-R7RGRTY5.mjs";import{FloatingToolHost as wi}from"@buoy-gg/shared-ui/web/floating";import{LicenseManager as xi,useLicense as Ci,sameLicenseKey as Ti}from"@buoy-gg/license/web";import{AccountSetup as zi,startSettingsSync as ki}from"@buoy-gg/shared-ui/web";import{useState as wt,useMemo as Oe,useCallback as Fe,useEffect as le,useRef as Ii}from"react";import{useSettings as Mi,getToolLabel as nt,getToolDescription as Ri,getToolColor as qt}from"@buoy-gg/floating-tools-react/web";import{persistentStorage as Te,devToolsStorageKeys as at,EnvironmentIndicator as Ai,EnvironmentSelectorInline as Di}from"@buoy-gg/shared-ui/web";var Ei=[];function Bi(){return[]}function Gt(e=[]){return[...new Map(e.map(t=>[t.id,t])).values()]}function xt(e,t){return e.filter(o=>{let a=o.slot||"both";return a==="both"||a===t})}function Oi(e,t){let o=t instanceof Set?t:new Set(t);return e.filter(a=>o.has(a.id))}import{FloatingTool as Jt,FloatingToolDivider as Fi,FloatingToolUserStatus as Xt,getBubbleAnchorPosition as Li}from"@buoy-gg/shared-ui/web/floating";import{useState as Q,useEffect as ze,useMemo as it,useRef as rt,useCallback as st}from"react";import{getDialLayout as Pi,getAllIconPositions as $i,getGridLineRotations as ji,getIconStaggerInputRange as Hi,MAX_DIAL_SLOTS as We,DIAL_ICON_SIZE as Wi,dialAnimationConfig as Yt,getDialCSSKeyframesString as Ni,getDialCSSAnimationStyles as Vi,dialColors as F,dialStyles as S,withAlpha as Qt,floatingToolsColors as Ui}from"@buoy-gg/floating-tools-react/web";import{persistentStorage as Zt,monoFont as eo,ToolBackground as Ki,useToolBackground as _i}from"@buoy-gg/shared-ui/web";import{memo as qi}from"react";import{RasterLayer as Gi,scatter as Ji,useLoop as Xi,withBgAlpha as Yi}from"@buoy-gg/shared-ui/web";import{Fragment as Qi,jsx as Ne}from"react/jsx-runtime";var Zi=.94,er=6,tr=2400,lt=3,to=16,or=Array.from({length:lt},(e,t)=>Ji(22343^t*40503,to*4)),oo=["#FFFFFF","#B3D9FF","#8CB3FF"],no=Math.PI/3,ao=14*Math.PI/180;function nr(e){let t=Math.min(5,Math.floor(e*6)),o=e*6-t;return t*no+ao/2+o*(no-ao)}function ar(e){return Math.min(er,1/(1-e*Zi))}function ir(e){let t=.15+.85*e*e;return e<.06?t*=e/.06:e>.94&&(t*=(1-e)/.06),Math.min(.7,t)}function rr(e){let t=e/lt,o=[],a=12;for(let d=0;d<=a;d++)o.push(d/a);let n=(1-t)%1;n>.001&&n<1-.001&&o.push(n-1e-4,n+1e-4),o.sort((d,p)=>d-p);let i=[],l=[],u=[];for(let d of o){let p=t===0&&d===1?1:(d+t)%1;i.push(d),l.push(ar(p)),u.push(ir(p))}return{input:i,scale:l,opacity:u}}var sr=Array.from({length:lt},(e,t)=>rr(t)),lr=qi(function({size:e}){let t=Xi(tr),o=e/2,a=[];for(let n=0;n<lt;n++){let i=or[n],l=sr[n],u=[];for(let d=0;d<to;d++){let p=nr(i[d*4]),m=(.15+.85*Math.sqrt(i[d*4+1]))*.5*o,x=oo[Math.floor(i[d*4+3]*oo.length)%3],g=o+Math.cos(p)*m,R=o+Math.sin(p)*m,v=.6,I=v*2.4;u.push(Ne(H,{style:{position:"absolute",left:g-I/2,top:R-I/2,width:I,height:I,borderRadius:I/2,backgroundColor:Yi(x,.3)}},`${d}-h`),Ne(H,{style:{position:"absolute",left:g-v/2,top:R-v/2,width:v,height:v,borderRadius:v/2,backgroundColor:x}},d))}a.push(Ne(Ce.View,{style:{position:"absolute",left:0,top:0,width:e,height:e,opacity:t.interpolate({inputRange:l.input,outputRange:l.opacity}),transform:[{scale:t.interpolate({inputRange:l.input,outputRange:l.scale})}]},pointerEvents:"none",children:Ne(Gi,{style:{width:e,height:e},raster:false,children:u})},n))}return Ne(Qi,{children:a})});import{useEffect as cr,useState as io}from"react";import{dialColors as Le,withAlpha as ro}from"@buoy-gg/floating-tools-react/web";import{ARROW_BOTTOM_OFFSET as dr,ARROW_HEIGHT as ur,SPACING_GAP as xc,getScreenCenterY as Cc,calculateTooltipPosition as pr,calculateTargetPosition as Tc}from"@buoy-gg/shared-ui/web/floating";import{monoFont as so}from"@buoy-gg/shared-ui/web";import{jsx as Pe,jsxs as lo}from"react/jsx-runtime";var co=false;function mr(){if(co||typeof document>"u")return;let e=document.createElement("style");e.textContent=`
2
2
  @keyframes buoyOnboardPulse {
3
3
  0%, 100% { transform: scale(1); }
4
4
  50% { transform: scale(1.02); }
@@ -7,4 +7,4 @@
7
7
  0%, 100% { transform: translateY(0); }
8
8
  50% { transform: translateY(-8px); }
9
9
  }
10
- `,document.head.appendChild(e),co=true}var Ct=Le.accent;function uo({title:e,message:t,onDismiss:o,showArrow:a=true}){let[n,i]=io(false),[l,u]=io(false);cr(()=>{mr();let p=requestAnimationFrame(()=>i(true));return()=>cancelAnimationFrame(p)},[]);let d={fontFamily:so,textTransform:"uppercase"};return Pe("div",{style:{position:"fixed",left:"50%",bottom:pr(),transform:`translateX(-50%) scale(${n?1:.8})`,opacity:n?1:0,transition:"transform 300ms cubic-bezier(0.34, 1.3, 0.64, 1), opacity 300ms ease",zIndex:10002,pointerEvents:"auto"},children:lo("div",{style:{position:"relative",animation:n?"buoyOnboardPulse 3s ease-in-out infinite":"none"},children:[Pe("div",{style:{position:"absolute",inset:-4,borderRadius:18,backgroundColor:"#FFFFFF",opacity:.06}}),lo("div",{style:{position:"relative",maxWidth:280,backgroundColor:Le.dialBackground,borderRadius:16,border:`1px solid ${Le.dialBorder}`,padding:20,boxShadow:`0 0 20px ${ro(Le.dialShadow,.6)}`,display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[Pe("span",{style:{...d,fontSize:16,fontWeight:900,letterSpacing:1,color:Ct,textAlign:"center"},children:e}),Pe("span",{style:{fontFamily:so,fontSize:13,lineHeight:"20px",color:Le.centerText,textAlign:"center"},children:t}),Pe("button",{onClick:o,onMouseDown:()=>u(true),onMouseUp:()=>u(false),onMouseLeave:()=>u(false),style:{...d,marginTop:8,borderRadius:8,border:"none",backgroundColor:Ct,padding:"10px 24px",fontSize:14,fontWeight:900,letterSpacing:1.5,color:"#000000",cursor:"pointer",opacity:l?.7:1,transform:l?"scale(0.96)":"scale(1)",transition:"transform 100ms ease, opacity 100ms ease"},children:"Got it!"})]}),a&&Pe("div",{style:{position:"absolute",left:"50%",bottom:dr,marginLeft:-12,width:0,height:0,borderLeft:"12px solid transparent",borderRight:"12px solid transparent",borderTop:`${ur}px solid ${Ct}`,filter:`drop-shadow(0 0 10px ${ro(Le.dialShadow,.5)})`,animation:n?"buoyOnboardArrowBounce 1.6s ease-in-out infinite":"none"}})]})})}import{Fragment as gr,jsx as B,jsxs as ge}from"react/jsx-runtime";var fr={x:.5,y:.5},po="@react_buoy_settings_tooltip_shown",mo=false;function hr(){if(mo||typeof document>"u")return;let e=document.createElement("style");e.textContent=Ni(),document.head.appendChild(e),mo=true}var $e=e=>1-Math.pow(1-e,3),Tt=e=>e*e*e;function yr({icon:e,index:t,totalIcons:o,position:a,progress:n,onPress:i}){let[l,u]=Q(false),[d,p]=Q(false),m=!e.icon&&e.id.startsWith("empty-"),x=!m&&e.unavailable===true,g=!m&&!x,{icons:R}=Yt,v=Hi(t,o),I=0;n<=v[1]?I=0:n<=v[2]?I=(n-v[1])/(v[2]-v[1]):I=1,I=Math.max(0,Math.min(1,I));let T=Wi,k=R.pressIn.scale,z=I*(d?k:l?1.1:1),O=0;I<=0?O=0:I<=.3?O=I:O=.3+(I-.3)*(.7/.7);let b=a.x*I,M=a.y*I;return B("button",{role:"menuitem","aria-label":m?"Empty slot":e.name,"aria-disabled":!g,tabIndex:g?0:-1,onClick:g?i:void 0,onMouseEnter:()=>g&&u(true),onMouseLeave:()=>{u(false),p(false)},onMouseDown:()=>g&&p(true),onMouseUp:()=>p(false),style:{position:"absolute",left:"50%",top:"50%",width:T,height:T,marginLeft:-T/2,marginTop:-T/2,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:g?"pointer":"default",transform:`translate(${b}px, ${M}px) scale(${z})`,opacity:O,transition:l||d?"transform 100ms ease":"none",background:"none",border:"none",padding:0},children:m?B("div",{style:{width:S.emptySlot.dotSize,height:S.emptySlot.dotSize,borderRadius:S.emptySlot.dotSize/2,backgroundColor:F.emptyDotBackground,border:`${S.emptySlot.borderWidth}px solid ${F.emptyDotBorder}`}}):ge(gr,{children:[B("div",{style:{position:"absolute",width:`${S.icon.gradientBgSizePercent}%`,height:`${S.icon.gradientBgSizePercent}%`,borderRadius:S.icon.gradientBgBorderRadius,backgroundColor:"rgba(0, 0, 0, 0.2)",opacity:S.icon.gradientBgOpacity}}),B("div",{style:{position:"absolute",width:`${S.icon.innerGlowSizePercent}%`,height:`${S.icon.innerGlowSizePercent}%`,borderRadius:S.icon.innerGlowBorderRadius,backgroundColor:"rgba(255, 255, 255, 0.02)",opacity:S.icon.innerGlowOpacity}}),B("div",{style:{marginBottom:S.icon.wrapperMarginBottom,display:"flex",alignItems:"center",justifyContent:"center",fontSize:32,filter:l?"brightness(1.2)":"none"},children:e.icon}),B("span",{style:{fontSize:e.name.length>8?Math.max(S.icon.label.fontSize*.7,S.icon.label.fontSize*8/e.name.length):S.icon.label.fontSize,fontWeight:S.icon.label.fontWeight,fontFamily:S.icon.label.fontFamily,color:F.iconLabel,letterSpacing:S.icon.label.letterSpacing,marginTop:S.icon.label.marginTop,textTransform:"uppercase",whiteSpace:"nowrap"},children:e.name}),x&&B("span",{style:{fontSize:S.icon.label.fontSize-1,fontWeight:S.icon.label.fontWeight,fontFamily:S.icon.label.fontFamily,letterSpacing:S.icon.label.letterSpacing,color:Ui.muted,textTransform:"uppercase",whiteSpace:"nowrap"},children:"Unavailable"})]})})}function go({side:e,color:t}){return B("svg",{width:18,height:18,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:(e==="prev"?[[15,18,9,12],[9,12,15,6]]:[[9,18,15,12],[15,12,9,6]]).map(([o,a,n,i],l)=>B("line",{x1:o,y1:a,x2:n,y2:i,stroke:t,strokeWidth:2},l))})}function fo({side:e,disabled:t,onClick:o}){let[a,n]=Q(false),i=t?F.emptyDotBorder:F.accent;return ge("button",{type:"button","aria-label":`${e==="prev"?"Previous":"Next"} dial page`,disabled:t,onClick:o,onMouseDown:()=>!t&&n(true),onMouseUp:()=>n(false),onMouseLeave:()=>n(false),style:{display:"flex",alignItems:"center",gap:4,padding:"10px 16px",borderRadius:10,border:`1px solid ${F.dialBorder}`,backgroundColor:F.dialBackground,color:t?F.iconLabelMuted:F.centerText,fontSize:12,fontWeight:900,fontFamily:eo,letterSpacing:1.5,textTransform:"uppercase",cursor:t?"default":"pointer",opacity:t?.4:1,boxShadow:t?"none":`0 0 8px ${Qt(F.dialShadow,.4)}`,transform:a?"scale(0.92)":"scale(1)",transition:"transform 100ms ease"},children:[e==="prev"&&B(go,{side:"prev",color:i}),e==="prev"?"PREV":"NEXT",e==="next"&&B(go,{side:"next",color:i})]})}function ho({icons:e,onClose:t,centerLabel:o="MENU",onCenterPress:a,settingsOpen:n=false,hintsDisabled:i=false}){let{id:l}=_i(),[u,d]=Q(0),[p,m]=Q(0),[x,g]=Q(0),[R,v]=Q(0),[I,T]=Q(0),[k,z]=Q(1),[O,b]=Q(false),[M,$]=Q(false),[C,A]=Q(false),ee=it(null),Z=it(null),q=it(null),ce=it(false),{entrance:K,exit:ne,interaction:J}=Yt,Se=Vi(),[me,ve]=Q(()=>({width:window.innerWidth,height:window.innerHeight}));Te(()=>{let D=()=>ve({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]);let j=at(()=>Pi({screenWidth:me.width,maxCircleSize:Math.max(120,Math.min(320,me.height-96))}),[me]),Re=at(()=>ji(),[]),fe=at(()=>$i(We,j.iconRadius),[j.iconRadius]),[se,we]=Q(0),ae=Math.max(1,Math.ceil(e.length/We)),r=Math.min(se,ae-1),L=at(()=>{let D=r*We,w=[...e.slice(D,D+We)];for(;w.length<We;)w.push({id:`empty-${w.length}`,name:"",icon:null,onPress:()=>{}});return w},[e,r]);Te(()=>{hr()},[]),Te(()=>{let D=K.backdrop.duration,w=K.dial.rotation.duration,X=K.centerButton.delay,V=K.icons.delay,G=K.icons.duration,_=performance.now(),te=de=>{let s=de-_;d(Math.min(1,s/D));let f=Math.min(1,s/400),E=$e(f)*1.1;f>.7&&(E-=(f-.7)*.33),f>=1&&(E=1),m(Math.max(0,Math.min(1.05,E)));let Y=Math.min(1,s/w);if(g($e(Y)*360),s>=X){let ye=Math.min(1,(s-X)/300),Ee=$e(ye)*1.15;ye>.6&&(Ee-=(ye-.6)*.375),ye>=1&&(Ee=1),v(Math.max(0,Math.min(1.05,Ee)))}if(s>=V){let ye=Math.min(1,(s-V)/G);T($e(ye))}let he=V+G;s<he?q.current=requestAnimationFrame(te):(d(1),m(1),g(360),v(1),T(1),A(true))};return q.current=requestAnimationFrame(te),()=>{q.current&&cancelAnimationFrame(q.current)}},[]);let W=rt(()=>{if(ce.current)return;ce.current=true,$(true),q.current&&cancelAnimationFrame(q.current);let D=performance.now(),w=ne.icons.duration,X=ne.centerButton.duration,V=ne.dialScale.duration,G=Math.max(X,V),_=ne.backdrop.duration,te=de=>{let s=de-D;if(s<w){let Y=Tt(s/w);T(1-Y),q.current=requestAnimationFrame(te);return}let f=w;if(s<f+G){T(0);let Y=Math.min(1,(s-f)/X),he=Math.min(1,(s-f)/V);v(1-Tt(Y)),m(1-Tt(he)),q.current=requestAnimationFrame(te);return}let E=f+G;if(s<E+_){m(0),v(0);let Y=(s-E)/_;d(1-Y),q.current=requestAnimationFrame(te);return}d(0),t()};q.current=requestAnimationFrame(te)},[ne,t]);Te(()=>{let D=document.activeElement,w=ee.current;return()=>{D?.isConnected&&(document.activeElement===document.body||w?.contains(document.activeElement))&&D.focus()}},[]),Te(()=>{if(n)return;Z.current?.focus();let D=w=>{let X=ee.current;if(X){if(w.key==="Escape")w.preventDefault(),W();else if(w.key==="Tab"){let V=Array.from(X.querySelectorAll('button:not(:disabled):not([aria-disabled="true"]), [tabindex="0"]')).filter(te=>te.getClientRects().length>0),G=V[0],_=V[V.length-1];(!X.contains(document.activeElement)||(w.shiftKey?document.activeElement===G:document.activeElement===_))&&(w.preventDefault(),(w.shiftKey?_:G)?.focus())}else if(["ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End"].includes(w.key)){let V=Array.from(X.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')),G=V.indexOf(document.activeElement);if(G<0||!V.length)return;w.preventDefault();let _=w.key==="Home"?0:w.key==="End"?V.length-1:(G+(w.key==="ArrowRight"||w.key==="ArrowDown"?1:-1)+V.length)%V.length;V[_].focus()}}};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[W,n]);let[He,Xe]=Q(false);Te(()=>{if(i)return;let D=false,w=setTimeout(async()=>{let X=await Zt.getItem(po);!D&&!X&&Xe(true)},1200);return()=>{D=true,clearTimeout(w)}},[i]);let Ae=rt(()=>{Xe(false),Zt.setItem(po,"true")},[]);Te(()=>{n&&He&&Ae()},[n,He,Ae]);let Ye=rt(D=>{if(D.id.startsWith("empty-")||ce.current)return;let[w,X]=J.iconSelect.pulse,V=performance.now(),G=150,_=te=>{let de=te-V;if(de<G){let s=$e(de/G);z(1-(1-w.scale)*s),requestAnimationFrame(_)}else if(de<G*2){let s=$e((de-G)/G);z(w.scale+(X.scale-w.scale)*s),requestAnimationFrame(_)}else z(1)};requestAnimationFrame(_),setTimeout(()=>{D.onPress(),W()},J.iconSelect.actionDelay)},[J.iconSelect,W]),Qe=rt(D=>{if(ce.current)return;let w=Math.max(0,Math.min(D,ae-1));w!==r&&we(w)},[ae,r]),De=j.buttonSize*S.centerButton.containerRatio,Ze=j.buttonSize*S.centerButton.borderRatio,St=j.buttonSize*S.centerButton.containerRatio/2+6,vt=C&&!M;return ge("div",{ref:ee,role:"dialog","aria-label":"Dial Menu","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:1e4},children:[B("button",{type:"button","aria-label":"Close dial menu",tabIndex:0,onClick:W,style:{position:"absolute",inset:0,border:0,padding:0,backgroundColor:F.dialBackdrop,opacity:u}}),ge("div",{style:{position:"absolute",left:"50%",marginLeft:-j.circleSize/2,bottom:80,width:j.circleSize,height:j.circleSize,borderRadius:"50%",backgroundColor:F.dialBackground,border:`${S.circle.borderWidth}px solid ${F.dialBorder}`,boxShadow:`0 0 ${S.circle.shadowRadius}px ${Qt(F.dialShadow,S.circle.shadowOpacity)}`,transform:`scale(${p}) rotate(${x}deg)`,opacity:p>.01?1:0,overflow:"hidden"},children:[B("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:F.dialGradient1,opacity:S.gradientLayers[0].opacity}}),B("div",{style:{position:"absolute",inset:0,top:"30%",left:"30%",borderRadius:"50%",backgroundColor:F.dialGradient2,opacity:S.gradientLayers[1].opacity}}),B("div",{style:{position:"absolute",inset:0,top:"50%",left:"50%",borderRadius:"50%",backgroundColor:F.dialGradient3,opacity:S.gradientLayers[2].opacity}}),Re.map(D=>B("div",{style:{position:"absolute",top:"50%",left:0,right:0,height:S.grid.lineHeight,transform:`rotate(${D}deg)`,transformOrigin:"center"},children:["left","right"].map(w=>B("div",{style:{position:"absolute",top:0,[w]:0,width:`calc(50% - ${St}px)`,height:S.grid.lineHeight,backgroundColor:F.dialGridLine}},w))},D)),B("div",{"data-testid":"dial-background","data-background":l,style:{position:"absolute",inset:0,pointerEvents:"none"},children:l==="hyperspace"?B(lr,{size:j.circleSize}):B(Ki,{focus:fr})}),L.map((D,w)=>B(yr,{icon:D,index:w,totalIcons:L.length,position:fe[w],progress:I,onPress:()=>Ye(D)},w)),ge("div",{style:{position:"absolute",left:"50%",top:"50%",width:De,height:De,marginLeft:-De/2,marginTop:-De/2,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:F.hubHalo,borderRadius:j.buttonSize,overflow:"hidden",transform:`scale(${R*k})`,opacity:R>.01?1:0},children:[B("div",{style:{position:"absolute",inset:0,backgroundColor:F.dialGradient1,opacity:.5,borderRadius:j.buttonSize}}),B("div",{style:{position:"absolute",inset:0,top:"20%",left:"20%",backgroundColor:F.dialGradient2,opacity:.3,borderRadius:j.buttonSize}}),B("div",{style:{position:"absolute",inset:0,top:"40%",left:"40%",backgroundColor:F.dialGradient3,opacity:.2,borderRadius:j.buttonSize}}),B("div",{style:{width:Ze,height:Ze,borderRadius:j.buttonSize*S.centerButton.borderRadiusRatio,backgroundColor:F.hubFill,display:"flex",alignItems:"center",justifyContent:"center"},children:B("button",{ref:Z,type:"button","aria-label":n?"Close settings":"Open settings",disabled:!a,onClick:a,onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),style:{border:0,padding:0,background:"transparent",width:j.buttonSize,height:j.buttonSize,borderRadius:j.buttonSize/2,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:a?"pointer":"default",transform:O?`scale(${J.centerHover.scale})`:"scale(1)",transition:`transform ${J.centerHover.duration}ms ease`,animation:vt&&!O?Se.pulse:"none"},children:n?ge("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",fontSize:S.centerButton.text.fontSize-2,fontWeight:S.centerButton.text.fontWeight,fontFamily:S.centerButton.text.fontFamily,color:F.centerText,letterSpacing:S.centerButton.text.letterSpacing,textAlign:"center",textShadow:`0 0 4px ${F.centerTextGlow}`,textTransform:"uppercase",lineHeight:1.2},children:[B("span",{style:{marginBottom:-2},children:"CLOSE"}),B("span",{style:{marginTop:-2},children:"SETTINGS"})]}):B("span",{style:{fontSize:S.centerButton.text.fontSize,fontWeight:S.centerButton.text.fontWeight,fontFamily:S.centerButton.text.fontFamily,color:F.centerText,letterSpacing:S.centerButton.text.letterSpacing,textAlign:"center",textShadow:`0 0 4px ${F.centerTextGlow}`,textTransform:"uppercase"},children:o})})})]})]}),ae>1&&ge("div",{style:{position:"absolute",left:"50%",marginLeft:-j.circleSize/2,top:"calc(100% - 64px)",width:j.circleSize,display:"flex",alignItems:"center",justifyContent:"space-between",opacity:Math.min(1,p),transform:`scale(${Math.min(1,p)})`},children:[B(fo,{side:"prev",disabled:r<=0,onClick:()=>Qe(r-1)}),ge("span",{style:{padding:"6px 12px",fontSize:13,fontWeight:900,fontFamily:eo,letterSpacing:2,color:F.centerText,textShadow:`0 0 6px ${F.centerTextGlow}`},children:[String(r+1).padStart(2,"0"),ge("span",{style:{color:F.iconLabelMuted,textShadow:"none"},children:[" / ",String(ae).padStart(2,"0")]})]}),B(fo,{side:"next",disabled:r>=ae-1,onClick:()=>Qe(r+1)})]}),He&&!n&&B(uo,{title:"Welcome to Buoy!",message:"Tap the center button to configure and add tools to your dial menu.",onDismiss:Ae,showArrow:false})]})}import{persistentStorage as yo,devToolsStorageKeys as br}from"@buoy-gg/shared-ui/web";import{recordUsage as Sr,pruneUsage as vr}from"@buoy-gg/floating-tools-core/web";var bo=br.dial.usage(),je={},So=false,zt=null;function vo(){return zt||(zt=(async()=>{try{let e=await yo.getItem(bo);if(e){let t=JSON.parse(e);t&&typeof t=="object"&&(je=t)}}catch{}finally{So=true}})(),zt)}vo();function wr(e){return e.map((t,o)=>({id:t,index:o,lastUsed:je[t]?.lastUsed??0})).sort((t,o)=>o.lastUsed-t.lastUsed||t.index-o.index).map(({id:t})=>t)}async function xr(e){if(!e)return;So||await vo();let t=Math.max(Date.now(),...Object.values(je).map(o=>o.lastUsed+1));je=vr(Sr(je,e,t),t);try{await yo.setItem(bo,JSON.stringify(je))}catch{}}import{useCallback as Cr,useMemo as wo}from"react";import{persistentStorage as Tr}from"@buoy-gg/shared-ui/web";import{useState as oe,useEffect as ze,useCallback as lt,useMemo as ct}from"react";import{settingsEventBus as dt}from"@buoy-gg/floating-tools-core/web";import{useSyncExternalStore as zr}from"react";import{getRegisteredToolModule as kr}from"@buoy-gg/shared-ui/web";var Ir=()=>()=>{},Mr=()=>null;function Rr(){let e=kr("@buoy-gg/external-sync");return zr(e?.subscribeSyncStatus??Ir,()=>e?.getSyncStatus?.()??null,Mr)}import{SentryIcon as Ar,WifiCircuitIcon as Dr,ImageOverlayIcon as Er,RenderCountIcon as Br,Info as kt,Layers as Or,ChevronRightIcon as xo,ChevronDown as Co,getStorageBackendType as Fr,getUseLicense as Lr,signOutOfBuoy as Pr,persistentStorage as ke,Trash2 as $r,CheckCircle2 as To,LicenseEntryModal as jr,BackgroundSwitcher as Hr,night as h,NightCard as Ie,NightRows as It,NightSectionLabel as Wr,NightFootnote as zo,NightSwitch as ko,NightButton as Mt,NightSegmented as Nr,NightBadge as ue,NightSeparator as Vr,monoFont as Io}from"@buoy-gg/shared-ui/web";import{EnvIcon as Mo,StorageIcon as Ur,RoutesIcon as Kr,NetworkIcon as _r,QueryIcon as Gr,HighlighterIcon as qr,ReduxIcon as Jr,EventsIcon as Xr}from"@buoy-gg/floating-tools-core/web";import Yr,{createContext as Qr,useContext as Zr}from"react";import{jsx as es}from"react/jsx-runtime";var Ro=Qr({});function ts({children:e,defaultFloatingTools:t,defaultDialTools:o}){let a=Yr.useMemo(()=>({defaultFloatingTools:t,defaultDialTools:o}),[t,o]);return es(Ro.Provider,{value:a,children:e})}function Ao(){return Zr(Ro)}import os from"react";import{toolTheme as ns}from"@buoy-gg/shared-ui/web";import{jsx as Do}from"react/jsx-runtime";function as({label:e,size:t,color:o=ns.colors.text}){let a=Math.max(Array.from(e.replace(/[\uFE00-\uFE0F\u200D]/g,"")).length,1),n=a<=2?t:t*1.6,i=Math.max(7,Math.min(t*(a===1?.7:.62),n/(.62*a)));return Do("span",{style:{display:"inline-flex",minWidth:t,maxWidth:n,height:t,alignItems:"center",justifyContent:"center",color:o,fontSize:i,fontWeight:800,letterSpacing:.5,whiteSpace:"nowrap",overflow:"hidden"},children:e})}function Eo(e,t){return e==null?e:typeof e=="function"?os.createElement(e,{slot:t.slot,size:t.size,state:t.state,actions:t.actions}):typeof e=="string"||typeof e=="number"?Do(as,{label:String(e),size:t.size,color:t.color}):e}import{JsModal as is,devToolsStorageKeys as Rt}from"@buoy-gg/shared-ui/web";import{useSafeAreaInsets as rs}from"@buoy-gg/shared-ui/web";import{Fragment as Ve,jsx as c,jsxs as P}from"react/jsx-runtime";var ut="@react_buoy_dev_tools_settings",ss=6,pt=e=>{let t=ss,o={};for(let[a,n]of Object.entries(e))n&&t>0?(o[a]=true,t-=1):o[a]=false;return o},ls=(e,t)=>{let{userStatus:o,environment:a,...n}=e,i=t?Object.entries(n).filter(([l])=>t.includes(l)):Object.entries(n);return{...Object.fromEntries(i),environment:a??false}},Bo=(e,t,o)=>{if(!t)return e;let a={...e.dialTools,...t.dialTools??{}},n=o?.allowedDialKeys?Object.entries(a).filter(([i])=>o.allowedDialKeys?.includes(i)):Object.entries(a);return{dialTools:pt(Object.fromEntries(n)),floatingTools:ls({...e.floatingTools,...t.floatingTools??{}},o?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...t.globalSettings??{}}}},cs=(e=[],t,o)=>{let a={},n={},i=new Set(t??[]),l=new Set(o??[]),u=!o||o.length===0;for(let d of e){let{id:p,slot:m="both"}=d;(m==="dial"||m==="both")&&(a[p]=u?true:l.has(p)),(m==="row"||m==="both")&&(n[p]=i.has(p))}return{dialTools:pt(a),floatingTools:{...n,environment:i.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}},ds=({visible:e,onClose:t,onSettingsChange:o,initialSettings:a,availableApps:n=[],storage:i=ke,zIndex:l})=>{let{defaultFloatingTools:u,defaultDialTools:d}=Ao(),p=ct(()=>cs(n,u,d),[n,u,d]),m=ct(()=>Object.keys(p.dialTools),[p]),x=ct(()=>Object.keys(p.floatingTools).filter(s=>s!=="environment"),[p]),[g,R]=oe(a||Ue||p),[v,I]=oe(At??"floating"),[T,k]=oe(At!==null),[z,O]=oe(new Set),[b,M]=oe(false),[$,C]=oe(false);ze(()=>{let s=requestAnimationFrame(()=>C(true));return()=>cancelAnimationFrame(s)},[]);let A=Rr();ze(()=>{(async()=>{try{let s=await ke.getItem(Rt.settings.activeTab());if(s&&["floating","settings","pro"].includes(s)){let f=s;At=f,I(E=>E===f?E:f)}}catch{}finally{k(true)}})()},[]),ze(()=>{T&&ke.setItem(Rt.settings.activeTab(),v).catch(s=>{console.warn("Failed to save settings active tab:",s)})},[v,T]);let ee=Lr()?.(),Z=ee?.isPro??false,q=!Z&&ee?.licenseKey?ee.error:null,ce=ee?.errorKind==="transport",[K,ne]=oe(Oo),[J,Se]=oe(false),[me,ve]=oe(false),[j,Re]=oe(false),[fe,se]=oe([]),[we,ae]=oe(false),r=rs(),L=Vt.get("window").height,W=Vt.get("window").width,He=Math.floor(L*.33),Xe=Math.min(W-32,400),Ae=lt(async()=>{try{let s=await i.getItem(ut);if(s){let f=JSON.parse(s),E=Bo(p,f,{allowedDialKeys:m,allowedFloatingKeys:x});Ue=E,R(Y=>Fo(Y,E)?Y:E);return}Ue=p,R(f=>Fo(f,p)?f:p)}catch(s){console.error("Failed to load dev tools settings:",s),R(p)}},[p,m,x,i]);ze(()=>{Ae()},[Ae]),ze(()=>{Fr().then(s=>{Oo=s,ne(f=>f===s?f:s)})},[]),ze(()=>{j&&(ae(true),ke.getAllKeys().then(s=>{se(s.sort())}).catch(()=>{se([])}).finally(()=>{ae(false)}))},[j]);let Ye=async s=>{try{let f={...s,dialTools:pt(s.dialTools)};await i.setItem(ut,JSON.stringify(f)),Ue=f,R(f),o?.(f),dt.emit(f)}catch(f){console.error("Failed to save dev tools settings:",f)}},Qe=s=>{let f={...g,floatingTools:{...g.floatingTools,[s]:!g.floatingTools[s]}};Ye(f)},De=s=>{let f={...g,globalSettings:{...g.globalSettings,[s]:!g.globalSettings?.[s]}};Ye(f)},Ze=async()=>{Se(true),ve(false);try{await ke.clear(),ve(true),R(p),i!==ke&&await i.setItem(ut,JSON.stringify(p)),o?.(p),dt.emit(p),setTimeout(()=>ve(false),2e3)}catch(s){console.error("Failed to clear storage:",s)}finally{Se(false)}},St=lt(s=>{},[]),vt=s=>{let f=n.find(E=>E.id===s);return f?.description?f.description:s==="environment"?"Environment badge.":""},D=s=>s==="environment"?"Env Badge":n.find(f=>f.id===s)?.name??s.toUpperCase().replace(/_/g," "),w=s=>{if(!$)return null;switch(s){case"query":return c(Gr,{size:18});case"env":return c(Mo,{size:18});case"sentry":return c(Ar,{size:18,color:"#9945FF"});case"storage":return c(Ur,{size:18,bgColor:h.color.surface});case"wifi":case"query-wifi-toggle":return c(Dr,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return c(Kr,{size:18,bgColor:h.color.surface});case"network":return c(_r,{size:18});case"environment":return c(Mo,{size:18});case"debug-borders":return c(Or,{size:18,color:h.color.accent});case"highlight-updates":return c(Br,{size:18,color:h.color.accent});case"highlight-updates-modal":return c(qr,{size:18});case"redux":return c(Jr,{size:18});case"image-overlay":return c(Er,{size:18});case"events":return c(Xr,{size:18});case"zustand":try{let{ZustandIcon:f}=_t("@buoy-gg/zustand/web");return c(f,{size:18})}catch{return c(kt,{size:18,color:h.color.textSecondary})}case"jotai":try{let{JotaiIcon:f}=_t("@buoy-gg/jotai/web");return c(f,{size:18})}catch{return c(kt,{size:18,color:h.color.textSecondary})}default:{let f=n.find(E=>E.id===s);return f?.icon!=null?Eo(f.icon,{slot:"row",size:18,color:f.color}):c(kt,{size:18,color:h.color.textSecondary})}}},X=(s,f,E,Y)=>{let he=vt(s);return P(et,{activeOpacity:E?1:.7,onPress:()=>!E&&Y(),accessibilityLabel:D(s),accessibilityRole:"button",style:[y.toolRow,E&&y.rowDisabled],children:[c(H,{style:y.toolIconSlot,children:w(s)}),P(H,{style:y.rowInfo,children:[P(N,{style:y.rowLabel,children:[D(s),E?" \xB7 max 6":""]}),he?c(N,{style:y.rowCaption,numberOfLines:1,children:he}):null]}),c(ko,{value:f,disabled:E,onValueChange:()=>Y()})]},s)},V=s=>{O(f=>{let E=new Set(f);return E.has(s)?E.delete(s):E.add(s),E})},G=(s,f,E,Y,he)=>{let ye=g.globalSettings?.[s]??false,Ee=z.has(s);return P(H,{children:[P(et,{activeOpacity:.7,onPress:()=>V(s),accessibilityLabel:f,style:y.settingRow,children:[P(H,{style:y.rowInfo,children:[c(N,{style:y.rowLabel,children:f}),c(N,{style:y.rowCaption,numberOfLines:Ee?0:1,children:E})]}),c(ko,{value:ye,onValueChange:()=>De(s)})]}),Ee&&P(H,{style:y.settingRowBody,children:[c(N,{style:y.settingRowBodyText,children:Y}),c(N,{style:y.settingRowBodyHint,children:he})]})]},s)},_=(s,f,E)=>P(H,{children:[c(Wr,{children:s}),f,E]}),te=K==="filesystem"?c(ue,{label:"File System",tone:"accent"}):K==="asyncstorage"?c(ue,{label:"Async Storage",tone:"warning"}):K==="localstorage"?c(ue,{label:"Local Storage",tone:"accent"}):K==="memory"?c(ue,{label:"Memory",tone:"danger"}):c(ue,{label:"Loading\u2026",tone:"neutral"}),de=()=>P(H,{style:y.container,children:[P(Nt,{style:y.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:y.scrollContainer,children:[v==="floating"&&c(Ve,{children:_("Floating Tools",c(Ie,{glass:true,children:c(It,{children:Object.entries(g.floatingTools).map(([s,f])=>X(s,f,false,()=>Qe(s)))})}),c(zo,{children:"Tools switched on here appear in the floating bubble row."}))}),v==="settings"&&P(Ve,{children:[_("Background",c(Ie,{glass:true,padded:true,children:c(Hr,{embedded:true})})),_("Storage",P(Ie,{glass:true,children:[P(et,{activeOpacity:.7,onPress:()=>Re(!j),accessibilityLabel:"Storage Type",style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"Storage Type"})}),te,j?c(Co,{size:16,color:h.color.textTertiary}):c(xo,{size:16,color:h.color.textTertiary})]}),j&&P(Ve,{children:[P(H,{style:y.settingRowBody,children:[c(N,{style:y.settingRowBodyText,children:K==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":K==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":K==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":K==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),K==="asyncstorage"&&c(N,{style:[y.settingRowBodyText,y.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),K==="memory"&&c(N,{style:[y.settingRowBodyText,y.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),c(Vr,{}),P(H,{style:y.storageExpanded,children:[P(H,{style:y.storageExpandedHeader,children:[c(N,{style:y.storageExpandedTitle,children:"SAVED SETTINGS"}),c(N,{style:y.storageExpandedCount,children:we?"\u2026":`${fe.length} keys`})]}),we?c(N,{style:y.storageKeyEmpty,children:"Loading\u2026"}):fe.length===0?c(N,{style:y.storageKeyEmpty,children:"No settings saved yet"}):c(Nt,{style:y.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:fe.map(s=>c(H,{style:y.storageKeyItem,children:c(N,{style:y.storageKeyText,numberOfLines:1,children:s.replace("@react_buoy_","")})},s))})]}),c(H,{style:y.cardButtonWrap,children:c(Mt,{label:me?"Cleared":J?"Clearing\u2026":"Clear All Settings",variant:me?"secondary":"destructive",size:"md",disabled:J,onPress:Ze,icon:me?c(To,{size:15,color:h.color.accent}):c($r,{size:15,color:J?h.color.textTertiary:h.color.danger})})})]})]})),A&&A.state!=="idle"&&_("Desktop Sync",P(Ie,{glass:true,children:[P(et,{activeOpacity:.7,onPress:()=>V("desktopSync"),accessibilityLabel:"Buoy Desktop",style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"Buoy Desktop"})}),A.state==="connected"?c(ue,{label:"Connected",tone:"accent"}):A.state==="connecting"?c(ue,{label:"Connecting\u2026",tone:"neutral"}):c(ue,{label:"Retrying",tone:"warning"}),z.has("desktopSync")?c(Co,{size:16,color:h.color.textTertiary}):c(xo,{size:16,color:h.color.textTertiary})]}),z.has("desktopSync")&&P(H,{style:y.settingRowBody,children:[P(N,{style:y.settingRowBodyText,children:[A.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",c(N,{style:y.footnoteMono,children:A.targetURL??"(unknown URL)"}),A.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),A.state==="retrying"&&A.lastError&&P(N,{style:[y.settingRowBodyText,y.bodyWarning],children:["Last error: ",A.lastError]})]})]})),_("Modal Behavior",c(Ie,{glass:true,children:P(It,{children:[G("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),Be.OS!=="web"?G("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),v==="pro"&&P(Ve,{children:[_("License",P(Ie,{glass:true,children:[P(H,{style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"License Status"})}),c(H,{testID:"buoy-settings-license-status",accessibilityLabel:Z?"License: Active":"License: Free",children:Z?c(ue,{label:"Active",tone:"accent"}):c(ue,{label:"Free",tone:"neutral"})})]}),ee?.tierSource==="session"?P(H,{style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"Signed in with Buoy"})}),c(Mt,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void Pr(),testID:"buoy-settings-signout"})]}):null]}),c(zo,{children:Z?"You have full access to all Buoy DevTools features.":q?ce?`Couldn't reach the license server (${q}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${q}.`:"Upgrade to Pro to unlock all features and support development."})),!Z&&P(Ve,{children:[_("Pro Features",c(Ie,{glass:true,children:c(It,{children:["Advanced Settings","Priority Support"].map(s=>P(H,{style:y.featureRow,children:[c(To,{size:16,color:h.color.accent}),c(N,{style:y.rowLabel,children:s})]},s))})})),c(Mt,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>M(true)})]})]})]}),c(jr,{visible:b,onClose:()=>M(false),onSuccess:()=>M(false)})]});return c(is,{visible:e,onClose:t,zIndex:l,variant:"night",header:{showToggleButton:false,customContent:c(H,{style:y.headerRow,children:c(Nr,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:v,onChange:s=>I(s)})})},initialMode:"bottomSheet",onModeChange:St,persistenceKey:Rt.settings.root(),enablePersistence:true,maxHeight:L-r.top,initialHeight:He,initialFloatingPosition:{x:(W-Xe)/2,y:r.top+20},enableGlitchEffects:true,children:de()})},us={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}},ps=(e,t)=>{let o=new Set(e??[]),a=new Set(t??[]),n={};for(let l of a)n[l]=true;let i={environment:o.has("environment")};for(let l of o)l!=="environment"&&(i[l]=true);return{dialTools:pt(n),floatingTools:i,globalSettings:{enableSharedModalDimensions:false}}},Ue=null,At=null,Oo=null,Fo=(e,t)=>JSON.stringify(e)===JSON.stringify(t);dt.addListener(e=>{e&&(Ue=e)});var ms=()=>{let{defaultFloatingTools:e,defaultDialTools:t}=Ao(),o=ct(()=>!e&&!t?us:ps(e,t),[e,t]),[a,n]=oe(o),i=lt(async()=>{try{let u=await ke.getItem(ut);if(u){let d=JSON.parse(u),p=Bo(o,d);n(p);return}n(o)}catch(u){console.error("Failed to load dev tools settings:",u),n(o)}},[o]);ze(()=>{i();let u=dt.addListener(d=>{try{d&&n(d)}catch{}});return()=>{u()}},[i]);let l=lt(()=>{i()},[i]);return{settings:a,refreshSettings:l}},y=Ut.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:h.gutter,paddingRight:h.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:h.gutter,paddingTop:8,paddingBottom:24,gap:h.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:h.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:h.rowPadH,paddingVertical:h.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:h.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:h.color.text,fontSize:h.font.row,fontWeight:"500"},rowCaption:{color:h.color.textTertiary,fontSize:h.font.label},settingRowBody:{paddingHorizontal:h.rowPadH,paddingBottom:h.rowPadV,gap:6},settingRowBodyText:{color:h.color.textSecondary,fontSize:h.font.caption,lineHeight:h.font.caption*1.45},settingRowBodyHint:{color:h.color.textTertiary,fontSize:h.font.caption,lineHeight:h.font.caption*1.45},bodyWarning:{color:h.color.warning},bodyDanger:{color:h.color.danger},cardButtonWrap:{paddingHorizontal:h.cardPad,paddingTop:10,paddingBottom:h.cardPad},storageExpanded:{paddingHorizontal:h.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:h.color.textSecondary,fontSize:h.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:h.color.textTertiary,fontSize:h.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:h.color.glassElevated,borderRadius:h.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:h.color.textSecondary,fontSize:h.font.micro,fontFamily:Io},storageKeyEmpty:{color:h.color.textTertiary,fontSize:h.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:Io,fontSize:h.font.label,color:h.color.textSecondary}});import{jsx as Lo}from"react/jsx-runtime";var gs=[];function Po({visible:e,onClose:t,availableTools:o=gs,defaultFloatingTools:a,defaultDialTools:n,storage:i=Tr,onSettingsChange:l}){let u=wo(()=>({getItem:async m=>i.getItem(m),setItem:async(m,x)=>i.setItem(m,x)}),[i]),d=wo(()=>o.map(m=>({...m,name:m.name??m.id,icon:typeof m.icon=="function"?x=>m.icon(x.size):m.icon})),[o]),p=Cr(m=>{l?.(m)},[l]);return Lo(ts,{defaultFloatingTools:a,defaultDialTools:n,children:Lo(ds,{visible:e,onClose:t,zIndex:11e3,availableApps:d,storage:u,onSettingsChange:p})})}import{persistentStorage as $o}from"@buoy-gg/shared-ui/web";import{createContext as fs,useCallback as be,useContext as hs,useEffect as Dt,useMemo as ys,useRef as Ke,useState as jo}from"react";var bs=(e,t,o)=>{if(t.singleton){let n=e.find(i=>i.id===t.id);if(n){let i=n.minimized??false;return{instanceId:n.instanceId,wasMinimized:i,apps:[...e.filter(l=>l.instanceId!==n.instanceId),{...n,minimized:false}]}}}let a=o();return{instanceId:a,wasMinimized:false,apps:[...e,{...t,instanceId:a}]}};import{createContext as Ss,useCallback as Ho,useContext as vs,useEffect as mt,useMemo as ws,useRef as Wo,useState as gt}from"react";import{JsModal as xs,ModalHeader as _e,HeaderSearchButton as Cs,TickProvider as Ts,ToolScreenHeaderContext as zs,devToolsStorageKeys as No,buoyColors as Vo,gameUIColors as Et}from"@buoy-gg/shared-ui/web";import{jsx as ie,jsxs as ft}from"react/jsx-runtime";var Ge=()=>{},ks={search:"",isSearchActive:false,clearSearch:Ge,close:Ge,minimize:Ge,showToast:Ge,setHeaderOverride:Ge},Uo=Ss(null);function Ko(){return vs(Uo)??ks}function Is(e,t){let{setHeaderOverride:o}=Ko();mt(()=>(o(e),()=>o(null)),t)}var _o=2200,Ms={success:Et.success,error:Et.error,info:Et.info};function Rs({message:e,type:t,nonce:o}){let a=Wo(new xe.Value(0)).current;mt(()=>{a.setValue(0),xe.sequence([xe.timing(a,{toValue:1,duration:150,useNativeDriver:true}),xe.delay(_o-450),xe.timing(a,{toValue:0,duration:300,useNativeDriver:true})]).start()},[o,a]);let n=Ms[t];return ft(xe.View,{pointerEvents:"none",style:[ht.toast,{opacity:a,borderColor:n+"60"}],children:[ie(H,{style:[ht.toastDot,{backgroundColor:n}]}),ie(N,{style:ht.toastText,numberOfLines:2,children:e})]})}function As({app:e,config:t,visible:o,zIndex:a,onClose:n,onMinimize:i,initialModalState:l,enableSharedModalDimensions:u,bodyProps:d}){let p=e.component,[m,x]=gt(false),[g,R]=gt(""),[v,I]=gt(null),[T,k]=gt(null),z=Wo(null),O=Ho(()=>{x(false),R("")},[]),b=Ho((K,ne="info")=>{z.current&&clearTimeout(z.current),k(J=>({message:K,type:ne,nonce:(J?.nonce??0)+1})),z.current=setTimeout(()=>k(null),_o)},[]);mt(()=>()=>{z.current&&clearTimeout(z.current)},[]);let M=ws(()=>({search:m?g:"",isSearchActive:m,clearSearch:O,close:n,minimize:()=>i(),showToast:b,setHeaderOverride:I,instanceId:e.instanceId}),[g,m,O,n,i,b,e.instanceId]),$=v?.title??t.title??e.title??e.id,C=v?.subtitle??t.subtitle,A=v?.onBack,ee=v?.actions??t.headerActions,Z=v?.searchable??t.searchable;mt(()=>{!Z&&m&&O()},[Z,m,O]);let q=u?No.modal.root():No.custom(e.id).modal(),ce=ft(_e,{children:[A&&!m&&ie(_e.Navigation,{onBack:A}),m?ie(_e.Search,{value:g,onChangeText:R,onCancel:O,placeholder:t.searchPlaceholder,testID:`tool-search-field-${e.id}`}):ie(_e.Content,{title:$,subtitle:C}),ft(_e.Actions,{children:[!m&&ee,Z&&!m&&ie(Cs,{variant:"chip",testID:`tool-search-${e.id}`,onPress:()=>x(true)})]})]});return ie(Uo.Provider,{value:M,children:ie(xs,{visible:o,onClose:n,onBack:A,onMinimize:i,initialModalState:l,zIndex:a,persistenceKey:q,enablePersistence:true,initialMode:t.initialMode??"bottomSheet",header:{customContent:ce,showToggleButton:true},disableScrollWrapper:true,styles:{},children:ft(H,{style:ht.bodyRoot,children:[ie(Ts,{children:ie(zs.Provider,{value:I,children:ie(p,{...d})})}),T&&ie(Rs,{message:T.message,type:T.type,nonce:T.nonce})]})})})}var ht=Ut.create({bodyRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},toast:{position:"absolute",bottom:16,alignSelf:"center",flexDirection:"row",alignItems:"center",gap:8,maxWidth:"86%",backgroundColor:Vo.card,borderWidth:1,borderRadius:8,paddingHorizontal:12,paddingVertical:8,shadowColor:"#000",shadowOpacity:.4,shadowRadius:8,shadowOffset:{width:0,height:2},elevation:6},toastDot:{width:6,height:6,borderRadius:3},toastText:{flex:1,fontSize:12,color:Vo.text}});import{Fragment as Ds,jsx as pe}from"react/jsx-runtime";var Go=fs(null),qo="@react_buoy_open_apps",Bt=44,Es=12,Bs=100,Os=16,Fs=e=>({x:window.innerWidth-Bt-Os,y:window.innerHeight-Bs-Bt-e*(Bt+Es)}),Jo=({children:e})=>{let[t,o]=jo([]),[a,n]=jo(false),i=Ke([]),l=Ke(null),u=Ke(false),d=Ke(false),p=Ke(false),m=be(b=>{let M="";return o($=>{let{apps:C,instanceId:A}=bs($,b,()=>`${b.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`);return M=A,C}),M},[]),x=be(()=>{if(u.current||!d.current||!p.current)return;u.current=true;let b=l.current;if(!b||b.length===0){n(true);return}l.current=null,b.forEach(({id:M,minimized:$})=>{let C=i.current.find(A=>A.id===M);if(C&&C.component){let A=Eo(C.icon,{slot:"dial",size:20,color:C.color});m({id:C.id,title:C.name,component:C.component,props:C.props,modal:C.modal,launchMode:C.launchMode||"self-modal",singleton:C.singleton??true,icon:A,color:C.color,minimized:$})}}),n(true)},[m]);Dt(()=>{let b=false;return(async()=>{try{let M=await $o.getItem(qo);if(b)return;if(M){let $=JSON.parse(M),C;Array.isArray($)&&$.length>0&&(typeof $[0]=="string"?C=$.map(A=>({id:A,minimized:false})):C=$.filter(A=>typeof A=="object"&&A!==null&&typeof A.id=="string"),C.length&&(l.current=C))}}catch{}b||(d.current=true,x())})(),()=>{b=true}},[x]),Dt(()=>{if(!a)return;let b=t.map(M=>({id:M.id,minimized:M.minimized??false}));$o.setItem(qo,JSON.stringify(b))},[t,a]);let g=be(b=>{i.current=b,p.current=true,x()},[x]),R=be(b=>{o(M=>M.length?b?M.filter($=>$.instanceId!==b):M.slice(0,-1):M)},[]),v=be(()=>o([]),[]),I=be((b,M)=>{o($=>$.map(C=>C.instanceId===b?{...C,minimized:true,restoreState:M}:C))},[]),T=be((b,M)=>{o($=>$.map(C=>C.instanceId===b?{...C,minimized:false,restoreState:M??C.restoreState}:C))},[]),k=be(b=>t.find(M=>M.instanceId===b)?.minimized??false,[t]),z=t.some(b=>b.launchMode!=="toggle-only"&&!b.minimized);Dt(()=>{if(!z)return;let b=M=>{if(M.key!=="Escape"||M.defaultPrevented)return;let $=[...t].reverse().find(C=>C.launchMode!=="toggle-only"&&!C.minimized);$&&R($.instanceId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[z,R,t]);let O=ys(()=>({openApps:t,isAnyOpen:z,open:m,close:R,closeAll:v,registerApps:g,minimize:I,restore:T,isMinimized:k}),[t,z,m,R,v,g,I,T,k]);return pe(Go.Provider,{value:O,children:e})},yt=()=>{let e=hs(Go);return e||{openApps:[],isAnyOpen:false,open:()=>"",close:()=>{},closeAll:()=>{},registerApps:()=>{},minimize:()=>{},restore:()=>{},isMinimized:()=>false}},Ls=9e3,Ps={position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.28)",display:"flex",alignItems:"center",justifyContent:"center"},$s={maxHeight:"90%",width:"94%",borderRadius:12,backgroundColor:"white",overflow:"hidden"},js=({app:e,zIndex:t,onClose:o,onMinimize:a,minimizeTargetPosition:n,enableSharedModalDimensions:i})=>{let l=e.component,u=!e.minimized,d={...e.props??{},...i?{enableSharedModalDimensions:true}:{}};return e.modal&&(!e.launchMode||e.launchMode==="self-modal")?pe(As,{app:e,config:e.modal,visible:u,zIndex:t,onClose:o,onMinimize:a,initialModalState:e.restoreState,enableSharedModalDimensions:i,bodyProps:d}):e.launchMode==="self-modal"?pe(l,{...d,visible:u,onClose:o,onRequestClose:o,onMinimize:a,minimizeTargetPosition:n,instanceId:e.instanceId,zIndex:t,initialModalState:e.restoreState}):e.launchMode==="inline"?u?pe("div",{style:{position:"fixed",inset:0,zIndex:t,pointerEvents:"none"},children:pe(l,{...d,onClose:o,onMinimize:a,minimizeTargetPosition:n,instanceId:e.instanceId})}):null:pe("div",{style:{...Ps,zIndex:t,display:u?"flex":"none"},children:pe("div",{style:$s,children:pe(l,{...d,onClose:o,onMinimize:a,minimizeTargetPosition:n,instanceId:e.instanceId})})})},Xo=()=>{let{openApps:e,close:t,minimize:o}=yt(),{settings:a}=ms(),n=e.filter(u=>u.launchMode!=="toggle-only");if(n.length===0)return null;let i=n.filter(u=>u.minimized).length,l=Li()??Fs(i);return pe(Ds,{children:n.map((u,d)=>pe(js,{app:u,zIndex:Ls+d,onClose:()=>t(u.instanceId),onMinimize:p=>o(u.instanceId,p),enableSharedModalDimensions:a.globalSettings?.enableSharedModalDimensions===true,minimizeTargetPosition:l},u.instanceId))})};import{useCallback as Hs,useEffect as Ot,useRef as Ws,useState as Yo,useSyncExternalStore as Qo}from"react";import{persistentStorage as Zo,getToolAttention as Ft,subscribeToolAttention as en}from"@buoy-gg/shared-ui/web";import{jsx as re,jsxs as bt}from"react/jsx-runtime";function Ns(e){return Qo(en,()=>Ft(e),()=>Ft(e))}var tn={needsInput:"#FF8329",done:"#20C997",failed:"#FF3B30"},on={needsInput:3,failed:2,done:1},nn=new Map;function an(e){let t=null;for(let a of e?e.split("|"):[]){let n=Ft(a);n&&(!t||on[n.kind]>on[t.kind])&&(t=n)}let o=nn.get(e);return o&&t&&o.kind===t.kind&&o.label===t.label?o:!o&&!t?null:(nn.set(e,t),t)}function Vs(e){let t=e.join("|");return Qo(en,()=>an(t),()=>an(t))}var rn=28,Lt=32,Pt=6,sn=8,ln=24,cn="@react_buoy_minimized_stack_expanded",Us=80,dn=2e3,Ks=6e3,_s="#1A1A1A",qe="#888888";function un({down:e=false}){return re("svg",{width:12,height:12,viewBox:"0 0 24 24","aria-hidden":"true",style:{transform:e?"rotate(180deg)":void 0},children:re("path",{d:"M18 15l-6-6-6 6",fill:"none",stroke:qe,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Gs({id:e,title:t,icon:o,index:a,onPress:n}){let i=Ns(e),l=Ws(null);return Ot(()=>{let u=true,d,p=()=>{l.current?.animate([{transform:"translateX(0) scale(1)",opacity:1,offset:0},{transform:"translateX(3px) scale(1.05)",opacity:.4,offset:.2},{transform:"translateX(-3px) scale(1.1)",opacity:1,offset:.4},{transform:"translateX(2px) scale(1.0)",opacity:.6,offset:.6},{transform:"translateX(-1px) scale(0.95)",opacity:1,offset:.8},{transform:"translateX(0) scale(1)",opacity:1,offset:1}],{duration:Us,easing:"linear"})},m=x=>{let g=x?500+Math.random()*1500+a*200:dn+Math.random()*(Ks-dn)+a*300;d=setTimeout(()=>{u&&(p(),m(false))},g)};return m(true),()=>{u=false,clearTimeout(d)}},[a]),bt("button",{type:"button","aria-label":i?`${t} \u2014 ${i.label}. Restore`:`Restore ${t}`,onClick:n,style:{width:Lt,height:Lt,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",padding:0,cursor:"pointer",position:"relative"},children:[re("div",{ref:l,style:{display:"flex",alignItems:"center",justifyContent:"center"},children:o}),i?re("span",{"aria-hidden":true,"data-testid":`buoy-dock-badge-${e}-${i.kind}`,style:{position:"absolute",top:0,right:0,minWidth:12,height:12,borderRadius:6,padding:"0 2px",boxSizing:"border-box",background:tn[i.kind],border:"1.5px solid #0C0C0C",color:"#000",fontSize:8,fontWeight:800,lineHeight:"9px",display:"flex",alignItems:"center",justifyContent:"center"},children:i.kind==="needsInput"?"!":""}):null]})}function qs({containerWidth:e=32}){let{openApps:t,restore:o}=yt(),a=t.filter(g=>g.minimized&&g.launchMode!=="toggle-only"),[n,i]=Yo(false),[l,u]=Yo(false),d=Vs(a.map(g=>g.id));Ot(()=>{let g=false;return(async()=>{let R=await Zo.getItem(cn);!g&&R==="true"&&i(true),g||u(true)})(),()=>{g=true}},[]),Ot(()=>{l&&Zo.setItem(cn,n?"true":"false")},[n,l]);let p=Hs(g=>{o(g)},[o]);if(a.length===0)return null;let m=sn+a.length*Lt+(a.length-1)*Pt+Pt+ln+4,x={backgroundColor:_s,borderTopLeftRadius:6,borderTopRightRadius:6,borderTop:`1px solid ${qe}66`,borderLeft:`1px solid ${qe}66`,borderRight:`1px solid ${qe}66`,borderBottom:"none",boxSizing:"border-box"};return bt("div",{style:{height:rn,overflow:"visible",position:"relative"},children:[re("div",{style:{position:"absolute",bottom:"var(--buoy-stack-bottom, 0px)",top:"var(--buoy-stack-top, auto)",left:0,width:e,maxHeight:"var(--buoy-stack-space, calc(100vh - 48px))",visibility:n?"visible":"hidden",height:n?m:0,opacity:n?1:0,overflowY:"auto",overflowX:"hidden",transition:"height 200ms ease, opacity 200ms ease",pointerEvents:n?"auto":"none",...x},children:bt("div",{style:{height:m,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:sn,gap:Pt,boxSizing:"border-box"},children:[[...a].reverse().map((g,R)=>re(Gs,{id:g.id,title:g.title||g.id,icon:g.icon??re("span",{style:{color:"#fff",fontSize:13},children:(g.title||g.id).slice(0,1).toUpperCase()}),index:R,onPress:()=>p(g.instanceId)},g.instanceId)),re("button",{type:"button","aria-label":"Collapse",onClick:()=>i(false),style:{width:"100%",height:ln,marginTop:3,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",padding:0},children:re(un,{down:true})})]})}),bt("button",{type:"button","aria-label":`Show ${a.length} minimized tools`,tabIndex:n?-1:0,"aria-hidden":n,onClick:()=>i(true),style:{position:"absolute",bottom:0,left:0,width:e,height:rn,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:2,cursor:"pointer",padding:0,opacity:n?0:1,transform:n?"scale(0.9)":"scale(1)",transition:"opacity 200ms ease, transform 200ms ease",pointerEvents:n?"none":"auto",...x},children:[re(un,{}),d?re("span",{"aria-hidden":true,"data-testid":"buoy-dock-peek-attention",style:{position:"absolute",top:2,right:2,minWidth:11,height:11,borderRadius:6,padding:"0 2px",boxSizing:"border-box",background:tn[d.kind],border:"1.5px solid #0C0C0C",color:"#000",fontSize:8,fontWeight:800,lineHeight:"9px",display:"flex",alignItems:"center",justifyContent:"center"},children:d.kind==="needsInput"?"!":""}):null,a.length>1&&re("span",{style:{fontSize:9,fontWeight:600,color:qe,marginLeft:1},children:a.length})]})]})}import{registerToolModules as Js}from"@buoy-gg/shared-ui/web";import{createElement as Xs}from"react";function pn(e){let t=e.icon;return{...e,icon:typeof t=="function"?o=>Xs(t,{size:o,slot:e.slot??"both",color:e.color}):()=>t}}import{createContext as Ys,useContext as Qs,useState as mn,useMemo as gn}from"react";import{jsx as Zs}from"react/jsx-runtime";var fn=Ys(null);function hn({children:e}){let[t,o]=mn(false),[a,n]=mn(false),i=gn(()=>t||a,[t,a]),l=gn(()=>({isDialOpen:t,isToolOpen:a,isDevToolsActive:i,setDialOpen:o,setToolOpen:n}),[t,a,i]);return Zs(fn.Provider,{value:l,children:e})}function $t(){let e=Qs(fn);return e||{isDialOpen:false,isToolOpen:false,isDevToolsActive:false,setDialOpen:()=>{},setToolOpen:()=>{}}}import*as el from"@buoy-gg/license/web";import*as tl from"@buoy-gg/shared-ui/web";import*as ol from"@buoy-gg/shared-ui/web/dataViewer";function yn(e){Js({core:{useDevToolsVisibility:$t},license:el,"shared-ui":tl,"shared-ui/dataViewer":ol,...e});let t=new Set;return Object.values(e).flatMap(o=>Object.entries(o).flatMap(([a,n])=>!a.endsWith("Preset")||!n||typeof n.id!="string"||!n.component||t.has(n.id)?[]:(t.add(n.id),[pn(n)])))}import{useEffect as jt,useMemo as Ht,useRef as nl}from"react";import{LicenseManager as al,useLicense as il}from"@buoy-gg/license/web";import{registerToolAdapters as rl}from"@buoy-gg/shared-ui/web";function bn(e){return typeof e=="object"&&e!==null?e:void 0}function sl({isDevelopment:e,isLicensed:t,externalSync:o,isAvailable:a}){if(o===false||!a)return false;if(e)return true;let n=bn(o);return t&&n?.enableInRelease===true&&vn(n.socketURL,n)===null}var Sn="http://localhost:42831";function ll(e){return e==="localhost"||e.endsWith(".localhost")||/^127\.\d+\.\d+\.\d+$/.test(e)||e==="[::1]"||e==="::1"||e==="10.0.2.2"}function vn(e,t){let o=e??Sn;if(t?.allowInsecureNetwork===true)return null;let a;try{a=new URL(o)}catch{return`[Buoy] externalSync.socketURL "${o}" isn't a valid URL, so this release build won't connect to Buoy Desktop.`}return a.protocol==="https:"||a.protocol==="wss:"||ll(a.hostname)?null:`[Buoy] This release build won't connect to ${o}: release sync carries real user data, and plain http to another machine is readable by anyone on the same network. Use a simulator, an emulator or adb reverse (localhost), an https:// broker, or set externalSync.allowInsecureNetwork: true for a network you trust.`}var cl={impersonate:["searchUsers","startImpersonation","resumeImpersonation","updateSettings","removeFromHistory","clearHistory"]};function dl(e,t,o){if(t)return e;let a=null;for(let[n,i]of Object.entries(cl)){if(o?.includes(n))continue;let l=e[n];if(!l?.actions)continue;let u={...l.actions};for(let d of i)d in u&&(u[d]=()=>{throw new Error(`${n}.${d} is off in release builds. To allow it from Buoy Desktop and the MCP, pass externalSync={{ enableInRelease: true, releaseActions: ["${n}"] }}.`)});a??(a={...e}),a[n]={...l,actions:u}}return a??e}import{useEffect as ul,useMemo as pl,useState as ml}from"react";import{devToolsStorageKeys as gl,persistentStorage as fl}from"@buoy-gg/shared-ui/web";var hl=8;function yl(){let e="";for(;e.length<hl;)e+=(Math.random()*16|0).toString(16);return e}function bl(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")}function Sl({appName:e,hardwareName:t,platform:o,installId:a,deviceId:n}){let i=bl(e??"buoy")||"buoy",l=e??"Buoy Device",u=t?.trim()||o;return n?{deviceId:n,deviceName:`${l} (${u})`}:{deviceId:`${i}-${o}-${a}`,deviceName:`${l} (${u} \xB7 ${a.slice(-4)})`}}function vl(){let e=globalThis;try{return e.sessionStorage??null}catch{return null}}async function wl({platform:e=Be.OS,store:t,mint:o=yl}={}){let a=gl.sync.deviceId(),n=t===void 0?e==="web"?vl():fl:t;if(!n)return o();try{let i=await n.getItem(a);if(i&&i.length>0)return i;let l=o();return await n.setItem(a,l),l}catch{return o()}}var Wt=null;function xl(){return Wt||(Wt=wl()),Wt}function Cl(e,t){let o=e?.deviceId,a=e?.deviceName,n=t.loadId??xl,i=t.platform??Be.OS,[l,u]=ml(null);return ul(()=>{if(o)return;let d=false;return n().then(p=>{d||u(p)}),()=>{d=true}},[o,n]),pl(()=>{if(!o&&!l)return null;let d=Sl({appName:t.appName,hardwareName:t.hardwareName,platform:i,installId:l??"",deviceId:o});return a?{...d,deviceName:a}:d},[o,a,l,t.appName,t.hardwareName,i])}import{getDevServerOrigin as Tl,resolveReloadStrategy as zl,scheduleReloadApp as kl}from"@buoy-gg/shared-ui/web";var wn=Date.now(),xn=Tl(),Il={platform:Be.OS,isTV:Be.isTV===true,isTVOS:Be.isTVOS===true},Cn={version:3,getSnapshot:()=>{let e=zl("auto");return{startedAt:wn,devServerOrigin:xn,device:Il,reload:{available:e!==null,strategy:e}}},subscribe:e=>()=>{},actions:{ping:()=>({ok:true,startedAt:wn,devServerOrigin:xn}),reloadApp:e=>{let t=e??{},{strategy:o,delayMs:a}=kl({strategy:t.strategy,delayMs:t.delayMs});return{scheduled:true,strategy:o,delayMs:a}}}};import{Fragment as Ml,jsx as Me,jsxs as Rl}from"react/jsx-runtime";var Al=["ConsoleRoot","RouteTracker","ReactQueryTracker","ReduxAutoInstrument","PerfMonitorRoot","AutomationResumer","ImagesRoot"],Dl=["DebugBordersStandaloneOverlay","HighlightUpdatesOverlay","ImageOverlayStandalone","PerfMonitorOverlay","JsTopHudOverlay","ImpersonateOverlay","ScenariosOverlay"];function El(e){let t=Ht(()=>Object.fromEntries(Object.entries(e.modules).map(([a,n])=>[a.replace(/^@buoy-gg\//,"").replace(/\/web$/,""),n])),[e.modules]),o=t["react-query"];return o?.useReactQuerySyncAdapter?Me(Bl,{...e,modules:t,query:o}):Me(Tn,{...e,modules:t})}function Bl(e){let t=e.query.useReactQuerySyncAdapter();return Me(Tn,{...e,queryAdapter:t})}function Tn({modules:e,apps:t,requiredEnvVars:o,externalSync:a,headless:n,sentryGetClient:i,queryAdapter:l}){let{isPro:u,tier:d}=il(),p=Ht(()=>{let T={app:Cn};for(let[k,z]of Object.entries(e))for(let[O,b]of Object.entries(z))O.endsWith("SyncAdapter")&&b&&typeof b=="object"&&(T[k]=b);l&&(T.query=l),e.env?.createEnvSyncAdapter&&(T.env=e.env.createEnvSyncAdapter(o??[]));for(let k of t??[])k.sync&&(T[`custom:${k.id}`]=k.sync);return T},[e,t,o,l]),m=nl(p);m.current=p,jt(()=>rl(()=>m.current),[]),jt(()=>{let T=[],k=z=>{let O=z?.();typeof O=="function"&&T.push(O)};return k(e.network?.startNetworkCapture),k(e.storage?.startBrowserStorageCapture),k(e.assets?.startBrowserAssetCapture),e.storage?.storageSyncAdapter?.subscribe&&k(()=>e.storage.storageSyncAdapter.subscribe(()=>{})),e["focus-inspector"]?.focusInspectorSyncAdapter?.subscribe&&k(()=>e["focus-inspector"].focusInspectorSyncAdapter.subscribe(()=>{})),()=>{for(let z of T.reverse())z()}},[e]);let x=e["external-sync"],g=typeof tt<"u"?tt:process.env.NODE_ENV!=="production",R=sl({isDevelopment:g,isLicensed:u,externalSync:a,isAvailable:!!x}),v=bn(a);!g&&v?.enableInRelease&&Ol(vn(v.socketURL,v));let I=e.sentry?.SentryRoot;return Rl(Ml,{children:[Object.entries(e).flatMap(([T,k])=>Al.map(z=>{let O=k[z];return O?Me(O,{},`${T}:${z}`):null})),I&&Me(I,{getClient:i}),Object.entries(e).flatMap(([T,k])=>Dl.map(z=>{let O=k[z];return O&&(!n||z==="ScenariosOverlay"||z==="ImpersonateOverlay")?Me(O,{},`${T}:${z}`):null})),R&&Me(Fl,{module:x,tools:p,options:v,isPro:u,tier:d,dev:g})]})}var zn=null;function Ol(e){!e||e===zn||(zn=e,console.warn(e))}function Fl({module:e,tools:t,options:o,isPro:a,tier:n,dev:i}){let l=Cl(o,{appName:typeof document>"u"?null:document.title||location.hostname,hardwareName:"Browser",platform:"web"}),{socket:u}=e.useExternalSyncSocket({deviceName:l?.deviceName??"Buoy Browser",socketURL:o?.socketURL??(i?e.getDefaultSocketURL():Sn),persistentDeviceId:l?.deviceId??null,platform:"web",enableLogs:o?.enableLogs});jt(()=>{if(!u)return;let m=()=>{u.connected&&al.hasAccountAccess()&&u.emit("device-license",{isPro:a?"1":"0",tier:n})};return m(),u.on("connect",m),()=>{u.off("connect",m)}},[u,a,n]);let d=o?.releaseActions?.join(",")??"",p=Ht(()=>dl(t,i,d?d.split(","):void 0),[t,i,d]);return e.useExternalSync({tools:p,socket:u,deviceId:l?.deviceId??null,enableLogs:o?.enableLogs}),null}import{useState as kn}from"react";import{createPortal as Ll}from"react-dom";import{useBuoySession as Pl}from"@buoy-gg/license/web";import{Fragment as In,jsx as Je,jsxs as Mn}from"react/jsx-runtime";var Rn="#20C997";function $l(){let{status:e,signIn:t,signOut:o}=Pl(),[a,n]=kn(false),[i,l]=kn(null);if(typeof document>"u")return null;let u=()=>{l(null),n(true),t().catch(p=>l(p instanceof Error?p.message:"Sign-in did not work. Try again.")).finally(()=>n(false))},d=e.state==="active";return Ll(Je("div",{"data-buoy-signin":"",style:{position:"fixed",right:"max(16px, env(safe-area-inset-right))",bottom:"max(20px, env(safe-area-inset-bottom))",zIndex:99999,maxWidth:"min(320px, calc(100vw - 32px))",padding:d||i?"12px 14px":0,borderRadius:16,background:d||i?"#0f1419":"transparent",color:"#e6edf3",boxShadow:d||i?"0 10px 30px rgba(0,0,0,.35)":"none",fontFamily:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:14,lineHeight:1.45},children:d?Mn(In,{children:[Je("div",{"data-testid":"buoy-signin-needs-plan",children:"Buoy on a live site needs a Pro or Business plan."}),Je("button",{type:"button",onClick:()=>void o(),style:jl,"data-testid":"buoy-signout",children:"Sign out"})]}):Mn(In,{children:[i?Je("div",{role:"alert",style:{marginBottom:10},"data-testid":"buoy-signin-error",children:i}):null,Je("button",{type:"button",onClick:u,disabled:a,"data-testid":"buoy-signin",style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 16px",border:"none",borderRadius:999,background:Rn,color:"#04130d",fontWeight:600,fontSize:14,cursor:a?"wait":"pointer",boxShadow:"0 8px 24px rgba(0,0,0,.3)"},children:a?"Signing in\u2026":"Sign in to Buoy"})]})}),document.body)}var jl={marginTop:8,padding:0,border:"none",background:"none",color:Rn,fontSize:14,cursor:"pointer",textDecoration:"underline"};import{jsx as U,jsxs as An}from"react/jsx-runtime";var Hl={},Dn="@react_buoy_floating_menu_tooltip_shown",Wl=Ce;function Nl({size:e=14,color:t="#20C997"}){let o=Math.max(2,e/4),a=Math.max(1,e/16);return U("div",{style:{display:"grid",gridTemplateColumns:`repeat(3, ${o}px)`,gap:a,width:e,height:e,alignContent:"center",justifyContent:"center"},children:Array.from({length:9}).map((n,i)=>U("div",{style:{width:o,height:o,borderRadius:o/2,backgroundColor:t}},i))})}function Vl(e){return U(hn,{children:U(Jo,{children:U(Ul,{...e})})})}function Ul({environment:e,userRole:t,availableEnvironments:o,onEnvironmentSwitch:a,apps:n,modules:i=Hl,externalSync:l,requiredEnvVars:u,sentryGetClient:d,disableHints:p=false,headless:m=false}){let[x,g]=wt(false),[R,v]=wt(false),I=Ii(false),T=yt(),k=Oe(()=>qt([...yn(i),...n??[]]),[n,i]),z=$t(),O=T.openApps.some(r=>!r.minimized);le(()=>{z.setDialOpen(x)},[x,z.setDialOpen]),le(()=>{z.setToolOpen(O||R)},[O,R,z.setToolOpen]);let{registerApps:b}=T;le(()=>{b(k.map(r=>{let L=r.icon;return{...r,icon:typeof L=="function"?({size:W})=>L(W):L}}))},[b,k]);let M=Oe(()=>k.map(r=>({id:r.id,name:r.name,description:r.description,slot:r.slot})),[k]),{settings:$}=Mi({availableTools:M,storage:Wl});le(()=>{let r=false;return(async()=>{let[L,W]=await Promise.all([Ce.getItem(nt.dial.isOpen()),Ce.getItem(nt.settings.modalOpen())]);r||(L==="true"&&g(true),W==="true"&&(g(true),v(true)),I.current=true)})(),()=>{r=true}},[]),le(()=>{I.current&&Ce.setItem(nt.dial.isOpen(),x?"true":"false")},[x]),le(()=>{I.current&&Ce.setItem(nt.settings.modalOpen(),R?"true":"false")},[R]);let C=Fe(r=>{if(xr(r.id),r.launchMode==="toggle-only"){r.onPress?.();return}if(r.component){let L=typeof r.icon=="function"?r.icon(20):r.icon;T.open({id:r.id,title:r.name||ot(r.id),component:r.component,props:r.props,modal:r.modal,launchMode:r.launchMode||"self-modal",singleton:r.singleton??true,icon:L,color:r.color||Gt(r.id)})}else r.onPress?.()},[T]),A=Oe(()=>xt(k,"dial").map(r=>{let L=r.color||Gt(r.id),W;return typeof r.icon=="string"?W=r.icon:typeof r.icon=="function"?W=r.icon(32):W=null,{id:r.id,name:r.name||ot(r.id),icon:W,unavailable:!r.component&&!r.onPress,color:L,onPress:()=>{C(r),g(false)}}}),[k,C]),ee=Oe(()=>{if(!x)return A;let r=new Map(A.map(L=>[L.id,L]));return wr(A.map(L=>L.id)).map(L=>r.get(L)).filter(L=>!!L)},[x,A]),Z=Oe(()=>xt(k,"row").filter(r=>$.floatingTools[r.id]===true&&(r.component||r.onPress)),[k,$.floatingTools]),q=Oe(()=>k.map(r=>({id:r.id,name:r.name||ot(r.id),description:r.description||Ri(r.id),slot:r.slot,icon:r.icon,color:r.color})),[k]),[ce,K]=wt(false),ne=T.openApps.some(r=>!r.minimized);le(()=>{if(p)return;let r=false,L=setTimeout(async()=>{let W=await Ce.getItem(Dn);!r&&!W&&K(true)},1e3);return()=>{r=true,clearTimeout(L)}},[p]);let J=Fe(()=>{K(false),Ce.setItem(Dn,"true")},[]),Se=Fe(()=>{J(),g(true)},[J]),me=Fe(()=>{g(false),v(false)},[]),ve=Fe(()=>{v(r=>!r)},[]),j=Fe(()=>v(false),[]),Re=!!(o?.length&&a),fe=$.floatingTools.environment!==false,se=ce&&!x&&!ne;le(()=>{if(!se)return;let r=W=>{(!(W.target instanceof Element)||!W.target.closest("[data-buoy-root]"))&&J()},L=W=>{W.key==="Escape"&&J()};return document.addEventListener("pointerdown",r,true),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",r,true),document.removeEventListener("keydown",L)}},[se,J]);let we=T.openApps.some(r=>r.minimized&&r.launchMode!=="toggle-only"),ae=U(El,{modules:i,apps:n,requiredEnvVars:u,externalSync:l,headless:m,sentryGetClient:d});return m?ae:An("div",{"data-buoy-root":"",style:{display:"contents"},children:[ae,se&&U("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.85)",zIndex:1e4,pointerEvents:"none"}}),An(Jt,{enablePositionPersistence:!se,pushToSide:x||ne,suspendPointerEvents:x,centerOnboarding:se,minimizedStack:we?U(qs,{}):void 0,hasMinimizedStack:we,children:[e&&fe&&!Re&&U(Ai,{environment:e}),Re&&fe&&U(Di,{currentEnvironment:e??"local",availableEnvironments:o,onSelect:a}),t?U(Xt,{userRole:t,onPress:Se}):U("button",{"aria-label":"Open dev tools",onClick:Se,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",background:"none",border:"none",cursor:"pointer"},children:U(Nl,{})}),Z.map(r=>U("button",{"aria-label":r.name||ot(r.id),title:r.description,onClick:()=>C(r),style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",borderRadius:6,background:"none",border:"none",cursor:"pointer"},children:typeof r.icon=="function"?r.icon(16):r.icon},r.id))]}),se&&U(uo,{title:"Welcome to Buoy!",message:"Grab and position this menu wherever you want, then tap the icon to open your tools.",onDismiss:J}),x&&U(ho,{icons:ee,onClose:me,centerLabel:"BUOY",onCenterPress:ve,settingsOpen:R,hintsDisabled:p}),U(Po,{visible:R,onClose:j,availableTools:q,onSettingsChange:r=>{}}),U(Xo,{}),U(wi,{})]})}function Kl(e){let{access:t,isPro:o,licenseKey:a}=Ci();le(()=>{xi.configure(e.licenseKey)},[e.licenseKey]);let n=e.licenseKey===void 0||Ti(e.licenseKey,a),i=typeof tt<"u"?tt:process.env.NODE_ENV!=="production",l=n&&t.status==="admitted";return le(()=>{l&&ki()},[l]),le(()=>{i||t.status==="initializing"||(o&&l?vi():Kt())},[i,o,l,t.status]),!i&&!o?e.signIn&&!e.headless?U($l,{}):null:l?U(Vl,{...e}):e.headless?null:U(zi,{})}import{useSettings as _l,useFloatingTools as Gl,getToolLabel as ql,getToolDescription as Jl,getToolColor as Xl,settingsColors as Yl,settingsStyles as Ql,dialColors as Zl,dialStyles as ec}from"@buoy-gg/floating-tools-react/web";export{ua as Activity,Si as AlertCircle,ma as AlertTriangle,Jo as AppHostProvider,Xo as AppOverlay,_a as Badge,On as BarChart3,jn as BaseEventStore,Ln as Bookmark,fa as Bug,oi as Button,di as Card,ya as Check,Sa as CheckCircle,ba as CheckSquare,wa as ChevronDown,Ca as ChevronLeft,za as ChevronRight,Ia as ChevronUp,Ra as Clock,$n as Cloud,gi as CollapsibleSection,Aa as Copy,ai as CopyButton,Pn as DataViewer,En as Database,hn as DevToolsVisibilityProvider,ho as DialMenu,Qa as DiffViewer,Fi as Divider,Hn as Download,Nn as Edit3,bi as EmptyState,Fn as EventStepperFooter,Da as Eye,Ea as EyeOff,Ba as FileJson,Oa as FileText,Fa as Filter,La as FlaskConical,Kl as FloatingDevTools,Jt as FloatingTools,Un as GitBranch,Pa as Globe,_n as HardDrive,$a as Hash,qn as HelpCircle,Xn as Home,Qn as Image,ja as Info,Xa as InfoRow,ca as JsModal,Wa as Key,Va as Layers,ea as Link,Ka as Lock,oa as Maximize2,aa as Minus,ra as Palette,Ga as Pause,la as Pin,Ja as Play,Ya as Plus,Za as Power,ri as PowerToggle,ti as RefreshCw,Wn as RelativeTime,da as Route,li as Row,ni as Search,Bn as SearchBar,pi as SectionHeader,pa as Server,ii as Settings,Po as SettingsModal,si as Shield,ga as Smartphone,ha as Square,qa as StatusDot,hi as TabSelector,va as Timer,ci as Trash2,xa as Unlock,Ta as Upload,ui as User,Xt as UserStatus,ka as Users,mi as Wifi,fi as X,Ma as XCircle,yi as Zap,Cn as appSyncAdapter,Bi as autoDiscoverWebPresets,qt as autoDiscoverWithCustom,Kt as clearReleaseOptIn,sa as copyToClipboard,pn as createWebTool,yn as createWebTools,Ei as defaultToolPresets,na as devToolsStorageKeys,Zl as dialColors,ec as dialStyles,Vn as formatBytes,Kn as formatDuration,Gn as formatNumber,Oi as getEnabledTools,Xl as getToolColor,Jl as getToolDescription,ql as getToolLabel,xt as getToolsBySlot,Na as methodColor,ta as persistentStorage,Yn as safeStringify,Yl as settingsColors,Ql as settingsStyles,Ha as statusColor,ei as toolTheme,Jn as truncateMiddle,Ua as typeColor,yt as useAppHost,$t as useDevToolsVisibility,Gl as useFloatingTools,Zn as usePersistedState,ia as useSafeAreaInsets,_l as useSettings,Is as useToolHeader,Ko as useToolHost};
10
+ `,document.head.appendChild(e),co=true}var Ct=Le.accent;function uo({title:e,message:t,onDismiss:o,showArrow:a=true}){let[n,i]=io(false),[l,u]=io(false);cr(()=>{mr();let p=requestAnimationFrame(()=>i(true));return()=>cancelAnimationFrame(p)},[]);let d={fontFamily:so,textTransform:"uppercase"};return Pe("div",{style:{position:"fixed",left:"50%",bottom:pr(),transform:`translateX(-50%) scale(${n?1:.8})`,opacity:n?1:0,transition:"transform 300ms cubic-bezier(0.34, 1.3, 0.64, 1), opacity 300ms ease",zIndex:10002,pointerEvents:"auto"},children:lo("div",{style:{position:"relative",animation:n?"buoyOnboardPulse 3s ease-in-out infinite":"none"},children:[Pe("div",{style:{position:"absolute",inset:-4,borderRadius:18,backgroundColor:"#FFFFFF",opacity:.06}}),lo("div",{style:{position:"relative",maxWidth:280,backgroundColor:Le.dialBackground,borderRadius:16,border:`1px solid ${Le.dialBorder}`,padding:20,boxShadow:`0 0 20px ${ro(Le.dialShadow,.6)}`,display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[Pe("span",{style:{...d,fontSize:16,fontWeight:900,letterSpacing:1,color:Ct,textAlign:"center"},children:e}),Pe("span",{style:{fontFamily:so,fontSize:13,lineHeight:"20px",color:Le.centerText,textAlign:"center"},children:t}),Pe("button",{onClick:o,onMouseDown:()=>u(true),onMouseUp:()=>u(false),onMouseLeave:()=>u(false),style:{...d,marginTop:8,borderRadius:8,border:"none",backgroundColor:Ct,padding:"10px 24px",fontSize:14,fontWeight:900,letterSpacing:1.5,color:"#000000",cursor:"pointer",opacity:l?.7:1,transform:l?"scale(0.96)":"scale(1)",transition:"transform 100ms ease, opacity 100ms ease"},children:"Got it!"})]}),a&&Pe("div",{style:{position:"absolute",left:"50%",bottom:dr,marginLeft:-12,width:0,height:0,borderLeft:"12px solid transparent",borderRight:"12px solid transparent",borderTop:`${ur}px solid ${Ct}`,filter:`drop-shadow(0 0 10px ${ro(Le.dialShadow,.5)})`,animation:n?"buoyOnboardArrowBounce 1.6s ease-in-out infinite":"none"}})]})})}import{Fragment as gr,jsx as B,jsxs as ge}from"react/jsx-runtime";var fr={x:.5,y:.5},po="@react_buoy_settings_tooltip_shown",mo=false;function hr(){if(mo||typeof document>"u")return;let e=document.createElement("style");e.textContent=Ni(),document.head.appendChild(e),mo=true}var $e=e=>1-Math.pow(1-e,3),Tt=e=>e*e*e;function yr({icon:e,index:t,totalIcons:o,position:a,progress:n,onPress:i}){let[l,u]=Q(false),[d,p]=Q(false),m=!e.icon&&e.id.startsWith("empty-"),x=!m&&e.unavailable===true,g=!m&&!x,{icons:R}=Yt,v=Hi(t,o),I=0;n<=v[1]?I=0:n<=v[2]?I=(n-v[1])/(v[2]-v[1]):I=1,I=Math.max(0,Math.min(1,I));let T=Wi,k=R.pressIn.scale,z=I*(d?k:l?1.1:1),O=0;I<=0?O=0:I<=.3?O=I:O=.3+(I-.3)*(.7/.7);let b=a.x*I,M=a.y*I;return B("button",{role:"menuitem","aria-label":m?"Empty slot":e.name,"aria-disabled":!g,tabIndex:g?0:-1,onClick:g?i:void 0,onMouseEnter:()=>g&&u(true),onMouseLeave:()=>{u(false),p(false)},onMouseDown:()=>g&&p(true),onMouseUp:()=>p(false),style:{position:"absolute",left:"50%",top:"50%",width:T,height:T,marginLeft:-T/2,marginTop:-T/2,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:g?"pointer":"default",transform:`translate(${b}px, ${M}px) scale(${z})`,opacity:O,transition:l||d?"transform 100ms ease":"none",background:"none",border:"none",padding:0},children:m?B("div",{style:{width:S.emptySlot.dotSize,height:S.emptySlot.dotSize,borderRadius:S.emptySlot.dotSize/2,backgroundColor:F.emptyDotBackground,border:`${S.emptySlot.borderWidth}px solid ${F.emptyDotBorder}`}}):ge(gr,{children:[B("div",{style:{position:"absolute",width:`${S.icon.gradientBgSizePercent}%`,height:`${S.icon.gradientBgSizePercent}%`,borderRadius:S.icon.gradientBgBorderRadius,backgroundColor:"rgba(0, 0, 0, 0.2)",opacity:S.icon.gradientBgOpacity}}),B("div",{style:{position:"absolute",width:`${S.icon.innerGlowSizePercent}%`,height:`${S.icon.innerGlowSizePercent}%`,borderRadius:S.icon.innerGlowBorderRadius,backgroundColor:"rgba(255, 255, 255, 0.02)",opacity:S.icon.innerGlowOpacity}}),B("div",{style:{marginBottom:S.icon.wrapperMarginBottom,display:"flex",alignItems:"center",justifyContent:"center",fontSize:32,filter:l?"brightness(1.2)":"none"},children:e.icon}),B("span",{style:{fontSize:e.name.length>8?Math.max(S.icon.label.fontSize*.7,S.icon.label.fontSize*8/e.name.length):S.icon.label.fontSize,fontWeight:S.icon.label.fontWeight,fontFamily:S.icon.label.fontFamily,color:F.iconLabel,letterSpacing:S.icon.label.letterSpacing,marginTop:S.icon.label.marginTop,textTransform:"uppercase",whiteSpace:"nowrap"},children:e.name}),x&&B("span",{style:{fontSize:S.icon.label.fontSize-1,fontWeight:S.icon.label.fontWeight,fontFamily:S.icon.label.fontFamily,letterSpacing:S.icon.label.letterSpacing,color:Ui.muted,textTransform:"uppercase",whiteSpace:"nowrap"},children:"Unavailable"})]})})}function go({side:e,color:t}){return B("svg",{width:18,height:18,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:(e==="prev"?[[15,18,9,12],[9,12,15,6]]:[[9,18,15,12],[15,12,9,6]]).map(([o,a,n,i],l)=>B("line",{x1:o,y1:a,x2:n,y2:i,stroke:t,strokeWidth:2},l))})}function fo({side:e,disabled:t,onClick:o}){let[a,n]=Q(false),i=t?F.emptyDotBorder:F.accent;return ge("button",{type:"button","aria-label":`${e==="prev"?"Previous":"Next"} dial page`,disabled:t,onClick:o,onMouseDown:()=>!t&&n(true),onMouseUp:()=>n(false),onMouseLeave:()=>n(false),style:{display:"flex",alignItems:"center",gap:4,padding:"10px 16px",borderRadius:10,border:`1px solid ${F.dialBorder}`,backgroundColor:F.dialBackground,color:t?F.iconLabelMuted:F.centerText,fontSize:12,fontWeight:900,fontFamily:eo,letterSpacing:1.5,textTransform:"uppercase",cursor:t?"default":"pointer",opacity:t?.4:1,boxShadow:t?"none":`0 0 8px ${Qt(F.dialShadow,.4)}`,transform:a?"scale(0.92)":"scale(1)",transition:"transform 100ms ease"},children:[e==="prev"&&B(go,{side:"prev",color:i}),e==="prev"?"PREV":"NEXT",e==="next"&&B(go,{side:"next",color:i})]})}function ho({icons:e,onClose:t,centerLabel:o="MENU",onCenterPress:a,settingsOpen:n=false,hintsDisabled:i=false}){let{id:l}=_i(),[u,d]=Q(0),[p,m]=Q(0),[x,g]=Q(0),[R,v]=Q(0),[I,T]=Q(0),[k,z]=Q(1),[O,b]=Q(false),[M,$]=Q(false),[C,A]=Q(false),ee=rt(null),Z=rt(null),G=rt(null),ce=rt(false),{entrance:K,exit:ne,interaction:J}=Yt,ve=Vi(),[me,we]=Q(()=>({width:window.innerWidth,height:window.innerHeight}));ze(()=>{let D=()=>we({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",D),()=>window.removeEventListener("resize",D)},[]);let j=it(()=>Pi({screenWidth:me.width,maxCircleSize:Math.max(120,Math.min(320,me.height-96))}),[me]),Re=it(()=>ji(),[]),fe=it(()=>$i(We,j.iconRadius),[j.iconRadius]),[se,xe]=Q(0),ae=Math.max(1,Math.ceil(e.length/We)),r=Math.min(se,ae-1),L=it(()=>{let D=r*We,w=[...e.slice(D,D+We)];for(;w.length<We;)w.push({id:`empty-${w.length}`,name:"",icon:null,onPress:()=>{}});return w},[e,r]);ze(()=>{hr()},[]),ze(()=>{let D=K.backdrop.duration,w=K.dial.rotation.duration,X=K.centerButton.delay,V=K.icons.delay,q=K.icons.duration,_=performance.now(),te=de=>{let s=de-_;d(Math.min(1,s/D));let f=Math.min(1,s/400),E=$e(f)*1.1;f>.7&&(E-=(f-.7)*.33),f>=1&&(E=1),m(Math.max(0,Math.min(1.05,E)));let Y=Math.min(1,s/w);if(g($e(Y)*360),s>=X){let ye=Math.min(1,(s-X)/300),Ee=$e(ye)*1.15;ye>.6&&(Ee-=(ye-.6)*.375),ye>=1&&(Ee=1),v(Math.max(0,Math.min(1.05,Ee)))}if(s>=V){let ye=Math.min(1,(s-V)/q);T($e(ye))}let he=V+q;s<he?G.current=requestAnimationFrame(te):(d(1),m(1),g(360),v(1),T(1),A(true))};return G.current=requestAnimationFrame(te),()=>{G.current&&cancelAnimationFrame(G.current)}},[]);let W=st(()=>{if(ce.current)return;ce.current=true,$(true),G.current&&cancelAnimationFrame(G.current);let D=performance.now(),w=ne.icons.duration,X=ne.centerButton.duration,V=ne.dialScale.duration,q=Math.max(X,V),_=ne.backdrop.duration,te=de=>{let s=de-D;if(s<w){let Y=Tt(s/w);T(1-Y),G.current=requestAnimationFrame(te);return}let f=w;if(s<f+q){T(0);let Y=Math.min(1,(s-f)/X),he=Math.min(1,(s-f)/V);v(1-Tt(Y)),m(1-Tt(he)),G.current=requestAnimationFrame(te);return}let E=f+q;if(s<E+_){m(0),v(0);let Y=(s-E)/_;d(1-Y),G.current=requestAnimationFrame(te);return}d(0),t()};G.current=requestAnimationFrame(te)},[ne,t]);ze(()=>{let D=document.activeElement,w=ee.current;return()=>{D?.isConnected&&(document.activeElement===document.body||w?.contains(document.activeElement))&&D.focus()}},[]),ze(()=>{if(n)return;Z.current?.focus();let D=w=>{let X=ee.current;if(X){if(w.key==="Escape")w.preventDefault(),W();else if(w.key==="Tab"){let V=Array.from(X.querySelectorAll('button:not(:disabled):not([aria-disabled="true"]), [tabindex="0"]')).filter(te=>te.getClientRects().length>0),q=V[0],_=V[V.length-1];(!X.contains(document.activeElement)||(w.shiftKey?document.activeElement===q:document.activeElement===_))&&(w.preventDefault(),(w.shiftKey?_:q)?.focus())}else if(["ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End"].includes(w.key)){let V=Array.from(X.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')),q=V.indexOf(document.activeElement);if(q<0||!V.length)return;w.preventDefault();let _=w.key==="Home"?0:w.key==="End"?V.length-1:(q+(w.key==="ArrowRight"||w.key==="ArrowDown"?1:-1)+V.length)%V.length;V[_].focus()}}};return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[W,n]);let[He,Ye]=Q(false);ze(()=>{if(i)return;let D=false,w=setTimeout(async()=>{let X=await Zt.getItem(po);!D&&!X&&Ye(true)},1200);return()=>{D=true,clearTimeout(w)}},[i]);let Ae=st(()=>{Ye(false),Zt.setItem(po,"true")},[]);ze(()=>{n&&He&&Ae()},[n,He,Ae]);let Qe=st(D=>{if(D.id.startsWith("empty-")||ce.current)return;let[w,X]=J.iconSelect.pulse,V=performance.now(),q=150,_=te=>{let de=te-V;if(de<q){let s=$e(de/q);z(1-(1-w.scale)*s),requestAnimationFrame(_)}else if(de<q*2){let s=$e((de-q)/q);z(w.scale+(X.scale-w.scale)*s),requestAnimationFrame(_)}else z(1)};requestAnimationFrame(_),setTimeout(()=>{D.onPress(),W()},J.iconSelect.actionDelay)},[J.iconSelect,W]),Ze=st(D=>{if(ce.current)return;let w=Math.max(0,Math.min(D,ae-1));w!==r&&xe(w)},[ae,r]),De=j.buttonSize*S.centerButton.containerRatio,et=j.buttonSize*S.centerButton.borderRatio,St=j.buttonSize*S.centerButton.containerRatio/2+6,vt=C&&!M;return ge("div",{ref:ee,role:"dialog","aria-label":"Dial Menu","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:1e4},children:[B("button",{type:"button","aria-label":"Close dial menu",tabIndex:0,onClick:W,style:{position:"absolute",inset:0,border:0,padding:0,backgroundColor:F.dialBackdrop,opacity:u}}),ge("div",{style:{position:"absolute",left:"50%",marginLeft:-j.circleSize/2,bottom:80,width:j.circleSize,height:j.circleSize,borderRadius:"50%",backgroundColor:F.dialBackground,border:`${S.circle.borderWidth}px solid ${F.dialBorder}`,boxShadow:`0 0 ${S.circle.shadowRadius}px ${Qt(F.dialShadow,S.circle.shadowOpacity)}`,transform:`scale(${p}) rotate(${x}deg)`,opacity:p>.01?1:0,overflow:"hidden"},children:[B("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:F.dialGradient1,opacity:S.gradientLayers[0].opacity}}),B("div",{style:{position:"absolute",inset:0,top:"30%",left:"30%",borderRadius:"50%",backgroundColor:F.dialGradient2,opacity:S.gradientLayers[1].opacity}}),B("div",{style:{position:"absolute",inset:0,top:"50%",left:"50%",borderRadius:"50%",backgroundColor:F.dialGradient3,opacity:S.gradientLayers[2].opacity}}),Re.map(D=>B("div",{style:{position:"absolute",top:"50%",left:0,right:0,height:S.grid.lineHeight,transform:`rotate(${D}deg)`,transformOrigin:"center"},children:["left","right"].map(w=>B("div",{style:{position:"absolute",top:0,[w]:0,width:`calc(50% - ${St}px)`,height:S.grid.lineHeight,backgroundColor:F.dialGridLine}},w))},D)),B("div",{"data-testid":"dial-background","data-background":l,style:{position:"absolute",inset:0,pointerEvents:"none"},children:l==="hyperspace"?B(lr,{size:j.circleSize}):B(Ki,{focus:fr})}),L.map((D,w)=>B(yr,{icon:D,index:w,totalIcons:L.length,position:fe[w],progress:I,onPress:()=>Qe(D)},w)),ge("div",{style:{position:"absolute",left:"50%",top:"50%",width:De,height:De,marginLeft:-De/2,marginTop:-De/2,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:F.hubHalo,borderRadius:j.buttonSize,overflow:"hidden",transform:`scale(${R*k})`,opacity:R>.01?1:0},children:[B("div",{style:{position:"absolute",inset:0,backgroundColor:F.dialGradient1,opacity:.5,borderRadius:j.buttonSize}}),B("div",{style:{position:"absolute",inset:0,top:"20%",left:"20%",backgroundColor:F.dialGradient2,opacity:.3,borderRadius:j.buttonSize}}),B("div",{style:{position:"absolute",inset:0,top:"40%",left:"40%",backgroundColor:F.dialGradient3,opacity:.2,borderRadius:j.buttonSize}}),B("div",{style:{width:et,height:et,borderRadius:j.buttonSize*S.centerButton.borderRadiusRatio,backgroundColor:F.hubFill,display:"flex",alignItems:"center",justifyContent:"center"},children:B("button",{ref:Z,type:"button","aria-label":n?"Close settings":"Open settings",disabled:!a,onClick:a,onMouseEnter:()=>b(true),onMouseLeave:()=>b(false),style:{border:0,padding:0,background:"transparent",width:j.buttonSize,height:j.buttonSize,borderRadius:j.buttonSize/2,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",cursor:a?"pointer":"default",transform:O?`scale(${J.centerHover.scale})`:"scale(1)",transition:`transform ${J.centerHover.duration}ms ease`,animation:vt&&!O?ve.pulse:"none"},children:n?ge("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",fontSize:S.centerButton.text.fontSize-2,fontWeight:S.centerButton.text.fontWeight,fontFamily:S.centerButton.text.fontFamily,color:F.centerText,letterSpacing:S.centerButton.text.letterSpacing,textAlign:"center",textShadow:`0 0 4px ${F.centerTextGlow}`,textTransform:"uppercase",lineHeight:1.2},children:[B("span",{style:{marginBottom:-2},children:"CLOSE"}),B("span",{style:{marginTop:-2},children:"SETTINGS"})]}):B("span",{style:{fontSize:S.centerButton.text.fontSize,fontWeight:S.centerButton.text.fontWeight,fontFamily:S.centerButton.text.fontFamily,color:F.centerText,letterSpacing:S.centerButton.text.letterSpacing,textAlign:"center",textShadow:`0 0 4px ${F.centerTextGlow}`,textTransform:"uppercase"},children:o})})})]})]}),ae>1&&ge("div",{style:{position:"absolute",left:"50%",marginLeft:-j.circleSize/2,top:"calc(100% - 64px)",width:j.circleSize,display:"flex",alignItems:"center",justifyContent:"space-between",opacity:Math.min(1,p),transform:`scale(${Math.min(1,p)})`},children:[B(fo,{side:"prev",disabled:r<=0,onClick:()=>Ze(r-1)}),ge("span",{style:{padding:"6px 12px",fontSize:13,fontWeight:900,fontFamily:eo,letterSpacing:2,color:F.centerText,textShadow:`0 0 6px ${F.centerTextGlow}`},children:[String(r+1).padStart(2,"0"),ge("span",{style:{color:F.iconLabelMuted,textShadow:"none"},children:[" / ",String(ae).padStart(2,"0")]})]}),B(fo,{side:"next",disabled:r>=ae-1,onClick:()=>Ze(r+1)})]}),He&&!n&&B(uo,{title:"Welcome to Buoy!",message:"Tap the center button to configure and add tools to your dial menu.",onDismiss:Ae,showArrow:false})]})}import{persistentStorage as yo,devToolsStorageKeys as br}from"@buoy-gg/shared-ui/web";import{recordUsage as Sr,pruneUsage as vr}from"@buoy-gg/floating-tools-core/web";var bo=br.dial.usage(),je={},So=false,zt=null;function vo(){return zt||(zt=(async()=>{try{let e=await yo.getItem(bo);if(e){let t=JSON.parse(e);t&&typeof t=="object"&&(je=t)}}catch{}finally{So=true}})(),zt)}vo();function wr(e){return e.map((t,o)=>({id:t,index:o,lastUsed:je[t]?.lastUsed??0})).sort((t,o)=>o.lastUsed-t.lastUsed||t.index-o.index).map(({id:t})=>t)}async function xr(e){if(!e)return;So||await vo();let t=Math.max(Date.now(),...Object.values(je).map(o=>o.lastUsed+1));je=vr(Sr(je,e,t),t);try{await yo.setItem(bo,JSON.stringify(je))}catch{}}import{useCallback as Cr,useMemo as wo}from"react";import{persistentStorage as Tr}from"@buoy-gg/shared-ui/web";import{useState as oe,useEffect as be,useCallback as ct,useMemo as dt}from"react";import{settingsEventBus as ut}from"@buoy-gg/floating-tools-core/web";import{useSyncExternalStore as zr}from"react";import{getRegisteredToolModule as kr}from"@buoy-gg/shared-ui/web";var Ir=()=>()=>{},Mr=()=>null;function Rr(){let e=kr("@buoy-gg/external-sync");return zr(e?.subscribeSyncStatus??Ir,()=>e?.getSyncStatus?.()??null,Mr)}import{SentryIcon as Ar,WifiCircuitIcon as Dr,ImageOverlayIcon as Er,RenderCountIcon as Br,Info as kt,Layers as Or,ChevronRightIcon as xo,ChevronDown as Co,getStorageBackendType as Fr,getUseLicense as Lr,signOutOfBuoy as Pr,persistentStorage as ke,Trash2 as $r,CheckCircle2 as To,LicenseEntryModal as jr,BackgroundSwitcher as Hr,night as h,NightCard as Ie,NightRows as It,NightSectionLabel as Wr,NightFootnote as zo,NightSwitch as ko,NightButton as Mt,NightSegmented as Nr,NightBadge as ue,NightSeparator as Vr,monoFont as Io}from"@buoy-gg/shared-ui/web";import{EnvIcon as Mo,StorageIcon as Ur,RoutesIcon as Kr,NetworkIcon as _r,QueryIcon as qr,HighlighterIcon as Gr,ReduxIcon as Jr,EventsIcon as Xr}from"@buoy-gg/floating-tools-core/web";import Yr,{createContext as Qr,useContext as Zr}from"react";import{jsx as es}from"react/jsx-runtime";var Ro=Qr({});function ts({children:e,defaultFloatingTools:t,defaultDialTools:o}){let a=Yr.useMemo(()=>({defaultFloatingTools:t,defaultDialTools:o}),[t,o]);return es(Ro.Provider,{value:a,children:e})}function Ao(){return Zr(Ro)}import os from"react";import{toolTheme as ns}from"@buoy-gg/shared-ui/web";import{jsx as Do}from"react/jsx-runtime";function as({label:e,size:t,color:o=ns.colors.text}){let a=Math.max(Array.from(e.replace(/[\uFE00-\uFE0F\u200D]/g,"")).length,1),n=a<=2?t:t*1.6,i=Math.max(7,Math.min(t*(a===1?.7:.62),n/(.62*a)));return Do("span",{style:{display:"inline-flex",minWidth:t,maxWidth:n,height:t,alignItems:"center",justifyContent:"center",color:o,fontSize:i,fontWeight:800,letterSpacing:.5,whiteSpace:"nowrap",overflow:"hidden"},children:e})}function Eo(e,t){return e==null?e:typeof e=="function"?os.createElement(e,{slot:t.slot,size:t.size,state:t.state,actions:t.actions}):typeof e=="string"||typeof e=="number"?Do(as,{label:String(e),size:t.size,color:t.color}):e}import{JsModal as is,devToolsStorageKeys as Rt,onSettingsApplied as rs}from"@buoy-gg/shared-ui/web";import{useSafeAreaInsets as ss}from"@buoy-gg/shared-ui/web";import{Fragment as Ve,jsx as c,jsxs as P}from"react/jsx-runtime";var Ue="@react_buoy_dev_tools_settings",ls=6,pt=e=>{let t=ls,o={};for(let[a,n]of Object.entries(e))n&&t>0?(o[a]=true,t-=1):o[a]=false;return o},cs=(e,t)=>{let{userStatus:o,environment:a,...n}=e,i=t?Object.entries(n).filter(([l])=>t.includes(l)):Object.entries(n);return{...Object.fromEntries(i),environment:a??false}},Bo=(e,t,o)=>{if(!t)return e;let a={...e.dialTools,...t.dialTools??{}},n=o?.allowedDialKeys?Object.entries(a).filter(([i])=>o.allowedDialKeys?.includes(i)):Object.entries(a);return{dialTools:pt(Object.fromEntries(n)),floatingTools:cs({...e.floatingTools,...t.floatingTools??{}},o?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...t.globalSettings??{}}}},ds=(e=[],t,o)=>{let a={},n={},i=new Set(t??[]),l=new Set(o??[]),u=!o||o.length===0;for(let d of e){let{id:p,slot:m="both"}=d;(m==="dial"||m==="both")&&(a[p]=u?true:l.has(p)),(m==="row"||m==="both")&&(n[p]=i.has(p))}return{dialTools:pt(a),floatingTools:{...n,environment:i.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}},us=({visible:e,onClose:t,onSettingsChange:o,initialSettings:a,availableApps:n=[],storage:i=ke,zIndex:l})=>{let{defaultFloatingTools:u,defaultDialTools:d}=Ao(),p=dt(()=>ds(n,u,d),[n,u,d]),m=dt(()=>Object.keys(p.dialTools),[p]),x=dt(()=>Object.keys(p.floatingTools).filter(s=>s!=="environment"),[p]),[g,R]=oe(a||Ke||p),[v,I]=oe(At??"floating"),[T,k]=oe(At!==null),[z,O]=oe(new Set),[b,M]=oe(false),[$,C]=oe(false);be(()=>{let s=requestAnimationFrame(()=>C(true));return()=>cancelAnimationFrame(s)},[]);let A=Rr();be(()=>{(async()=>{try{let s=await ke.getItem(Rt.settings.activeTab());if(s&&["floating","settings","pro"].includes(s)){let f=s;At=f,I(E=>E===f?E:f)}}catch{}finally{k(true)}})()},[]),be(()=>{T&&ke.setItem(Rt.settings.activeTab(),v).catch(s=>{console.warn("Failed to save settings active tab:",s)})},[v,T]);let ee=Lr()?.(),Z=ee?.isPro??false,G=!Z&&ee?.licenseKey?ee.error:null,ce=ee?.errorKind==="transport",[K,ne]=oe(Oo),[J,ve]=oe(false),[me,we]=oe(false),[j,Re]=oe(false),[fe,se]=oe([]),[xe,ae]=oe(false),r=ss(),L=Vt.get("window").height,W=Vt.get("window").width,He=Math.floor(L*.33),Ye=Math.min(W-32,400),Ae=ct(async()=>{try{let s=await i.getItem(Ue);if(s){let f=JSON.parse(s),E=Bo(p,f,{allowedDialKeys:m,allowedFloatingKeys:x});Ke=E,R(Y=>Fo(Y,E)?Y:E);return}Ke=p,R(f=>Fo(f,p)?f:p)}catch(s){console.error("Failed to load dev tools settings:",s),R(p)}},[p,m,x,i]);be(()=>{Ae()},[Ae]),be(()=>{Fr().then(s=>{Oo=s,ne(f=>f===s?f:s)})},[]),be(()=>{j&&(ae(true),ke.getAllKeys().then(s=>{se(s.sort())}).catch(()=>{se([])}).finally(()=>{ae(false)}))},[j]);let Qe=async s=>{try{let f={...s,dialTools:pt(s.dialTools)};await i.setItem(Ue,JSON.stringify(f)),Ke=f,R(f),o?.(f),ut.emit(f)}catch(f){console.error("Failed to save dev tools settings:",f)}},Ze=s=>{let f={...g,floatingTools:{...g.floatingTools,[s]:!g.floatingTools[s]}};Qe(f)},De=s=>{let f={...g,globalSettings:{...g.globalSettings,[s]:!g.globalSettings?.[s]}};Qe(f)},et=async()=>{ve(true),we(false);try{await ke.clear(),we(true),R(p),i!==ke&&await i.setItem(Ue,JSON.stringify(p)),o?.(p),ut.emit(p),setTimeout(()=>we(false),2e3)}catch(s){console.error("Failed to clear storage:",s)}finally{ve(false)}},St=ct(s=>{},[]),vt=s=>{let f=n.find(E=>E.id===s);return f?.description?f.description:s==="environment"?"Environment badge.":""},D=s=>s==="environment"?"Env Badge":n.find(f=>f.id===s)?.name??s.toUpperCase().replace(/_/g," "),w=s=>{if(!$)return null;switch(s){case"query":return c(qr,{size:18});case"env":return c(Mo,{size:18});case"sentry":return c(Ar,{size:18,color:"#9945FF"});case"storage":return c(Ur,{size:18,bgColor:h.color.surface});case"wifi":case"query-wifi-toggle":return c(Dr,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return c(Kr,{size:18,bgColor:h.color.surface});case"network":return c(_r,{size:18});case"environment":return c(Mo,{size:18});case"debug-borders":return c(Or,{size:18,color:h.color.accent});case"highlight-updates":return c(Br,{size:18,color:h.color.accent});case"highlight-updates-modal":return c(Gr,{size:18});case"redux":return c(Jr,{size:18});case"image-overlay":return c(Er,{size:18});case"events":return c(Xr,{size:18});case"zustand":try{let{ZustandIcon:f}=_t("@buoy-gg/zustand/web");return c(f,{size:18})}catch{return c(kt,{size:18,color:h.color.textSecondary})}case"jotai":try{let{JotaiIcon:f}=_t("@buoy-gg/jotai/web");return c(f,{size:18})}catch{return c(kt,{size:18,color:h.color.textSecondary})}default:{let f=n.find(E=>E.id===s);return f?.icon!=null?Eo(f.icon,{slot:"row",size:18,color:f.color}):c(kt,{size:18,color:h.color.textSecondary})}}},X=(s,f,E,Y)=>{let he=vt(s);return P(tt,{activeOpacity:E?1:.7,onPress:()=>!E&&Y(),accessibilityLabel:D(s),accessibilityRole:"button",style:[y.toolRow,E&&y.rowDisabled],children:[c(H,{style:y.toolIconSlot,children:w(s)}),P(H,{style:y.rowInfo,children:[P(N,{style:y.rowLabel,children:[D(s),E?" \xB7 max 6":""]}),he?c(N,{style:y.rowCaption,numberOfLines:1,children:he}):null]}),c(ko,{value:f,disabled:E,onValueChange:()=>Y()})]},s)},V=s=>{O(f=>{let E=new Set(f);return E.has(s)?E.delete(s):E.add(s),E})},q=(s,f,E,Y,he)=>{let ye=g.globalSettings?.[s]??false,Ee=z.has(s);return P(H,{children:[P(tt,{activeOpacity:.7,onPress:()=>V(s),accessibilityLabel:f,style:y.settingRow,children:[P(H,{style:y.rowInfo,children:[c(N,{style:y.rowLabel,children:f}),c(N,{style:y.rowCaption,numberOfLines:Ee?0:1,children:E})]}),c(ko,{value:ye,onValueChange:()=>De(s)})]}),Ee&&P(H,{style:y.settingRowBody,children:[c(N,{style:y.settingRowBodyText,children:Y}),c(N,{style:y.settingRowBodyHint,children:he})]})]},s)},_=(s,f,E)=>P(H,{children:[c(Wr,{children:s}),f,E]}),te=K==="filesystem"?c(ue,{label:"File System",tone:"accent"}):K==="asyncstorage"?c(ue,{label:"Async Storage",tone:"warning"}):K==="localstorage"?c(ue,{label:"Local Storage",tone:"accent"}):K==="memory"?c(ue,{label:"Memory",tone:"danger"}):c(ue,{label:"Loading\u2026",tone:"neutral"}),de=()=>P(H,{style:y.container,children:[P(Nt,{style:y.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:y.scrollContainer,children:[v==="floating"&&c(Ve,{children:_("Floating Tools",c(Ie,{glass:true,children:c(It,{children:Object.entries(g.floatingTools).map(([s,f])=>X(s,f,false,()=>Ze(s)))})}),c(zo,{children:"Tools switched on here appear in the floating bubble row."}))}),v==="settings"&&P(Ve,{children:[_("Background",c(Ie,{glass:true,padded:true,children:c(Hr,{embedded:true})})),_("Storage",P(Ie,{glass:true,children:[P(tt,{activeOpacity:.7,onPress:()=>Re(!j),accessibilityLabel:"Storage Type",style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"Storage Type"})}),te,j?c(Co,{size:16,color:h.color.textTertiary}):c(xo,{size:16,color:h.color.textTertiary})]}),j&&P(Ve,{children:[P(H,{style:y.settingRowBody,children:[c(N,{style:y.settingRowBodyText,children:K==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":K==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":K==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":K==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),K==="asyncstorage"&&c(N,{style:[y.settingRowBodyText,y.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),K==="memory"&&c(N,{style:[y.settingRowBodyText,y.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),c(Vr,{}),P(H,{style:y.storageExpanded,children:[P(H,{style:y.storageExpandedHeader,children:[c(N,{style:y.storageExpandedTitle,children:"SAVED SETTINGS"}),c(N,{style:y.storageExpandedCount,children:xe?"\u2026":`${fe.length} keys`})]}),xe?c(N,{style:y.storageKeyEmpty,children:"Loading\u2026"}):fe.length===0?c(N,{style:y.storageKeyEmpty,children:"No settings saved yet"}):c(Nt,{style:y.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:fe.map(s=>c(H,{style:y.storageKeyItem,children:c(N,{style:y.storageKeyText,numberOfLines:1,children:s.replace("@react_buoy_","")})},s))})]}),c(H,{style:y.cardButtonWrap,children:c(Mt,{label:me?"Cleared":J?"Clearing\u2026":"Clear All Settings",variant:me?"secondary":"destructive",size:"md",disabled:J,onPress:et,icon:me?c(To,{size:15,color:h.color.accent}):c($r,{size:15,color:J?h.color.textTertiary:h.color.danger})})})]})]})),A&&A.state!=="idle"&&_("Desktop Sync",P(Ie,{glass:true,children:[P(tt,{activeOpacity:.7,onPress:()=>V("desktopSync"),accessibilityLabel:"Buoy Desktop",style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"Buoy Desktop"})}),A.state==="connected"?c(ue,{label:"Connected",tone:"accent"}):A.state==="connecting"?c(ue,{label:"Connecting\u2026",tone:"neutral"}):c(ue,{label:"Retrying",tone:"warning"}),z.has("desktopSync")?c(Co,{size:16,color:h.color.textTertiary}):c(xo,{size:16,color:h.color.textTertiary})]}),z.has("desktopSync")&&P(H,{style:y.settingRowBody,children:[P(N,{style:y.settingRowBodyText,children:[A.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",c(N,{style:y.footnoteMono,children:A.targetURL??"(unknown URL)"}),A.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),A.state==="retrying"&&A.lastError&&P(N,{style:[y.settingRowBodyText,y.bodyWarning],children:["Last error: ",A.lastError]})]})]})),_("Modal Behavior",c(Ie,{glass:true,children:P(It,{children:[q("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),Be.OS!=="web"?q("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),v==="pro"&&P(Ve,{children:[_("License",P(Ie,{glass:true,children:[P(H,{style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"License Status"})}),c(H,{testID:"buoy-settings-license-status",accessibilityLabel:Z?"License: Active":"License: Free",children:Z?c(ue,{label:"Active",tone:"accent"}):c(ue,{label:"Free",tone:"neutral"})})]}),ee?.tierSource==="session"?P(H,{style:y.settingRow,children:[c(H,{style:y.rowInfo,children:c(N,{style:y.rowLabel,children:"Signed in with Buoy"})}),c(Mt,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void Pr(),testID:"buoy-settings-signout"})]}):null]}),c(zo,{children:Z?"You have full access to all Buoy DevTools features.":G?ce?`Couldn't reach the license server (${G}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${G}.`:"Upgrade to Pro to unlock all features and support development."})),!Z&&P(Ve,{children:[_("Pro Features",c(Ie,{glass:true,children:c(It,{children:["Advanced Settings","Priority Support"].map(s=>P(H,{style:y.featureRow,children:[c(To,{size:16,color:h.color.accent}),c(N,{style:y.rowLabel,children:s})]},s))})})),c(Mt,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>M(true)})]})]})]}),c(jr,{visible:b,onClose:()=>M(false),onSuccess:()=>M(false)})]});return c(is,{visible:e,onClose:t,zIndex:l,variant:"night",header:{showToggleButton:false,customContent:c(H,{style:y.headerRow,children:c(Nr,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:v,onChange:s=>I(s)})})},initialMode:"bottomSheet",onModeChange:St,persistenceKey:Rt.settings.root(),enablePersistence:true,maxHeight:L-r.top,initialHeight:He,initialFloatingPosition:{x:(W-Ye)/2,y:r.top+20},enableGlitchEffects:true,children:de()})},ps={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}},ms=(e,t)=>{let o=new Set(e??[]),a=new Set(t??[]),n={};for(let l of a)n[l]=true;let i={environment:o.has("environment")};for(let l of o)l!=="environment"&&(i[l]=true);return{dialTools:pt(n),floatingTools:i,globalSettings:{enableSharedModalDimensions:false}}},Ke=null,At=null,Oo=null,Fo=(e,t)=>JSON.stringify(e)===JSON.stringify(t);ut.addListener(e=>{e&&(Ke=e)});var gs=()=>{let{defaultFloatingTools:e,defaultDialTools:t}=Ao(),o=dt(()=>!e&&!t?ps:ms(e,t),[e,t]),[a,n]=oe(o),i=ct(async()=>{try{let u=await ke.getItem(Ue);if(u){let d=JSON.parse(u),p=Bo(o,d);n(p);return}n(o)}catch(u){console.error("Failed to load dev tools settings:",u),n(o)}},[o]);be(()=>rs(u=>{u.includes(Ue)&&i()}),[i]),be(()=>{i();let u=ut.addListener(d=>{try{d&&n(d)}catch{}});return()=>{u()}},[i]);let l=ct(()=>{i()},[i]);return{settings:a,refreshSettings:l}},y=Ut.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:h.gutter,paddingRight:h.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:h.gutter,paddingTop:8,paddingBottom:24,gap:h.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:h.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:h.rowPadH,paddingVertical:h.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:h.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:h.color.text,fontSize:h.font.row,fontWeight:"500"},rowCaption:{color:h.color.textTertiary,fontSize:h.font.label},settingRowBody:{paddingHorizontal:h.rowPadH,paddingBottom:h.rowPadV,gap:6},settingRowBodyText:{color:h.color.textSecondary,fontSize:h.font.caption,lineHeight:h.font.caption*1.45},settingRowBodyHint:{color:h.color.textTertiary,fontSize:h.font.caption,lineHeight:h.font.caption*1.45},bodyWarning:{color:h.color.warning},bodyDanger:{color:h.color.danger},cardButtonWrap:{paddingHorizontal:h.cardPad,paddingTop:10,paddingBottom:h.cardPad},storageExpanded:{paddingHorizontal:h.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:h.color.textSecondary,fontSize:h.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:h.color.textTertiary,fontSize:h.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:h.color.glassElevated,borderRadius:h.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:h.color.textSecondary,fontSize:h.font.micro,fontFamily:Io},storageKeyEmpty:{color:h.color.textTertiary,fontSize:h.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:Io,fontSize:h.font.label,color:h.color.textSecondary}});import{jsx as Lo}from"react/jsx-runtime";var fs=[];function Po({visible:e,onClose:t,availableTools:o=fs,defaultFloatingTools:a,defaultDialTools:n,storage:i=Tr,onSettingsChange:l}){let u=wo(()=>({getItem:async m=>i.getItem(m),setItem:async(m,x)=>i.setItem(m,x)}),[i]),d=wo(()=>o.map(m=>({...m,name:m.name??m.id,icon:typeof m.icon=="function"?x=>m.icon(x.size):m.icon})),[o]),p=Cr(m=>{l?.(m)},[l]);return Lo(ts,{defaultFloatingTools:a,defaultDialTools:n,children:Lo(us,{visible:e,onClose:t,zIndex:11e3,availableApps:d,storage:u,onSettingsChange:p})})}import{persistentStorage as $o}from"@buoy-gg/shared-ui/web";import{createContext as hs,useCallback as Se,useContext as ys,useEffect as Dt,useMemo as bs,useRef as _e,useState as jo}from"react";var Ss=(e,t,o)=>{if(t.singleton){let n=e.find(i=>i.id===t.id);if(n){let i=n.minimized??false;return{instanceId:n.instanceId,wasMinimized:i,apps:[...e.filter(l=>l.instanceId!==n.instanceId),{...n,minimized:false}]}}}let a=o();return{instanceId:a,wasMinimized:false,apps:[...e,{...t,instanceId:a}]}};import{createContext as vs,useCallback as Ho,useContext as ws,useEffect as mt,useMemo as xs,useRef as Wo,useState as gt}from"react";import{JsModal as Cs,ModalHeader as qe,HeaderSearchButton as Ts,TickProvider as zs,ToolScreenHeaderContext as ks,devToolsStorageKeys as No,buoyColors as Vo,gameUIColors as Et}from"@buoy-gg/shared-ui/web";import{jsx as ie,jsxs as ft}from"react/jsx-runtime";var Ge=()=>{},Is={search:"",isSearchActive:false,clearSearch:Ge,close:Ge,minimize:Ge,showToast:Ge,setHeaderOverride:Ge},Uo=vs(null);function Ko(){return ws(Uo)??Is}function Ms(e,t){let{setHeaderOverride:o}=Ko();mt(()=>(o(e),()=>o(null)),t)}var _o=2200,Rs={success:Et.success,error:Et.error,info:Et.info};function As({message:e,type:t,nonce:o}){let a=Wo(new Ce.Value(0)).current;mt(()=>{a.setValue(0),Ce.sequence([Ce.timing(a,{toValue:1,duration:150,useNativeDriver:true}),Ce.delay(_o-450),Ce.timing(a,{toValue:0,duration:300,useNativeDriver:true})]).start()},[o,a]);let n=Rs[t];return ft(Ce.View,{pointerEvents:"none",style:[ht.toast,{opacity:a,borderColor:n+"60"}],children:[ie(H,{style:[ht.toastDot,{backgroundColor:n}]}),ie(N,{style:ht.toastText,numberOfLines:2,children:e})]})}function Ds({app:e,config:t,visible:o,zIndex:a,onClose:n,onMinimize:i,initialModalState:l,enableSharedModalDimensions:u,bodyProps:d}){let p=e.component,[m,x]=gt(false),[g,R]=gt(""),[v,I]=gt(null),[T,k]=gt(null),z=Wo(null),O=Ho(()=>{x(false),R("")},[]),b=Ho((K,ne="info")=>{z.current&&clearTimeout(z.current),k(J=>({message:K,type:ne,nonce:(J?.nonce??0)+1})),z.current=setTimeout(()=>k(null),_o)},[]);mt(()=>()=>{z.current&&clearTimeout(z.current)},[]);let M=xs(()=>({search:m?g:"",isSearchActive:m,clearSearch:O,close:n,minimize:()=>i(),showToast:b,setHeaderOverride:I,instanceId:e.instanceId}),[g,m,O,n,i,b,e.instanceId]),$=v?.title??t.title??e.title??e.id,C=v?.subtitle??t.subtitle,A=v?.onBack,ee=v?.actions??t.headerActions,Z=v?.searchable??t.searchable;mt(()=>{!Z&&m&&O()},[Z,m,O]);let G=u?No.modal.root():No.custom(e.id).modal(),ce=ft(qe,{children:[A&&!m&&ie(qe.Navigation,{onBack:A}),m?ie(qe.Search,{value:g,onChangeText:R,onCancel:O,placeholder:t.searchPlaceholder,testID:`tool-search-field-${e.id}`}):ie(qe.Content,{title:$,subtitle:C}),ft(qe.Actions,{children:[!m&&ee,Z&&!m&&ie(Ts,{variant:"chip",testID:`tool-search-${e.id}`,onPress:()=>x(true)})]})]});return ie(Uo.Provider,{value:M,children:ie(Cs,{visible:o,onClose:n,onBack:A,onMinimize:i,initialModalState:l,zIndex:a,persistenceKey:G,enablePersistence:true,initialMode:t.initialMode??"bottomSheet",header:{customContent:ce,showToggleButton:true},disableScrollWrapper:true,styles:{},children:ft(H,{style:ht.bodyRoot,children:[ie(zs,{children:ie(ks.Provider,{value:I,children:ie(p,{...d})})}),T&&ie(As,{message:T.message,type:T.type,nonce:T.nonce})]})})})}var ht=Ut.create({bodyRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},toast:{position:"absolute",bottom:16,alignSelf:"center",flexDirection:"row",alignItems:"center",gap:8,maxWidth:"86%",backgroundColor:Vo.card,borderWidth:1,borderRadius:8,paddingHorizontal:12,paddingVertical:8,shadowColor:"#000",shadowOpacity:.4,shadowRadius:8,shadowOffset:{width:0,height:2},elevation:6},toastDot:{width:6,height:6,borderRadius:3},toastText:{flex:1,fontSize:12,color:Vo.text}});import{Fragment as Es,jsx as pe}from"react/jsx-runtime";var qo=hs(null),Go="@react_buoy_open_apps",Bt=44,Bs=12,Os=100,Fs=16,Ls=e=>({x:window.innerWidth-Bt-Fs,y:window.innerHeight-Os-Bt-e*(Bt+Bs)}),Jo=({children:e})=>{let[t,o]=jo([]),[a,n]=jo(false),i=_e([]),l=_e(null),u=_e(false),d=_e(false),p=_e(false),m=Se(b=>{let M="";return o($=>{let{apps:C,instanceId:A}=Ss($,b,()=>`${b.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`);return M=A,C}),M},[]),x=Se(()=>{if(u.current||!d.current||!p.current)return;u.current=true;let b=l.current;if(!b||b.length===0){n(true);return}l.current=null,b.forEach(({id:M,minimized:$})=>{let C=i.current.find(A=>A.id===M);if(C&&C.component){let A=Eo(C.icon,{slot:"dial",size:20,color:C.color});m({id:C.id,title:C.name,component:C.component,props:C.props,modal:C.modal,launchMode:C.launchMode||"self-modal",singleton:C.singleton??true,icon:A,color:C.color,minimized:$})}}),n(true)},[m]);Dt(()=>{let b=false;return(async()=>{try{let M=await $o.getItem(Go);if(b)return;if(M){let $=JSON.parse(M),C;Array.isArray($)&&$.length>0&&(typeof $[0]=="string"?C=$.map(A=>({id:A,minimized:false})):C=$.filter(A=>typeof A=="object"&&A!==null&&typeof A.id=="string"),C.length&&(l.current=C))}}catch{}b||(d.current=true,x())})(),()=>{b=true}},[x]),Dt(()=>{if(!a)return;let b=t.map(M=>({id:M.id,minimized:M.minimized??false}));$o.setItem(Go,JSON.stringify(b))},[t,a]);let g=Se(b=>{i.current=b,p.current=true,x()},[x]),R=Se(b=>{o(M=>M.length?b?M.filter($=>$.instanceId!==b):M.slice(0,-1):M)},[]),v=Se(()=>o([]),[]),I=Se((b,M)=>{o($=>$.map(C=>C.instanceId===b?{...C,minimized:true,restoreState:M}:C))},[]),T=Se((b,M)=>{o($=>$.map(C=>C.instanceId===b?{...C,minimized:false,restoreState:M??C.restoreState}:C))},[]),k=Se(b=>t.find(M=>M.instanceId===b)?.minimized??false,[t]),z=t.some(b=>b.launchMode!=="toggle-only"&&!b.minimized);Dt(()=>{if(!z)return;let b=M=>{if(M.key!=="Escape"||M.defaultPrevented)return;let $=[...t].reverse().find(C=>C.launchMode!=="toggle-only"&&!C.minimized);$&&R($.instanceId)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[z,R,t]);let O=bs(()=>({openApps:t,isAnyOpen:z,open:m,close:R,closeAll:v,registerApps:g,minimize:I,restore:T,isMinimized:k}),[t,z,m,R,v,g,I,T,k]);return pe(qo.Provider,{value:O,children:e})},yt=()=>{let e=ys(qo);return e||{openApps:[],isAnyOpen:false,open:()=>"",close:()=>{},closeAll:()=>{},registerApps:()=>{},minimize:()=>{},restore:()=>{},isMinimized:()=>false}},Ps=9e3,$s={position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.28)",display:"flex",alignItems:"center",justifyContent:"center"},js={maxHeight:"90%",width:"94%",borderRadius:12,backgroundColor:"white",overflow:"hidden"},Hs=({app:e,zIndex:t,onClose:o,onMinimize:a,minimizeTargetPosition:n,enableSharedModalDimensions:i})=>{let l=e.component,u=!e.minimized,d={...e.props??{},...i?{enableSharedModalDimensions:true}:{}};return e.modal&&(!e.launchMode||e.launchMode==="self-modal")?pe(Ds,{app:e,config:e.modal,visible:u,zIndex:t,onClose:o,onMinimize:a,initialModalState:e.restoreState,enableSharedModalDimensions:i,bodyProps:d}):e.launchMode==="self-modal"?pe(l,{...d,visible:u,onClose:o,onRequestClose:o,onMinimize:a,minimizeTargetPosition:n,instanceId:e.instanceId,zIndex:t,initialModalState:e.restoreState}):e.launchMode==="inline"?u?pe("div",{style:{position:"fixed",inset:0,zIndex:t,pointerEvents:"none"},children:pe(l,{...d,onClose:o,onMinimize:a,minimizeTargetPosition:n,instanceId:e.instanceId})}):null:pe("div",{style:{...$s,zIndex:t,display:u?"flex":"none"},children:pe("div",{style:js,children:pe(l,{...d,onClose:o,onMinimize:a,minimizeTargetPosition:n,instanceId:e.instanceId})})})},Xo=()=>{let{openApps:e,close:t,minimize:o}=yt(),{settings:a}=gs(),n=e.filter(u=>u.launchMode!=="toggle-only");if(n.length===0)return null;let i=n.filter(u=>u.minimized).length,l=Li()??Ls(i);return pe(Es,{children:n.map((u,d)=>pe(Hs,{app:u,zIndex:Ps+d,onClose:()=>t(u.instanceId),onMinimize:p=>o(u.instanceId,p),enableSharedModalDimensions:a.globalSettings?.enableSharedModalDimensions===true,minimizeTargetPosition:l},u.instanceId))})};import{useCallback as Ws,useEffect as Ot,useRef as Ns,useState as Yo,useSyncExternalStore as Qo}from"react";import{persistentStorage as Zo,getToolAttention as Ft,subscribeToolAttention as en}from"@buoy-gg/shared-ui/web";import{jsx as re,jsxs as bt}from"react/jsx-runtime";function Vs(e){return Qo(en,()=>Ft(e),()=>Ft(e))}var tn={needsInput:"#FF8329",done:"#20C997",failed:"#FF3B30"},on={needsInput:3,failed:2,done:1},nn=new Map;function an(e){let t=null;for(let a of e?e.split("|"):[]){let n=Ft(a);n&&(!t||on[n.kind]>on[t.kind])&&(t=n)}let o=nn.get(e);return o&&t&&o.kind===t.kind&&o.label===t.label?o:!o&&!t?null:(nn.set(e,t),t)}function Us(e){let t=e.join("|");return Qo(en,()=>an(t),()=>an(t))}var rn=28,Lt=32,Pt=6,sn=8,ln=24,cn="@react_buoy_minimized_stack_expanded",Ks=80,dn=2e3,_s=6e3,qs="#1A1A1A",Je="#888888";function un({down:e=false}){return re("svg",{width:12,height:12,viewBox:"0 0 24 24","aria-hidden":"true",style:{transform:e?"rotate(180deg)":void 0},children:re("path",{d:"M18 15l-6-6-6 6",fill:"none",stroke:Je,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Gs({id:e,title:t,icon:o,index:a,onPress:n}){let i=Vs(e),l=Ns(null);return Ot(()=>{let u=true,d,p=()=>{l.current?.animate([{transform:"translateX(0) scale(1)",opacity:1,offset:0},{transform:"translateX(3px) scale(1.05)",opacity:.4,offset:.2},{transform:"translateX(-3px) scale(1.1)",opacity:1,offset:.4},{transform:"translateX(2px) scale(1.0)",opacity:.6,offset:.6},{transform:"translateX(-1px) scale(0.95)",opacity:1,offset:.8},{transform:"translateX(0) scale(1)",opacity:1,offset:1}],{duration:Ks,easing:"linear"})},m=x=>{let g=x?500+Math.random()*1500+a*200:dn+Math.random()*(_s-dn)+a*300;d=setTimeout(()=>{u&&(p(),m(false))},g)};return m(true),()=>{u=false,clearTimeout(d)}},[a]),bt("button",{type:"button","aria-label":i?`${t} \u2014 ${i.label}. Restore`:`Restore ${t}`,onClick:n,style:{width:Lt,height:Lt,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",padding:0,cursor:"pointer",position:"relative"},children:[re("div",{ref:l,style:{display:"flex",alignItems:"center",justifyContent:"center"},children:o}),i?re("span",{"aria-hidden":true,"data-testid":`buoy-dock-badge-${e}-${i.kind}`,style:{position:"absolute",top:0,right:0,minWidth:12,height:12,borderRadius:6,padding:"0 2px",boxSizing:"border-box",background:tn[i.kind],border:"1.5px solid #0C0C0C",color:"#000",fontSize:8,fontWeight:800,lineHeight:"9px",display:"flex",alignItems:"center",justifyContent:"center"},children:i.kind==="needsInput"?"!":""}):null]})}function Js({containerWidth:e=32}){let{openApps:t,restore:o}=yt(),a=t.filter(g=>g.minimized&&g.launchMode!=="toggle-only"),[n,i]=Yo(false),[l,u]=Yo(false),d=Us(a.map(g=>g.id));Ot(()=>{let g=false;return(async()=>{let R=await Zo.getItem(cn);!g&&R==="true"&&i(true),g||u(true)})(),()=>{g=true}},[]),Ot(()=>{l&&Zo.setItem(cn,n?"true":"false")},[n,l]);let p=Ws(g=>{o(g)},[o]);if(a.length===0)return null;let m=sn+a.length*Lt+(a.length-1)*Pt+Pt+ln+4,x={backgroundColor:qs,borderTopLeftRadius:6,borderTopRightRadius:6,borderTop:`1px solid ${Je}66`,borderLeft:`1px solid ${Je}66`,borderRight:`1px solid ${Je}66`,borderBottom:"none",boxSizing:"border-box"};return bt("div",{style:{height:rn,overflow:"visible",position:"relative"},children:[re("div",{style:{position:"absolute",bottom:"var(--buoy-stack-bottom, 0px)",top:"var(--buoy-stack-top, auto)",left:0,width:e,maxHeight:"var(--buoy-stack-space, calc(100vh - 48px))",visibility:n?"visible":"hidden",height:n?m:0,opacity:n?1:0,overflowY:"auto",overflowX:"hidden",transition:"height 200ms ease, opacity 200ms ease",pointerEvents:n?"auto":"none",...x},children:bt("div",{style:{height:m,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:sn,gap:Pt,boxSizing:"border-box"},children:[[...a].reverse().map((g,R)=>re(Gs,{id:g.id,title:g.title||g.id,icon:g.icon??re("span",{style:{color:"#fff",fontSize:13},children:(g.title||g.id).slice(0,1).toUpperCase()}),index:R,onPress:()=>p(g.instanceId)},g.instanceId)),re("button",{type:"button","aria-label":"Collapse",onClick:()=>i(false),style:{width:"100%",height:ln,marginTop:3,display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",cursor:"pointer",padding:0},children:re(un,{down:true})})]})}),bt("button",{type:"button","aria-label":`Show ${a.length} minimized tools`,tabIndex:n?-1:0,"aria-hidden":n,onClick:()=>i(true),style:{position:"absolute",bottom:0,left:0,width:e,height:rn,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",gap:2,cursor:"pointer",padding:0,opacity:n?0:1,transform:n?"scale(0.9)":"scale(1)",transition:"opacity 200ms ease, transform 200ms ease",pointerEvents:n?"none":"auto",...x},children:[re(un,{}),d?re("span",{"aria-hidden":true,"data-testid":"buoy-dock-peek-attention",style:{position:"absolute",top:2,right:2,minWidth:11,height:11,borderRadius:6,padding:"0 2px",boxSizing:"border-box",background:tn[d.kind],border:"1.5px solid #0C0C0C",color:"#000",fontSize:8,fontWeight:800,lineHeight:"9px",display:"flex",alignItems:"center",justifyContent:"center"},children:d.kind==="needsInput"?"!":""}):null,a.length>1&&re("span",{style:{fontSize:9,fontWeight:600,color:Je,marginLeft:1},children:a.length})]})]})}import{registerToolModules as Xs}from"@buoy-gg/shared-ui/web";import{createElement as Ys}from"react";function pn(e){let t=e.icon;return{...e,icon:typeof t=="function"?o=>Ys(t,{size:o,slot:e.slot??"both",color:e.color}):()=>t}}import{createContext as Qs,useContext as Zs,useState as mn,useMemo as gn}from"react";import{jsx as el}from"react/jsx-runtime";var fn=Qs(null);function hn({children:e}){let[t,o]=mn(false),[a,n]=mn(false),i=gn(()=>t||a,[t,a]),l=gn(()=>({isDialOpen:t,isToolOpen:a,isDevToolsActive:i,setDialOpen:o,setToolOpen:n}),[t,a,i]);return el(fn.Provider,{value:l,children:e})}function $t(){let e=Zs(fn);return e||{isDialOpen:false,isToolOpen:false,isDevToolsActive:false,setDialOpen:()=>{},setToolOpen:()=>{}}}import*as tl from"@buoy-gg/license/web";import*as ol from"@buoy-gg/shared-ui/web";import*as nl from"@buoy-gg/shared-ui/web/dataViewer";function yn(e){Xs({core:{useDevToolsVisibility:$t},license:tl,"shared-ui":ol,"shared-ui/dataViewer":nl,...e});let t=new Set;return Object.values(e).flatMap(o=>Object.entries(o).flatMap(([a,n])=>!a.endsWith("Preset")||!n||typeof n.id!="string"||!n.component||t.has(n.id)?[]:(t.add(n.id),[pn(n)])))}import{useEffect as jt,useMemo as Ht,useRef as al}from"react";import{LicenseManager as il,useLicense as rl}from"@buoy-gg/license/web";import{registerToolAdapters as sl}from"@buoy-gg/shared-ui/web";function bn(e){return typeof e=="object"&&e!==null?e:void 0}function ll({isDevelopment:e,isLicensed:t,externalSync:o,isAvailable:a}){if(o===false||!a)return false;if(e)return true;let n=bn(o);return t&&n?.enableInRelease===true&&vn(n.socketURL,n)===null}var Sn="http://localhost:42831";function cl(e){return e==="localhost"||e.endsWith(".localhost")||/^127\.\d+\.\d+\.\d+$/.test(e)||e==="[::1]"||e==="::1"||e==="10.0.2.2"}function vn(e,t){let o=e??Sn;if(t?.allowInsecureNetwork===true)return null;let a;try{a=new URL(o)}catch{return`[Buoy] externalSync.socketURL "${o}" isn't a valid URL, so this release build won't connect to Buoy Desktop.`}return a.protocol==="https:"||a.protocol==="wss:"||cl(a.hostname)?null:`[Buoy] This release build won't connect to ${o}: release sync carries real user data, and plain http to another machine is readable by anyone on the same network. Use a simulator, an emulator or adb reverse (localhost), an https:// broker, or set externalSync.allowInsecureNetwork: true for a network you trust.`}var dl={impersonate:["searchUsers","startImpersonation","resumeImpersonation","updateSettings","removeFromHistory","clearHistory"]};function ul(e,t,o){if(t)return e;let a=null;for(let[n,i]of Object.entries(dl)){if(o?.includes(n))continue;let l=e[n];if(!l?.actions)continue;let u={...l.actions};for(let d of i)d in u&&(u[d]=()=>{throw new Error(`${n}.${d} is off in release builds. To allow it from Buoy Desktop and the MCP, pass externalSync={{ enableInRelease: true, releaseActions: ["${n}"] }}.`)});a??(a={...e}),a[n]={...l,actions:u}}return a??e}import{useEffect as pl,useMemo as ml,useState as gl}from"react";import{devToolsStorageKeys as fl,persistentStorage as hl}from"@buoy-gg/shared-ui/web";var yl=8;function bl(){let e="";for(;e.length<yl;)e+=(Math.random()*16|0).toString(16);return e}function Sl(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"")}function vl({appName:e,hardwareName:t,platform:o,installId:a,deviceId:n}){let i=Sl(e??"buoy")||"buoy",l=e??"Buoy Device",u=t?.trim()||o;return n?{deviceId:n,deviceName:`${l} (${u})`}:{deviceId:`${i}-${o}-${a}`,deviceName:`${l} (${u} \xB7 ${a.slice(-4)})`}}function wl(){let e=globalThis;try{return e.sessionStorage??null}catch{return null}}async function xl({platform:e=Be.OS,store:t,mint:o=bl}={}){let a=fl.sync.deviceId(),n=t===void 0?e==="web"?wl():hl:t;if(!n)return o();try{let i=await n.getItem(a);if(i&&i.length>0)return i;let l=o();return await n.setItem(a,l),l}catch{return o()}}var Wt=null;function Cl(){return Wt||(Wt=xl()),Wt}function Tl(e,t){let o=e?.deviceId,a=e?.deviceName,n=t.loadId??Cl,i=t.platform??Be.OS,[l,u]=gl(null);return pl(()=>{if(o)return;let d=false;return n().then(p=>{d||u(p)}),()=>{d=true}},[o,n]),ml(()=>{if(!o&&!l)return null;let d=vl({appName:t.appName,hardwareName:t.hardwareName,platform:i,installId:l??"",deviceId:o});return a?{...d,deviceName:a}:d},[o,a,l,t.appName,t.hardwareName,i])}import{getDevServerOrigin as zl,resolveReloadStrategy as kl,scheduleReloadApp as Il}from"@buoy-gg/shared-ui/web";var wn=Date.now(),xn=zl(),Ml={platform:Be.OS,isTV:Be.isTV===true,isTVOS:Be.isTVOS===true},Cn={version:3,getSnapshot:()=>{let e=kl("auto");return{startedAt:wn,devServerOrigin:xn,device:Ml,reload:{available:e!==null,strategy:e}}},subscribe:e=>()=>{},actions:{ping:()=>({ok:true,startedAt:wn,devServerOrigin:xn}),reloadApp:e=>{let t=e??{},{strategy:o,delayMs:a}=Il({strategy:t.strategy,delayMs:t.delayMs});return{scheduled:true,strategy:o,delayMs:a}}}};import{Fragment as Rl,jsx as Me,jsxs as Al}from"react/jsx-runtime";var Dl=["ConsoleRoot","RouteTracker","ReactQueryTracker","ReduxAutoInstrument","PerfMonitorRoot","AutomationResumer","ImagesRoot"],El=["DebugBordersStandaloneOverlay","HighlightUpdatesOverlay","ImageOverlayStandalone","PerfMonitorOverlay","JsTopHudOverlay","ImpersonateOverlay","ScenariosOverlay"];function Bl(e){let t=Ht(()=>Object.fromEntries(Object.entries(e.modules).map(([a,n])=>[a.replace(/^@buoy-gg\//,"").replace(/\/web$/,""),n])),[e.modules]),o=t["react-query"];return o?.useReactQuerySyncAdapter?Me(Ol,{...e,modules:t,query:o}):Me(Tn,{...e,modules:t})}function Ol(e){let t=e.query.useReactQuerySyncAdapter();return Me(Tn,{...e,queryAdapter:t})}function Tn({modules:e,apps:t,requiredEnvVars:o,externalSync:a,headless:n,sentryGetClient:i,queryAdapter:l}){let{isPro:u,tier:d}=rl(),p=Ht(()=>{let T={app:Cn};for(let[k,z]of Object.entries(e))for(let[O,b]of Object.entries(z))O.endsWith("SyncAdapter")&&b&&typeof b=="object"&&(T[k]=b);l&&(T.query=l),e.env?.createEnvSyncAdapter&&(T.env=e.env.createEnvSyncAdapter(o??[]));for(let k of t??[])k.sync&&(T[`custom:${k.id}`]=k.sync);return T},[e,t,o,l]),m=al(p);m.current=p,jt(()=>sl(()=>m.current),[]),jt(()=>{let T=[],k=z=>{let O=z?.();typeof O=="function"&&T.push(O)};return k(e.network?.startNetworkCapture),k(e.storage?.startBrowserStorageCapture),k(e.assets?.startBrowserAssetCapture),e.storage?.storageSyncAdapter?.subscribe&&k(()=>e.storage.storageSyncAdapter.subscribe(()=>{})),e["focus-inspector"]?.focusInspectorSyncAdapter?.subscribe&&k(()=>e["focus-inspector"].focusInspectorSyncAdapter.subscribe(()=>{})),()=>{for(let z of T.reverse())z()}},[e]);let x=e["external-sync"],g=typeof ot<"u"?ot:process.env.NODE_ENV!=="production",R=ll({isDevelopment:g,isLicensed:u,externalSync:a,isAvailable:!!x}),v=bn(a);!g&&v?.enableInRelease&&Fl(vn(v.socketURL,v));let I=e.sentry?.SentryRoot;return Al(Rl,{children:[Object.entries(e).flatMap(([T,k])=>Dl.map(z=>{let O=k[z];return O?Me(O,{},`${T}:${z}`):null})),I&&Me(I,{getClient:i}),Object.entries(e).flatMap(([T,k])=>El.map(z=>{let O=k[z];return O&&(!n||z==="ScenariosOverlay"||z==="ImpersonateOverlay")?Me(O,{},`${T}:${z}`):null})),R&&Me(Ll,{module:x,tools:p,options:v,isPro:u,tier:d,dev:g})]})}var zn=null;function Fl(e){!e||e===zn||(zn=e,console.warn(e))}function Ll({module:e,tools:t,options:o,isPro:a,tier:n,dev:i}){let l=Tl(o,{appName:typeof document>"u"?null:document.title||location.hostname,hardwareName:"Browser",platform:"web"}),{socket:u}=e.useExternalSyncSocket({deviceName:l?.deviceName??"Buoy Browser",socketURL:o?.socketURL??(i?e.getDefaultSocketURL():Sn),persistentDeviceId:l?.deviceId??null,platform:"web",enableLogs:o?.enableLogs});jt(()=>{if(!u)return;let m=()=>{u.connected&&il.hasAccountAccess()&&u.emit("device-license",{isPro:a?"1":"0",tier:n})};return m(),u.on("connect",m),()=>{u.off("connect",m)}},[u,a,n]);let d=o?.releaseActions?.join(",")??"",p=Ht(()=>ul(t,i,d?d.split(","):void 0),[t,i,d]);return e.useExternalSync({tools:p,socket:u,deviceId:l?.deviceId??null,enableLogs:o?.enableLogs}),null}import{useState as kn}from"react";import{createPortal as Pl}from"react-dom";import{useBuoySession as $l}from"@buoy-gg/license/web";import{Fragment as In,jsx as Xe,jsxs as Mn}from"react/jsx-runtime";var Rn="#20C997";function jl(){let{status:e,signIn:t,signOut:o}=$l(),[a,n]=kn(false),[i,l]=kn(null);if(typeof document>"u")return null;let u=()=>{l(null),n(true),t().catch(p=>l(p instanceof Error?p.message:"Sign-in did not work. Try again.")).finally(()=>n(false))},d=e.state==="active";return Pl(Xe("div",{"data-buoy-signin":"",style:{position:"fixed",right:"max(16px, env(safe-area-inset-right))",bottom:"max(20px, env(safe-area-inset-bottom))",zIndex:99999,maxWidth:"min(320px, calc(100vw - 32px))",padding:d||i?"12px 14px":0,borderRadius:16,background:d||i?"#0f1419":"transparent",color:"#e6edf3",boxShadow:d||i?"0 10px 30px rgba(0,0,0,.35)":"none",fontFamily:"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",fontSize:14,lineHeight:1.45},children:d?Mn(In,{children:[Xe("div",{"data-testid":"buoy-signin-needs-plan",children:"Buoy on a live site needs a Pro or Business plan."}),Xe("button",{type:"button",onClick:()=>void o(),style:Hl,"data-testid":"buoy-signout",children:"Sign out"})]}):Mn(In,{children:[i?Xe("div",{role:"alert",style:{marginBottom:10},"data-testid":"buoy-signin-error",children:i}):null,Xe("button",{type:"button",onClick:u,disabled:a,"data-testid":"buoy-signin",style:{display:"inline-flex",alignItems:"center",gap:8,padding:"10px 16px",border:"none",borderRadius:999,background:Rn,color:"#04130d",fontWeight:600,fontSize:14,cursor:a?"wait":"pointer",boxShadow:"0 8px 24px rgba(0,0,0,.3)"},children:a?"Signing in\u2026":"Sign in to Buoy"})]})}),document.body)}var Hl={marginTop:8,padding:0,border:"none",background:"none",color:Rn,fontSize:14,cursor:"pointer",textDecoration:"underline"};import{jsx as U,jsxs as An}from"react/jsx-runtime";var Wl={},Dn="@react_buoy_floating_menu_tooltip_shown",Nl=Te;function Vl({size:e=14,color:t="#20C997"}){let o=Math.max(2,e/4),a=Math.max(1,e/16);return U("div",{style:{display:"grid",gridTemplateColumns:`repeat(3, ${o}px)`,gap:a,width:e,height:e,alignContent:"center",justifyContent:"center"},children:Array.from({length:9}).map((n,i)=>U("div",{style:{width:o,height:o,borderRadius:o/2,backgroundColor:t}},i))})}function Ul(e){return U(hn,{children:U(Jo,{children:U(Kl,{...e})})})}function Kl({environment:e,userRole:t,availableEnvironments:o,onEnvironmentSwitch:a,apps:n,modules:i=Wl,externalSync:l,requiredEnvVars:u,sentryGetClient:d,disableHints:p=false,headless:m=false}){let[x,g]=wt(false),[R,v]=wt(false),I=Ii(false),T=yt(),k=Oe(()=>Gt([...yn(i),...n??[]]),[n,i]),z=$t(),O=T.openApps.some(r=>!r.minimized);le(()=>{z.setDialOpen(x)},[x,z.setDialOpen]),le(()=>{z.setToolOpen(O||R)},[O,R,z.setToolOpen]);let{registerApps:b}=T;le(()=>{b(k.map(r=>{let L=r.icon;return{...r,icon:typeof L=="function"?({size:W})=>L(W):L}}))},[b,k]);let M=Oe(()=>k.map(r=>({id:r.id,name:r.name,description:r.description,slot:r.slot})),[k]),{settings:$}=Mi({availableTools:M,storage:Nl});le(()=>{let r=false;return(async()=>{let[L,W]=await Promise.all([Te.getItem(at.dial.isOpen()),Te.getItem(at.settings.modalOpen())]);r||(L==="true"&&g(true),W==="true"&&(g(true),v(true)),I.current=true)})(),()=>{r=true}},[]),le(()=>{I.current&&Te.setItem(at.dial.isOpen(),x?"true":"false")},[x]),le(()=>{I.current&&Te.setItem(at.settings.modalOpen(),R?"true":"false")},[R]);let C=Fe(r=>{if(xr(r.id),r.launchMode==="toggle-only"){r.onPress?.();return}if(r.component){let L=typeof r.icon=="function"?r.icon(20):r.icon;T.open({id:r.id,title:r.name||nt(r.id),component:r.component,props:r.props,modal:r.modal,launchMode:r.launchMode||"self-modal",singleton:r.singleton??true,icon:L,color:r.color||qt(r.id)})}else r.onPress?.()},[T]),A=Oe(()=>xt(k,"dial").map(r=>{let L=r.color||qt(r.id),W;return typeof r.icon=="string"?W=r.icon:typeof r.icon=="function"?W=r.icon(32):W=null,{id:r.id,name:r.name||nt(r.id),icon:W,unavailable:!r.component&&!r.onPress,color:L,onPress:()=>{C(r),g(false)}}}),[k,C]),ee=Oe(()=>{if(!x)return A;let r=new Map(A.map(L=>[L.id,L]));return wr(A.map(L=>L.id)).map(L=>r.get(L)).filter(L=>!!L)},[x,A]),Z=Oe(()=>xt(k,"row").filter(r=>$.floatingTools[r.id]===true&&(r.component||r.onPress)),[k,$.floatingTools]),G=Oe(()=>k.map(r=>({id:r.id,name:r.name||nt(r.id),description:r.description||Ri(r.id),slot:r.slot,icon:r.icon,color:r.color})),[k]),[ce,K]=wt(false),ne=T.openApps.some(r=>!r.minimized);le(()=>{if(p)return;let r=false,L=setTimeout(async()=>{let W=await Te.getItem(Dn);!r&&!W&&K(true)},1e3);return()=>{r=true,clearTimeout(L)}},[p]);let J=Fe(()=>{K(false),Te.setItem(Dn,"true")},[]),ve=Fe(()=>{J(),g(true)},[J]),me=Fe(()=>{g(false),v(false)},[]),we=Fe(()=>{v(r=>!r)},[]),j=Fe(()=>v(false),[]),Re=!!(o?.length&&a),fe=$.floatingTools.environment!==false,se=ce&&!x&&!ne;le(()=>{if(!se)return;let r=W=>{(!(W.target instanceof Element)||!W.target.closest("[data-buoy-root]"))&&J()},L=W=>{W.key==="Escape"&&J()};return document.addEventListener("pointerdown",r,true),document.addEventListener("keydown",L),()=>{document.removeEventListener("pointerdown",r,true),document.removeEventListener("keydown",L)}},[se,J]);let xe=T.openApps.some(r=>r.minimized&&r.launchMode!=="toggle-only"),ae=U(Bl,{modules:i,apps:n,requiredEnvVars:u,externalSync:l,headless:m,sentryGetClient:d});return m?ae:An("div",{"data-buoy-root":"",style:{display:"contents"},children:[ae,se&&U("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.85)",zIndex:1e4,pointerEvents:"none"}}),An(Jt,{enablePositionPersistence:!se,pushToSide:x||ne,suspendPointerEvents:x,centerOnboarding:se,minimizedStack:xe?U(Js,{}):void 0,hasMinimizedStack:xe,children:[e&&fe&&!Re&&U(Ai,{environment:e}),Re&&fe&&U(Di,{currentEnvironment:e??"local",availableEnvironments:o,onSelect:a}),t?U(Xt,{userRole:t,onPress:ve}):U("button",{"aria-label":"Open dev tools",onClick:ve,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",background:"none",border:"none",cursor:"pointer"},children:U(Vl,{})}),Z.map(r=>U("button",{"aria-label":r.name||nt(r.id),title:r.description,onClick:()=>C(r),style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",borderRadius:6,background:"none",border:"none",cursor:"pointer"},children:typeof r.icon=="function"?r.icon(16):r.icon},r.id))]}),se&&U(uo,{title:"Welcome to Buoy!",message:"Grab and position this menu wherever you want, then tap the icon to open your tools.",onDismiss:J}),x&&U(ho,{icons:ee,onClose:me,centerLabel:"BUOY",onCenterPress:we,settingsOpen:R,hintsDisabled:p}),U(Po,{visible:R,onClose:j,availableTools:G,onSettingsChange:r=>{}}),U(Xo,{}),U(wi,{})]})}function _l(e){let{access:t,isPro:o,licenseKey:a}=Ci();le(()=>{xi.configure(e.licenseKey)},[e.licenseKey]);let n=e.licenseKey===void 0||Ti(e.licenseKey,a),i=typeof ot<"u"?ot:process.env.NODE_ENV!=="production",l=n&&t.status==="admitted";return le(()=>{l&&ki()},[l]),le(()=>{i||t.status==="initializing"||(o&&l?vi():Kt())},[i,o,l,t.status]),!i&&!o?e.signIn&&!e.headless?U(jl,{}):null:l?U(Ul,{...e}):e.headless?null:U(zi,{})}import{useSettings as ql,useFloatingTools as Gl,getToolLabel as Jl,getToolDescription as Xl,getToolColor as Yl,settingsColors as Ql,settingsStyles as Zl,dialColors as ec,dialStyles as tc}from"@buoy-gg/floating-tools-react/web";export{ua as Activity,Si as AlertCircle,ma as AlertTriangle,Jo as AppHostProvider,Xo as AppOverlay,_a as Badge,On as BarChart3,jn as BaseEventStore,Ln as Bookmark,fa as Bug,oi as Button,di as Card,ya as Check,Sa as CheckCircle,ba as CheckSquare,wa as ChevronDown,Ca as ChevronLeft,za as ChevronRight,Ia as ChevronUp,Ra as Clock,$n as Cloud,gi as CollapsibleSection,Aa as Copy,ai as CopyButton,Pn as DataViewer,En as Database,hn as DevToolsVisibilityProvider,ho as DialMenu,Qa as DiffViewer,Fi as Divider,Hn as Download,Nn as Edit3,bi as EmptyState,Fn as EventStepperFooter,Da as Eye,Ea as EyeOff,Ba as FileJson,Oa as FileText,Fa as Filter,La as FlaskConical,_l as FloatingDevTools,Jt as FloatingTools,Un as GitBranch,Pa as Globe,_n as HardDrive,$a as Hash,Gn as HelpCircle,Xn as Home,Qn as Image,ja as Info,Xa as InfoRow,ca as JsModal,Wa as Key,Va as Layers,ea as Link,Ka as Lock,oa as Maximize2,aa as Minus,ra as Palette,qa as Pause,la as Pin,Ja as Play,Ya as Plus,Za as Power,ri as PowerToggle,ti as RefreshCw,Wn as RelativeTime,da as Route,li as Row,ni as Search,Bn as SearchBar,pi as SectionHeader,pa as Server,ii as Settings,Po as SettingsModal,si as Shield,ga as Smartphone,ha as Square,Ga as StatusDot,hi as TabSelector,va as Timer,ci as Trash2,xa as Unlock,Ta as Upload,ui as User,Xt as UserStatus,ka as Users,mi as Wifi,fi as X,Ma as XCircle,yi as Zap,Cn as appSyncAdapter,Bi as autoDiscoverWebPresets,Gt as autoDiscoverWithCustom,Kt as clearReleaseOptIn,sa as copyToClipboard,pn as createWebTool,yn as createWebTools,Ei as defaultToolPresets,na as devToolsStorageKeys,ec as dialColors,tc as dialStyles,Vn as formatBytes,Kn as formatDuration,qn as formatNumber,Oi as getEnabledTools,Yl as getToolColor,Xl as getToolDescription,Jl as getToolLabel,xt as getToolsBySlot,Na as methodColor,ta as persistentStorage,Yn as safeStringify,Ql as settingsColors,Zl as settingsStyles,Ha as statusColor,ei as toolTheme,Jn as truncateMiddle,Ua as typeColor,yt as useAppHost,$t as useDevToolsVisibility,Gl as useFloatingTools,Zn as usePersistedState,ia as useSafeAreaInsets,ql as useSettings,Ms as useToolHeader,Ko as useToolHost};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/core",
3
- "version": "7.0.48",
3
+ "version": "7.0.49",
4
4
  "description": "Floating developer menu and account setup for React Native. Add tool packages and configure Desktop or MCP connections separately.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -61,10 +61,10 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "react-devtools-core": "6.1.5",
64
- "@buoy-gg/license": "^7.0.48",
65
- "@buoy-gg/floating-tools-react": "^7.0.48",
66
- "@buoy-gg/shared-ui": "^7.0.48",
67
- "@buoy-gg/floating-tools-core": "^7.0.48"
64
+ "@buoy-gg/floating-tools-core": "^7.0.49",
65
+ "@buoy-gg/license": "^7.0.49",
66
+ "@buoy-gg/floating-tools-react": "^7.0.49",
67
+ "@buoy-gg/shared-ui": "^7.0.49"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "*"