@buoy-gg/shared-ui 7.0.85 → 7.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/lib/commonjs/JsModal.js +1 -1
  2. package/lib/commonjs/JsModal.web.js +1 -1
  3. package/lib/commonjs/index.js +1 -1
  4. package/lib/commonjs/license/AccountSetupContent.js +1 -1
  5. package/lib/commonjs/license/index.js +1 -1
  6. package/lib/commonjs/license/licenseModule.js +1 -1
  7. package/lib/commonjs/license/releaseSimulation.js +1 -0
  8. package/lib/commonjs/license/tierLimits.js +1 -1
  9. package/lib/commonjs/ui/floating/FloatingTool.js +1 -1
  10. package/lib/commonjs/ui/floating/FloatingTool.web.js +1 -1
  11. package/lib/module/JsModal.js +1 -1
  12. package/lib/module/JsModal.web.js +1 -1
  13. package/lib/module/index.js +1 -1
  14. package/lib/module/license/AccountSetupContent.js +1 -1
  15. package/lib/module/license/index.js +1 -1
  16. package/lib/module/license/licenseModule.js +1 -1
  17. package/lib/module/license/releaseSimulation.js +1 -0
  18. package/lib/module/license/tierLimits.js +1 -1
  19. package/lib/module/ui/floating/FloatingTool.js +1 -1
  20. package/lib/module/ui/floating/FloatingTool.web.js +1 -1
  21. package/lib/typescript/commonjs/hooks/safe-area-impl.d.ts +1 -1
  22. package/lib/typescript/commonjs/index.d.ts +3 -2
  23. package/lib/typescript/commonjs/license/index.d.ts +1 -1
  24. package/lib/typescript/commonjs/license/licenseModule.d.ts +10 -2
  25. package/lib/typescript/commonjs/license/releaseSimulation.d.ts +27 -0
  26. package/lib/typescript/commonjs/utils/stateSnapshotRegistry.d.ts +5 -0
  27. package/lib/typescript/module/hooks/safe-area-impl.d.ts +1 -1
  28. package/lib/typescript/module/index.d.ts +3 -2
  29. package/lib/typescript/module/license/index.d.ts +1 -1
  30. package/lib/typescript/module/license/licenseModule.d.ts +10 -2
  31. package/lib/typescript/module/license/releaseSimulation.d.ts +27 -0
  32. package/lib/typescript/module/utils/stateSnapshotRegistry.d.ts +5 -0
  33. package/lib/web/chunks/{chunk-4YIFUO7B.mjs → chunk-MGKPQCZU.mjs} +4 -4
  34. package/lib/web/chunks/chunk-TWVTG6LD.mjs +1 -0
  35. package/lib/web/dataViewer.mjs +1 -1
  36. package/lib/web/floating.mjs +1 -1
  37. package/lib/web/index.mjs +11 -11
  38. package/lib/web/ui.mjs +1 -1
  39. package/package.json +5 -5
  40. package/lib/web/chunks/chunk-4YLP5MMN.mjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Divider=Divider;exports.FloatingTool=FloatingTool;exports.UserStatus=UserStatus;exports.getBubbleAnchorPosition=getBubbleAnchorPosition;var _react=require("react");var _reactNative=require("react-native");var _nightTheme=require("../night/nightTheme.js");var _DraggableHeader=require("../components/DraggableHeader.js");var _EnvironmentSelectorInline=require("../../env/EnvironmentSelectorInline");var _GripVerticalIcon=require("../components/GripVerticalIcon.js");var _gameUIColors=require("../gameUI/constants/gameUIColors.js");var _index=require("../../utils/index.js");var _index2=require("../../hooks/index.js");var _onboardingConstants=require("./onboardingConstants");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _jsxRuntime=require("react/jsx-runtime");const STORAGE_KEYS={BUBBLE_POSITION_X:"@react_buoy_bubble_position_x",BUBBLE_POSITION_Y:"@react_buoy_bubble_position_y"};const VISIBLE_HANDLE_WIDTH=32;const EDGE_PADDING=20;const LAYOUT_SETTLE_DELAY_MS=150;const getAnimatedValue=d=>d.__getValue();function useFloatingToolsPosition({animatedPosition:d,bubbleWidth:M=100,bubbleHeight:x=32,enabled:c=true,visibleHandleWidth:S=32,listenersSuspended:A=false,skipAutoSaveRef:V,defaultPlacement:F="top",bottomClearance:N=0,onPositionLoaded:q,storageKey:f}){const[C,B]=(0,_react.useState)(false);const m=(0,_react.useRef)(void 0);const I=(0,_react.useRef)(true);(0,_react.useEffect)(()=>{I.current=true;return()=>{I.current=false;if(m.current){clearTimeout(m.current);m.current=void 0}}},[]);const _=(0,_react.useCallback)(async(l,t)=>{if(!c)return;if(!I.current)return;const{width:n}=_reactNative.Dimensions.get("window");if(n<=0||l<0||t<0)return;try{await Promise.all([_index.persistentStorage.setItem(f?`${f}:x`:STORAGE_KEYS.BUBBLE_POSITION_X,l.toString()),_index.persistentStorage.setItem(f?`${f}:y`:STORAGE_KEYS.BUBBLE_POSITION_Y,t.toString())])}catch(w){}},[c,f]);const Y=(0,_react.useCallback)((l,t)=>{if(!I.current)return;if(m.current)clearTimeout(m.current);m.current=setTimeout(()=>{if(I.current){_(l,t)}},500)},[_]);const W=(0,_react.useCallback)(async()=>{if(!c)return null;try{const[l,t]=await Promise.all([_index.persistentStorage.getItem(f?`${f}:x`:STORAGE_KEYS.BUBBLE_POSITION_X),_index.persistentStorage.getItem(f?`${f}:y`:STORAGE_KEYS.BUBBLE_POSITION_Y)]);if(l!==null&&t!==null){const n=parseFloat(l);const w=parseFloat(t);if(!Number.isNaN(n)&&!Number.isNaN(w)){return{x:n,y:w}}}}catch(l){}return null},[c,f]);const z=(0,_react.useCallback)(l=>{const{width:t,height:n}=_reactNative.Dimensions.get("window");const w=(0,_index.getSafeAreaInsets)();if(t<=0||n<=0){return{...l,isValid:false}}const e=w.left;const E=t-S;const R=w.top+EDGE_PADDING;const O=n-x-w.bottom;const o={x:Math.max(e,Math.min(l.x,E)),y:Math.max(R,Math.min(l.y,O)),isValid:true};return o},[S,x]);(0,_react.useEffect)(()=>{if(!c||C)return;let l=false;const t=async()=>{const n=await W();if(l||!I.current)return;const{width:w,height:e}=_reactNative.Dimensions.get("window");const E=(0,_index.getSafeAreaInsets)();if(w<=0||e<=0){setTimeout(()=>{if(I.current&&!l){t()}},100);return}let R;let O=false;if(n){const o=z(n);if(!o.isValid){setTimeout(()=>{if(I.current&&!l){t()}},100);return}const D=Math.abs(n.x-o.x)>5||Math.abs(n.y-o.y)>5;if(D){await _(o.x,o.y)}R={x:o.x,y:o.y};O=o.x>=w-S-5}else{const o=F==="bottom"?Math.max(E.top+EDGE_PADDING,e-x-E.bottom-EDGE_PADDING-N):Math.max(E.top+EDGE_PADDING,Math.min(100,e-x-E.bottom));R={x:w-M-EDGE_PADDING,y:o}}if(l||!I.current)return;d.setValue(R);B(true);q?.(R,O)};t();return()=>{l=true}},[c,C,d,W,z,_,M,x,S,q]);(0,_react.useEffect)(()=>{if(!c||!C||A)return;const l=d.addListener(t=>{if(V?.current)return;Y(t.x,t.y)});return()=>{d.removeListener(l);if(m.current){clearTimeout(m.current);m.current=void 0}}},[c,C,A,V,d,Y]);return{savePosition:_,isInitialized:C}}function Divider(){const d={width:1,height:12,backgroundColor:_gameUIColors.buoyColors.textMuted+"66",flexShrink:0};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:d})}const gameUIColorsCompat={success:"#20C997",warning:"#FFA94D",error:"#EF4444",muted:_gameUIColors.buoyColors.textMuted,secondary:_gameUIColors.buoyColors.textSecondary,info:"#20C997",primary:"#20C997",optional:_gameUIColors.buoyColors.textSecondary};function getUserStatusConfig(d){return(0,_floatingToolsCore.getUserStatusConfig)(d,gameUIColorsCompat)}const FloatingToolsContext=(0,_react.createContext)({isDragging:false});function UserStatus({userRole:d,onPress:M}){const{isDragging:x}=(0,_react.useContext)(FloatingToolsContext);const c=getUserStatusConfig(d);const S={flexDirection:"row",alignItems:"center",paddingVertical:6,paddingHorizontal:8,flexShrink:0};const A={width:6,height:6,borderRadius:3,backgroundColor:c.dotColor,marginRight:4};const V={fontSize:10,fontWeight:"500",color:c.textColor,letterSpacing:.3};if(!M){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:S,accessibilityLabel:`User status: ${c.label}`,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:A}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:V,children:c.label})]})}return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{accessibilityRole:"button",accessibilityLabel:"Open Dev Tools Menu",testID:"open-dev-tools-button",onPress:M,hitSlop:{top:10,bottom:10,left:0,right:10},disabled:x,activeOpacity:.85,style:S,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:A}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:V,children:c.label})]})}function interleaveWithDividers(d){const M=(0,_floatingToolsCore.filterValidChildren)(d);const x=[];M.forEach((c,S)=>{x.push(c);if(S<M.length-1)x.push((0,_jsxRuntime.jsx)(Divider,{},`divider-${S}`))});return x}function FloatingTool({id:d,suspendPointerEvents:M=false,revealToken:x,variant:c="bubble",dragFromSurface:S=false,accessibilityLabel:A="Move dev tools bubble",minimizedStack:V,hasMinimizedStack:F=false,accessory:N,handleAdornment:q,enablePositionPersistence:f=true,defaultPlacement:C="top",bottomClearance:B=0,pushToSide:m=false,centerOnboarding:I=false,children:_,environment:Y,availableEnvironments:W,onEnvironmentSwitch:z,showEnvironmentSelector:l=false}){const t=(0,_react.useRef)(new _reactNative.Animated.ValueXY).current;const[n,w]=(0,_react.useState)(false);const[e,E]=(0,_react.useState)({width:100,height:32});const[R,O]=(0,_react.useState)(false);const[o,D]=(0,_react.useState)(false);const[J,rt]=(0,_react.useState)(0);const[nt,ot]=(0,_react.useState)(false);const g=(0,_react.useRef)(null);const T=(0,_react.useRef)(false);const H=(0,_react.useRef)(false);const Q=(0,_react.useRef)(m);const U=(0,_react.useRef)(null);const[X,it]=(0,_react.useState)(false);const u=(0,_index2.useSafeAreaInsets)();const{width:a,height:y}=(0,_reactNative.useWindowDimensions)();const st=(0,_react.useCallback)((i,r)=>{if(r){D(true)}},[]);const{savePosition:b,isInitialized:v}=useFloatingToolsPosition({animatedPosition:t,bubbleWidth:e.width,bubbleHeight:e.height,enabled:f,visibleHandleWidth:VISIBLE_HANDLE_WIDTH,listenersSuspended:n,skipAutoSaveRef:T,defaultPlacement:C,bottomClearance:B,onPositionLoaded:st,storageKey:d?`@buoy/floating-tool/${d}`:void 0});(0,_react.useEffect)(()=>{if(f&&!v)return;if(!Q.current&&m){H.current=false}Q.current=m;if(m&&!o&&!n&&!H.current){const i=getAnimatedValue(t.x);const r=getAnimatedValue(t.y);g.current={x:i,y:r};const s=a-VISIBLE_HANDLE_WIDTH;T.current=true;D(true);_reactNative.Animated.timing(t,{toValue:{x:s,y:r},duration:200,useNativeDriver:false}).start()}else if(!m&&o&&T.current){if(g.current){const{x:i,y:r}=g.current;T.current=false;H.current=false;D(false);_reactNative.Animated.timing(t,{toValue:{x:i,y:r},duration:200,useNativeDriver:false}).start(()=>{b(i,r)})}}},[f,v,m,o,n,a,t,b]);(0,_react.useEffect)(()=>{if(!v||X)return;const i=setTimeout(()=>{U.current=e.width;it(true);if(!o&&!n){const r=getAnimatedValue(t.x);const s=a-e.width-EDGE_PADDING;if(r>s){const h=Math.max(u.left,s);const p=getAnimatedValue(t.y);t.setValue({x:h,y:p});b(h,p)}}},LAYOUT_SETTLE_DELAY_MS);return()=>clearTimeout(i)},[v,X,e.width]);(0,_react.useEffect)(()=>{if(!v||!X||o||n)return;const i=getAnimatedValue(t.y);const r=y-e.height-u.bottom-EDGE_PADDING-(C==="bottom"?B:0);if(i<=r)return;const s=getAnimatedValue(t.x);const h=Math.max(u.top+EDGE_PADDING,r);t.setValue({x:s,y:h});b(s,h)},[v,X,o,n,e.height,y,u.top,u.bottom,B,C]);(0,_react.useEffect)(()=>{if(!v)return;if(!X)return;if(U.current===null)return;if(n){U.current=e.width;return}const i=U.current;const r=e.width;const s=r-i;if(Math.abs(s)<2){return}U.current=r;if(o){if(g.current){const k=g.current.x-s;g.current.x=Math.max(u.left,Math.min(k,a-r-EDGE_PADDING))}return}const h=getAnimatedValue(t.x);const p=getAnimatedValue(t.y);const j=h-s;const L=Math.max(u.left,Math.min(j,a-VISIBLE_HANDLE_WIDTH));if(Math.abs(L-h)>1){_reactNative.Animated.timing(t,{toValue:{x:L,y:p},duration:150,useNativeDriver:false}).start(()=>{b(L,p);if(g.current){g.current.x=L}})}},[e.width,v,X,n,o,t,a,u.left,b]);(0,_react.useEffect)(()=>{if(!f){if(I){const i=(0,_onboardingConstants.calculateTargetPosition)();const r=(a-e.width)/2;const s=y-e.height-i;t.setValue({x:r,y:s})}else{const i=C==="bottom"?Math.max(u.top+EDGE_PADDING,y-e.height-u.bottom-EDGE_PADDING-B):Math.max(u.top+EDGE_PADDING,Math.min(100,y-e.height-u.bottom));t.setValue({x:a-e.width-EDGE_PADDING,y:i})}}},[f,I,t,e.width,e.height,u.top,u.bottom,a,y]);const $=(0,_react.useCallback)(()=>{const i=getAnimatedValue(t.x);const r=getAnimatedValue(t.y);const s=i>a-e.width/2;if(o||s){let h;let p;if(g.current&&g.current.x<a-e.width/2){h=g.current.x;p=g.current.y}else{h=a-e.width-EDGE_PADDING;p=r}T.current=false;H.current=true;D(false);_reactNative.Animated.timing(t,{toValue:{x:h,y:p},duration:200,useNativeDriver:false}).start(()=>{b(h,p)})}else{g.current={x:i,y:r};H.current=false;const h=a-VISIBLE_HANDLE_WIDTH;D(true);_reactNative.Animated.timing(t,{toValue:{x:h,y:r},duration:200,useNativeDriver:false}).start(()=>{b(h,r)})}},[t,o,e.width,b,a]);const Z=(0,_react.useCallback)(()=>{w(true)},[]);const K=(0,_react.useCallback)(i=>{let{x:r,y:s}=i;const h=r+e.width/2;const p=h>a;if(p){const j=a-VISIBLE_HANDLE_WIDTH;D(true);if(g.current){g.current.y=s}else{g.current={x:a-e.width-EDGE_PADDING,y:s}}_reactNative.Animated.timing(t,{toValue:{x:j,y:s},duration:200,useNativeDriver:false}).start(()=>{b(j,s)})}else{if(o&&r<a-VISIBLE_HANDLE_WIDTH-10){D(false);T.current=false}if(r<a-e.width/2){g.current={x:r,y:s}}b(r,s)}w(false)},[t,e.width,o,b,a]);const G=(0,_react.useRef)({width:a,height:y});(0,_react.useEffect)(()=>{if(f&&!v)return;if(G.current.width===a&&G.current.height===y)return;G.current={width:a,height:y};const i=s=>({x:Math.max(u.left,Math.min(s.x,a-e.width-EDGE_PADDING)),y:Math.max(u.top+EDGE_PADDING,Math.min(s.y,y-e.height-u.bottom))});const r=i({x:getAnimatedValue(t.x),y:getAnimatedValue(t.y)});if(o)r.x=a-VISIBLE_HANDLE_WIDTH;if(g.current)g.current=i(g.current);t.stopAnimation();t.setValue(r);if(T.current)return;void b(r.x,r.y)},[a,y,v,f,e,u,o,t,b]);const tt=Boolean(N);(0,_react.useEffect)(()=>{if(!tt)return;const i=({y:s})=>ot(s+e.height+J>y-u.bottom);i({y:getAnimatedValue(t.y)});const r=t.addListener(i);return()=>t.removeListener(r)},[t,e.height,J,y,u.bottom,tt]);const at=(0,_react.useMemo)(()=>({position:"absolute",zIndex:1001,opacity:R?1:0,transform:t.getTranslateTransform()}),[t,R]);const et=(0,_react.useRef)(void 0);(0,_react.useEffect)(()=>{if(f&&!v)return;if(et.current===x)return;et.current=x;if(x!==void 0&&x>0&&o)$()},[x,v,f,o,$]);const P=F;const ut={flexDirection:"row",alignItems:"center",backgroundColor:_gameUIColors.buoyColors.card,borderTopLeftRadius:P?0:6,borderTopRightRadius:6,borderBottomLeftRadius:6,borderBottomRightRadius:6,borderLeftWidth:n?2:1,borderRightWidth:n?2:1,borderBottomWidth:n?2:1,borderTopWidth:n?2:P?0:1,borderColor:n?_floatingToolsCore.floatingToolsColors.dragActive:_gameUIColors.buoyColors.textMuted+"66",overflow:"visible",elevation:8,shadowColor:n?_floatingToolsCore.floatingToolsColors.dragActive+"99":"#000",shadowOffset:{width:0,height:n?6:4},shadowOpacity:n?.6:.3,shadowRadius:n?12:8,...c==="strip"?{borderRadius:_nightTheme.night.radius.card,borderTopLeftRadius:_nightTheme.night.radius.card,borderTopRightRadius:_nightTheme.night.radius.card,borderBottomLeftRadius:_nightTheme.night.radius.card,borderBottomRightRadius:_nightTheme.night.radius.card,minHeight:48,backgroundColor:_nightTheme.night.color.surface,borderColor:n?_nightTheme.night.color.accentBorderStrong:_nightTheme.night.color.separator,shadowOpacity:.24,shadowRadius:16}:{}};const ct={paddingHorizontal:6,paddingVertical:6,backgroundColor:_gameUIColors.buoyColors.textMuted+"1A",alignItems:"center",justifyContent:"center",width:32,...c==="strip"?{minHeight:48}:{},borderRightWidth:1,borderRightColor:_gameUIColors.buoyColors.textMuted+"66",borderTopLeftRadius:P?0:void 0,...c==="strip"?{backgroundColor:"transparent",borderRightWidth:0}:{}};const lt={flexDirection:"row",alignItems:"center",gap:6,paddingRight:8};const dt=(0,_react.useMemo)(()=>c==="strip"?_react.Children.toArray(_):interleaveWithDividers(_react.Children.toArray(_)),[_,c]);const ft=32;if(f&&!v){return null}return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:M?"none":"box-none",testID:d??"buoy-floating-tool",style:at,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{overflow:"visible"},children:[V&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",bottom:"100%",left:0,width:ft,overflow:"visible",zIndex:1001},children:V}),(0,_jsxRuntime.jsxs)(_DraggableHeader.DraggableHeader,{position:t,enabled:S,claimOnMove:false,onDragStart:Z,onDragEnd:K,containerBounds:{width:a,height:y},elementSize:e,minPosition:{x:u.left,y:u.top+EDGE_PADDING},maxOverflowX:e.width,hitSlop:{top:10,bottom:10,left:10,right:10},style:ut,onLayout:i=>{const{width:r,height:s}=i.nativeEvent.layout;E({width:r,height:s});if(R)return;O(true);if(o||n||T.current)return;const h=getAnimatedValue(t.x);const p=getAnimatedValue(t.y);const j=a-r-EDGE_PADDING;const L=y-s-u.bottom-EDGE_PADDING-(C==="bottom"?B:0);if(h<=j&&p<=L)return;const k={x:Math.max(u.left,Math.min(h,j)),y:Math.max(u.top+EDGE_PADDING,Math.min(p,L))};t.setValue(k);b(k.x,k.y)},children:[(0,_jsxRuntime.jsxs)(_DraggableHeader.DraggableHeader,{position:t,testID:d?`${d}-grip`:"buoy-floating-grip",accessibilityLabel:A,onDragStart:Z,onDragEnd:K,onTap:$,containerBounds:{width:a,height:y},elementSize:e,minPosition:{x:u.left,y:u.top+EDGE_PADDING},style:ct,enabled:true,maxOverflowX:e.width,children:[(0,_jsxRuntime.jsx)(_GripVerticalIcon.GripVerticalIcon,{size:c==="strip"?20:12,color:_gameUIColors.buoyColors.textSecondary+"CC"}),q]}),(0,_jsxRuntime.jsx)(FloatingToolsContext.Provider,{value:{isDragging:n},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:lt,children:[l&&Y&&W&&z&&(0,_jsxRuntime.jsx)(_EnvironmentSelectorInline.EnvironmentSelectorInline,{currentEnvironment:Y,availableEnvironments:W,onSelect:z}),dt]})})]}),!o&&N&&(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:i=>rt(i.nativeEvent.layout.height),style:{position:"absolute",...nt?{bottom:"100%"}:{top:"100%"},left:0,width:"100%",zIndex:1002},children:N})]})})}function getBubbleAnchorPosition(){return null}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Divider=Divider;exports.FloatingTool=FloatingTool;exports.UserStatus=UserStatus;exports.getBubbleAnchorPosition=getBubbleAnchorPosition;var _react=require("react");var _reactNative=require("react-native");var _nightTheme=require("../night/nightTheme.js");var _DraggableHeader=require("../components/DraggableHeader.js");var _EnvironmentSelectorInline=require("../../env/EnvironmentSelectorInline");var _GripVerticalIcon=require("../components/GripVerticalIcon.js");var _gameUIColors=require("../gameUI/constants/gameUIColors.js");var _index=require("../../utils/index.js");var _index2=require("../../hooks/index.js");var _onboardingConstants=require("./onboardingConstants");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _jsxRuntime=require("react/jsx-runtime");const STORAGE_KEYS={BUBBLE_POSITION_X:"@react_buoy_bubble_position_x",BUBBLE_POSITION_Y:"@react_buoy_bubble_position_y"};const VISIBLE_HANDLE_WIDTH=32;const EDGE_PADDING=20;const LAYOUT_SETTLE_DELAY_MS=150;const getAnimatedValue=d=>d.__getValue();function useFloatingToolsPosition({animatedPosition:d,bubbleWidth:M=100,bubbleHeight:x=32,enabled:c=true,visibleHandleWidth:S=32,listenersSuspended:A=false,skipAutoSaveRef:V,defaultPlacement:F="top",bottomClearance:N=0,onPositionLoaded:q,storageKey:f}){const[C,B]=(0,_react.useState)(false);const m=(0,_react.useRef)(void 0);const I=(0,_react.useRef)(true);(0,_react.useEffect)(()=>{I.current=true;return()=>{I.current=false;if(m.current){clearTimeout(m.current);m.current=void 0}}},[]);const _=(0,_react.useCallback)(async(l,t)=>{if(!c)return;if(!I.current)return;const{width:n}=_reactNative.Dimensions.get("window");if(n<=0||l<0||t<0)return;try{await Promise.all([_index.persistentStorage.setItem(f?`${f}:x`:STORAGE_KEYS.BUBBLE_POSITION_X,l.toString()),_index.persistentStorage.setItem(f?`${f}:y`:STORAGE_KEYS.BUBBLE_POSITION_Y,t.toString())])}catch(w){}},[c,f]);const Y=(0,_react.useCallback)((l,t)=>{if(!I.current)return;if(m.current)clearTimeout(m.current);m.current=setTimeout(()=>{if(I.current){_(l,t)}},500)},[_]);const W=(0,_react.useCallback)(async()=>{if(!c)return null;try{const[l,t]=await Promise.all([_index.persistentStorage.getItem(f?`${f}:x`:STORAGE_KEYS.BUBBLE_POSITION_X),_index.persistentStorage.getItem(f?`${f}:y`:STORAGE_KEYS.BUBBLE_POSITION_Y)]);if(l!==null&&t!==null){const n=parseFloat(l);const w=parseFloat(t);if(!Number.isNaN(n)&&!Number.isNaN(w)){return{x:n,y:w}}}}catch(l){}return null},[c,f]);const z=(0,_react.useCallback)(l=>{const{width:t,height:n}=_reactNative.Dimensions.get("window");const w=(0,_index.getSafeAreaInsets)();if(t<=0||n<=0){return{...l,isValid:false}}const e=w.left;const E=t-S;const R=w.top+EDGE_PADDING;const O=n-x-w.bottom;const o={x:Math.max(e,Math.min(l.x,E)),y:Math.max(R,Math.min(l.y,O)),isValid:true};return o},[S,x]);(0,_react.useEffect)(()=>{if(!c||C)return;let l=false;const t=async()=>{const n=await W();if(l||!I.current)return;const{width:w,height:e}=_reactNative.Dimensions.get("window");const E=(0,_index.getSafeAreaInsets)();if(w<=0||e<=0){setTimeout(()=>{if(I.current&&!l){t()}},100);return}let R;let O=false;if(n){const o=z(n);if(!o.isValid){setTimeout(()=>{if(I.current&&!l){t()}},100);return}const D=Math.abs(n.x-o.x)>5||Math.abs(n.y-o.y)>5;if(D){await _(o.x,o.y)}R={x:o.x,y:o.y};O=o.x>=w-S-5}else{const o=F==="bottom"?Math.max(E.top+EDGE_PADDING,e-x-E.bottom-EDGE_PADDING-N):Math.max(E.top+EDGE_PADDING,Math.min(100,e-x-E.bottom));R={x:w-M-EDGE_PADDING,y:o}}if(l||!I.current)return;d.setValue(R);B(true);q?.(R,O)};t();return()=>{l=true}},[c,C,d,W,z,_,M,x,S,q]);(0,_react.useEffect)(()=>{if(!c||!C||A)return;const l=d.addListener(t=>{if(V?.current)return;Y(t.x,t.y)});return()=>{d.removeListener(l);if(m.current){clearTimeout(m.current);m.current=void 0}}},[c,C,A,V,d,Y]);return{savePosition:_,isInitialized:C}}function Divider(){const d={width:1,height:12,backgroundColor:_gameUIColors.buoyColors.textMuted+"66",flexShrink:0};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:d})}const gameUIColorsCompat={success:"#20C997",warning:"#FFA94D",error:"#EF4444",muted:_gameUIColors.buoyColors.textMuted,secondary:_gameUIColors.buoyColors.textSecondary,info:"#20C997",primary:"#20C997",optional:_gameUIColors.buoyColors.textSecondary};function getUserStatusConfig(d){return(0,_floatingToolsCore.getUserStatusConfig)(d,gameUIColorsCompat)}const FloatingToolsContext=(0,_react.createContext)({isDragging:false});function UserStatus({userRole:d,onPress:M}){const{isDragging:x}=(0,_react.useContext)(FloatingToolsContext);const c=getUserStatusConfig(d);const S={flexDirection:"row",alignItems:"center",paddingVertical:6,paddingHorizontal:8,flexShrink:0};const A={width:6,height:6,borderRadius:3,backgroundColor:c.dotColor,marginRight:4};const V={fontSize:10,fontWeight:"500",color:c.textColor,letterSpacing:.3};if(!M){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:S,accessibilityLabel:`User status: ${c.label}`,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:A}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:V,children:c.label})]})}return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{accessibilityRole:"button",accessibilityLabel:`${c.label}, Open Dev Tools Menu`,testID:"open-dev-tools-button",onPress:M,hitSlop:{top:10,bottom:10,left:0,right:10},disabled:x,activeOpacity:.85,style:S,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:A}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:V,children:c.label})]})}function interleaveWithDividers(d){const M=(0,_floatingToolsCore.filterValidChildren)(d);const x=[];M.forEach((c,S)=>{x.push(c);if(S<M.length-1)x.push((0,_jsxRuntime.jsx)(Divider,{},`divider-${S}`))});return x}function FloatingTool({id:d,suspendPointerEvents:M=false,revealToken:x,variant:c="bubble",dragFromSurface:S=false,accessibilityLabel:A="Move dev tools bubble",minimizedStack:V,hasMinimizedStack:F=false,accessory:N,handleAdornment:q,enablePositionPersistence:f=true,defaultPlacement:C="top",bottomClearance:B=0,pushToSide:m=false,centerOnboarding:I=false,children:_,environment:Y,availableEnvironments:W,onEnvironmentSwitch:z,showEnvironmentSelector:l=false}){const t=(0,_react.useRef)(new _reactNative.Animated.ValueXY).current;const[n,w]=(0,_react.useState)(false);const[e,E]=(0,_react.useState)({width:100,height:32});const[R,O]=(0,_react.useState)(false);const[o,D]=(0,_react.useState)(false);const[J,rt]=(0,_react.useState)(0);const[nt,ot]=(0,_react.useState)(false);const g=(0,_react.useRef)(null);const T=(0,_react.useRef)(false);const H=(0,_react.useRef)(false);const Q=(0,_react.useRef)(m);const U=(0,_react.useRef)(null);const[X,it]=(0,_react.useState)(false);const u=(0,_index2.useSafeAreaInsets)();const{width:a,height:y}=(0,_reactNative.useWindowDimensions)();const st=(0,_react.useCallback)((i,r)=>{if(r){D(true)}},[]);const{savePosition:b,isInitialized:v}=useFloatingToolsPosition({animatedPosition:t,bubbleWidth:e.width,bubbleHeight:e.height,enabled:f,visibleHandleWidth:VISIBLE_HANDLE_WIDTH,listenersSuspended:n,skipAutoSaveRef:T,defaultPlacement:C,bottomClearance:B,onPositionLoaded:st,storageKey:d?`@buoy/floating-tool/${d}`:void 0});(0,_react.useEffect)(()=>{if(f&&!v)return;if(!Q.current&&m){H.current=false}Q.current=m;if(m&&!o&&!n&&!H.current){const i=getAnimatedValue(t.x);const r=getAnimatedValue(t.y);g.current={x:i,y:r};const s=a-VISIBLE_HANDLE_WIDTH;T.current=true;D(true);_reactNative.Animated.timing(t,{toValue:{x:s,y:r},duration:200,useNativeDriver:false}).start()}else if(!m&&o&&T.current){if(g.current){const{x:i,y:r}=g.current;T.current=false;H.current=false;D(false);_reactNative.Animated.timing(t,{toValue:{x:i,y:r},duration:200,useNativeDriver:false}).start(()=>{b(i,r)})}}},[f,v,m,o,n,a,t,b]);(0,_react.useEffect)(()=>{if(!v||X)return;const i=setTimeout(()=>{U.current=e.width;it(true);if(!o&&!n){const r=getAnimatedValue(t.x);const s=a-e.width-EDGE_PADDING;if(r>s){const h=Math.max(u.left,s);const p=getAnimatedValue(t.y);t.setValue({x:h,y:p});b(h,p)}}},LAYOUT_SETTLE_DELAY_MS);return()=>clearTimeout(i)},[v,X,e.width]);(0,_react.useEffect)(()=>{if(!v||!X||o||n)return;const i=getAnimatedValue(t.y);const r=y-e.height-u.bottom-EDGE_PADDING-(C==="bottom"?B:0);if(i<=r)return;const s=getAnimatedValue(t.x);const h=Math.max(u.top+EDGE_PADDING,r);t.setValue({x:s,y:h});b(s,h)},[v,X,o,n,e.height,y,u.top,u.bottom,B,C]);(0,_react.useEffect)(()=>{if(!v)return;if(!X)return;if(U.current===null)return;if(n){U.current=e.width;return}const i=U.current;const r=e.width;const s=r-i;if(Math.abs(s)<2){return}U.current=r;if(o){if(g.current){const k=g.current.x-s;g.current.x=Math.max(u.left,Math.min(k,a-r-EDGE_PADDING))}return}const h=getAnimatedValue(t.x);const p=getAnimatedValue(t.y);const j=h-s;const L=Math.max(u.left,Math.min(j,a-VISIBLE_HANDLE_WIDTH));if(Math.abs(L-h)>1){_reactNative.Animated.timing(t,{toValue:{x:L,y:p},duration:150,useNativeDriver:false}).start(()=>{b(L,p);if(g.current){g.current.x=L}})}},[e.width,v,X,n,o,t,a,u.left,b]);(0,_react.useEffect)(()=>{if(!f){if(I){const i=(0,_onboardingConstants.calculateTargetPosition)();const r=(a-e.width)/2;const s=y-e.height-i;t.setValue({x:r,y:s})}else{const i=C==="bottom"?Math.max(u.top+EDGE_PADDING,y-e.height-u.bottom-EDGE_PADDING-B):Math.max(u.top+EDGE_PADDING,Math.min(100,y-e.height-u.bottom));t.setValue({x:a-e.width-EDGE_PADDING,y:i})}}},[f,I,t,e.width,e.height,u.top,u.bottom,a,y]);const $=(0,_react.useCallback)(()=>{const i=getAnimatedValue(t.x);const r=getAnimatedValue(t.y);const s=i>a-e.width/2;if(o||s){let h;let p;if(g.current&&g.current.x<a-e.width/2){h=g.current.x;p=g.current.y}else{h=a-e.width-EDGE_PADDING;p=r}T.current=false;H.current=true;D(false);_reactNative.Animated.timing(t,{toValue:{x:h,y:p},duration:200,useNativeDriver:false}).start(()=>{b(h,p)})}else{g.current={x:i,y:r};H.current=false;const h=a-VISIBLE_HANDLE_WIDTH;D(true);_reactNative.Animated.timing(t,{toValue:{x:h,y:r},duration:200,useNativeDriver:false}).start(()=>{b(h,r)})}},[t,o,e.width,b,a]);const Z=(0,_react.useCallback)(()=>{w(true)},[]);const K=(0,_react.useCallback)(i=>{let{x:r,y:s}=i;const h=r+e.width/2;const p=h>a;if(p){const j=a-VISIBLE_HANDLE_WIDTH;D(true);if(g.current){g.current.y=s}else{g.current={x:a-e.width-EDGE_PADDING,y:s}}_reactNative.Animated.timing(t,{toValue:{x:j,y:s},duration:200,useNativeDriver:false}).start(()=>{b(j,s)})}else{if(o&&r<a-VISIBLE_HANDLE_WIDTH-10){D(false);T.current=false}if(r<a-e.width/2){g.current={x:r,y:s}}b(r,s)}w(false)},[t,e.width,o,b,a]);const G=(0,_react.useRef)({width:a,height:y});(0,_react.useEffect)(()=>{if(f&&!v)return;if(G.current.width===a&&G.current.height===y)return;G.current={width:a,height:y};const i=s=>({x:Math.max(u.left,Math.min(s.x,a-e.width-EDGE_PADDING)),y:Math.max(u.top+EDGE_PADDING,Math.min(s.y,y-e.height-u.bottom))});const r=i({x:getAnimatedValue(t.x),y:getAnimatedValue(t.y)});if(o)r.x=a-VISIBLE_HANDLE_WIDTH;if(g.current)g.current=i(g.current);t.stopAnimation();t.setValue(r);if(T.current)return;void b(r.x,r.y)},[a,y,v,f,e,u,o,t,b]);const tt=Boolean(N);(0,_react.useEffect)(()=>{if(!tt)return;const i=({y:s})=>ot(s+e.height+J>y-u.bottom);i({y:getAnimatedValue(t.y)});const r=t.addListener(i);return()=>t.removeListener(r)},[t,e.height,J,y,u.bottom,tt]);const at=(0,_react.useMemo)(()=>({position:"absolute",zIndex:1001,opacity:R?1:0,transform:t.getTranslateTransform()}),[t,R]);const et=(0,_react.useRef)(void 0);(0,_react.useEffect)(()=>{if(f&&!v)return;if(et.current===x)return;et.current=x;if(x!==void 0&&x>0&&o)$()},[x,v,f,o,$]);const P=F;const ut={flexDirection:"row",alignItems:"center",backgroundColor:_gameUIColors.buoyColors.card,borderTopLeftRadius:P?0:6,borderTopRightRadius:6,borderBottomLeftRadius:6,borderBottomRightRadius:6,borderLeftWidth:n?2:1,borderRightWidth:n?2:1,borderBottomWidth:n?2:1,borderTopWidth:n?2:P?0:1,borderColor:n?_floatingToolsCore.floatingToolsColors.dragActive:_gameUIColors.buoyColors.textMuted+"66",overflow:"visible",elevation:8,shadowColor:n?_floatingToolsCore.floatingToolsColors.dragActive+"99":"#000",shadowOffset:{width:0,height:n?6:4},shadowOpacity:n?.6:.3,shadowRadius:n?12:8,...c==="strip"?{borderRadius:_nightTheme.night.radius.card,borderTopLeftRadius:_nightTheme.night.radius.card,borderTopRightRadius:_nightTheme.night.radius.card,borderBottomLeftRadius:_nightTheme.night.radius.card,borderBottomRightRadius:_nightTheme.night.radius.card,minHeight:48,backgroundColor:_nightTheme.night.color.surface,borderColor:n?_nightTheme.night.color.accentBorderStrong:_nightTheme.night.color.separator,shadowOpacity:.24,shadowRadius:16}:{}};const ct={paddingHorizontal:6,paddingVertical:6,backgroundColor:_gameUIColors.buoyColors.textMuted+"1A",alignItems:"center",justifyContent:"center",width:32,...c==="strip"?{minHeight:48}:{},borderRightWidth:1,borderRightColor:_gameUIColors.buoyColors.textMuted+"66",borderTopLeftRadius:P?0:void 0,...c==="strip"?{backgroundColor:"transparent",borderRightWidth:0}:{}};const lt={flexDirection:"row",alignItems:"center",gap:6,paddingRight:8};const dt=(0,_react.useMemo)(()=>c==="strip"?_react.Children.toArray(_):interleaveWithDividers(_react.Children.toArray(_)),[_,c]);const ft=32;if(f&&!v){return null}return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:M?"none":"box-none",testID:d??"buoy-floating-tool",style:at,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{overflow:"visible"},children:[V&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",bottom:"100%",left:0,width:ft,overflow:"visible",zIndex:1001},children:V}),(0,_jsxRuntime.jsxs)(_DraggableHeader.DraggableHeader,{position:t,enabled:S,claimOnMove:false,onDragStart:Z,onDragEnd:K,containerBounds:{width:a,height:y},elementSize:e,minPosition:{x:u.left,y:u.top+EDGE_PADDING},maxOverflowX:e.width,hitSlop:{top:10,bottom:10,left:10,right:10},style:ut,onLayout:i=>{const{width:r,height:s}=i.nativeEvent.layout;E({width:r,height:s});if(R)return;O(true);if(o||n||T.current)return;const h=getAnimatedValue(t.x);const p=getAnimatedValue(t.y);const j=a-r-EDGE_PADDING;const L=y-s-u.bottom-EDGE_PADDING-(C==="bottom"?B:0);if(h<=j&&p<=L)return;const k={x:Math.max(u.left,Math.min(h,j)),y:Math.max(u.top+EDGE_PADDING,Math.min(p,L))};t.setValue(k);b(k.x,k.y)},children:[(0,_jsxRuntime.jsxs)(_DraggableHeader.DraggableHeader,{position:t,testID:d?`${d}-grip`:"buoy-floating-grip",accessibilityLabel:A,onDragStart:Z,onDragEnd:K,onTap:$,containerBounds:{width:a,height:y},elementSize:e,minPosition:{x:u.left,y:u.top+EDGE_PADDING},style:ct,enabled:true,maxOverflowX:e.width,children:[(0,_jsxRuntime.jsx)(_GripVerticalIcon.GripVerticalIcon,{size:c==="strip"?20:12,color:_gameUIColors.buoyColors.textSecondary+"CC"}),q]}),(0,_jsxRuntime.jsx)(FloatingToolsContext.Provider,{value:{isDragging:n},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:lt,children:[l&&Y&&W&&z&&(0,_jsxRuntime.jsx)(_EnvironmentSelectorInline.EnvironmentSelectorInline,{currentEnvironment:Y,availableEnvironments:W,onSelect:z}),dt]})})]}),!o&&N&&(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:i=>rt(i.nativeEvent.layout.height),style:{position:"absolute",...nt?{bottom:"100%"}:{top:"100%"},left:0,width:"100%",zIndex:1002},children:N})]})})}function getBubbleAnchorPosition(){return null}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Divider=Divider;exports.FloatingTool=FloatingTool;exports.UserStatus=UserStatus;exports.getBubbleAnchorPosition=getBubbleAnchorPosition;var _portalHostWeb=require("./portalHost.web.js");var _nightTheme=require("../night/nightTheme.js");var _react=require("react");var _onboardingConstantsWeb=require("./onboardingConstants.web.js");var _floating=require("@buoy-gg/floating-tools-react/floating");var _jsxRuntime=require("react/jsx-runtime");const EDGE_PADDING=10;const NATIVE_TOP_PADDING=20;function readSafeAreaInsets(){if(typeof document==="undefined"||!document.body)return{top:0,left:0,bottom:0};const e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-left:env(safe-area-inset-left);padding-bottom:env(safe-area-inset-bottom)";document.body.appendChild(e);const s=getComputedStyle(e);const r={top:parseFloat(s.paddingTop)||0,left:parseFloat(s.paddingLeft)||0,bottom:parseFloat(s.paddingBottom)||0};document.body.removeChild(e);return r}const webStorageAdapter={getItem:e=>localStorage.getItem(e),setItem:(e,s)=>localStorage.setItem(e,s)};const NATIVE_TEXT_SECONDARY="#A0A0A0";function GripVerticalIcon({size:e=24,color:s=(0,_floating.withAlpha)(NATIVE_TEXT_SECONDARY,"CC")}){const r=(0,_floating.getGripIconLayout)(e);return(0,_jsxRuntime.jsx)("div",{style:{width:e,height:e,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center"},children:[0,1].map(c=>(0,_jsxRuntime.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:r.columnGap/2,marginRight:r.columnGap/2},children:[0,1,2].map(f=>(0,_jsxRuntime.jsx)("div",{style:{width:r.dotSize,height:r.dotSize,borderRadius:r.dotSize/2,backgroundColor:s,marginTop:r.rowGap/2,marginBottom:r.rowGap/2}},f))},c))})}function Divider(){return(0,_jsxRuntime.jsx)("div",{style:{width:1,height:12,backgroundColor:(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"66"),flexShrink:0}})}const userStatusColors={success:_floating.floatingToolsColors.success,optional:_floating.floatingToolsColors.optional,muted:_floating.floatingToolsColors.muted,secondary:NATIVE_TEXT_SECONDARY};function UserStatus({userRole:e,onPress:s}){const{isDragging:r}=(0,_floating.useFloatingToolsContext)();const c=(0,_floating.getUserStatusConfig)(e,userStatusColors);const f=p=>{if(!r&&s){p.stopPropagation();p.currentTarget.focus();s()}};return(0,_jsxRuntime.jsxs)("button",{role:"button","aria-label":s?"Open Dev Tools Menu":`User status: ${c.label}`,"data-testid":s?"open-dev-tools-button":void 0,onClick:f,style:{display:"flex",flexDirection:"row",alignItems:"center",paddingTop:6,paddingBottom:6,paddingLeft:8,paddingRight:8,flexShrink:0,cursor:s&&!r?"pointer":"default",background:"none",border:"none",margin:0},children:[(0,_jsxRuntime.jsx)("div",{style:{width:6,height:6,borderRadius:3,backgroundColor:c.dotColor,marginRight:4}}),(0,_jsxRuntime.jsx)("span",{style:{fontSize:10,fontWeight:500,color:c.textColor,letterSpacing:.3,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',lineHeight:"normal"},children:c.label})]})}function useWebAnimation(){const e=(0,_react.useRef)(null);const[s,r]=(0,_react.useState)({x:0,y:0});const c=(0,_react.useCallback)((f,p,C)=>{if(e.current){cancelAnimationFrame(e.current)}const P=performance.now();const D=m=>{const b=m-P;const w=Math.min(b/_floating.ANIMATION_DURATION,1);const S=(0,_floating.interpolatePosition)(f,p,w,_floating.easing.easeOutCubic);r(S);if(w<1){e.current=requestAnimationFrame(D)}else{r(p);C?.()}};e.current=requestAnimationFrame(D)},[]);(0,_react.useEffect)(()=>{return()=>{if(e.current){cancelAnimationFrame(e.current)}}},[]);return{position:s,setPosition:r,animateTo:c}}let lastBubbleAnchor=null;function getBubbleAnchorPosition(){return lastBubbleAnchor}function FloatingTool({id:e,revealToken:s,variant:r="bubble",dragFromSurface:c=false,defaultPlacement:f="top",accessibilityLabel:p="Drag handle",accessory:C,handleAdornment:P,enablePositionPersistence:D=true,children:m,pushToSide:b=false,suspendPointerEvents:w=false,centerOnboarding:S=false,minimizedStack:B,hasMinimizedStack:z=false}){const h=(0,_react.useRef)(null);const M=(0,_react.useMemo)(()=>e?{getItem:t=>webStorageAdapter.getItem(`@buoy/floating-tool/${e}/${t}`),setItem:(t,i)=>webStorageAdapter.setItem(`@buoy/floating-tool/${e}/${t}`,i)}:webStorageAdapter,[e]);const{state:o,actions:n,isInitialized:d}=(0,_floating.useFloatingTools)({screenSize:{width:window.innerWidth,height:window.innerHeight},enablePositionPersistence:D,storage:M,...f==="bottom"?{initialBubbleSize:{width:100,height:48},initialPosition:{x:window.innerWidth-100-EDGE_PADDING,y:Math.max(readSafeAreaInsets().top+NATIVE_TOP_PADDING,window.innerHeight-48-readSafeAreaInsets().bottom-EDGE_PADDING)}}:{}});const{position:u,setPosition:A,animateTo:g}=useWebAnimation();(0,_react.useEffect)(()=>{if(d){A(o.position)}},[d,o.position,A]);(0,_react.useEffect)(()=>{if(!e)lastBubbleAnchor={x:u.x,y:u.y}},[u,e]);(0,_react.useEffect)(()=>{if(!d)return;const t=()=>{const l=h.current?.getBoundingClientRect();if(l&&l.width>0&&l.height>0)n.setBubbleSize({width:l.width,height:l.height})};const i=()=>{const l=readSafeAreaInsets().bottom;n.setScreenSize(window.innerWidth,window.innerHeight-(l>0?l-EDGE_PADDING:0));t()};t();const a=typeof ResizeObserver!=="undefined"?new ResizeObserver(t):null;if(h.current)a?.observe(h.current);window.addEventListener("resize",i);return()=>{a?.disconnect();window.removeEventListener("resize",i)}},[n,d]);const[F,G]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{let t=false;const i=()=>{const a=readSafeAreaInsets();G(a.top);if(a.top>0||a.left>0||a.bottom>0){t=true;n.setMinPosition({x:a.left,y:a.top+NATIVE_TOP_PADDING});n.setScreenSize(window.innerWidth,window.innerHeight-(a.bottom>0?a.bottom-EDGE_PADDING:0))}else if(t){t=false;n.setMinPosition({x:EDGE_PADDING,y:EDGE_PADDING});n.setScreenSize(window.innerWidth,window.innerHeight)}};i();window.addEventListener("resize",i);return()=>window.removeEventListener("resize",i)},[n]);const[L,k]=(0,_react.useState)(false);const _=(0,_react.useCallback)(t=>{t.stopPropagation();t.preventDefault();k(true);n.handleDragStart({clientX:t.clientX,clientY:t.clientY})},[n]);const E=(0,_react.useRef)(false);const N=t=>{if(t.button!==0||!(t.target instanceof Element))return;if(t.target.closest('button, a, input, select, textarea, [role="button"], [role="switch"], [role="slider"], [role="checkbox"], [role="radio"], [contenteditable="true"], [data-floating-accessory]'))return;E.current=true;_(t)};const H=(0,_react.useCallback)(t=>{const i=n.handleDragMove({clientX:t.clientX,clientY:t.clientY});if(i.isDragging){A(i.position)}},[n,A]);const x=(0,_react.useCallback)(t=>{k(false);const i=n.handleDragEnd({clientX:t.clientX,clientY:t.clientY});const a=E.current;E.current=false;if(i.wasTap&&!a){const l=n.toggleHideShow();g(o.position,l.targetPosition,()=>{n.commitPosition(l.targetPosition)})}else if(i.shouldHide){g(o.position,i.position,()=>{n.commitPosition(i.position)})}},[n,g,o.position]);(0,_react.useEffect)(()=>{if(L){window.addEventListener("pointermove",H);window.addEventListener("pointerup",x);window.addEventListener("pointercancel",x);return()=>{window.removeEventListener("pointermove",H);window.removeEventListener("pointerup",x);window.removeEventListener("pointercancel",x)}}},[L,H,x]);const R=(0,_react.useRef)(o.position);R.current=o.position;const j=(0,_react.useRef)(o.isHidden);j.current=o.isHidden;const I=(0,_react.useRef)(false);(0,_react.useEffect)(()=>{if(!d)return;if(b&&!I.current){if(j.current)return;I.current=true;const{targetPosition:t}=n.forceHide();g(R.current,t,()=>{})}else if(!b&&I.current){I.current=false;if(!j.current)return;const{targetPosition:t}=n.forceShow();const i=h.current?.getBoundingClientRect().width??100;const a={x:Math.max(10,Math.min(t.x,window.innerWidth-i-10)),y:t.y};g(R.current,a,()=>{n.commitPosition(a)})}},[b,d]);(0,_react.useEffect)(()=>{if(!S||!d)return;const t=h.current?.getBoundingClientRect().width??100;const i=h.current?.getBoundingClientRect().height??32;const a=(0,_onboardingConstantsWeb.calculateTargetPosition)();const l={x:(window.innerWidth-t)/2,y:window.innerHeight-a-i};g(R.current,l,()=>{})},[S,d]);const W=(0,_react.useRef)(void 0);(0,_react.useEffect)(()=>{if(!d||W.current===s)return;W.current=s;if(s!==void 0&&s>0&&o.isHidden){const{targetPosition:t}=n.forceShow();g(o.position,t,()=>n.commitPosition(t))}},[s,d,o.isHidden,o.position,n,g]);const Y=(0,_react.useMemo)(()=>r==="strip"?_react.Children.toArray(m):(0,_floating.interleaveWithDividers)(_react.Children.toArray(m),t=>(0,_jsxRuntime.jsx)(Divider,{},t)),[m,r]);if(!d){return null}const y=Math.max(0,u.y-F-8);const T=Math.max(0,window.innerHeight-u.y-o.bubbleSize.height-8);const $=y>T;const v=y>=48||y>=T;return(0,_jsxRuntime.jsxs)("div",{ref:h,"data-testid":e??"buoy-floating-tool",role:"toolbar","aria-label":"Floating Tools",onPointerDown:c?N:void 0,style:{position:"fixed",left:u.x,top:u.y,zIndex:b?8999:9999,display:"flex",flexDirection:"row",alignItems:"center",backgroundColor:_floating.floatingToolsColors.panel,borderTopLeftRadius:z?0:6,borderTopRightRadius:6,borderBottomLeftRadius:6,borderBottomRightRadius:6,borderWidth:o.isDragging?2:1,borderTopWidth:o.isDragging?2:z?0:1,borderStyle:"solid",borderColor:o.isDragging?_floating.floatingToolsColors.dragActive:(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"66"),boxShadow:o.isDragging?`0 6px 12px ${(0,_floating.withAlpha)(_floating.floatingToolsColors.dragActive,.36)}`:"0 4px 8px rgba(0, 0, 0, 0.3)",cursor:c?o.isDragging?"grabbing":"grab":void 0,userSelect:"none",touchAction:"none",pointerEvents:w?"none":"auto",...r==="strip"?{borderRadius:_nightTheme.night.radius.card,minHeight:48,backgroundColor:_nightTheme.night.color.surface,borderColor:o.isDragging?_nightTheme.night.color.accentBorderStrong:_nightTheme.night.color.separator,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.24)"}:{}},children:[B&&(0,_jsxRuntime.jsx)(_portalHostWeb.BuoyPortal,{children:(0,_jsxRuntime.jsx)("div",{style:{position:"fixed",top:v?u.y:u.y+o.bubbleSize.height,transform:v?"translateY(-100%)":void 0,"--buoy-stack-bottom":v?"0px":"auto","--buoy-stack-top":v?"auto":"0px","--buoy-stack-space":`${v?y:T}px`,left:u.x-1,width:_floating.VISIBLE_HANDLE_WIDTH,overflow:"visible",zIndex:1e4,pointerEvents:w?"none":"auto"},children:B})}),(0,_jsxRuntime.jsxs)("div",{role:"button","aria-label":p,"data-testid":e?`${e}-grip`:"buoy-floating-grip",tabIndex:0,onPointerDown:_,onKeyDown:t=>{if(t.key!=="Enter"&&t.key!==" ")return;t.preventDefault();const i=n.toggleHideShow();g(o.position,i.targetPosition,()=>n.commitPosition(i.targetPosition))},style:{touchAction:"none",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,backgroundColor:(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"1A"),display:"flex",alignItems:"center",justifyContent:"center",width:_floating.VISIBLE_HANDLE_WIDTH,boxSizing:"border-box",borderRight:`1px solid ${(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"66")}`,cursor:o.isDragging?"grabbing":"grab",...r==="strip"?{minHeight:48,backgroundColor:"transparent",borderRight:"none",flexDirection:"column"}:{}},children:[(0,_jsxRuntime.jsx)(GripVerticalIcon,{size:r==="strip"?20:12}),P]}),(0,_jsxRuntime.jsx)(_floating.FloatingToolsProvider,{value:{isDragging:o.isDragging,isHidden:o.isHidden},children:(0,_jsxRuntime.jsx)("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,paddingRight:8},children:Y})}),!o.isHidden&&C&&(0,_jsxRuntime.jsx)("div",{"data-floating-accessory":true,style:{position:"absolute",...$?{bottom:"100%"}:{top:"100%"},left:0,width:"100%",maxHeight:Math.max(y,T),overflowY:"auto",zIndex:1002},children:C})]})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Divider=Divider;exports.FloatingTool=FloatingTool;exports.UserStatus=UserStatus;exports.getBubbleAnchorPosition=getBubbleAnchorPosition;var _portalHostWeb=require("./portalHost.web.js");var _nightTheme=require("../night/nightTheme.js");var _react=require("react");var _onboardingConstantsWeb=require("./onboardingConstants.web.js");var _floating=require("@buoy-gg/floating-tools-react/floating");var _jsxRuntime=require("react/jsx-runtime");const EDGE_PADDING=10;const NATIVE_TOP_PADDING=20;function readSafeAreaInsets(){if(typeof document==="undefined"||!document.body)return{top:0,left:0,bottom:0};const e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top);padding-left:env(safe-area-inset-left);padding-bottom:env(safe-area-inset-bottom)";document.body.appendChild(e);const s=getComputedStyle(e);const r={top:parseFloat(s.paddingTop)||0,left:parseFloat(s.paddingLeft)||0,bottom:parseFloat(s.paddingBottom)||0};document.body.removeChild(e);return r}const webStorageAdapter={getItem:e=>localStorage.getItem(e),setItem:(e,s)=>localStorage.setItem(e,s)};const NATIVE_TEXT_SECONDARY="#A0A0A0";function GripVerticalIcon({size:e=24,color:s=(0,_floating.withAlpha)(NATIVE_TEXT_SECONDARY,"CC")}){const r=(0,_floating.getGripIconLayout)(e);return(0,_jsxRuntime.jsx)("div",{style:{width:e,height:e,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center"},children:[0,1].map(c=>(0,_jsxRuntime.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",marginLeft:r.columnGap/2,marginRight:r.columnGap/2},children:[0,1,2].map(f=>(0,_jsxRuntime.jsx)("div",{style:{width:r.dotSize,height:r.dotSize,borderRadius:r.dotSize/2,backgroundColor:s,marginTop:r.rowGap/2,marginBottom:r.rowGap/2}},f))},c))})}function Divider(){return(0,_jsxRuntime.jsx)("div",{style:{width:1,height:12,backgroundColor:(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"66"),flexShrink:0}})}const userStatusColors={success:_floating.floatingToolsColors.success,optional:_floating.floatingToolsColors.optional,muted:_floating.floatingToolsColors.muted,secondary:NATIVE_TEXT_SECONDARY};function UserStatus({userRole:e,onPress:s}){const{isDragging:r}=(0,_floating.useFloatingToolsContext)();const c=(0,_floating.getUserStatusConfig)(e,userStatusColors);const f=p=>{if(!r&&s){p.stopPropagation();p.currentTarget.focus();s()}};return(0,_jsxRuntime.jsxs)("button",{role:"button","aria-label":s?`${c.label}, Open Dev Tools Menu`:`User status: ${c.label}`,"data-testid":s?"open-dev-tools-button":void 0,onClick:f,style:{display:"flex",flexDirection:"row",alignItems:"center",paddingTop:6,paddingBottom:6,paddingLeft:8,paddingRight:8,flexShrink:0,cursor:s&&!r?"pointer":"default",background:"none",border:"none",margin:0},children:[(0,_jsxRuntime.jsx)("div",{style:{width:6,height:6,borderRadius:3,backgroundColor:c.dotColor,marginRight:4}}),(0,_jsxRuntime.jsx)("span",{style:{fontSize:10,fontWeight:500,color:c.textColor,letterSpacing:.3,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',lineHeight:"normal"},children:c.label})]})}function useWebAnimation(){const e=(0,_react.useRef)(null);const[s,r]=(0,_react.useState)({x:0,y:0});const c=(0,_react.useCallback)((f,p,C)=>{if(e.current){cancelAnimationFrame(e.current)}const P=performance.now();const D=m=>{const b=m-P;const w=Math.min(b/_floating.ANIMATION_DURATION,1);const S=(0,_floating.interpolatePosition)(f,p,w,_floating.easing.easeOutCubic);r(S);if(w<1){e.current=requestAnimationFrame(D)}else{r(p);C?.()}};e.current=requestAnimationFrame(D)},[]);(0,_react.useEffect)(()=>{return()=>{if(e.current){cancelAnimationFrame(e.current)}}},[]);return{position:s,setPosition:r,animateTo:c}}let lastBubbleAnchor=null;function getBubbleAnchorPosition(){return lastBubbleAnchor}function FloatingTool({id:e,revealToken:s,variant:r="bubble",dragFromSurface:c=false,defaultPlacement:f="top",accessibilityLabel:p="Drag handle",accessory:C,handleAdornment:P,enablePositionPersistence:D=true,children:m,pushToSide:b=false,suspendPointerEvents:w=false,centerOnboarding:S=false,minimizedStack:B,hasMinimizedStack:z=false}){const h=(0,_react.useRef)(null);const M=(0,_react.useMemo)(()=>e?{getItem:t=>webStorageAdapter.getItem(`@buoy/floating-tool/${e}/${t}`),setItem:(t,i)=>webStorageAdapter.setItem(`@buoy/floating-tool/${e}/${t}`,i)}:webStorageAdapter,[e]);const{state:o,actions:n,isInitialized:d}=(0,_floating.useFloatingTools)({screenSize:{width:window.innerWidth,height:window.innerHeight},enablePositionPersistence:D,storage:M,...f==="bottom"?{initialBubbleSize:{width:100,height:48},initialPosition:{x:window.innerWidth-100-EDGE_PADDING,y:Math.max(readSafeAreaInsets().top+NATIVE_TOP_PADDING,window.innerHeight-48-readSafeAreaInsets().bottom-EDGE_PADDING)}}:{}});const{position:u,setPosition:A,animateTo:g}=useWebAnimation();(0,_react.useEffect)(()=>{if(d){A(o.position)}},[d,o.position,A]);(0,_react.useEffect)(()=>{if(!e)lastBubbleAnchor={x:u.x,y:u.y}},[u,e]);(0,_react.useEffect)(()=>{if(!d)return;const t=()=>{const l=h.current?.getBoundingClientRect();if(l&&l.width>0&&l.height>0)n.setBubbleSize({width:l.width,height:l.height})};const i=()=>{const l=readSafeAreaInsets().bottom;n.setScreenSize(window.innerWidth,window.innerHeight-(l>0?l-EDGE_PADDING:0));t()};t();const a=typeof ResizeObserver!=="undefined"?new ResizeObserver(t):null;if(h.current)a?.observe(h.current);window.addEventListener("resize",i);return()=>{a?.disconnect();window.removeEventListener("resize",i)}},[n,d]);const[F,G]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{let t=false;const i=()=>{const a=readSafeAreaInsets();G(a.top);if(a.top>0||a.left>0||a.bottom>0){t=true;n.setMinPosition({x:a.left,y:a.top+NATIVE_TOP_PADDING});n.setScreenSize(window.innerWidth,window.innerHeight-(a.bottom>0?a.bottom-EDGE_PADDING:0))}else if(t){t=false;n.setMinPosition({x:EDGE_PADDING,y:EDGE_PADDING});n.setScreenSize(window.innerWidth,window.innerHeight)}};i();window.addEventListener("resize",i);return()=>window.removeEventListener("resize",i)},[n]);const[L,k]=(0,_react.useState)(false);const _=(0,_react.useCallback)(t=>{t.stopPropagation();t.preventDefault();k(true);n.handleDragStart({clientX:t.clientX,clientY:t.clientY})},[n]);const E=(0,_react.useRef)(false);const N=t=>{if(t.button!==0||!(t.target instanceof Element))return;if(t.target.closest('button, a, input, select, textarea, [role="button"], [role="switch"], [role="slider"], [role="checkbox"], [role="radio"], [contenteditable="true"], [data-floating-accessory]'))return;E.current=true;_(t)};const H=(0,_react.useCallback)(t=>{const i=n.handleDragMove({clientX:t.clientX,clientY:t.clientY});if(i.isDragging){A(i.position)}},[n,A]);const x=(0,_react.useCallback)(t=>{k(false);const i=n.handleDragEnd({clientX:t.clientX,clientY:t.clientY});const a=E.current;E.current=false;if(i.wasTap&&!a){const l=n.toggleHideShow();g(o.position,l.targetPosition,()=>{n.commitPosition(l.targetPosition)})}else if(i.shouldHide){g(o.position,i.position,()=>{n.commitPosition(i.position)})}},[n,g,o.position]);(0,_react.useEffect)(()=>{if(L){window.addEventListener("pointermove",H);window.addEventListener("pointerup",x);window.addEventListener("pointercancel",x);return()=>{window.removeEventListener("pointermove",H);window.removeEventListener("pointerup",x);window.removeEventListener("pointercancel",x)}}},[L,H,x]);const R=(0,_react.useRef)(o.position);R.current=o.position;const j=(0,_react.useRef)(o.isHidden);j.current=o.isHidden;const I=(0,_react.useRef)(false);(0,_react.useEffect)(()=>{if(!d)return;if(b&&!I.current){if(j.current)return;I.current=true;const{targetPosition:t}=n.forceHide();g(R.current,t,()=>{})}else if(!b&&I.current){I.current=false;if(!j.current)return;const{targetPosition:t}=n.forceShow();const i=h.current?.getBoundingClientRect().width??100;const a={x:Math.max(10,Math.min(t.x,window.innerWidth-i-10)),y:t.y};g(R.current,a,()=>{n.commitPosition(a)})}},[b,d]);(0,_react.useEffect)(()=>{if(!S||!d)return;const t=h.current?.getBoundingClientRect().width??100;const i=h.current?.getBoundingClientRect().height??32;const a=(0,_onboardingConstantsWeb.calculateTargetPosition)();const l={x:(window.innerWidth-t)/2,y:window.innerHeight-a-i};g(R.current,l,()=>{})},[S,d]);const W=(0,_react.useRef)(void 0);(0,_react.useEffect)(()=>{if(!d||W.current===s)return;W.current=s;if(s!==void 0&&s>0&&o.isHidden){const{targetPosition:t}=n.forceShow();g(o.position,t,()=>n.commitPosition(t))}},[s,d,o.isHidden,o.position,n,g]);const $=(0,_react.useMemo)(()=>r==="strip"?_react.Children.toArray(m):(0,_floating.interleaveWithDividers)(_react.Children.toArray(m),t=>(0,_jsxRuntime.jsx)(Divider,{},t)),[m,r]);if(!d){return null}const y=Math.max(0,u.y-F-8);const T=Math.max(0,window.innerHeight-u.y-o.bubbleSize.height-8);const Y=y>T;const v=y>=48||y>=T;return(0,_jsxRuntime.jsxs)("div",{ref:h,"data-testid":e??"buoy-floating-tool",role:"toolbar","aria-label":"Floating Tools",onPointerDown:c?N:void 0,style:{position:"fixed",left:u.x,top:u.y,zIndex:b?8999:9999,display:"flex",flexDirection:"row",alignItems:"center",backgroundColor:_floating.floatingToolsColors.panel,borderTopLeftRadius:z?0:6,borderTopRightRadius:6,borderBottomLeftRadius:6,borderBottomRightRadius:6,borderWidth:o.isDragging?2:1,borderTopWidth:o.isDragging?2:z?0:1,borderStyle:"solid",borderColor:o.isDragging?_floating.floatingToolsColors.dragActive:(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"66"),boxShadow:o.isDragging?`0 6px 12px ${(0,_floating.withAlpha)(_floating.floatingToolsColors.dragActive,.36)}`:"0 4px 8px rgba(0, 0, 0, 0.3)",cursor:c?o.isDragging?"grabbing":"grab":void 0,userSelect:"none",touchAction:"none",pointerEvents:w?"none":"auto",...r==="strip"?{borderRadius:_nightTheme.night.radius.card,minHeight:48,backgroundColor:_nightTheme.night.color.surface,borderColor:o.isDragging?_nightTheme.night.color.accentBorderStrong:_nightTheme.night.color.separator,boxShadow:"0 4px 16px rgba(0, 0, 0, 0.24)"}:{}},children:[B&&(0,_jsxRuntime.jsx)(_portalHostWeb.BuoyPortal,{children:(0,_jsxRuntime.jsx)("div",{style:{position:"fixed",top:v?u.y:u.y+o.bubbleSize.height,transform:v?"translateY(-100%)":void 0,"--buoy-stack-bottom":v?"0px":"auto","--buoy-stack-top":v?"auto":"0px","--buoy-stack-space":`${v?y:T}px`,left:u.x-1,width:_floating.VISIBLE_HANDLE_WIDTH,overflow:"visible",zIndex:1e4,pointerEvents:w?"none":"auto"},children:B})}),(0,_jsxRuntime.jsxs)("div",{role:"button","aria-label":p,"data-testid":e?`${e}-grip`:"buoy-floating-grip",tabIndex:0,onPointerDown:_,onKeyDown:t=>{if(t.key!=="Enter"&&t.key!==" ")return;t.preventDefault();const i=n.toggleHideShow();g(o.position,i.targetPosition,()=>n.commitPosition(i.targetPosition))},style:{touchAction:"none",paddingLeft:6,paddingRight:6,paddingTop:6,paddingBottom:6,backgroundColor:(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"1A"),display:"flex",alignItems:"center",justifyContent:"center",width:_floating.VISIBLE_HANDLE_WIDTH,boxSizing:"border-box",borderRight:`1px solid ${(0,_floating.withAlpha)(_floating.floatingToolsColors.muted,"66")}`,cursor:o.isDragging?"grabbing":"grab",...r==="strip"?{minHeight:48,backgroundColor:"transparent",borderRight:"none",flexDirection:"column"}:{}},children:[(0,_jsxRuntime.jsx)(GripVerticalIcon,{size:r==="strip"?20:12}),P]}),(0,_jsxRuntime.jsx)(_floating.FloatingToolsProvider,{value:{isDragging:o.isDragging,isHidden:o.isHidden},children:(0,_jsxRuntime.jsx)("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:6,paddingRight:8},children:$})}),!o.isHidden&&C&&(0,_jsxRuntime.jsx)("div",{"data-floating-accessory":true,style:{position:"absolute",...Y?{bottom:"100%"}:{top:"100%"},left:0,width:"100%",maxHeight:Math.max(y,T),overflowY:"auto",zIndex:1002},children:C})]})}
@@ -1 +1 @@
1
- "use strict";import{getUseAccountAccess as We}from"./license/licenseModule.js";import{AccountSetup as Ee}from"./license/AccountSetup";import{useState as $,useRef as l,useEffect as I,useMemo as se,useCallback as nt,memo as Mt,isValidElement as le,cloneElement as de}from"react";import{View as c,StyleSheet as Wt,TouchableWithoutFeedback as ce,Dimensions as ue,PanResponder as he,Animated as r,ScrollView as fe,Text as jt,TextInput as Ne,Keyboard as St,Easing as Oe,Platform as Pe}from"react-native";import{absoluteFill as Yt}from"./utils/absoluteFill.js";import{useSafeAreaInsets as Fe}from"./hooks/useSafeAreaInsets";import{gameUIColors as O,buoyColors as V}from"./ui/gameUI/index.js";import{DraggableHeader as _e,ModalHintBanner as Ge,WindowControls as ge}from"./ui/components/index.js";import{ToolBackground as Et}from"./ui/backgrounds/ToolBackground.js";import{night as L}from"./ui/night/nightTheme.js";import{persistentStorage as me}from"./utils/persistentStorage";import{ModalStorage as Xt}from"./utils/modalStorage.js";import{devToolsStorageKeys as pe}from"./storage/devToolsStorageKeys.js";import{useHintsDisabled as ze}from"./context/index.js";import{jsx as e,jsxs as K}from"react/jsx-runtime";const we=true;const p=ue.get("window");const je=100;const Ye=400;const wt=p.width;const bt=500;const xt=p.width*.25;const Ht=80;const Xe=20;const Ue=16;function Je(a,s){const v=l(null);const S=l(new r.Value(0)).current;const w=l(new r.Value(0)).current;I(()=>{if(!a||Pe.OS!=="ios")return;let P=0;const b=(f,y,x)=>{const G=(W,g)=>r.timing(W,{toValue:g,duration:x.duration||250,easing:Oe.bezier(.17,.59,.4,.77),useNativeDriver:false});r.parallel([G(S,f),G(w,y)]).start()};const h=f=>{const y=v.current;const x=++P;if(!y)return;const G=Ne.State.currentlyFocusedInput();const W=g=>new Promise(H=>{if(!g?.measureInWindow)return H(null);g.measureInWindow((C,J,rt,u)=>H({y:J,h:u}))});Promise.all([W(y),W(G)]).then(([g,H])=>{if(x!==P||!g)return;const C=ue.get("window").height;const J=f.endCoordinates.screenY;const rt=C-g.h;const u=C-J;const ut=Math.max(0,rt-s-8);const ht=Math.max(0,Math.min(u,ut));if(!H)return b(ht,Math.max(0,u-ht),f);if(H.y<g.y||H.y>=g.y+g.h)return b(0,0,f);const ft=rt+(H.y-g.y)+H.h;const B=ft+Ue-J;const kt=Math.max(0,Math.min(B,ht));b(kt,Math.max(0,u-kt),f)})};const A=f=>{P++;b(0,0,f)};const U=[St.addListener("keyboardWillChangeFrame",h),St.addListener("keyboardWillShow",h),St.addListener("keyboardWillHide",A)];return()=>{P++;U.forEach(f=>f.remove());S.stopAnimation();w.stopAnimation();S.setValue(0);w.setValue(0)}},[a,s,S,w]);const X=l(r.multiply(S,-1)).current;return{sheetRef:v,lift:S,raise:X,pad:w}}const be=Mt(function a({isResizing:s,mode:v,hasCustomContent:S=false,variant:w="default"}){return K(c,{style:[o.dragIndicatorContainer,S&&o.dragIndicatorContainerCustom],children:[e(c,{style:[o.dragIndicator,v==="floating"&&o.floatingDragIndicator,s&&o.dragIndicatorActive,w==="night"&&o.nightDragIndicator]}),s&&v==="bottomSheet"&&K(c,{style:o.resizeGripContainer,children:[e(c,{style:o.resizeGripLine}),e(c,{style:o.resizeGripLine}),e(c,{style:o.resizeGripLine})]})]})});const ye=Mt(function a({position:s,isActive:v}){return e(c,{style:[o.cornerHandle],children:e(c,{style:[o.handler,v&&o.handlerActive]})})});const Ce=Mt(function a({header:s,onClose:v,onToggleMode:S,onMinimize:w,isResizing:X,mode:P,panHandlers:b,variant:h="default"}){const A=l(0);const U=l(0);const f=l(null);const y=nt(()=>{const g=Date.now();const H=g-A.current;if(H>500){U.current=0}U.current++;A.current=g;if(f.current){clearTimeout(f.current)}f.current=setTimeout(()=>{if(U.current===2){S()}else if(U.current>=3){if(w){w()}}U.current=0},300)},[S,w]);I(()=>{return()=>{if(f.current){clearTimeout(f.current)}}},[]);const x=b?b:{};const G=!!b;if(s?.customContent){const g=le(s.customContent)&&typeof s.customContent.type==="function"&&s.customContent.type.name==="CyberpunkModalHeader";if(g){return de(s.customContent,{onToggleMode:S,onClose:v,mode:P,panHandlers:x,showToggleButton:s?.showToggleButton!==false,hideCloseButton:s?.hideCloseButton})}let H=s.customContent;if(le(s.customContent)&&w){H=de(s.customContent,{onMinimize:w})}const C=K(c,{style:o.headerInner,children:[e(be,{isResizing:X,mode:P,hasCustomContent:true,variant:h}),H]});return e(c,{style:[o.header,h==="night"&&o.nightHeader],...x,children:G?e(ce,{onPress:y,children:C}):C})}const W=K(c,{style:o.headerInner,children:[e(be,{isResizing:X,mode:P,variant:h}),K(c,{style:o.headerContent,children:[s?.title&&e(jt,{style:o.headerTitle,children:s.title}),s?.subtitle&&e(jt,{style:o.headerSubtitle,children:s.subtitle})]}),e(c,{style:o.headerHintText,children:e(jt,{style:o.hintText,children:"Double tap: Toggle \u2022 Triple tap: Close"})})]});return e(c,{style:[o.header,P==="floating"&&o.floatingModeHeader,h==="night"&&o.nightHeader],...x,children:G?e(ce,{onPress:y,children:W}):W})});const qe=({visible:a,onClose:s,children:v,header:S,styles:w={},minHeight:X=je,maxHeight:P,initialHeight:b=Ye,animatedHeight:h,benchMotion:A,initialMode:U="bottomSheet",onModeChange:f,persistenceKey:y,enablePersistence:x=true,initialFloatingPosition:G,footer:W,footerHeight:g=0,onBack:H,onMinimize:C,minimizeRequest:J=0,minimizeTargetPosition:rt,initialModalState:u,zIndex:ut,disableScrollWrapper:ht=false,background:ft=true,variant:B="night",avoidKeyboard:kt=true})=>{const F=Fe();const Nt=l(false);I(()=>{if(a)Nt.current=true;else if(Nt.current)St.dismiss()},[a]);I(()=>()=>{if(Nt.current)St.dismiss()},[]);const[Ut,Jt]=$(!x);const[d,Ot]=$(U);const Pt=Je(kt&&a&&d==="bottomSheet",F.top);const[gt,z]=$(false);const[Lt,mt]=$(false);const[Ve,Ft]=$(b);const[q,yt]=$({width:wt,height:bt,top:(p.height-bt)/2,left:0});const[vt]=$({width:p.width,height:p.height});const[Te,At]=$(false);const[De,qt]=$(false);const Ie=ze();const T=l(new r.Value(0)).current;const M=l(new r.Value(p.height)).current;const Qt=l(new r.Value(0)).current;const j=l(new r.Value(b)).current;const Y=l(b);I(()=>{if(!x||!y||!Ut)return;const t=setTimeout(()=>{Xt.save(y,{mode:d,panelHeight:Y.current,dimensions:q,isVisible:a})},500);return()=>clearTimeout(t)},[d,Ve,q,a,y,x,Ut]);const Zt=l(false);I(()=>{if(h&&!Zt.current){Zt.current=true;Y.current=b;h.setValue(b)}},[h,b]);I(()=>{k.current=q},[q]);const R=l(new r.ValueXY({x:G?.x??0,y:G?.y??(p.height-bt)/2})).current;const it=l(new r.Value(0)).current;const at=l(new r.Value(wt)).current;const st=l(new r.Value(bt)).current;const k=l(q);const $t=l(q);const Se=l(0);const xe=l(0);const He=l(0);const ke=l(0);I(()=>{let t=true;const i=async()=>{try{const n=pe.modal.hintAcknowledged();const Q=await me.getItem(n);if(t){At(Q!=="true");qt(true)}}catch(n){if(t){At(true);qt(true)}}};i();return()=>{t=false}},[]);const Le=nt(async()=>{try{const t=pe.modal.hintAcknowledged();await me.setItem(t,"true");At(false)}catch(t){At(false)}},[]);const Kt=l(f);Kt.current=f;I(()=>{if(!x||!y){Jt(true);return}let t=true;const i=async()=>{const n=await Xt.load(y);if(t&&n){if(n.mode){Ot(n.mode);Kt.current?.(n.mode)}if(n.panelHeight){Ft(n.panelHeight);Y.current=n.panelHeight;j.setValue(n.panelHeight);h?.setValue(n.panelHeight)}if(n.dimensions){yt(n.dimensions);R.setValue({x:n.dimensions.left,y:n.dimensions.top});at.setValue(n.dimensions.width);st.setValue(n.dimensions.height)}}if(t)Jt(true)};i();return()=>{t=false}},[y,x,j,st,at,R]);I(()=>{return()=>{T.stopAnimation();M.stopAnimation();it.stopAnimation();Qt.stopAnimation();j.stopAnimation();R.stopAnimation();at.stopAnimation();st.stopAnimation();T.setValue(0);M.setValue(p.height);it.setValue(0);Qt.setValue(0);j.setValue(b);Y.current=b}},[]);const te=T.interpolate({inputRange:[0,1],outputRange:[0,1],extrapolate:"clamp"});const _t=P||p.height-F.top;const lt=nt(()=>{mt(false);z(false);const t=d==="bottomSheet"?"floating":"bottomSheet";Ot(t);f?.(t)},[d,f]);I(()=>{mt(false);z(false)},[d]);const tt=nt(()=>{if(!C)return;const t={mode:d,panelHeight:Y.current,floatingPosition:{x:k.current.left,y:k.current.top},floatingDimensions:{width:k.current.width,height:k.current.height}};if(x&&y)void Xt.saveMinimized(y,t);const i=rt?.x??p.width-50;const n=rt?.y??p.height-150;if(d==="bottomSheet"){r.parallel([r.timing(T,{toValue:0,duration:300,useNativeDriver:true}),r.timing(M,{toValue:p.height,duration:300,useNativeDriver:true})]).start(()=>{C(t)})}else{r.parallel([r.timing(it,{toValue:0,duration:300,useNativeDriver:true}),r.timing(T,{toValue:0,duration:300,useNativeDriver:true}),r.timing(R,{toValue:{x:i,y:n},duration:300,useNativeDriver:true})]).start(()=>{C(t)})}},[d,C,rt,x,y,T,M,it,R]);const ee=l(J);I(()=>{if(ee.current===J)return;ee.current=J;tt()},[J,tt]);I(()=>{if(!u)return;if(u.mode){Ot(u.mode);f?.(u.mode)}if(u.panelHeight){Ft(u.panelHeight);Y.current=u.panelHeight;j.setValue(u.panelHeight)}if(u.floatingDimensions&&u.floatingPosition){const t={width:u.floatingDimensions.width,height:u.floatingDimensions.height,top:u.floatingPosition.y,left:u.floatingPosition.x};yt(t);R.setValue({x:u.floatingPosition.x,y:u.floatingPosition.y});at.setValue(u.floatingDimensions.width);st.setValue(u.floatingDimensions.height)}},[u]);const oe=t=>{if(t){if(d==="bottomSheet"){M.setValue(0)}else{it.setValue(1);R.setValue({x:k.current.left,y:k.current.top})}T.setValue(1)}else{if(d==="bottomSheet"){M.setValue(p.height)}T.setValue(0)}};const ne=l(null);if(we&&ne.current!==a){ne.current=a;oe(a)}I(()=>{let t=null;let i=null;if(we){oe(a);return}if(a){M.setValue(p.height);T.setValue(0);if(d==="bottomSheet"){t=r.parallel([r.spring(M,{toValue:0,tension:180,friction:22,useNativeDriver:true}),r.timing(T,{toValue:1,duration:200,useNativeDriver:true})]);t.start()}else{it.setValue(1);R.setValue({x:k.current.left,y:k.current.top});t=r.timing(T,{toValue:1,duration:200,useNativeDriver:true});t.start()}}else{if(d==="bottomSheet"){i=r.parallel([r.spring(M,{toValue:p.height,tension:180,friction:22,useNativeDriver:true}),r.timing(T,{toValue:0,duration:200,useNativeDriver:true})]);i.start()}else{i=r.timing(T,{toValue:0,duration:200,useNativeDriver:true});i.start()}}return()=>{if(t){t.stop()}if(i){i.stop()}}},[a,d,T,M,it,R,h]);const re=l(0);I(()=>{if(!__DEV__||!A||!a)return void 0;let t=null;let i=null;let n=true;const Q=Date.now();let E=false;const et=Z=>{E=Z;if(A==="resize"||A==="float-resize"){z(Z)}else if(A==="float-drag"){mt(Z)}};if(A==="mode-cycle"){i=setInterval(()=>lt(),2200)}else{const Z=X;const Bt=_t;const Tt=()=>{if(!n)return;const pt=(Date.now()-Q)/1e3;const m=pt%2.5;if(m<2&&!E)et(true);else if(m>=2&&E)et(false);if(E){const N=(Math.sin(pt*2.2)+1)/2;if(A==="resize"){const D=Z+N*(Bt-Z);j.setValue(D);Y.current=D;if(h){h.setValue(D)}}else if(A==="float-drag"){const D=(Math.sin(pt*1.7)+1)/2;R.setValue({x:10+N*Math.max(p.width-wt-20,0),y:70+D*260})}else if(A==="float-resize"){const D=wt+N*Math.max(p.width-wt-40,0);const _=bt+N*240;at.setValue(D);st.setValue(_);k.current={...k.current,width:D,height:_}}}t=requestAnimationFrame(Tt)};t=requestAnimationFrame(Tt)}return()=>{n=false;if(t!=null)cancelAnimationFrame(t);if(i!=null)clearInterval(i);z(false);mt(false)}},[A,a]);const ve=se(()=>he.create({onStartShouldSetPanResponder:()=>d==="bottomSheet",onMoveShouldSetPanResponder:(t,i)=>d==="bottomSheet"&&Math.abs(i.dy)>3,onPanResponderTerminationRequest:()=>false,onPanResponderGrant:t=>{z(true);re.current=t.nativeEvent.locationY||0;j.stopAnimation(i=>{Y.current=i});h?.stopAnimation();M.stopAnimation()},onPanResponderMove:t=>{const i=t.nativeEvent.pageY-re.current;let n=p.height-i;n=Math.max(X,Math.min(n,_t));j.setValue(n);Y.current=n;if(h){h.setValue(n)}},onPanResponderRelease:(t,i)=>{z(false);const n=Y.current;const Q=i.vy>.8&&i.dy>50||i.dy>150&&n<=X;if(Q){r.parallel([r.timing(T,{toValue:0,duration:200,useNativeDriver:true}),r.spring(M,{toValue:p.height,tension:180,friction:22,useNativeDriver:true})]).start(()=>s());return}Ft(n);if(h)h.setValue(n)},onPanResponderTerminate:()=>{z(false)}}),[d,X,_t,j,h,M,T,s]);const Ct=nt(t=>{let i=false;return he.create({onStartShouldSetPanResponder:()=>d==="floating",onMoveShouldSetPanResponder:()=>d==="floating",onPanResponderGrant:()=>{i=false;const n=k.current;R.stopAnimation(({x:Q,y:E})=>{R.setValue({x:Q,y:E})});z(true);$t.current={...n};He.current=n.height;ke.current=n.width;Se.current=n.left;xe.current=n.top},onPanResponderMove:(n,Q)=>{const{dx:E,dy:et}=Q;if(Math.abs(E)<.5&&Math.abs(et)<.5)return;i=true;const Z=Math.max(0,F.left||0);const Bt=vt.width-Math.max(0,F.right||0);const Tt=Math.max(0,F.top||0);const pt=vt.height-Math.max(0,F.bottom||0);const m=$t.current;const N=m.left+m.width;const D=m.top+m.height;let _=m.left;let ot=m.top;let Dt=N;let It=D;switch(t){case"topLeft":{const dt=Math.max(Z,Math.min(m.left+E,N-xt));const ct=Math.max(Tt,Math.min(m.top+et,D-Ht));_=dt;ot=ct;Dt=N;It=D;break}case"topRight":{const dt=Math.min(Bt,Math.max(N+E,m.left+xt));const ct=Math.max(Tt,Math.min(m.top+et,D-Ht));_=m.left;ot=ct;Dt=dt;It=D;break}case"bottomLeft":{const dt=Math.max(Z,Math.min(m.left+E,N-xt));const ct=Math.min(pt,Math.max(D+et,m.top+Ht));_=dt;ot=m.top;Dt=N;It=ct;break}case"bottomRight":{const dt=Math.min(Bt,Math.max(N+E,m.left+xt));const ct=Math.min(pt,Math.max(D+et,m.top+Ht));_=m.left;ot=m.top;Dt=dt;It=ct;break}}const Gt=Math.max(xt,Dt-_);const zt=Math.max(Ht,It-ot);yt({width:Gt,height:zt,left:_,top:ot});at.setValue(Gt);st.setValue(zt);R.setValue({x:_,y:ot});k.current={width:Gt,height:zt,left:_,top:ot}},onPanResponderRelease:()=>{z(false);i=false;yt(k.current)},onPanResponderTerminate:()=>{z(false);i=false}})},[d,vt,F.left,F.right,F.top,F.bottom,R,at,st,s,H]);const ie=se(()=>{return{topLeft:Ct("topLeft"),topRight:Ct("topRight"),bottomLeft:Ct("bottomLeft"),bottomRight:Ct("bottomRight")}},[Ct]);const Ae=nt(()=>{mt(true)},[]);const Be=nt(t=>{mt(false);const i=k.current;const n={...i,left:t.x,top:t.y};yt(n)},[]);const ae=l(0);const Rt=l(0);const Vt=l(null);const Me=nt(()=>{const t=Date.now();const i=t-ae.current;if(i>500){Rt.current=0}Rt.current++;ae.current=t;if(Vt.current){clearTimeout(Vt.current)}Vt.current=setTimeout(()=>{if(Rt.current===2){lt()}else if(Rt.current>=3){if(C){tt()}}Rt.current=0},300)},[lt,C,tt]);I(()=>{return()=>{if(Vt.current){clearTimeout(Vt.current)}}},[]);if(d==="floating"){return K(r.View,{nativeID:"jsmodal-root",pointerEvents:a?"auto":"none",accessibilityElementsHidden:!a,importantForAccessibility:a?"auto":"no-hide-descendants",style:[o.floatingModal,{width:q.width,height:q.height,opacity:te,transform:[{translateX:R.x},{translateY:R.y}],...ut!==void 0&&{zIndex:ut}},B==="night"&&o.nightFloatingModal,(Lt||gt)&&o.floatingModalDragging,w.container,!a&&o.parkedOffscreen],children:[ft&&B==="night"?e(c,{style:o.nightBackdropFloating,pointerEvents:"none",children:e(Et,{})}):null,e(_e,{position:R,onDragStart:Ae,onDragEnd:Be,onTap:Me,containerBounds:vt,elementSize:q,minPosition:{x:0,y:F.top},style:o.floatingHeader,enabled:d==="floating"&&!gt,children:e(Ce,{header:S,onClose:s,onToggleMode:lt,onMinimize:C?tt:void 0,isResizing:Lt||gt,mode:d,variant:B})}),e(c,{style:o.windowControlsContainer,children:e(ge,{onClose:s,onMinimize:C?tt:void 0,onToggleMode:lt,mode:d,variant:B})}),K(c,{style:[o.content,B==="night"&&o.nightContent,w.content],children:[ft&&B!=="night"?e(Et,{}):null,ht?e(c,{style:{flex:1,paddingBottom:g},children:v}):e(fe,{style:{flex:1},contentContainerStyle:{flexGrow:1,paddingBottom:g},showsVerticalScrollIndicator:true,nestedScrollEnabled:true,keyboardShouldPersistTaps:"handled",children:v}),W?e(c,{style:Re.footerContainer,children:W}):null]}),e(c,{...ie.bottomLeft.panHandlers,style:[o.cornerHandleWrapper,{bottom:4,left:4}],hitSlop:{top:2,left:2,right:2,bottom:2},children:e(ye,{position:"bottomLeft",isActive:Lt||gt})}),e(c,{...ie.bottomRight.panHandlers,style:[o.cornerHandleWrapper,{bottom:4,right:4}],hitSlop:{top:2,left:2,right:2,bottom:2},children:e(ye,{position:"bottomRight",isActive:Lt||gt})})]})}return e(c,{style:[a?o.fullScreenContainer:o.parkedFullScreen,a&&ut!==void 0&&{zIndex:ut}],pointerEvents:a?"box-none":"none",accessibilityElementsHidden:!a,importantForAccessibility:a?"auto":"no-hide-descendants",children:e(r.View,{nativeID:"jsmodal-root",style:[o.bottomSheetWrapper,{opacity:te,transform:[{translateY:M}]}],children:e(r.View,{style:{transform:[{translateY:Pt.raise}]},children:K(r.View,{ref:Pt.sheetRef,style:[o.bottomSheet,B==="night"&&o.nightBottomSheet,w.container,{height:h||j}],children:[ft&&B==="night"?e(c,{style:o.nightBackdropSheet,pointerEvents:"none",children:e(Et,{})}):null,e(Ce,{header:S,onClose:s,onToggleMode:lt,onMinimize:C?tt:void 0,isResizing:gt,mode:d,panHandlers:ve.panHandlers,variant:B}),e(c,{style:o.windowControlsContainer,children:e(ge,{onClose:s,onMinimize:C?tt:void 0,onToggleMode:lt,mode:d,variant:B})}),De&&Te&&d==="bottomSheet"&&!Ie&&e(Ge,{onAcknowledge:Le}),K(r.View,{style:[o.content,B==="night"&&o.nightContent,w.content,{paddingBottom:Pt.pad}],children:[ft&&B!=="night"?e(Et,{}):null,ht?e(c,{style:{flex:1,paddingBottom:g},children:v}):e(fe,{style:{flex:1},contentContainerStyle:{flexGrow:1,paddingBottom:g},showsVerticalScrollIndicator:true,nestedScrollEnabled:true,keyboardShouldPersistTaps:"handled",children:v}),W?e(c,{style:Re.footerContainer,children:W}):null]})]})})})})};const o=Wt.create({fullScreenContainer:{...Yt,zIndex:1e3},bottomSheetWrapper:{position:"absolute",bottom:0,left:0,right:0},bottomSheet:{backgroundColor:V.card,borderTopLeftRadius:6,borderTopRightRadius:6,borderWidth:1,borderColor:V.border,shadowColor:V.primary,shadowOffset:{width:0,height:-4},shadowOpacity:.2,shadowRadius:12,elevation:20},parkedOffscreen:{left:-9999,top:-9999,opacity:0},parkedFullScreen:{position:"absolute",left:-9999,top:-9999,width:p.width,height:p.height,opacity:0},floatingModal:{position:"absolute",backgroundColor:V.card,borderRadius:6,borderWidth:1,borderColor:V.border,shadowColor:V.primary,shadowOffset:{width:0,height:0},shadowOpacity:.3,shadowRadius:20,elevation:24,zIndex:1e3,width:wt,height:bt},floatingModalDragging:{borderColor:V.primary,borderWidth:2,shadowColor:V.primary+"99",shadowOpacity:.8,shadowRadius:12},header:{borderTopLeftRadius:6,borderTopRightRadius:6,backgroundColor:V.card,minHeight:56,borderWidth:1,borderColor:V.border,borderBottomWidth:1,borderBottomColor:V.border},nightBottomSheet:{backgroundColor:L.color.bg,borderTopLeftRadius:L.radius.sheet,borderTopRightRadius:L.radius.sheet,borderWidth:Wt.hairlineWidth,borderColor:L.color.accent+"55",shadowColor:L.color.accent,shadowOffset:{width:0,height:-4},shadowOpacity:.22,shadowRadius:10},nightFloatingModal:{backgroundColor:L.color.bg,borderRadius:L.radius.sheet,borderWidth:Wt.hairlineWidth,borderColor:L.color.accent+"55",shadowColor:L.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.22,shadowRadius:14},nightHeader:{backgroundColor:"transparent",borderWidth:0,borderBottomWidth:0,borderTopLeftRadius:L.radius.sheet,borderTopRightRadius:L.radius.sheet},nightContent:{backgroundColor:"transparent"},nightBackdropSheet:{...Yt,borderTopLeftRadius:L.radius.sheet,borderTopRightRadius:L.radius.sheet,overflow:"hidden"},nightBackdropFloating:{...Yt,borderRadius:L.radius.sheet,overflow:"hidden"},nightDragIndicator:{width:36,height:5,borderRadius:2.5,backgroundColor:L.color.placeholder,shadowOpacity:0,elevation:0},floatingHeader:{borderTopLeftRadius:6,borderTopRightRadius:6},windowControlsContainer:{position:"absolute",top:4,right:4,zIndex:10},floatingModeHeader:{borderTopLeftRadius:6,borderTopRightRadius:6},headerInner:{flex:1,justifyContent:"center"},dragIndicatorContainer:{alignItems:"center",paddingVertical:8,backgroundColor:"transparent"},dragIndicatorContainerCustom:{minHeight:Xe,justifyContent:"center",paddingVertical:0,backgroundColor:"transparent"},dragIndicator:{width:40,height:3,backgroundColor:V.primary,borderRadius:2,shadowColor:V.primary,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:4},floatingDragIndicator:{width:50,height:5,backgroundColor:V.textMuted},dragIndicatorActive:{backgroundColor:V.primary,width:40},resizeGripContainer:{position:"absolute",flexDirection:"row",gap:2,marginTop:12},resizeGripLine:{width:12,height:1,backgroundColor:O.success,opacity:.6},headerContent:{paddingHorizontal:16,alignItems:"center"},headerControls:{position:"absolute",top:8,right:16,flexDirection:"row",alignItems:"center"},headerTitle:{fontSize:16,fontWeight:"600",color:O.primary},headerSubtitle:{fontSize:12,color:O.secondary,paddingTop:4},headerHintText:{position:"absolute",top:0,left:0,right:0,bottom:0,justifyContent:"center",alignItems:"center"},hintText:{fontSize:10,color:O.muted,fontStyle:"italic"},controlButton:{width:28,height:28,borderRadius:6,justifyContent:"center",alignItems:"center",marginLeft:8},toggleButton:{backgroundColor:O.info+"1A",borderWidth:1,borderColor:O.info+"33"},closeButton:{width:28,height:28,borderRadius:6,justifyContent:"center",alignItems:"center",backgroundColor:O.error+"1A",borderWidth:1,borderColor:O.error+"33",marginLeft:8},iconLine:{position:"absolute",top:7.25,left:2,width:12,height:1.5,backgroundColor:O.error},content:{flex:1,backgroundColor:V.base,borderBottomLeftRadius:16,borderBottomRightRadius:16,overflow:"hidden"},cornerHandle:{position:"absolute",zIndex:1},cornerHandleWrapper:{position:"absolute",width:30,height:30,zIndex:1e3},handler:{width:20,height:20,backgroundColor:"transparent",borderRadius:10,borderWidth:0,borderColor:"transparent"},handlerActive:{backgroundColor:O.success+"1A",borderColor:O.success,borderWidth:2,shadowColor:O.success+"99",shadowOffset:{width:0,height:0},shadowOpacity:1,shadowRadius:8}});const Re=Wt.create({footerContainer:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:V.base,borderBottomLeftRadius:16,borderBottomRightRadius:16}});export const JsModal=Mt(a=>{const s=We()();if(s.status!=="admitted")return a.visible?e(Ee,{}):null;return e(qe,{...a})});
1
+ "use strict";import{getUseAccountAccess as We}from"./license/licenseModule.js";import{AccountSetup as Ee}from"./license/AccountSetup";import{useState as $,useRef as l,useEffect as S,useMemo as se,useCallback as nt,memo as Mt,isValidElement as le,cloneElement as de}from"react";import{View as c,StyleSheet as Wt,TouchableWithoutFeedback as ce,Dimensions as ue,PanResponder as he,Animated as r,ScrollView as fe,Text as jt,TextInput as Ne,Keyboard as St,Easing as Oe,Platform as Pe}from"react-native";import{absoluteFill as Yt}from"./utils/absoluteFill.js";import{useSafeAreaInsets as Fe}from"./hooks/useSafeAreaInsets";import{gameUIColors as O,buoyColors as V}from"./ui/gameUI/index.js";import{DraggableHeader as _e,ModalHintBanner as Ge,WindowControls as ge}from"./ui/components/index.js";import{ToolBackground as Et}from"./ui/backgrounds/ToolBackground.js";import{night as v}from"./ui/night/nightTheme.js";import{persistentStorage as me}from"./utils/persistentStorage";import{ModalStorage as Xt}from"./utils/modalStorage.js";import{devToolsStorageKeys as pe}from"./storage/devToolsStorageKeys.js";import{useHintsDisabled as ze}from"./context/index.js";import{jsx as e,jsxs as K}from"react/jsx-runtime";const we=true;const p=ue.get("window");const je=100;const Ye=400;const wt=p.width;const bt=500;const xt=p.width*.25;const Ht=80;const Xe=20;const Ue=16;function Je(a,s){const T=l(null);const x=l(new r.Value(0)).current;const w=l(new r.Value(0)).current;S(()=>{if(!a||Pe.OS!=="ios")return;let P=0;const b=(f,y,H)=>{const G=(W,g)=>r.timing(W,{toValue:g,duration:H.duration||250,easing:Oe.bezier(.17,.59,.4,.77),useNativeDriver:false});r.parallel([G(x,f),G(w,y)]).start()};const h=f=>{const y=T.current;const H=++P;if(!y)return;const G=Ne.State.currentlyFocusedInput();const W=g=>new Promise(k=>{if(!g?.measureInWindow)return k(null);g.measureInWindow((C,J,rt,u)=>k({y:J,h:u}))});Promise.all([W(y),W(G)]).then(([g,k])=>{if(H!==P||!g)return;const C=ue.get("window").height;const J=f.endCoordinates.screenY;const rt=C-g.h;const u=C-J;const ut=Math.max(0,rt-s-8);const ht=Math.max(0,Math.min(u,ut));if(!k)return b(ht,Math.max(0,u-ht),f);if(k.y<g.y||k.y>=g.y+g.h)return b(0,0,f);const ft=rt+(k.y-g.y)+k.h;const B=ft+Ue-J;const kt=Math.max(0,Math.min(B,ht));b(kt,Math.max(0,u-kt),f)})};const A=f=>{P++;b(0,0,f)};const U=[St.addListener("keyboardWillChangeFrame",h),St.addListener("keyboardWillShow",h),St.addListener("keyboardWillHide",A)];return()=>{P++;U.forEach(f=>f.remove());x.stopAnimation();w.stopAnimation();x.setValue(0);w.setValue(0)}},[a,s,x,w]);const X=l(r.multiply(x,-1)).current;return{sheetRef:T,lift:x,raise:X,pad:w}}const be=Mt(function a({isResizing:s,mode:T,hasCustomContent:x=false,variant:w="default"}){return K(c,{style:[o.dragIndicatorContainer,x&&o.dragIndicatorContainerCustom],children:[e(c,{style:[o.dragIndicator,T==="floating"&&o.floatingDragIndicator,s&&o.dragIndicatorActive,w==="night"&&o.nightDragIndicator]}),s&&T==="bottomSheet"&&K(c,{style:o.resizeGripContainer,children:[e(c,{style:o.resizeGripLine}),e(c,{style:o.resizeGripLine}),e(c,{style:o.resizeGripLine})]})]})});const ye=Mt(function a({position:s,isActive:T}){return e(c,{style:[o.cornerHandle],children:e(c,{style:[o.handler,T&&o.handlerActive]})})});const Ce=Mt(function a({header:s,onClose:T,onToggleMode:x,onMinimize:w,isResizing:X,mode:P,panHandlers:b,variant:h="default"}){const A=l(0);const U=l(0);const f=l(null);const y=nt(()=>{const g=Date.now();const k=g-A.current;if(k>500){U.current=0}U.current++;A.current=g;if(f.current){clearTimeout(f.current)}f.current=setTimeout(()=>{if(U.current===2){x()}else if(U.current>=3){if(w){w()}}U.current=0},300)},[x,w]);S(()=>{return()=>{if(f.current){clearTimeout(f.current)}}},[]);const H=b?b:{};const G=!!b;if(s?.customContent){const g=le(s.customContent)&&typeof s.customContent.type==="function"&&s.customContent.type.name==="CyberpunkModalHeader";if(g){return de(s.customContent,{onToggleMode:x,onClose:T,mode:P,panHandlers:H,showToggleButton:s?.showToggleButton!==false,hideCloseButton:s?.hideCloseButton})}let k=s.customContent;if(le(s.customContent)&&w){k=de(s.customContent,{onMinimize:w})}const C=K(c,{style:o.headerInner,children:[e(be,{isResizing:X,mode:P,hasCustomContent:true,variant:h}),k]});return e(c,{style:[o.header,h==="night"&&o.nightHeader],...H,children:G?e(ce,{onPress:y,children:C}):C})}const W=K(c,{style:o.headerInner,children:[e(be,{isResizing:X,mode:P,variant:h}),K(c,{style:o.headerContent,children:[s?.title&&e(jt,{style:o.headerTitle,children:s.title}),s?.subtitle&&e(jt,{style:o.headerSubtitle,children:s.subtitle})]}),e(c,{style:o.headerHintText,children:e(jt,{style:o.hintText,children:"Double tap: Toggle \u2022 Triple tap: Close"})})]});return e(c,{style:[o.header,P==="floating"&&o.floatingModeHeader,h==="night"&&o.nightHeader],...H,children:G?e(ce,{onPress:y,children:W}):W})});const qe=({visible:a,onClose:s,children:T,header:x,styles:w={},minHeight:X=je,maxHeight:P,initialHeight:b=Ye,animatedHeight:h,benchMotion:A,initialMode:U="bottomSheet",onModeChange:f,persistenceKey:y,enablePersistence:H=true,initialFloatingPosition:G,footer:W,footerHeight:g=0,onBack:k,onMinimize:C,minimizeRequest:J=0,minimizeTargetPosition:rt,initialModalState:u,zIndex:ut,disableScrollWrapper:ht=false,background:ft=true,variant:B="night",avoidKeyboard:kt=true})=>{const F=Fe();const Nt=l(false);S(()=>{if(a)Nt.current=true;else if(Nt.current)St.dismiss()},[a]);S(()=>()=>{if(Nt.current)St.dismiss()},[]);const[Ut,Jt]=$(!H);const[d,Ot]=$(U);const Pt=Je(kt&&a&&d==="bottomSheet",F.top);const[gt,z]=$(false);const[Lt,mt]=$(false);const[Ve,Ft]=$(b);const[q,yt]=$({width:wt,height:bt,top:(p.height-bt)/2,left:0});const[vt]=$({width:p.width,height:p.height});const[Te,At]=$(false);const[De,qt]=$(false);const Ie=ze();const D=l(new r.Value(0)).current;const M=l(new r.Value(p.height)).current;const Qt=l(new r.Value(0)).current;const j=l(new r.Value(b)).current;const Y=l(b);S(()=>{if(!H||!y||!Ut)return;const t=setTimeout(()=>{Xt.save(y,{mode:d,panelHeight:Y.current,dimensions:q,isVisible:a})},500);return()=>clearTimeout(t)},[d,Ve,q,a,y,H,Ut]);const Zt=l(false);S(()=>{if(h&&!Zt.current){Zt.current=true;Y.current=b;h.setValue(b)}},[h,b]);S(()=>{L.current=q},[q]);const R=l(new r.ValueXY({x:G?.x??0,y:G?.y??(p.height-bt)/2})).current;const it=l(new r.Value(0)).current;const at=l(new r.Value(wt)).current;const st=l(new r.Value(bt)).current;const L=l(q);const $t=l(q);const Se=l(0);const xe=l(0);const He=l(0);const ke=l(0);S(()=>{let t=true;const i=async()=>{try{const n=pe.modal.hintAcknowledged();const Q=await me.getItem(n);if(t){At(Q!=="true");qt(true)}}catch(n){if(t){At(true);qt(true)}}};i();return()=>{t=false}},[]);const Le=nt(async()=>{try{const t=pe.modal.hintAcknowledged();await me.setItem(t,"true");At(false)}catch(t){At(false)}},[]);const Kt=l(f);Kt.current=f;S(()=>{if(!H||!y){Jt(true);return}let t=true;const i=async()=>{const n=await Xt.load(y);if(t&&n){if(n.mode){Ot(n.mode);Kt.current?.(n.mode)}if(n.panelHeight){Ft(n.panelHeight);Y.current=n.panelHeight;j.setValue(n.panelHeight);h?.setValue(n.panelHeight)}if(n.dimensions){yt(n.dimensions);R.setValue({x:n.dimensions.left,y:n.dimensions.top});at.setValue(n.dimensions.width);st.setValue(n.dimensions.height)}}if(t)Jt(true)};i();return()=>{t=false}},[y,H,j,st,at,R]);S(()=>{return()=>{D.stopAnimation();M.stopAnimation();it.stopAnimation();Qt.stopAnimation();j.stopAnimation();R.stopAnimation();at.stopAnimation();st.stopAnimation();D.setValue(0);M.setValue(p.height);it.setValue(0);Qt.setValue(0);j.setValue(b);Y.current=b}},[]);const te=D.interpolate({inputRange:[0,1],outputRange:[0,1],extrapolate:"clamp"});const _t=P||p.height-F.top;const lt=nt(()=>{mt(false);z(false);const t=d==="bottomSheet"?"floating":"bottomSheet";Ot(t);f?.(t)},[d,f]);S(()=>{mt(false);z(false)},[d]);const tt=nt(()=>{if(!C)return;const t={mode:d,panelHeight:Y.current,floatingPosition:{x:L.current.left,y:L.current.top},floatingDimensions:{width:L.current.width,height:L.current.height}};if(H&&y)void Xt.saveMinimized(y,t);const i=rt?.x??p.width-50;const n=rt?.y??p.height-150;if(d==="bottomSheet"){r.parallel([r.timing(D,{toValue:0,duration:300,useNativeDriver:true}),r.timing(M,{toValue:p.height,duration:300,useNativeDriver:true})]).start(()=>{C(t)})}else{r.parallel([r.timing(it,{toValue:0,duration:300,useNativeDriver:true}),r.timing(D,{toValue:0,duration:300,useNativeDriver:true}),r.timing(R,{toValue:{x:i,y:n},duration:300,useNativeDriver:true})]).start(()=>{C(t)})}},[d,C,rt,H,y,D,M,it,R]);const ee=l(J);S(()=>{if(ee.current===J)return;ee.current=J;tt()},[J,tt]);S(()=>{if(!u)return;if(u.mode){Ot(u.mode);f?.(u.mode)}if(u.panelHeight){Ft(u.panelHeight);Y.current=u.panelHeight;j.setValue(u.panelHeight)}if(u.floatingDimensions&&u.floatingPosition){const t={width:u.floatingDimensions.width,height:u.floatingDimensions.height,top:u.floatingPosition.y,left:u.floatingPosition.x};yt(t);R.setValue({x:u.floatingPosition.x,y:u.floatingPosition.y});at.setValue(u.floatingDimensions.width);st.setValue(u.floatingDimensions.height)}},[u]);const oe=t=>{if(t){if(d==="bottomSheet"){M.setValue(0)}else{it.setValue(1);R.setValue({x:L.current.left,y:L.current.top})}D.setValue(1)}else{if(d==="bottomSheet"){M.setValue(p.height)}D.setValue(0)}};const ne=l(null);if(we&&ne.current!==a){ne.current=a;oe(a)}S(()=>{let t=null;let i=null;if(we){oe(a);return}if(a){M.setValue(p.height);D.setValue(0);if(d==="bottomSheet"){t=r.parallel([r.spring(M,{toValue:0,tension:180,friction:22,useNativeDriver:true}),r.timing(D,{toValue:1,duration:200,useNativeDriver:true})]);t.start()}else{it.setValue(1);R.setValue({x:L.current.left,y:L.current.top});t=r.timing(D,{toValue:1,duration:200,useNativeDriver:true});t.start()}}else{if(d==="bottomSheet"){i=r.parallel([r.spring(M,{toValue:p.height,tension:180,friction:22,useNativeDriver:true}),r.timing(D,{toValue:0,duration:200,useNativeDriver:true})]);i.start()}else{i=r.timing(D,{toValue:0,duration:200,useNativeDriver:true});i.start()}}return()=>{if(t){t.stop()}if(i){i.stop()}}},[a,d,D,M,it,R,h]);const re=l(0);S(()=>{if(!__DEV__||!A||!a)return void 0;let t=null;let i=null;let n=true;const Q=Date.now();let E=false;const et=Z=>{E=Z;if(A==="resize"||A==="float-resize"){z(Z)}else if(A==="float-drag"){mt(Z)}};if(A==="mode-cycle"){i=setInterval(()=>lt(),2200)}else{const Z=X;const Bt=_t;const Tt=()=>{if(!n)return;const pt=(Date.now()-Q)/1e3;const m=pt%2.5;if(m<2&&!E)et(true);else if(m>=2&&E)et(false);if(E){const N=(Math.sin(pt*2.2)+1)/2;if(A==="resize"){const I=Z+N*(Bt-Z);j.setValue(I);Y.current=I;if(h){h.setValue(I)}}else if(A==="float-drag"){const I=(Math.sin(pt*1.7)+1)/2;R.setValue({x:10+N*Math.max(p.width-wt-20,0),y:70+I*260})}else if(A==="float-resize"){const I=wt+N*Math.max(p.width-wt-40,0);const _=bt+N*240;at.setValue(I);st.setValue(_);L.current={...L.current,width:I,height:_}}}t=requestAnimationFrame(Tt)};t=requestAnimationFrame(Tt)}return()=>{n=false;if(t!=null)cancelAnimationFrame(t);if(i!=null)clearInterval(i);z(false);mt(false)}},[A,a]);const ve=se(()=>he.create({onStartShouldSetPanResponder:()=>d==="bottomSheet",onMoveShouldSetPanResponder:(t,i)=>d==="bottomSheet"&&Math.abs(i.dy)>3,onPanResponderTerminationRequest:()=>false,onPanResponderGrant:t=>{z(true);re.current=t.nativeEvent.locationY||0;j.stopAnimation(i=>{Y.current=i});h?.stopAnimation();M.stopAnimation()},onPanResponderMove:t=>{const i=t.nativeEvent.pageY-re.current;let n=p.height-i;n=Math.max(X,Math.min(n,_t));j.setValue(n);Y.current=n;if(h){h.setValue(n)}},onPanResponderRelease:(t,i)=>{z(false);const n=Y.current;const Q=i.vy>.8&&i.dy>50||i.dy>150&&n<=X;if(Q){r.parallel([r.timing(D,{toValue:0,duration:200,useNativeDriver:true}),r.spring(M,{toValue:p.height,tension:180,friction:22,useNativeDriver:true})]).start(()=>s());return}Ft(n);if(h)h.setValue(n)},onPanResponderTerminate:()=>{z(false)}}),[d,X,_t,j,h,M,D,s]);const Ct=nt(t=>{let i=false;return he.create({onStartShouldSetPanResponder:()=>d==="floating",onMoveShouldSetPanResponder:()=>d==="floating",onPanResponderGrant:()=>{i=false;const n=L.current;R.stopAnimation(({x:Q,y:E})=>{R.setValue({x:Q,y:E})});z(true);$t.current={...n};He.current=n.height;ke.current=n.width;Se.current=n.left;xe.current=n.top},onPanResponderMove:(n,Q)=>{const{dx:E,dy:et}=Q;if(Math.abs(E)<.5&&Math.abs(et)<.5)return;i=true;const Z=Math.max(0,F.left||0);const Bt=vt.width-Math.max(0,F.right||0);const Tt=Math.max(0,F.top||0);const pt=vt.height-Math.max(0,F.bottom||0);const m=$t.current;const N=m.left+m.width;const I=m.top+m.height;let _=m.left;let ot=m.top;let Dt=N;let It=I;switch(t){case"topLeft":{const dt=Math.max(Z,Math.min(m.left+E,N-xt));const ct=Math.max(Tt,Math.min(m.top+et,I-Ht));_=dt;ot=ct;Dt=N;It=I;break}case"topRight":{const dt=Math.min(Bt,Math.max(N+E,m.left+xt));const ct=Math.max(Tt,Math.min(m.top+et,I-Ht));_=m.left;ot=ct;Dt=dt;It=I;break}case"bottomLeft":{const dt=Math.max(Z,Math.min(m.left+E,N-xt));const ct=Math.min(pt,Math.max(I+et,m.top+Ht));_=dt;ot=m.top;Dt=N;It=ct;break}case"bottomRight":{const dt=Math.min(Bt,Math.max(N+E,m.left+xt));const ct=Math.min(pt,Math.max(I+et,m.top+Ht));_=m.left;ot=m.top;Dt=dt;It=ct;break}}const Gt=Math.max(xt,Dt-_);const zt=Math.max(Ht,It-ot);yt({width:Gt,height:zt,left:_,top:ot});at.setValue(Gt);st.setValue(zt);R.setValue({x:_,y:ot});L.current={width:Gt,height:zt,left:_,top:ot}},onPanResponderRelease:()=>{z(false);i=false;yt(L.current)},onPanResponderTerminate:()=>{z(false);i=false}})},[d,vt,F.left,F.right,F.top,F.bottom,R,at,st,s,k]);const ie=se(()=>{return{topLeft:Ct("topLeft"),topRight:Ct("topRight"),bottomLeft:Ct("bottomLeft"),bottomRight:Ct("bottomRight")}},[Ct]);const Ae=nt(()=>{mt(true)},[]);const Be=nt(t=>{mt(false);const i=L.current;const n={...i,left:t.x,top:t.y};yt(n)},[]);const ae=l(0);const Rt=l(0);const Vt=l(null);const Me=nt(()=>{const t=Date.now();const i=t-ae.current;if(i>500){Rt.current=0}Rt.current++;ae.current=t;if(Vt.current){clearTimeout(Vt.current)}Vt.current=setTimeout(()=>{if(Rt.current===2){lt()}else if(Rt.current>=3){if(C){tt()}}Rt.current=0},300)},[lt,C,tt]);S(()=>{return()=>{if(Vt.current){clearTimeout(Vt.current)}}},[]);if(d==="floating"){return K(r.View,{nativeID:"jsmodal-root",pointerEvents:a?"auto":"none",accessibilityElementsHidden:!a,importantForAccessibility:a?"auto":"no-hide-descendants",style:[o.floatingModal,{width:q.width,height:q.height,opacity:te,transform:[{translateX:R.x},{translateY:R.y}],...ut!==void 0&&{zIndex:ut}},B==="night"&&o.nightFloatingModal,(Lt||gt)&&o.floatingModalDragging,w.container,!a&&o.parkedOffscreen],children:[ft&&B==="night"?e(c,{style:o.nightBackdropFloating,pointerEvents:"none",children:e(Et,{})}):null,e(_e,{position:R,onDragStart:Ae,onDragEnd:Be,onTap:Me,containerBounds:vt,elementSize:q,minPosition:{x:0,y:F.top},style:o.floatingHeader,enabled:d==="floating"&&!gt,children:e(Ce,{header:x,onClose:s,onToggleMode:lt,onMinimize:C?tt:void 0,isResizing:Lt||gt,mode:d,variant:B})}),e(c,{style:o.windowControlsContainer,children:e(ge,{onClose:s,onMinimize:C?tt:void 0,onToggleMode:lt,mode:d,variant:B})}),K(c,{style:[o.content,B==="night"&&o.nightContent,w.content],children:[ft&&B!=="night"?e(Et,{}):null,ht?e(c,{style:{flex:1,paddingBottom:g},children:T}):e(fe,{style:{flex:1},contentContainerStyle:{flexGrow:1,paddingBottom:g},showsVerticalScrollIndicator:true,nestedScrollEnabled:true,keyboardShouldPersistTaps:"handled",children:T}),W?e(c,{style:Re.footerContainer,children:W}):null]}),e(c,{...ie.bottomLeft.panHandlers,style:[o.cornerHandleWrapper,{bottom:4,left:4}],hitSlop:{top:2,left:2,right:2,bottom:2},children:e(ye,{position:"bottomLeft",isActive:Lt||gt})}),e(c,{...ie.bottomRight.panHandlers,style:[o.cornerHandleWrapper,{bottom:4,right:4}],hitSlop:{top:2,left:2,right:2,bottom:2},children:e(ye,{position:"bottomRight",isActive:Lt||gt})})]})}return e(c,{style:[a?o.fullScreenContainer:o.parkedFullScreen,a&&ut!==void 0&&{zIndex:ut}],pointerEvents:a?"box-none":"none",accessibilityElementsHidden:!a,importantForAccessibility:a?"auto":"no-hide-descendants",children:e(r.View,{nativeID:"jsmodal-root",style:[o.bottomSheetWrapper,{opacity:te,transform:[{translateY:M}]}],children:e(r.View,{style:{transform:[{translateY:Pt.raise}]},children:K(r.View,{ref:Pt.sheetRef,style:[o.bottomSheet,B==="night"&&o.nightBottomSheet,w.container,{height:h||j}],children:[ft&&B==="night"?e(c,{style:o.nightBackdropSheet,pointerEvents:"none",children:e(Et,{})}):null,e(Ce,{header:x,onClose:s,onToggleMode:lt,onMinimize:C?tt:void 0,isResizing:gt,mode:d,panHandlers:ve.panHandlers,variant:B}),e(c,{style:o.windowControlsContainer,children:e(ge,{onClose:s,onMinimize:C?tt:void 0,onToggleMode:lt,mode:d,variant:B})}),De&&Te&&d==="bottomSheet"&&!Ie&&e(Ge,{onAcknowledge:Le}),K(r.View,{style:[o.content,B==="night"&&o.nightContent,w.content,{paddingBottom:Pt.pad}],children:[ft&&B!=="night"?e(Et,{}):null,ht?e(c,{style:{flex:1,paddingBottom:g},children:T}):e(fe,{style:{flex:1},contentContainerStyle:{flexGrow:1,paddingBottom:g},showsVerticalScrollIndicator:true,nestedScrollEnabled:true,keyboardShouldPersistTaps:"handled",children:T}),W?e(c,{style:Re.footerContainer,children:W}):null]})]})})})})};const o=Wt.create({fullScreenContainer:{...Yt,zIndex:1e3},bottomSheetWrapper:{position:"absolute",bottom:0,left:0,right:0},bottomSheet:{backgroundColor:V.card,borderTopLeftRadius:6,borderTopRightRadius:6,borderWidth:1,borderColor:V.border,shadowColor:V.primary,shadowOffset:{width:0,height:-4},shadowOpacity:.2,shadowRadius:12,elevation:20},parkedOffscreen:{left:-9999,top:-9999,opacity:0},parkedFullScreen:{position:"absolute",left:-9999,top:-9999,width:p.width,height:p.height,opacity:0},floatingModal:{position:"absolute",backgroundColor:V.card,borderRadius:6,borderWidth:1,borderColor:V.border,shadowColor:V.primary,shadowOffset:{width:0,height:0},shadowOpacity:.3,shadowRadius:20,elevation:24,zIndex:1e3,width:wt,height:bt},floatingModalDragging:{borderColor:V.primary,borderWidth:2,shadowColor:V.primary+"99",shadowOpacity:.8,shadowRadius:12},header:{borderTopLeftRadius:6,borderTopRightRadius:6,backgroundColor:V.card,minHeight:56,borderWidth:1,borderColor:V.border,borderBottomWidth:1,borderBottomColor:V.border},nightBottomSheet:{backgroundColor:v.color.bg,borderTopLeftRadius:v.radius.sheet,borderTopRightRadius:v.radius.sheet,borderWidth:Wt.hairlineWidth,borderColor:v.color.accent+"55",shadowColor:v.color.accent,shadowOffset:{width:0,height:-4},shadowOpacity:.22,shadowRadius:10},nightFloatingModal:{backgroundColor:v.color.bg,borderRadius:v.radius.sheet,borderWidth:Wt.hairlineWidth,borderColor:v.color.accent+"55",shadowColor:v.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.22,shadowRadius:14},nightHeader:{backgroundColor:"transparent",borderWidth:0,borderBottomWidth:0,borderTopLeftRadius:v.radius.sheet,borderTopRightRadius:v.radius.sheet},nightContent:{backgroundColor:"transparent"},nightBackdropSheet:{...Yt,borderTopLeftRadius:v.radius.sheet,borderTopRightRadius:v.radius.sheet,overflow:"hidden"},nightBackdropFloating:{...Yt,borderRadius:v.radius.sheet,overflow:"hidden"},nightDragIndicator:{width:36,height:5,borderRadius:2.5,backgroundColor:v.color.placeholder,shadowOpacity:0,elevation:0},floatingHeader:{borderTopLeftRadius:6,borderTopRightRadius:6},windowControlsContainer:{position:"absolute",top:4,right:4,zIndex:10},floatingModeHeader:{borderTopLeftRadius:6,borderTopRightRadius:6},headerInner:{flex:1,justifyContent:"center"},dragIndicatorContainer:{alignItems:"center",paddingVertical:8,backgroundColor:"transparent"},dragIndicatorContainerCustom:{minHeight:Xe,justifyContent:"center",paddingVertical:0,backgroundColor:"transparent"},dragIndicator:{width:40,height:3,backgroundColor:V.primary,borderRadius:2,shadowColor:V.primary,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:4},floatingDragIndicator:{width:50,height:5,backgroundColor:V.textMuted},dragIndicatorActive:{backgroundColor:V.primary,width:40},resizeGripContainer:{position:"absolute",flexDirection:"row",gap:2,marginTop:12},resizeGripLine:{width:12,height:1,backgroundColor:O.success,opacity:.6},headerContent:{paddingHorizontal:16,alignItems:"center"},headerControls:{position:"absolute",top:8,right:16,flexDirection:"row",alignItems:"center"},headerTitle:{fontSize:16,fontWeight:"600",color:O.primary},headerSubtitle:{fontSize:12,color:O.secondary,paddingTop:4},headerHintText:{position:"absolute",top:0,left:0,right:0,bottom:0,justifyContent:"center",alignItems:"center"},hintText:{fontSize:10,color:O.muted,fontStyle:"italic"},controlButton:{width:28,height:28,borderRadius:6,justifyContent:"center",alignItems:"center",marginLeft:8},toggleButton:{backgroundColor:O.info+"1A",borderWidth:1,borderColor:O.info+"33"},closeButton:{width:28,height:28,borderRadius:6,justifyContent:"center",alignItems:"center",backgroundColor:O.error+"1A",borderWidth:1,borderColor:O.error+"33",marginLeft:8},iconLine:{position:"absolute",top:7.25,left:2,width:12,height:1.5,backgroundColor:O.error},content:{flex:1,backgroundColor:V.base,borderBottomLeftRadius:16,borderBottomRightRadius:16,overflow:"hidden"},cornerHandle:{position:"absolute",zIndex:1},cornerHandleWrapper:{position:"absolute",width:30,height:30,zIndex:1e3},handler:{width:20,height:20,backgroundColor:"transparent",borderRadius:10,borderWidth:0,borderColor:"transparent"},handlerActive:{backgroundColor:O.success+"1A",borderColor:O.success,borderWidth:2,shadowColor:O.success+"99",shadowOffset:{width:0,height:0},shadowOpacity:1,shadowRadius:8}});const Re=Wt.create({footerContainer:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:V.base,borderBottomLeftRadius:16,borderBottomRightRadius:16}});export const JsModal=Mt(a=>{const s=We();const T=s();if(T.status!=="admitted")return a.visible?e(Ee,{}):null;return e(qe,{...a})});
@@ -1 +1 @@
1
- "use strict";import{systemFont as ie}from"./ui/fonts.js";import{getUseAccountAccess as He}from"./license/licenseModule.js";import{AccountSetup as Pe}from"./license/AccountSetup";import{useState as T,useRef as y,useEffect as W,useLayoutEffect as Ee,useCallback as m,memo as $t,isValidElement as _e,cloneElement as ze}from"react";import{persistentStorage as se}from"./utils/persistentStorage";import{ModalStorage as Wt}from"./utils/modalStorage.js";import{devToolsStorageKeys as ae}from"./storage/devToolsStorageKeys.js";import{useHintsDisabled as Be}from"./context/index.js";import{ToolBackground as le}from"./ui/backgrounds/ToolBackground.js";import{night as d}from"./ui/night/nightTheme.js";import{expandableWindowControlsSupported as Ye,isExpandableWindowControlsEnabled as Fe}from"./ui/components/windowControlsSetting.js";import{jsx as n,jsxs as b,Fragment as Le}from"react/jsx-runtime";const g={base:"#121212",card:"#1A1A1A",border:"#333333",textMuted:"#888888",primary:"#20C997"};const w={primary:"#F5F5F7",primaryLight:"#F5F5F7",secondary:"#A1A1A6",muted:"#8E8E93",success:"#34C759",info:"#00B8E6"};const Ne=100;const Oe=400;const ce=500;const J=80;const wt=()=>typeof window!=="undefined"?window.innerWidth:0;const B=()=>typeof window!=="undefined"?window.innerHeight:0;const de=o=>1-Math.pow(1-o,3);const at=o=>o<.5?2*o*o:1-Math.pow(-2*o+2,2)/2;function G(o,r,s,u){let x=0;let l=false;const C=performance.now();const M=Q=>{if(l)return;const U=Math.min((Q-C)/o,1);s(r(U));if(U<1){x=requestAnimationFrame(M)}else{u?.()}};x=requestAnimationFrame(M);return()=>{l=true;cancelAnimationFrame(x)}}function Xe(){if(typeof document==="undefined"){return{top:0,left:0,right:0,bottom:0}}const o=document.createElement("div");o.style.cssText="position:fixed;top:env(safe-area-inset-top);left:env(safe-area-inset-left);right:env(safe-area-inset-right);bottom:env(safe-area-inset-bottom);visibility:hidden;pointer-events:none";document.body.appendChild(o);const r=o.getBoundingClientRect();document.body.removeChild(o);return{top:Math.max(0,r.top),left:Math.max(0,r.left),right:Math.max(0,window.innerWidth-r.right),bottom:Math.max(0,window.innerHeight-r.bottom)}}function Ht(o,r,s=false){const u=Math.max(J,window.innerWidth-r.left-r.right);const x=Math.max(J,window.innerHeight-r.top-r.bottom);const l=Math.min(o.width,u);const C=Math.min(o.height,x);return{width:l,height:C,left:Math.max(r.left,Math.min(o.left,window.innerWidth-r.right-l)),top:Math.max(r.top,Math.min(o.top,window.innerHeight-r.bottom-(s?J:C)))}}const Pt=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>b("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:[n("line",{x1:18,y1:6,x2:6,y2:18,stroke:r,strokeWidth:s,strokeLinecap:"round"}),n("line",{x1:6,y1:6,x2:18,y2:18,stroke:r,strokeWidth:s,strokeLinecap:"round"})]});const Et=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>n("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:n("line",{x1:5,y1:12,x2:19,y2:12,stroke:r,strokeWidth:s,strokeLinecap:"round"})});const ue=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>b("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:[n("rect",{x:3,y:3,width:18,height:18,rx:2,stroke:r,strokeWidth:s}),n("rect",{x:3,y:14,width:18,height:7,fill:r})]});const fe=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>b("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:[n("rect",{x:3,y:3,width:14,height:14,rx:2,stroke:r,strokeWidth:s}),n("line",{x1:7,y1:17,x2:7,y2:21,stroke:r,strokeWidth:s}),n("line",{x1:7,y1:21,x2:21,y2:21,stroke:r,strokeWidth:s}),n("line",{x1:21,y1:21,x2:21,y2:7,stroke:r,strokeWidth:s}),n("line",{x1:17,y1:7,x2:21,y2:7,stroke:r,strokeWidth:s})]});const z={close:"#FF5F57",minimize:"#FEBC2E",toggleMode:"#28C840"};const _t=24;const je=2;const V=8;const zt=o=>({width:_t,height:_t,borderRadius:_t/2,display:"flex",alignItems:"center",justifyContent:"center",background:`radial-gradient(circle, ${o} 6px, transparent 6px)`,border:"none",padding:0,cursor:"pointer",flexShrink:0});function Ge(o){if(Fe()&&Ye(true)){return n(Ve,{...o})}return n(Ue,{...o})}function Ue({onClose:o,onMinimize:r,onToggleMode:s,mode:u}){const x=u==="floating"?ue:fe;const l=u==="floating"?"Dock to bottom sheet":"Make floating window";return b("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:je},children:[r&&n("button",{type:"button",onClick:r,style:zt(z.minimize),"aria-label":"Minimize modal",children:n(Et,{size:V,color:"#7A5A00",strokeWidth:1.5})}),s&&n("button",{type:"button",onClick:s,style:zt(z.toggleMode),"aria-label":l,children:n(x,{size:V,color:"#004A1A",strokeWidth:1.5})}),n("button",{type:"button",onClick:o,style:zt(z.close),"aria-label":"Close modal",children:n(Pt,{size:V,color:"#4A0000",strokeWidth:1.5})})]})}const Bt=12;const Ze=8;const vt=36;const qe=12;const Yt=16;const Ct=8;const Je=3e3;const Ft=150;const Lt=o=>({width:Bt,height:Bt,borderRadius:Bt/2,backgroundColor:o,display:"flex",alignItems:"center",justifyContent:"center"});const Nt=(o,r,s,u)=>({width:vt,height:vt,borderRadius:vt/2,display:"flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",flexShrink:0,backgroundColor:o?s:r,border:o?`1px solid ${u}`:"none"});function Ve({onClose:o,onMinimize:r,onToggleMode:s,mode:u,variant:x="night"}){const l=x==="night";const[C,M]=T(false);const[Q,U]=T(false);const Z=y(null);const Y=y(null);const A=u==="floating"?ue:fe;const H=u==="floating"?"Dock to bottom sheet":"Make floating window";const P=m(()=>{if(Z.current)clearTimeout(Z.current);if(Y.current)clearTimeout(Y.current);Z.current=null;Y.current=null},[]);const q=m(()=>{P();U(false);Y.current=setTimeout(()=>M(false),Ft)},[P]);const lt=m(()=>{P();M(true);requestAnimationFrame(()=>requestAnimationFrame(()=>U(true)));Z.current=setTimeout(q,Je)},[P,q]);W(()=>P,[P]);const ct=D=>{q();D()};return b(Le,{children:[b("button",{type:"button",onClick:lt,"aria-label":"Open window controls","data-testid":"tool-window-controls",style:{padding:10,margin:-8,border:"none",background:"transparent",cursor:"pointer",display:"flex",flexDirection:"row",alignItems:"center",gap:Ze},children:[r&&n("span",{style:Lt(z.minimize),children:n(Et,{size:V,color:"#7A5A00",strokeWidth:1.5})}),s&&n("span",{style:Lt(z.toggleMode),children:n(A,{size:V,color:"#004A1A",strokeWidth:1.5})}),n("span",{style:Lt(z.close),children:n(Pt,{size:V,color:"#4A0000",strokeWidth:1.5})})]}),C&&n("div",{style:{position:"absolute",top:-Ct,right:-Ct,zIndex:9999,transform:`scale(${Q?1:.3})`,opacity:Q?1:0,transition:`transform ${Ft}ms ease-out, opacity ${Ft}ms ease-out`},children:b("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:qe,padding:Ct,borderRadius:(vt+Ct*2)/2,backgroundColor:l?d.color.surface:g.card,border:`1px solid ${l?d.color.border:g.border}`,boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[r&&n("button",{type:"button",onClick:()=>ct(r),"aria-label":"Minimize modal","data-testid":"tool-window-minimize",style:Nt(l,z.minimize,d.color.warningSoft,d.color.warning+"59"),children:n(Et,{size:Yt,color:l?d.color.warning:"#7A5A00",strokeWidth:2})}),s&&n("button",{type:"button",onClick:()=>ct(s),"aria-label":H,"data-testid":"tool-window-mode",style:Nt(l,z.toggleMode,d.color.accentSoft,d.color.accentBorderStrong),children:n(A,{size:Yt,color:l?d.color.accent:"#004A1A",strokeWidth:2})}),n("button",{type:"button",onClick:()=>ct(o),"aria-label":"Close modal","data-testid":"tool-window-close",style:Nt(l,z.close,d.color.dangerSoft,d.color.danger+"59"),children:n(Pt,{size:Yt,color:l?d.color.danger:"#4A0000",strokeWidth:2})})]})})]})}const he=$t(function o({isResizing:r,mode:s,hasCustomContent:u=false,variant:x="default"}){const l=s==="floating";const C=x==="night";return b("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",position:"relative",justifyContent:u?"center":void 0,minHeight:u?32:void 0,paddingTop:u?0:8,paddingBottom:u?0:8,backgroundColor:"transparent"},children:[n("div",{style:{width:C?36:r?40:l?50:40,height:C?5:l?5:3,backgroundColor:C?d.color.placeholder:r?g.primary:l?g.textMuted:g.primary,borderRadius:C?2.5:2,boxShadow:C?"none":`0 0 4px ${g.primary}99`}}),r&&s==="bottomSheet"&&n("div",{style:{position:"absolute",display:"flex",flexDirection:"row",gap:2,marginTop:12},children:[0,1,2].map(M=>n("div",{style:{width:12,height:1,backgroundColor:w.success,opacity:.6}},M))})]})});const Qe=$t(function o({onAcknowledge:r}){return n("div",{style:{backgroundColor:`${w.info}15`,borderLeft:`3px solid ${w.info}`,borderRadius:8,margin:"8px 12px 4px",overflow:"hidden",boxShadow:`0 0 8px ${w.info}4D`,flexShrink:0},children:b("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",padding:12,gap:12},children:[b("div",{style:{width:32,height:32,position:"relative",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:[n("div",{style:{position:"absolute",width:20,height:20,borderRadius:10,border:`2px solid ${w.info}`,opacity:.6,transform:"scale(0.8)",boxSizing:"border-box"}}),n("div",{style:{position:"absolute",width:20,height:20,borderRadius:10,border:`2px solid ${w.info}`,boxSizing:"border-box"}})]}),b("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:2},children:[n("span",{style:{fontSize:13,fontWeight:600,color:w.info,letterSpacing:.3},children:"\u{1F4A1} Pro Tip"}),n("span",{style:{fontSize:12,color:w.primaryLight,lineHeight:"16px"},children:"Double-tap the header to transform this into a floating modal"})]}),n("button",{type:"button",onClick:r,style:{backgroundColor:`${w.info}30`,padding:"6px 12px",borderRadius:6,border:`1px solid ${w.info}50`,fontSize:12,fontWeight:600,color:w.info,cursor:"pointer",fontFamily:"inherit",flexShrink:0},children:"Got it!"})]})})});function pe({header:o,isResizing:r,mode:s,onMinimize:u,variant:x="default"}){if(o?.customContent){let l=o.customContent;if(_e(o.customContent)&&u){l=ze(o.customContent,{onMinimize:u})}return b("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",minWidth:0},children:[n(he,{isResizing:r,mode:s,hasCustomContent:true,variant:x}),l]})}return b("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",position:"relative",minWidth:0},children:[n(he,{isResizing:r,mode:s,variant:x}),b("div",{style:{padding:"0 16px",display:"flex",flexDirection:"column",alignItems:"center"},children:[o?.title&&n("span",{style:{fontSize:16,fontWeight:600,color:w.primary},children:o.title}),o?.subtitle&&n("span",{style:{fontSize:12,color:w.secondary,paddingTop:4},children:o.subtitle})]}),n("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:n("span",{style:{fontSize:10,color:w.muted,fontStyle:"italic"},children:"Double tap: Toggle \u2022 Triple tap: Close"})})]})}const Ke=({visible:o,onClose:r,children:s,header:u,styles:x={},minHeight:l=Ne,maxHeight:C,initialHeight:M=Oe,animatedHeight:Q,benchMotion:U,initialMode:Z="bottomSheet",onModeChange:Y,persistenceKey:A,enablePersistence:H=true,initialFloatingPosition:P,footer:q,footerHeight:lt=0,onBack:ct,onMinimize:D,minimizeRequest:dt=0,minimizeTargetPosition:kt,initialModalState:v,zIndex:Ot,disableScrollWrapper:ge=false,background:Xt=true,variant:ut="night"})=>{const[I]=T(Xe);const[jt,Gt]=T(!H);const[p,St]=T(Z);const ft=y(Y);ft.current=Y;const[K,F]=T(false);const[Dt,tt]=T(false);const[me,At]=T(M);const[E,et]=T(()=>Ht({width:wt(),height:ce,top:P?.y??(B()-ce)/2,left:P?.x??0},I));const[xe,ht]=T(false);const[ye,Ut]=T(false);const be=Be();const L=y(M);const R=y(E);const k=y({x:E.left,y:E.top});const pt=y(null);const It=y(null);const _=y(null);const N=y([]);const $=m(()=>{N.current.forEach(t=>t());N.current=[]},[]);W(()=>{R.current=E},[E]);W(()=>$,[$]);const Zt=C||B()-I.top;W(()=>{if(!H||!A){Gt(true);return}let t=true;const e=async()=>{const i=await Wt.load(A);if(t&&i){if(i.mode){St(i.mode);ft.current?.(i.mode)}if(i.panelHeight){At(i.panelHeight);L.current=i.panelHeight}if(i.dimensions){const a=Ht(i.dimensions,I,true);et(a);k.current={x:a.left,y:a.top}}}if(t)Gt(true)};e();return()=>{t=false}},[A,H]);W(()=>{if(!H||!A||!jt)return;const t=setTimeout(()=>{Wt.save(A,{mode:p,panelHeight:L.current,dimensions:E,isVisible:o})},500);return()=>clearTimeout(t)},[p,me,E,o,A,H,jt]);W(()=>{let t=true;const e=async()=>{try{const i=ae.modal.hintAcknowledged();const a=await se.getItem(i);if(t){ht(a!=="true");Ut(true)}}catch{if(t){ht(true);Ut(true)}}};e();return()=>{t=false}},[]);const we=m(async()=>{try{const t=ae.modal.hintAcknowledged();await se.setItem(t,"true");ht(false)}catch{ht(false)}},[]);const Rt=m(()=>{tt(false);F(false);const t=p==="bottomSheet"?"floating":"bottomSheet";St(t);ft.current?.(t)},[p]);W(()=>{tt(false);F(false)},[p]);const O=m(()=>{if(!D)return;const t={mode:p,panelHeight:L.current,floatingPosition:{x:R.current.left,y:R.current.top},floatingDimensions:{width:R.current.width,height:R.current.height}};if(H&&A)void Wt.saveMinimized(A,t);const e=kt?.x??wt()-50;const i=kt?.y??B()-150;$();if(p==="bottomSheet"){const a=pt.current;if(!a){D(t);return}const c=B();N.current.push(G(300,at,h=>{a.style.opacity=String(1-h);a.style.transform=`translateY(${h*c}px)`},()=>D(t)))}else{const a=_.current;if(!a){D(t);return}const c={...k.current};N.current.push(G(300,at,h=>{a.style.opacity=String(1-h);const rt=c.x+(e-c.x)*h;const X=c.y+(i-c.y)*h;a.style.transform=`translate(${rt}px, ${X}px)`},()=>D(t)))}},[p,D,kt,$,H,A]);const qt=y(dt);W(()=>{if(qt.current===dt)return;qt.current=dt;O()},[dt,O]);W(()=>{if(!v)return;if(v.mode){St(v.mode);ft.current?.(v.mode)}if(v.panelHeight){At(v.panelHeight);L.current=v.panelHeight}if(v.floatingDimensions&&v.floatingPosition){const t={width:v.floatingDimensions.width,height:v.floatingDimensions.height,top:v.floatingPosition.y,left:v.floatingPosition.x};et(t);k.current={x:v.floatingPosition.x,y:v.floatingPosition.y}}},[v]);Ee(()=>{if(!o)return;$();if(p==="bottomSheet"){const t=pt.current;if(!t)return;const e=B();t.style.transform=`translateY(${e}px)`;t.style.opacity="0";N.current.push(G(300,de,i=>{t.style.transform=`translateY(${(1-i)*e}px)`}),G(200,at,i=>{t.style.opacity=String(i)}))}else{const t=_.current;if(!t)return;k.current={x:R.current.left,y:R.current.top};t.style.transform=`translate(${k.current.x}px, ${k.current.y}px)`;t.style.opacity="0";N.current.push(G(200,at,e=>{t.style.opacity=String(e)}))}},[o,p,$]);const Jt=y(0);const nt=y(0);const ot=y(null);const gt=m(()=>{const t=Date.now();if(t-Jt.current>500){nt.current=0}nt.current++;Jt.current=t;if(ot.current)clearTimeout(ot.current);ot.current=setTimeout(()=>{if(nt.current===2){Rt()}else if(nt.current>=3){if(D)O()}nt.current=0},300)},[Rt,D,O]);W(()=>{return()=>{if(ot.current)clearTimeout(ot.current)}},[]);const mt=y({active:false,resizing:false,startY:0,headerOffsetY:0,samples:[]});const ve=m(t=>{if(p!=="bottomSheet")return;if(t.button!==0||t.target.closest('button, a, input, textarea, select, [role="button"], [role="tab"], [role="switch"], [contenteditable="true"], [tabindex]'))return;const e=mt.current;e.active=true;e.resizing=false;e.startY=t.clientY;const i=t.currentTarget.getBoundingClientRect();e.headerOffsetY=t.clientY-i.top;e.samples=[{t:performance.now(),y:t.clientY}];t.currentTarget.setPointerCapture(t.pointerId)},[p]);const Ce=m(t=>{const e=mt.current;if(!e.active)return;const i=t.clientY-e.startY;if(!e.resizing&&Math.abs(i)>3){e.resizing=true;$();F(true)}if(!e.resizing)return;const a=t.clientY-e.headerOffsetY;let c=B()-a;c=Math.max(l,Math.min(c,Zt));L.current=c;if(It.current)It.current.style.height=`${c}px`;const h=performance.now();e.samples.push({t:h,y:t.clientY});while(e.samples.length>2&&h-e.samples[0].t>100)e.samples.shift()},[l,Zt,$]);const ke=m(t=>{const e=mt.current;if(!e.active)return;e.active=false;if(!e.resizing){gt();return}F(false);const i=L.current;const a=t.clientY-e.startY;const c=e.samples[0];const h=e.samples[e.samples.length-1];const rt=h&&c&&h.t>c.t?(h.y-c.y)/(h.t-c.t):0;const X=rt>.8&&a>50||a>150&&i<=l;if(X){const S=pt.current;$();if(S){const it=B();N.current.push(G(200,at,j=>{S.style.opacity=String(1-j)}),G(300,de,j=>{S.style.transform=`translateY(${j*it}px)`},()=>r()))}else{r()}return}At(i)},[l,r,gt,$]);const Se=m(()=>{const t=mt.current;if(!t.active)return;t.active=false;t.resizing=false;F(false)},[]);const xt=y({active:false,dragging:false,startX:0,startY:0,startPos:{x:0,y:0}});const De=m(t=>{if(p!=="floating"||K)return;if(t.button!==0||t.target.closest('button, a, input, textarea, select, [role="button"], [role="tab"], [role="switch"], [contenteditable="true"], [tabindex]'))return;const e=xt.current;e.active=true;e.dragging=false;e.startX=t.clientX;e.startY=t.clientY;e.startPos={...k.current};t.currentTarget.setPointerCapture(t.pointerId)},[p,K]);const Ae=m(t=>{const e=xt.current;if(!e.active)return;const i=t.clientX-e.startX;const a=t.clientY-e.startY;if(!e.dragging&&Math.abs(i)+Math.abs(a)>5){e.dragging=true;tt(true)}if(!e.dragging)return;const c=e.startPos.x+i;const h=e.startPos.y+a;k.current={x:c,y:h};if(_.current){_.current.style.transform=`translate(${c}px, ${h}px)`}},[]);const Ie=m(()=>{const t=xt.current;if(!t.active)return;t.active=false;if(!t.dragging){gt();return}tt(false);const e=R.current;const i=Ht({...e,left:k.current.x,top:k.current.y},I);const a=i.left;const c=i.top;k.current={x:a,y:c};if(_.current){_.current.style.transform=`translate(${a}px, ${c}px)`}et(h=>({...h,left:a,top:c}))},[I,gt]);const Re=m(()=>{const t=xt.current;if(!t.active)return;t.active=false;t.dragging=false;tt(false)},[]);const Tt=y({active:false,corner:"bottomRight",startX:0,startY:0,start:{width:0,height:0,top:0,left:0}});const Te=m(t=>e=>{if(p!=="floating")return;e.stopPropagation();const i=Tt.current;i.active=true;i.corner=t;i.startX=e.clientX;i.startY=e.clientY;i.start={...R.current};F(true);e.currentTarget.setPointerCapture(e.pointerId)},[p]);const Me=m(t=>{const e=Tt.current;if(!e.active)return;const i=t.clientX-e.startX;const a=t.clientY-e.startY;if(Math.abs(i)<.5&&Math.abs(a)<.5)return;const c=Math.max(0,I.left);const h=B()-Math.max(0,I.bottom);const rt=wt()-Math.max(0,I.right);const X=wt()*.25;const S=e.start;const it=S.left+S.width;const j=S.top+S.height;let st=S.left;const bt=S.top;let oe=it;let Mt=j;if(e.corner==="bottomLeft"){st=Math.max(c,Math.min(S.left+i,it-X));Mt=Math.min(h,Math.max(j+a,S.top+J))}else{oe=Math.min(rt,Math.max(it+i,S.left+X));Mt=Math.min(h,Math.max(j+a,S.top+J))}const $e=Math.max(X,oe-st);const We=Math.max(J,Mt-bt);const re={width:$e,height:We,left:st,top:bt};R.current=re;k.current={x:st,y:bt};et(re);if(_.current){_.current.style.transform=`translate(${st}px, ${bt}px)`}},[I.left,I.right,I.bottom]);const Vt=m(()=>{const t=Tt.current;if(!t.active)return;t.active=false;F(false);et(R.current)},[]);const yt=!o;const Qt=yt?{left:-9999,top:-9999,opacity:0,visibility:"hidden",pointerEvents:"none"}:{};const Kt=u?.title||"Dev tool panel";const f=ut==="night";const te=Xt&&f?n("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":true,children:n(le,{})}):null;const ee=b("div",{style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column",backgroundColor:f?"transparent":g.base,borderBottomLeftRadius:16,borderBottomRightRadius:16,overflow:"hidden",...x.content},children:[Xt&&!f?n(le,{}):null,ge?n("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",paddingBottom:lt},children:s}):n("div",{style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:lt},children:s}),q?n("div",{style:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:g.base,borderBottomLeftRadius:16,borderBottomRightRadius:16},children:q}):null]});const ne=n("div",{style:{position:"absolute",top:4,right:4,zIndex:10},children:n(Ge,{onClose:r,onMinimize:D?O:void 0,onToggleMode:Rt,mode:p,variant:ut})});if(p==="floating"){const t=Dt||K;return b("div",{ref:_,role:"dialog","aria-label":Kt,"aria-hidden":yt||void 0,style:{fontFamily:ie,position:"fixed",pointerEvents:"auto",left:0,top:0,width:E.width,height:E.height,transform:`translate(${k.current.x}px, ${k.current.y}px)`,display:"flex",flexDirection:"column",backgroundColor:f?d.color.bg:g.card,borderRadius:f?d.radius.sheet:6,border:f?`1px solid ${d.color.accent}55`:t?`2px solid ${g.primary}`:`1px solid ${g.border}`,boxShadow:f?`0 0 14px ${d.color.accent}38`:t?`0 0 12px ${g.primary}7A`:`0 0 20px ${g.primary}4D`,...f?{overflow:"hidden"}:null,boxSizing:"border-box",zIndex:Ot??1e3,...x.container,...Qt},children:[te,n("div",{onPointerDown:De,onPointerMove:Ae,onPointerUp:Ie,onPointerCancel:Re,style:{borderTopLeftRadius:f?d.radius.sheet:6,borderTopRightRadius:f?d.radius.sheet:6,backgroundColor:f?"transparent":g.card,minHeight:56,border:f?"none":`1px solid ${g.border}`,boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",flexShrink:0,touchAction:"none",userSelect:"none",cursor:Dt?"grabbing":"grab",position:"relative"},children:n(pe,{header:u,isResizing:Dt||K,mode:p,onMinimize:D?O:void 0,variant:ut})}),ne,ee,["bottomLeft","bottomRight"].map(e=>n("div",{onPointerDown:Te(e),onPointerMove:Me,onPointerUp:Vt,onPointerCancel:Vt,style:{position:"absolute",width:30,height:30,bottom:4,...e==="bottomLeft"?{left:4}:{right:4},zIndex:1e3,touchAction:"none",cursor:e==="bottomLeft"?"nesw-resize":"nwse-resize"},children:n("div",{style:{width:20,height:20,borderRadius:10,boxSizing:"border-box",backgroundColor:t?`${w.success}1A`:"transparent",border:t?`2px solid ${w.success}`:"none",boxShadow:t?`0 0 8px ${w.success}99`:"none"}})},e))]},"floating")}return n("div",{"aria-hidden":yt||void 0,style:{fontFamily:ie,position:"fixed",inset:0,zIndex:Ot??1e3,pointerEvents:"none",...yt?{...Qt,inset:"auto",width:"100vw",height:"100vh"}:null},children:n("div",{ref:pt,style:{position:"absolute",bottom:0,left:0,right:0,pointerEvents:"auto"},children:b("div",{ref:It,role:"dialog","aria-label":Kt,style:{height:L.current,display:"flex",flexDirection:"column",backgroundColor:f?d.color.bg:g.card,borderTopLeftRadius:f?d.radius.sheet:6,borderTopRightRadius:f?d.radius.sheet:6,border:f?`1px solid ${d.color.accent}55`:`1px solid ${g.border}`,boxShadow:f?`0 -4px 10px ${d.color.accent}38`:`0 -4px 12px ${g.primary}33`,...f?{overflow:"hidden"}:null,boxSizing:"border-box",position:"relative",...x.container},children:[te,n("div",{onPointerDown:ve,onPointerMove:Ce,onPointerUp:ke,onPointerCancel:Se,style:{borderTopLeftRadius:f?d.radius.sheet:6,borderTopRightRadius:f?d.radius.sheet:6,backgroundColor:f?"transparent":g.card,minHeight:56,border:f?"none":`1px solid ${g.border}`,boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",flexShrink:0,touchAction:"none",userSelect:"none",cursor:"ns-resize",position:"relative"},children:n(pe,{header:u,isResizing:K,mode:p,onMinimize:D?O:void 0,variant:ut})}),ne,ye&&xe&&!be&&n(Qe,{onAcknowledge:we}),ee]})})},"bottomSheet")};export const JsModal=$t(o=>{const r=He()();if(r.status!=="admitted")return o.visible?n(Pe,{}):null;return n(Ke,{...o})});
1
+ "use strict";import{systemFont as ie}from"./ui/fonts.js";import{getUseAccountAccess as He}from"./license/licenseModule.js";import{AccountSetup as Pe}from"./license/AccountSetup";import{useState as T,useRef as y,useEffect as W,useLayoutEffect as Ee,useCallback as m,memo as $t,isValidElement as _e,cloneElement as ze}from"react";import{persistentStorage as se}from"./utils/persistentStorage";import{ModalStorage as Wt}from"./utils/modalStorage.js";import{devToolsStorageKeys as ae}from"./storage/devToolsStorageKeys.js";import{useHintsDisabled as Be}from"./context/index.js";import{ToolBackground as le}from"./ui/backgrounds/ToolBackground.js";import{night as d}from"./ui/night/nightTheme.js";import{expandableWindowControlsSupported as Ye,isExpandableWindowControlsEnabled as Fe}from"./ui/components/windowControlsSetting.js";import{jsx as n,jsxs as b,Fragment as Le}from"react/jsx-runtime";const g={base:"#121212",card:"#1A1A1A",border:"#333333",textMuted:"#888888",primary:"#20C997"};const w={primary:"#F5F5F7",primaryLight:"#F5F5F7",secondary:"#A1A1A6",muted:"#8E8E93",success:"#34C759",info:"#00B8E6"};const Ne=100;const Oe=400;const ce=500;const J=80;const wt=()=>typeof window!=="undefined"?window.innerWidth:0;const B=()=>typeof window!=="undefined"?window.innerHeight:0;const de=o=>1-Math.pow(1-o,3);const at=o=>o<.5?2*o*o:1-Math.pow(-2*o+2,2)/2;function G(o,r,s,u){let x=0;let l=false;const C=performance.now();const M=Q=>{if(l)return;const U=Math.min((Q-C)/o,1);s(r(U));if(U<1){x=requestAnimationFrame(M)}else{u?.()}};x=requestAnimationFrame(M);return()=>{l=true;cancelAnimationFrame(x)}}function Xe(){if(typeof document==="undefined"){return{top:0,left:0,right:0,bottom:0}}const o=document.createElement("div");o.style.cssText="position:fixed;top:env(safe-area-inset-top);left:env(safe-area-inset-left);right:env(safe-area-inset-right);bottom:env(safe-area-inset-bottom);visibility:hidden;pointer-events:none";document.body.appendChild(o);const r=o.getBoundingClientRect();document.body.removeChild(o);return{top:Math.max(0,r.top),left:Math.max(0,r.left),right:Math.max(0,window.innerWidth-r.right),bottom:Math.max(0,window.innerHeight-r.bottom)}}function Ht(o,r,s=false){const u=Math.max(J,window.innerWidth-r.left-r.right);const x=Math.max(J,window.innerHeight-r.top-r.bottom);const l=Math.min(o.width,u);const C=Math.min(o.height,x);return{width:l,height:C,left:Math.max(r.left,Math.min(o.left,window.innerWidth-r.right-l)),top:Math.max(r.top,Math.min(o.top,window.innerHeight-r.bottom-(s?J:C)))}}const Pt=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>b("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:[n("line",{x1:18,y1:6,x2:6,y2:18,stroke:r,strokeWidth:s,strokeLinecap:"round"}),n("line",{x1:6,y1:6,x2:18,y2:18,stroke:r,strokeWidth:s,strokeLinecap:"round"})]});const Et=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>n("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:n("line",{x1:5,y1:12,x2:19,y2:12,stroke:r,strokeWidth:s,strokeLinecap:"round"})});const ue=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>b("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:[n("rect",{x:3,y:3,width:18,height:18,rx:2,stroke:r,strokeWidth:s}),n("rect",{x:3,y:14,width:18,height:7,fill:r})]});const fe=({size:o=24,color:r="currentColor",strokeWidth:s=2})=>b("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",children:[n("rect",{x:3,y:3,width:14,height:14,rx:2,stroke:r,strokeWidth:s}),n("line",{x1:7,y1:17,x2:7,y2:21,stroke:r,strokeWidth:s}),n("line",{x1:7,y1:21,x2:21,y2:21,stroke:r,strokeWidth:s}),n("line",{x1:21,y1:21,x2:21,y2:7,stroke:r,strokeWidth:s}),n("line",{x1:17,y1:7,x2:21,y2:7,stroke:r,strokeWidth:s})]});const z={close:"#FF5F57",minimize:"#FEBC2E",toggleMode:"#28C840"};const _t=24;const je=2;const V=8;const zt=o=>({width:_t,height:_t,borderRadius:_t/2,display:"flex",alignItems:"center",justifyContent:"center",background:`radial-gradient(circle, ${o} 6px, transparent 6px)`,border:"none",padding:0,cursor:"pointer",flexShrink:0});function Ge(o){if(Fe()&&Ye(true)){return n(Ve,{...o})}return n(Ue,{...o})}function Ue({onClose:o,onMinimize:r,onToggleMode:s,mode:u}){const x=u==="floating"?ue:fe;const l=u==="floating"?"Dock to bottom sheet":"Make floating window";return b("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:je},children:[r&&n("button",{type:"button",onClick:r,style:zt(z.minimize),"aria-label":"Minimize modal",children:n(Et,{size:V,color:"#7A5A00",strokeWidth:1.5})}),s&&n("button",{type:"button",onClick:s,style:zt(z.toggleMode),"aria-label":l,children:n(x,{size:V,color:"#004A1A",strokeWidth:1.5})}),n("button",{type:"button",onClick:o,style:zt(z.close),"aria-label":"Close modal",children:n(Pt,{size:V,color:"#4A0000",strokeWidth:1.5})})]})}const Bt=12;const Ze=8;const vt=36;const qe=12;const Yt=16;const Ct=8;const Je=3e3;const Ft=150;const Lt=o=>({width:Bt,height:Bt,borderRadius:Bt/2,backgroundColor:o,display:"flex",alignItems:"center",justifyContent:"center"});const Nt=(o,r,s,u)=>({width:vt,height:vt,borderRadius:vt/2,display:"flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",flexShrink:0,backgroundColor:o?s:r,border:o?`1px solid ${u}`:"none"});function Ve({onClose:o,onMinimize:r,onToggleMode:s,mode:u,variant:x="night"}){const l=x==="night";const[C,M]=T(false);const[Q,U]=T(false);const Z=y(null);const Y=y(null);const A=u==="floating"?ue:fe;const H=u==="floating"?"Dock to bottom sheet":"Make floating window";const P=m(()=>{if(Z.current)clearTimeout(Z.current);if(Y.current)clearTimeout(Y.current);Z.current=null;Y.current=null},[]);const q=m(()=>{P();U(false);Y.current=setTimeout(()=>M(false),Ft)},[P]);const lt=m(()=>{P();M(true);requestAnimationFrame(()=>requestAnimationFrame(()=>U(true)));Z.current=setTimeout(q,Je)},[P,q]);W(()=>P,[P]);const ct=D=>{q();D()};return b(Le,{children:[b("button",{type:"button",onClick:lt,"aria-label":"Open window controls","data-testid":"tool-window-controls",style:{padding:10,margin:-8,border:"none",background:"transparent",cursor:"pointer",display:"flex",flexDirection:"row",alignItems:"center",gap:Ze},children:[r&&n("span",{style:Lt(z.minimize),children:n(Et,{size:V,color:"#7A5A00",strokeWidth:1.5})}),s&&n("span",{style:Lt(z.toggleMode),children:n(A,{size:V,color:"#004A1A",strokeWidth:1.5})}),n("span",{style:Lt(z.close),children:n(Pt,{size:V,color:"#4A0000",strokeWidth:1.5})})]}),C&&n("div",{style:{position:"absolute",top:-Ct,right:-Ct,zIndex:9999,transform:`scale(${Q?1:.3})`,opacity:Q?1:0,transition:`transform ${Ft}ms ease-out, opacity ${Ft}ms ease-out`},children:b("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:qe,padding:Ct,borderRadius:(vt+Ct*2)/2,backgroundColor:l?d.color.surface:g.card,border:`1px solid ${l?d.color.border:g.border}`,boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[r&&n("button",{type:"button",onClick:()=>ct(r),"aria-label":"Minimize modal","data-testid":"tool-window-minimize",style:Nt(l,z.minimize,d.color.warningSoft,d.color.warning+"59"),children:n(Et,{size:Yt,color:l?d.color.warning:"#7A5A00",strokeWidth:2})}),s&&n("button",{type:"button",onClick:()=>ct(s),"aria-label":H,"data-testid":"tool-window-mode",style:Nt(l,z.toggleMode,d.color.accentSoft,d.color.accentBorderStrong),children:n(A,{size:Yt,color:l?d.color.accent:"#004A1A",strokeWidth:2})}),n("button",{type:"button",onClick:()=>ct(o),"aria-label":"Close modal","data-testid":"tool-window-close",style:Nt(l,z.close,d.color.dangerSoft,d.color.danger+"59"),children:n(Pt,{size:Yt,color:l?d.color.danger:"#4A0000",strokeWidth:2})})]})})]})}const he=$t(function o({isResizing:r,mode:s,hasCustomContent:u=false,variant:x="default"}){const l=s==="floating";const C=x==="night";return b("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",position:"relative",justifyContent:u?"center":void 0,minHeight:u?32:void 0,paddingTop:u?0:8,paddingBottom:u?0:8,backgroundColor:"transparent"},children:[n("div",{style:{width:C?36:r?40:l?50:40,height:C?5:l?5:3,backgroundColor:C?d.color.placeholder:r?g.primary:l?g.textMuted:g.primary,borderRadius:C?2.5:2,boxShadow:C?"none":`0 0 4px ${g.primary}99`}}),r&&s==="bottomSheet"&&n("div",{style:{position:"absolute",display:"flex",flexDirection:"row",gap:2,marginTop:12},children:[0,1,2].map(M=>n("div",{style:{width:12,height:1,backgroundColor:w.success,opacity:.6}},M))})]})});const Qe=$t(function o({onAcknowledge:r}){return n("div",{style:{backgroundColor:`${w.info}15`,borderLeft:`3px solid ${w.info}`,borderRadius:8,margin:"8px 12px 4px",overflow:"hidden",boxShadow:`0 0 8px ${w.info}4D`,flexShrink:0},children:b("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",padding:12,gap:12},children:[b("div",{style:{width:32,height:32,position:"relative",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:[n("div",{style:{position:"absolute",width:20,height:20,borderRadius:10,border:`2px solid ${w.info}`,opacity:.6,transform:"scale(0.8)",boxSizing:"border-box"}}),n("div",{style:{position:"absolute",width:20,height:20,borderRadius:10,border:`2px solid ${w.info}`,boxSizing:"border-box"}})]}),b("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:2},children:[n("span",{style:{fontSize:13,fontWeight:600,color:w.info,letterSpacing:.3},children:"\u{1F4A1} Pro Tip"}),n("span",{style:{fontSize:12,color:w.primaryLight,lineHeight:"16px"},children:"Double-tap the header to transform this into a floating modal"})]}),n("button",{type:"button",onClick:r,style:{backgroundColor:`${w.info}30`,padding:"6px 12px",borderRadius:6,border:`1px solid ${w.info}50`,fontSize:12,fontWeight:600,color:w.info,cursor:"pointer",fontFamily:"inherit",flexShrink:0},children:"Got it!"})]})})});function pe({header:o,isResizing:r,mode:s,onMinimize:u,variant:x="default"}){if(o?.customContent){let l=o.customContent;if(_e(o.customContent)&&u){l=ze(o.customContent,{onMinimize:u})}return b("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",minWidth:0},children:[n(he,{isResizing:r,mode:s,hasCustomContent:true,variant:x}),l]})}return b("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",position:"relative",minWidth:0},children:[n(he,{isResizing:r,mode:s,variant:x}),b("div",{style:{padding:"0 16px",display:"flex",flexDirection:"column",alignItems:"center"},children:[o?.title&&n("span",{style:{fontSize:16,fontWeight:600,color:w.primary},children:o.title}),o?.subtitle&&n("span",{style:{fontSize:12,color:w.secondary,paddingTop:4},children:o.subtitle})]}),n("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:n("span",{style:{fontSize:10,color:w.muted,fontStyle:"italic"},children:"Double tap: Toggle \u2022 Triple tap: Close"})})]})}const Ke=({visible:o,onClose:r,children:s,header:u,styles:x={},minHeight:l=Ne,maxHeight:C,initialHeight:M=Oe,animatedHeight:Q,benchMotion:U,initialMode:Z="bottomSheet",onModeChange:Y,persistenceKey:A,enablePersistence:H=true,initialFloatingPosition:P,footer:q,footerHeight:lt=0,onBack:ct,onMinimize:D,minimizeRequest:dt=0,minimizeTargetPosition:kt,initialModalState:v,zIndex:Ot,disableScrollWrapper:ge=false,background:Xt=true,variant:ut="night"})=>{const[I]=T(Xe);const[jt,Gt]=T(!H);const[p,St]=T(Z);const ft=y(Y);ft.current=Y;const[K,F]=T(false);const[Dt,tt]=T(false);const[me,At]=T(M);const[E,et]=T(()=>Ht({width:wt(),height:ce,top:P?.y??(B()-ce)/2,left:P?.x??0},I));const[xe,ht]=T(false);const[ye,Ut]=T(false);const be=Be();const L=y(M);const R=y(E);const k=y({x:E.left,y:E.top});const pt=y(null);const It=y(null);const _=y(null);const N=y([]);const $=m(()=>{N.current.forEach(t=>t());N.current=[]},[]);W(()=>{R.current=E},[E]);W(()=>$,[$]);const Zt=C||B()-I.top;W(()=>{if(!H||!A){Gt(true);return}let t=true;const e=async()=>{const i=await Wt.load(A);if(t&&i){if(i.mode){St(i.mode);ft.current?.(i.mode)}if(i.panelHeight){At(i.panelHeight);L.current=i.panelHeight}if(i.dimensions){const a=Ht(i.dimensions,I,true);et(a);k.current={x:a.left,y:a.top}}}if(t)Gt(true)};e();return()=>{t=false}},[A,H]);W(()=>{if(!H||!A||!jt)return;const t=setTimeout(()=>{Wt.save(A,{mode:p,panelHeight:L.current,dimensions:E,isVisible:o})},500);return()=>clearTimeout(t)},[p,me,E,o,A,H,jt]);W(()=>{let t=true;const e=async()=>{try{const i=ae.modal.hintAcknowledged();const a=await se.getItem(i);if(t){ht(a!=="true");Ut(true)}}catch{if(t){ht(true);Ut(true)}}};e();return()=>{t=false}},[]);const we=m(async()=>{try{const t=ae.modal.hintAcknowledged();await se.setItem(t,"true");ht(false)}catch{ht(false)}},[]);const Rt=m(()=>{tt(false);F(false);const t=p==="bottomSheet"?"floating":"bottomSheet";St(t);ft.current?.(t)},[p]);W(()=>{tt(false);F(false)},[p]);const O=m(()=>{if(!D)return;const t={mode:p,panelHeight:L.current,floatingPosition:{x:R.current.left,y:R.current.top},floatingDimensions:{width:R.current.width,height:R.current.height}};if(H&&A)void Wt.saveMinimized(A,t);const e=kt?.x??wt()-50;const i=kt?.y??B()-150;$();if(p==="bottomSheet"){const a=pt.current;if(!a){D(t);return}const c=B();N.current.push(G(300,at,h=>{a.style.opacity=String(1-h);a.style.transform=`translateY(${h*c}px)`},()=>D(t)))}else{const a=_.current;if(!a){D(t);return}const c={...k.current};N.current.push(G(300,at,h=>{a.style.opacity=String(1-h);const rt=c.x+(e-c.x)*h;const X=c.y+(i-c.y)*h;a.style.transform=`translate(${rt}px, ${X}px)`},()=>D(t)))}},[p,D,kt,$,H,A]);const qt=y(dt);W(()=>{if(qt.current===dt)return;qt.current=dt;O()},[dt,O]);W(()=>{if(!v)return;if(v.mode){St(v.mode);ft.current?.(v.mode)}if(v.panelHeight){At(v.panelHeight);L.current=v.panelHeight}if(v.floatingDimensions&&v.floatingPosition){const t={width:v.floatingDimensions.width,height:v.floatingDimensions.height,top:v.floatingPosition.y,left:v.floatingPosition.x};et(t);k.current={x:v.floatingPosition.x,y:v.floatingPosition.y}}},[v]);Ee(()=>{if(!o)return;$();if(p==="bottomSheet"){const t=pt.current;if(!t)return;const e=B();t.style.transform=`translateY(${e}px)`;t.style.opacity="0";N.current.push(G(300,de,i=>{t.style.transform=`translateY(${(1-i)*e}px)`}),G(200,at,i=>{t.style.opacity=String(i)}))}else{const t=_.current;if(!t)return;k.current={x:R.current.left,y:R.current.top};t.style.transform=`translate(${k.current.x}px, ${k.current.y}px)`;t.style.opacity="0";N.current.push(G(200,at,e=>{t.style.opacity=String(e)}))}},[o,p,$]);const Jt=y(0);const nt=y(0);const ot=y(null);const gt=m(()=>{const t=Date.now();if(t-Jt.current>500){nt.current=0}nt.current++;Jt.current=t;if(ot.current)clearTimeout(ot.current);ot.current=setTimeout(()=>{if(nt.current===2){Rt()}else if(nt.current>=3){if(D)O()}nt.current=0},300)},[Rt,D,O]);W(()=>{return()=>{if(ot.current)clearTimeout(ot.current)}},[]);const mt=y({active:false,resizing:false,startY:0,headerOffsetY:0,samples:[]});const ve=m(t=>{if(p!=="bottomSheet")return;if(t.button!==0||t.target.closest('button, a, input, textarea, select, [role="button"], [role="tab"], [role="switch"], [contenteditable="true"], [tabindex]'))return;const e=mt.current;e.active=true;e.resizing=false;e.startY=t.clientY;const i=t.currentTarget.getBoundingClientRect();e.headerOffsetY=t.clientY-i.top;e.samples=[{t:performance.now(),y:t.clientY}];t.currentTarget.setPointerCapture(t.pointerId)},[p]);const Ce=m(t=>{const e=mt.current;if(!e.active)return;const i=t.clientY-e.startY;if(!e.resizing&&Math.abs(i)>3){e.resizing=true;$();F(true)}if(!e.resizing)return;const a=t.clientY-e.headerOffsetY;let c=B()-a;c=Math.max(l,Math.min(c,Zt));L.current=c;if(It.current)It.current.style.height=`${c}px`;const h=performance.now();e.samples.push({t:h,y:t.clientY});while(e.samples.length>2&&h-e.samples[0].t>100)e.samples.shift()},[l,Zt,$]);const ke=m(t=>{const e=mt.current;if(!e.active)return;e.active=false;if(!e.resizing){gt();return}F(false);const i=L.current;const a=t.clientY-e.startY;const c=e.samples[0];const h=e.samples[e.samples.length-1];const rt=h&&c&&h.t>c.t?(h.y-c.y)/(h.t-c.t):0;const X=rt>.8&&a>50||a>150&&i<=l;if(X){const S=pt.current;$();if(S){const it=B();N.current.push(G(200,at,j=>{S.style.opacity=String(1-j)}),G(300,de,j=>{S.style.transform=`translateY(${j*it}px)`},()=>r()))}else{r()}return}At(i)},[l,r,gt,$]);const Se=m(()=>{const t=mt.current;if(!t.active)return;t.active=false;t.resizing=false;F(false)},[]);const xt=y({active:false,dragging:false,startX:0,startY:0,startPos:{x:0,y:0}});const De=m(t=>{if(p!=="floating"||K)return;if(t.button!==0||t.target.closest('button, a, input, textarea, select, [role="button"], [role="tab"], [role="switch"], [contenteditable="true"], [tabindex]'))return;const e=xt.current;e.active=true;e.dragging=false;e.startX=t.clientX;e.startY=t.clientY;e.startPos={...k.current};t.currentTarget.setPointerCapture(t.pointerId)},[p,K]);const Ae=m(t=>{const e=xt.current;if(!e.active)return;const i=t.clientX-e.startX;const a=t.clientY-e.startY;if(!e.dragging&&Math.abs(i)+Math.abs(a)>5){e.dragging=true;tt(true)}if(!e.dragging)return;const c=e.startPos.x+i;const h=e.startPos.y+a;k.current={x:c,y:h};if(_.current){_.current.style.transform=`translate(${c}px, ${h}px)`}},[]);const Ie=m(()=>{const t=xt.current;if(!t.active)return;t.active=false;if(!t.dragging){gt();return}tt(false);const e=R.current;const i=Ht({...e,left:k.current.x,top:k.current.y},I);const a=i.left;const c=i.top;k.current={x:a,y:c};if(_.current){_.current.style.transform=`translate(${a}px, ${c}px)`}et(h=>({...h,left:a,top:c}))},[I,gt]);const Re=m(()=>{const t=xt.current;if(!t.active)return;t.active=false;t.dragging=false;tt(false)},[]);const Tt=y({active:false,corner:"bottomRight",startX:0,startY:0,start:{width:0,height:0,top:0,left:0}});const Te=m(t=>e=>{if(p!=="floating")return;e.stopPropagation();const i=Tt.current;i.active=true;i.corner=t;i.startX=e.clientX;i.startY=e.clientY;i.start={...R.current};F(true);e.currentTarget.setPointerCapture(e.pointerId)},[p]);const Me=m(t=>{const e=Tt.current;if(!e.active)return;const i=t.clientX-e.startX;const a=t.clientY-e.startY;if(Math.abs(i)<.5&&Math.abs(a)<.5)return;const c=Math.max(0,I.left);const h=B()-Math.max(0,I.bottom);const rt=wt()-Math.max(0,I.right);const X=wt()*.25;const S=e.start;const it=S.left+S.width;const j=S.top+S.height;let st=S.left;const bt=S.top;let oe=it;let Mt=j;if(e.corner==="bottomLeft"){st=Math.max(c,Math.min(S.left+i,it-X));Mt=Math.min(h,Math.max(j+a,S.top+J))}else{oe=Math.min(rt,Math.max(it+i,S.left+X));Mt=Math.min(h,Math.max(j+a,S.top+J))}const $e=Math.max(X,oe-st);const We=Math.max(J,Mt-bt);const re={width:$e,height:We,left:st,top:bt};R.current=re;k.current={x:st,y:bt};et(re);if(_.current){_.current.style.transform=`translate(${st}px, ${bt}px)`}},[I.left,I.right,I.bottom]);const Vt=m(()=>{const t=Tt.current;if(!t.active)return;t.active=false;F(false);et(R.current)},[]);const yt=!o;const Qt=yt?{left:-9999,top:-9999,opacity:0,visibility:"hidden",pointerEvents:"none"}:{};const Kt=u?.title||"Dev tool panel";const f=ut==="night";const te=Xt&&f?n("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":true,children:n(le,{})}):null;const ee=b("div",{style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column",backgroundColor:f?"transparent":g.base,borderBottomLeftRadius:16,borderBottomRightRadius:16,overflow:"hidden",...x.content},children:[Xt&&!f?n(le,{}):null,ge?n("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",paddingBottom:lt},children:s}):n("div",{style:{flex:1,minHeight:0,overflowY:"auto",paddingBottom:lt},children:s}),q?n("div",{style:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:g.base,borderBottomLeftRadius:16,borderBottomRightRadius:16},children:q}):null]});const ne=n("div",{style:{position:"absolute",top:4,right:4,zIndex:10},children:n(Ge,{onClose:r,onMinimize:D?O:void 0,onToggleMode:Rt,mode:p,variant:ut})});if(p==="floating"){const t=Dt||K;return b("div",{ref:_,role:"dialog","aria-label":Kt,"aria-hidden":yt||void 0,style:{fontFamily:ie,position:"fixed",pointerEvents:"auto",left:0,top:0,width:E.width,height:E.height,transform:`translate(${k.current.x}px, ${k.current.y}px)`,display:"flex",flexDirection:"column",backgroundColor:f?d.color.bg:g.card,borderRadius:f?d.radius.sheet:6,border:f?`1px solid ${d.color.accent}55`:t?`2px solid ${g.primary}`:`1px solid ${g.border}`,boxShadow:f?`0 0 14px ${d.color.accent}38`:t?`0 0 12px ${g.primary}7A`:`0 0 20px ${g.primary}4D`,...f?{overflow:"hidden"}:null,boxSizing:"border-box",zIndex:Ot??1e3,...x.container,...Qt},children:[te,n("div",{onPointerDown:De,onPointerMove:Ae,onPointerUp:Ie,onPointerCancel:Re,style:{borderTopLeftRadius:f?d.radius.sheet:6,borderTopRightRadius:f?d.radius.sheet:6,backgroundColor:f?"transparent":g.card,minHeight:56,border:f?"none":`1px solid ${g.border}`,boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",flexShrink:0,touchAction:"none",userSelect:"none",cursor:Dt?"grabbing":"grab",position:"relative"},children:n(pe,{header:u,isResizing:Dt||K,mode:p,onMinimize:D?O:void 0,variant:ut})}),ne,ee,["bottomLeft","bottomRight"].map(e=>n("div",{onPointerDown:Te(e),onPointerMove:Me,onPointerUp:Vt,onPointerCancel:Vt,style:{position:"absolute",width:30,height:30,bottom:4,...e==="bottomLeft"?{left:4}:{right:4},zIndex:1e3,touchAction:"none",cursor:e==="bottomLeft"?"nesw-resize":"nwse-resize"},children:n("div",{style:{width:20,height:20,borderRadius:10,boxSizing:"border-box",backgroundColor:t?`${w.success}1A`:"transparent",border:t?`2px solid ${w.success}`:"none",boxShadow:t?`0 0 8px ${w.success}99`:"none"}})},e))]},"floating")}return n("div",{"aria-hidden":yt||void 0,style:{fontFamily:ie,position:"fixed",inset:0,zIndex:Ot??1e3,pointerEvents:"none",...yt?{...Qt,inset:"auto",width:"100vw",height:"100vh"}:null},children:n("div",{ref:pt,style:{position:"absolute",bottom:0,left:0,right:0,pointerEvents:"auto"},children:b("div",{ref:It,role:"dialog","aria-label":Kt,style:{height:L.current,display:"flex",flexDirection:"column",backgroundColor:f?d.color.bg:g.card,borderTopLeftRadius:f?d.radius.sheet:6,borderTopRightRadius:f?d.radius.sheet:6,border:f?`1px solid ${d.color.accent}55`:`1px solid ${g.border}`,boxShadow:f?`0 -4px 10px ${d.color.accent}38`:`0 -4px 12px ${g.primary}33`,...f?{overflow:"hidden"}:null,boxSizing:"border-box",position:"relative",...x.container},children:[te,n("div",{onPointerDown:ve,onPointerMove:Ce,onPointerUp:ke,onPointerCancel:Se,style:{borderTopLeftRadius:f?d.radius.sheet:6,borderTopRightRadius:f?d.radius.sheet:6,backgroundColor:f?"transparent":g.card,minHeight:56,border:f?"none":`1px solid ${g.border}`,boxSizing:"border-box",display:"flex",flexDirection:"column",justifyContent:"center",flexShrink:0,touchAction:"none",userSelect:"none",cursor:"ns-resize",position:"relative"},children:n(pe,{header:u,isResizing:K,mode:p,onMinimize:D?O:void 0,variant:ut})}),ne,ye&&xe&&!be&&n(Qe,{onAcknowledge:we}),ee]})})},"bottomSheet")};export const JsModal=$t(o=>{const r=He();const s=r();if(s.status!=="admitted")return o.visible?n(Pe,{}):null;return n(Ke,{...o})});
@@ -1 +1 @@
1
- "use strict";export*from"./ui/index.js";export*from"./stores/index.js";export*from"./bugCase/index.js";export*from"./sync/keyedArrays.js";export*from"./sync/valueShape.js";export*from"./sync/valuePath.js";export*from"./sync/typedEdit.js";export*from"./sync/wireBudget.js";export*from"./sync/wireForm.js";export*from"./sync/toolSyncAdapter.js";export{startSettingsSync,SettingsSync,PERSONAL_SETTING_KEYS,TEAM_SETTING_KEYS,onSettingsApplied,syncSettingsNow}from"./sync/settingsSync.js";export*from"./tools/defineTool.js";export*from"./sync/toolActionRegistry.js";export*from"./sync/toolUiBridge.js";export*from"./sync/toolScreenHeader.js";export{absoluteFill,displayValue,parseDisplayValue,getSafeAreaInsets,persistentStorage,setItemChecked,getItemChecked,storageIsMemoryOnly,isUsingPersistentStorage,getStorageBackendType,safeStringify,getValueType,isPrimitive,isJsonSerializable,isValidJson,getConstructorName,isEmpty,getValueSize,parseValue,formatValue,getTypeColor,truncateText,flattenObject,formatPath,loadOptionalModule,getCachedOptionalModule,setRenderCaptureProvider,getRenderCaptureProvider,registerStateSnapshotProvider,getStateSnapshotProviders,getStateSnapshotProvider,subscribeToStateSnapshotProviders,superJsonSerialize,superJsonDeserialize,realNow,getRealAppState,subscribeRealAppState,BUOY_SYNTHETIC_MARK,countBuoyListener,reloadApp,scheduleReloadApp,resolveReloadStrategy,REMOTE_RELOAD_DELAY_MS,getDevServerOrigin,Subscribable,subscriberCountNotifier,subscribeToSubscriberCountChanges,notifySubscriberCountChange,useSafeRouter,useSafePathname,useSafeSegments,useSafeGlobalSearchParams,getSafeRouter,getSafeCurrentPathname,getSafeCurrentRoute,isExpoRouterAvailable}from"./utils/index.js";export*from"./utils/toolModules.js";export{subscribeStorageWrites}from"./utils/storageWrites.js";export{FiberRootAnchor,getAnchoredFiberRoots}from"./utils/fiberRootAnchor.js";export{registerBrowserRouter,browserRouter,subscribeBrowserNavigation}from"./utils/browserNavigation.js";export{PREVIEW_ITEM_RENDER_BYTE_LIMIT,createRestoreScope,emptyRestoreResult,failedRestore,skippedRestore,classifyPreviewItem,wontApply,unionKeys}from"./utils/snapshotProviderKit.js";export{entityColor,formatValuePreview,shallowDiffSummary}from"./utils/stateTools.js";export*from"./utils/formatting/index.js";export*from"./utils/time/index.js";export{isPlainObject as isPlainObjectUtil}from"./utils/typeHelpers.js";export*from"./icons/index.js";export*from"./clipboard/index.js";export*from"./logger/index.js";export*from"./settings/index.js";export*from"./storage/index.js";export{useSafeAreaInsets,useFilterManager,usePersistedState,resetPersistedStateCache,useChangeLog,useSubscribedValue,useEventStoreEvents,useDeviceInfo,getDeviceInfo,logDeviceInfo}from"./hooks/index.js";export{JsModal}from"./JsModal";export{night,NIGHT_LABEL_TRACKING}from"./ui/night/nightTheme.js";export{QrCodeView}from"./ui/qr/QrCodeView.js";export{NightSectionLabel,NightFootnote,NightCard,NightSeparator,NightRows,NightSwitch,NightChip,NightButton,NightSegmented,NightBadge}from"./ui/night/primitives.js";export{gameUIColors,buoyColors}from"./ui/gameUI/constants/gameUIColors.js";export{refreshGameUIColors}from"./ui/gameUI/constants/gameUIColors.js";export{macOSColors}from"./ui/gameUI/constants/macOSDesignSystemColors.js";export{dialColors}from"./ui/gameUI/constants/gameUIColors.js";export{EnvironmentIndicator}from"./env/EnvironmentIndicator";export{EnvironmentSelector}from"./env/EnvironmentSelector.js";export{EnvironmentSelectorInline}from"./env/EnvironmentSelectorInline";export{normalizeEnvironment}from"./types/types.js";export{HintsProvider,useHintsDisabled,useHintsContext}from"./context/index.js";export*from"./history/index.js";export{FeatureGate,UpgradePrompt,useFeatureGate,ProFeatureBanner,UpgradeModal,BuoyUpgradeSheet,BuoySignInCard,BuoyNeedsPlanCard,BuoyGetProCard,useSignInState,ProBadge,ProUpgradeModal,FreeAccountPrompt,LOGIN_COMMAND,getUseIsPro,getUseLicense,getUseTier,signOutOfBuoy,TIER_LIMITS,useLimit,resolveEffectiveTier}from"./license/index.js";export{getAccountAccess,hasAccountAccess,assertAccountAccess,subscribeAccountAccess,getUseAccountAccess,retryAccountAccess,isProNow,getTeamCredential,getSignInSession}from"./license/licenseModule.js";export{setBuoyAppId,getBuoyAppId}from"./utils/appIdentity.js";export{guardToolAdapter}from"./sync/toolActionRegistry.js";export{AccountSetup}from"./license/AccountSetup";export{AccountSetupButton}from"./license/AccountSetupContent.js";
1
+ "use strict";export*from"./ui/index.js";export*from"./stores/index.js";export*from"./bugCase/index.js";export*from"./sync/keyedArrays.js";export*from"./sync/valueShape.js";export*from"./sync/valuePath.js";export*from"./sync/typedEdit.js";export*from"./sync/wireBudget.js";export*from"./sync/wireForm.js";export*from"./sync/toolSyncAdapter.js";export{startSettingsSync,SettingsSync,PERSONAL_SETTING_KEYS,TEAM_SETTING_KEYS,onSettingsApplied,syncSettingsNow}from"./sync/settingsSync.js";export*from"./tools/defineTool.js";export*from"./sync/toolActionRegistry.js";export*from"./sync/toolUiBridge.js";export*from"./sync/toolScreenHeader.js";export{absoluteFill,displayValue,parseDisplayValue,getSafeAreaInsets,persistentStorage,setItemChecked,getItemChecked,storageIsMemoryOnly,isUsingPersistentStorage,getStorageBackendType,safeStringify,getValueType,isPrimitive,isJsonSerializable,isValidJson,getConstructorName,isEmpty,getValueSize,parseValue,formatValue,getTypeColor,truncateText,flattenObject,formatPath,loadOptionalModule,getCachedOptionalModule,setRenderCaptureProvider,getRenderCaptureProvider,registerStateSnapshotProvider,getStateSnapshotProviders,getStateSnapshotProvider,subscribeToStateSnapshotProviders,superJsonSerialize,superJsonDeserialize,realNow,getRealAppState,subscribeRealAppState,BUOY_SYNTHETIC_MARK,countBuoyListener,reloadApp,scheduleReloadApp,resolveReloadStrategy,REMOTE_RELOAD_DELAY_MS,getDevServerOrigin,Subscribable,subscriberCountNotifier,subscribeToSubscriberCountChanges,notifySubscriberCountChange,useSafeRouter,useSafePathname,useSafeSegments,useSafeGlobalSearchParams,getSafeRouter,getSafeCurrentPathname,getSafeCurrentRoute,isExpoRouterAvailable}from"./utils/index.js";export*from"./utils/toolModules.js";export{subscribeStorageWrites}from"./utils/storageWrites.js";export{FiberRootAnchor,getAnchoredFiberRoots}from"./utils/fiberRootAnchor.js";export{registerBrowserRouter,browserRouter,subscribeBrowserNavigation}from"./utils/browserNavigation.js";export{PREVIEW_ITEM_RENDER_BYTE_LIMIT,createRestoreScope,emptyRestoreResult,failedRestore,skippedRestore,classifyPreviewItem,wontApply,unionKeys}from"./utils/snapshotProviderKit.js";export{entityColor,formatValuePreview,shallowDiffSummary}from"./utils/stateTools.js";export*from"./utils/formatting/index.js";export*from"./utils/time/index.js";export{isPlainObject as isPlainObjectUtil}from"./utils/typeHelpers.js";export*from"./icons/index.js";export*from"./clipboard/index.js";export*from"./logger/index.js";export*from"./settings/index.js";export*from"./storage/index.js";export{useSafeAreaInsets,useFilterManager,usePersistedState,resetPersistedStateCache,useChangeLog,useSubscribedValue,useEventStoreEvents,useDeviceInfo,getDeviceInfo,logDeviceInfo}from"./hooks/index.js";export{JsModal}from"./JsModal";export{night,NIGHT_LABEL_TRACKING}from"./ui/night/nightTheme.js";export{QrCodeView}from"./ui/qr/QrCodeView.js";export{NightSectionLabel,NightFootnote,NightCard,NightSeparator,NightRows,NightSwitch,NightChip,NightButton,NightSegmented,NightBadge}from"./ui/night/primitives.js";export{gameUIColors,buoyColors}from"./ui/gameUI/constants/gameUIColors.js";export{refreshGameUIColors}from"./ui/gameUI/constants/gameUIColors.js";export{macOSColors}from"./ui/gameUI/constants/macOSDesignSystemColors.js";export{dialColors}from"./ui/gameUI/constants/gameUIColors.js";export{EnvironmentIndicator}from"./env/EnvironmentIndicator";export{EnvironmentSelector}from"./env/EnvironmentSelector.js";export{EnvironmentSelectorInline}from"./env/EnvironmentSelectorInline";export{normalizeEnvironment}from"./types/types.js";export{HintsProvider,useHintsDisabled,useHintsContext}from"./context/index.js";export*from"./history/index.js";export{FeatureGate,UpgradePrompt,useFeatureGate,ProFeatureBanner,UpgradeModal,BuoyUpgradeSheet,BuoySignInCard,BuoyNeedsPlanCard,BuoyGetProCard,useSignInState,ProBadge,ProUpgradeModal,FreeAccountPrompt,LOGIN_COMMAND,getUseIsPro,getUseLicense,getUseTier,signOutOfBuoy,restoreSignedOutKey,TIER_LIMITS,useLimit,resolveEffectiveTier}from"./license/index.js";export{getAccountAccess,hasAccountAccess,assertAccountAccess,isLicensedNow,subscribeAccountAccess,getUseAccountAccess,retryAccountAccess,isProNow,getTeamCredential,getSignInSession}from"./license/licenseModule.js";export{bootBeforeActions,canSimulateInThisBuild,canSimulateNow,isReleaseBuild,isWebRelease,markSimulationSurface,SIMULATION_RELEASE_HELP,simulationSurfacePending,subscribeSimulationSurface}from"./license/releaseSimulation.js";export{setBuoyAppId,getBuoyAppId}from"./utils/appIdentity.js";export{guardToolAdapter}from"./sync/toolActionRegistry.js";export{AccountSetup}from"./license/AccountSetup";export{AccountSetupButton}from"./license/AccountSetupContent.js";
@@ -1 +1 @@
1
- "use strict";import{useCallback as R,useEffect as W,useRef as C,useState as x}from"react";import{ActivityIndicator as H,Pressable as l,StyleSheet as I,Text as i,View as n}from"react-native";import{Check as j,ChevronRight as v,Copy as O,RefreshCw as F,X as N}from"../icons/lucide-icons.js";import{copyToClipboard as U}from"../clipboard/index.js";import{monoFont as T}from"../ui/fonts.js";import{night as o}from"../ui/night/nightTheme.js";import{getAccountAccess as E,getUseAccountAccess as B,getUseLicense as V,retryAccountAccess as M}from"./licenseModule.js";import{openPricing as S}from"./openPricing.js";import{jsx as t,jsxs as r}from"react/jsx-runtime";export const LOGIN_COMMAND="npx --package=@buoy-gg/core buoy login";export function AccountSetupButton({onPress:m,expanded:y=false,needsPlan:g=false}){const f=B()();const p=f.status==="initializing";return r(l,{accessibilityRole:"button",accessibilityLabel:g?"Plan needed for Buoy":"Sign in to Buoy",accessibilityState:{expanded:y},onPress:m,style:({pressed:a})=>[e.launcher,y&&e.launcherOpen,a&&e.pressed],children:[t(n,{style:e.brandDot}),t(i,{style:e.launcherBrand,children:"BUOY"}),t(n,{style:e.launcherDivider}),t(i,{style:e.launcherLabel,children:p?"Checking\u2026":g?"Plan needed":"Sign in"}),p?t(H,{size:14,color:o.color.accent}):t(v,{size:14,color:o.color.textSecondary})]})}export function AccountSetupCard({onClose:m,titleId:y}){const g=B()();const f=V();const p=f?.();const[a,k]=x(false);const[L,w]=x(false);const[A,h]=x(null);const u=C(null);const s=C(true);const b=C(false);const d=L||g.status==="initializing";const z=p?.error||A;W(()=>{s.current=true;return()=>{s.current=false;if(u.current)clearTimeout(u.current)}},[]);const D=R(async()=>{const c=await U(LOGIN_COMMAND);if(!s.current)return;if(!c){h("Select the command to copy it, then run it in your project terminal.");return}h(null);k(true);if(u.current)clearTimeout(u.current);u.current=setTimeout(()=>k(false),2e3)},[]);const P=R(async()=>{if(b.current)return;b.current=true;w(true);h(null);try{await M();if(s.current&&E().status!=="admitted"){h("No account connected yet. Run the command, sign in, then reload your app.")}}catch{if(s.current)h("Couldn't verify your account. Check your connection and try again.")}finally{b.current=false;if(s.current)w(false)}},[]);return r(n,{style:e.card,children:[r(n,{style:e.header,children:[r(n,{style:e.brand,children:[t(n,{style:e.brandDot}),t(i,{style:e.wordmark,children:"BUOY"}),t(i,{style:e.headerLabel,children:"Developer tools"})]}),t(l,{accessibilityRole:"button",accessibilityLabel:"Close account setup",onPress:m,hitSlop:6,style:({pressed:c})=>[e.close,c&&e.pressed],children:t(N,{size:16,color:o.color.textSecondary})})]}),r(i,{nativeID:y,accessibilityRole:"header",style:e.title,children:["Connect your","\n","Buoy account"]}),t(i,{style:e.description,children:"Sign in with a Free or Pro account to open your developer tools."}),r(n,{style:e.terminal,children:[r(n,{style:e.terminalHeader,children:[t(i,{style:e.terminalLabel,children:"RUN IN YOUR PROJECT"}),r(l,{accessibilityRole:"button",accessibilityLabel:a?"Login command copied":"Copy login command",onPress:D,style:({pressed:c})=>[e.copy,c&&e.pressed],children:[a?t(j,{size:13,color:o.color.accent}):t(O,{size:13,color:o.color.textSecondary}),t(i,{accessibilityLiveRegion:"polite",style:[e.copyText,a&&e.accentText],children:a?"Copied":"Copy"})]})]}),r(n,{style:e.command,children:[t(i,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:e.prompt,children:"$"}),t(i,{selectable:true,style:e.commandText,children:LOGIN_COMMAND})]})]}),t(i,{style:e.hint,children:"Finish signing in, then reload your app."}),r(l,{accessibilityRole:"button",accessibilityState:{disabled:d,busy:d},disabled:d,onPress:P,style:({pressed:c})=>[e.primary,c&&e.primaryPressed,d&&e.primaryBusy],children:[d?t(H,{size:15,color:o.color.onAccent}):t(F,{size:15,color:o.color.onAccent}),t(i,{style:e.primaryText,children:d?"Checking connection\u2026":"Check connection"})]}),z&&t(i,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",style:e.feedback,children:z}),r(n,{style:e.footer,children:[t(i,{style:e.footerLabel,children:"Need a hand?"}),r(n,{style:e.links,children:[t(l,{accessibilityRole:"link",onPress:()=>S("https://github.com/Buoy-gg/buoy/issues/new/choose"),style:e.link,children:t(i,{style:e.linkText,children:"GitHub"})}),t(l,{accessibilityRole:"link",accessibilityLabel:"Email support@buoy.gg",onPress:()=>S("mailto:support@buoy.gg"),style:e.link,children:t(i,{style:e.linkText,children:"Email"})}),t(l,{accessibilityRole:"link",accessibilityLabel:"View Buoy plans",onPress:()=>S(),style:e.link,children:t(i,{style:e.linkText,children:"Plans"})})]})]})]})}const e=I.create({launcher:{flexDirection:"row",alignItems:"center",gap:10,minHeight:44,paddingHorizontal:16,borderRadius:14,backgroundColor:"#111315",borderWidth:1,borderColor:"#303437",shadowColor:"#000",shadowOpacity:.28,shadowRadius:14,shadowOffset:{width:0,height:4},elevation:8},launcherOpen:{borderColor:o.color.accentBorderStrong},launcherBrand:{color:o.color.text,fontSize:11,fontWeight:"800",letterSpacing:1.2,lineHeight:16},launcherDivider:{width:1,height:16,backgroundColor:"#35383C",marginHorizontal:2},launcherLabel:{color:o.color.text,fontSize:12,fontWeight:"500",lineHeight:18},brandDot:{width:6,height:6,borderRadius:3,backgroundColor:o.color.accent},card:{width:"100%",backgroundColor:"#111315",borderColor:"#303437",borderWidth:1,borderRadius:20,paddingHorizontal:24,paddingTop:18,paddingBottom:12},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:24},brand:{flexDirection:"row",alignItems:"center",gap:8},wordmark:{color:o.color.text,fontSize:11,fontWeight:"800",letterSpacing:1.4,lineHeight:16},headerLabel:{color:o.color.textSecondary,fontSize:11,lineHeight:16,marginLeft:4},close:{width:28,height:28,borderRadius:8,backgroundColor:o.color.fill,alignItems:"center",justifyContent:"center"},title:{color:o.color.text,fontSize:25,fontWeight:"600",lineHeight:31,letterSpacing:-.6,marginBottom:10},description:{color:"#A4AAAF",fontSize:13,lineHeight:20,marginBottom:22},terminal:{backgroundColor:"#090B0D",borderWidth:1,borderColor:"#292C30",borderRadius:12},terminalHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:14,paddingRight:6,paddingTop:6},terminalLabel:{color:"#93999F",fontSize:9,fontWeight:"600",letterSpacing:.8,lineHeight:14},copy:{minWidth:68,minHeight:32,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:5,borderRadius:6},copyText:{color:o.color.textSecondary,fontSize:11,fontWeight:"500",lineHeight:16},accentText:{color:o.color.accent},command:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:16,paddingTop:6,paddingBottom:18},prompt:{color:o.color.accent,fontSize:15,fontFamily:T,lineHeight:22},commandText:{color:o.color.text,fontSize:15,fontFamily:T,lineHeight:22,flexShrink:1},hint:{color:o.color.textSecondary,fontSize:12,lineHeight:18,marginTop:10,marginBottom:22},primary:{minHeight:42,borderRadius:10,backgroundColor:o.color.accent,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:9,paddingHorizontal:12,paddingVertical:10},primaryPressed:{backgroundColor:o.color.accentPressed},primaryBusy:{opacity:.75},primaryText:{color:o.color.onAccent,fontSize:13,fontWeight:"600",lineHeight:20},feedback:{color:"#B5BBC0",fontSize:12,lineHeight:18,marginTop:12},footer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",borderTopWidth:1,borderTopColor:o.color.separator,marginTop:20,paddingTop:8},footerLabel:{color:o.color.textSecondary,fontSize:11,lineHeight:16},links:{flexDirection:"row",gap:2},link:{paddingHorizontal:7,paddingVertical:10,borderRadius:6},linkText:{color:"#B5BBC0",fontSize:11,fontWeight:"500",lineHeight:16},pressed:{opacity:.7}});
1
+ "use strict";import{useCallback as R,useEffect as I,useRef as x,useState as k}from"react";import{ActivityIndicator as T,Pressable as l,StyleSheet as j,Text as i,View as n}from"react-native";import{Check as v,ChevronRight as O,Copy as F,RefreshCw as N,X as U}from"../icons/lucide-icons.js";import{copyToClipboard as E}from"../clipboard/index.js";import{monoFont as B}from"../ui/fonts.js";import{night as o}from"../ui/night/nightTheme.js";import{getAccountAccess as V,getUseAccountAccess as A,getUseLicense as M,retryAccountAccess as Y}from"./licenseModule.js";import{openPricing as S}from"./openPricing.js";import{jsx as t,jsxs as r}from"react/jsx-runtime";export const LOGIN_COMMAND="npx --package=@buoy-gg/core buoy login";export function AccountSetupButton({onPress:m,expanded:y=false,needsPlan:g=false}){const f=A();const b=f();const p=b.status==="initializing";return r(l,{accessibilityRole:"button",accessibilityLabel:g?"Plan needed for Buoy":"Sign in to Buoy",accessibilityState:{expanded:y},onPress:m,style:({pressed:a})=>[e.launcher,y&&e.launcherOpen,a&&e.pressed],children:[t(n,{style:e.brandDot}),t(i,{style:e.launcherBrand,children:"BUOY"}),t(n,{style:e.launcherDivider}),t(i,{style:e.launcherLabel,children:p?"Checking\u2026":g?"Plan needed":"Sign in"}),p?t(T,{size:14,color:o.color.accent}):t(O,{size:14,color:o.color.textSecondary})]})}export function AccountSetupCard({onClose:m,titleId:y}){const g=A();const f=g();const b=M();const p=b?.();const[a,w]=k(false);const[L,H]=k(false);const[D,u]=k(null);const h=x(null);const s=x(true);const C=x(false);const d=L||f.status==="initializing";const z=p?.error||D;I(()=>{s.current=true;return()=>{s.current=false;if(h.current)clearTimeout(h.current)}},[]);const P=R(async()=>{const c=await E(LOGIN_COMMAND);if(!s.current)return;if(!c){u("Select the command to copy it, then run it in your project terminal.");return}u(null);w(true);if(h.current)clearTimeout(h.current);h.current=setTimeout(()=>w(false),2e3)},[]);const W=R(async()=>{if(C.current)return;C.current=true;H(true);u(null);try{await Y();if(s.current&&V().status!=="admitted"){u("No account connected yet. Run the command, sign in, then reload your app.")}}catch{if(s.current)u("Couldn't verify your account. Check your connection and try again.")}finally{C.current=false;if(s.current)H(false)}},[]);return r(n,{style:e.card,children:[r(n,{style:e.header,children:[r(n,{style:e.brand,children:[t(n,{style:e.brandDot}),t(i,{style:e.wordmark,children:"BUOY"}),t(i,{style:e.headerLabel,children:"Developer tools"})]}),t(l,{accessibilityRole:"button",accessibilityLabel:"Close account setup",onPress:m,hitSlop:6,style:({pressed:c})=>[e.close,c&&e.pressed],children:t(U,{size:16,color:o.color.textSecondary})})]}),r(i,{nativeID:y,accessibilityRole:"header",style:e.title,children:["Connect your","\n","Buoy account"]}),t(i,{style:e.description,children:"Sign in with a Free or Pro account to open your developer tools."}),r(n,{style:e.terminal,children:[r(n,{style:e.terminalHeader,children:[t(i,{style:e.terminalLabel,children:"RUN IN YOUR PROJECT"}),r(l,{accessibilityRole:"button",accessibilityLabel:a?"Login command copied":"Copy login command",onPress:P,style:({pressed:c})=>[e.copy,c&&e.pressed],children:[a?t(v,{size:13,color:o.color.accent}):t(F,{size:13,color:o.color.textSecondary}),t(i,{accessibilityLiveRegion:"polite",style:[e.copyText,a&&e.accentText],children:a?"Copied":"Copy"})]})]}),r(n,{style:e.command,children:[t(i,{accessibilityElementsHidden:true,importantForAccessibility:"no",style:e.prompt,children:"$"}),t(i,{selectable:true,style:e.commandText,children:LOGIN_COMMAND})]})]}),t(i,{style:e.hint,children:"Finish signing in, then reload your app."}),r(l,{accessibilityRole:"button",accessibilityState:{disabled:d,busy:d},disabled:d,onPress:W,style:({pressed:c})=>[e.primary,c&&e.primaryPressed,d&&e.primaryBusy],children:[d?t(T,{size:15,color:o.color.onAccent}):t(N,{size:15,color:o.color.onAccent}),t(i,{style:e.primaryText,children:d?"Checking connection\u2026":"Check connection"})]}),z&&t(i,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",style:e.feedback,children:z}),r(n,{style:e.footer,children:[t(i,{style:e.footerLabel,children:"Need a hand?"}),r(n,{style:e.links,children:[t(l,{accessibilityRole:"link",onPress:()=>S("https://github.com/Buoy-gg/buoy/issues/new/choose"),style:e.link,children:t(i,{style:e.linkText,children:"GitHub"})}),t(l,{accessibilityRole:"link",accessibilityLabel:"Email support@buoy.gg",onPress:()=>S("mailto:support@buoy.gg"),style:e.link,children:t(i,{style:e.linkText,children:"Email"})}),t(l,{accessibilityRole:"link",accessibilityLabel:"View Buoy plans",onPress:()=>S(),style:e.link,children:t(i,{style:e.linkText,children:"Plans"})})]})]})]})}const e=j.create({launcher:{flexDirection:"row",alignItems:"center",gap:10,minHeight:44,paddingHorizontal:16,borderRadius:14,backgroundColor:"#111315",borderWidth:1,borderColor:"#303437",shadowColor:"#000",shadowOpacity:.28,shadowRadius:14,shadowOffset:{width:0,height:4},elevation:8},launcherOpen:{borderColor:o.color.accentBorderStrong},launcherBrand:{color:o.color.text,fontSize:11,fontWeight:"800",letterSpacing:1.2,lineHeight:16},launcherDivider:{width:1,height:16,backgroundColor:"#35383C",marginHorizontal:2},launcherLabel:{color:o.color.text,fontSize:12,fontWeight:"500",lineHeight:18},brandDot:{width:6,height:6,borderRadius:3,backgroundColor:o.color.accent},card:{width:"100%",backgroundColor:"#111315",borderColor:"#303437",borderWidth:1,borderRadius:20,paddingHorizontal:24,paddingTop:18,paddingBottom:12},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:24},brand:{flexDirection:"row",alignItems:"center",gap:8},wordmark:{color:o.color.text,fontSize:11,fontWeight:"800",letterSpacing:1.4,lineHeight:16},headerLabel:{color:o.color.textSecondary,fontSize:11,lineHeight:16,marginLeft:4},close:{width:28,height:28,borderRadius:8,backgroundColor:o.color.fill,alignItems:"center",justifyContent:"center"},title:{color:o.color.text,fontSize:25,fontWeight:"600",lineHeight:31,letterSpacing:-.6,marginBottom:10},description:{color:"#A4AAAF",fontSize:13,lineHeight:20,marginBottom:22},terminal:{backgroundColor:"#090B0D",borderWidth:1,borderColor:"#292C30",borderRadius:12},terminalHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingLeft:14,paddingRight:6,paddingTop:6},terminalLabel:{color:"#93999F",fontSize:9,fontWeight:"600",letterSpacing:.8,lineHeight:14},copy:{minWidth:68,minHeight:32,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:5,borderRadius:6},copyText:{color:o.color.textSecondary,fontSize:11,fontWeight:"500",lineHeight:16},accentText:{color:o.color.accent},command:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:16,paddingTop:6,paddingBottom:18},prompt:{color:o.color.accent,fontSize:15,fontFamily:B,lineHeight:22},commandText:{color:o.color.text,fontSize:15,fontFamily:B,lineHeight:22,flexShrink:1},hint:{color:o.color.textSecondary,fontSize:12,lineHeight:18,marginTop:10,marginBottom:22},primary:{minHeight:42,borderRadius:10,backgroundColor:o.color.accent,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:9,paddingHorizontal:12,paddingVertical:10},primaryPressed:{backgroundColor:o.color.accentPressed},primaryBusy:{opacity:.75},primaryText:{color:o.color.onAccent,fontSize:13,fontWeight:"600",lineHeight:20},feedback:{color:"#B5BBC0",fontSize:12,lineHeight:18,marginTop:12},footer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",borderTopWidth:1,borderTopColor:o.color.separator,marginTop:20,paddingTop:8},footerLabel:{color:o.color.textSecondary,fontSize:11,lineHeight:16},links:{flexDirection:"row",gap:2},link:{paddingHorizontal:7,paddingVertical:10,borderRadius:6},linkText:{color:"#B5BBC0",fontSize:11,fontWeight:"500",lineHeight:16},pressed:{opacity:.7}});
@@ -1 +1 @@
1
- "use strict";export{FeatureGate,UpgradePrompt,useFeatureGate,ProFeatureBanner,UpgradeModal,ProBadge,ProUpgradeModal}from"./FeatureGate.js";export{BuoyUpgradeSheet,BuoySignInCard,BuoyNeedsPlanCard,BuoyGetProCard,useSignInState}from"./BuoyUpgradeSheet.js";export{FreeAccountPrompt,LOGIN_COMMAND}from"./FreeAccountPrompt.js";export{getUseIsPro,getUseLicense,getUseTier,signOutOfBuoy}from"./licenseModule.js";export{TIER_LIMITS,useLimit,resolveEffectiveTier}from"./tierLimits.js";
1
+ "use strict";export{FeatureGate,UpgradePrompt,useFeatureGate,ProFeatureBanner,UpgradeModal,ProBadge,ProUpgradeModal}from"./FeatureGate.js";export{BuoyUpgradeSheet,BuoySignInCard,BuoyNeedsPlanCard,BuoyGetProCard,useSignInState}from"./BuoyUpgradeSheet.js";export{FreeAccountPrompt,LOGIN_COMMAND}from"./FreeAccountPrompt.js";export{getUseIsPro,getUseLicense,getUseTier,signOutOfBuoy,restoreSignedOutKey}from"./licenseModule.js";export{TIER_LIMITS,useLimit,resolveEffectiveTier}from"./tierLimits.js";
@@ -1 +1 @@
1
- "use strict";import*as t from"@buoy-gg/license";import{canInitializeAccount as l}from"./accountRuntime";let o=null;let s=null;let i=null;let a=false;function n(){if(a)return;a=true;try{const e=t;if(e){o=e.useIsPro??null;s=e.useLicense??null;i=e.useTier??null}}catch{}}export function getUseIsPro(){n();return o??(()=>false)}export function getUseLicense(){n();return s}export function getUseTier(){n();return i??(()=>"free")}export function isProNow(){try{return t.isPro?.()??false}catch{return false}}const r={status:"locked",reason:"account_required",validUntil:null};function c(){if(!l())return null;try{const e=t.LicenseManager;void e?.initialize?.();return e}catch{return null}}export function getAccountAccess(){return c()?.getAccountAccess?.()??r}export function hasAccountAccess(){return getAccountAccess().status==="admitted"}export function assertAccountAccess(){if(!hasAccountAccess())throw new Error("A verified Buoy account is required. Run npx --package=@buoy-gg/core buoy login, then reload your app.")}export function subscribeAccountAccess(e){return c()?.subscribe?.(e)??(()=>{})}export function getUseAccountAccess(){try{return t.useAccountAccess??(()=>r)}catch{return()=>r}}export async function retryAccountAccess(){const e=c();const u=e?.getState?.().licenseKey;if(u)await e.setLicenseKey(u,{force:true});else await e?.initialize?.()}export function getSignInSession(){try{return t.SessionManager}catch{return void 0}}export async function signOutOfBuoy(){try{await t.SessionManager?.signOut()}catch{}}export function getSyncCredential(){try{return t.getSyncCredential?.()??null}catch{return null}}export function getTeamCredential(){try{return t.getTeamCredential?.()??null}catch{return null}}
1
+ "use strict";import*as t from"@buoy-gg/license";import{canInitializeAccount as l}from"./accountRuntime";let s=null;let i=null;let o=null;let a=false;function r(){if(a)return;a=true;try{const e=t;if(e){s=e.useIsPro??null;i=e.useLicense??null;o=e.useTier??null}}catch{}}export function getUseIsPro(){r();return s??(()=>false)}export function getUseLicense(){r();return i}export function getUseTier(){r();return o??(()=>"free")}export function isProNow(){try{return t.isPro?.()??false}catch{return false}}const c={status:"locked",reason:"account_required",validUntil:null};function n(){if(!l())return null;try{const e=t.LicenseManager;void e?.initialize?.();return e}catch{return null}}export function getAccountAccess(){return n()?.getAccountAccess?.()??c}export function hasAccountAccess(){return getAccountAccess().status==="admitted"}export function isLicensedNow(){try{const e=n();return e?.getState?.().isInitialized===true&&e.isPro?.()===true}catch{return false}}export function assertAccountAccess(){if(!hasAccountAccess())throw new Error("A verified Buoy account is required. Run npx --package=@buoy-gg/core buoy login, then reload your app.")}export function subscribeAccountAccess(e){return n()?.subscribe?.(e)??(()=>{})}export function getUseAccountAccess(){try{return t.useAccountAccess??(()=>c)}catch{return()=>c}}export async function retryAccountAccess(){const e=n();const u=e?.getState?.().licenseKey;if(u)await e.setLicenseKey(u,{force:true});else await e?.initialize?.()}export function getSignInSession(){try{return t.SessionManager}catch{return void 0}}export async function signOutOfBuoy(){try{const e=t.LicenseManager;if(e?.signOut)await e.signOut();else await t.SessionManager?.signOut()}catch{}}export async function restoreSignedOutKey(){try{const e=t.LicenseManager;return await e?.restoreSignedOutKey?.()??false}catch{return false}}export function getSyncCredential(){try{return t.getSyncCredential?.()??null}catch{return null}}export function getTeamCredential(){try{return t.getTeamCredential?.()??null}catch{return null}}
@@ -0,0 +1 @@
1
+ "use strict";import{realNow as u}from"../utils/realNow.js";import{getAccountAccess as d,hasAccountAccess as p,isLicensedNow as c}from"./licenseModule.js";export const SURFACE_WAIT_MS=15e3;const m=u();let o=0;let a=false;const n=new Set;export function isReleaseBuild(){return typeof __DEV__!=="undefined"&&!__DEV__}function s(){return typeof navigator!=="undefined"&&navigator.product==="ReactNative"}export function isWebRelease(){return isReleaseBuild()&&!s()}export function bootBeforeActions(e,t){if(!isReleaseBuild()||!s()||!e.actions)return;const r=e.actions;for(const i of Object.keys(r)){const f=r[i];r[i]=(...l)=>{t();return f(...l)}}}export function markSimulationSurface(){o+=1;a=true;n.forEach(t=>t());let e=false;return()=>{if(e)return;e=true;o-=1;n.forEach(t=>t())}}export function subscribeSimulationSurface(e){n.add(e);return()=>{n.delete(e)}}export function simulationSurfacePending(){if(!isReleaseBuild()||isWebRelease()||a)return false;if(u()-m>=SURFACE_WAIT_MS)return false;return d().status==="initializing"||c()}export function canSimulateInThisBuild(){if(!isReleaseBuild())return true;return c()&&o>0}export function canSimulateNow(){return p()&&canSimulateInThisBuild()}export const SIMULATION_RELEASE_HELP="A release build needs a paid Buoy plan and the Buoy menu on screen.";
@@ -1 +1 @@
1
- "use strict";import{getUseIsPro as n,getUseTier as i}from"./licenseModule.js";const o={"network.requests":{free:25,pro:Infinity},"network.saved":{free:5,pro:50},"network.overrideRules":{free:1,pro:50},"storage.events":{free:25,pro:Infinity},"storage.keys":{free:25,pro:Infinity},"storage.mmkvInstances":{free:1,pro:Infinity},"redux.actions":{free:25,pro:Infinity},"zustand.changes":{free:25,pro:Infinity},"jotai.changes":{free:25,pro:Infinity},"events.entries":{free:25,pro:Infinity},"highlightUpdates.components":{free:25,pro:Infinity},"highlightUpdates.historyEvents":{free:3,pro:Infinity},"highlightUpdates.detailEvents":{free:5,pro:Infinity},"routeEvents.entries":{free:3,pro:Infinity},"timeMachine.snapshots":{free:1,pro:Infinity},"perfMonitor.automationCases":{free:3,pro:Infinity},"scenarios.saved":{free:3,pro:Infinity},"scenarios.active":{free:1,pro:3}};export const TIER_LIMITS=o;export function resolveEffectiveTier(e,r){return r?"pro":e}export function useLimit(e){const r=n()();const t=i()();return TIER_LIMITS[e][resolveEffectiveTier(t,r)]}
1
+ "use strict";import{getUseIsPro as o,getUseTier as s}from"./licenseModule.js";const f={"network.requests":{free:25,pro:Infinity},"network.saved":{free:5,pro:50},"network.overrideRules":{free:1,pro:50},"storage.events":{free:25,pro:Infinity},"storage.keys":{free:25,pro:Infinity},"storage.mmkvInstances":{free:1,pro:Infinity},"redux.actions":{free:25,pro:Infinity},"zustand.changes":{free:25,pro:Infinity},"jotai.changes":{free:25,pro:Infinity},"events.entries":{free:25,pro:Infinity},"highlightUpdates.components":{free:25,pro:Infinity},"highlightUpdates.historyEvents":{free:3,pro:Infinity},"highlightUpdates.detailEvents":{free:5,pro:Infinity},"routeEvents.entries":{free:3,pro:Infinity},"timeMachine.snapshots":{free:1,pro:Infinity},"perfMonitor.automationCases":{free:3,pro:Infinity},"scenarios.saved":{free:3,pro:Infinity},"scenarios.active":{free:1,pro:3}};export const TIER_LIMITS=f;export function resolveEffectiveTier(e,r){return r?"pro":e}export function useLimit(e){const r=o();const t=r();const n=s();const i=n();return TIER_LIMITS[e][resolveEffectiveTier(i,t)]}
@@ -1 +1 @@
1
- "use strict";import{useEffect as _,useMemo as pt,useRef as V,useState as N,useContext as Xt,createContext as Yt,useCallback as W,Children as bt}from"react";import{Animated as z,Dimensions as dt,useWindowDimensions as Nt,View as H,Text as wt,TouchableOpacity as Wt}from"react-native";import{night as U}from"../night/nightTheme.js";import{DraggableHeader as St}from"../components/DraggableHeader.js";import{EnvironmentSelectorInline as zt}from"../../env/EnvironmentSelectorInline";import{GripVerticalIcon as Ht}from"../components/GripVerticalIcon.js";import{buoyColors as A}from"../gameUI/constants/gameUIColors.js";import{getSafeAreaInsets as vt,persistentStorage as it}from"../../utils/index.js";import{useSafeAreaInsets as Ut}from"../../hooks/index.js";import{calculateTargetPosition as Ft}from"./onboardingConstants";import{getUserStatusConfig as $t,filterValidChildren as jt,floatingToolsColors as It}from"@buoy-gg/floating-tools-core";import{jsx as R,jsxs as J}from"react/jsx-runtime";const st={BUBBLE_POSITION_X:"@react_buoy_bubble_position_x",BUBBLE_POSITION_Y:"@react_buoy_bubble_position_y"};const G=32;const d=20;const kt=150;const S=f=>f.__getValue();function Gt({animatedPosition:f,bubbleWidth:T=100,bubbleHeight:x=32,enabled:u=true,visibleHandleWidth:M=32,listenersSuspended:F=false,skipAutoSaveRef:E,defaultPlacement:at="top",bottomClearance:Q=0,onPositionLoaded:nt,storageKey:h}){const[B,$]=N(false);const y=V(void 0);const D=V(true);_(()=>{D.current=true;return()=>{D.current=false;if(y.current){clearTimeout(y.current);y.current=void 0}}},[]);const C=W(async(l,t)=>{if(!u)return;if(!D.current)return;const{width:o}=dt.get("window");if(o<=0||l<0||t<0)return;try{await Promise.all([it.setItem(h?`${h}:x`:st.BUBBLE_POSITION_X,l.toString()),it.setItem(h?`${h}:y`:st.BUBBLE_POSITION_Y,t.toString())])}catch(v){}},[u,h]);const Z=W((l,t)=>{if(!D.current)return;if(y.current)clearTimeout(y.current);y.current=setTimeout(()=>{if(D.current){C(l,t)}},500)},[C]);const K=W(async()=>{if(!u)return null;try{const[l,t]=await Promise.all([it.getItem(h?`${h}:x`:st.BUBBLE_POSITION_X),it.getItem(h?`${h}:y`:st.BUBBLE_POSITION_Y)]);if(l!==null&&t!==null){const o=parseFloat(l);const v=parseFloat(t);if(!Number.isNaN(o)&&!Number.isNaN(v)){return{x:o,y:v}}}}catch(l){}return null},[u,h]);const tt=W(l=>{const{width:t,height:o}=dt.get("window");const v=vt();if(t<=0||o<=0){return{...l,isValid:false}}const e=v.left;const X=t-M;const L=v.top+d;const P=o-x-v.bottom;const n={x:Math.max(e,Math.min(l.x,X)),y:Math.max(L,Math.min(l.y,P)),isValid:true};return n},[M,x]);_(()=>{if(!u||B)return;let l=false;const t=async()=>{const o=await K();if(l||!D.current)return;const{width:v,height:e}=dt.get("window");const X=vt();if(v<=0||e<=0){setTimeout(()=>{if(D.current&&!l){t()}},100);return}let L;let P=false;if(o){const n=tt(o);if(!n.isValid){setTimeout(()=>{if(D.current&&!l){t()}},100);return}const O=Math.abs(o.x-n.x)>5||Math.abs(o.y-n.y)>5;if(O){await C(n.x,n.y)}L={x:n.x,y:n.y};P=n.x>=v-M-5}else{const n=at==="bottom"?Math.max(X.top+d,e-x-X.bottom-d-Q):Math.max(X.top+d,Math.min(100,e-x-X.bottom));L={x:v-T-d,y:n}}if(l||!D.current)return;f.setValue(L);$(true);nt?.(L,P)};t();return()=>{l=true}},[u,B,f,K,tt,C,T,x,M,nt]);_(()=>{if(!u||!B||F)return;const l=f.addListener(t=>{if(E?.current)return;Z(t.x,t.y)});return()=>{f.removeListener(l);if(y.current){clearTimeout(y.current);y.current=void 0}}},[u,B,F,E,f,Z]);return{savePosition:C,isInitialized:B}}export function Divider(){const f={width:1,height:12,backgroundColor:A.textMuted+"66",flexShrink:0};return R(H,{style:f})}const Pt={success:"#20C997",warning:"#FFA94D",error:"#EF4444",muted:A.textMuted,secondary:A.textSecondary,info:"#20C997",primary:"#20C997",optional:A.textSecondary};function qt(f){return $t(f,Pt)}const Mt=Yt({isDragging:false});export function UserStatus({userRole:f,onPress:T}){const{isDragging:x}=Xt(Mt);const u=qt(f);const M={flexDirection:"row",alignItems:"center",paddingVertical:6,paddingHorizontal:8,flexShrink:0};const F={width:6,height:6,borderRadius:3,backgroundColor:u.dotColor,marginRight:4};const E={fontSize:10,fontWeight:"500",color:u.textColor,letterSpacing:.3};if(!T){return J(H,{style:M,accessibilityLabel:`User status: ${u.label}`,children:[R(H,{style:F}),R(wt,{style:E,children:u.label})]})}return J(Wt,{accessibilityRole:"button",accessibilityLabel:"Open Dev Tools Menu",testID:"open-dev-tools-button",onPress:T,hitSlop:{top:10,bottom:10,left:0,right:10},disabled:x,activeOpacity:.85,style:M,children:[R(H,{style:F}),R(wt,{style:E,children:u.label})]})}function Jt(f){const T=jt(f);const x=[];T.forEach((u,M)=>{x.push(u);if(M<T.length-1)x.push(R(Divider,{},`divider-${M}`))});return x}export function FloatingTool({id:f,suspendPointerEvents:T=false,revealToken:x,variant:u="bubble",dragFromSurface:M=false,accessibilityLabel:F="Move dev tools bubble",minimizedStack:E,hasMinimizedStack:at=false,accessory:Q,handleAdornment:nt,enablePositionPersistence:h=true,defaultPlacement:B="top",bottomClearance:$=0,pushToSide:y=false,centerOnboarding:D=false,children:C,environment:Z,availableEnvironments:K,onEnvironmentSwitch:tt,showEnvironmentSelector:l=false}){const t=V(new z.ValueXY).current;const[o,v]=N(false);const[e,X]=N({width:100,height:32});const[L,P]=N(false);const[n,O]=N(false);const[ft,Dt]=N(0);const[Rt,Bt]=N(false);const g=V(null);const Y=V(false);const et=V(false);const ht=V(y);const rt=V(null);const[q,_t]=N(false);const c=Ut();const{width:a,height:p}=Nt();const Tt=W((i,r)=>{if(r){O(true)}},[]);const{savePosition:b,isInitialized:I}=Gt({animatedPosition:t,bubbleWidth:e.width,bubbleHeight:e.height,enabled:h,visibleHandleWidth:G,listenersSuspended:o,skipAutoSaveRef:Y,defaultPlacement:B,bottomClearance:$,onPositionLoaded:Tt,storageKey:f?`@buoy/floating-tool/${f}`:void 0});_(()=>{if(h&&!I)return;if(!ht.current&&y){et.current=false}ht.current=y;if(y&&!n&&!o&&!et.current){const i=S(t.x);const r=S(t.y);g.current={x:i,y:r};const s=a-G;Y.current=true;O(true);z.timing(t,{toValue:{x:s,y:r},duration:200,useNativeDriver:false}).start()}else if(!y&&n&&Y.current){if(g.current){const{x:i,y:r}=g.current;Y.current=false;et.current=false;O(false);z.timing(t,{toValue:{x:i,y:r},duration:200,useNativeDriver:false}).start(()=>{b(i,r)})}}},[h,I,y,n,o,a,t,b]);_(()=>{if(!I||q)return;const i=setTimeout(()=>{rt.current=e.width;_t(true);if(!n&&!o){const r=S(t.x);const s=a-e.width-d;if(r>s){const m=Math.max(c.left,s);const w=S(t.y);t.setValue({x:m,y:w});b(m,w)}}},kt);return()=>clearTimeout(i)},[I,q,e.width]);_(()=>{if(!I||!q||n||o)return;const i=S(t.y);const r=p-e.height-c.bottom-d-(B==="bottom"?$:0);if(i<=r)return;const s=S(t.x);const m=Math.max(c.top+d,r);t.setValue({x:s,y:m});b(s,m)},[I,q,n,o,e.height,p,c.top,c.bottom,$,B]);_(()=>{if(!I)return;if(!q)return;if(rt.current===null)return;if(o){rt.current=e.width;return}const i=rt.current;const r=e.width;const s=r-i;if(Math.abs(s)<2){return}rt.current=r;if(n){if(g.current){const ot=g.current.x-s;g.current.x=Math.max(c.left,Math.min(ot,a-r-d))}return}const m=S(t.x);const w=S(t.y);const j=m-s;const k=Math.max(c.left,Math.min(j,a-G));if(Math.abs(k-m)>1){z.timing(t,{toValue:{x:k,y:w},duration:150,useNativeDriver:false}).start(()=>{b(k,w);if(g.current){g.current.x=k}})}},[e.width,I,q,o,n,t,a,c.left,b]);_(()=>{if(!h){if(D){const i=Ft();const r=(a-e.width)/2;const s=p-e.height-i;t.setValue({x:r,y:s})}else{const i=B==="bottom"?Math.max(c.top+d,p-e.height-c.bottom-d-$):Math.max(c.top+d,Math.min(100,p-e.height-c.bottom));t.setValue({x:a-e.width-d,y:i})}}},[h,D,t,e.width,e.height,c.top,c.bottom,a,p]);const ct=W(()=>{const i=S(t.x);const r=S(t.y);const s=i>a-e.width/2;if(n||s){let m;let w;if(g.current&&g.current.x<a-e.width/2){m=g.current.x;w=g.current.y}else{m=a-e.width-d;w=r}Y.current=false;et.current=true;O(false);z.timing(t,{toValue:{x:m,y:w},duration:200,useNativeDriver:false}).start(()=>{b(m,w)})}else{g.current={x:i,y:r};et.current=false;const m=a-G;O(true);z.timing(t,{toValue:{x:m,y:r},duration:200,useNativeDriver:false}).start(()=>{b(m,r)})}},[t,n,e.width,b,a]);const mt=W(()=>{v(true)},[]);const gt=W(i=>{let{x:r,y:s}=i;const m=r+e.width/2;const w=m>a;if(w){const j=a-G;O(true);if(g.current){g.current.y=s}else{g.current={x:a-e.width-d,y:s}}z.timing(t,{toValue:{x:j,y:s},duration:200,useNativeDriver:false}).start(()=>{b(j,s)})}else{if(n&&r<a-G-10){O(false);Y.current=false}if(r<a-e.width/2){g.current={x:r,y:s}}b(r,s)}v(false)},[t,e.width,n,b,a]);const ut=V({width:a,height:p});_(()=>{if(h&&!I)return;if(ut.current.width===a&&ut.current.height===p)return;ut.current={width:a,height:p};const i=s=>({x:Math.max(c.left,Math.min(s.x,a-e.width-d)),y:Math.max(c.top+d,Math.min(s.y,p-e.height-c.bottom))});const r=i({x:S(t.x),y:S(t.y)});if(n)r.x=a-G;if(g.current)g.current=i(g.current);t.stopAnimation();t.setValue(r);if(Y.current)return;void b(r.x,r.y)},[a,p,I,h,e,c,n,t,b]);const xt=Boolean(Q);_(()=>{if(!xt)return;const i=({y:s})=>Bt(s+e.height+ft>p-c.bottom);i({y:S(t.y)});const r=t.addListener(i);return()=>t.removeListener(r)},[t,e.height,ft,p,c.bottom,xt]);const Lt=pt(()=>({position:"absolute",zIndex:1001,opacity:L?1:0,transform:t.getTranslateTransform()}),[t,L]);const yt=V(void 0);_(()=>{if(h&&!I)return;if(yt.current===x)return;yt.current=x;if(x!==void 0&&x>0&&n)ct()},[x,I,h,n,ct]);const lt=at;const Vt={flexDirection:"row",alignItems:"center",backgroundColor:A.card,borderTopLeftRadius:lt?0:6,borderTopRightRadius:6,borderBottomLeftRadius:6,borderBottomRightRadius:6,borderLeftWidth:o?2:1,borderRightWidth:o?2:1,borderBottomWidth:o?2:1,borderTopWidth:o?2:lt?0:1,borderColor:o?It.dragActive:A.textMuted+"66",overflow:"visible",elevation:8,shadowColor:o?It.dragActive+"99":"#000",shadowOffset:{width:0,height:o?6:4},shadowOpacity:o?.6:.3,shadowRadius:o?12:8,...u==="strip"?{borderRadius:U.radius.card,borderTopLeftRadius:U.radius.card,borderTopRightRadius:U.radius.card,borderBottomLeftRadius:U.radius.card,borderBottomRightRadius:U.radius.card,minHeight:48,backgroundColor:U.color.surface,borderColor:o?U.color.accentBorderStrong:U.color.separator,shadowOpacity:.24,shadowRadius:16}:{}};const Ct={paddingHorizontal:6,paddingVertical:6,backgroundColor:A.textMuted+"1A",alignItems:"center",justifyContent:"center",width:32,...u==="strip"?{minHeight:48}:{},borderRightWidth:1,borderRightColor:A.textMuted+"66",borderTopLeftRadius:lt?0:void 0,...u==="strip"?{backgroundColor:"transparent",borderRightWidth:0}:{}};const Ot={flexDirection:"row",alignItems:"center",gap:6,paddingRight:8};const At=pt(()=>u==="strip"?bt.toArray(C):Jt(bt.toArray(C)),[C,u]);const Et=32;if(h&&!I){return null}return R(z.View,{pointerEvents:T?"none":"box-none",testID:f??"buoy-floating-tool",style:Lt,children:J(H,{style:{overflow:"visible"},children:[E&&R(H,{style:{position:"absolute",bottom:"100%",left:0,width:Et,overflow:"visible",zIndex:1001},children:E}),J(St,{position:t,enabled:M,claimOnMove:false,onDragStart:mt,onDragEnd:gt,containerBounds:{width:a,height:p},elementSize:e,minPosition:{x:c.left,y:c.top+d},maxOverflowX:e.width,hitSlop:{top:10,bottom:10,left:10,right:10},style:Vt,onLayout:i=>{const{width:r,height:s}=i.nativeEvent.layout;X({width:r,height:s});if(L)return;P(true);if(n||o||Y.current)return;const m=S(t.x);const w=S(t.y);const j=a-r-d;const k=p-s-c.bottom-d-(B==="bottom"?$:0);if(m<=j&&w<=k)return;const ot={x:Math.max(c.left,Math.min(m,j)),y:Math.max(c.top+d,Math.min(w,k))};t.setValue(ot);b(ot.x,ot.y)},children:[J(St,{position:t,testID:f?`${f}-grip`:"buoy-floating-grip",accessibilityLabel:F,onDragStart:mt,onDragEnd:gt,onTap:ct,containerBounds:{width:a,height:p},elementSize:e,minPosition:{x:c.left,y:c.top+d},style:Ct,enabled:true,maxOverflowX:e.width,children:[R(Ht,{size:u==="strip"?20:12,color:A.textSecondary+"CC"}),nt]}),R(Mt.Provider,{value:{isDragging:o},children:J(H,{style:Ot,children:[l&&Z&&K&&tt&&R(zt,{currentEnvironment:Z,availableEnvironments:K,onSelect:tt}),At]})})]}),!n&&Q&&R(H,{onLayout:i=>Dt(i.nativeEvent.layout.height),style:{position:"absolute",...Rt?{bottom:"100%"}:{top:"100%"},left:0,width:"100%",zIndex:1002},children:Q})]})})}export function getBubbleAnchorPosition(){return null}
1
+ "use strict";import{useEffect as _,useMemo as pt,useRef as V,useState as N,useContext as Xt,createContext as Yt,useCallback as W,Children as bt}from"react";import{Animated as z,Dimensions as dt,useWindowDimensions as Nt,View as H,Text as wt,TouchableOpacity as Wt}from"react-native";import{night as U}from"../night/nightTheme.js";import{DraggableHeader as St}from"../components/DraggableHeader.js";import{EnvironmentSelectorInline as zt}from"../../env/EnvironmentSelectorInline";import{GripVerticalIcon as Ht}from"../components/GripVerticalIcon.js";import{buoyColors as A}from"../gameUI/constants/gameUIColors.js";import{getSafeAreaInsets as vt,persistentStorage as it}from"../../utils/index.js";import{useSafeAreaInsets as Ut}from"../../hooks/index.js";import{calculateTargetPosition as $t}from"./onboardingConstants";import{getUserStatusConfig as Ft,filterValidChildren as jt,floatingToolsColors as It}from"@buoy-gg/floating-tools-core";import{jsx as R,jsxs as J}from"react/jsx-runtime";const st={BUBBLE_POSITION_X:"@react_buoy_bubble_position_x",BUBBLE_POSITION_Y:"@react_buoy_bubble_position_y"};const G=32;const d=20;const kt=150;const S=f=>f.__getValue();function Gt({animatedPosition:f,bubbleWidth:T=100,bubbleHeight:x=32,enabled:u=true,visibleHandleWidth:M=32,listenersSuspended:$=false,skipAutoSaveRef:E,defaultPlacement:at="top",bottomClearance:Q=0,onPositionLoaded:nt,storageKey:h}){const[B,F]=N(false);const y=V(void 0);const D=V(true);_(()=>{D.current=true;return()=>{D.current=false;if(y.current){clearTimeout(y.current);y.current=void 0}}},[]);const C=W(async(l,t)=>{if(!u)return;if(!D.current)return;const{width:o}=dt.get("window");if(o<=0||l<0||t<0)return;try{await Promise.all([it.setItem(h?`${h}:x`:st.BUBBLE_POSITION_X,l.toString()),it.setItem(h?`${h}:y`:st.BUBBLE_POSITION_Y,t.toString())])}catch(v){}},[u,h]);const Z=W((l,t)=>{if(!D.current)return;if(y.current)clearTimeout(y.current);y.current=setTimeout(()=>{if(D.current){C(l,t)}},500)},[C]);const K=W(async()=>{if(!u)return null;try{const[l,t]=await Promise.all([it.getItem(h?`${h}:x`:st.BUBBLE_POSITION_X),it.getItem(h?`${h}:y`:st.BUBBLE_POSITION_Y)]);if(l!==null&&t!==null){const o=parseFloat(l);const v=parseFloat(t);if(!Number.isNaN(o)&&!Number.isNaN(v)){return{x:o,y:v}}}}catch(l){}return null},[u,h]);const tt=W(l=>{const{width:t,height:o}=dt.get("window");const v=vt();if(t<=0||o<=0){return{...l,isValid:false}}const e=v.left;const X=t-M;const L=v.top+d;const P=o-x-v.bottom;const n={x:Math.max(e,Math.min(l.x,X)),y:Math.max(L,Math.min(l.y,P)),isValid:true};return n},[M,x]);_(()=>{if(!u||B)return;let l=false;const t=async()=>{const o=await K();if(l||!D.current)return;const{width:v,height:e}=dt.get("window");const X=vt();if(v<=0||e<=0){setTimeout(()=>{if(D.current&&!l){t()}},100);return}let L;let P=false;if(o){const n=tt(o);if(!n.isValid){setTimeout(()=>{if(D.current&&!l){t()}},100);return}const O=Math.abs(o.x-n.x)>5||Math.abs(o.y-n.y)>5;if(O){await C(n.x,n.y)}L={x:n.x,y:n.y};P=n.x>=v-M-5}else{const n=at==="bottom"?Math.max(X.top+d,e-x-X.bottom-d-Q):Math.max(X.top+d,Math.min(100,e-x-X.bottom));L={x:v-T-d,y:n}}if(l||!D.current)return;f.setValue(L);F(true);nt?.(L,P)};t();return()=>{l=true}},[u,B,f,K,tt,C,T,x,M,nt]);_(()=>{if(!u||!B||$)return;const l=f.addListener(t=>{if(E?.current)return;Z(t.x,t.y)});return()=>{f.removeListener(l);if(y.current){clearTimeout(y.current);y.current=void 0}}},[u,B,$,E,f,Z]);return{savePosition:C,isInitialized:B}}export function Divider(){const f={width:1,height:12,backgroundColor:A.textMuted+"66",flexShrink:0};return R(H,{style:f})}const Pt={success:"#20C997",warning:"#FFA94D",error:"#EF4444",muted:A.textMuted,secondary:A.textSecondary,info:"#20C997",primary:"#20C997",optional:A.textSecondary};function qt(f){return Ft(f,Pt)}const Mt=Yt({isDragging:false});export function UserStatus({userRole:f,onPress:T}){const{isDragging:x}=Xt(Mt);const u=qt(f);const M={flexDirection:"row",alignItems:"center",paddingVertical:6,paddingHorizontal:8,flexShrink:0};const $={width:6,height:6,borderRadius:3,backgroundColor:u.dotColor,marginRight:4};const E={fontSize:10,fontWeight:"500",color:u.textColor,letterSpacing:.3};if(!T){return J(H,{style:M,accessibilityLabel:`User status: ${u.label}`,children:[R(H,{style:$}),R(wt,{style:E,children:u.label})]})}return J(Wt,{accessibilityRole:"button",accessibilityLabel:`${u.label}, Open Dev Tools Menu`,testID:"open-dev-tools-button",onPress:T,hitSlop:{top:10,bottom:10,left:0,right:10},disabled:x,activeOpacity:.85,style:M,children:[R(H,{style:$}),R(wt,{style:E,children:u.label})]})}function Jt(f){const T=jt(f);const x=[];T.forEach((u,M)=>{x.push(u);if(M<T.length-1)x.push(R(Divider,{},`divider-${M}`))});return x}export function FloatingTool({id:f,suspendPointerEvents:T=false,revealToken:x,variant:u="bubble",dragFromSurface:M=false,accessibilityLabel:$="Move dev tools bubble",minimizedStack:E,hasMinimizedStack:at=false,accessory:Q,handleAdornment:nt,enablePositionPersistence:h=true,defaultPlacement:B="top",bottomClearance:F=0,pushToSide:y=false,centerOnboarding:D=false,children:C,environment:Z,availableEnvironments:K,onEnvironmentSwitch:tt,showEnvironmentSelector:l=false}){const t=V(new z.ValueXY).current;const[o,v]=N(false);const[e,X]=N({width:100,height:32});const[L,P]=N(false);const[n,O]=N(false);const[ft,Dt]=N(0);const[Rt,Bt]=N(false);const g=V(null);const Y=V(false);const et=V(false);const ht=V(y);const rt=V(null);const[q,_t]=N(false);const c=Ut();const{width:a,height:p}=Nt();const Tt=W((i,r)=>{if(r){O(true)}},[]);const{savePosition:b,isInitialized:I}=Gt({animatedPosition:t,bubbleWidth:e.width,bubbleHeight:e.height,enabled:h,visibleHandleWidth:G,listenersSuspended:o,skipAutoSaveRef:Y,defaultPlacement:B,bottomClearance:F,onPositionLoaded:Tt,storageKey:f?`@buoy/floating-tool/${f}`:void 0});_(()=>{if(h&&!I)return;if(!ht.current&&y){et.current=false}ht.current=y;if(y&&!n&&!o&&!et.current){const i=S(t.x);const r=S(t.y);g.current={x:i,y:r};const s=a-G;Y.current=true;O(true);z.timing(t,{toValue:{x:s,y:r},duration:200,useNativeDriver:false}).start()}else if(!y&&n&&Y.current){if(g.current){const{x:i,y:r}=g.current;Y.current=false;et.current=false;O(false);z.timing(t,{toValue:{x:i,y:r},duration:200,useNativeDriver:false}).start(()=>{b(i,r)})}}},[h,I,y,n,o,a,t,b]);_(()=>{if(!I||q)return;const i=setTimeout(()=>{rt.current=e.width;_t(true);if(!n&&!o){const r=S(t.x);const s=a-e.width-d;if(r>s){const m=Math.max(c.left,s);const w=S(t.y);t.setValue({x:m,y:w});b(m,w)}}},kt);return()=>clearTimeout(i)},[I,q,e.width]);_(()=>{if(!I||!q||n||o)return;const i=S(t.y);const r=p-e.height-c.bottom-d-(B==="bottom"?F:0);if(i<=r)return;const s=S(t.x);const m=Math.max(c.top+d,r);t.setValue({x:s,y:m});b(s,m)},[I,q,n,o,e.height,p,c.top,c.bottom,F,B]);_(()=>{if(!I)return;if(!q)return;if(rt.current===null)return;if(o){rt.current=e.width;return}const i=rt.current;const r=e.width;const s=r-i;if(Math.abs(s)<2){return}rt.current=r;if(n){if(g.current){const ot=g.current.x-s;g.current.x=Math.max(c.left,Math.min(ot,a-r-d))}return}const m=S(t.x);const w=S(t.y);const j=m-s;const k=Math.max(c.left,Math.min(j,a-G));if(Math.abs(k-m)>1){z.timing(t,{toValue:{x:k,y:w},duration:150,useNativeDriver:false}).start(()=>{b(k,w);if(g.current){g.current.x=k}})}},[e.width,I,q,o,n,t,a,c.left,b]);_(()=>{if(!h){if(D){const i=$t();const r=(a-e.width)/2;const s=p-e.height-i;t.setValue({x:r,y:s})}else{const i=B==="bottom"?Math.max(c.top+d,p-e.height-c.bottom-d-F):Math.max(c.top+d,Math.min(100,p-e.height-c.bottom));t.setValue({x:a-e.width-d,y:i})}}},[h,D,t,e.width,e.height,c.top,c.bottom,a,p]);const ct=W(()=>{const i=S(t.x);const r=S(t.y);const s=i>a-e.width/2;if(n||s){let m;let w;if(g.current&&g.current.x<a-e.width/2){m=g.current.x;w=g.current.y}else{m=a-e.width-d;w=r}Y.current=false;et.current=true;O(false);z.timing(t,{toValue:{x:m,y:w},duration:200,useNativeDriver:false}).start(()=>{b(m,w)})}else{g.current={x:i,y:r};et.current=false;const m=a-G;O(true);z.timing(t,{toValue:{x:m,y:r},duration:200,useNativeDriver:false}).start(()=>{b(m,r)})}},[t,n,e.width,b,a]);const mt=W(()=>{v(true)},[]);const gt=W(i=>{let{x:r,y:s}=i;const m=r+e.width/2;const w=m>a;if(w){const j=a-G;O(true);if(g.current){g.current.y=s}else{g.current={x:a-e.width-d,y:s}}z.timing(t,{toValue:{x:j,y:s},duration:200,useNativeDriver:false}).start(()=>{b(j,s)})}else{if(n&&r<a-G-10){O(false);Y.current=false}if(r<a-e.width/2){g.current={x:r,y:s}}b(r,s)}v(false)},[t,e.width,n,b,a]);const ut=V({width:a,height:p});_(()=>{if(h&&!I)return;if(ut.current.width===a&&ut.current.height===p)return;ut.current={width:a,height:p};const i=s=>({x:Math.max(c.left,Math.min(s.x,a-e.width-d)),y:Math.max(c.top+d,Math.min(s.y,p-e.height-c.bottom))});const r=i({x:S(t.x),y:S(t.y)});if(n)r.x=a-G;if(g.current)g.current=i(g.current);t.stopAnimation();t.setValue(r);if(Y.current)return;void b(r.x,r.y)},[a,p,I,h,e,c,n,t,b]);const xt=Boolean(Q);_(()=>{if(!xt)return;const i=({y:s})=>Bt(s+e.height+ft>p-c.bottom);i({y:S(t.y)});const r=t.addListener(i);return()=>t.removeListener(r)},[t,e.height,ft,p,c.bottom,xt]);const Lt=pt(()=>({position:"absolute",zIndex:1001,opacity:L?1:0,transform:t.getTranslateTransform()}),[t,L]);const yt=V(void 0);_(()=>{if(h&&!I)return;if(yt.current===x)return;yt.current=x;if(x!==void 0&&x>0&&n)ct()},[x,I,h,n,ct]);const lt=at;const Vt={flexDirection:"row",alignItems:"center",backgroundColor:A.card,borderTopLeftRadius:lt?0:6,borderTopRightRadius:6,borderBottomLeftRadius:6,borderBottomRightRadius:6,borderLeftWidth:o?2:1,borderRightWidth:o?2:1,borderBottomWidth:o?2:1,borderTopWidth:o?2:lt?0:1,borderColor:o?It.dragActive:A.textMuted+"66",overflow:"visible",elevation:8,shadowColor:o?It.dragActive+"99":"#000",shadowOffset:{width:0,height:o?6:4},shadowOpacity:o?.6:.3,shadowRadius:o?12:8,...u==="strip"?{borderRadius:U.radius.card,borderTopLeftRadius:U.radius.card,borderTopRightRadius:U.radius.card,borderBottomLeftRadius:U.radius.card,borderBottomRightRadius:U.radius.card,minHeight:48,backgroundColor:U.color.surface,borderColor:o?U.color.accentBorderStrong:U.color.separator,shadowOpacity:.24,shadowRadius:16}:{}};const Ct={paddingHorizontal:6,paddingVertical:6,backgroundColor:A.textMuted+"1A",alignItems:"center",justifyContent:"center",width:32,...u==="strip"?{minHeight:48}:{},borderRightWidth:1,borderRightColor:A.textMuted+"66",borderTopLeftRadius:lt?0:void 0,...u==="strip"?{backgroundColor:"transparent",borderRightWidth:0}:{}};const Ot={flexDirection:"row",alignItems:"center",gap:6,paddingRight:8};const At=pt(()=>u==="strip"?bt.toArray(C):Jt(bt.toArray(C)),[C,u]);const Et=32;if(h&&!I){return null}return R(z.View,{pointerEvents:T?"none":"box-none",testID:f??"buoy-floating-tool",style:Lt,children:J(H,{style:{overflow:"visible"},children:[E&&R(H,{style:{position:"absolute",bottom:"100%",left:0,width:Et,overflow:"visible",zIndex:1001},children:E}),J(St,{position:t,enabled:M,claimOnMove:false,onDragStart:mt,onDragEnd:gt,containerBounds:{width:a,height:p},elementSize:e,minPosition:{x:c.left,y:c.top+d},maxOverflowX:e.width,hitSlop:{top:10,bottom:10,left:10,right:10},style:Vt,onLayout:i=>{const{width:r,height:s}=i.nativeEvent.layout;X({width:r,height:s});if(L)return;P(true);if(n||o||Y.current)return;const m=S(t.x);const w=S(t.y);const j=a-r-d;const k=p-s-c.bottom-d-(B==="bottom"?F:0);if(m<=j&&w<=k)return;const ot={x:Math.max(c.left,Math.min(m,j)),y:Math.max(c.top+d,Math.min(w,k))};t.setValue(ot);b(ot.x,ot.y)},children:[J(St,{position:t,testID:f?`${f}-grip`:"buoy-floating-grip",accessibilityLabel:$,onDragStart:mt,onDragEnd:gt,onTap:ct,containerBounds:{width:a,height:p},elementSize:e,minPosition:{x:c.left,y:c.top+d},style:Ct,enabled:true,maxOverflowX:e.width,children:[R(Ht,{size:u==="strip"?20:12,color:A.textSecondary+"CC"}),nt]}),R(Mt.Provider,{value:{isDragging:o},children:J(H,{style:Ot,children:[l&&Z&&K&&tt&&R(zt,{currentEnvironment:Z,availableEnvironments:K,onSelect:tt}),At]})})]}),!n&&Q&&R(H,{onLayout:i=>Dt(i.nativeEvent.layout.height),style:{position:"absolute",...Rt?{bottom:"100%"}:{top:"100%"},left:0,width:"100%",zIndex:1002},children:Q})]})})}export function getBubbleAnchorPosition(){return null}