@buoy-gg/impersonate 7.0.68 → 7.0.69
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.
- package/lib/commonjs/impersonate/components/DataNukeSettings.js +2 -2
- package/lib/commonjs/impersonate/components/ImpersonateBanner.js +1 -1
- package/lib/commonjs/impersonate/components/ImpersonateHistoryList.js +1 -1
- package/lib/commonjs/impersonate/components/ImpersonateModal.js +1 -1
- package/lib/commonjs/impersonate/components/UserCard.js +1 -1
- package/lib/commonjs/impersonate/components/UserSearchView.js +1 -1
- package/lib/module/impersonate/components/DataNukeSettings.js +2 -2
- package/lib/module/impersonate/components/ImpersonateBanner.js +1 -1
- package/lib/module/impersonate/components/ImpersonateHistoryList.js +1 -1
- package/lib/module/impersonate/components/ImpersonateModal.js +1 -1
- package/lib/module/impersonate/components/UserCard.js +1 -1
- package/lib/module/impersonate/components/UserSearchView.js +1 -1
- package/lib/web/index.mjs +2 -2
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DataNukeSettings=DataNukeSettings;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(c,n){if("function"==typeof WeakMap)var l=new WeakMap,u=new WeakMap;return(_interopRequireWildcard=function(o,s){if(!s&&o&&o.__esModule)return o;var t,i,e={__proto__:null,default:o};if(null===o||"object"!=typeof o&&"function"!=typeof o)return e;if(t=s?u:l){if(t.has(o))return t.get(o);t.set(o,e)}for(const a in o)"default"!==a&&{}.hasOwnProperty.call(o,a)&&((i=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(o,a))&&(i.get||i.set)?t(e,a,i):e[a]=o[a]);return e})(c,n)}const DEFAULT_HEADER_KEY="x-impersonate-user-id";const DEFAULT_SHOW_BANNER=true;const DEFAULT_DATA_NUKE_SETTINGS={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function ToggleRow({label:c,description:n,value:l,onChange:u,recommended:o,dangerous:s,detected:t}){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.DataNukeSettings=DataNukeSettings;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(c,n){if("function"==typeof WeakMap)var l=new WeakMap,u=new WeakMap;return(_interopRequireWildcard=function(o,s){if(!s&&o&&o.__esModule)return o;var t,i,e={__proto__:null,default:o};if(null===o||"object"!=typeof o&&"function"!=typeof o)return e;if(t=s?u:l){if(t.has(o))return t.get(o);t.set(o,e)}for(const a in o)"default"!==a&&{}.hasOwnProperty.call(o,a)&&((i=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(o,a))&&(i.get||i.set)?t(e,a,i):e[a]=o[a]);return e})(c,n)}const DEFAULT_HEADER_KEY="x-impersonate-user-id";const DEFAULT_SHOW_BANNER=true;const DEFAULT_DATA_NUKE_SETTINGS={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function ToggleRow({label:c,description:n,value:l,onChange:u,recommended:o,dangerous:s,detected:t,testID:i}){const e=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t!==void 0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.detectedBadge,t?styles.detectedBadgeActive:styles.detectedBadgeInactive],children:[t?(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:10,color:_sharedUi.buoyColors.success}):(0,_jsxRuntime.jsx)(_sharedUi.X,{size:10,color:_sharedUi.night.color.textTertiary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.detectedText,t?styles.detectedTextActive:styles.detectedTextInactive],children:t?"Detected":"Not Detected"})]}),o&&t!==false&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.recommendedBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:10,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.recommendedText,children:"Recommended"})]})]});return(0,_jsxRuntime.jsx)(_sharedUi.ToggleRow,{variant:"plain",label:c,description:n,value:l,onValueChange:u,tone:s?"warning":"accent",emphasizeLabel:s,accessory:e,testID:i})}function DataNukeSettings({headerKey:c,settings:n,showBanner:l,onSave:u,onShowBannerChange:o,detectionStatus:s}){const[t,i]=(0,_react.useState)(c);const[e,a]=(0,_react.useState)(n);const[d,g]=(0,_react.useState)(l);const[y,x]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{i(c)},[c]);(0,_react.useEffect)(()=>{a(n)},[n]);(0,_react.useEffect)(()=>{g(l)},[l]);const p=(0,_react.useMemo)(()=>{return t!==c||e.reactQuery!==n.reactQuery||e.redux!==n.redux||e.asyncStorage!==n.asyncStorage||e.mmkv!==n.mmkv},[t,e,c,n]);const f=(0,_react.useMemo)(()=>{return t===DEFAULT_HEADER_KEY&&d===DEFAULT_SHOW_BANNER&&e.reactQuery===DEFAULT_DATA_NUKE_SETTINGS.reactQuery&&e.redux===DEFAULT_DATA_NUKE_SETTINGS.redux&&e.asyncStorage===DEFAULT_DATA_NUKE_SETTINGS.asyncStorage&&e.mmkv===DEFAULT_DATA_NUKE_SETTINGS.mmkv},[t,d,e]);const m=()=>{u(t.trim()||DEFAULT_HEADER_KEY,e,d)};const b=()=>{i(c);a(n);g(l)};const T=()=>{i(DEFAULT_HEADER_KEY);a(DEFAULT_DATA_NUKE_SETTINGS);g(DEFAULT_SHOW_BANNER);o(DEFAULT_SHOW_BANNER)};const h=(r,S)=>{a(w=>({...w,[r]:S}))};const C=(0,_react.useMemo)(()=>({defaults:{headerKey:t,showBanner:d,dataNukeSettings:{reactQuery:e.reactQuery,redux:e.redux,asyncStorage:e.asyncStorage,mmkv:e.mmkv}}}),[t,d,e]);const j=async()=>{const r=`defaults: {
|
|
2
2
|
headerKey: '${t}',
|
|
3
3
|
showBanner: ${d},
|
|
4
4
|
dataNukeSettings: {
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
asyncStorage: ${e.asyncStorage},
|
|
8
8
|
mmkv: ${e.mmkv},
|
|
9
9
|
},
|
|
10
|
-
},`;try{await(0,_sharedUi.copyToClipboard)(r);x(true);setTimeout(()=>x(false),2e3)}catch{}};return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.container,contentContainerStyle:styles.contentContainer,children:[p&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.actionBar,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionBarContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.unsavedText,children:"Unsaved changes"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionButtons,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.discardButton,onPress:T,children:[(0,_jsxRuntime.jsx)(_sharedUi.X,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.discardButtonText,children:"Discard"})]}),(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.saveButton,onPress:m,children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.night.color.onAccent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.saveButtonText,children:"Save"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Header Configuration",icon:_sharedUi.Settings,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.inputLabel,children:"Header Key"}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{style:styles.input,value:t,onChangeText:i,placeholder:"x-impersonate-user-id",placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inputFooter,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),t!==DEFAULT_HEADER_KEY&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>i(DEFAULT_HEADER_KEY),style:styles.resetLink,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.resetLinkText,children:"Reset to default"})})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Display",icon:_sharedUi.Eye,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.togglesCard,children:(0,_jsxRuntime.jsx)(ToggleRow,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:d,onChange:r=>{g(r);o(r)},recommended:true})})})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Data Clearing",icon:_sharedUi.AlertTriangle,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.togglesCard,children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"React Query",description:"Clear query cache and cancel pending queries",value:e.reactQuery,onChange:r=>h("reactQuery",r),recommended:true,detected:s?.reactQuery}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"Redux",description:"Reset Redux store to initial state",value:e.redux,onChange:r=>h("redux",r),recommended:true,detected:s?.redux})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.advancedSection,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.advancedLabel,children:"Storage Options"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.togglesCard,styles.dangerousCard],children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:e.asyncStorage,onChange:r=>h("asyncStorage",r),dangerous:true,detected:s?.asyncStorage}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:e.mmkv,onChange:r=>h("mmkv",r),dangerous:true,detected:s?.mmkv})]})]}),(e.asyncStorage||e.mmkv)&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Storage Clearing Enabled"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!f&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.restoreButton,onPress:b,children:[(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.restoreButtonText,children:"Restore Defaults"})]}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"How It Works",icon:_sharedUi.Info,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.infoText,styles.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.codeBlock,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeComment,children:"// Example request header"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.codeText,children:[t||"x-impersonate-user-id",": ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeValue,children:"user_123"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Export Configuration",icon:_sharedUi.Copy,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"Copy current settings to use in createImpersonateTool()."}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:C,showTypeFilter:true,rawMode:true,initialExpanded:true})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.copyButton,onPress:j,children:y?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.copyButtonText,styles.copySuccessText],children:"Copied!"})]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.copyButtonText,children:"Copy Config"})]})})]})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:_sharedUi.night.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:4},dangerousCard:{borderColor:_sharedUi.night.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,paddingHorizontal:14,fontSize:14,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:_sharedUi.night.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:_sharedUi.night.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:_sharedUi.night.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:_sharedUi.buoyColors.success+"15"},detectedBadgeInactive:{backgroundColor:_sharedUi.night.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:_sharedUi.buoyColors.success},detectedTextInactive:{color:_sharedUi.night.color.textTertiary},divider:{height:1,backgroundColor:_sharedUi.night.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:12,color:_sharedUi.night.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:_sharedUi.night.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont,marginBottom:6},codeText:{fontSize:13,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},codeValue:{color:_sharedUi.night.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:_sharedUi.night.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:_sharedUi.night.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.accent},copySuccessText:{color:_sharedUi.buoyColors.success}});
|
|
10
|
+
},`;try{await(0,_sharedUi.copyToClipboard)(r);x(true);setTimeout(()=>x(false),2e3)}catch{}};return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{testID:"buoy-impersonate-settings-scroll",style:styles.container,contentContainerStyle:styles.contentContainer,children:[p&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.actionBar,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionBarContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.unsavedText,children:"Unsaved changes"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionButtons,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-discard",style:styles.discardButton,onPress:b,children:[(0,_jsxRuntime.jsx)(_sharedUi.X,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.discardButtonText,children:"Discard"})]}),(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-save",style:styles.saveButton,onPress:m,children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.night.color.onAccent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.saveButtonText,children:"Save"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Header Configuration",icon:_sharedUi.Settings,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.inputLabel,children:"Header Key"}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{testID:"buoy-impersonate-header-key",style:styles.input,value:t,onChangeText:i,placeholder:"x-impersonate-user-id",placeholderTextColor:_sharedUi.night.color.placeholder,autoCapitalize:"none",autoCorrect:false}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inputFooter,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),t!==DEFAULT_HEADER_KEY&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>i(DEFAULT_HEADER_KEY),style:styles.resetLink,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.resetLinkText,children:"Reset to default"})})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Display",icon:_sharedUi.Eye,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.togglesCard,children:(0,_jsxRuntime.jsx)(ToggleRow,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:d,onChange:r=>{g(r);o(r)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Data Clearing",icon:_sharedUi.AlertTriangle,defaultOpen:true,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.togglesCard,children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"React Query",description:"Clear query cache and cancel pending queries",value:e.reactQuery,onChange:r=>h("reactQuery",r),recommended:true,detected:s?.reactQuery}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"Redux",description:"Reset Redux store to initial state",value:e.redux,onChange:r=>h("redux",r),recommended:true,detected:s?.redux})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.advancedSection,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.advancedLabel,children:"Storage Options"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.togglesCard,styles.dangerousCard],children:[(0,_jsxRuntime.jsx)(ToggleRow,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:e.asyncStorage,onChange:r=>h("asyncStorage",r),dangerous:true,detected:s?.asyncStorage}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.divider}),(0,_jsxRuntime.jsx)(ToggleRow,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:e.mmkv,onChange:r=>h("mmkv",r),dangerous:true,detected:s?.mmkv})]})]}),(e.asyncStorage||e.mmkv)&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Storage Clearing Enabled"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!f&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-restore-defaults",style:styles.restoreButton,onPress:T,children:[(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.restoreButtonText,children:"Restore Defaults"})]}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"How It Works",icon:_sharedUi.Info,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.infoText,styles.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.codeBlock,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeComment,children:"// Example request header"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.codeText,children:[t||"x-impersonate-user-id",": ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.codeValue,children:"user_123"})]})]})]})}),(0,_jsxRuntime.jsx)(_sharedUi.CollapsibleSection,{title:"Export Configuration",icon:_sharedUi.Copy,defaultOpen:false,variant:"bordered",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoText,children:"Copy current settings to use in createImpersonateTool()."}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:C,showTypeFilter:true,rawMode:true,initialExpanded:true})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.copyButton,onPress:j,children:y?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Check,{size:14,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.copyButtonText,styles.copySuccessText],children:"Copied!"})]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.Copy,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.copyButtonText,children:"Copy Config"})]})})]})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:_sharedUi.night.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:4},dangerousCard:{borderColor:_sharedUi.night.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,paddingHorizontal:14,fontSize:14,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:_sharedUi.night.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:_sharedUi.night.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:_sharedUi.night.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:_sharedUi.buoyColors.success+"15"},detectedBadgeInactive:{backgroundColor:_sharedUi.night.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:_sharedUi.buoyColors.success},detectedTextInactive:{color:_sharedUi.night.color.textTertiary},divider:{height:1,backgroundColor:_sharedUi.night.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:12,color:_sharedUi.night.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:_sharedUi.night.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont,marginBottom:6},codeText:{fontSize:13,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},codeValue:{color:_sharedUi.night.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:_sharedUi.night.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:_sharedUi.night.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:_sharedUi.night.color.accent},copySuccessText:{color:_sharedUi.buoyColors.success}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateBanner=ImpersonateBanner;exports.ImpersonateBannerMinimal=ImpersonateBannerMinimal;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _impersonateStore=require("../utils/impersonateStore");var _UserAvatar=require("./UserAvatar");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateBanner=ImpersonateBanner;exports.ImpersonateBannerMinimal=ImpersonateBannerMinimal;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _impersonateStore=require("../utils/impersonateStore");var _UserAvatar=require("./UserAvatar");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(s,a){if("function"==typeof WeakMap)var c=new WeakMap,i=new WeakMap;return(_interopRequireWildcard=function(e,l){if(!l&&e&&e.__esModule)return e;var t,o,r={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return r;if(t=l?i:c){if(t.has(e))return t.get(e);t.set(e,r)}for(const n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((o=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,n))&&(o.get||o.set)?t(r,n,o):r[n]=e[n]);return r})(s,a)}function ImpersonateBanner({onPress:s,onStopPress:a,position:c="top",offset:i=50}){const e=(0,_react.useSyncExternalStore)(_impersonateStore.impersonateStore.subscribe,_impersonateStore.impersonateStore.getSnapshot,_impersonateStore.impersonateStore.getSnapshot);if(!e.isActive||!e.currentUser||!e.showBanner){return null}const l=async()=>{console.log("[Buoy]","[impersonate] banner pause/resume pressed");if(e.isPaused){await _impersonateStore.impersonateStore.resumeImpersonation()}else{await _impersonateStore.impersonateStore.pauseImpersonation()}};const t=e.currentUser.displayName||e.currentUser.email||e.currentUser.id;const o=c==="top"?{top:i}:{bottom:i};const r=async()=>{console.log("[Buoy]","[impersonate] banner STOP pressed");await _impersonateStore.impersonateStore.stopImpersonation()};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.container,o],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"buoy-impersonate-banner",style:styles.banner,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-banner-open",style:styles.userSection,onPress:s,activeOpacity:.7,children:[(0,_jsxRuntime.jsx)(_UserAvatar.UserAvatar,{userId:e.currentUser.id,name:t,size:"small",showActiveIndicator:false}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.userName,e.isPaused&&styles.userNamePaused],numberOfLines:1,children:t})]}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:!e.isPaused,onToggle:l,size:"small",accessibilityLabel:"Toggle impersonation",testID:"buoy-impersonate-banner-toggle"}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-banner-stop",accessibilityLabel:"Stop impersonating",style:styles.closeButton,onPress:r,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]})})}function ImpersonateBannerMinimal({onPress:s}){const a=(0,_react.useSyncExternalStore)(_impersonateStore.impersonateStore.subscribe,_impersonateStore.impersonateStore.getSnapshot,_impersonateStore.impersonateStore.getSnapshot);if(!a.isActive||!a.currentUser){return null}return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.minimalBanner,onPress:s,activeOpacity:.8,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.minimalDot}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.minimalText,children:"IMP"})]})}const styles=_reactNative.StyleSheet.create({container:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999,pointerEvents:"box-none"},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:_sharedUi.buoyColors.success+"40",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},userSection:{flexDirection:"row",alignItems:"center",gap:10},userName:{fontSize:14,fontWeight:"600",color:"#fff",maxWidth:180},userNamePaused:{opacity:.6},closeButton:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},minimalBanner:{position:"absolute",top:60,right:16,flexDirection:"row",alignItems:"center",backgroundColor:"rgba(26, 26, 26, 0.92)",borderWidth:1,borderColor:_sharedUi.buoyColors.success+"35",borderRadius:12,paddingVertical:5,paddingHorizontal:10,gap:5,zIndex:9999,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.2,shadowRadius:6,elevation:4},minimalDot:{width:6,height:6,borderRadius:3,backgroundColor:_sharedUi.buoyColors.success},minimalText:{fontSize:10,fontWeight:"700",color:_sharedUi.buoyColors.success,letterSpacing:.5}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateHistoryList=ImpersonateHistoryList;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(n
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateHistoryList=ImpersonateHistoryList;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(o,n){if("function"==typeof WeakMap)var s=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,i){if(!i&&e&&e.__esModule)return e;var t,r,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(t=i?l:s){if(t.has(e))return t.get(e);t.set(e,a)}for(const c in e)"default"!==c&&{}.hasOwnProperty.call(e,c)&&((r=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,c))&&(r.get||r.set)?t(a,c,r):a[c]=e[c]);return a})(o,n)}function HistoryItemCard({item:o,isActive:n,onSelect:s,onStop:l,onRemove:e,showRemoveButton:i}){const t=(0,_sharedUi.useRelativeTime)(new Date(o.lastUsedAt));return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:o.user,isActive:n,onPress:()=>!n&&s(o.user),onStop:n?l:void 0,onRemove:e,showRemoveButton:i,lastUsedTime:t})}function ImpersonateHistoryList({history:o,currentUserId:n,onSelectUser:s,onStopImpersonation:l,onRemoveFromHistory:e,onClearHistory:i}){const t=(0,_react.useCallback)(({item:r})=>{const a=n===r.user.id;return(0,_jsxRuntime.jsx)(HistoryItemCard,{item:r,isActive:a,onSelect:s,onStop:l,onRemove:e?()=>e(r.user.id):void 0,showRemoveButton:!!e})},[n,s,l,e]);if(o.length===0){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerTitle,children:"Recent"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerBadgeText,children:o.length})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerSpacer}),i&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-clear-history",style:styles.clearButton,onPress:i,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:12,color:_sharedUi.night.color.textTertiary})})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:"buoy-impersonate-history-scroll",data:o,keyExtractor:r=>r.user.id,renderItem:t,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateModal=ImpersonateModal;exports.ImpersonateToolView=ImpersonateToolView;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _useImpersonate=require("../hooks/useImpersonate");var _useAutoClearReactQuery=require("../hooks/useAutoClearReactQuery");var _useAutoClearRedux=require("../hooks/useAutoClearRedux");var _useAutoClearAsyncStorage=require("../hooks/useAutoClearAsyncStorage");var _UserSearchView=require("./UserSearchView");var _ImpersonateHistoryList=require("./ImpersonateHistoryList");var _DataNukeSettings=require("./DataNukeSettings");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(i,y){if("function"==typeof WeakMap)var l=new WeakMap,S=new WeakMap;return(_interopRequireWildcard=function(e,c){if(!c&&e&&e.__esModule)return e;var r,s,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(r=c?S:l){if(r.has(e))return r.get(e);r.set(e,a)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((s=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(s.get||s.set)?r(a,t,s):a[t]=e[t]);return a})(i,y)}const JsModal=_sharedUi.JsModal;const ALL_TABS=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}];const TABS_WITHOUT_SETTINGS=[{key:"search",label:"Search"},{key:"history",label:"History"}];function ImpersonateModal({visible:i,onClose:y,onBack:l,onMinimize:S,onSearchUsers:e,onClearReactQuery:c,onClearRedux:r,onClearAsyncStorage:s,onClearMMKV:a,showSettingsTab:t=true,inline:_=false}){const w=t?ALL_TABS:TABS_WITHOUT_SETTINGS;const[o,p]=(0,_react.useState)("search");const[d,u]=(0,_react.useState)(false);const ae=(0,_react.useRef)(false);const[h,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateModal=ImpersonateModal;exports.ImpersonateToolView=ImpersonateToolView;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _useImpersonate=require("../hooks/useImpersonate");var _useAutoClearReactQuery=require("../hooks/useAutoClearReactQuery");var _useAutoClearRedux=require("../hooks/useAutoClearRedux");var _useAutoClearAsyncStorage=require("../hooks/useAutoClearAsyncStorage");var _UserSearchView=require("./UserSearchView");var _ImpersonateHistoryList=require("./ImpersonateHistoryList");var _DataNukeSettings=require("./DataNukeSettings");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(i,y){if("function"==typeof WeakMap)var l=new WeakMap,S=new WeakMap;return(_interopRequireWildcard=function(e,c){if(!c&&e&&e.__esModule)return e;var r,s,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(r=c?S:l){if(r.has(e))return r.get(e);r.set(e,a)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((s=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(s.get||s.set)?r(a,t,s):a[t]=e[t]);return a})(i,y)}const JsModal=_sharedUi.JsModal;const ALL_TABS=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}];const TABS_WITHOUT_SETTINGS=[{key:"search",label:"Search"},{key:"history",label:"History"}];function ImpersonateModal({visible:i,onClose:y,onBack:l,onMinimize:S,onSearchUsers:e,onClearReactQuery:c,onClearRedux:r,onClearAsyncStorage:s,onClearMMKV:a,showSettingsTab:t=true,inline:_=false}){const w=t?ALL_TABS:TABS_WITHOUT_SETTINGS;const[o,p]=(0,_react.useState)("search");const[d,u]=(0,_react.useState)(false);const ae=(0,_react.useRef)(false);const[h,b]=(0,_react.useState)("");const g=(0,_react.useRef)(null);const{clearCache:H,isAvailable:T}=(0,_useAutoClearReactQuery.useAutoClearReactQuery)();const{resetStore:D,isAvailable:M}=(0,_useAutoClearRedux.useAutoClearRedux)();const{clearStorage:q,isAvailable:B}=(0,_useAutoClearAsyncStorage.useAutoClearAsyncStorage)();const P=c??H??void 0;const U=r??D??void 0;const Q=s??q??void 0;const N={reactQuery:!!c||T,redux:!!r||M,asyncStorage:!!s||B,mmkv:!!a};const{isActive:O,currentUser:m,headerKey:V,dataNukeSettings:W,showBanner:E,searchQuery:L,searchResults:z,isSearching:F,searchError:J,searchUsers:v,startImpersonation:x,stopImpersonation:C,updateHeaderKey:A,updateDataNukeSettings:k,updateShowBanner:f,history:K,removeFromHistory:G,clearHistory:X}=(0,_useImpersonate.useImpersonate)({onSearchUsers:e,onClearReactQuery:P,onClearRedux:U,onClearAsyncStorage:Q,onClearMMKV:a});(0,_react.useEffect)(()=>{if(d&&g.current){setTimeout(()=>{g.current?.focus()},100)}},[d]);(0,_react.useEffect)(()=>{if(!t&&o==="settings"){p("search")}},[t,o]);const Y=(0,_react.useCallback)(n=>{b(n)},[]);const Z=(0,_react.useCallback)(()=>{if(h.trim()){v(h.trim())}u(false)},[h,v]);const j=(0,_react.useCallback)(async n=>{await x(n)},[x]);const $=(0,_react.useCallback)(async(n,te,re)=>{await A(n);await k(te);await f(re)},[A,k,f]);const ee=(0,_react.useCallback)(n=>{p(n);u(false)},[]);const I=()=>{return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[l&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:l}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:d?(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Search,{value:h,onChangeText:Y,onCancel:()=>{b("");u(false)},onDismiss:()=>u(false),dismissOnBlur:true,placeholder:"Search by email, name, or ID...",iconSize:14,testID:"buoy-impersonate-search-input",inputProps:{onSubmitEditing:Z}}):(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:w,activeTab:o,onTabChange:ee,testIDPrefix:"buoy-impersonate-tab"})}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Actions,{children:o==="search"&&!d&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"buoy-impersonate-search-toggle",onPress:()=>u(true),style:styles.headerActionButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.night.color.textSecondary})})})]})};if(!i){return null}const R=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[o==="search"&&(0,_jsxRuntime.jsx)(_UserSearchView.UserSearchView,{currentUser:m,isActive:O,searchQuery:L,searchResults:z,isSearching:F,searchError:J,onSelectUser:j,onStopImpersonation:C,searchAvailable:!!e}),o==="history"&&(0,_jsxRuntime.jsx)(_ImpersonateHistoryList.ImpersonateHistoryList,{history:K,currentUserId:m?.id??null,onSelectUser:j,onStopImpersonation:C,onRemoveFromHistory:G,onClearHistory:X}),o==="settings"&&(0,_jsxRuntime.jsx)(_DataNukeSettings.DataNukeSettings,{headerKey:V,settings:W,showBanner:E,onSave:$,onShowBannerChange:f,detectionStatus:N})]});if(_){return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:I()}),R]})})}return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsx)(JsModal,{visible:i,onClose:y,onMinimize:S,header:{showToggleButton:true,customContent:I()},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:R})})}function ImpersonateToolView(i){return(0,_jsxRuntime.jsx)(ImpersonateModal,{...i,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.buoyColors.border,backgroundColor:"transparent"},container:{flex:1},headerActionButton:{width:28,height:28,borderRadius:6,backgroundColor:_sharedUi.night.color.buttonSurface,justifyContent:"center",alignItems:"center"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UserCard=UserCard;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserAvatar=require("./UserAvatar");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function UserCard({user:e,isActive:t=false,onPress:o,onStop:c,onRemove:r,showRemoveButton:s=false,lastUsedTime:a,variant:i="default"}){const n=e.displayName||e.email||e.id;const d=e.email&&e.displayName;const l=typeof e.metadata?.role==="string"?e.metadata.role:null;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`buoy-impersonate-user-${e.id}`,style:[styles.container,t&&styles.activeContainer,i==="compact"&&styles.compactContainer],onPress:o,disabled:t,activeOpacity:.7,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.avatarSection,children:(0,_jsxRuntime.jsx)(_UserAvatar.UserAvatar,{userId:e.id,name:n,size:i==="compact"?"small":"medium",showActiveIndicator:t})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.content,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.nameRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.name,t&&styles.activeName],numberOfLines:1,children:n}),l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.roleBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.roleBadgeText,children:l.toUpperCase()})}):null]}),d&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.email,numberOfLines:1,children:e.email}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.metadataRow,children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.userId,children:["ID: ",e.id]})})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actions,children:[t?(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:true,onToggle:c||(()=>{}),accessibilityLabel:"Stop impersonation"}):(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.actionButton,onPress:o,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.Play,{size:14,color:_sharedUi.night.color.onAccent})}),s&&r&&!t&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.removeButton,onPress:r,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:12,color:_sharedUi.night.color.textTertiary})})]}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.lastUsed,children:a}):null]})}const styles=_reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:12,gap:12},activeContainer:{backgroundColor:_sharedUi.buoyColors.success+"10",borderColor:_sharedUi.buoyColors.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:_sharedUi.night.color.text,flexShrink:1},activeName:{color:_sharedUi.buoyColors.success},roleBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:_sharedUi.night.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:_sharedUi.night.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:_sharedUi.night.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:_sharedUi.night.color.surfaceElevated,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UserCard=UserCard;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserAvatar=require("./UserAvatar");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function UserCard({user:e,isActive:t=false,onPress:o,onStop:c,onRemove:r,showRemoveButton:s=false,lastUsedTime:a,variant:i="default"}){const n=e.displayName||e.email||e.id;const d=e.email&&e.displayName;const l=typeof e.metadata?.role==="string"?e.metadata.role:null;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`buoy-impersonate-user-${e.id}`,style:[styles.container,t&&styles.activeContainer,i==="compact"&&styles.compactContainer],onPress:o,disabled:t,activeOpacity:.7,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.avatarSection,children:(0,_jsxRuntime.jsx)(_UserAvatar.UserAvatar,{userId:e.id,name:n,size:i==="compact"?"small":"medium",showActiveIndicator:t})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.content,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.nameRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.name,t&&styles.activeName],numberOfLines:1,children:n}),l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.roleBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.roleBadgeText,children:l.toUpperCase()})}):null]}),d&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.email,numberOfLines:1,children:e.email}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.metadataRow,children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.userId,children:["ID: ",e.id]})})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actions,children:[t?(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:true,onToggle:c||(()=>{}),accessibilityLabel:"Stop impersonation",testID:`buoy-impersonate-stop-${e.id}`}):(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`buoy-impersonate-start-${e.id}`,style:styles.actionButton,onPress:o,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.Play,{size:14,color:_sharedUi.night.color.onAccent})}),s&&r&&!t&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`buoy-impersonate-remove-${e.id}`,style:styles.removeButton,onPress:r,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:12,color:_sharedUi.night.color.textTertiary})})]}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.lastUsed,children:a}):null]})}const styles=_reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:12,gap:12},activeContainer:{backgroundColor:_sharedUi.buoyColors.success+"10",borderColor:_sharedUi.buoyColors.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:_sharedUi.night.color.text,flexShrink:1},activeName:{color:_sharedUi.buoyColors.success},roleBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:_sharedUi.night.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:_sharedUi.night.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:_sharedUi.night.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:_sharedUi.night.color.surfaceElevated,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UserSearchView=UserSearchView;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(c,a){if("function"==typeof WeakMap)var n=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,s){if(!s&&e&&e.__esModule)return e;var r,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(r=s?l:n){if(r.has(e))return r.get(e);r.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?r(o,t,i):o[t]=e[t]);return o})(c,a)}function UserSearchView({currentUser:c,searchQuery:a,searchResults:n,isSearching:l,searchError:e,onSelectUser:s,onStopImpersonation:r,searchAvailable:i=true}){const o=(0,_react.useCallback)(({item:t})=>{const d=c?.id===t.id;return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:t,isActive:d,onPress:()=>!d&&s(t),onStop:d?r:void 0})},[c,s,r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[!i&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:18,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Search Not Available"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),l&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.loadingContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.loadingText,children:"Searching users..."})]}),e?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.danger}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.errorText,children:e})]})}):null,n.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.resultsSection,children:[(0,_jsxRuntime.jsxs)(_sharedUi.SectionHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Title,{children:"Results"}),(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Badge,{count:n.length})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{data:n,keyExtractor:t=>t.id,renderItem:o,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]}),!!a&&!l&&n.length===0&&!e&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyStateContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.emptyStateIcon,children:(0,_jsxRuntime.jsx)(_sharedUi.Users,{size:28,color:_sharedUi.night.color.textTertiary})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateTitle,children:"No users found"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.emptyStateDescription,children:['No results for "',a,'"']}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateHint,children:"Try a different search term"})]}),!a&&n.length===0&&!l&&i&&(0,_jsxRuntime.jsx)(_sharedUi.EmptyState,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:_sharedUi.Search,variant:"minimal"})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:_sharedUi.night.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:_sharedUi.night.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:_sharedUi.night.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:_sharedUi.night.color.textTertiary}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UserSearchView=UserSearchView;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(c,a){if("function"==typeof WeakMap)var n=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,s){if(!s&&e&&e.__esModule)return e;var r,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(r=s?l:n){if(r.has(e))return r.get(e);r.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?r(o,t,i):o[t]=e[t]);return o})(c,a)}function UserSearchView({currentUser:c,searchQuery:a,searchResults:n,isSearching:l,searchError:e,onSelectUser:s,onStopImpersonation:r,searchAvailable:i=true}){const o=(0,_react.useCallback)(({item:t})=>{const d=c?.id===t.id;return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:t,isActive:d,onPress:()=>!d&&s(t),onStop:d?r:void 0})},[c,s,r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[!i&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:18,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.warningContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningTitle,children:"Search Not Available"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),l&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.loadingContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.ActivityIndicator,{size:"small",color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.loadingText,children:"Searching users..."})]}),e?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.section,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.errorCard,children:[(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:16,color:_sharedUi.night.color.danger}),(0,_jsxRuntime.jsx)(_reactNative.Text,{testID:"buoy-impersonate-error",style:styles.errorText,children:e})]})}):null,n.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.resultsSection,children:[(0,_jsxRuntime.jsxs)(_sharedUi.SectionHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Title,{children:"Results"}),(0,_jsxRuntime.jsx)(_sharedUi.SectionHeader.Badge,{count:n.length})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:"buoy-impersonate-search-scroll",data:n,keyExtractor:t=>t.id,renderItem:o,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]}),!!a&&!l&&n.length===0&&!e&&(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"buoy-impersonate-no-results",style:styles.emptyStateContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.emptyStateIcon,children:(0,_jsxRuntime.jsx)(_sharedUi.Users,{size:28,color:_sharedUi.night.color.textTertiary})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateTitle,children:"No users found"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.emptyStateDescription,children:['No results for "',a,'"']}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateHint,children:"Try a different search term"})]}),!a&&n.length===0&&!l&&i&&(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"buoy-impersonate-search-empty",children:(0,_jsxRuntime.jsx)(_sharedUi.EmptyState,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:_sharedUi.Search,variant:"minimal"})})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:_sharedUi.night.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.warning,marginBottom:4},warningText:{fontSize:13,color:_sharedUi.night.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:_sharedUi.night.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:_sharedUi.night.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:_sharedUi.night.color.textTertiary}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";import ae,{useState as k,useEffect as
|
|
1
|
+
"use strict";import ae,{useState as k,useEffect as D,useMemo as z}from"react";import{View as a,Text as c,TextInput as q,StyleSheet as K,ScrollView as X,TouchableOpacity as p}from"react-native";import{CollapsibleSection as m,buoyColors as f,night as o,Settings as Y,AlertTriangle as V,Info as G,Zap as Z,RefreshCw as J,Check as R,X as E,Copy as A,Eye as ee,copyToClipboard as te,ToggleRow as oe,monoFont as I}from"@buoy-gg/shared-ui";import{DataViewer as re}from"@buoy-gg/shared-ui/dataViewer";import{jsx as t,jsxs as n,Fragment as W}from"react/jsx-runtime";const x="x-impersonate-user-id";const H=true;const b={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function C({label:s,description:d,value:h,onChange:B,recommended:T,dangerous:u,detected:i,testID:g}){const r=n(W,{children:[i!==void 0&&n(a,{style:[e.detectedBadge,i?e.detectedBadgeActive:e.detectedBadgeInactive],children:[i?t(R,{size:10,color:f.success}):t(E,{size:10,color:o.color.textTertiary}),t(c,{style:[e.detectedText,i?e.detectedTextActive:e.detectedTextInactive],children:i?"Detected":"Not Detected"})]}),T&&i!==false&&n(a,{style:e.recommendedBadge,children:[t(Z,{size:10,color:o.color.accent}),t(c,{style:e.recommendedText,children:"Recommended"})]})]});return t(oe,{variant:"plain",label:s,description:d,value:h,onValueChange:B,tone:u?"warning":"accent",emphasizeLabel:u,accessory:r,testID:g})}export function DataNukeSettings({headerKey:s,settings:d,showBanner:h,onSave:B,onShowBannerChange:T,detectionStatus:u}){const[i,g]=k(s);const[r,S]=k(d);const[y,v]=k(h);const[F,L]=k(false);D(()=>{g(s)},[s]);D(()=>{S(d)},[d]);D(()=>{v(h)},[h]);const Q=z(()=>{return i!==s||r.reactQuery!==d.reactQuery||r.redux!==d.redux||r.asyncStorage!==d.asyncStorage||r.mmkv!==d.mmkv},[i,r,s,d]);const _=z(()=>{return i===x&&y===H&&r.reactQuery===b.reactQuery&&r.redux===b.redux&&r.asyncStorage===b.asyncStorage&&r.mmkv===b.mmkv},[i,y,r]);const j=()=>{B(i.trim()||x,r,y)};const N=()=>{g(s);S(d);v(h)};const O=()=>{g(x);S(b);v(H);T(H)};const w=(l,$)=>{S(U=>({...U,[l]:$}))};const M=z(()=>({defaults:{headerKey:i,showBanner:y,dataNukeSettings:{reactQuery:r.reactQuery,redux:r.redux,asyncStorage:r.asyncStorage,mmkv:r.mmkv}}}),[i,y,r]);const P=async()=>{const l=`defaults: {
|
|
2
2
|
headerKey: '${i}',
|
|
3
3
|
showBanner: ${y},
|
|
4
4
|
dataNukeSettings: {
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
asyncStorage: ${r.asyncStorage},
|
|
8
8
|
mmkv: ${r.mmkv},
|
|
9
9
|
},
|
|
10
|
-
},`;try{await te(l);L(true);setTimeout(()=>L(false),2e3)}catch{}};return n(X,{style:e.container,contentContainerStyle:e.contentContainer,children:[Q&&t(a,{style:e.actionBar,children:n(a,{style:e.actionBarContent,children:[t(c,{style:e.unsavedText,children:"Unsaved changes"}),n(a,{style:e.actionButtons,children:[n(p,{style:e.discardButton,onPress:N,children:[t(E,{size:14,color:o.color.textSecondary}),t(c,{style:e.discardButtonText,children:"Discard"})]}),n(p,{style:e.saveButton,onPress:j,children:[t(R,{size:14,color:o.color.onAccent}),t(c,{style:e.saveButtonText,children:"Save"})]})]})]})}),t(
|
|
10
|
+
},`;try{await te(l);L(true);setTimeout(()=>L(false),2e3)}catch{}};return n(X,{testID:"buoy-impersonate-settings-scroll",style:e.container,contentContainerStyle:e.contentContainer,children:[Q&&t(a,{style:e.actionBar,children:n(a,{style:e.actionBarContent,children:[t(c,{style:e.unsavedText,children:"Unsaved changes"}),n(a,{style:e.actionButtons,children:[n(p,{testID:"buoy-impersonate-discard",style:e.discardButton,onPress:N,children:[t(E,{size:14,color:o.color.textSecondary}),t(c,{style:e.discardButtonText,children:"Discard"})]}),n(p,{testID:"buoy-impersonate-save",style:e.saveButton,onPress:j,children:[t(R,{size:14,color:o.color.onAccent}),t(c,{style:e.saveButtonText,children:"Save"})]})]})]})}),t(m,{title:"Header Configuration",icon:Y,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.inputLabel,children:"Header Key"}),t(q,{testID:"buoy-impersonate-header-key",style:e.input,value:i,onChangeText:g,placeholder:"x-impersonate-user-id",placeholderTextColor:o.color.placeholder,autoCapitalize:"none",autoCorrect:false}),n(a,{style:e.inputFooter,children:[t(c,{style:e.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),i!==x&&t(p,{onPress:()=>g(x),style:e.resetLink,children:t(c,{style:e.resetLinkText,children:"Reset to default"})})]})]})}),t(m,{title:"Display",icon:ee,defaultOpen:true,variant:"bordered",children:t(a,{style:e.sectionContent,children:t(a,{style:e.togglesCard,children:t(C,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:y,onChange:l=>{v(l);T(l)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),t(m,{title:"Data Clearing",icon:V,defaultOpen:true,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),n(a,{style:e.togglesCard,children:[t(C,{label:"React Query",description:"Clear query cache and cancel pending queries",value:r.reactQuery,onChange:l=>w("reactQuery",l),recommended:true,detected:u?.reactQuery}),t(a,{style:e.divider}),t(C,{label:"Redux",description:"Reset Redux store to initial state",value:r.redux,onChange:l=>w("redux",l),recommended:true,detected:u?.redux})]}),n(a,{style:e.advancedSection,children:[t(c,{style:e.advancedLabel,children:"Storage Options"}),n(a,{style:[e.togglesCard,e.dangerousCard],children:[t(C,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:r.asyncStorage,onChange:l=>w("asyncStorage",l),dangerous:true,detected:u?.asyncStorage}),t(a,{style:e.divider}),t(C,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:r.mmkv,onChange:l=>w("mmkv",l),dangerous:true,detected:u?.mmkv})]})]}),(r.asyncStorage||r.mmkv)&&n(a,{style:e.warningCard,children:[t(V,{size:16,color:o.color.warning}),n(a,{style:e.warningContent,children:[t(c,{style:e.warningTitle,children:"Storage Clearing Enabled"}),t(c,{style:e.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!_&&n(p,{testID:"buoy-impersonate-restore-defaults",style:e.restoreButton,onPress:O,children:[t(J,{size:14,color:o.color.textSecondary}),t(c,{style:e.restoreButtonText,children:"Restore Defaults"})]}),t(m,{title:"How It Works",icon:G,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),t(c,{style:[e.infoText,e.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),n(a,{style:e.codeBlock,children:[t(c,{style:e.codeComment,children:"// Example request header"}),n(c,{style:e.codeText,children:[i||"x-impersonate-user-id",": ",t(c,{style:e.codeValue,children:"user_123"})]})]})]})}),t(m,{title:"Export Configuration",icon:A,defaultOpen:false,variant:"bordered",children:n(a,{style:e.sectionContent,children:[t(c,{style:e.infoText,children:"Copy current settings to use in createImpersonateTool()."}),t(a,{style:e.dataViewerContainer,children:t(re,{title:"",data:M,showTypeFilter:true,rawMode:true,initialExpanded:true})}),t(p,{style:e.copyButton,onPress:P,children:F?n(W,{children:[t(R,{size:14,color:f.success}),t(c,{style:[e.copyButtonText,e.copySuccessText],children:"Copied!"})]}):n(W,{children:[t(A,{size:14,color:o.color.accent}),t(c,{style:e.copyButtonText,children:"Copy Config"})]})})]})})]})}const e=K.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:o.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:o.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:o.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:o.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:o.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:o.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:o.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:o.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:o.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:o.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:o.color.surface,borderRadius:10,borderWidth:1,borderColor:o.color.border,padding:4},dangerousCard:{borderColor:o.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:o.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:o.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:o.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:o.color.border,paddingHorizontal:14,fontSize:14,color:o.color.text,fontFamily:I},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:o.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:o.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:o.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:o.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:f.success+"15"},detectedBadgeInactive:{backgroundColor:o.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:f.success},detectedTextInactive:{color:o.color.textTertiary},divider:{height:1,backgroundColor:o.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:o.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:o.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:o.color.warning,marginBottom:4},warningText:{fontSize:12,color:o.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:o.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:o.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:o.color.textTertiary,fontFamily:I,marginBottom:6},codeText:{fontSize:13,color:o.color.text,fontFamily:I},codeValue:{color:o.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:o.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:o.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:o.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:o.color.accent},copySuccessText:{color:f.success}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import P,{useSyncExternalStore as
|
|
1
|
+
"use strict";import P,{useSyncExternalStore as p}from"react";import{View as a,Text as m,TouchableOpacity as l,StyleSheet as f}from"react-native";import{buoyColors as r,X as w,PowerToggleButton as I}from"@buoy-gg/shared-ui";import{impersonateStore as t}from"../utils/impersonateStore";import{UserAvatar as S}from"./UserAvatar";import{jsx as s,jsxs as c}from"react/jsx-runtime";export function ImpersonateBanner({onPress:n,onStopPress:i,position:g="top",offset:d=50}){const e=p(t.subscribe,t.getSnapshot,t.getSnapshot);if(!e.isActive||!e.currentUser||!e.showBanner){return null}const h=async()=>{console.log("[Buoy]","[impersonate] banner pause/resume pressed");if(e.isPaused){await t.resumeImpersonation()}else{await t.pauseImpersonation()}};const u=e.currentUser.displayName||e.currentUser.email||e.currentUser.id;const b=g==="top"?{top:d}:{bottom:d};const y=async()=>{console.log("[Buoy]","[impersonate] banner STOP pressed");await t.stopImpersonation()};return s(a,{style:[o.container,b],children:c(a,{testID:"buoy-impersonate-banner",style:o.banner,children:[c(l,{testID:"buoy-impersonate-banner-open",style:o.userSection,onPress:n,activeOpacity:.7,children:[s(S,{userId:e.currentUser.id,name:u,size:"small",showActiveIndicator:false}),s(m,{style:[o.userName,e.isPaused&&o.userNamePaused],numberOfLines:1,children:u})]}),s(I,{isEnabled:!e.isPaused,onToggle:h,size:"small",accessibilityLabel:"Toggle impersonation",testID:"buoy-impersonate-banner-toggle"}),s(l,{testID:"buoy-impersonate-banner-stop",accessibilityLabel:"Stop impersonating",style:o.closeButton,onPress:y,activeOpacity:.7,children:s(w,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]})})}export function ImpersonateBannerMinimal({onPress:n}){const i=p(t.subscribe,t.getSnapshot,t.getSnapshot);if(!i.isActive||!i.currentUser){return null}return c(l,{style:o.minimalBanner,onPress:n,activeOpacity:.8,children:[s(a,{style:o.minimalDot}),s(m,{style:o.minimalText,children:"IMP"})]})}const o=f.create({container:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999,pointerEvents:"box-none"},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:r.success+"40",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},userSection:{flexDirection:"row",alignItems:"center",gap:10},userName:{fontSize:14,fontWeight:"600",color:"#fff",maxWidth:180},userNamePaused:{opacity:.6},closeButton:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},minimalBanner:{position:"absolute",top:60,right:16,flexDirection:"row",alignItems:"center",backgroundColor:"rgba(26, 26, 26, 0.92)",borderWidth:1,borderColor:r.success+"35",borderRadius:12,paddingVertical:5,paddingHorizontal:10,gap:5,zIndex:9999,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.2,shadowRadius:6,elevation:4},minimalDot:{width:6,height:6,borderRadius:3,backgroundColor:r.success},minimalText:{fontSize:10,fontWeight:"700",color:r.success,letterSpacing:.5}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import
|
|
1
|
+
"use strict";import B,{useCallback as m}from"react";import{View as s,Text as p,TouchableOpacity as y,StyleSheet as f,FlatList as x}from"react-native";import{night as r,Trash2 as T,useRelativeTime as S,ToolEmptyState as C}from"@buoy-gg/shared-ui";import{UserCard as I}from"./UserCard";import{jsx as e,jsxs as h}from"react/jsx-runtime";function b({item:o,isActive:a,onSelect:l,onStop:c,onRemove:n,showRemoveButton:d}){const u=S(new Date(o.lastUsedAt));return e(I,{user:o.user,isActive:a,onPress:()=>!a&&l(o.user),onStop:a?c:void 0,onRemove:n,showRemoveButton:d,lastUsedTime:u})}export function ImpersonateHistoryList({history:o,currentUserId:a,onSelectUser:l,onStopImpersonation:c,onRemoveFromHistory:n,onClearHistory:d}){const u=m(({item:i})=>{const g=a===i.user.id;return e(b,{item:i,isActive:g,onSelect:l,onStop:c,onRemove:n?()=>n(i.user.id):void 0,showRemoveButton:!!n})},[a,l,c,n]);if(o.length===0){return e(C,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"})}return h(s,{style:t.container,children:[h(s,{style:t.headerRow,children:[e(p,{style:t.headerTitle,children:"Recent"}),e(s,{style:t.headerBadge,children:e(p,{style:t.headerBadgeText,children:o.length})}),e(s,{style:t.headerSpacer}),d&&e(y,{testID:"buoy-impersonate-clear-history",style:t.clearButton,onPress:d,activeOpacity:.7,children:e(T,{size:12,color:r.color.textTertiary})})]}),e(x,{testID:"buoy-impersonate-history-scroll",data:o,keyExtractor:i=>i.user.id,renderItem:u,ItemSeparatorComponent:()=>e(s,{style:t.separator}),contentContainerStyle:t.listContent,showsVerticalScrollIndicator:false})]})}const t=f.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:r.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:r.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:r.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:r.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:r.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:r.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:r.color.textSecondary,textAlign:"center"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import
|
|
1
|
+
"use strict";import Pe,{useState as h,useCallback as a,useRef as P,useEffect as Q}from"react";import{View as m,StyleSheet as ye,TouchableOpacity as Se}from"react-native";import{JsModal as fe,TabSelector as pe,ModalHeader as s,buoyColors as be,night as N,Search as ge,TickProvider as j,windowDragProps as Ce}from"@buoy-gg/shared-ui";import{useImpersonate as ve}from"../hooks/useImpersonate";import{useAutoClearReactQuery as Ae}from"../hooks/useAutoClearReactQuery";import{useAutoClearRedux as xe}from"../hooks/useAutoClearRedux";import{useAutoClearAsyncStorage as Te}from"../hooks/useAutoClearAsyncStorage";import{UserSearchView as Ie}from"./UserSearchView";import{ImpersonateHistoryList as Re}from"./ImpersonateHistoryList";import{DataNukeSettings as ke}from"./DataNukeSettings";import{jsx as e,jsxs as y}from"react/jsx-runtime";const He=fe;const we=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}];const Be=[{key:"search",label:"Search"},{key:"history",label:"History"}];export function ImpersonateModal({visible:n,onClose:E,onBack:S,onMinimize:M,onSearchUsers:f,onClearReactQuery:p,onClearRedux:b,onClearAsyncStorage:g,onClearMMKV:C,showSettingsTab:u=true,inline:_=false}){const z=u?we:Be;const[t,v]=h("search");const[i,o]=h(false);const De=P(false);const[c,A]=h("");const x=P(null);const{clearCache:J,isAvailable:L}=Ae();const{resetStore:O,isAvailable:V}=xe();const{clearStorage:W,isAvailable:F}=Te();const K=p??J??void 0;const G=b??O??void 0;const q=g??W??void 0;const X={reactQuery:!!p||L,redux:!!b||V,asyncStorage:!!g||F,mmkv:!!C};const{isActive:Y,currentUser:T,headerKey:Z,dataNukeSettings:$,showBanner:ee,searchQuery:te,searchResults:re,isSearching:oe,searchError:ae,searchUsers:I,startImpersonation:R,stopImpersonation:k,updateHeaderKey:H,updateDataNukeSettings:w,updateShowBanner:d,history:se,removeFromHistory:ne,clearHistory:ie}=ve({onSearchUsers:f,onClearReactQuery:K,onClearRedux:G,onClearAsyncStorage:q,onClearMMKV:C});Q(()=>{if(i&&x.current){setTimeout(()=>{x.current?.focus()},100)}},[i]);Q(()=>{if(!u&&t==="settings"){v("search")}},[u,t]);const ce=a(r=>{A(r)},[]);const le=a(()=>{if(c.trim()){I(c.trim())}o(false)},[c,I]);const B=a(async r=>{await R(r)},[R]);const ue=a(async(r,he,me)=>{await H(r);await w(he);await d(me)},[H,w,d]);const de=a(r=>{v(r);o(false)},[]);const D=()=>{return y(s,{children:[S&&e(s.Navigation,{onBack:S}),e(s.Content,{title:"",children:i?e(s.Search,{value:c,onChangeText:ce,onCancel:()=>{A("");o(false)},onDismiss:()=>o(false),dismissOnBlur:true,placeholder:"Search by email, name, or ID...",iconSize:14,testID:"buoy-impersonate-search-input",inputProps:{onSubmitEditing:le}}):e(pe,{tabs:z,activeTab:t,onTabChange:de,testIDPrefix:"buoy-impersonate-tab"})}),e(s.Actions,{children:t==="search"&&!i&&e(Se,{testID:"buoy-impersonate-search-toggle",onPress:()=>o(true),style:l.headerActionButton,children:e(ge,{size:14,color:N.color.textSecondary})})})]})};if(!n){return null}const U=y(m,{style:l.container,children:[t==="search"&&e(Ie,{currentUser:T,isActive:Y,searchQuery:te,searchResults:re,isSearching:oe,searchError:ae,onSelectUser:B,onStopImpersonation:k,searchAvailable:!!f}),t==="history"&&e(Re,{history:se,currentUserId:T?.id??null,onSelectUser:B,onStopImpersonation:k,onRemoveFromHistory:ne,onClearHistory:ie}),t==="settings"&&e(ke,{headerKey:Z,settings:$,showBanner:ee,onSave:ue,onShowBannerChange:d,detectionStatus:X})]});if(_){return e(j,{children:y(m,{style:l.inlineRoot,children:[e(m,{style:l.inlineHeader,...Ce,children:D()}),U]})})}return e(j,{children:e(He,{visible:n,onClose:E,onMinimize:M,header:{showToggleButton:true,customContent:D()},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:U})})}export function ImpersonateToolView(n){return e(ImpersonateModal,{...n,inline:true,visible:true,onClose:()=>{}})}const l=ye.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:be.border,backgroundColor:"transparent"},container:{flex:1},headerActionButton:{width:28,height:28,borderRadius:6,backgroundColor:N.color.buttonSurface,justifyContent:"center",alignItems:"center"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import
|
|
1
|
+
"use strict";import z from"react";import{View as i,Text as n,TouchableOpacity as c,StyleSheet as x}from"react-native";import{buoyColors as s,night as t,Play as C,X as I,PowerToggleButton as S,monoFont as w}from"@buoy-gg/shared-ui";import{UserAvatar as B}from"./UserAvatar";import{jsx as r,jsxs as l}from"react/jsx-runtime";export function UserCard({user:o,isActive:a=false,onPress:d,onStop:f,onRemove:m,showRemoveButton:u=false,lastUsedTime:y,variant:g="default"}){const p=o.displayName||o.email||o.id;const b=o.email&&o.displayName;const h=typeof o.metadata?.role==="string"?o.metadata.role:null;return l(c,{testID:`buoy-impersonate-user-${o.id}`,style:[e.container,a&&e.activeContainer,g==="compact"&&e.compactContainer],onPress:d,disabled:a,activeOpacity:.7,children:[r(i,{style:e.avatarSection,children:r(B,{userId:o.id,name:p,size:g==="compact"?"small":"medium",showActiveIndicator:a})}),l(i,{style:e.content,children:[l(i,{style:e.nameRow,children:[r(n,{style:[e.name,a&&e.activeName],numberOfLines:1,children:p}),h?r(i,{style:e.roleBadge,children:r(n,{style:e.roleBadgeText,children:h.toUpperCase()})}):null]}),b&&r(n,{style:e.email,numberOfLines:1,children:o.email}),r(i,{style:e.metadataRow,children:l(n,{style:e.userId,children:["ID: ",o.id]})})]}),l(i,{style:e.actions,children:[a?r(S,{isEnabled:true,onToggle:f||(()=>{}),accessibilityLabel:"Stop impersonation",testID:`buoy-impersonate-stop-${o.id}`}):r(c,{testID:`buoy-impersonate-start-${o.id}`,style:e.actionButton,onPress:d,activeOpacity:.7,children:r(C,{size:14,color:t.color.onAccent})}),u&&m&&!a&&r(c,{testID:`buoy-impersonate-remove-${o.id}`,style:e.removeButton,onPress:m,activeOpacity:.7,children:r(I,{size:12,color:t.color.textTertiary})})]}),y?r(n,{style:e.lastUsed,children:y}):null]})}const e=x.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:t.color.surface,borderRadius:10,borderWidth:1,borderColor:t.color.border,padding:12,gap:12},activeContainer:{backgroundColor:s.success+"10",borderColor:s.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:t.color.text,flexShrink:1},activeName:{color:s.success},roleBadge:{backgroundColor:t.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:t.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:t.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:t.color.textTertiary,fontFamily:w},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:t.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:t.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:t.color.surfaceElevated,borderWidth:1,borderColor:t.color.border,alignItems:"center",justifyContent:"center"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import
|
|
1
|
+
"use strict";import B,{useCallback as x}from"react";import{View as o,Text as i,StyleSheet as C,FlatList as w,ActivityIndicator as b}from"react-native";import{SectionHeader as m,EmptyState as T,night as r,Search as I,AlertTriangle as S,Users as z}from"@buoy-gg/shared-ui";import{UserCard as D}from"./UserCard";import{jsx as e,jsxs as n}from"react/jsx-runtime";export function UserSearchView({currentUser:y,searchQuery:c,searchResults:l,isSearching:s,searchError:d,onSelectUser:h,onStopImpersonation:p,searchAvailable:f=true}){const u=x(({item:a})=>{const g=y?.id===a.id;return e(D,{user:a,isActive:g,onPress:()=>!g&&h(a),onStop:g?p:void 0})},[y,h,p]);return n(o,{style:t.container,children:[!f&&e(o,{style:t.section,children:n(o,{style:t.warningCard,children:[e(S,{size:18,color:r.color.warning}),n(o,{style:t.warningContent,children:[e(i,{style:t.warningTitle,children:"Search Not Available"}),e(i,{style:t.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),s&&n(o,{style:t.loadingContainer,children:[e(b,{size:"small",color:r.color.accent}),e(i,{style:t.loadingText,children:"Searching users..."})]}),d?e(o,{style:t.section,children:n(o,{style:t.errorCard,children:[e(S,{size:16,color:r.color.danger}),e(i,{testID:"buoy-impersonate-error",style:t.errorText,children:d})]})}):null,l.length>0&&n(o,{style:t.resultsSection,children:[n(m,{children:[e(m.Title,{children:"Results"}),e(m.Badge,{count:l.length})]}),e(w,{testID:"buoy-impersonate-search-scroll",data:l,keyExtractor:a=>a.id,renderItem:u,ItemSeparatorComponent:()=>e(o,{style:t.separator}),contentContainerStyle:t.listContent,showsVerticalScrollIndicator:false})]}),!!c&&!s&&l.length===0&&!d&&n(o,{testID:"buoy-impersonate-no-results",style:t.emptyStateContainer,children:[e(o,{style:t.emptyStateIcon,children:e(z,{size:28,color:r.color.textTertiary})}),e(i,{style:t.emptyStateTitle,children:"No users found"}),n(i,{style:t.emptyStateDescription,children:['No results for "',c,'"']}),e(i,{style:t.emptyStateHint,children:"Try a different search term"})]}),!c&&l.length===0&&!s&&f&&e(o,{testID:"buoy-impersonate-search-empty",children:e(T,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:I,variant:"minimal"})})]})}const t=C.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:r.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:r.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:r.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:r.color.warning,marginBottom:4},warningText:{fontSize:13,color:r.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:r.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:r.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:r.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:r.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:r.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:r.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:r.color.textTertiary}});
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";var ot=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var yr=Object.prototype.hasOwnProperty;var fr=(e,t)=>{for(var r in t)ot(e,r,{get:t[r],enumerable:true})},nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mr(t))!yr.call(e,o)&&o!==r&&ot(e,o,{get:()=>t[o],enumerable:!(n=pr(t,o))||n.enumerable});return e},br=(e,t,r)=>(nt(e,t,"default"),r&&nt(r,t,"default"));var oa=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import at from"@buoy-gg/shared-ui/web/asyncStorage";import{getCapacitorAppStorage as Sr}from"@buoy-gg/shared-ui/web";function vr(){return at}function wr(){return Sr()??at}import{useState as xe,useCallback as te,useRef as st,useEffect as it}from"react";var lt={};fr(lt,{AccessibilityInfo:()=>kr,ActivityIndicator:()=>mt,Alert:()=>Bo,Animated:()=>Tr,AppRegistry:()=>Rr,AppState:()=>Ar,Appearance:()=>Br,BackHandler:()=>Hr,Button:()=>ko,CheckBox:()=>Xr,Clipboard:()=>Pr,DeviceEventEmitter:()=>io,Dimensions:()=>zr,Easing:()=>Er,FlatList:()=>Ie,I18nManager:()=>Lr,Image:()=>Qr,ImageBackground:()=>qr,InteractionManager:()=>Nr,Keyboard:()=>Dr,KeyboardAvoidingView:()=>_r,LayoutAnimation:()=>Ur,Linking:()=>Or,LogBox:()=>so,Modal:()=>xo,NativeEventEmitter:()=>Kr,NativeModules:()=>Ir,PanResponder:()=>Wr,Picker:()=>Jr,PixelRatio:()=>Fr,Platform:()=>Mr,Pressable:()=>Co,ProgressBar:()=>Yr,RefreshControl:()=>Gr,SafeAreaView:()=>Zr,ScrollView:()=>gt,SectionList:()=>eo,Share:()=>jr,StatusBar:()=>to,StyleSheet:()=>F,Switch:()=>Io,Text:()=>y,TextInput:()=>ht,Touchable:()=>ro,TouchableHighlight:()=>vo,TouchableNativeFeedback:()=>oo,TouchableOpacity:()=>H,TouchableWithoutFeedback:()=>wo,UIManager:()=>Vr,Vibration:()=>$r,View:()=>d,VirtualizedList:()=>no,YellowBox:()=>ao,findNodeHandle:()=>To,unstable_createElement:()=>xr,useColorScheme:()=>lo,useLocaleContext:()=>co,useWindowDimensions:()=>uo});br(lt,Cr);import*as Cr from"react-native-web";import{unstable_createElement as xr,NativeModules as Ir,AccessibilityInfo as kr,Animated as Tr,Appearance as Br,AppRegistry as Rr,AppState as Ar,BackHandler as Hr,Clipboard as Pr,Dimensions as zr,Easing as Er,I18nManager as Lr,Keyboard as Dr,InteractionManager as Nr,LayoutAnimation as Ur,Linking as Or,NativeEventEmitter as Kr,PanResponder as Wr,PixelRatio as Fr,Platform as Mr,Share as jr,StyleSheet as F,UIManager as Vr,Vibration as $r,CheckBox as Xr,FlatList as Ie,Image as Qr,ImageBackground as qr,KeyboardAvoidingView as _r,Picker as Jr,ProgressBar as Yr,RefreshControl as Gr,SafeAreaView as Zr,SectionList as eo,StatusBar as to,Touchable as ro,TouchableNativeFeedback as oo,VirtualizedList as no,YellowBox as ao,LogBox as so,DeviceEventEmitter as io,useColorScheme as lo,useLocaleContext as co,useWindowDimensions as uo}from"react-native-web";import*as z from"react-native-web";import{createElement as ke,forwardRef as ct,useCallback as ho,useRef as go}from"react";import{useEffect as po,useState as mo}from"react";import{createPortal as yo}from"react-dom";var fo='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as bo}from"react/jsx-runtime";var re=Symbol.for("@buoy-gg/portal-host"),dt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function ut(){let e=document;if(e[re])return e[re].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:fo});let r=()=>{let s=document.fullscreenElement,b=s&&s.tagName!=="CANVAS"?s:document.body;t.parentElement!==b&&b.appendChild(t)},n=new Map,o=s=>{(!t.contains(s.target)||!dt(s.target))&&n.set(s.code||s.key,{key:s.key,code:s.code,location:s.location,keyCode:s.keyCode,which:s.which,altKey:s.altKey,ctrlKey:s.ctrlKey,metaKey:s.metaKey,shiftKey:s.shiftKey})},i=s=>{n.delete(s.code||s.key)},l=()=>n.clear(),h=()=>{let s=[...n.values()];n.clear();for(let b of s)document.dispatchEvent(new KeyboardEvent("keyup",{...b,bubbles:true}))},a=s=>{dt(s.target)&&s.stopPropagation()},c=s=>s.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",l),t.addEventListener("focusin",h),t.addEventListener("keydown",a),t.addEventListener("keyup",a),t.addEventListener("keypress",a),t.addEventListener("wheel",c,{passive:true}),e[re]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",l),t.remove(),delete e[re]}},t}function So({children:e}){let[t,r]=mo(null);return po(()=>{let n=ut(),o=document[re];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?yo(bo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function D(e){let t=ct((n,o)=>{let{accessibilityState:i,accessibilityValue:l,...h}=n;for(let a of["busy","checked","disabled","expanded","selected"])i?.[a]!==void 0&&h[`aria-${a}`]===void 0&&(h[`aria-${a}`]=i[a]);for(let[a,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[a]!==void 0&&h[`aria-${c}`]===void 0&&(h[`aria-${c}`]=l[a]);return ke(e,{...h,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var d=D(z.View),y=D(z.Text),ht=D(z.TextInput),H=D(z.TouchableOpacity),vo=D(z.TouchableHighlight),wo=D(z.TouchableWithoutFeedback),Co=D(z.Pressable),gt=D(z.ScrollView),pt=ct((e,t)=>{let r=go(null),n=ho(o=>{if(o){let i=o;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(r.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),ut().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return ke(So,null,ke(z.Modal,{...e,ref:n}))});pt.displayName="Modal";var xo=D(pt),Io=D(z.Switch),mt=D(z.ActivityIndicator),ko=D(z.Button),To=z.findNodeHandle,Bo={alert(e,t,r,n){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(c)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let h=r?.length?r:[{text:"OK"}],a=()=>{o.close?.(),o.remove()};for(let c of h){let s=document.createElement("button");s.type="button",s.textContent=c.text??"OK",s.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,s.onclick=()=>{a(),c.onPress?.()},l.appendChild(s)}o.addEventListener("cancel",c=>{c.preventDefault(),n?.cancelable!==false&&(a(),n?.onDismiss?.())}),o.appendChild(l),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{JsModal as Ro,TabSelector as Ao,ModalHeader as oe,buoyColors as Ho,night as yt,Search as Po,TickProvider as ft,windowDragProps as zo}from"@buoy-gg/shared-ui/web";import{useState as me,useEffect as bt,useCallback as N,useSyncExternalStore as Eo}from"react";import{assertAccountAccess as St,getAccountAccess as Lo,hasAccountAccess as Do,subscribeAccountAccess as No}from"@buoy-gg/shared-ui/web";var vt=[/\/symbolicate$/,/\/logs$/,/\/debugger-proxy/,/\/reload$/,/\/launch-js-devtools/,/localhost:8081/,/100\.64\.\d+\.\d+:8081/,/10\.0\.\d+\.\d+:8081/,/\.hot-update\./,/__metro/];function Te(e,t){for(let r of Object.keys(t))r.startsWith("__buoy")&&(e[r]=t[r])}var Uo=class{constructor(){this.isListeningFlag=false;this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.reportHeader=e=>this.shouldInjectHeader(e)?{[this.config.headerKey]:this.config.userId}:null;this.originalFetch=globalThis.fetch.bind(globalThis),this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send,this.config={headerKey:"x-impersonate-user-id",userId:null,ignorePatterns:[...vt]}}setConfig(e){this.config={...this.config,...e},e.ignorePatterns&&(this.config.ignorePatterns=[...vt,...e.ignorePatterns])}getConfig(){return{...this.config}}shouldInjectHeader(e){return!this.config.userId||this.config.gate&&!this.config.gate()?false:!this.config.ignorePatterns.some(t=>t.test(e))}extractUrl(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}startListening(){if(this.isListeningFlag)return;let e=globalThis.fetch,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send;this.originalFetch=e.bind(globalThis),this.originalXHROpen=t,this.originalXHRSend=r;let n=this,o=async function(c,s){let b=n.extractUrl(c);if(n.shouldInjectHeader(b)){let C=s?.headers??(typeof c=="object"&&"headers"in c?c.headers:void 0),f=new Headers(C);return f.set(n.config.headerKey,n.config.userId),n.originalFetch(c,{...s,headers:f})}return n.originalFetch(c,s)};Te(o,e),this.patchedFetch=o,globalThis.fetch=this.patchedFetch;let i=function(c,s,b=true,C,f){let x=this;x._impersonateUrl=typeof s=="string"?s:s.href;let I=typeof s=="string"?s:s.toString();return n.originalXHROpen.call(this,c,I,b,C,f)},l=function(c){let s=this;return s._impersonateUrl&&n.shouldInjectHeader(s._impersonateUrl)&&this.setRequestHeader(n.config.headerKey,n.config.userId),n.originalXHRSend.call(this,c)};Te(i,t),Te(l,r),this.patchedXHROpen=i,this.patchedXHRSend=l,XMLHttpRequest.prototype.open=this.patchedXHROpen,XMLHttpRequest.prototype.send=this.patchedXHRSend;let h=globalThis,a=h.__buoyHeaderInjectors??(h.__buoyHeaderInjectors=[]);a.includes(this.reportHeader)||a.push(this.reportHeader),this.isListeningFlag=true}stopListening(){if(!this.isListeningFlag)return;this.patchedFetch&&globalThis.fetch===this.patchedFetch&&(globalThis.fetch=this.originalFetch),this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend),this.patchedFetch=null,this.patchedXHROpen=null,this.patchedXHRSend=null;let e=globalThis.__buoyHeaderInjectors,t=e?.indexOf(this.reportHeader)??-1;e&&t>=0&&e.splice(t,1),this.isListeningFlag=false}get isListening(){return this.isListeningFlag}get isImpersonating(){return this.config.userId!==null&&(this.config.gate?.()??true)}},ne=null;function O(){return ne||(ne=new Uo),ne}function Oo(){O().startListening()}function Ko(){O().stopListening()}function wt(e){O().setConfig(e)}function Wo(){return ne?.isImpersonating??false}function Fo(){return ne?.getConfig().userId??null}var ae="@buoy/impersonate/state",Mo=10,Ct={reactQuery:true,redux:true,asyncStorage:false,mmkv:false},Z={isActive:false,isPaused:false,currentUser:null,headerKey:"x-impersonate-user-id",ignorePatterns:[],dataNukeSettings:Ct,showBanner:true,history:[]},Be=false,xt={getItem:e=>{try{return typeof localStorage<"u"?localStorage.getItem(e):null}catch{return null}},setItem:(e,t)=>{try{typeof localStorage<"u"&&localStorage.setItem(e,t)}catch{}},removeItem:e=>{try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}}},jo=class{constructor(){this.state={...Z};this.listeners=new Set;this.nukeCallbacks={};this.isInitialized=false;this.asyncStorageRef=null;this.storageReadyPromise=null;this.resolveStorageReady=null;this.developerDefaults=null;this.getSnapshot=()=>this.state;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));this.remoteHandler=null;this.loadFromStorage(),Promise.resolve().then(()=>{let e=false,t=()=>{let r=Lo().status;r==="admitted"?e=true:r==="locked"&&e&&(e=false,this.disposeAccountSession())};No(t),t()}),typeof localStorage<"u"?this.storageReadyPromise=Promise.resolve():this.storageReadyPromise=new Promise(e=>{this.resolveStorageReady=e})}loadFromStorage(){try{let e=xt.getItem(ae),t=this.getEffectiveDefaults();if(e){let r=JSON.parse(e);this.state={...Z,headerKey:r.headerKey??t.headerKey,ignorePatterns:r.ignorePatterns??Z.ignorePatterns,dataNukeSettings:{...t.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??t.showBanner,history:r.history??[],isActive:r.isActive??false,isPaused:r.isPaused??false,currentUser:r.currentUser??null},this.state.isActive&&this.state.currentUser&&this.syncWithListener()}else this.state={...Z,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner};this.isInitialized=true}catch{this.isInitialized=true}}setAsyncStorage(e){this.asyncStorageRef=e,this.resolveStorageReady&&(this.resolveStorageReady(),this.resolveStorageReady=null)}setDeveloperDefaults(e){this.developerDefaults=e;let t=this.getEffectiveDefaults();this.isInitialized||(this.state={...this.state,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner})}getEffectiveDefaults(){return{headerKey:this.developerDefaults?.headerKey??Z.headerKey,dataNukeSettings:{...Ct,...this.developerDefaults?.dataNukeSettings},showBanner:this.developerDefaults?.showBanner??Z.showBanner}}getDeveloperDefaults(){return this.developerDefaults}async initializeAsync(e){if(e){this.asyncStorageRef=e;try{let t=await e.getItem(ae);if(console.log("[Buoy]",`[impersonate] initializeAsync read STORAGE_KEY=${ae} stored=${t?t.slice(0,200):"null"}`),t){let r=JSON.parse(t);this.state={...this.state,headerKey:r.headerKey??this.state.headerKey,ignorePatterns:r.ignorePatterns??this.state.ignorePatterns,dataNukeSettings:{...this.state.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??this.state.showBanner,history:r.history??this.state.history,isActive:r.isActive??this.state.isActive,isPaused:r.isPaused??this.state.isPaused,currentUser:r.currentUser??this.state.currentUser},this.state.isActive&&this.state.currentUser&&this.syncWithListener(),this.notify()}}catch{}}}registerNukeCallbacks(e){this.nukeCallbacks={...this.nukeCallbacks,...e}}getState(){return{...this.state}}setRemoteHandler(e){this.remoteHandler=e}replaceState(e){this.state=e,this.notify()}async startImpersonation(e){if(St(),this.remoteHandler){this.remoteHandler("startImpersonation",{user:e});return}let t=[{user:e,lastUsedAt:new Date().toISOString()},...this.state.history.filter(r=>r.user.id!==e.id)].slice(0,Mo);this.state={...this.state,isActive:true,currentUser:e,history:t},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async stopImpersonation(){if(this.remoteHandler){this.remoteHandler("stopImpersonation");return}console.log("[Buoy]",`[impersonate] stopImpersonation: isActive ${this.state.isActive} -> false, listeners=${this.listeners.size}`),this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async pauseImpersonation(){if(this.remoteHandler){this.remoteHandler("pauseImpersonation");return}!this.state.isActive||this.state.isPaused||(this.state={...this.state,isPaused:true},this.syncWithListener(),await this.persist(),this.notify())}async resumeImpersonation(){if(St(),this.remoteHandler){this.remoteHandler("resumeImpersonation");return}!this.state.isActive||!this.state.isPaused||(this.state={...this.state,isPaused:false},this.syncWithListener(),await this.persist(),this.notify())}async quickSwitch(e){return this.startImpersonation(e)}async updateSettings(e){if(this.remoteHandler){this.remoteHandler("updateSettings",{settings:e});return}this.state={...this.state,headerKey:e.headerKey??this.state.headerKey,ignorePatterns:e.ignorePatterns??this.state.ignorePatterns,showBanner:e.showBanner??this.state.showBanner,dataNukeSettings:e.dataNukeSettings?{...this.state.dataNukeSettings,...e.dataNukeSettings}:this.state.dataNukeSettings},(e.headerKey||e.ignorePatterns)&&this.syncWithListener(),await this.persist(),this.notify()}async removeFromHistory(e){if(this.remoteHandler){this.remoteHandler("removeFromHistory",{userId:e});return}this.state={...this.state,history:this.state.history.filter(t=>t.user.id!==e)},await this.persist(),this.notify()}async clearHistory(){if(this.remoteHandler){this.remoteHandler("clearHistory");return}this.state={...this.state,history:[]},await this.persist(),this.notify()}async executeDataNuke(){if(!Be){Be=true;try{let{dataNukeSettings:e}=this.state,t=[];e.reactQuery&&this.nukeCallbacks.reactQuery&&t.push(Promise.resolve(this.nukeCallbacks.reactQuery())),e.redux&&this.nukeCallbacks.redux&&t.push(Promise.resolve(this.nukeCallbacks.redux())),e.asyncStorage&&this.nukeCallbacks.asyncStorage&&t.push(Promise.resolve(this.nukeCallbacks.asyncStorage())),e.mmkv&&this.nukeCallbacks.mmkv&&t.push(Promise.resolve(this.nukeCallbacks.mmkv())),await Promise.allSettled(t)}finally{setTimeout(()=>{Be=false},100)}}}disposeAccountSession(){this.remoteHandler||!this.state.isActive||(this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),this.persist())}syncWithListener(){let e=this.state.isActive&&!this.state.isPaused;wt({headerKey:this.state.headerKey,userId:e?this.state.currentUser?.id??null:null,ignorePatterns:this.state.ignorePatterns.map(t=>new RegExp(t)),gate:Do}),O().isListening||O().startListening()}async persist(){this.storageReadyPromise&&await this.storageReadyPromise;let e={headerKey:this.state.headerKey,ignorePatterns:this.state.ignorePatterns,dataNukeSettings:this.state.dataNukeSettings,showBanner:this.state.showBanner,history:this.state.history,isActive:this.state.isActive,isPaused:this.state.isPaused,currentUser:this.state.currentUser},t=JSON.stringify(e);try{this.asyncStorageRef?(await this.asyncStorageRef.setItem(ae,t),console.log("[Buoy]",`[impersonate] persist -> AsyncStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`)):(xt.setItem(ae,t),console.log("[Buoy]",`[impersonate] persist -> localStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`))}catch(r){console.warn("[Buoy]","[impersonate] persist failed",r)}}notify(){this.listeners.forEach(e=>{try{e(this.state)}catch{}})}},p=new jo;function It(e={}){let[t,r]=me(""),[n,o]=me([]),[i,l]=me(false),[h,a]=me(null),c=Eo(p.subscribe,p.getSnapshot,p.getSnapshot);bt(()=>{p.registerNukeCallbacks({reactQuery:e.onClearReactQuery,redux:e.onClearRedux,asyncStorage:e.onClearAsyncStorage,mmkv:e.onClearMMKV})},[e.onClearReactQuery,e.onClearRedux,e.onClearAsyncStorage,e.onClearMMKV]),bt(()=>{let S=true;return(async()=>{try{let v=await import("@buoy-gg/shared-ui/web/asyncStorage").then(W=>W.default),G={getItem:W=>v.getItem(W),setItem:(W,we)=>v.setItem(W,we)};p.setAsyncStorage(G),S&&await p.initializeAsync(G)}catch{}})(),O().isListening||O().startListening(),()=>{S=false}},[]);let s=N(async S=>{if(r(S),a(null),!S.trim()){o([]);return}if(!e.onSearchUsers){a("Search not configured"),o([]);return}l(true);try{let v=await e.onSearchUsers(S);o(v)}catch(v){a(v instanceof Error?v.message:"Search failed"),o([])}finally{l(false)}},[e.onSearchUsers]),b=N(()=>{r(""),o([]),a(null)},[]),C=N(async S=>{await p.startImpersonation(S)},[]),f=N(async()=>{await p.stopImpersonation()},[]),x=N(async S=>{await p.quickSwitch(S)},[]),I=N(async S=>{await p.updateSettings({headerKey:S})},[]),pe=N(async S=>{await p.updateSettings({ignorePatterns:S})},[]),X=N(async S=>{await p.updateSettings({dataNukeSettings:S})},[]),Y=N(async S=>{await p.updateSettings({showBanner:S})},[]),K=N(async S=>{await p.removeFromHistory(S)},[]),ee=N(async()=>{await p.clearHistory()},[]);return{isActive:c.isActive,currentUser:c.currentUser,headerKey:c.headerKey,ignorePatterns:c.ignorePatterns,dataNukeSettings:c.dataNukeSettings,showBanner:c.showBanner,history:c.history,searchQuery:t,searchResults:n,isSearching:i,searchError:h,searchUsers:s,clearSearch:b,startImpersonation:C,stopImpersonation:f,quickSwitch:x,updateHeaderKey:I,updateIgnorePatterns:pe,updateDataNukeSettings:X,updateShowBanner:Y,removeFromHistory:K,clearHistory:ee}}import{useCallback as Vo}from"react";import{dispatchToolAction as kt,getToolAdapters as $o}from"@buoy-gg/shared-ui/web";function Xo(){let e=!!$o().query,t=Vo(async()=>{await kt("query","clearQueryCache"),await kt("query","clearMutationCache")},[]);return{isAvailable:e,error:e?null:"Connect React Query to Buoy or provide onClearReactQuery.",clearCache:e?t:null}}import{useCallback as Qo}from"react";import{dispatchToolAction as qo,getToolAdapters as _o}from"@buoy-gg/shared-ui/web";var Jo="@@RESET";function Yo({resetActionType:e=Jo}={}){let t=!!_o().redux,r=Qo(async()=>{await qo("redux","dispatch",{action:{type:e}})},[e]);return{isAvailable:t,error:t?null:"Connect Redux to Buoy or provide onClearRedux.",resetStore:t?r:null}}import{isDevToolsStorageKey as Go}from"@buoy-gg/shared-ui/web";import{useCallback as Zo,useMemo as en,useState as Tt,useEffect as tn}from"react";var Re=false;function rn(){let[e,t]=Tt(null),[r,n]=Tt(null);tn(()=>{let i=wr();i?(t(i),n(null)):n("@react-native-async-storage/async-storage is not installed")},[]);let o=Zo(async()=>{if(!Re){Re=true;try{if(e){let i=(await e.getAllKeys()).filter(l=>!Go(l));i.length>0&&await e.multiRemove([...i])}}finally{setTimeout(()=>{Re=false},100)}}},[e]);return en(()=>!e||r?{isAvailable:false,error:r||"@react-native-async-storage/async-storage is not available",clearStorage:null}:{isAvailable:true,error:null,clearStorage:o},[e,r,o])}import{useCallback as on}from"react";import{SectionHeader as Ae,EmptyState as nn,night as A,Search as an,AlertTriangle as Bt,Users as sn}from"@buoy-gg/shared-ui/web";import{buoyColors as He,night as E,Play as ln,X as cn,PowerToggleButton as dn,monoFont as un}from"@buoy-gg/shared-ui/web";import{useMemo as Rt}from"react";import{buoyColors as hn,night as gn}from"@buoy-gg/shared-ui/web";import{jsx as Pe,jsxs as pn}from"react/jsx-runtime";var At=["#6366F1","#8B5CF6","#EC4899","#F43F5E","#F97316","#EAB308","#22C55E","#14B8A6","#06B6D4","#3B82F6"],mn={small:{container:24,font:10,indicator:8},medium:{container:36,font:14,indicator:10},large:{container:44,font:16,indicator:12}};function yn(e){if(!e)return"?";if(e.includes("@"))return e.charAt(0).toUpperCase();let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}function fn(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return At[Math.abs(t)%At.length]}function ze({userId:e,name:t,size:r="medium",showActiveIndicator:n=false,backgroundColor:o}){let i=mn[r],l=Rt(()=>o??fn(e),[e,o]),h=Rt(()=>yn(t),[t]);return pn(d,{style:ye.wrapper,children:[Pe(d,{style:[ye.container,{width:i.container,height:i.container,borderRadius:i.container/2,backgroundColor:l}],children:Pe(y,{style:[ye.initials,{fontSize:i.font}],children:h})}),n&&Pe(d,{style:[ye.indicator,{width:i.indicator,height:i.indicator,borderRadius:i.indicator/2,right:-1,bottom:-1}]})]})}var ye=F.create({wrapper:{position:"relative"},container:{alignItems:"center",justifyContent:"center"},initials:{color:"#FFFFFF",fontWeight:"600",letterSpacing:.5},indicator:{position:"absolute",backgroundColor:hn.success,borderWidth:2,borderColor:gn.color.surface}});import{jsx as L,jsxs as se}from"react/jsx-runtime";function Ht({user:e,isActive:t=false,onPress:r,onStop:n,onRemove:o,showRemoveButton:i=false,lastUsedTime:l,variant:h="default"}){let a=e.displayName||e.email||e.id,c=e.email&&e.displayName,s=typeof e.metadata?.role=="string"?e.metadata.role:null;return se(H,{testID:`buoy-impersonate-user-${e.id}`,style:[R.container,t&&R.activeContainer,h==="compact"&&R.compactContainer],onPress:r,disabled:t,activeOpacity:.7,children:[L(d,{style:R.avatarSection,children:L(ze,{userId:e.id,name:a,size:h==="compact"?"small":"medium",showActiveIndicator:t})}),se(d,{style:R.content,children:[se(d,{style:R.nameRow,children:[L(y,{style:[R.name,t&&R.activeName],numberOfLines:1,children:a}),s?L(d,{style:R.roleBadge,children:L(y,{style:R.roleBadgeText,children:s.toUpperCase()})}):null]}),c&&L(y,{style:R.email,numberOfLines:1,children:e.email}),L(d,{style:R.metadataRow,children:se(y,{style:R.userId,children:["ID: ",e.id]})})]}),se(d,{style:R.actions,children:[t?L(dn,{isEnabled:true,onToggle:n||(()=>{}),accessibilityLabel:"Stop impersonation"}):L(H,{style:R.actionButton,onPress:r,activeOpacity:.7,children:L(ln,{size:14,color:E.color.onAccent})}),i&&o&&!t&&L(H,{style:R.removeButton,onPress:o,activeOpacity:.7,children:L(cn,{size:12,color:E.color.textTertiary})})]}),l?L(y,{style:R.lastUsed,children:l}):null]})}var R=F.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:E.color.surface,borderRadius:10,borderWidth:1,borderColor:E.color.border,padding:12,gap:12},activeContainer:{backgroundColor:He.success+"10",borderColor:He.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:E.color.text,flexShrink:1},activeName:{color:He.success},roleBadge:{backgroundColor:E.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:E.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:E.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:E.color.textTertiary,fontFamily:un},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:E.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:E.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:E.color.surfaceElevated,borderWidth:1,borderColor:E.color.border,alignItems:"center",justifyContent:"center"}});import{jsx as T,jsxs as M}from"react/jsx-runtime";function Pt({currentUser:e,searchQuery:t,searchResults:r,isSearching:n,searchError:o,onSelectUser:i,onStopImpersonation:l,searchAvailable:h=true}){let a=on(({item:c})=>{let s=e?.id===c.id;return T(Ht,{user:c,isActive:s,onPress:()=>!s&&i(c),onStop:s?l:void 0})},[e,i,l]);return M(d,{style:B.container,children:[!h&&T(d,{style:B.section,children:M(d,{style:B.warningCard,children:[T(Bt,{size:18,color:A.color.warning}),M(d,{style:B.warningContent,children:[T(y,{style:B.warningTitle,children:"Search Not Available"}),T(y,{style:B.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),n&&M(d,{style:B.loadingContainer,children:[T(mt,{size:"small",color:A.color.accent}),T(y,{style:B.loadingText,children:"Searching users..."})]}),o?T(d,{style:B.section,children:M(d,{style:B.errorCard,children:[T(Bt,{size:16,color:A.color.danger}),T(y,{style:B.errorText,children:o})]})}):null,r.length>0&&M(d,{style:B.resultsSection,children:[M(Ae,{children:[T(Ae.Title,{children:"Results"}),T(Ae.Badge,{count:r.length})]}),T(Ie,{data:r,keyExtractor:c=>c.id,renderItem:a,ItemSeparatorComponent:()=>T(d,{style:B.separator}),contentContainerStyle:B.listContent,showsVerticalScrollIndicator:false})]}),!!t&&!n&&r.length===0&&!o&&M(d,{style:B.emptyStateContainer,children:[T(d,{style:B.emptyStateIcon,children:T(sn,{size:28,color:A.color.textTertiary})}),T(y,{style:B.emptyStateTitle,children:"No users found"}),M(y,{style:B.emptyStateDescription,children:['No results for "',t,'"']}),T(y,{style:B.emptyStateHint,children:"Try a different search term"})]}),!t&&r.length===0&&!n&&h&&T(nn,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:an,variant:"minimal"})]})}var B=F.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:A.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:A.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:A.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:A.color.warning,marginBottom:4},warningText:{fontSize:13,color:A.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:A.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:A.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:A.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:A.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:A.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:A.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:A.color.textTertiary}});import{useCallback as bn}from"react";import{night as Q,Trash2 as Sn,useRelativeTime as vn,ToolEmptyState as wn}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as zt}from"react/jsx-runtime";function Cn({item:e,isActive:t,onSelect:r,onStop:n,onRemove:o,showRemoveButton:i}){let l=vn(new Date(e.lastUsedAt));return U(Ht,{user:e.user,isActive:t,onPress:()=>!t&&r(e.user),onStop:t?n:void 0,onRemove:o,showRemoveButton:i,lastUsedTime:l})}function Et({history:e,currentUserId:t,onSelectUser:r,onStopImpersonation:n,onRemoveFromHistory:o,onClearHistory:i}){let l=bn(({item:h})=>{let a=t===h.user.id;return U(Cn,{item:h,isActive:a,onSelect:r,onStop:n,onRemove:o?()=>o(h.user.id):void 0,showRemoveButton:!!o})},[t,r,n,o]);return e.length===0?U(wn,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"}):zt(d,{style:j.container,children:[zt(d,{style:j.headerRow,children:[U(y,{style:j.headerTitle,children:"Recent"}),U(d,{style:j.headerBadge,children:U(y,{style:j.headerBadgeText,children:e.length})}),U(d,{style:j.headerSpacer}),i&&U(H,{style:j.clearButton,onPress:i,activeOpacity:.7,children:U(Sn,{size:12,color:Q.color.textTertiary})})]}),U(Ie,{data:e,keyExtractor:h=>h.user.id,renderItem:l,ItemSeparatorComponent:()=>U(d,{style:j.separator}),contentContainerStyle:j.listContent,showsVerticalScrollIndicator:false})]})}var j=F.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:Q.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:Q.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:Q.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:Q.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:Q.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:Q.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:Q.color.textSecondary,textAlign:"center"}});import{useState as fe,useEffect as Ee,useMemo as Le}from"react";import{CollapsibleSection as ie,buoyColors as le,night as m,Settings as xn,AlertTriangle as Lt,Info as In,Zap as kn,RefreshCw as Tn,Check as De,X as Dt,Copy as Nt,Eye as Bn,copyToClipboard as Rn,ToggleRow as An,monoFont as Ne}from"@buoy-gg/shared-ui/web";import{DataViewer as Hn}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as Ue,jsx as g,jsxs as w}from"react/jsx-runtime";var ce="x-impersonate-user-id",Oe=true,de={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function ue({label:e,description:t,value:r,onChange:n,recommended:o,dangerous:i,detected:l}){let h=w(Ue,{children:[l!==void 0&&w(d,{style:[u.detectedBadge,l?u.detectedBadgeActive:u.detectedBadgeInactive],children:[l?g(De,{size:10,color:le.success}):g(Dt,{size:10,color:m.color.textTertiary}),g(y,{style:[u.detectedText,l?u.detectedTextActive:u.detectedTextInactive],children:l?"Detected":"Not Detected"})]}),o&&l!==false&&w(d,{style:u.recommendedBadge,children:[g(kn,{size:10,color:m.color.accent}),g(y,{style:u.recommendedText,children:"Recommended"})]})]});return g(An,{variant:"plain",label:e,description:t,value:r,onValueChange:n,tone:i?"warning":"accent",emphasizeLabel:i,accessory:h})}function Ut({headerKey:e,settings:t,showBanner:r,onSave:n,onShowBannerChange:o,detectionStatus:i}){let[l,h]=fe(e),[a,c]=fe(t),[s,b]=fe(r),[C,f]=fe(false);Ee(()=>{h(e)},[e]),Ee(()=>{c(t)},[t]),Ee(()=>{b(r)},[r]);let x=Le(()=>l!==e||a.reactQuery!==t.reactQuery||a.redux!==t.redux||a.asyncStorage!==t.asyncStorage||a.mmkv!==t.mmkv,[l,a,e,t]),I=Le(()=>l===ce&&s===Oe&&a.reactQuery===de.reactQuery&&a.redux===de.redux&&a.asyncStorage===de.asyncStorage&&a.mmkv===de.mmkv,[l,s,a]),pe=()=>{n(l.trim()||ce,a,s)},X=()=>{h(e),c(t),b(r)},Y=()=>{h(ce),c(de),b(Oe),o(Oe)},K=(v,G)=>{c(W=>({...W,[v]:G}))},ee=Le(()=>({defaults:{headerKey:l,showBanner:s,dataNukeSettings:{reactQuery:a.reactQuery,redux:a.redux,asyncStorage:a.asyncStorage,mmkv:a.mmkv}}}),[l,s,a]),S=async()=>{let v=`defaults: {
|
|
1
|
+
"use client";var ot=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var yr=Object.prototype.hasOwnProperty;var fr=(e,t)=>{for(var r in t)ot(e,r,{get:t[r],enumerable:true})},nt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mr(t))!yr.call(e,o)&&o!==r&&ot(e,o,{get:()=>t[o],enumerable:!(n=gr(t,o))||n.enumerable});return e},br=(e,t,r)=>(nt(e,t,"default"),r&&nt(r,t,"default"));var oa=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import at from"@buoy-gg/shared-ui/web/asyncStorage";import{getCapacitorAppStorage as Sr}from"@buoy-gg/shared-ui/web";function vr(){return at}function wr(){return Sr()??at}import{useState as xe,useCallback as te,useRef as st,useEffect as it}from"react";var lt={};fr(lt,{AccessibilityInfo:()=>kr,ActivityIndicator:()=>mt,Alert:()=>Bo,Animated:()=>Tr,AppRegistry:()=>Rr,AppState:()=>Ar,Appearance:()=>Br,BackHandler:()=>Hr,Button:()=>ko,CheckBox:()=>Xr,Clipboard:()=>Pr,DeviceEventEmitter:()=>io,Dimensions:()=>Dr,Easing:()=>zr,FlatList:()=>Ie,I18nManager:()=>Er,Image:()=>Qr,ImageBackground:()=>qr,InteractionManager:()=>Nr,Keyboard:()=>Lr,KeyboardAvoidingView:()=>_r,LayoutAnimation:()=>Ur,Linking:()=>Or,LogBox:()=>so,Modal:()=>xo,NativeEventEmitter:()=>Kr,NativeModules:()=>Ir,PanResponder:()=>Wr,Picker:()=>Jr,PixelRatio:()=>Fr,Platform:()=>Mr,Pressable:()=>Co,ProgressBar:()=>Yr,RefreshControl:()=>Gr,SafeAreaView:()=>Zr,ScrollView:()=>pt,SectionList:()=>eo,Share:()=>jr,StatusBar:()=>to,StyleSheet:()=>F,Switch:()=>Io,Text:()=>y,TextInput:()=>ht,Touchable:()=>ro,TouchableHighlight:()=>vo,TouchableNativeFeedback:()=>oo,TouchableOpacity:()=>H,TouchableWithoutFeedback:()=>wo,UIManager:()=>Vr,Vibration:()=>$r,View:()=>c,VirtualizedList:()=>no,YellowBox:()=>ao,findNodeHandle:()=>To,unstable_createElement:()=>xr,useColorScheme:()=>lo,useLocaleContext:()=>co,useWindowDimensions:()=>uo});br(lt,Cr);import*as Cr from"react-native-web";import{unstable_createElement as xr,NativeModules as Ir,AccessibilityInfo as kr,Animated as Tr,Appearance as Br,AppRegistry as Rr,AppState as Ar,BackHandler as Hr,Clipboard as Pr,Dimensions as Dr,Easing as zr,I18nManager as Er,Keyboard as Lr,InteractionManager as Nr,LayoutAnimation as Ur,Linking as Or,NativeEventEmitter as Kr,PanResponder as Wr,PixelRatio as Fr,Platform as Mr,Share as jr,StyleSheet as F,UIManager as Vr,Vibration as $r,CheckBox as Xr,FlatList as Ie,Image as Qr,ImageBackground as qr,KeyboardAvoidingView as _r,Picker as Jr,ProgressBar as Yr,RefreshControl as Gr,SafeAreaView as Zr,SectionList as eo,StatusBar as to,Touchable as ro,TouchableNativeFeedback as oo,VirtualizedList as no,YellowBox as ao,LogBox as so,DeviceEventEmitter as io,useColorScheme as lo,useLocaleContext as co,useWindowDimensions as uo}from"react-native-web";import*as D from"react-native-web";import{createElement as ke,forwardRef as ct,useCallback as ho,useRef as po}from"react";import{useEffect as go,useState as mo}from"react";import{createPortal as yo}from"react-dom";var fo='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as bo}from"react/jsx-runtime";var re=Symbol.for("@buoy-gg/portal-host"),dt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function ut(){let e=document;if(e[re])return e[re].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:fo});let r=()=>{let s=document.fullscreenElement,b=s&&s.tagName!=="CANVAS"?s:document.body;t.parentElement!==b&&b.appendChild(t)},n=new Map,o=s=>{(!t.contains(s.target)||!dt(s.target))&&n.set(s.code||s.key,{key:s.key,code:s.code,location:s.location,keyCode:s.keyCode,which:s.which,altKey:s.altKey,ctrlKey:s.ctrlKey,metaKey:s.metaKey,shiftKey:s.shiftKey})},i=s=>{n.delete(s.code||s.key)},l=()=>n.clear(),h=()=>{let s=[...n.values()];n.clear();for(let b of s)document.dispatchEvent(new KeyboardEvent("keyup",{...b,bubbles:true}))},a=s=>{dt(s.target)&&s.stopPropagation()},d=s=>s.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",o,true),document.addEventListener("keyup",i,true),window.addEventListener("blur",l),t.addEventListener("focusin",h),t.addEventListener("keydown",a),t.addEventListener("keyup",a),t.addEventListener("keypress",a),t.addEventListener("wheel",d,{passive:true}),e[re]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",o,true),document.removeEventListener("keyup",i,true),window.removeEventListener("blur",l),t.remove(),delete e[re]}},t}function So({children:e}){let[t,r]=mo(null);return go(()=>{let n=ut(),o=document[re];return o.users++,r(n),()=>{--o.users===0&&o.dispose()}},[]),t?yo(bo("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function L(e){let t=ct((n,o)=>{let{accessibilityState:i,accessibilityValue:l,...h}=n;for(let a of["busy","checked","disabled","expanded","selected"])i?.[a]!==void 0&&h[`aria-${a}`]===void 0&&(h[`aria-${a}`]=i[a]);for(let[a,d]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[a]!==void 0&&h[`aria-${d}`]===void 0&&(h[`aria-${d}`]=l[a]);return ke(e,{...h,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var c=L(D.View),y=L(D.Text),ht=L(D.TextInput),H=L(D.TouchableOpacity),vo=L(D.TouchableHighlight),wo=L(D.TouchableWithoutFeedback),Co=L(D.Pressable),pt=L(D.ScrollView),gt=ct((e,t)=>{let r=po(null),n=ho(o=>{if(o){let i=o;for(;i.parentElement&&i.parentElement!==document.body;)i=i.parentElement;i.parentElement===document.body&&(r.current=i,Object.assign(i.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),ut().appendChild(i))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(o):t&&(t.current=o)},[t]);return ke(So,null,ke(D.Modal,{...e,ref:n}))});gt.displayName="Modal";var xo=L(gt),Io=L(D.Switch),mt=L(D.ActivityIndicator),ko=L(D.Button),To=D.findNodeHandle,Bo={alert(e,t,r,n){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(i),t){let d=document.createElement("p");d.textContent=t,d.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(d)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let h=r?.length?r:[{text:"OK"}],a=()=>{o.close?.(),o.remove()};for(let d of h){let s=document.createElement("button");s.type="button",s.textContent=d.text??"OK",s.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,s.onclick=()=>{a(),d.onPress?.()},l.appendChild(s)}o.addEventListener("cancel",d=>{d.preventDefault(),n?.cancelable!==false&&(a(),n?.onDismiss?.())}),o.appendChild(l),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{JsModal as Ro,TabSelector as Ao,ModalHeader as oe,buoyColors as Ho,night as yt,Search as Po,TickProvider as ft,windowDragProps as Do}from"@buoy-gg/shared-ui/web";import{useState as me,useEffect as bt,useCallback as N,useSyncExternalStore as zo}from"react";import{assertAccountAccess as St,getAccountAccess as Eo,hasAccountAccess as Lo,subscribeAccountAccess as No}from"@buoy-gg/shared-ui/web";var vt=[/\/symbolicate$/,/\/logs$/,/\/debugger-proxy/,/\/reload$/,/\/launch-js-devtools/,/localhost:8081/,/100\.64\.\d+\.\d+:8081/,/10\.0\.\d+\.\d+:8081/,/\.hot-update\./,/__metro/];function Te(e,t){for(let r of Object.keys(t))r.startsWith("__buoy")&&(e[r]=t[r])}var Uo=class{constructor(){this.isListeningFlag=false;this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.reportHeader=e=>this.shouldInjectHeader(e)?{[this.config.headerKey]:this.config.userId}:null;this.originalFetch=globalThis.fetch.bind(globalThis),this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send,this.config={headerKey:"x-impersonate-user-id",userId:null,ignorePatterns:[...vt]}}setConfig(e){this.config={...this.config,...e},e.ignorePatterns&&(this.config.ignorePatterns=[...vt,...e.ignorePatterns])}getConfig(){return{...this.config}}shouldInjectHeader(e){return!this.config.userId||this.config.gate&&!this.config.gate()?false:!this.config.ignorePatterns.some(t=>t.test(e))}extractUrl(e){return typeof e=="string"?e:e instanceof URL?e.href:e.url}startListening(){if(this.isListeningFlag)return;let e=globalThis.fetch,t=XMLHttpRequest.prototype.open,r=XMLHttpRequest.prototype.send;this.originalFetch=e.bind(globalThis),this.originalXHROpen=t,this.originalXHRSend=r;let n=this,o=async function(d,s){let b=n.extractUrl(d);if(n.shouldInjectHeader(b)){let C=s?.headers??(typeof d=="object"&&"headers"in d?d.headers:void 0),f=new Headers(C);return f.set(n.config.headerKey,n.config.userId),n.originalFetch(d,{...s,headers:f})}return n.originalFetch(d,s)};Te(o,e),this.patchedFetch=o,globalThis.fetch=this.patchedFetch;let i=function(d,s,b=true,C,f){let x=this;x._impersonateUrl=typeof s=="string"?s:s.href;let I=typeof s=="string"?s:s.toString();return n.originalXHROpen.call(this,d,I,b,C,f)},l=function(d){let s=this;return s._impersonateUrl&&n.shouldInjectHeader(s._impersonateUrl)&&this.setRequestHeader(n.config.headerKey,n.config.userId),n.originalXHRSend.call(this,d)};Te(i,t),Te(l,r),this.patchedXHROpen=i,this.patchedXHRSend=l,XMLHttpRequest.prototype.open=this.patchedXHROpen,XMLHttpRequest.prototype.send=this.patchedXHRSend;let h=globalThis,a=h.__buoyHeaderInjectors??(h.__buoyHeaderInjectors=[]);a.includes(this.reportHeader)||a.push(this.reportHeader),this.isListeningFlag=true}stopListening(){if(!this.isListeningFlag)return;this.patchedFetch&&globalThis.fetch===this.patchedFetch&&(globalThis.fetch=this.originalFetch),this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend),this.patchedFetch=null,this.patchedXHROpen=null,this.patchedXHRSend=null;let e=globalThis.__buoyHeaderInjectors,t=e?.indexOf(this.reportHeader)??-1;e&&t>=0&&e.splice(t,1),this.isListeningFlag=false}get isListening(){return this.isListeningFlag}get isImpersonating(){return this.config.userId!==null&&(this.config.gate?.()??true)}},ne=null;function O(){return ne||(ne=new Uo),ne}function Oo(){O().startListening()}function Ko(){O().stopListening()}function wt(e){O().setConfig(e)}function Wo(){return ne?.isImpersonating??false}function Fo(){return ne?.getConfig().userId??null}var ae="@buoy/impersonate/state",Mo=10,Ct={reactQuery:true,redux:true,asyncStorage:false,mmkv:false},Z={isActive:false,isPaused:false,currentUser:null,headerKey:"x-impersonate-user-id",ignorePatterns:[],dataNukeSettings:Ct,showBanner:true,history:[]},Be=false,xt={getItem:e=>{try{return typeof localStorage<"u"?localStorage.getItem(e):null}catch{return null}},setItem:(e,t)=>{try{typeof localStorage<"u"&&localStorage.setItem(e,t)}catch{}},removeItem:e=>{try{typeof localStorage<"u"&&localStorage.removeItem(e)}catch{}}},jo=class{constructor(){this.state={...Z};this.listeners=new Set;this.nukeCallbacks={};this.isInitialized=false;this.asyncStorageRef=null;this.storageReadyPromise=null;this.resolveStorageReady=null;this.developerDefaults=null;this.getSnapshot=()=>this.state;this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));this.remoteHandler=null;this.loadFromStorage(),Promise.resolve().then(()=>{let e=false,t=()=>{let r=Eo().status;r==="admitted"?e=true:r==="locked"&&e&&(e=false,this.disposeAccountSession())};No(t),t()}),typeof localStorage<"u"?this.storageReadyPromise=Promise.resolve():this.storageReadyPromise=new Promise(e=>{this.resolveStorageReady=e})}loadFromStorage(){try{let e=xt.getItem(ae),t=this.getEffectiveDefaults();if(e){let r=JSON.parse(e);this.state={...Z,headerKey:r.headerKey??t.headerKey,ignorePatterns:r.ignorePatterns??Z.ignorePatterns,dataNukeSettings:{...t.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??t.showBanner,history:r.history??[],isActive:r.isActive??false,isPaused:r.isPaused??false,currentUser:r.currentUser??null},this.state.isActive&&this.state.currentUser&&this.syncWithListener()}else this.state={...Z,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner};this.isInitialized=true}catch{this.isInitialized=true}}setAsyncStorage(e){this.asyncStorageRef=e,this.resolveStorageReady&&(this.resolveStorageReady(),this.resolveStorageReady=null)}setDeveloperDefaults(e){this.developerDefaults=e;let t=this.getEffectiveDefaults();this.isInitialized||(this.state={...this.state,headerKey:t.headerKey,dataNukeSettings:t.dataNukeSettings,showBanner:t.showBanner})}getEffectiveDefaults(){return{headerKey:this.developerDefaults?.headerKey??Z.headerKey,dataNukeSettings:{...Ct,...this.developerDefaults?.dataNukeSettings},showBanner:this.developerDefaults?.showBanner??Z.showBanner}}getDeveloperDefaults(){return this.developerDefaults}async initializeAsync(e){if(e){this.asyncStorageRef=e;try{let t=await e.getItem(ae);if(console.log("[Buoy]",`[impersonate] initializeAsync read STORAGE_KEY=${ae} stored=${t?t.slice(0,200):"null"}`),t){let r=JSON.parse(t);this.state={...this.state,headerKey:r.headerKey??this.state.headerKey,ignorePatterns:r.ignorePatterns??this.state.ignorePatterns,dataNukeSettings:{...this.state.dataNukeSettings,...r.dataNukeSettings},showBanner:r.showBanner??this.state.showBanner,history:r.history??this.state.history,isActive:r.isActive??this.state.isActive,isPaused:r.isPaused??this.state.isPaused,currentUser:r.currentUser??this.state.currentUser},this.state.isActive&&this.state.currentUser&&this.syncWithListener(),this.notify()}}catch{}}}registerNukeCallbacks(e){this.nukeCallbacks={...this.nukeCallbacks,...e}}getState(){return{...this.state}}setRemoteHandler(e){this.remoteHandler=e}replaceState(e){this.state=e,this.notify()}async startImpersonation(e){if(St(),this.remoteHandler){this.remoteHandler("startImpersonation",{user:e});return}let t=[{user:e,lastUsedAt:new Date().toISOString()},...this.state.history.filter(r=>r.user.id!==e.id)].slice(0,Mo);this.state={...this.state,isActive:true,currentUser:e,history:t},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async stopImpersonation(){if(this.remoteHandler){this.remoteHandler("stopImpersonation");return}console.log("[Buoy]",`[impersonate] stopImpersonation: isActive ${this.state.isActive} -> false, listeners=${this.listeners.size}`),this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),await this.executeDataNuke(),await this.persist()}async pauseImpersonation(){if(this.remoteHandler){this.remoteHandler("pauseImpersonation");return}!this.state.isActive||this.state.isPaused||(this.state={...this.state,isPaused:true},this.syncWithListener(),await this.persist(),this.notify())}async resumeImpersonation(){if(St(),this.remoteHandler){this.remoteHandler("resumeImpersonation");return}!this.state.isActive||!this.state.isPaused||(this.state={...this.state,isPaused:false},this.syncWithListener(),await this.persist(),this.notify())}async quickSwitch(e){return this.startImpersonation(e)}async updateSettings(e){if(this.remoteHandler){this.remoteHandler("updateSettings",{settings:e});return}this.state={...this.state,headerKey:e.headerKey??this.state.headerKey,ignorePatterns:e.ignorePatterns??this.state.ignorePatterns,showBanner:e.showBanner??this.state.showBanner,dataNukeSettings:e.dataNukeSettings?{...this.state.dataNukeSettings,...e.dataNukeSettings}:this.state.dataNukeSettings},(e.headerKey||e.ignorePatterns)&&this.syncWithListener(),await this.persist(),this.notify()}async removeFromHistory(e){if(this.remoteHandler){this.remoteHandler("removeFromHistory",{userId:e});return}this.state={...this.state,history:this.state.history.filter(t=>t.user.id!==e)},await this.persist(),this.notify()}async clearHistory(){if(this.remoteHandler){this.remoteHandler("clearHistory");return}this.state={...this.state,history:[]},await this.persist(),this.notify()}async executeDataNuke(){if(!Be){Be=true;try{let{dataNukeSettings:e}=this.state,t=[];e.reactQuery&&this.nukeCallbacks.reactQuery&&t.push(Promise.resolve(this.nukeCallbacks.reactQuery())),e.redux&&this.nukeCallbacks.redux&&t.push(Promise.resolve(this.nukeCallbacks.redux())),e.asyncStorage&&this.nukeCallbacks.asyncStorage&&t.push(Promise.resolve(this.nukeCallbacks.asyncStorage())),e.mmkv&&this.nukeCallbacks.mmkv&&t.push(Promise.resolve(this.nukeCallbacks.mmkv())),await Promise.allSettled(t)}finally{setTimeout(()=>{Be=false},100)}}}disposeAccountSession(){this.remoteHandler||!this.state.isActive||(this.state={...this.state,isActive:false,isPaused:false,currentUser:null},this.syncWithListener(),this.notify(),this.persist())}syncWithListener(){let e=this.state.isActive&&!this.state.isPaused;wt({headerKey:this.state.headerKey,userId:e?this.state.currentUser?.id??null:null,ignorePatterns:this.state.ignorePatterns.map(t=>new RegExp(t)),gate:Lo}),O().isListening||O().startListening()}async persist(){this.storageReadyPromise&&await this.storageReadyPromise;let e={headerKey:this.state.headerKey,ignorePatterns:this.state.ignorePatterns,dataNukeSettings:this.state.dataNukeSettings,showBanner:this.state.showBanner,history:this.state.history,isActive:this.state.isActive,isPaused:this.state.isPaused,currentUser:this.state.currentUser},t=JSON.stringify(e);try{this.asyncStorageRef?(await this.asyncStorageRef.setItem(ae,t),console.log("[Buoy]",`[impersonate] persist -> AsyncStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`)):(xt.setItem(ae,t),console.log("[Buoy]",`[impersonate] persist -> localStorage isActive=${e.isActive} userId=${e.currentUser?.id??"null"}`))}catch(r){console.warn("[Buoy]","[impersonate] persist failed",r)}}notify(){this.listeners.forEach(e=>{try{e(this.state)}catch{}})}},g=new jo;function It(e={}){let[t,r]=me(""),[n,o]=me([]),[i,l]=me(false),[h,a]=me(null),d=zo(g.subscribe,g.getSnapshot,g.getSnapshot);bt(()=>{g.registerNukeCallbacks({reactQuery:e.onClearReactQuery,redux:e.onClearRedux,asyncStorage:e.onClearAsyncStorage,mmkv:e.onClearMMKV})},[e.onClearReactQuery,e.onClearRedux,e.onClearAsyncStorage,e.onClearMMKV]),bt(()=>{let S=true;return(async()=>{try{let v=await import("@buoy-gg/shared-ui/web/asyncStorage").then(W=>W.default),G={getItem:W=>v.getItem(W),setItem:(W,we)=>v.setItem(W,we)};g.setAsyncStorage(G),S&&await g.initializeAsync(G)}catch{}})(),O().isListening||O().startListening(),()=>{S=false}},[]);let s=N(async S=>{if(r(S),a(null),!S.trim()){o([]);return}if(!e.onSearchUsers){a("Search not configured"),o([]);return}l(true);try{let v=await e.onSearchUsers(S);o(v)}catch(v){a(v instanceof Error?v.message:"Search failed"),o([])}finally{l(false)}},[e.onSearchUsers]),b=N(()=>{r(""),o([]),a(null)},[]),C=N(async S=>{await g.startImpersonation(S)},[]),f=N(async()=>{await g.stopImpersonation()},[]),x=N(async S=>{await g.quickSwitch(S)},[]),I=N(async S=>{await g.updateSettings({headerKey:S})},[]),ge=N(async S=>{await g.updateSettings({ignorePatterns:S})},[]),X=N(async S=>{await g.updateSettings({dataNukeSettings:S})},[]),Y=N(async S=>{await g.updateSettings({showBanner:S})},[]),K=N(async S=>{await g.removeFromHistory(S)},[]),ee=N(async()=>{await g.clearHistory()},[]);return{isActive:d.isActive,currentUser:d.currentUser,headerKey:d.headerKey,ignorePatterns:d.ignorePatterns,dataNukeSettings:d.dataNukeSettings,showBanner:d.showBanner,history:d.history,searchQuery:t,searchResults:n,isSearching:i,searchError:h,searchUsers:s,clearSearch:b,startImpersonation:C,stopImpersonation:f,quickSwitch:x,updateHeaderKey:I,updateIgnorePatterns:ge,updateDataNukeSettings:X,updateShowBanner:Y,removeFromHistory:K,clearHistory:ee}}import{useCallback as Vo}from"react";import{dispatchToolAction as kt,getToolAdapters as $o}from"@buoy-gg/shared-ui/web";function Xo(){let e=!!$o().query,t=Vo(async()=>{await kt("query","clearQueryCache"),await kt("query","clearMutationCache")},[]);return{isAvailable:e,error:e?null:"Connect React Query to Buoy or provide onClearReactQuery.",clearCache:e?t:null}}import{useCallback as Qo}from"react";import{dispatchToolAction as qo,getToolAdapters as _o}from"@buoy-gg/shared-ui/web";var Jo="@@RESET";function Yo({resetActionType:e=Jo}={}){let t=!!_o().redux,r=Qo(async()=>{await qo("redux","dispatch",{action:{type:e}})},[e]);return{isAvailable:t,error:t?null:"Connect Redux to Buoy or provide onClearRedux.",resetStore:t?r:null}}import{isDevToolsStorageKey as Go}from"@buoy-gg/shared-ui/web";import{useCallback as Zo,useMemo as en,useState as Tt,useEffect as tn}from"react";var Re=false;function rn(){let[e,t]=Tt(null),[r,n]=Tt(null);tn(()=>{let i=wr();i?(t(i),n(null)):n("@react-native-async-storage/async-storage is not installed")},[]);let o=Zo(async()=>{if(!Re){Re=true;try{if(e){let i=(await e.getAllKeys()).filter(l=>!Go(l));i.length>0&&await e.multiRemove([...i])}}finally{setTimeout(()=>{Re=false},100)}}},[e]);return en(()=>!e||r?{isAvailable:false,error:r||"@react-native-async-storage/async-storage is not available",clearStorage:null}:{isAvailable:true,error:null,clearStorage:o},[e,r,o])}import{useCallback as on}from"react";import{SectionHeader as Ae,EmptyState as nn,night as A,Search as an,AlertTriangle as Bt,Users as sn}from"@buoy-gg/shared-ui/web";import{buoyColors as He,night as z,Play as ln,X as cn,PowerToggleButton as dn,monoFont as un}from"@buoy-gg/shared-ui/web";import{useMemo as Rt}from"react";import{buoyColors as hn,night as pn}from"@buoy-gg/shared-ui/web";import{jsx as Pe,jsxs as gn}from"react/jsx-runtime";var At=["#6366F1","#8B5CF6","#EC4899","#F43F5E","#F97316","#EAB308","#22C55E","#14B8A6","#06B6D4","#3B82F6"],mn={small:{container:24,font:10,indicator:8},medium:{container:36,font:14,indicator:10},large:{container:44,font:16,indicator:12}};function yn(e){if(!e)return"?";if(e.includes("@"))return e.charAt(0).toUpperCase();let t=e.trim().split(/\s+/);return t.length===1?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[t.length-1].charAt(0)).toUpperCase()}function fn(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return At[Math.abs(t)%At.length]}function De({userId:e,name:t,size:r="medium",showActiveIndicator:n=false,backgroundColor:o}){let i=mn[r],l=Rt(()=>o??fn(e),[e,o]),h=Rt(()=>yn(t),[t]);return gn(c,{style:ye.wrapper,children:[Pe(c,{style:[ye.container,{width:i.container,height:i.container,borderRadius:i.container/2,backgroundColor:l}],children:Pe(y,{style:[ye.initials,{fontSize:i.font}],children:h})}),n&&Pe(c,{style:[ye.indicator,{width:i.indicator,height:i.indicator,borderRadius:i.indicator/2,right:-1,bottom:-1}]})]})}var ye=F.create({wrapper:{position:"relative"},container:{alignItems:"center",justifyContent:"center"},initials:{color:"#FFFFFF",fontWeight:"600",letterSpacing:.5},indicator:{position:"absolute",backgroundColor:hn.success,borderWidth:2,borderColor:pn.color.surface}});import{jsx as E,jsxs as se}from"react/jsx-runtime";function Ht({user:e,isActive:t=false,onPress:r,onStop:n,onRemove:o,showRemoveButton:i=false,lastUsedTime:l,variant:h="default"}){let a=e.displayName||e.email||e.id,d=e.email&&e.displayName,s=typeof e.metadata?.role=="string"?e.metadata.role:null;return se(H,{testID:`buoy-impersonate-user-${e.id}`,style:[R.container,t&&R.activeContainer,h==="compact"&&R.compactContainer],onPress:r,disabled:t,activeOpacity:.7,children:[E(c,{style:R.avatarSection,children:E(De,{userId:e.id,name:a,size:h==="compact"?"small":"medium",showActiveIndicator:t})}),se(c,{style:R.content,children:[se(c,{style:R.nameRow,children:[E(y,{style:[R.name,t&&R.activeName],numberOfLines:1,children:a}),s?E(c,{style:R.roleBadge,children:E(y,{style:R.roleBadgeText,children:s.toUpperCase()})}):null]}),d&&E(y,{style:R.email,numberOfLines:1,children:e.email}),E(c,{style:R.metadataRow,children:se(y,{style:R.userId,children:["ID: ",e.id]})})]}),se(c,{style:R.actions,children:[t?E(dn,{isEnabled:true,onToggle:n||(()=>{}),accessibilityLabel:"Stop impersonation",testID:`buoy-impersonate-stop-${e.id}`}):E(H,{testID:`buoy-impersonate-start-${e.id}`,style:R.actionButton,onPress:r,activeOpacity:.7,children:E(ln,{size:14,color:z.color.onAccent})}),i&&o&&!t&&E(H,{testID:`buoy-impersonate-remove-${e.id}`,style:R.removeButton,onPress:o,activeOpacity:.7,children:E(cn,{size:12,color:z.color.textTertiary})})]}),l?E(y,{style:R.lastUsed,children:l}):null]})}var R=F.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:z.color.surface,borderRadius:10,borderWidth:1,borderColor:z.color.border,padding:12,gap:12},activeContainer:{backgroundColor:He.success+"10",borderColor:He.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:z.color.text,flexShrink:1},activeName:{color:He.success},roleBadge:{backgroundColor:z.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:z.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:z.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:z.color.textTertiary,fontFamily:un},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:z.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:z.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:z.color.surfaceElevated,borderWidth:1,borderColor:z.color.border,alignItems:"center",justifyContent:"center"}});import{jsx as k,jsxs as M}from"react/jsx-runtime";function Pt({currentUser:e,searchQuery:t,searchResults:r,isSearching:n,searchError:o,onSelectUser:i,onStopImpersonation:l,searchAvailable:h=true}){let a=on(({item:d})=>{let s=e?.id===d.id;return k(Ht,{user:d,isActive:s,onPress:()=>!s&&i(d),onStop:s?l:void 0})},[e,i,l]);return M(c,{style:B.container,children:[!h&&k(c,{style:B.section,children:M(c,{style:B.warningCard,children:[k(Bt,{size:18,color:A.color.warning}),M(c,{style:B.warningContent,children:[k(y,{style:B.warningTitle,children:"Search Not Available"}),k(y,{style:B.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),n&&M(c,{style:B.loadingContainer,children:[k(mt,{size:"small",color:A.color.accent}),k(y,{style:B.loadingText,children:"Searching users..."})]}),o?k(c,{style:B.section,children:M(c,{style:B.errorCard,children:[k(Bt,{size:16,color:A.color.danger}),k(y,{testID:"buoy-impersonate-error",style:B.errorText,children:o})]})}):null,r.length>0&&M(c,{style:B.resultsSection,children:[M(Ae,{children:[k(Ae.Title,{children:"Results"}),k(Ae.Badge,{count:r.length})]}),k(Ie,{testID:"buoy-impersonate-search-scroll",data:r,keyExtractor:d=>d.id,renderItem:a,ItemSeparatorComponent:()=>k(c,{style:B.separator}),contentContainerStyle:B.listContent,showsVerticalScrollIndicator:false})]}),!!t&&!n&&r.length===0&&!o&&M(c,{testID:"buoy-impersonate-no-results",style:B.emptyStateContainer,children:[k(c,{style:B.emptyStateIcon,children:k(sn,{size:28,color:A.color.textTertiary})}),k(y,{style:B.emptyStateTitle,children:"No users found"}),M(y,{style:B.emptyStateDescription,children:['No results for "',t,'"']}),k(y,{style:B.emptyStateHint,children:"Try a different search term"})]}),!t&&r.length===0&&!n&&h&&k(c,{testID:"buoy-impersonate-search-empty",children:k(nn,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:an,variant:"minimal"})})]})}var B=F.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:A.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:A.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:A.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:A.color.warning,marginBottom:4},warningText:{fontSize:13,color:A.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:A.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:A.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:A.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:A.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:A.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:A.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:A.color.textTertiary}});import{useCallback as bn}from"react";import{night as Q,Trash2 as Sn,useRelativeTime as vn,ToolEmptyState as wn}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as Dt}from"react/jsx-runtime";function Cn({item:e,isActive:t,onSelect:r,onStop:n,onRemove:o,showRemoveButton:i}){let l=vn(new Date(e.lastUsedAt));return U(Ht,{user:e.user,isActive:t,onPress:()=>!t&&r(e.user),onStop:t?n:void 0,onRemove:o,showRemoveButton:i,lastUsedTime:l})}function zt({history:e,currentUserId:t,onSelectUser:r,onStopImpersonation:n,onRemoveFromHistory:o,onClearHistory:i}){let l=bn(({item:h})=>{let a=t===h.user.id;return U(Cn,{item:h,isActive:a,onSelect:r,onStop:n,onRemove:o?()=>o(h.user.id):void 0,showRemoveButton:!!o})},[t,r,n,o]);return e.length===0?U(wn,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"}):Dt(c,{style:j.container,children:[Dt(c,{style:j.headerRow,children:[U(y,{style:j.headerTitle,children:"Recent"}),U(c,{style:j.headerBadge,children:U(y,{style:j.headerBadgeText,children:e.length})}),U(c,{style:j.headerSpacer}),i&&U(H,{testID:"buoy-impersonate-clear-history",style:j.clearButton,onPress:i,activeOpacity:.7,children:U(Sn,{size:12,color:Q.color.textTertiary})})]}),U(Ie,{testID:"buoy-impersonate-history-scroll",data:e,keyExtractor:h=>h.user.id,renderItem:l,ItemSeparatorComponent:()=>U(c,{style:j.separator}),contentContainerStyle:j.listContent,showsVerticalScrollIndicator:false})]})}var j=F.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:Q.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:Q.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:Q.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:Q.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:Q.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:Q.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:Q.color.textSecondary,textAlign:"center"}});import{useState as fe,useEffect as ze,useMemo as Ee}from"react";import{CollapsibleSection as ie,buoyColors as le,night as m,Settings as xn,AlertTriangle as Et,Info as In,Zap as kn,RefreshCw as Tn,Check as Le,X as Lt,Copy as Nt,Eye as Bn,copyToClipboard as Rn,ToggleRow as An,monoFont as Ne}from"@buoy-gg/shared-ui/web";import{DataViewer as Hn}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as Ue,jsx as p,jsxs as w}from"react/jsx-runtime";var ce="x-impersonate-user-id",Oe=true,de={reactQuery:true,redux:true,asyncStorage:false,mmkv:false};function ue({label:e,description:t,value:r,onChange:n,recommended:o,dangerous:i,detected:l,testID:h}){let a=w(Ue,{children:[l!==void 0&&w(c,{style:[u.detectedBadge,l?u.detectedBadgeActive:u.detectedBadgeInactive],children:[l?p(Le,{size:10,color:le.success}):p(Lt,{size:10,color:m.color.textTertiary}),p(y,{style:[u.detectedText,l?u.detectedTextActive:u.detectedTextInactive],children:l?"Detected":"Not Detected"})]}),o&&l!==false&&w(c,{style:u.recommendedBadge,children:[p(kn,{size:10,color:m.color.accent}),p(y,{style:u.recommendedText,children:"Recommended"})]})]});return p(An,{variant:"plain",label:e,description:t,value:r,onValueChange:n,tone:i?"warning":"accent",emphasizeLabel:i,accessory:a,testID:h})}function Ut({headerKey:e,settings:t,showBanner:r,onSave:n,onShowBannerChange:o,detectionStatus:i}){let[l,h]=fe(e),[a,d]=fe(t),[s,b]=fe(r),[C,f]=fe(false);ze(()=>{h(e)},[e]),ze(()=>{d(t)},[t]),ze(()=>{b(r)},[r]);let x=Ee(()=>l!==e||a.reactQuery!==t.reactQuery||a.redux!==t.redux||a.asyncStorage!==t.asyncStorage||a.mmkv!==t.mmkv,[l,a,e,t]),I=Ee(()=>l===ce&&s===Oe&&a.reactQuery===de.reactQuery&&a.redux===de.redux&&a.asyncStorage===de.asyncStorage&&a.mmkv===de.mmkv,[l,s,a]),ge=()=>{n(l.trim()||ce,a,s)},X=()=>{h(e),d(t),b(r)},Y=()=>{h(ce),d(de),b(Oe),o(Oe)},K=(v,G)=>{d(W=>({...W,[v]:G}))},ee=Ee(()=>({defaults:{headerKey:l,showBanner:s,dataNukeSettings:{reactQuery:a.reactQuery,redux:a.redux,asyncStorage:a.asyncStorage,mmkv:a.mmkv}}}),[l,s,a]),S=async()=>{let v=`defaults: {
|
|
2
2
|
headerKey: '${l}',
|
|
3
3
|
showBanner: ${s},
|
|
4
4
|
dataNukeSettings: {
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
asyncStorage: ${a.asyncStorage},
|
|
8
8
|
mmkv: ${a.mmkv},
|
|
9
9
|
},
|
|
10
|
-
},`;try{await Rn(v),f(true),setTimeout(()=>f(false),2e3)}catch{}};return w(gt,{style:u.container,contentContainerStyle:u.contentContainer,children:[x&&g(d,{style:u.actionBar,children:w(d,{style:u.actionBarContent,children:[g(y,{style:u.unsavedText,children:"Unsaved changes"}),w(d,{style:u.actionButtons,children:[w(H,{style:u.discardButton,onPress:X,children:[g(Dt,{size:14,color:m.color.textSecondary}),g(y,{style:u.discardButtonText,children:"Discard"})]}),w(H,{style:u.saveButton,onPress:pe,children:[g(De,{size:14,color:m.color.onAccent}),g(y,{style:u.saveButtonText,children:"Save"})]})]})]})}),g(ie,{title:"Header Configuration",icon:xn,defaultOpen:true,variant:"bordered",children:w(d,{style:u.sectionContent,children:[g(y,{style:u.inputLabel,children:"Header Key"}),g(ht,{style:u.input,value:l,onChangeText:h,placeholder:"x-impersonate-user-id",placeholderTextColor:m.color.placeholder,autoCapitalize:"none",autoCorrect:false}),w(d,{style:u.inputFooter,children:[g(y,{style:u.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),l!==ce&&g(H,{onPress:()=>h(ce),style:u.resetLink,children:g(y,{style:u.resetLinkText,children:"Reset to default"})})]})]})}),g(ie,{title:"Display",icon:Bn,defaultOpen:true,variant:"bordered",children:g(d,{style:u.sectionContent,children:g(d,{style:u.togglesCard,children:g(ue,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:s,onChange:v=>{b(v),o(v)},recommended:true})})})}),g(ie,{title:"Data Clearing",icon:Lt,defaultOpen:true,variant:"bordered",children:w(d,{style:u.sectionContent,children:[g(y,{style:u.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),w(d,{style:u.togglesCard,children:[g(ue,{label:"React Query",description:"Clear query cache and cancel pending queries",value:a.reactQuery,onChange:v=>K("reactQuery",v),recommended:true,detected:i?.reactQuery}),g(d,{style:u.divider}),g(ue,{label:"Redux",description:"Reset Redux store to initial state",value:a.redux,onChange:v=>K("redux",v),recommended:true,detected:i?.redux})]}),w(d,{style:u.advancedSection,children:[g(y,{style:u.advancedLabel,children:"Storage Options"}),w(d,{style:[u.togglesCard,u.dangerousCard],children:[g(ue,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:a.asyncStorage,onChange:v=>K("asyncStorage",v),dangerous:true,detected:i?.asyncStorage}),g(d,{style:u.divider}),g(ue,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:a.mmkv,onChange:v=>K("mmkv",v),dangerous:true,detected:i?.mmkv})]})]}),(a.asyncStorage||a.mmkv)&&w(d,{style:u.warningCard,children:[g(Lt,{size:16,color:m.color.warning}),w(d,{style:u.warningContent,children:[g(y,{style:u.warningTitle,children:"Storage Clearing Enabled"}),g(y,{style:u.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!I&&w(H,{style:u.restoreButton,onPress:Y,children:[g(Tn,{size:14,color:m.color.textSecondary}),g(y,{style:u.restoreButtonText,children:"Restore Defaults"})]}),g(ie,{title:"How It Works",icon:In,defaultOpen:false,variant:"bordered",children:w(d,{style:u.sectionContent,children:[g(y,{style:u.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),g(y,{style:[u.infoText,u.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),w(d,{style:u.codeBlock,children:[g(y,{style:u.codeComment,children:"// Example request header"}),w(y,{style:u.codeText,children:[l||"x-impersonate-user-id",": ",g(y,{style:u.codeValue,children:"user_123"})]})]})]})}),g(ie,{title:"Export Configuration",icon:Nt,defaultOpen:false,variant:"bordered",children:w(d,{style:u.sectionContent,children:[g(y,{style:u.infoText,children:"Copy current settings to use in createImpersonateTool()."}),g(d,{style:u.dataViewerContainer,children:g(Hn,{title:"",data:ee,showTypeFilter:true,rawMode:true,initialExpanded:true})}),g(H,{style:u.copyButton,onPress:S,children:C?w(Ue,{children:[g(De,{size:14,color:le.success}),g(y,{style:[u.copyButtonText,u.copySuccessText],children:"Copied!"})]}):w(Ue,{children:[g(Nt,{size:14,color:m.color.accent}),g(y,{style:u.copyButtonText,children:"Copy Config"})]})})]})})]})}var u=F.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:m.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:m.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:m.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:m.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:m.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:m.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:m.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:m.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:m.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:m.color.surface,borderRadius:10,borderWidth:1,borderColor:m.color.border,padding:4},dangerousCard:{borderColor:m.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:m.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:m.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:m.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:m.color.border,paddingHorizontal:14,fontSize:14,color:m.color.text,fontFamily:Ne},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:m.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:m.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:m.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:m.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:le.success+"15"},detectedBadgeInactive:{backgroundColor:m.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:le.success},detectedTextInactive:{color:m.color.textTertiary},divider:{height:1,backgroundColor:m.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:m.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:m.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:m.color.warning,marginBottom:4},warningText:{fontSize:12,color:m.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:m.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:m.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:m.color.textTertiary,fontFamily:Ne,marginBottom:6},codeText:{fontSize:13,color:m.color.text,fontFamily:Ne},codeValue:{color:m.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:m.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:m.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:m.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:m.color.accent},copySuccessText:{color:le.success}});import{jsx as P,jsxs as Ke}from"react/jsx-runtime";var Pn=Ro,zn=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}],En=[{key:"search",label:"Search"},{key:"history",label:"History"}];function We({visible:e,onClose:t,onBack:r,onMinimize:n,onSearchUsers:o,onClearReactQuery:i,onClearRedux:l,onClearAsyncStorage:h,onClearMMKV:a,showSettingsTab:c=true,inline:s=false}){let b=c?zn:En,[C,f]=xe("search"),[x,I]=xe(false),pe=st(false),[X,Y]=xe(""),K=st(null),{clearCache:ee,isAvailable:S}=Xo(),{resetStore:v,isAvailable:G}=Yo(),{clearStorage:W,isAvailable:we}=rn(),Qt=i??ee??void 0,qt=l??v??void 0,_t=h??W??void 0,Jt={reactQuery:!!i||S,redux:!!l||G,asyncStorage:!!h||we,mmkv:!!a},{isActive:Yt,currentUser:qe,headerKey:Gt,dataNukeSettings:Zt,showBanner:er,searchQuery:tr,searchResults:rr,isSearching:or,searchError:nr,searchUsers:_e,startImpersonation:Je,stopImpersonation:Ye,updateHeaderKey:Ge,updateDataNukeSettings:Ze,updateShowBanner:Ce,history:ar,removeFromHistory:sr,clearHistory:ir}=It({onSearchUsers:o,onClearReactQuery:Qt,onClearRedux:qt,onClearAsyncStorage:_t,onClearMMKV:a});it(()=>{x&&K.current&&setTimeout(()=>{K.current?.focus()},100)},[x]),it(()=>{!c&&C==="settings"&&f("search")},[c,C]);let lr=te(_=>{Y(_)},[]),cr=te(()=>{X.trim()&&_e(X.trim()),I(false)},[X,_e]),et=te(async _=>{await Je(_)},[Je]),dr=te(async(_,hr,gr)=>{await Ge(_),await Ze(hr),await Ce(gr)},[Ge,Ze,Ce]),ur=te(_=>{f(_),I(false)},[]),tt=()=>Ke(oe,{children:[r&&P(oe.Navigation,{onBack:r}),P(oe.Content,{title:"",children:x?P(oe.Search,{value:X,onChangeText:lr,onCancel:()=>{Y(""),I(false)},onDismiss:()=>I(false),dismissOnBlur:true,placeholder:"Search by email, name, or ID...",iconSize:14,testID:"buoy-impersonate-search-input",inputProps:{onSubmitEditing:cr}}):P(Ao,{tabs:b,activeTab:C,onTabChange:ur})}),P(oe.Actions,{children:C==="search"&&!x&&P(H,{testID:"buoy-impersonate-search-toggle",onPress:()=>I(true),style:be.headerActionButton,children:P(Po,{size:14,color:yt.color.textSecondary})})})]});if(!e)return null;let rt=Ke(d,{style:be.container,children:[C==="search"&&P(Pt,{currentUser:qe,isActive:Yt,searchQuery:tr,searchResults:rr,isSearching:or,searchError:nr,onSelectUser:et,onStopImpersonation:Ye,searchAvailable:!!o}),C==="history"&&P(Et,{history:ar,currentUserId:qe?.id??null,onSelectUser:et,onStopImpersonation:Ye,onRemoveFromHistory:sr,onClearHistory:ir}),C==="settings"&&P(Ut,{headerKey:Gt,settings:Zt,showBanner:er,onSave:dr,onShowBannerChange:Ce,detectionStatus:Jt})]});return s?P(ft,{children:Ke(d,{style:be.inlineRoot,children:[P(d,{style:be.inlineHeader,...zo,children:tt()}),rt]})}):P(ft,{children:P(Pn,{visible:e,onClose:t,onMinimize:n,header:{showToggleButton:true,customContent:tt()},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:rt})})}function Ln(e){return P(We,{...e,inline:true,visible:true,onClose:()=>{}})}var be=F.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ho.border,backgroundColor:"transparent"},container:{flex:1},headerActionButton:{width:28,height:28,borderRadius:6,backgroundColor:yt.color.buttonSurface,justifyContent:"center",alignItems:"center"}});import{useSyncExternalStore as Ot}from"react";import{buoyColors as Se,X as Dn,PowerToggleButton as Nn}from"@buoy-gg/shared-ui/web";import{jsx as q,jsxs as Fe}from"react/jsx-runtime";function Me({onPress:e,onStopPress:t,position:r="top",offset:n=50}){let o=Ot(p.subscribe,p.getSnapshot,p.getSnapshot);if(!o.isActive||!o.currentUser||!o.showBanner)return null;let i=async()=>{console.log("[Buoy]","[impersonate] banner pause/resume pressed"),o.isPaused?await p.resumeImpersonation():await p.pauseImpersonation()},l=o.currentUser.displayName||o.currentUser.email||o.currentUser.id,h=r==="top"?{top:n}:{bottom:n},a=async()=>{console.log("[Buoy]","[impersonate] banner STOP pressed"),await p.stopImpersonation()};return q(d,{style:[V.container,h],children:Fe(d,{style:V.banner,children:[Fe(H,{style:V.userSection,onPress:e,activeOpacity:.7,children:[q(ze,{userId:o.currentUser.id,name:l,size:"small",showActiveIndicator:false}),q(y,{style:[V.userName,o.isPaused&&V.userNamePaused],numberOfLines:1,children:l})]}),q(Nn,{isEnabled:!o.isPaused,onToggle:i,size:"small",accessibilityLabel:"Toggle impersonation"}),q(H,{style:V.closeButton,onPress:a,activeOpacity:.7,children:q(Dn,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]})})}function Un({onPress:e}){let t=Ot(p.subscribe,p.getSnapshot,p.getSnapshot);return!t.isActive||!t.currentUser?null:Fe(H,{style:V.minimalBanner,onPress:e,activeOpacity:.8,children:[q(d,{style:V.minimalDot}),q(y,{style:V.minimalText,children:"IMP"})]})}var V=F.create({container:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999,pointerEvents:"box-none"},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:Se.success+"40",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},userSection:{flexDirection:"row",alignItems:"center",gap:10},userName:{fontSize:14,fontWeight:"600",color:"#fff",maxWidth:180},userNamePaused:{opacity:.6},closeButton:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},minimalBanner:{position:"absolute",top:60,right:16,flexDirection:"row",alignItems:"center",backgroundColor:"rgba(26, 26, 26, 0.92)",borderWidth:1,borderColor:Se.success+"35",borderRadius:12,paddingVertical:5,paddingHorizontal:10,gap:5,zIndex:9999,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.2,shadowRadius:6,elevation:4},minimalDot:{width:6,height:6,borderRadius:3,backgroundColor:Se.success},minimalText:{fontSize:10,fontWeight:"700",color:Se.success,letterSpacing:.5}});import{hasAccountAccess as On,isOverWireBudget as Kn}from"@buoy-gg/shared-ui/web";var je=null;function Wn(e){je=e}var Ve=2*1024,Fn=16*1024,Kt=Object.freeze({__buoyOmitted:"user-metadata",note:"User metadata stays on the device."});function Mn(e){if(!e)return e;if(e.startsWith("data:")){let t=e.indexOf(",");return`${t>=0?e.slice(0,Math.min(t+1,64)):"data:"}[${e.length} chars]`}return e.length<=Ve?e:`${e.slice(0,Ve)}\u2026 [${e.length-Ve} more]`}function jn(e){if(!e)return e;let t=typeof e.role=="string"?e.role:void 0;return Kn(e,Fn)?t?{role:t,...Kt}:{...Kt}:e}function $e(e){return{...e,avatarUrl:Mn(e.avatarUrl),metadata:jn(e.metadata)}}function Wt(e){return{...e,currentUser:e.currentUser?$e(e.currentUser):null,history:e.history.map(t=>({...t,user:$e(t.user)}))}}var Xe=new Map;function Ft(e){for(let t of e)t&&typeof t=="object"&&t.id&&Xe.set(String(t.id),t)}function Vn(e){let t=Xe.get(e);if(t)return t;let r=p.getState();return r.currentUser?.id===e?r.currentUser:r.history.find(n=>n.user.id===e)?.user}function Mt(e){if(!e||typeof e!="object"||!e.id)return false;if(Xe.has(String(e.id)))return true;let t=p.getState();return t.currentUser?.id===e.id?true:t.history.some(r=>r.user.id===e.id)}async function $n(e,t){let r=k(t.userId),n=r??k(t.user?.id),o=(k(t.email)??k(t.user?.email))?.toLowerCase(),i=[k(t.user?.name),k(t.user?.displayName),k(t.query)].map(f=>f?.toLowerCase()).filter(f=>!!f),l=[o,n,k(t.query),k(t.user?.name),k(t.user?.displayName)].filter((f,x,I)=>!!f&&I.indexOf(f)===x),h=new Map;for(let f of l){let x;try{x=await e(f)}catch{continue}if(Array.isArray(x)){Ft(x);for(let I of x)I?.id&&h.set(String(I.id),I)}}let a=[...h.values()],c=f=>k(f.email)?.toLowerCase(),s=n?a.filter(f=>String(f.id)===n):[],b=o?a.filter(f=>c(f)===o):[];if(s.length===1&&b.length&&b[0].id!==s[0].id)throw new Error(`The id ${n} and the email ${o} belong to different users. Pass one of them.`);if(s.length===1)return s[0];if(r)return;if(b.length===1)return b[0];if(n||o)return;let C=a.filter(f=>{let x=f;return[k(x.displayName),k(x.name)].some(I=>I&&i.includes(I.toLowerCase()))});if(C.length>1)throw new Error(`${C.length} users are named that (${C.map(f=>f.id).join(", ")}). Pass the user's id or email.`);return C[0]}function k(e){return typeof e=="string"&&e.trim()?e.trim():typeof e=="number"?String(e):void 0}function jt(e){return{searchUsers:async t=>{let r=String(t?.query??""),n=await e(r);return Array.isArray(n)&&Ft(n),Array.isArray(n)?n.map($e):n},startImpersonation:async t=>{let r=t??{},n=r.user,o=k(r.userId),i=k(n?.id);if(o&&i&&o!==i)throw new Error(`userId ${o} and user.id ${i} are different users. Pass one of them.`);let l=k(r.email)?.toLowerCase(),h=k(n?.email)?.toLowerCase();if(l&&h&&l!==h)throw new Error(`email ${l} and user.email ${h} are different users. Pass one of them.`);let a;if(n?.id&&Mt(n)&&r.userId===void 0&&r.email===void 0?a=Vn(String(n.id)):a=await $n(e,r),!a||!Mt(a))throw new Error("That user isn't in this app's directory. Call searchUsers and impersonate one of its results \u2014 a user object that didn't come from search impersonates nobody.");let c=(k(r.email)??k(n?.email))?.toLowerCase(),s=k(a.email)?.toLowerCase();if(c&&s&&c!==s)throw new Error(`User ${a.id} has a different email than ${c}. Pass the id or the email of one user.`);return await p.startImpersonation(a),{ok:true,userId:a.id}},stopImpersonation:()=>p.stopImpersonation(),pauseImpersonation:()=>p.pauseImpersonation(),resumeImpersonation:()=>p.resumeImpersonation(),updateSettings:t=>{let r=t??{},n=r.settings??(["headerKey","ignorePatterns","showBanner","dataNukeSettings"].some(o=>o in r)?r:void 0);if(!n)throw new Error("updateSettings needs { settings: { headerKey?, ignorePatterns?, showBanner?, dataNukeSettings? } }.");return p.updateSettings(n)},removeFromHistory:t=>p.removeFromHistory(t.userId),clearHistory:()=>p.clearHistory()}}function Xn({onSearchUsers:e}){return{version:1,getSnapshot:()=>Wt(p.getState()),subscribe:t=>p.subscribe(t),actions:jt(e)}}var Qn={dispose:()=>{On()||p.disposeAccountSession()},version:1,getSnapshot:()=>Wt(p.getState()),subscribe:e=>p.subscribe(e),actions:jt(e=>{if(!je)throw new Error("No onSearchUsers configured \u2014 pass it to createImpersonateTool()");return je(e)})};import{ImpersonateIcon as Vt,IMPERSONATE_ICON_COLOR as qn}from"@buoy-gg/shared-ui/web";import{jsx as $t}from"react/jsx-runtime";var Xt=false;async function _n(){if(!(typeof window>"u"||Xt)){Xt=true,console.log("[Buoy]","[impersonate] bootstrap: start"),O().isListening||O().startListening();try{let e=vr();if(!e||typeof e.getItem!="function"){console.warn("[Buoy]","[impersonate] bootstrap: AsyncStorage shape unexpected",Object.keys(e??{}));return}let t={getItem:r=>e.getItem(r),setItem:(r,n)=>e.setItem(r,n)};p.setAsyncStorage(t),console.log("[Buoy]","[impersonate] bootstrap: AsyncStorage adapter installed"),await p.initializeAsync(t),console.log("[Buoy]","[impersonate] bootstrap: initializeAsync done")}catch(e){console.warn("[Buoy]","[impersonate] bootstrap: failed",e)}}}function Jn(e){let{id:t="impersonate",name:r="IMPERSONATE",description:n="User impersonation for admin testing",defaults:o,showSettingsTab:i=true,onSearchUsers:l,onClearReactQuery:h,onClearRedux:a,onClearAsyncStorage:c,onClearMMKV:s}=e;return o&&p.setDeveloperDefaults(o),Wn(l??null),_n(),{id:t,name:r,description:n,slot:"both",icon:({size:b,slot:C})=>$t(Vt,{size:C==="dial"?b*1.5:b,color:qn}),component:b=>$t(We,{...b,onSearchUsers:l,onClearReactQuery:h,onClearRedux:a,onClearAsyncStorage:c,onClearMMKV:s,showSettingsTab:i}),props:{enableSharedModalDimensions:false},Banner:Me}}import{jsx as Yn}from"react/jsx-runtime";function Gn(){return Yn(Me,{position:"top",offset:50})}import{buoyColors as he,night as ge,X as Zn}from"@buoy-gg/shared-ui/web";import{jsx as J,jsxs as ve}from"react/jsx-runtime";function ea({user:e,onStopImpersonation:t}){let r=e.displayName||e.email||e.id;return ve(d,{style:$.container,children:[ve(d,{style:$.userSection,children:[J(ze,{userId:e.id,name:r,size:"small",showActiveIndicator:false}),J(d,{style:$.userInfo,children:J(y,{style:$.userName,numberOfLines:1,children:r})})]}),ve(d,{style:$.statusPill,children:[J(d,{style:$.pulseDot}),J(y,{style:$.statusText,children:"Active"})]}),ve(H,{style:$.stopButton,onPress:t,activeOpacity:.7,children:[J(Zn,{size:12,color:ge.color.danger}),J(y,{style:$.stopButtonText,children:"Stop"})]})]})}var $=F.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,paddingHorizontal:16,backgroundColor:he.success+"10",borderBottomWidth:1,borderBottomColor:he.success+"25",gap:12},userSection:{flexDirection:"row",alignItems:"center",flex:1,gap:10,minWidth:0},userInfo:{flex:1,minWidth:0},userName:{fontSize:14,fontWeight:"600",color:ge.color.text},statusPill:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:he.success+"20",paddingHorizontal:10,paddingVertical:5,borderRadius:12},pulseDot:{width:6,height:6,borderRadius:3,backgroundColor:he.success},statusText:{fontSize:11,fontWeight:"600",color:he.success,textTransform:"uppercase",letterSpacing:.5},stopButton:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:12,paddingVertical:6,backgroundColor:ge.color.dangerSoft,borderRadius:6,borderWidth:1,borderColor:ge.color.danger+"30"},stopButtonText:{fontSize:12,fontWeight:"600",color:ge.color.danger}});import{useCallback as Qe,useSyncExternalStore as ta}from"react";function ra(){let e=ta(p.subscribe,p.getSnapshot,p.getSnapshot),t=Qe(async o=>{await p.quickSwitch(o)},[]),r=Qe(async o=>{await p.removeFromHistory(o)},[]),n=Qe(async()=>{await p.clearHistory()},[]);return{history:e.history,currentUserId:e.currentUser?.id??null,quickSwitch:t,removeFromHistory:r,clearHistory:n}}export{Ut as DataNukeSettingsComponent,Me as ImpersonateBanner,Un as ImpersonateBannerMinimal,Et as ImpersonateHistoryList,Vt as ImpersonateIcon,We as ImpersonateModal,Gn as ImpersonateOverlay,ea as ImpersonateStatusBar,Ln as ImpersonateToolView,Pt as UserSearchView,Xn as createImpersonateSyncAdapter,Jn as createImpersonateTool,Fo as getImpersonatedUserId,O as impersonateListener,p as impersonateStore,Qn as impersonateSyncAdapter,Wo as isImpersonating,wt as setImpersonateConfig,Oo as startImpersonateListener,Ko as stopImpersonateListener,It as useImpersonate,ra as useImpersonateHistory};
|
|
10
|
+
},`;try{await Rn(v),f(true),setTimeout(()=>f(false),2e3)}catch{}};return w(pt,{testID:"buoy-impersonate-settings-scroll",style:u.container,contentContainerStyle:u.contentContainer,children:[x&&p(c,{style:u.actionBar,children:w(c,{style:u.actionBarContent,children:[p(y,{style:u.unsavedText,children:"Unsaved changes"}),w(c,{style:u.actionButtons,children:[w(H,{testID:"buoy-impersonate-discard",style:u.discardButton,onPress:X,children:[p(Lt,{size:14,color:m.color.textSecondary}),p(y,{style:u.discardButtonText,children:"Discard"})]}),w(H,{testID:"buoy-impersonate-save",style:u.saveButton,onPress:ge,children:[p(Le,{size:14,color:m.color.onAccent}),p(y,{style:u.saveButtonText,children:"Save"})]})]})]})}),p(ie,{title:"Header Configuration",icon:xn,defaultOpen:true,variant:"bordered",children:w(c,{style:u.sectionContent,children:[p(y,{style:u.inputLabel,children:"Header Key"}),p(ht,{testID:"buoy-impersonate-header-key",style:u.input,value:l,onChangeText:h,placeholder:"x-impersonate-user-id",placeholderTextColor:m.color.placeholder,autoCapitalize:"none",autoCorrect:false}),w(c,{style:u.inputFooter,children:[p(y,{style:u.helperText,children:"The HTTP header key used for impersonation. Value will be the user ID."}),l!==ce&&p(H,{onPress:()=>h(ce),style:u.resetLink,children:p(y,{style:u.resetLinkText,children:"Reset to default"})})]})]})}),p(ie,{title:"Display",icon:Bn,defaultOpen:true,variant:"bordered",children:p(c,{style:u.sectionContent,children:p(c,{style:u.togglesCard,children:p(ue,{label:"Floating Banner",description:"Show a floating banner when impersonation is active",value:s,onChange:v=>{b(v),o(v)},recommended:true,testID:"buoy-impersonate-show-banner"})})})}),p(ie,{title:"Data Clearing",icon:Et,defaultOpen:true,variant:"bordered",children:w(c,{style:u.sectionContent,children:[p(y,{style:u.sectionDescription,children:"Choose what data to clear when impersonation starts or stops. This ensures you see fresh data for the impersonated user."}),w(c,{style:u.togglesCard,children:[p(ue,{label:"React Query",description:"Clear query cache and cancel pending queries",value:a.reactQuery,onChange:v=>K("reactQuery",v),recommended:true,detected:i?.reactQuery}),p(c,{style:u.divider}),p(ue,{label:"Redux",description:"Reset Redux store to initial state",value:a.redux,onChange:v=>K("redux",v),recommended:true,detected:i?.redux})]}),w(c,{style:u.advancedSection,children:[p(y,{style:u.advancedLabel,children:"Storage Options"}),w(c,{style:[u.togglesCard,u.dangerousCard],children:[p(ue,{label:"AsyncStorage",description:"Clear app data (preserves @buoy/* keys)",value:a.asyncStorage,onChange:v=>K("asyncStorage",v),dangerous:true,detected:i?.asyncStorage}),p(c,{style:u.divider}),p(ue,{label:"MMKV",description:"Clear MMKV storage (preserves @buoy/* keys)",value:a.mmkv,onChange:v=>K("mmkv",v),dangerous:true,detected:i?.mmkv})]})]}),(a.asyncStorage||a.mmkv)&&w(c,{style:u.warningCard,children:[p(Et,{size:16,color:m.color.warning}),w(c,{style:u.warningContent,children:[p(y,{style:u.warningTitle,children:"Storage Clearing Enabled"}),p(y,{style:u.warningText,children:"This will remove app data like settings and cached content. Auth tokens managed by @buoy/* are preserved."})]})]})]})}),!I&&w(H,{testID:"buoy-impersonate-restore-defaults",style:u.restoreButton,onPress:Y,children:[p(Tn,{size:14,color:m.color.textSecondary}),p(y,{style:u.restoreButtonText,children:"Restore Defaults"})]}),p(ie,{title:"How It Works",icon:In,defaultOpen:false,variant:"bordered",children:w(c,{style:u.sectionContent,children:[p(y,{style:u.infoText,children:"When impersonation is enabled, the configured header is automatically added to all outgoing fetch and XMLHttpRequest calls."}),p(y,{style:[u.infoText,u.infoTextSpaced],children:"Your backend should check for this header and return data for the specified user ID instead of the authenticated user."}),w(c,{style:u.codeBlock,children:[p(y,{style:u.codeComment,children:"// Example request header"}),w(y,{style:u.codeText,children:[l||"x-impersonate-user-id",": ",p(y,{style:u.codeValue,children:"user_123"})]})]})]})}),p(ie,{title:"Export Configuration",icon:Nt,defaultOpen:false,variant:"bordered",children:w(c,{style:u.sectionContent,children:[p(y,{style:u.infoText,children:"Copy current settings to use in createImpersonateTool()."}),p(c,{style:u.dataViewerContainer,children:p(Hn,{title:"",data:ee,showTypeFilter:true,rawMode:true,initialExpanded:true})}),p(H,{style:u.copyButton,onPress:S,children:C?w(Ue,{children:[p(Le,{size:14,color:le.success}),p(y,{style:[u.copyButtonText,u.copySuccessText],children:"Copied!"})]}):w(Ue,{children:[p(Nt,{size:14,color:m.color.accent}),p(y,{style:u.copyButtonText,children:"Copy Config"})]})})]})})]})}var u=F.create({container:{flex:1},contentContainer:{padding:16,gap:12,paddingBottom:32},actionBar:{backgroundColor:m.color.accentSoft,borderRadius:10,borderWidth:1,borderColor:m.color.accentBorder,padding:12},actionBarContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},unsavedText:{fontSize:13,fontWeight:"500",color:m.color.accent},actionButtons:{flexDirection:"row",gap:8},saveButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.accent,paddingHorizontal:14,paddingVertical:8,borderRadius:6},saveButtonText:{fontSize:13,fontWeight:"600",color:m.color.onAccent},discardButton:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:m.color.surfaceElevated,paddingHorizontal:14,paddingVertical:8,borderRadius:6,borderWidth:1,borderColor:m.color.border},discardButtonText:{fontSize:13,fontWeight:"500",color:m.color.textSecondary},restoreButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,paddingVertical:12,borderRadius:8,borderWidth:1,borderColor:m.color.border,borderStyle:"dashed"},restoreButtonText:{fontSize:13,color:m.color.textSecondary},sectionContent:{paddingTop:8},sectionDescription:{fontSize:13,color:m.color.textSecondary,lineHeight:18,marginBottom:14},togglesCard:{backgroundColor:m.color.surface,borderRadius:10,borderWidth:1,borderColor:m.color.border,padding:4},dangerousCard:{borderColor:m.color.warning+"30"},advancedSection:{marginTop:16},advancedLabel:{fontSize:11,fontWeight:"600",color:m.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8,marginLeft:2},inputLabel:{fontSize:12,fontWeight:"600",color:m.color.textSecondary,marginBottom:8},input:{height:42,backgroundColor:m.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:m.color.border,paddingHorizontal:14,fontSize:14,color:m.color.text,fontFamily:Ne},inputFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-start",marginTop:8,gap:12},helperText:{flex:1,fontSize:12,color:m.color.textTertiary,lineHeight:16},resetLink:{paddingVertical:2},resetLinkText:{fontSize:12,color:m.color.accent,fontWeight:"500"},recommendedBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:m.color.accentSoft,paddingHorizontal:8,paddingVertical:3,borderRadius:4},recommendedText:{fontSize:10,fontWeight:"600",color:m.color.accent},detectedBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4},detectedBadgeActive:{backgroundColor:le.success+"15"},detectedBadgeInactive:{backgroundColor:m.color.textTertiary+"15"},detectedText:{fontSize:10,fontWeight:"600"},detectedTextActive:{color:le.success},detectedTextInactive:{color:m.color.textTertiary},divider:{height:1,backgroundColor:m.color.separator,marginHorizontal:12},warningCard:{marginTop:14,flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:m.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:m.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:13,fontWeight:"600",color:m.color.warning,marginBottom:4},warningText:{fontSize:12,color:m.color.textSecondary,lineHeight:17},infoText:{fontSize:13,color:m.color.textSecondary,lineHeight:19},infoTextSpaced:{marginTop:10},codeBlock:{marginTop:14,backgroundColor:m.color.bg,borderRadius:8,padding:14},codeComment:{fontSize:12,color:m.color.textTertiary,fontFamily:Ne,marginBottom:6},codeText:{fontSize:13,color:m.color.text,fontFamily:Ne},codeValue:{color:m.color.accent},dataViewerContainer:{marginTop:12,borderRadius:8,overflow:"hidden",borderWidth:1,borderColor:m.color.border},copyButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,marginTop:14,backgroundColor:m.color.accentSoft,paddingVertical:10,paddingHorizontal:16,borderRadius:8,borderWidth:1,borderColor:m.color.accentBorder},copyButtonText:{fontSize:13,fontWeight:"600",color:m.color.accent},copySuccessText:{color:le.success}});import{jsx as P,jsxs as Ke}from"react/jsx-runtime";var Pn=Ro,Dn=[{key:"search",label:"Search"},{key:"history",label:"History"},{key:"settings",label:"Settings"}],zn=[{key:"search",label:"Search"},{key:"history",label:"History"}];function We({visible:e,onClose:t,onBack:r,onMinimize:n,onSearchUsers:o,onClearReactQuery:i,onClearRedux:l,onClearAsyncStorage:h,onClearMMKV:a,showSettingsTab:d=true,inline:s=false}){let b=d?Dn:zn,[C,f]=xe("search"),[x,I]=xe(false),ge=st(false),[X,Y]=xe(""),K=st(null),{clearCache:ee,isAvailable:S}=Xo(),{resetStore:v,isAvailable:G}=Yo(),{clearStorage:W,isAvailable:we}=rn(),Qt=i??ee??void 0,qt=l??v??void 0,_t=h??W??void 0,Jt={reactQuery:!!i||S,redux:!!l||G,asyncStorage:!!h||we,mmkv:!!a},{isActive:Yt,currentUser:qe,headerKey:Gt,dataNukeSettings:Zt,showBanner:er,searchQuery:tr,searchResults:rr,isSearching:or,searchError:nr,searchUsers:_e,startImpersonation:Je,stopImpersonation:Ye,updateHeaderKey:Ge,updateDataNukeSettings:Ze,updateShowBanner:Ce,history:ar,removeFromHistory:sr,clearHistory:ir}=It({onSearchUsers:o,onClearReactQuery:Qt,onClearRedux:qt,onClearAsyncStorage:_t,onClearMMKV:a});it(()=>{x&&K.current&&setTimeout(()=>{K.current?.focus()},100)},[x]),it(()=>{!d&&C==="settings"&&f("search")},[d,C]);let lr=te(_=>{Y(_)},[]),cr=te(()=>{X.trim()&&_e(X.trim()),I(false)},[X,_e]),et=te(async _=>{await Je(_)},[Je]),dr=te(async(_,hr,pr)=>{await Ge(_),await Ze(hr),await Ce(pr)},[Ge,Ze,Ce]),ur=te(_=>{f(_),I(false)},[]),tt=()=>Ke(oe,{children:[r&&P(oe.Navigation,{onBack:r}),P(oe.Content,{title:"",children:x?P(oe.Search,{value:X,onChangeText:lr,onCancel:()=>{Y(""),I(false)},onDismiss:()=>I(false),dismissOnBlur:true,placeholder:"Search by email, name, or ID...",iconSize:14,testID:"buoy-impersonate-search-input",inputProps:{onSubmitEditing:cr}}):P(Ao,{tabs:b,activeTab:C,onTabChange:ur,testIDPrefix:"buoy-impersonate-tab"})}),P(oe.Actions,{children:C==="search"&&!x&&P(H,{testID:"buoy-impersonate-search-toggle",onPress:()=>I(true),style:be.headerActionButton,children:P(Po,{size:14,color:yt.color.textSecondary})})})]});if(!e)return null;let rt=Ke(c,{style:be.container,children:[C==="search"&&P(Pt,{currentUser:qe,isActive:Yt,searchQuery:tr,searchResults:rr,isSearching:or,searchError:nr,onSelectUser:et,onStopImpersonation:Ye,searchAvailable:!!o}),C==="history"&&P(zt,{history:ar,currentUserId:qe?.id??null,onSelectUser:et,onStopImpersonation:Ye,onRemoveFromHistory:sr,onClearHistory:ir}),C==="settings"&&P(Ut,{headerKey:Gt,settings:Zt,showBanner:er,onSave:dr,onShowBannerChange:Ce,detectionStatus:Jt})]});return s?P(ft,{children:Ke(c,{style:be.inlineRoot,children:[P(c,{style:be.inlineHeader,...Do,children:tt()}),rt]})}):P(ft,{children:P(Pn,{visible:e,onClose:t,onMinimize:n,header:{showToggleButton:true,customContent:tt()},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:rt})})}function En(e){return P(We,{...e,inline:true,visible:true,onClose:()=>{}})}var be=F.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ho.border,backgroundColor:"transparent"},container:{flex:1},headerActionButton:{width:28,height:28,borderRadius:6,backgroundColor:yt.color.buttonSurface,justifyContent:"center",alignItems:"center"}});import{useSyncExternalStore as Ot}from"react";import{buoyColors as Se,X as Ln,PowerToggleButton as Nn}from"@buoy-gg/shared-ui/web";import{jsx as q,jsxs as Fe}from"react/jsx-runtime";function Me({onPress:e,onStopPress:t,position:r="top",offset:n=50}){let o=Ot(g.subscribe,g.getSnapshot,g.getSnapshot);if(!o.isActive||!o.currentUser||!o.showBanner)return null;let i=async()=>{console.log("[Buoy]","[impersonate] banner pause/resume pressed"),o.isPaused?await g.resumeImpersonation():await g.pauseImpersonation()},l=o.currentUser.displayName||o.currentUser.email||o.currentUser.id,h=r==="top"?{top:n}:{bottom:n},a=async()=>{console.log("[Buoy]","[impersonate] banner STOP pressed"),await g.stopImpersonation()};return q(c,{style:[V.container,h],children:Fe(c,{testID:"buoy-impersonate-banner",style:V.banner,children:[Fe(H,{testID:"buoy-impersonate-banner-open",style:V.userSection,onPress:e,activeOpacity:.7,children:[q(De,{userId:o.currentUser.id,name:l,size:"small",showActiveIndicator:false}),q(y,{style:[V.userName,o.isPaused&&V.userNamePaused],numberOfLines:1,children:l})]}),q(Nn,{isEnabled:!o.isPaused,onToggle:i,size:"small",accessibilityLabel:"Toggle impersonation",testID:"buoy-impersonate-banner-toggle"}),q(H,{testID:"buoy-impersonate-banner-stop",accessibilityLabel:"Stop impersonating",style:V.closeButton,onPress:a,activeOpacity:.7,children:q(Ln,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]})})}function Un({onPress:e}){let t=Ot(g.subscribe,g.getSnapshot,g.getSnapshot);return!t.isActive||!t.currentUser?null:Fe(H,{style:V.minimalBanner,onPress:e,activeOpacity:.8,children:[q(c,{style:V.minimalDot}),q(y,{style:V.minimalText,children:"IMP"})]})}var V=F.create({container:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999,pointerEvents:"box-none"},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:Se.success+"40",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},userSection:{flexDirection:"row",alignItems:"center",gap:10},userName:{fontSize:14,fontWeight:"600",color:"#fff",maxWidth:180},userNamePaused:{opacity:.6},closeButton:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},minimalBanner:{position:"absolute",top:60,right:16,flexDirection:"row",alignItems:"center",backgroundColor:"rgba(26, 26, 26, 0.92)",borderWidth:1,borderColor:Se.success+"35",borderRadius:12,paddingVertical:5,paddingHorizontal:10,gap:5,zIndex:9999,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.2,shadowRadius:6,elevation:4},minimalDot:{width:6,height:6,borderRadius:3,backgroundColor:Se.success},minimalText:{fontSize:10,fontWeight:"700",color:Se.success,letterSpacing:.5}});import{hasAccountAccess as On,isOverWireBudget as Kn}from"@buoy-gg/shared-ui/web";var je=null;function Wn(e){je=e}var Ve=2*1024,Fn=16*1024,Kt=Object.freeze({__buoyOmitted:"user-metadata",note:"User metadata stays on the device."});function Mn(e){if(!e)return e;if(e.startsWith("data:")){let t=e.indexOf(",");return`${t>=0?e.slice(0,Math.min(t+1,64)):"data:"}[${e.length} chars]`}return e.length<=Ve?e:`${e.slice(0,Ve)}\u2026 [${e.length-Ve} more]`}function jn(e){if(!e)return e;let t=typeof e.role=="string"?e.role:void 0;return Kn(e,Fn)?t?{role:t,...Kt}:{...Kt}:e}function $e(e){return{...e,avatarUrl:Mn(e.avatarUrl),metadata:jn(e.metadata)}}function Wt(e){return{...e,currentUser:e.currentUser?$e(e.currentUser):null,history:e.history.map(t=>({...t,user:$e(t.user)}))}}var Xe=new Map;function Ft(e){for(let t of e)t&&typeof t=="object"&&t.id&&Xe.set(String(t.id),t)}function Vn(e){let t=Xe.get(e);if(t)return t;let r=g.getState();return r.currentUser?.id===e?r.currentUser:r.history.find(n=>n.user.id===e)?.user}function Mt(e){if(!e||typeof e!="object"||!e.id)return false;if(Xe.has(String(e.id)))return true;let t=g.getState();return t.currentUser?.id===e.id?true:t.history.some(r=>r.user.id===e.id)}async function $n(e,t){let r=T(t.userId),n=r??T(t.user?.id),o=(T(t.email)??T(t.user?.email))?.toLowerCase(),i=[T(t.user?.name),T(t.user?.displayName),T(t.query)].map(f=>f?.toLowerCase()).filter(f=>!!f),l=[o,n,T(t.query),T(t.user?.name),T(t.user?.displayName)].filter((f,x,I)=>!!f&&I.indexOf(f)===x),h=new Map;for(let f of l){let x;try{x=await e(f)}catch{continue}if(Array.isArray(x)){Ft(x);for(let I of x)I?.id&&h.set(String(I.id),I)}}let a=[...h.values()],d=f=>T(f.email)?.toLowerCase(),s=n?a.filter(f=>String(f.id)===n):[],b=o?a.filter(f=>d(f)===o):[];if(s.length===1&&b.length&&b[0].id!==s[0].id)throw new Error(`The id ${n} and the email ${o} belong to different users. Pass one of them.`);if(s.length===1)return s[0];if(r)return;if(b.length===1)return b[0];if(n||o)return;let C=a.filter(f=>{let x=f;return[T(x.displayName),T(x.name)].some(I=>I&&i.includes(I.toLowerCase()))});if(C.length>1)throw new Error(`${C.length} users are named that (${C.map(f=>f.id).join(", ")}). Pass the user's id or email.`);return C[0]}function T(e){return typeof e=="string"&&e.trim()?e.trim():typeof e=="number"?String(e):void 0}function jt(e){return{searchUsers:async t=>{let r=String(t?.query??""),n=await e(r);return Array.isArray(n)&&Ft(n),Array.isArray(n)?n.map($e):n},startImpersonation:async t=>{let r=t??{},n=r.user,o=T(r.userId),i=T(n?.id);if(o&&i&&o!==i)throw new Error(`userId ${o} and user.id ${i} are different users. Pass one of them.`);let l=T(r.email)?.toLowerCase(),h=T(n?.email)?.toLowerCase();if(l&&h&&l!==h)throw new Error(`email ${l} and user.email ${h} are different users. Pass one of them.`);let a;if(n?.id&&Mt(n)&&r.userId===void 0&&r.email===void 0?a=Vn(String(n.id)):a=await $n(e,r),!a||!Mt(a))throw new Error("That user isn't in this app's directory. Call searchUsers and impersonate one of its results \u2014 a user object that didn't come from search impersonates nobody.");let d=(T(r.email)??T(n?.email))?.toLowerCase(),s=T(a.email)?.toLowerCase();if(d&&s&&d!==s)throw new Error(`User ${a.id} has a different email than ${d}. Pass the id or the email of one user.`);return await g.startImpersonation(a),{ok:true,userId:a.id}},stopImpersonation:()=>g.stopImpersonation(),pauseImpersonation:()=>g.pauseImpersonation(),resumeImpersonation:()=>g.resumeImpersonation(),updateSettings:t=>{let r=t??{},n=r.settings??(["headerKey","ignorePatterns","showBanner","dataNukeSettings"].some(o=>o in r)?r:void 0);if(!n)throw new Error("updateSettings needs { settings: { headerKey?, ignorePatterns?, showBanner?, dataNukeSettings? } }.");return g.updateSettings(n)},removeFromHistory:t=>g.removeFromHistory(t.userId),clearHistory:()=>g.clearHistory()}}function Xn({onSearchUsers:e}){return{version:1,getSnapshot:()=>Wt(g.getState()),subscribe:t=>g.subscribe(t),actions:jt(e)}}var Qn={dispose:()=>{On()||g.disposeAccountSession()},version:1,getSnapshot:()=>Wt(g.getState()),subscribe:e=>g.subscribe(e),actions:jt(e=>{if(!je)throw new Error("No onSearchUsers configured \u2014 pass it to createImpersonateTool()");return je(e)})};import{ImpersonateIcon as Vt,IMPERSONATE_ICON_COLOR as qn}from"@buoy-gg/shared-ui/web";import{jsx as $t}from"react/jsx-runtime";var Xt=false;async function _n(){if(!(typeof window>"u"||Xt)){Xt=true,console.log("[Buoy]","[impersonate] bootstrap: start"),O().isListening||O().startListening();try{let e=vr();if(!e||typeof e.getItem!="function"){console.warn("[Buoy]","[impersonate] bootstrap: AsyncStorage shape unexpected",Object.keys(e??{}));return}let t={getItem:r=>e.getItem(r),setItem:(r,n)=>e.setItem(r,n)};g.setAsyncStorage(t),console.log("[Buoy]","[impersonate] bootstrap: AsyncStorage adapter installed"),await g.initializeAsync(t),console.log("[Buoy]","[impersonate] bootstrap: initializeAsync done")}catch(e){console.warn("[Buoy]","[impersonate] bootstrap: failed",e)}}}function Jn(e){let{id:t="impersonate",name:r="IMPERSONATE",description:n="User impersonation for admin testing",defaults:o,showSettingsTab:i=true,onSearchUsers:l,onClearReactQuery:h,onClearRedux:a,onClearAsyncStorage:d,onClearMMKV:s}=e;return o&&g.setDeveloperDefaults(o),Wn(l??null),_n(),{id:t,name:r,description:n,slot:"both",icon:({size:b,slot:C})=>$t(Vt,{size:C==="dial"?b*1.5:b,color:qn}),component:b=>$t(We,{...b,onSearchUsers:l,onClearReactQuery:h,onClearRedux:a,onClearAsyncStorage:d,onClearMMKV:s,showSettingsTab:i}),props:{enableSharedModalDimensions:false},Banner:Me}}import{jsx as Yn}from"react/jsx-runtime";function Gn(){return Yn(Me,{position:"top",offset:50})}import{buoyColors as he,night as pe,X as Zn}from"@buoy-gg/shared-ui/web";import{jsx as J,jsxs as ve}from"react/jsx-runtime";function ea({user:e,onStopImpersonation:t}){let r=e.displayName||e.email||e.id;return ve(c,{style:$.container,children:[ve(c,{style:$.userSection,children:[J(De,{userId:e.id,name:r,size:"small",showActiveIndicator:false}),J(c,{style:$.userInfo,children:J(y,{style:$.userName,numberOfLines:1,children:r})})]}),ve(c,{style:$.statusPill,children:[J(c,{style:$.pulseDot}),J(y,{style:$.statusText,children:"Active"})]}),ve(H,{style:$.stopButton,onPress:t,activeOpacity:.7,children:[J(Zn,{size:12,color:pe.color.danger}),J(y,{style:$.stopButtonText,children:"Stop"})]})]})}var $=F.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,paddingHorizontal:16,backgroundColor:he.success+"10",borderBottomWidth:1,borderBottomColor:he.success+"25",gap:12},userSection:{flexDirection:"row",alignItems:"center",flex:1,gap:10,minWidth:0},userInfo:{flex:1,minWidth:0},userName:{fontSize:14,fontWeight:"600",color:pe.color.text},statusPill:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:he.success+"20",paddingHorizontal:10,paddingVertical:5,borderRadius:12},pulseDot:{width:6,height:6,borderRadius:3,backgroundColor:he.success},statusText:{fontSize:11,fontWeight:"600",color:he.success,textTransform:"uppercase",letterSpacing:.5},stopButton:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:12,paddingVertical:6,backgroundColor:pe.color.dangerSoft,borderRadius:6,borderWidth:1,borderColor:pe.color.danger+"30"},stopButtonText:{fontSize:12,fontWeight:"600",color:pe.color.danger}});import{useCallback as Qe,useSyncExternalStore as ta}from"react";function ra(){let e=ta(g.subscribe,g.getSnapshot,g.getSnapshot),t=Qe(async o=>{await g.quickSwitch(o)},[]),r=Qe(async o=>{await g.removeFromHistory(o)},[]),n=Qe(async()=>{await g.clearHistory()},[]);return{history:e.history,currentUserId:e.currentUser?.id??null,quickSwitch:t,removeFromHistory:r,clearHistory:n}}export{Ut as DataNukeSettingsComponent,Me as ImpersonateBanner,Un as ImpersonateBannerMinimal,zt as ImpersonateHistoryList,Vt as ImpersonateIcon,We as ImpersonateModal,Gn as ImpersonateOverlay,ea as ImpersonateStatusBar,En as ImpersonateToolView,Pt as UserSearchView,Xn as createImpersonateSyncAdapter,Jn as createImpersonateTool,Fo as getImpersonatedUserId,O as impersonateListener,g as impersonateStore,Qn as impersonateSyncAdapter,Wo as isImpersonating,wt as setImpersonateConfig,Oo as startImpersonateListener,Ko as stopImpersonateListener,It as useImpersonate,ra as useImpersonateHistory};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/impersonate",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.69",
|
|
4
4
|
"description": "Configure impersonation headers for supported app requests. Your backend must authenticate and authorize user changes.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
],
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
37
|
+
"@buoy-gg/shared-ui": "^7.0.69"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"react": "*"
|