@buoy-gg/bug-links 0.0.0-stage → 7.0.81

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 (100) hide show
  1. package/BuoyBugLinks.podspec +18 -0
  2. package/LICENSE +58 -0
  3. package/README.md +25 -2
  4. package/android/build.gradle +31 -0
  5. package/android/consumer-rules.pro +8 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/gg/buoy/buglinks/frames/BuoyFramesModule.kt +53 -0
  8. package/android/src/main/java/gg/buoy/buglinks/frames/BuoyFramesPackage.kt +11 -0
  9. package/android/src/main/java/gg/buoy/buglinks/frames/FrameEngine.kt +707 -0
  10. package/android/src/main/java/gg/buoy/buglinks/frames/FrameWalker.kt +181 -0
  11. package/ios/BuoyFrames.m +17 -0
  12. package/ios/BuoyFrames.swift +640 -0
  13. package/ios/BuoyFramesWalk.swift +213 -0
  14. package/lib/commonjs/components/BugLinksBody.js +1 -0
  15. package/lib/commonjs/components/TeamBugs.js +1 -0
  16. package/lib/commonjs/components/focus.js +1 -0
  17. package/lib/commonjs/components/overlays.js +1 -0
  18. package/lib/commonjs/components/topBanners.js +1 -0
  19. package/lib/commonjs/engine/client.js +1 -0
  20. package/lib/commonjs/engine/credential.js +1 -0
  21. package/lib/commonjs/engine/linksStore.js +1 -0
  22. package/lib/commonjs/engine/loader.js +1 -0
  23. package/lib/commonjs/engine/opener.js +1 -0
  24. package/lib/commonjs/engine/otherTabs.js +1 -0
  25. package/lib/commonjs/engine/phoneCheck.js +1 -0
  26. package/lib/commonjs/engine/phoneCrypto.js +1 -0
  27. package/lib/commonjs/engine/randomBytes.js +1 -0
  28. package/lib/commonjs/engine/reporter.js +1 -0
  29. package/lib/commonjs/engine/sandbox.js +1 -0
  30. package/lib/commonjs/engine/settings.js +1 -0
  31. package/lib/commonjs/engine/tabStorage.js +1 -0
  32. package/lib/commonjs/engine/teamKeys.js +1 -0
  33. package/lib/commonjs/engine/teamList.js +1 -0
  34. package/lib/commonjs/index.js +1 -0
  35. package/lib/commonjs/media/BuoyMask.js +1 -0
  36. package/lib/commonjs/media/frames.js +1 -0
  37. package/lib/commonjs/media/nativeFrames.js +1 -0
  38. package/lib/commonjs/media/nativeFrames.web.js +1 -0
  39. package/lib/commonjs/media/webFrames.js +14 -0
  40. package/lib/commonjs/package.json +1 -0
  41. package/lib/commonjs/preset.js +1 -0
  42. package/lib/commonjs/sync/bugLinksSyncAdapter.js +1 -0
  43. package/lib/module/components/BugLinksBody.js +1 -0
  44. package/lib/module/components/TeamBugs.js +1 -0
  45. package/lib/module/components/focus.js +1 -0
  46. package/lib/module/components/overlays.js +1 -0
  47. package/lib/module/components/topBanners.js +1 -0
  48. package/lib/module/engine/client.js +1 -0
  49. package/lib/module/engine/credential.js +1 -0
  50. package/lib/module/engine/linksStore.js +1 -0
  51. package/lib/module/engine/loader.js +1 -0
  52. package/lib/module/engine/opener.js +1 -0
  53. package/lib/module/engine/otherTabs.js +1 -0
  54. package/lib/module/engine/phoneCheck.js +1 -0
  55. package/lib/module/engine/phoneCrypto.js +1 -0
  56. package/lib/module/engine/randomBytes.js +1 -0
  57. package/lib/module/engine/reporter.js +1 -0
  58. package/lib/module/engine/sandbox.js +1 -0
  59. package/lib/module/engine/settings.js +1 -0
  60. package/lib/module/engine/tabStorage.js +1 -0
  61. package/lib/module/engine/teamKeys.js +1 -0
  62. package/lib/module/engine/teamList.js +1 -0
  63. package/lib/module/index.js +1 -0
  64. package/lib/module/media/BuoyMask.js +1 -0
  65. package/lib/module/media/frames.js +1 -0
  66. package/lib/module/media/nativeFrames.js +1 -0
  67. package/lib/module/media/nativeFrames.web.js +1 -0
  68. package/lib/module/media/webFrames.js +14 -0
  69. package/lib/module/preset.js +1 -0
  70. package/lib/module/sync/bugLinksSyncAdapter.js +1 -0
  71. package/lib/typescript/components/BugLinksBody.d.ts +2 -0
  72. package/lib/typescript/components/TeamBugs.d.ts +8 -0
  73. package/lib/typescript/components/focus.d.ts +6 -0
  74. package/lib/typescript/components/overlays.d.ts +10 -0
  75. package/lib/typescript/components/topBanners.d.ts +35 -0
  76. package/lib/typescript/engine/client.d.ts +78 -0
  77. package/lib/typescript/engine/credential.d.ts +11 -0
  78. package/lib/typescript/engine/linksStore.d.ts +132 -0
  79. package/lib/typescript/engine/loader.d.ts +172 -0
  80. package/lib/typescript/engine/opener.d.ts +21 -0
  81. package/lib/typescript/engine/otherTabs.d.ts +52 -0
  82. package/lib/typescript/engine/phoneCheck.d.ts +8 -0
  83. package/lib/typescript/engine/phoneCrypto.d.ts +16 -0
  84. package/lib/typescript/engine/randomBytes.d.ts +7 -0
  85. package/lib/typescript/engine/reporter.d.ts +53 -0
  86. package/lib/typescript/engine/sandbox.d.ts +83 -0
  87. package/lib/typescript/engine/settings.d.ts +42 -0
  88. package/lib/typescript/engine/tabStorage.d.ts +6 -0
  89. package/lib/typescript/engine/teamKeys.d.ts +37 -0
  90. package/lib/typescript/engine/teamList.d.ts +63 -0
  91. package/lib/typescript/index.d.ts +23 -0
  92. package/lib/typescript/media/BuoyMask.d.ts +19 -0
  93. package/lib/typescript/media/frames.d.ts +34 -0
  94. package/lib/typescript/media/nativeFrames.d.ts +2 -0
  95. package/lib/typescript/media/nativeFrames.web.d.ts +2 -0
  96. package/lib/typescript/media/webFrames.d.ts +178 -0
  97. package/lib/typescript/preset.d.ts +50 -0
  98. package/lib/typescript/sync/bugLinksSyncAdapter.d.ts +41 -0
  99. package/lib/web/index.mjs +20 -0
  100. package/package.json +119 -3
@@ -0,0 +1,50 @@
1
+ import { BugLinksBody } from "./components/BugLinksBody";
2
+ export declare const BUG_LINKS_COLOR = "#F43F5E";
3
+ declare function Nothing(): null;
4
+ export declare const reportBugToolPreset: {
5
+ id: string;
6
+ name: string;
7
+ description: string;
8
+ slot: "both";
9
+ color: string;
10
+ icon: ({ size, color }: {
11
+ size: number;
12
+ color?: string;
13
+ }) => import("react").JSX.Element;
14
+ component: typeof Nothing;
15
+ launchMode: "toggle-only";
16
+ onPress: (actions?: Record<string, (...args: unknown[]) => void>) => void;
17
+ };
18
+ export declare const bugLinksToolPreset: {
19
+ id: string;
20
+ name: string;
21
+ description: string;
22
+ slot: "both";
23
+ color: string;
24
+ icon: ({ size, color }: {
25
+ size: number;
26
+ color?: string;
27
+ }) => import("react").JSX.Element;
28
+ component: typeof BugLinksBody;
29
+ modal: {
30
+ subtitle: string;
31
+ };
32
+ };
33
+ /** Create a custom Bug links tool configuration. */
34
+ export declare const createBugLinksTool: (options?: (Record<never, never> & import("@buoy-gg/shared-ui").ToolPresetOverrides) | undefined) => {
35
+ id: string;
36
+ name: string;
37
+ description: string;
38
+ slot: "both";
39
+ color: string;
40
+ icon: ({ size, color }: {
41
+ size: number;
42
+ color?: string;
43
+ }) => import("react").JSX.Element;
44
+ component: typeof BugLinksBody;
45
+ modal: {
46
+ subtitle: string;
47
+ };
48
+ };
49
+ export {};
50
+ //# sourceMappingURL=preset.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * bugLinksSyncAdapter: bug links over external-sync.
3
+ *
4
+ * One adapter serves the tool's own screen, Buoy Desktop and the MCP server
5
+ * (`create_bug_case`, `load_bug_case`), so every surface does the same thing.
6
+ * Core's auto-discovery picks it up by export name as the "bug-links" tool.
7
+ *
8
+ * `load` takes either a link (the phone fetches and opens it) or an opened
9
+ * case (the Mac fetched and opened it, then hands it over the local broker).
10
+ * Either way the case is checked here, on the phone, before anything loads.
11
+ */
12
+ import { type ToolSyncAdapter } from "@buoy-gg/shared-ui";
13
+ import { type MyBugLink } from "../engine/linksStore";
14
+ import { loadedCase } from "../engine/loader";
15
+ import { reportState } from "../engine/reporter";
16
+ /** `withUrl` only for an explicit ask (report, listLinks): the url holds the key. */
17
+ declare function linkSummary(link: MyBugLink, withUrl?: boolean): {
18
+ localId: string;
19
+ status: import("..").MyBugLinkStatus;
20
+ url: string | undefined;
21
+ note: string | undefined;
22
+ createdAt: string;
23
+ expiresAt: string | null | undefined;
24
+ error: string | undefined;
25
+ steps: number;
26
+ errors: number;
27
+ removed: number;
28
+ /** Sent, but not yet locked to the team: only its link opens it. */
29
+ linkNeeded: boolean;
30
+ };
31
+ export interface BugLinksSnapshot {
32
+ server: string;
33
+ randomSource: string | null;
34
+ report: ReturnType<typeof reportState>;
35
+ loaded: ReturnType<typeof loadedCase> extends infer L ? (L extends null ? null : Omit<NonNullable<L>, "undo">) : never;
36
+ links: ReturnType<typeof linkSummary>[];
37
+ }
38
+ export declare function getBugLinksSnapshot(): BugLinksSnapshot;
39
+ export declare const bugLinksSyncAdapter: ToolSyncAdapter;
40
+ export {};
41
+ //# sourceMappingURL=bugLinksSyncAdapter.d.ts.map
@@ -0,0 +1,20 @@
1
+ "use client";var Pr=Object.defineProperty;var ks=Object.getOwnPropertyDescriptor;var vs=Object.getOwnPropertyNames;var Is=Object.prototype.hasOwnProperty;var Xn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ss=(e,t)=>{for(var n in t)Pr(e,n,{get:t[n],enumerable:true})},Lr=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of vs(t))!Is.call(e,r)&&r!==n&&Pr(e,r,{get:()=>t[r],enumerable:!(a=ks(t,r))||a.enumerable});return e},Ts=(e,t,n)=>(Lr(e,t,"default"),n&&Lr(n,t,"default"));var on=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);var Or={};Ss(Or,{AccessibilityInfo:()=>Es,ActivityIndicator:()=>aa,Alert:()=>Tl,Animated:()=>ml,AppRegistry:()=>Bs,AppState:()=>Dr,Appearance:()=>Rr,BackHandler:()=>Cs,Button:()=>Il,CheckBox:()=>Ws,Clipboard:()=>Ps,DeviceEventEmitter:()=>al,Dimensions:()=>_r,Easing:()=>Ls,FlatList:()=>Vs,I18nManager:()=>Os,Image:()=>Us,ImageBackground:()=>Ks,InteractionManager:()=>Rs,Keyboard:()=>Nr,KeyboardAvoidingView:()=>qs,LayoutAnimation:()=>Ds,Linking:()=>_s,LogBox:()=>nl,Modal:()=>kl,NativeEventEmitter:()=>Ns,NativeModules:()=>As,PanResponder:()=>Ms,Picker:()=>Fs,PixelRatio:()=>Zn,Platform:()=>dt,Pressable:()=>bl,ProgressBar:()=>Hs,RefreshControl:()=>Js,SafeAreaView:()=>Gs,ScrollView:()=>Vr,SectionList:()=>Ys,Share:()=>Qn,StatusBar:()=>Xs,StyleSheet:()=>Nt,Switch:()=>vl,Text:()=>O,TextInput:()=>Mt,Touchable:()=>Zs,TouchableHighlight:()=>yl,TouchableNativeFeedback:()=>Qs,TouchableOpacity:()=>Le,TouchableWithoutFeedback:()=>wl,UIManager:()=>js,Vibration:()=>zs,View:()=>K,VirtualizedList:()=>el,YellowBox:()=>tl,findNodeHandle:()=>Sl,unstable_createElement:()=>$s,useColorScheme:()=>rl,useLocaleContext:()=>ol,useWindowDimensions:()=>ea});Ts(Or,xs);import*as xs from"react-native-web";import{unstable_createElement as $s,NativeModules as As,AccessibilityInfo as Es,Appearance as Rr,AppRegistry as Bs,AppState as Dr,BackHandler as Cs,Clipboard as Ps,Dimensions as _r,Easing as Ls,I18nManager as Os,Keyboard as Nr,InteractionManager as Rs,LayoutAnimation as Ds,Linking as _s,NativeEventEmitter as Ns,PanResponder as Ms,PixelRatio as Zn,Platform as dt,Share as Qn,UIManager as js,Vibration as zs,CheckBox as Ws,FlatList as Vs,Image as Us,ImageBackground as Ks,KeyboardAvoidingView as qs,Picker as Fs,ProgressBar as Hs,RefreshControl as Js,SafeAreaView as Gs,SectionList as Ys,StatusBar as Xs,Touchable as Zs,TouchableNativeFeedback as Qs,VirtualizedList as el,YellowBox as tl,LogBox as nl,DeviceEventEmitter as al,useColorScheme as rl,useLocaleContext as ol,useWindowDimensions as ea}from"react-native-web";import*as re from"react-native-web";import{createElement as ta,forwardRef as Mr,useCallback as il,useRef as sl}from"react";import{useEffect as ll,useState as dl}from"react";import{createPortal as ul}from"react-dom";var cl='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as pl}from"react/jsx-runtime";var _t=Symbol.for("@buoy-gg/portal-host"),jr=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function zr(){let e=document;if(e[_t])return e[_t].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:cl});let n=()=>{let u=document.fullscreenElement,l=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==l&&l.appendChild(t)},a=new Map,r=u=>{(!t.contains(u.target)||!jr(u.target))&&a.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},o=u=>{a.delete(u.code||u.key)},i=()=>a.clear(),s=()=>{let u=[...a.values()];a.clear();for(let l of u)document.dispatchEvent(new KeyboardEvent("keyup",{...l,bubbles:true}))},c=u=>{jr(u.target)&&u.stopPropagation()},d=u=>u.stopPropagation();return n(),document.addEventListener("fullscreenchange",n),document.addEventListener("keydown",r,true),document.addEventListener("keyup",o,true),window.addEventListener("blur",i),t.addEventListener("focusin",s),t.addEventListener("keydown",c),t.addEventListener("keyup",c),t.addEventListener("keypress",c),t.addEventListener("wheel",d,{passive:true}),e[_t]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",n),document.removeEventListener("keydown",r,true),document.removeEventListener("keyup",o,true),window.removeEventListener("blur",i),t.remove(),delete e[_t]}},t}function hl({children:e}){let[t,n]=dl(null);return ll(()=>{let a=zr(),r=document[_t];return r.users++,n(a),()=>{--r.users===0&&r.dispose()}},[]),t?ul(pl("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var ut=re,fl=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ct=e=>typeof e=="number"?`${e}px`:e;function na(e){if(Array.isArray(e)){let l=e.map(na);return l.some((h,m)=>h!==e[m])?l:e}if(!e||typeof e!="object"||!fl.some(l=>e[l]!=null))return e;let{shadowColor:t,shadowOffset:n,shadowOpacity:a,shadowRadius:r,textShadowColor:o,textShadowOffset:i,textShadowRadius:s,...c}=e;if(t!=null||n!=null||a!=null||r!=null){let l=t??"black",h=a==null?l:`color-mix(in srgb, ${l} ${Math.min(a,1)*100}%, transparent)`,m=`${ct(n?.width??0)} ${ct(n?.height??0)} ${ct(r??0)} ${h}`;c.boxShadow=typeof c.boxShadow=="string"?`${c.boxShadow}, ${m}`:c.boxShadow??m}let{width:d=0,height:u=0}=i??{};if(o&&(d||u||s)){let l=`${ct(d)} ${ct(u)} ${ct(s??0)} ${o}`;c.textShadow=c.textShadow?`${c.textShadow}, ${l}`:l}return c}var gl=ut.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Wr(e,t){if(typeof e=="function")return a=>Wr(e(a),t);let n=na(e);return t?[n,gl[t]]:n}var Nt={...ut.StyleSheet,create:e=>ut.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,n])=>[t,na(n)])))};function pe(e){let t=Mr((a,r)=>{let{accessibilityState:o,accessibilityValue:i,pointerEvents:s,...c}=a;for(let u of["busy","checked","disabled","expanded","selected"])o?.[u]!==void 0&&c[`aria-${u}`]===void 0&&(c[`aria-${u}`]=o[u]);for(let[u,l]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[u]!==void 0&&c[`aria-${l}`]===void 0&&(c[`aria-${l}`]=i[u]);let d=Wr(c.style,s);return d!==c.style&&(c.style=d),ta(e,{...c,ref:r})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var K=pe(re.View),O=pe(re.Text),ml={...ut.Animated,View:ut.Animated.createAnimatedComponent(K),Text:ut.Animated.createAnimatedComponent(O)},Mt=pe(re.TextInput),Le=pe(re.TouchableOpacity),yl=pe(re.TouchableHighlight),wl=pe(re.TouchableWithoutFeedback),bl=pe(re.Pressable),Vr=pe(re.ScrollView),Ur=Mr((e,t)=>{let n=sl(null),a=il(r=>{if(r){let o=r;for(;o.parentElement&&o.parentElement!==document.body;)o=o.parentElement;o.parentElement===document.body&&(n.current=o,Object.assign(o.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),zr().appendChild(o))}else n.current&&(document.body.appendChild(n.current),n.current=null);typeof t=="function"?t(r):t&&(t.current=r)},[t]);return ta(hl,null,ta(re.Modal,{...e,ref:a}))});Ur.displayName="Modal";var kl=pe(Ur),vl=pe(re.Switch),aa=pe(re.ActivityIndicator),Il=pe(re.Button),Sl=re.findNodeHandle,Tl={alert(e,t,n,a){if(typeof document>"u")return;let r=document.createElement("dialog");r.dataset.buoyRoot="",r.setAttribute("aria-label",e),r.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let o=document.createElement("h2");if(o.textContent=e,o.style.cssText="font-size:18px;margin:0 0 12px",r.appendChild(o),t){let d=document.createElement("p");d.textContent=t,d.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",r.appendChild(d)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let s=n?.length?n:[{text:"OK"}],c=()=>{r.close?.(),r.remove()};for(let d of s){let u=document.createElement("button");u.type="button",u.textContent=d.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${d.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{c(),d.onPress?.()},i.appendChild(u)}r.addEventListener("cancel",d=>{d.preventDefault(),a?.cancelable!==false&&(c(),a?.onDismiss?.())}),r.appendChild(i),document.body.appendChild(r),r.showModal?r.showModal():r.setAttribute("open","")}};import{devToolsStorageKeys as Kr,startBugCaseRecorder as xl}from"@buoy-gg/shared-ui/web";import{useEffect as sn,useState as ra,useSyncExternalStore as ln}from"react";import{Bug as oa,FloatingTool as $l,X as qr,dismissFloatingTool as pt,getFloatingTools as Al,night as X,openBuoyTool as ia,openFloatingTool as El,subscribeFloatingTools as Bl,useSafeAreaInsets as Cl}from"@buoy-gg/shared-ui/web";import{dispatchToolAction as Pl,getStateSnapshotProviders as jt,getToolAdapters as Ll,getSafeCurrentRoute as Ol,devToolsStorageKeys as he,persistentStorage as Te,setItemChecked as sa,superJsonDeserialize as la,superJsonSerialize as Fr,validateBugCase as Rl,readToolSnapshot as Dl,reloadApp as _l,waitForToolRegistry as Nl}from"@buoy-gg/shared-ui/web";import{bugCaseAppInfo as Ml}from"@buoy-gg/shared-ui/web";var jl=.1,Hr=e=>(e??"").split(".")[0];function zl(e,t){if(!e)return[];let n=[],a=(d,u,l)=>n.push(`${d} was ${u}; here it's ${l}.`);e.id&&t.id&&e.id!==t.id&&a("The app",e.id,t.id),e.platform&&t.platform&&e.platform!==t.platform&&a("The platform",e.platform,t.platform);let r=!e.platform||!t.platform||e.platform===t.platform,o=!!e.version&&!!t.version&&e.version!==t.version,i=r&&!!e.build&&!!t.build&&e.build!==t.build;if(o||i){let d=!!e.version&&!!t.version,u=l=>[d&&l.version,i&&l.build&&`build ${l.build}`].filter(Boolean).join(", ");a("The app version",u(e),u(t))}e.os&&t.os&&e.platform===t.platform&&Hr(e.os)!==Hr(t.os)&&a(`${e.platform==="ios"?"iOS":e.platform==="android"?"Android":"The OS"}`,e.os,t.os),e.locale&&t.locale&&e.locale!==t.locale&&a("The language",e.locale,t.locale),e.timeZone&&t.timeZone&&e.timeZone!==t.timeZone&&a("The time zone",e.timeZone,t.timeZone),e.appearance&&t.appearance&&e.appearance!==t.appearance&&a("The phone",`in ${e.appearance} mode`,`in ${t.appearance} mode`);let s=e.window,c=t.window;if(s&&c&&s.width>0&&s.height>0&&c.width>0&&c.height>0){let d=(u,l)=>Math.abs(u-l)/u>jl;(d(s.width,c.width)||d(s.height,c.height))&&a("The screen",`${Math.round(s.width)}x${Math.round(s.height)}`,`${Math.round(c.width)}x${Math.round(c.height)}`)}return s?.fontScale&&c?.fontScale&&Math.abs(s.fontScale-c.fontScale)>=.05&&a("The text size",`${s.fontScale}x`,`${c.fontScale}x`),n}var Wl={ios:"an iOS app",android:"an Android app",macos:"a macOS app",windows:"a Windows app"},Jr=e=>Wl[e]??`a ${e} app`;function Vl(e,t){if(!e)return null;if((!e.platform||!t.platform||e.platform===t.platform)&&e.id&&t.id&&e.id!==t.id)return`This case is from another app (${e.id}), and this is ${t.id}.`;let n=a=>a==="web";return e.platform&&t.platform&&n(e.platform)!==n(t.platform)?n(e.platform)?`This case is from a web app, and this is ${Jr(t.platform)}.`:`This case is from ${Jr(e.platform)}, and this is a web app.`:null}function Gr(){let e,t;try{({locale:e,timeZone:t}=Intl.DateTimeFormat().resolvedOptions())}catch{}let n=_r.get("window");return{platform:dt.OS,os:String(dt.Version),...Ml(),appearance:Rr.getColorScheme()??void 0,locale:e,timeZone:t,window:{width:n.width,height:n.height,scale:Zn.get(),fontScale:Zn.getFontScale()}}}import{persistentStorage as da}from"@buoy-gg/shared-ui/web";function ua(){if(typeof navigator<"u"&&navigator.product==="ReactNative")return null;try{return globalThis.sessionStorage??null}catch{return null}}var dn={async getItem(e){let t=ua();if(!t)return da.getItem(e);try{return t.getItem(e)}catch{return null}},async setItem(e,t){let n=ua();if(!n)return da.setItem(e,t);try{n.setItem(e,t)}catch{}},async removeItem(e){let t=ua();if(!t)return da.removeItem(e);try{t.removeItem(e)}catch{}}};var Yr="buoy-bug-links-tab",Ul="buoy-bug-links-step",ca=null,Kl=false;function Xr(){return typeof navigator<"u"&&navigator.product==="ReactNative"?false:typeof window<"u"&&typeof document<"u"}function Zr(){if(ca)return Kl;try{return window.top!==window}catch{return true}}function pa(){return ca||(Xr()?navigator.locks??null:null)}function D(){return!!ca||Xr()}var zt=null,ha=false;function Qr(){if(zt)return zt;let e=D()?pa():null;return!e||Zr()?zt=Promise.resolve():(zt=new Promise(t=>{e.request(Yr,{mode:"shared"},()=>(ha=true,t(),new Promise(()=>{}))).catch(()=>{ha=false,t()})}),zt)}async function eo(){if(!D())return null;let e=pa();if(!e)return"This browser can't keep the app's other tabs safe from a bug case (it has no Web Locks). Load it in a current browser.";if(Zr())return"This app is inside a frame. Open it in its own tab to load a bug case.";await Qr();let t;try{let a=await e.query();t=new Set((a.held??[]).filter(r=>r.name===Yr).map((r,o)=>r.clientId??`unknown-${o}`)).size}catch{return"Buoy couldn't count the app's tabs, so it didn't load the bug case."}let n=t-(ha?1:0);return n<=0?null:`This app is open in ${n===1?"another tab":`${n} other tabs`}. A bug case changes the data every tab shares, so close the other tabs, then load it.`}function ql(e){return un(Ul,e)}function un(e,t){if(!D())return t();let n=pa();return n?n.request(e,{mode:"exclusive"},t):Promise.reject(new Error("This browser can't keep bug links safe across tabs. Update it to use bug links."))}var fa="Bug case: ",to=`${fa}blocked (no recorded answer)`,ga=49,Fl=1e4,Hl=/^(content-length|content-encoding|transfer-encoding|set-cookie|connection|keep-alive)$/i,Jl=/\[removed:[a-z]+\]/g,ma=/\[removed:[a-z]+\]/,Gl=/^(_|t|ts|time|timestamp|cb|cachebust|cachebuster|nocache|rnd|rand|random|nonce|bust)$/i;function Yl(e){let t=e.replace(Jl,"*"),n=t.indexOf("?");if(n<0)return t;let a=t.indexOf("#",n),r=t.slice(n+1,a<0?void 0:a).split("&").map(o=>{let i=o.indexOf("=");return i>0&&Gl.test(o.slice(0,i))?`${o.slice(0,i)}=*`:o});return`${t.slice(0,n+1)}${r.join("&")}${a<0?"":t.slice(a)}`}function Xl(e){if(!e)return false;let t=Object.entries(e).find(([n])=>n.toLowerCase()==="content-type")?.[1]??"";return/^application\/(?:[\w.-]+\+)?json\b/i.test(t.trim())}function no(e,t,n){if(e!==void 0){if(n===true)try{return JSON.stringify(e)}catch{return}if(typeof e=="string")return n===false||!Xl(t)?e:JSON.stringify(e);if(e===null)return"null";try{return JSON.stringify(e)}catch{return}}}function Zl(e){let t=e;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t,a=!!n.extensions&&typeof n.extensions=="object"&&!Array.isArray(n.extensions);if(typeof n.query!="string"&&!a)return;let r=n.operationName;return typeof r=="string"&&/^[A-Za-z0-9_]{1,100}$/.test(r)?r:void 0}function ao(e){let t=n=>Array.isArray(n)?n.map(t):n&&typeof n=="object"?Object.fromEntries(Object.keys(n).sort().map(a=>[a,t(n[a])])):n;return JSON.stringify(t(e))??"null"}function Ql(e){let t=n=>{if(!n||typeof n!="object"||Array.isArray(n))return false;let a=n;return typeof a.query=="string"||!!a.extensions&&typeof a.extensions=="object"&&!Array.isArray(a.extensions)};return Array.isArray(e)?e.some(t):t(e)}function ed(e){let t=e,n=t&&typeof t=="object"?t.variables??{}:void 0;return n===void 0?void 0:ao(n)}var td=4e3;function nd(e){return e===void 0?{kind:"none"}:{kind:"json",value:e}}function ad(e,t){let n;if(t)n=ed(e.requestData)??"{}";else{let a=nd(e.requestData);if(a.kind==="none")return{raw:"\0none",why:"it had no body, and other calls to this URL had one"};n=ao(a.value)}return ma.test(n)?{raw:n,why:"its input had private data taken out, so it can't be told apart from the others"}:n.length>td?{raw:n,why:"its input is too long to match"}:{raw:n,key:n}}var rd=/^(application\/(octet-stream|pdf|zip|gzip|x-protobuf|protobuf|x-msgpack|msgpack|wasm|vnd\.[^;]*)|image\/(?!svg)|audio\/|video\/|font\/)/i,od=/\+(json|xml|yaml|csv|text)\b|^text\//i;function id(e){let t=Object.entries(e.responseHeaders??{}).find(([a])=>a.toLowerCase()==="content-type")?.[1];if(typeof t!="string")return false;let n=t.trim();return rd.test(n)&&!od.test(n)}function sd(e){if(!e.responseHeaders)return;let t={};for(let[n,a]of Object.entries(e.responseHeaders))typeof a!="string"||Hl.test(n)||ma.test(a)||(t[n]=a);return Object.keys(t).length?t:void 0}function ld(e){let t=e.url.replace(/^[a-z]+:\/\/[^/]+/i,"").split(/[?#]/)[0]||"/";return`${e.method.toUpperCase()} ${t.slice(0,60)}`}function dd(e){let t=e.durationMs?Math.min(Fl,Math.max(0,Math.round(e.durationMs))):void 0;return e.error?{kind:"fail",failKind:/time(d)?[ -]?out/i.test(e.error)?"timeout":"network",delayMs:t}:{kind:"respond",status:Math.min(599,Math.max(200,e.status??200)),headers:sd(e),body:no(e.responseData,e.responseHeaders,e.responseJson)??"",delayMs:t}}function ro(e){return e.urlPattern.replace(/\*/g,"").length+(e.graphqlOperation?1e5:0)+(e.graphqlVariables!==void 0?2e5:0)+(e.bodyJson!==void 0?4e5:0)}function oo(e,t={}){let n=[...e.network??[]].reverse(),a=[],r=new Map;n.forEach((f,p)=>{if(!f||typeof f.url!="string"||typeof f.method!="string")return;let y=true;f.bodyOmitted&&!f.error?(a.push({method:f.method,url:f.url,reason:"its answer was too big to record"}),y=false):!f.error&&id(f)?(a.push({method:f.method,url:f.url,reason:"its answer was binary, and Buoy records answers as text"}),y=false):typeof f.status!="number"&&!f.error&&(a.push({method:f.method,url:f.url,reason:"it had no answer yet when the bug was sent"}),y=false);let w=f.method.toUpperCase(),$=Zl(f.requestData),A=ad(f,$),P=Yl(f.url),N=`${w} ${P} ${$??""}`,te=`${N} ${A.raw}`,F=r.get(te)??{key:te,family:N,pattern:P,method:w,op:$,input:A,calls:[]};F.calls.push({call:f,at:p,usable:y}),r.set(te,F)});let o=f=>`${f.call.status??""} ${f.call.error??""} ${no(f.call.responseData,f.call.responseHeaders,f.call.responseJson)??""}`;for(let[f,p]of[...r]){if(!ma.test(p.input.raw)||p.calls.length<2)continue;let y=p.calls.filter(w=>w.usable);y.length===p.calls.length&&new Set(y.map(o)).size<=1||(r.delete(f),p.calls.forEach((w,$)=>r.set(`${f} #${$}`,{...p,key:`${f} #${$}`,calls:[w]})))}let i=new Map;for(let f of r.values())i.set(f.family,(i.get(f.family)??0)+1);let s=new Set([...i].filter(([,f])=>f>1).map(([f])=>f)),c=f=>`${f.method} ${f.pattern}`,d=new Map;for(let f of r.values())d.set(c(f),(d.get(c(f))??0)+1);for(let f of r.values())f.op||((d.get(c(f))??0)>1||f.calls.some(p=>Ql(p.call.requestData)))&&s.add(f.family);let u=new Set;for(let f of r.values())f.calls.some(p=>p.call.bodyOmitted&&p.call.requestData===void 0&&!/^(GET|HEAD)$/.test(f.method))&&u.add(c(f));for(let f of r.values())u.has(c(f))&&s.add(f.family);for(let[f,p]of r){let y=p.calls.filter(w=>w.usable);if(s.has(p.family)&&p.input.key===void 0){for(let{call:w}of y)a.push({method:w.method,url:w.url,reason:p.input.why??"its input can't be matched"});r.delete(f)}else y.length?p.calls=y:r.delete(f)}let l=[],h=0;for(let f of r.values()){let p=t.sequence?f.calls:f.calls.slice(-1);p.forEach(({call:y,at:w},$)=>{let A=$===p.length-1;l.push({at:w,order:h++,rule:{name:`${fa}${ld(y)}${p.length>1?` (${$+1} of ${p.length})`:""}`,enabled:true,sandbox:true,urlPattern:f.pattern,methods:[f.method],graphqlOperation:f.op,...f.op?{graphqlSingle:true}:{},...s.has(f.family)?f.op?{graphqlVariables:f.input.key}:{bodyJson:f.input.key}:{},times:A?null:1,...dd(y)}})})}let m=[...l];if(m.length>ga){let f=[...m].sort((p,y)=>y.at-p.at||(y.rule.times===null?0:1)-(p.rule.times===null?0:1));m=f.slice(0,ga);for(let p of f.slice(ga))a.push({method:p.rule.methods?.[0]??"?",url:p.rule.urlPattern,reason:"over the 50-rule limit"})}m.sort((f,p)=>ro(p.rule)-ro(f.rule)||f.order-p.order);let g=m.map(f=>f.rule),k=m.length;return g.push({name:to,enabled:true,sandbox:true,urlPattern:"*",kind:"fail",failKind:"network",times:null}),{rules:g,answers:k,skipped:a}}function ud(e){return typeof e?.name=="string"&&e.name.startsWith(fa)}var io=15e5,Wt=()=>`${he.bugLinks.loaded()}_case`,Vt=()=>`${he.bugLinks.loaded()}_undo_state`,cn=()=>`${he.bugLinks.loaded()}_restart`,so=[300,400,800],x=null,lo=Promise.resolve(),ya=0;function Ve(e,t={}){t.quiet||(ya++,ie());let n=()=>ql(e),a=lo.then(n,n);return lo=a.catch(()=>{}),a.finally(()=>{t.quiet||(ya--,ie())})}function uo(){return ya>0}var fe,ne=[],Ue={},co=24,wa=new Set;function be(){return x}function ht(e){return wa.add(e),()=>wa.delete(e)}function ie(){for(let e of wa)e()}var xe=e=>!!Ll()[e];async function Z(e,t,n){return await Pl(e,t,n)}var ba=e=>new Promise(t=>setTimeout(t,e));function ka(e){if(typeof e!="string")return null;let t=e.trim();return!t.startsWith("/")||t.startsWith("//")||t.length>2e3||/[\u0000-\u001f\\]/.test(t)||/^\/[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function po(e){try{return Rl(e)}catch(t){throw new Error(t instanceof Error?t.message:"This isn't a bug case Buoy can load.")}}function ho(){return`ld_${Date.now().toString(36)}_${Math.floor(Math.random()*1e9).toString(36)}`}async function pn(e,t={}){let n=po(e);return Ve(()=>go(n,t))}function cd(e){try{let t=new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"});return t&&t!=="Invalid Date"?t:e}catch{return e}}function pd(e){if(!e.length)return"";let t=r=>r.replace(/^[a-z]+:\/\/[^/]+/i,"").split("?")[0]||"/",n=e.slice(0,3).map(r=>`${r.method.toUpperCase()} ${t(r.url)} (${r.reason})`),a=e.length>3?`, and ${e.length-3} more`:"";return` ${e.length===1?"1 recorded call has":`${e.length} recorded calls have`} no answer, so ${e.length===1?"it's":"they're"} blocked: ${n.join("; ")}${a}.`}function fo(){let e=[];return{steps:e,step:(t,n,a)=>{let r=e.findIndex(o=>o.part===t);r>=0?e[r]={part:t,ok:n,detail:a}:e.push({part:t,ok:n,detail:a})}}}function ft(e){return`state: ${jt().find(t=>t.id===e)?.label??e}`}async function go(e,t){let n=new Date().toISOString(),{steps:a,step:r}=fo(),o=t.replay!==false;if(t.stillWanted&&!t.stillWanted())return r("app",false,"The Bug Links screen closed, so Buoy stopped loading this bug."),{loadedAt:n,steps:a,replay:null,loaded:false};let i=t.otherApp?null:Vl(e.app,Gr());if(i)return r("app",false,`${i} Its state could break this app, so nothing was loaded. Load it anyway only if this app shares its data.`),{loadedAt:n,steps:a,replay:null,loaded:false};let s=await eo();if(s)return r("app",false,s),{loadedAt:n,steps:a,replay:null,loaded:false};await yt();let c=!!x?.undo,d=x?.undo??await md();if(c&&!fe){let M=await bo(d);M&&(fe=M.state,Ue=M.keys,ne=M.late)}let u=(M,T,v)=>yd(d,M,T,v),l=ho(),h=(e.note??"").split(`
2
+ `)[0].slice(0,80)||(e.route?.pathname?`Bug on ${e.route.pathname.slice(0,70)}`:"Bug case"),m={replay:t.replay,clock:t.clock,sequence:t.sequence,otherApp:t.otherApp};if(!c){let M={source:t.source?.id?{id:t.source.id}:null,loadId:l,canLoadAgain:false,title:h,createdAt:e.createdAt,report:{loadedAt:n,steps:[],replay:null,loaded:false},undo:d,options:m,phase:"loading",block:o};if(!await mn(M)&&So())return r("saved",false,"The phone couldn't save that a case is loading (its storage may be full), so nothing was loaded."),{loadedAt:n,steps:a,replay:null,loaded:false}}if(c&&x&&!await mn({...x,phase:"loading"},o||Kt(x))&&So())return await Ke(),r("saved",false,"The phone couldn't save that a case is loading (its storage may be full), so nothing new was loaded."),{loadedAt:n,steps:a,replay:null,loaded:false};let g=async()=>{c?await Ke():await Te.removeItem(he.bugLinks.loaded()).catch(()=>{})},k=await eo();if(k)return await g(),r("app",false,k),{loadedAt:n,steps:a,replay:null,loaded:false};if(t.stillWanted&&!t.stillWanted())return await g(),r("app",false,"The Bug Links screen closed, so Buoy stopped loading this bug."),{loadedAt:n,steps:a,replay:null,loaded:false};if(!o&&x&&Kt(x)){if(!await gt(d))return await g(),r("web calls",false,"Couldn't put your Network rules back, so the last case's answers stay on. Nothing new was loaded."),{loadedAt:n,steps:a,replay:null,loaded:false};await mn({...x,phase:"loading"},false)}let f=null;if(o){let M=async I=>(await g(),r("web calls",false,`${I} Nothing was loaded, so no real server got this case's data. Load with replay off to use real web calls.`),{loadedAt:n,steps:a,replay:null,loaded:false});if(!xe("network"))return M("The Network tool isn't installed, so Buoy can't block real web calls.");let T=oo(e,{sequence:t.sequence}),v=null;if(c&&(v=await Z("network","listOverrideRules").catch(()=>null)),t.stillWanted&&!t.stillWanted())return await g(),r("app",false,"The Bug Links screen closed, so Buoy stopped loading this bug."),{loadedAt:n,steps:a,replay:null,loaded:false};let b=await Z("network","replaceOverrideRules",{rules:T.rules,enabled:true}).catch(I=>({ok:false,error:I instanceof Error?I.message:String(I),active:false}));if(!b||b.ok===false)return M(`Couldn't set up replay: ${b?.error??"unknown"}.`);if(b.active===false)return c||await gt(d),M("This build can't fake web calls (release builds never do).");if(b.saved===false)return c?v?.rules&&await Z("network","replaceOverrideRules",{rules:v.rules,enabled:v.enabled!==false}).catch(()=>{}):await gt(d),M("The phone couldn't save the block on real web calls (its storage may be full).");f={answers:T.answers,skipped:T.skipped.length,active:true},r("web calls",true,`${T.answers} recorded answers. Every other call is blocked.${pd(T.skipped)}`)}if(t.clock!==false){let M=e.clock?.active?e.clock.virtualIso:e.createdAt;xe("clock")?typeof M=="string"&&!Number.isNaN(Date.parse(M))&&await Z("clock","setTime",{time:M,freeze:e.clock?.rate===0}).then(()=>r("clock",true,`App time set to ${cd(M)} (the reporter's time).`)).catch(T=>r("clock",false,`Couldn't set the clock: ${T instanceof Error?T.message:String(T)}`)):e.clock?.active?r("clock",false,"The reporter's app had its clock set by Buoy, but the Clock tool isn't installed here, so the app keeps today's time."):a.push({part:"clock",ok:true,warn:true,detail:"The Clock tool isn't installed, so the app keeps today's time."})}let p=hd(e,r),y=await mo(p,r,u),w=ka(e.route?.href)??ka(e.route?.pathname);w?xe("route-events")?await Z("route-events","navigate",{path:w,reset:true}).catch(()=>Z("route-events","navigate",{path:w,replace:true})).then(()=>r("screen",true,`Went to ${w}.`)).catch(M=>r("screen",false,`Couldn't go to ${w}: ${M instanceof Error?M.message:String(M)}`)):r("screen",false,`The Routes tool isn't installed. Go to ${w} by hand.`):e.route&&r("screen",false,"The case's screen isn't an app path, so Buoy didn't go there."),await yo(p,y,r,u);let $=zl(e.app,Gr());$.length&&a.push({part:"this phone",ok:true,warn:true,detail:`Not like the reporter's, so a bug that needs these may not show. ${$.join(" ")}`});let A={loadedAt:n,steps:a,replay:f,loaded:true};x={source:t.source?.id?{id:t.source.id}:null,loadId:l,canLoadAgain:false,title:h,createdAt:e.createdAt,report:A,undo:d,options:m};let P=await Ke(),{canLoadAgain:N,onDisk:te}=await bd(l,e);N&&(x={...x,canLoadAgain:N},P=await Ke()&&P),!P&&f?.active&&A.steps.push({part:"saved",ok:false,detail:"The phone couldn't save that a case is loaded. Restore your app before you restart it, or remove the bug case rules in the Network tool after."}),ie(),y.size&&gd(p,y,l,u);let F=N&&te&&P&&d.stateSaved;return t.restart&&F?(await dn.setItem(cn(),l).catch(()=>{}),A.steps.push({part:"restart",ok:true,detail:"Restarting the app, then loading the case again."}),_l("auto","bug links: load and restart").catch(()=>{dn.removeItem(cn()).catch(()=>{})})):t.restart&&A.steps.push({part:"restart",ok:false,detail:N?"The phone couldn't save everything a restart needs, so Buoy didn't restart. Restore your app before you restart it by hand.":"This case is too big to keep on the phone, so Buoy can't load it again after a restart."}),A}function hd(e,t){try{let n=e.state?la(JSON.parse(JSON.stringify(e.state)),{skipBadAnnotations:true}):{};if(n&&typeof n=="object"&&!Array.isArray(n)){let a=n,r=a.storage;if(r&&typeof r=="object"&&!Array.isArray(r)&&"secure"in r){let{secure:o,...i}=r;a.storage=i}return a}t("state",false,"The case's state isn't an object, so none of it was loaded.")}catch{t("state",false,"The case's state couldn't be read.")}return{}}async function mo(e,t,n){let a=new Map(Object.keys(e).map(r=>[r,{skipped:1/0,ids:null}]));return await va(e,a,t,n),a}async function va(e,t,n,a){for(let r of jt()){let o=t.get(r.id);if(!(!o||!r.status().canRestore))try{let i=a?await a(r,e[r.id],o.ids):{ok:true,scope:o.ids??void 0,later:[]};if(!i.ok){t.delete(r.id),n?.(ft(r.id),false,"Buoy couldn't save a copy of it first, so it wasn't loaded. (Restore couldn't have put it back.)");continue}let s=i.scope&&!i.scope.length?{ok:true,applied:0,skipped:[],warnings:[]}:await r.restore(e[r.id],i.scope?{includeKeys:i.scope}:void 0);i.unclaim&&await i.unclaim(s.skipped.map(u=>u.id));let c=[...new Set([...s.skipped.map(u=>u.id),...i.later])],d=c.length;d===0?t.delete(r.id):t.set(r.id,{skipped:d,ids:c}),n&&(o.skipped===1/0||d===0)&&n(ft(r.id),s.ok,`${s.applied} loaded${d?`, ${d} not there yet`:""}.`)}catch(i){t.delete(r.id),n?.(ft(r.id),false,i instanceof Error?i.message:String(i))}}}async function yo(e,t,n,a){for(let o of so){if(!t.size)break;await ba(o),await va(e,t,n,a)}let r=new Map(jt().map(o=>[o.id,o]));for(let[o,i]of t){let s=r.get(o);n(ft(o),false,s?i.skipped!==1/0?`${i.skipped} stores never mounted, so they weren't loaded.`:`It wasn't ready${s.status().detail?` (${s.status().detail})`:""}, so it wasn't loaded.`:"This app has no such source to load it into.")}}var fd=2e4;async function gd(e,t,n,a){let r=Date.now()+fd;for(;t.size&&Date.now()<r;)if(await ba(1e3),await Ve(async()=>{if(x?.loadId!==n||!await yt())return true;let o=new Map(t),i=[];if(await va(e,t,(d,u,l)=>i.push({part:d,ok:u,detail:l}),a),![...o.keys()].some(d=>!t.has(d)||t.get(d).skipped<o.get(d).skipped)||!x||x.loadId!==n)return false;let s=new Set([...t.keys()].map(ft)),c=x.report.steps.filter(d=>!i.some(u=>u.part===d.part)&&!(d.part.startsWith("state:")&&!d.ok&&!s.has(d.part)));return x={...x,report:{...x.report,steps:[...c,...i]}},await Ke(),ie(),false},{quiet:true}))return}async function md(){let e={},t={};for(let s of jt())if(s.status().canCapture)try{e[s.id]=(await s.capture()).data,t[s.id]=await Ta(s,e[s.id])}catch{}fe=e,Ue=t,ne=[];let n=ho(),a=await fn(n),r=xe("network")?await Z("network","listOverrideRules").then(s=>({enabled:!!s?.enabled,rules:(s?.rules??[]).filter(c=>!ud(c))})).catch(()=>null):null,o=xe("clock")?await Z("clock","getState").then(s=>({active:!!s?.active,virtualIso:s?.virtualIso,rate:s?.rate})).catch(()=>null):null,i=Ol();return{undoId:n,route:i?.href??i?.pathname??null,network:r,clock:o,stateSaved:a}}function wo(e){let t=e.storage;if(!t||typeof t!="object"||Array.isArray(t)||!("secure"in t))return e;let{secure:n,...a}=t;return{...e,storage:a}}async function Ia(e){return x&&(x={...x,notice:e},await Ke(),ie()),{ok:false,detail:e}}async function gt(e){if(!xe("network"))return false;let t=await Z("network","replaceOverrideRules",{rules:e?.network?.rules??[],enabled:e?.network?.enabled??true}).catch(()=>({ok:false}));return!!t&&t.ok!==false&&t.saved!==false}var Sa="Make sure the Network tool is on and you're signed in to Buoy, then try again.";function hn(){return Ve(async()=>{if(!await yt())return{ok:true,detail:$a};let e=x?.undo??(await qt())?.undo;return await gt(e)?(x&&(x={...x,phase:void 0,block:false,notice:void 0,report:{...x.report,replay:x.report.replay&&{...x.report.replay,active:false}}},await Ke(),ie()),{ok:true}):Ia(`Web calls are still answered from the case. ${Sa}`)})}async function fn(e){if(!fe)return false;let t=false;try{let n=JSON.stringify({undoId:e,state:Fr(wo(fe??{})),keys:Ue,late:ne.map(a=>({id:a.id,ids:a.ids,data:Fr(wo({[a.id]:a.data})[a.id])}))});n.length<=io&&(t=await sa(Vt(),n))}catch{t=false}return t||await Te.removeItem(Vt()).catch(()=>{}),t}async function bo(e){if(fe)return{state:fe,keys:Ue,late:ne};if(e.stateSaved)try{let t=await Te.getItem(Vt());if(!t)return;let n=JSON.parse(t);if(n.undoId!==e.undoId||!n.state)return;let a=la(n.state);if(!a||typeof a!="object")return;let r=s=>Array.isArray(s)?s.filter(c=>typeof c=="string"):null,o={};if(n.keys&&typeof n.keys=="object")for(let[s,c]of Object.entries(n.keys))o[s]=r(c);let i=Array.isArray(n.late)?n.late.flatMap(s=>typeof s?.id=="string"?[{id:s.id,ids:r(s.ids),data:la(s.data)}]:[]):[];return{state:a,keys:o,late:i}}catch{return}}async function Ta(e,t){if(!e.previewItems)return null;try{return(await e.previewItems(t,t)).items.map(n=>n.key)}catch{return null}}function xa(e,t){return!!Ue[e]?.includes(t)||ne.some(n=>n.id===e&&!!n.ids?.includes(t))}async function ko(e,t,n){if(ne.length>=co||!t.status().canCapture)return;let a;try{a=(await t.capture()).data}catch{return}let r={id:t.id,ids:n,data:a};return ne.push(r),e.stateSaved=await fn(e.undoId),r}function vo(e,t){if(e.includes(t))return true;let n=t.indexOf("/");return t.startsWith("mmkv:")&&n>5&&e.includes(t.slice(0,n))}async function yd(e,t,n,a){if(!fe)return{ok:true,scope:a??void 0,later:[]};let r=t.id;if(!t.previewItems){if(a){let h=a.filter(g=>!xa(r,g));if(!h.length)return{ok:true,scope:a,later:[]};let m=await ko(e,t,h);return m?{ok:true,scope:a,later:[],unclaim:async g=>{!g.length||!m.ids||(m.ids=m.ids.filter(k=>!vo(g,k)),m.ids.length||ne.splice(ne.indexOf(m),1),e.stateSaved=await fn(e.undoId))}}:{ok:false,later:[]}}return r in fe||ne.some(h=>h.id===r)?{ok:true,later:[]}:{ok:!!await ko(e,t,null),later:[]}}let o;try{o=(await t.previewItems(n)).items}catch{return{ok:false,later:[]}}a&&(o=o.filter(h=>vo(a,h.key)));let i=new Set(await Ta(t,n)??o.map(h=>h.key)),s=o.filter(h=>h.verdict!=="wont-apply"),c=o.filter(h=>h.verdict==="wont-apply"&&i.has(h.key)).map(h=>h.key),d=s.filter(h=>!xa(r,h.key));if(d.length){if(ne.length>=co||!t.status().canCapture)return{ok:false,later:[]};let h;try{h=(await t.capture()).data}catch{return{ok:false,later:[]}}let m=new Set(await Ta(t,h)??[]),g=d.filter(k=>m.has(k.key)||k.verdict==="added").map(k=>k.key);g.length&&(ne.push({id:r,ids:g,data:h}),e.stateSaved=await fn(e.undoId))}let u=s.map(h=>h.key).filter(h=>xa(r,h)),l=s.map(h=>h.key).filter(h=>!u.includes(h));return{ok:true,scope:u,later:[...c,...l]}}function Ut(){return Ve(async()=>await yt()?wd():[{part:"app",ok:true,detail:$a}])}async function Io(e,t,n){let a=new Map,r=new Map(jt().map(s=>[s.id,s])),o=new Map;for(let s of e)o.set(s.id,(o.get(s.id)??0)+1);let i="isn't open now. Open its screen and tap Restore my app again, or tap End.";for(let[s,c]of[...e.entries()].reverse()){if(n&&!n.has(c))continue;let d=`${ft(c.id)} (opened during the case${(o.get(c.id)??0)>1?`, copy ${s+1}`:""})`,u=m=>{c.ids&&a.set(c,m)},l=r.get(c.id);if(!l||!l.status().canRestore){t(d,false,`It ${i}`),u(n?.get(c)??[]);continue}let h=n?.get(c);try{let m=await l.restore(c.data,h?.length?{includeKeys:h}:c.ids?{includeKeys:c.ids}:void 0),g=m.skipped.map(k=>k.id);m.ok&&!g.length?t(d,true,`${m.applied} put back.`):(t(d,false,`${g.length||"Some"} ${i}`),u(g))}catch(m){t(d,false,m instanceof Error?m.message:String(m))}}return a}async function wd(){let e=x??await qt(),{steps:t,step:n}=fo();if(!e)return t;let a=e.undo,r=Kt(e),o=async(g,k=false)=>(x={...e,undoBlocked:true,undoGone:k||e.undoGone,notice:g},await Ke(),ie(),n("web calls",false,r?`${g} So web calls stay blocked. Tap End to keep the app as it is now and go back to real calls, or clear the app's data.`:`${g} Tap End to keep the app as it is now, or clear the app's data.`),t),i=a.undoId?await bo(a):void 0;if(!i)return o("The app's own state from before the load is gone.",true);let s=i.state;a.clock&&xe("clock")&&await(a.clock.active&&a.clock.virtualIso?Z("clock","setTime",{time:a.clock.virtualIso,freeze:a.clock.rate===0}).then(()=>a.clock.rate&&a.clock.rate!==1?Z("clock","setRate",{rate:a.clock.rate}):void 0):Z("clock","reset")).then(()=>n("clock",true,"The clock is back.")).catch(()=>{});let c=await Io(i.late,n),d=async(g,k,f)=>{let p=i.keys[g.id];return{ok:true,scope:f??p??void 0,later:[]}},u=await mo(s,n,d),l=ka(a.route),h=true;l&&xe("route-events")&&await Z("route-events","navigate",{path:l,reset:true}).catch(()=>Z("route-events","navigate",{path:l,replace:true})).catch(()=>{h=false}),await yo(s,u,n,d);for(let g of so){if(!c.size)break;await ba(g),c=await Io(i.late,n,c)}let m=t.filter(g=>!g.ok&&g.part.startsWith("state"));if(m.length||!h)return o(`${m.length?`${m.map(g=>g.part.replace("state: ","")).join(", ")} didn't come back.`:""}${h?"":" The app couldn't go back to its screen."}`.trim());if(r){if(!await gt(a))return o(`The app is back, but Buoy couldn't put your Network rules back. ${Sa}`);n("web calls",true,"Real web calls are back.")}x=null,fe=void 0,ne=[],Ue={};for(let g of[he.bugLinks.loaded(),Wt(),Vt()])await Te.removeItem(g).catch(()=>{});return ie(),t}function gn(){return Ve(async()=>{if(!await yt())return{ok:true,detail:$a};let e=x??await qt(),t=e?.undo.clock;if(t&&xe("clock")&&await(t.active&&t.virtualIso?Z("clock","setTime",{time:t.virtualIso,freeze:t.rate===0}).then(()=>t.rate&&t.rate!==1?Z("clock","setRate",{rate:t.rate}):void 0):Z("clock","reset")).catch(()=>{}),!!e&&Kt(e)&&!await gt(e.undo))return Ia(`The case is still loaded and web calls stay blocked. ${Sa}`);x=null,fe=void 0,ne=[],Ue={};for(let n of[he.bugLinks.loaded(),Wt(),Vt()])await Te.removeItem(n).catch(()=>{});return ie(),{ok:true}})}async function bd(e,t){try{let n=JSON.stringify({loadId:e,kase:t});if(n.length<=io)return{canLoadAgain:true,onDisk:await sa(Wt(),n)}}catch{}return await Te.removeItem(Wt()).catch(()=>{}),{canLoadAgain:false,onDisk:false}}async function Ke(){if(!x)return false;if(mt=await mn(x),!mt){let e=D()?globalThis.localStorage:void 0,t=null;try{t=e?e.getItem(he.bugLinks.loaded()):await Te.getItem(he.bugLinks.loaded())}catch{t=null}mt=!!t&&JSON.parse(t).loadId===x.loadId}return mt}var mt=true;function Kt(e){return e.phase==="loading"?e.block===true:e.options?.replay!==false&&!!e.report?.replay?.active}async function yt(){if(!x||!D()||!mt)return true;let e;try{let n=globalThis.localStorage;e=n?n.getItem(he.bugLinks.loaded()):await Te.getItem(he.bugLinks.loaded())}catch{return true}let t;if(e===null){if(!mt)return true}else{try{t=JSON.parse(e).loadId}catch{return true}if(t===x.loadId)return true}return x=null,fe=void 0,ne=[],Ue={},ie(),false}var $a="Another tab of this app already finished this bug case.";async function mn(e,t){let n=t??Kt(e);try{return await sa(he.bugLinks.loaded(),JSON.stringify({...e,block:n}))}catch{return false}}function So(){return typeof navigator<"u"&&navigator.product==="ReactNative"?false:typeof window<"u"&&typeof document<"u"}async function qt(){try{let e=await Te.getItem(he.bugLinks.loaded());return e?JSON.parse(e):null}catch{return null}}async function kd(){if(await Ve(async()=>{if(x)return false;let e=await qt();if(!e)return false;let t=await dn.getItem(cn()).catch(()=>null);return t&&(await dn.removeItem(cn()).catch(()=>{}),t===e.loadId)?(x=e,ie(),true):(x=e.undo?.undoId&&e.loadId?e:{...e,undoBlocked:true,undoGone:true},x.phase==="loading"&&(x={...x,notice:"This bug case didn't finish loading. Restore my app puts your app back the way it was."}),ie(),false)})&&await Nl(8e3)){let e=await wt().catch(t=>({loaded:false,steps:[{part:"app",ok:false,detail:t instanceof Error?t.message:String(t)}]}));if(!e.loaded&&x){let t=e.steps.find(n=>!n.ok)?.detail??"The case didn't load again after the restart.";await Ve(async()=>{await yt()&&await Ia(`${t} The app restarted with the case's saved state only.`)})}}return x}function wt(){return Ve(()=>vd())}async function vd(){let e=x??await qt();if(!e)throw new Error("No bug case is loaded. Open the bug link again.");if(!e.canLoadAgain)throw new Error("This case was too big to keep on the phone. Open the bug link again.");let t=null;try{t=JSON.parse(await Te.getItem(Wt())??"null")}catch{t=null}if(!t||t.loadId!==e.loadId)throw new Error("The saved case doesn't match the one loaded. Open the bug link again.");return x||(x=e,ie()),go(po(t.kase),{...e.options,source:e.source})}async function Aa(){if(!x?.report.replay?.active||!xe("network"))return[];try{let e=(await Z("network","listOverrideRules"))?.rules?.find(t=>t.name===to)?.id;return e?((await Dl("network"))?.events??[]).filter(t=>t.override?.ruleId===e).map(t=>({method:t.method??"GET",url:t.url??"",at:t.timestamp??0})).sort((t,n)=>n.at-t.at).slice(0,50):[]}catch{return[]}}import{bugLinkUrl as Id,captureBugCase as Sd,copyToClipboard as Td,lockBugCase as yn,base64UrlDecode as To,base64UrlEncode as Ea,scrubBugCase as xd,ScrubLimitError as $d,BugCaseLockError as xo,unlockBugCase as Ba,newCaseKeyParts as Ad,sealCard as $o,wrapCaseKey as Ao}from"@buoy-gg/shared-ui/web";import{base64UrlDecode as Ed,base64UrlEncode as Ca}from"@buoy-gg/shared-ui/web";var bt=["urgent","high","normal","low"];function Eo(e){let t={};return e?.card&&(t["X-Buoy-Card"]=e.card),e?.wrap&&(t["X-Buoy-Wrap"]=Ca(new TextEncoder().encode(e.wrap))),e?.cardRevision&&(t["X-Buoy-Card-Revision"]=String(e.cardRevision)),e?.owner&&(t["X-Buoy-Owner"]=e.owner),e?.priority&&e.priority!=="normal"&&(t["X-Buoy-Priority"]=e.priority),t}var B=class extends Error{constructor(e,t,n,a=false,r={}){super(t);this.code=e;this.status=n;this.retry=a;this.detail=r;this.name="BugLinksHttpError"}},Bo=3e4,Co=e=>/^[a-z][a-z0-9+.-]*:\/\/[^/?#]+/i.exec(e)?.[0].toLowerCase()??null;function Bd(e,t){let n=e?Co(e):null;return!!n&&n!==Co(t)}async function Oe(e,t,n,a){let r=Date.now()+Bo,o=typeof AbortController<"u"?new AbortController:null,i=o?setTimeout(()=>o.abort(),Bo):null,s=()=>o?.abort();a?.signal?.addEventListener?.("abort",s);let c,d;try{if(c=await Po(fetch(`${e.replace(/\/+$/,"")}${t}`,{...n,redirect:"error",signal:o?.signal,__buoyInternal:true}),r),c.redirected||Bd(c.url,e))throw new B("redirected","The bug links server sent this call somewhere else, so Buoy stopped.");let u=c.status,l=u===204||u===304?"":await Po(c.text(),r);d={status:u,ok:u>=200&&u<300,text:async()=>l,json:async()=>JSON.parse(l)}}catch(u){throw u instanceof B?u:a?.signal?.aborted?new B("cancelled","Cancelled."):new B("offline","Couldn't reach the bug links server. Buoy will try again.",void 0,true)}finally{i&&clearTimeout(i),a?.signal?.removeEventListener?.("abort",s)}return d}function Po(e,t){return new Promise((n,a)=>{let r=setTimeout(()=>a(new Error("timed out")),Math.max(0,t-Date.now()));e.then(o=>{clearTimeout(r),n(o)},o=>{clearTimeout(r),a(o)})})}async function Re(e){let t={};try{t=await e.json()}catch{}let n=typeof t.message=="string"?t.message:`The server said ${e.status}.`;throw e.status===401?new B("signed_out",n,401):e.status===402||t.error==="needs_pro"?new B("needs_pro",n,e.status):e.status===404?new B("not_found",n,404,false,t):e.status===410?new B("expired",n,410):e.status===413?new B("too_big",n,413):e.status===429?new B("rate_limited",n,429,true):e.status===409?new B(t.error==="team_changed"||t.error==="priority_set"?t.error:"conflict",n,409,false,t):new B("server",n,e.status,e.status>=500)}var Lo={"Content-Type":"text/plain","X-Buoy-Encoding":"base64url"};async function Cd(e,t,n,a={}){let r=await Oe(e,"/api/bugs",{method:"POST",headers:{...Lo,"X-Buoy-Auth":t,...a.uploadId?{"X-Buoy-Upload-Id":a.uploadId}:{},...a.editToken?{"X-Buoy-Edit-Token":a.editToken}:{},...Eo(a.extras)},body:Ca(n)},{signal:a.signal});if(r.status===404)throw new B("not_found",`${e} doesn't take bug links. Check the server in the Bug links screen.`,404);if(r.status!==201&&r.status!==200)return Re(r);let o=await r.json();if(typeof o.id!="string"||typeof o.editToken!="string")throw new B("server","The server's answer had no link id.",r.status,true);return{id:o.id,editToken:o.editToken,expiresAt:typeof o.expiresAt=="string"?o.expiresAt:null,cardRevision:typeof o.cardRevision=="number"?o.cardRevision:void 0,wrapStatus:typeof o.wrapStatus=="string"?o.wrapStatus:void 0,teamKeys:!!o.currentKey||o.teamKeys===true,owner:typeof o.owner=="string"&&o.owner?o.owner:void 0}}async function Pd(e,t,n,a,r){let o=await Oe(e,`/api/bugs/${encodeURIComponent(t)}`,{method:"PUT",headers:{...Lo,"X-Buoy-Edit-Token":n,...Eo(r)},body:Ca(a)});if(!o.ok)return Re(o);let i=await o.json().catch(()=>({}));return{expiresAt:typeof i.expiresAt=="string"?i.expiresAt:i.expiresAt===null?null:void 0,cardRevision:typeof i.cardRevision=="number"?i.cardRevision:void 0}}async function Ld(e,t,n,a,r){let o=await Oe(e,`/api/bugs/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-Buoy-Edit-Token":n},body:`{"wrap":${a},"caseTag":${JSON.stringify(r)}}`});if(!o.ok)return Re(o)}async function Od(e,t,n,a){let r=await Oe(e,`/api/bugs/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json","X-Buoy-Edit-Token":n},body:JSON.stringify({priority:a})});if(!r.ok)return Re(r)}async function at(e,t,n,a={}){let r={"X-Buoy-Auth":n};a.body!==void 0&&(r["Content-Type"]="application/json");let o=await Oe(e,t,{method:a.method??"GET",headers:r,...a.body!==void 0?{body:JSON.stringify(a.body)}:{}});return o.ok?o.status===204?{}:await o.json():Re(o)}async function Rd(e,t){let n=await Oe(e,"/api/bugs/team-key",{method:"GET",headers:{"X-Buoy-Auth":t}});return n.status===404?null:n.ok?n.json():Re(n)}async function Oo(e,t,n){let a={};n.editToken&&(a["X-Buoy-Edit-Token"]=n.editToken),n.credential&&(a["X-Buoy-Auth"]=n.credential);let r=await Oe(e,`/api/bugs/${encodeURIComponent(t)}`,{method:"DELETE",headers:a});if(!r.ok&&r.status!==404&&r.status!==410)return Re(r)}async function Pa(e,t,n){let a=await Oe(e,`/api/bugs?upload=${encodeURIComponent(t)}`,{method:"DELETE",headers:{"X-Buoy-Auth":n}});if(!a.ok&&a.status!==404)return Re(a)}async function Ro(e,t,n){let a=await Oe(e,`/api/bugs/${encodeURIComponent(t)}`,{method:"GET",headers:{"X-Buoy-Auth":n,Accept:"text/plain","X-Buoy-Encoding":"base64url"}});if(!a.ok)return Re(a);let r=Ed((await a.text()).trim());if(!r)throw new B("server","The server sent a case that isn't base64url.",a.status);return r}import*as Do from"@buoy-gg/license/web";import{base64UrlDecode as Dd}from"@buoy-gg/shared-ui/web";var La=null;function _d(e){La=e}function ee(){if(La)return La();try{let e=Do.SessionManager?.getAccessToken();if(e)return e}catch{}try{return Do.LicenseManager.getState().licenseKey??null}catch{return null}}function $e(e){if(!e)return null;let t=e.split(".");if(t.length===3)try{let n=Dd(t[1]),a="";if(n)for(let o=0;o<n.length;o++)a+=String.fromCharCode(n[o]);let r=JSON.parse(a).sub;if(typeof r=="string"&&r)return`sub:${_o(r)}`}catch{}return`key:${_o(e)}`}function _o(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t.toString(16).padStart(8,"0")}import{devToolsStorageKeys as No,getItemChecked as wn,persistentStorage as kt,setItemChecked as bn,storageIsMemoryOnly as Nd}from"@buoy-gg/shared-ui/web";import{BugCaseLockError as Mo}from"@buoy-gg/shared-ui/web";var Md=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function kn(){let e=globalThis;return typeof e.crypto?.getRandomValues=="function"?"getRandomValues":typeof e.expo?.uuidv4=="function"?"expo-uuid":null}var jo="This app has no safe random numbers, so Buoy can't lock a bug case. Add expo-modules-core (any Expo app has it), react-native-get-random-values or react-native-quick-crypto.";function Ft(e){let t=globalThis,n=kn();if(n==="getRandomValues")return t.crypto.getRandomValues(new Uint8Array(e));if(n==="expo-uuid")return jd(e,()=>t.expo.uuidv4());throw new Mo("no_crypto",jo)}function jd(e,t){let n=new Uint8Array(e),a=0,r=0,o=0,i="",s=(c,d)=>{for(r=r<<d|c,o+=d;o>=8&&a<e;)o-=8,n[a++]=r>>o&255;r&=(1<<o)-1};for(;a<e;){let c=String(t());if(!Md.test(c)||c===i)throw new Mo("no_crypto","Expo's UUID source gave a value that isn't a fresh v4 UUID.");i=c;let d=c.replace(/-/g,"");for(let u=0;u<32&&a<e;u++){if(u===12)continue;let l=parseInt(d[u],16);u===16?s(l&3,2):s(l,4)}}return n}var vn={strict:true},zd=50,zo=10,In=1e6,Wd=12,j=[],Sn=null,Ht=false,qe=new Map,Tn=new Set,Oa=new Set,vt=()=>No.bugLinks.links(),Vd="buoy-bug-links-links",Ae=e=>`${No.bugLinks.links()}_blob_${e}`;function Wo(e){let t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(n=>!!n&&typeof n=="object"&&typeof n.localId=="string"&&typeof n.key=="string"):[]}function Ra(e){try{return Wo(e)}catch{return e&&!Da&&(Da=true,kt.setItem(`${vt()}_broken`,e).catch(()=>{})),[]}}var Da=false;function Vo(e){if(Ht)return;let t=e.map(n=>n.status==="sending"?{...n,status:"waiting"}:n);j=[...j,...t.filter(n=>!j.some(a=>a.localId===n.localId))],Ht=true}var Ud=/^(bl_[a-z0-9]+_[a-z0-9]+)(?:_[a-z0-9]+_\d{1,2})?$/;async function Kd(){if(D()||!Ht||Da)return;let e=`${Ae("")}`,t;try{t=await kt.getAllKeys()}catch{return}for(let n of t){if(!Ht)return;if(!n.startsWith(e))continue;let a=Ud.exec(n.slice(e.length))?.[1];!a||j.some(r=>r.localId===a)||await kt.removeItem(n).catch(()=>{})}}function Fe(){return Sn||(Sn=(async()=>{try{Vo(Ra(await wn(vt()))),rt(Kd)}catch{Sn=null}Yt()})()),Sn}var De=new Set,xn=new Set;function Jt(e){return D()||!xn.has(e)&&!De.has(e)?Promise.resolve(true):rt(async()=>{if(await Nd())return true;if(De.has(e)){let t;try{t=Ra(await wn(vt())).some(n=>n.localId===e)}catch{return false}if(!t)return true}return Gt()})}var It=new Map;function _a(e){let t=It.get(e.localId);return t?{...e,...t,status:e.status==="deleting"?"deleting":t.status??e.status}:e}function Uo(e,t){It.set(e,{...It.get(e),...t}),j=j.map(_a),Yt()}function qd(e){return It.has(e)}function Fd(){return rt(()=>Gt())}async function Hd(){return Wo(await $n(vt()))}async function Ko(){let e=await Hd(),t=new Set(e.map(a=>a.localId)),n=j.filter(a=>De.has(a.localId)&&!t.has(a.localId));for(let a of t)De.delete(a);return[...n,...e]}var qo=Promise.resolve();function rt(e){let t=qo.catch(()=>{}).then(()=>Jd(e));return qo=t.catch(()=>{}),t}function Jd(e){return un(Vd,async()=>{if(await Fe(),D())try{j=(await Ko()).map(_a)}catch(t){if(globalThis.localStorage)throw t}return e()})}function _e(e){return De.has(e)}async function Fo(){await rt(async()=>Yt())}function St(){return j}function Gd(e){return e.status!=="sent"||e.needsPut?true:Tn.has(e.localId)?false:j.filter(t=>t.status==="sent"&&!t.needsPut).findIndex(t=>t.localId===e.localId)<zo}function R(e){return j.find(t=>t.localId===e)}function Na(e){return Oa.add(e),()=>Oa.delete(e)}function Yd(e,t){return rt(async()=>{j=[e,...j.filter(r=>r.localId!==e.localId)],De.add(e.localId);let n=await Ma(e.localId,t,e.blobVersion??0),a=await Gt();return n&&a})}function _(e,t){return rt(async()=>{if(typeof t=="function"){let o=j.find(s=>s.localId===e),i=o?t(o):null;if(!i)return o;t=i}let n=t,a;j=j.map(o=>o.localId===e?a={...o,...n,...o.status==="deleting"?{status:"deleting"}:{}}:o);let r=await Gt();return!r&&!D()&&xn.add(e),r||!D()?a:R(e)})}function Ho(e){return rt(async()=>{let t=j.findIndex(a=>a.localId===e),n=j[t];return j=j.filter(a=>a.localId!==e),await Gt()?(De.delete(e),It.delete(e),await ja(e),true):(n&&!D()&&!R(e)&&(j=[...j.slice(0,t),n,...j.slice(t)],xn.add(e),Yt()),false)})}async function $n(e){let t=D()?globalThis.localStorage:void 0;return t?t.getItem(e):kt.getItem(e)}async function Jo(e){let t=qe.get(e),n=j.find(s=>s.localId===e);if(t&&(!n||t.version===(n.blobVersion??0)))return t.blob;let a=s=>D()?$n(s):wn(s),r=await a(Ae(e)),o=r?/^chunks:(\d{1,2}):([a-z0-9]+)$/.exec(r):null;if(!o)return r;let i=[];for(let s=0;s<Number(o[1]);s++){let c=await a(`${Ae(e)}_${o[2]}_${s}`);if(c===null)return null;i.push(c)}return i.join("")}var Xd=0;function Zd(){try{return Array.from(Ft(6),e=>e.toString(36).padStart(2,"0")).join("")}catch{return`${Date.now().toString(36)}${(++Xd).toString(36)}`}}async function Ma(e,t,n=0){let a=qe.get(e),r=await Qd(e,t,n);return!r&&D()&&!De.has(e)&&(a?qe.set(e,a):qe.delete(e)),r}async function Qd(e,t,n){qe.set(e,{version:n,blob:t}),Tn.delete(e);try{let a=await $n(Ae(e)).catch(()=>null);if(t.length<=In)return await bn(Ae(e),t,vn)?(qe.delete(e),await An(e,a),true):false;let r=Math.ceil(t.length/In);if(r>Wd)return false;let o=Zd();try{for(let i=0;i<r;i++)if(!await bn(`${Ae(e)}_${o}_${i}`,t.slice(i*In,(i+1)*In),vn))throw new Error("not saved");if(!await bn(Ae(e),`chunks:${r}:${o}`,vn))throw new Error("not saved")}catch{return await An(e,`chunks:${r}:${o}`),false}return qe.delete(e),await An(e,a),true}catch{return false}}async function An(e,t){let n=t?/^chunks:(\d{1,2}):([a-z0-9]+)$/.exec(t):null;if(n)for(let a=0;a<Number(n[1]);a++)await kt.removeItem(`${Ae(e)}_${n[2]}_${a}`).catch(()=>{})}async function ja(e){qe.delete(e);let t=await $n(Ae(e)).catch(()=>null);await kt.removeItem(Ae(e)).catch(()=>{}),await An(e,t)}async function Gt(){let e=j,t=[];for(;e.length>zd;){let a=e.map(o=>o.status==="sent"&&!o.needsPut&&!o.wrapPending&&!o.priorityPending).lastIndexOf(true);if(a<0)break;let r=e[a].localId;t.push(r),e=e.filter(o=>o.localId!==r)}let n=true;try{if(!Ht&&!D()){let a=new Set(j.map(r=>r.localId));Vo(Ra(await wn(vt()))),e=[...e,...j.filter(r=>!a.has(r.localId))]}n=await bn(vt(),JSON.stringify(e),vn)}catch{n=false}if(n){De.clear(),xn.clear(),It.clear(),j=j.filter(r=>!t.includes(r.localId));for(let r of t)await ja(r);let a=e.filter(r=>r.status==="sent"&&!r.needsPut);for(let r of a.slice(zo))Tn.has(r.localId)||(Tn.add(r.localId),await ja(r.localId))}else if(D())try{j=(await Ko()).map(_a)}catch{}return Yt(),n}function Yt(){for(let e of Oa)e()}import{gcm as En}from"@noble/ciphers/aes";import{p256 as Tt}from"@noble/curves/nist";import{hmac as eu}from"@noble/hashes/hmac";import{sha256 as Go}from"@noble/hashes/sha2";import{Gunzip as tu,gzipSync as nu}from"fflate";import{BugCaseLockError as Yo,webCaseCrypto as au,webTeamKeyCrypto as ru}from"@buoy-gg/shared-ui/web";function Xo(){return{randomBytes:Ft,seal:async(e,t,n,a)=>En(e,t,a).encrypt(n),open:async(e,t,n,a)=>En(e,t,a).decrypt(n),gzip:async e=>nu(e,{level:6}),gunzip:async(e,t)=>iu(e,t)}}function Ne(){try{return au()}catch{return Xo()}}function ou(){return{randomBytes:Ft,sha256:async e=>Go(e),hmacSha256:async(e,t)=>eu(Go,e.length?e:new Uint8Array(32),t),seal:async(e,t,n,a)=>En(e,t,a).encrypt(n),open:async(e,t,n,a)=>En(e,t,a).decrypt(n),p256Generate:async()=>{let e=Tt.utils.randomSecretKey(Ft(48));return{d:e,pub:Tt.getPublicKey(e,false)}},p256Ecdh:async(e,t)=>{if(!Tt.utils.isValidPublicKey(t,false))throw new Error("That public key isn't on the curve.");return Tt.getSharedSecret(e.d,t,true).slice(1)},p256Sign:async(e,t)=>{let n=Tt.sign(t,e.d,{prehash:true,lowS:false});return n instanceof Uint8Array?n:n.toCompactRawBytes()},p256Verify:async(e,t,n)=>Tt.verify(n,t,e,{prehash:true,lowS:false})}}function He(){try{return ru()}catch{return ou()}}function iu(e,t){let n=[],a=0,r=false,o=new tu((d,u)=>{if(a+=d.length,a>t)throw new Yo("too_big",`This case unzips past ${t} bytes.`);n.push(d),u&&(r=true)}),i=64*1024;for(let d=0;d<e.length;d+=i)o.push(e.subarray(d,d+i),d+i>=e.length);if(!r)throw new Yo("bad_blob","This case ended before it finished unzipping.");let s=new Uint8Array(a),c=0;for(let d of n)s.set(d,c),c+=d.length;return s}import{base64UrlDecode as su,devToolsStorageKeys as lu,getItemChecked as du,setItemChecked as Zo,verifyRecord as uu}from"@buoy-gg/shared-ui/web";import{devToolsStorageKeys as Qo,getItemChecked as cu,setItemChecked as pu}from"@buoy-gg/shared-ui/web";var xt="#1F1F1F";var Bn="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",ei="[data-buoy-root],[data-buoy-mount],[data-buoy-portal-host],[id='floating-devtools-root'],[id='dial-devtools-root'],[id='buoy-tool-host']",hu="[id='dial-devtools-root'],[id='buoy-tool-host'],[role='dialog'][aria-label='Dial Menu']",fu="[id='buoy-mask'],[data-buoy-mask],.buoy-mask,.sentry-mask,.sentry-block,.sentry-react-native-mask,[data-sentry-mask]",za="[id='buoy-unmask'],[data-buoy-unmask],.buoy-unmask,.sentry-unmask,.sentry-react-native-unmask",gu=new Set(["sentry-react-native-mask","sentry-react-native-unmask"]),mu=new Set(["checkbox","radio","range","color","file","hidden"]),yu=new Set(["button","submit","reset"]),ti=/(^|\s)(current-password|new-password|one-time-code|cc-[a-z-]+)(\s|$)/i,ni=new Set(["IMG","PICTURE","VIDEO","CANVAS","svg","SVG","OBJECT","EMBED"]),wu=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","TEXTAREA","SELECT"]),bu=new Set(["TITLE","DESC","STYLE","SCRIPT","METADATA"]),Je=e=>(e.localName||e.tagName).toUpperCase(),Wa="http://www.w3.org/2000/svg",Va=12,Ge=()=>typeof performance<"u"&&performance.timeOrigin?performance.timeOrigin+performance.now():Date.now(),Me=class extends Error{},ai=e=>e.replace(/\S/g,"n"),ri=[["background",xt],["background-image","none"],["color","transparent"],["-webkit-text-fill-color","transparent"],["border-color",xt],["box-shadow","none"],["text-shadow","none"],["outline","none"],["filter","none"],["opacity","1"]];function ku(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|Va);for(let n=t.nextNode();n;n=t.nextNode()){if(n.nodeType===Node.TEXT_NODE||n.nodeType===Node.CDATA_SECTION_NODE){n.data=ai(n.data);continue}let a=n;a.style?.setProperty("visibility","hidden","important"),oi(a)}}function oi(e){for(let n of["srcset","poster","placeholder","title","href","xlink:href"])e.removeAttribute(n);let t=Je(e);t==="IMG"||t==="IMAGE"?(e.setAttribute("src",Bn),e.setAttribute("alt","")):t==="INPUT"?(e.setAttribute("value",""),e.removeAttribute("src")):(t==="TEXTAREA"||t==="OPTION")&&(e.textContent="")}function Ua(e,t,n){if(!e||!(e.width>0)||!(e.height>0))return null;let a=Math.max(0,Math.floor(e.left-2)),r=Math.max(0,Math.floor(e.top-2)),o=Math.min(t,Math.ceil(e.right+2)),i=Math.min(n,Math.ceil(e.bottom+2));return o>a&&i>r?{x:a,y:r,width:o-a,height:i-r}:null}function ii(e,t){for(let n=e;n;n=n.parentElement){let a=n.getAttribute("data-testid");if(a){if(n===e)return a;let r=n.getBoundingClientRect();return t.width*t.height>=r.width*r.height*.8?a:""}}return""}function vu(e){let t=Je(e);if(t==="INPUT"){let a=e,r=(a.type||"text").toLowerCase();return r==="password"||ti.test(a.autocomplete??"")?"secure":r==="image"?"image":yu.has(r)?"text":mu.has(r)?"none":"input"}if(t==="TEXTAREA"||t==="SELECT")return ti.test(e.autocomplete??"")?"secure":"input";if(e.isContentEditable&&!e.parentElement?.isContentEditable)return"input";if(t==="IFRAME"||t==="FRAME")return"web";if(ni.has(t)||e.getAttribute("role")==="img")return"image";let n=e.style?.backgroundImage;return n&&n.includes("url(")?"image":"none"}function Iu(e){let t=Array.from(e.classList).find(a=>gu.has(a)),n=e.parentElement;return t&&n&&n.childElementCount===1?n:e}function Ka(e){return e.replace(/\\\r?\n/g,"").replace(/\\([0-9a-f]{1,6})\s?/gi,(t,n)=>{let a=parseInt(n,16);return a>0&&a<=1114111?String.fromCodePoint(a):"\uFFFD"}).replace(/\\(.)/g,"$1")}var qa=e=>/^\s*data:/i.test(e),Su=/@font-face\s*\{[^}]*\}/gi;function Fa(e){return/data|\\/i.test(e)?(Ka(e).match(/data:[^,]*/gi)??[]).some(t=>qa(t)):false}function si(e){let t="";for(let n=0;n<e.length;n++){let a=e[n],r=e.getPropertyValue(a);if(Fa(r))continue;let o=e.getPropertyPriority(a);t+=`${a}: ${r}${o?" !important":""}; `}return t}function li(e){let t=e.cssText;if(!Fa(t))return t;let n=e;if(e.type===5||/^\s*@font-face\b/i.test(t))return t;let a=r=>{let o="";for(let i=0;r&&i<r.length;i++)o+=li(r[i])+`
3
+ `;return o};return n.style&&n.selectorText!==void 0?`${n.selectorText} { ${si(n.style)}${a(n.cssRules)}}`:n.cssRules&&t.includes("{")?`${t.slice(0,t.indexOf("{"))}{
4
+ ${a(n.cssRules)}}`:""}function di(e){let t=[],n=e.replace(Su,a=>`/*__buoy_font_${t.push(a)-1}__*/`);return Tu(n).replace(/\/\*__buoy_font_(\d+)__\*\//g,(a,r)=>t[Number(r)]??"")}function Tu(e){return e.replace(/(["'])((?:(?!\1)[^\\]|\\[\s\S])*)\1/g,(t,n,a)=>qa(Ka(a))?'""':t).replace(/url\(\s*((?:[^"'\s)\\]|\\[\s\S])(?:[^)\\]|\\[\s\S])*)\)/gi,(t,n)=>qa(Ka(n.trim()))?"none":t)}function xu(e){let t=[...Array.from(document.styleSheets),...document.adoptedStyleSheets??[]],n="";for(let a of t){let r=null;try{r=a.disabled?null:a.cssRules}catch{r=null}if(!r)continue;let o="";for(let s=0;s<r.length;s++)o+=(e?li(r[s]):r[s].cssText)+`
5
+ `;let i=a.media?.mediaText;n+=i&&i!=="all"?`@media ${i} {
6
+ ${o}}
7
+ `:o}return e&&(n=di(n)),n}var ke=":not(#_bq1#_bq2#_bq3#_bq4#_bq5#_bq6)",ui="__buoy_mask",Ha=e=>`${e}::before, ${e}::after, ${e}::marker`,$u=e=>`
8
+ head${ke}, head${ke} * { display: none !important; }
9
+ .__buoy_box${ke} { background: ${xt} !important; background-image: none !important; color: transparent !important; -webkit-text-fill-color: transparent !important; border-color: ${xt} !important; box-shadow: none !important; text-shadow: none !important; outline: none !important; caret-color: transparent !important; filter: none !important; opacity: 1 !important; mask: none !important; -webkit-mask: none !important; }
10
+ .__buoy_box${ke} *${ke} { visibility: hidden !important; }
11
+ ${Ha(`.__buoy_box${ke}`)}, ${Ha(`.__buoy_box${ke} *${ke}`)} { content: none !important; visibility: hidden !important; }
12
+ .__buoy_box${ke}::placeholder { color: transparent !important; }
13
+ .__buoy_text${ke} { background: ${xt} !important; color: transparent !important; -webkit-text-fill-color: transparent !important; text-shadow: none !important; border-radius: 0 !important; }
14
+ ${e.text?`${Ha(`*${ke}`)} { content: none !important; color: transparent !important; -webkit-text-fill-color: transparent !important; text-shadow: none !important; }`:""}
15
+ `;function Au(e){let t=e.checkVisibility;if(typeof t=="function")return t.call(e,{visibilityProperty:true});try{return getComputedStyle(e).visibility!=="hidden"}catch{return true}}var Cn=new Map;function ci(e=window.innerWidth,t=window.innerHeight){let n=a=>a.getClientRects().length>0&&!!Ua(a.getBoundingClientRect(),e,t);if(Array.from(document.querySelectorAll(hu)).some(n))return true;for(let a of Array.from(document.querySelectorAll("[data-buoy-portal-host]")))for(let r of Array.from(a.querySelectorAll("*"))){let o=r.getBoundingClientRect();if(o.width*o.height>=e*t*.2&&n(r)&&getComputedStyle(r).pointerEvents!=="none")return true}return false}function pi(e){let t=e.currentSrc||e.src;if(!t)return null;if(t.startsWith("data:image/"))return t;let n=Cn.get(t);if(n!==void 0)return n;if(!e.complete||!e.naturalWidth)return null;let a=null;try{let r=document.createElement("canvas");r.width=Math.min(e.naturalWidth,1024),r.height=Math.round(e.naturalHeight/e.naturalWidth*r.width),r.getContext("2d").drawImage(e,0,0,r.width,r.height),a=r.toDataURL("image/png")}catch{a=null}return Cn.size>200&&Cn.clear(),Cn.set(t,a),a}function hi(e,t=false){let n=performance.now(),a=document.documentElement.clientWidth||window.innerWidth,r=window.innerHeight||document.documentElement.clientHeight;if(!(a>0)||!(r>0)||!document.body)throw new Me("no page to draw");let o=ci(a,r),i=document.documentElement,s=document.implementation.createHTMLDocument("").importNode(i,true),c=[i,...Array.from(i.querySelectorAll("*"))],d=[s,...Array.from(s.querySelectorAll("*"))];if(c.length!==d.length)throw new Me("the page changed while it was copied");let u=[],l=document.createTreeWalker(i,Va),h=document.createTreeWalker(s,Va);for(let v=l.nextNode(),b=h.nextNode();v&&b;v=l.nextNode(),b=h.nextNode())v.data.trim()&&u.push([v,b]);let m=[],g=[],k=[],f=new Set,p=new Set,y=0,w=(v,b)=>{v&&(m.push(v),t&&g.push({testID:ii(b,v),x:v.x,y:v.y,w:v.width,h:v.height}))},$=(v,b)=>{f.add(v);let I=Au(v)?Ua(v.getBoundingClientRect(),a,r):null;I&&y++,w(I,v),b.classList.add("__buoy_box");for(let[z,U]of ri)b.style?.setProperty(z,U,"important");if(oi(b),ku(b),/^(VIDEO|CANVAS|IFRAME|FRAME|OBJECT|EMBED)$/.test(Je(b))){let z=v.getBoundingClientRect(),U=document.createElement("div");U.className=`${b.getAttribute("class")??""} __buoy_box`,U.setAttribute("style",`${b.getAttribute("style")??""};width:${z.width}px;height:${z.height}px;display:${getComputedStyle(v).display==="inline"?"inline-block":getComputedStyle(v).display}`),b.replaceWith(U)}},A=(v,b)=>{for(let I=v.parentElement;I;I=I.parentElement)if(b.has(I))return true;return false};for(let v=0;v<c.length;v++){let b=c[v],I=d[v];if(b.matches(ei)){p.add(b),k.push(I);continue}if(p.size&&A(b,p)||f.size&&A(b,f))continue;let z=Je(b);if(z==="SOURCE"){I.removeAttribute("srcset"),I.removeAttribute("src");continue}if(z==="SCRIPT"||z==="NOSCRIPT"||z==="LINK"&&/stylesheet|preload|modulepreload/i.test(b.getAttribute("rel")??"")||z==="STYLE"){k.push(I);continue}if(e.images){I.removeAttribute("background");let L=I.getAttribute("style");if(L&&Fa(L)){let W=b.style;I.setAttribute("style",W?si(W):di(L))}}if(b.matches(fu)){let L=Iu(b),W=L===b?v:c.lastIndexOf(L,v);W>=0&&!f.has(L)&&$(L,d[W]),f.has(b)||f.add(b);continue}if(z==="INPUT"){let L=b,W=(L.type||"").toLowerCase();W==="checkbox"||W==="radio"?L.checked?I.setAttribute("checked",""):I.removeAttribute("checked"):(W==="range"||W==="color")&&I.setAttribute("value",L.value)}let U=vu(b);if(U==="image"&&!ni.has(z)&&b.getAttribute("role")!=="img"&&Array.from(b.children).some(L=>Je(L)!=="IMG")&&(e.images&&!b.closest(za)&&I.style.setProperty("background-image","none","important"),U="none"),U==="none")continue;let Pe=U!=="secure"&&b.closest(za)!==null;if(U==="secure"||U==="input"&&e.inputs&&!Pe||U==="text"&&e.text&&!Pe||U==="image"&&e.images&&!Pe||U==="web"&&!Pe){$(b,I);continue}if(z==="INPUT"&&b.type==="image")I.setAttribute("src",Bn),I.setAttribute("alt","");else if(z==="INPUT")I.setAttribute("value",b.value);else if(z==="TEXTAREA")I.textContent=b.value;else if(z==="SELECT"){let L=b;Array.from(I.querySelectorAll("option")).forEach((W,bs)=>L.options[bs]?.selected?W.setAttribute("selected",""):W.removeAttribute("selected"))}else if(z==="IMG"){let L=pi(b);I.removeAttribute("srcset"),I.setAttribute("alt",""),I.setAttribute("src",L??Bn)}else if(z==="CANVAS"){let L=null;try{L=b.toDataURL("image/png")}catch{L=null}let W=document.createElement("img");W.setAttribute("src",L??Bn),W.setAttribute("style",`${I.getAttribute("style")??""};width:${b.clientWidth}px;height:${b.clientHeight}px`),W.className=I.getAttribute("class")??"",I.replaceWith(W)}else if(U==="image"&&b.style.backgroundImage.includes("url(")){let L=b.querySelector("img"),W=L?pi(L):null;I.style.backgroundImage=W?`url("${W}")`:"none"}}let P=new Set;for(let[v,b]of u){let I=v.parentElement;if(!I||wu.has(Je(I))||I.closest("head")||I.namespaceURI===Wa&&bu.has(Je(I))||Je(I)==="OPTION"&&I.closest("select")||p.size&&(p.has(I)||A(I,p))||f.has(I)||f.size&&A(I,f)||!e.text||I.closest(za))continue;if(I.namespaceURI===Wa){let L=I;for(;L.parentElement&&L.parentElement.namespaceURI===Wa;)L=L.parentElement;let W=c.indexOf(L);W>=0&&!f.has(L)&&$(L,d[W]);continue}let z=document.createRange();z.selectNodeContents(v);let U=Ua(z.getBoundingClientRect?.(),a,r);U&&(m.push(U),t&&!P.has(I)&&g.push({testID:ii(I,U),x:U.x,y:U.y,w:U.width,h:U.height})),U&&!P.has(I)&&(P.add(I),y++);let Pe=document.createElement("span");Pe.className="__buoy_text";for(let[L,W]of ri)Pe.style.setProperty(L,W,"important");b.data=ai(b.data),b.replaceWith(Pe),Pe.appendChild(b)}for(let v=0;v<c.length;v++){let b=c[v];if(!(b===i||b===document.body)&&(b.scrollTop||b.scrollLeft)&&!p.has(b))for(let I of Array.from(d[v].children)){let z=I.style;z&&z.setProperty("translate",`${-b.scrollLeft}px ${-b.scrollTop}px`)}}let N=window.scrollX,te=window.scrollY;if(N||te){let v=d[c.indexOf(document.body)];v&&v.style.setProperty("translate",`${-N}px ${-te}px`);let b=document.body.getBoundingClientRect();for(let I=0;I<c.length;I++){let z=c[I];!(z instanceof HTMLElement)||!document.body.contains(z)||p.has(z)||getComputedStyle(z).position==="fixed"&&d[I].style.setProperty("translate",`${N-(b.left+N)}px ${te-(b.top+te)}px`)}}for(let v of k)v.remove();let F=s.querySelector("head")??s.insertBefore(document.createElement("head"),s.firstChild);for(;F.firstChild;)F.removeChild(F.firstChild);for(let v of Array.from(s.querySelectorAll("head")))v!==F&&v.remove();F.setAttribute("style","display: none !important");let M=document.createElement("style");M.textContent=`@layer ${ui};
16
+ ${xu(e.images)}
17
+ @layer ${ui} {${$u(e)}}`,F.appendChild(M),s.style.setProperty("overflow","hidden"),s.style.setProperty("width",`${a}px`),s.style.setProperty("height",`${r}px`);let T=new XMLSerializer().serializeToString(s);return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${r}"><foreignObject x="0" y="0" width="${a}" height="${r}">${T}</foreignObject></svg>`,w:a,h:r,rects:m,parts:g,boxes:y,buoyOpen:o,mainMs:performance.now()-n}}var Eu=5e3;function fi(e){let t,n=new Promise((a,r)=>{t=setTimeout(()=>r(new Me("the picture took too long")),Eu)});return Promise.race([Bu(e),n]).finally(()=>clearTimeout(t))}async function Bu(e){let t=Math.min(1,1280/Math.max(e.w,e.h)),n=new Image;n.decoding="async";let a=new Promise((l,h)=>{n.onload=()=>l(),n.onerror=()=>h(new Me("the browser couldn't draw the page"))});n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e.svg)}`,await a;let r=document.createElement("canvas");r.width=Math.max(1,Math.round(e.w*t)),r.height=Math.max(1,Math.round(e.h*t));let o=r.getContext("2d");if(!o)throw new Me("no canvas in this browser");let i=performance.now();o.fillStyle="#ffffff",o.fillRect(0,0,r.width,r.height),o.drawImage(n,0,0,r.width,r.height),o.fillStyle=xt;for(let l of e.rects)o.fillRect(l.x*t,l.y*t,l.width*t,l.height*t);let s=performance.now()-i,c;try{c=await new Promise(l=>r.toBlob(l,"image/jpeg",.6))}catch{throw new Me("this browser can't take pictures of pages")}if(!c)throw new Me("couldn't make the picture");let d=new Uint8Array(await c.arrayBuffer()),u="";for(let l=0;l<d.length;l+=32768)u+=String.fromCharCode(...d.subarray(l,l+32768));return{jpeg:btoa(u),mainMs:s}}var Cu=class{constructor(){this.enabled=false;this.pictures=true;this.customer=false;this.masks={text:true,images:true,inputs:true};this.videoFps=2;this.taps=[];this.video=[];this.last=null;this.marks=[];this.dropped={};this.frozen=false;this.busy=false;this.run=0;this.slowInRow=0;this.stoppedReason=null;this.lastReason=null;this.buttonLastT=null;this.downOnBuoy=false;this.tapTimer=null;this.videoTimer=null;this.videoOn=false;this.videoAlways=false;this.videoUntil=0;this.listening=false;this.inflight=null;this.pendingLast=null;this.easeUntil=0;this.onDown=e=>{if(this.downOnBuoy=false,!(e.target instanceof Element?e.target:null)?.closest(ei)||(this.downOnBuoy=true,!this.enabled||this.frozen))return;this.tapTimer&&(clearTimeout(this.tapTimer),this.tapTimer=null);let t=a=>{a&&(this.buttonLastT=this.last?.t??null)};if(!this.busy){this.take("last").then(t);return}let n=(this.inflight??Promise.resolve(true)).catch(()=>false).then(()=>this.take("last")).then(t).finally(()=>{this.pendingLast===n&&(this.pendingLast=null)});this.pendingLast=n};this.onUp=()=>{if(this.downOnBuoy){this.downOnBuoy=false;return}!this.enabled||!this.pictures||this.customer||this.frozen||this.stoppedReason||(this.tapTimer&&clearTimeout(this.tapTimer),this.tapTimer=setTimeout(()=>{this.tapTimer=null,this.take("tap")},300))}}configure(e={}){this.pictures=e.pictures!==false,this.customer=e.mode==="customer",this.masks={text:e.maskAllText!==false,images:e.maskAllImages!==false,inputs:e.maskAllInputs!==false},typeof e.videoFps=="number"&&e.videoFps>0&&(this.videoFps=Math.min(e.videoFps,10)),this.enabled=true,this.listen(),e.video==="always"&&!this.customer?this.startVideo(true):(this.videoAlways||e.video==="off"||this.customer)&&this.stopVideo()}async status(){return{available:true,enabled:this.enabled,mode:this.customer?"customer":"internal",stopped:this.stoppedReason}}listen(){this.listening||typeof document>"u"||(this.listening=true,document.addEventListener("pointerdown",this.onDown,{capture:true,passive:true}),document.addEventListener("pointerup",this.onUp,{capture:true,passive:true}))}startVideo(e){!this.enabled||this.customer||(this.videoOn=true,this.videoAlways=e,e||(this.video=[],this.marks=[]),this.videoUntil=e?1/0:Ge()+6e4,this.videoTimer&&clearInterval(this.videoTimer),this.videoTimer=setInterval(()=>{if(Ge()>this.videoUntil)return this.stopVideo();this.videoOn&&!this.frozen&&!this.stoppedReason&&!this.busy&&this.take("video")},1e3/this.videoFps))}stopVideo(){this.videoOn=false,this.videoAlways=false,this.videoTimer&&clearInterval(this.videoTimer),this.videoTimer=null}mark(){this.videoOn&&this.marks.push(Ge())}async captureLast(){for(let n=0;n<3&&(this.pendingLast||this.inflight);n++)await this.pendingLast?.catch(()=>false),await this.inflight?.catch(()=>false);let e=this.buttonLastT;if(e!==null&&this.last?.t===e&&Ge()-e<1e4)return{ok:true,reason:null};let t=await this.take("last");return{ok:t,reason:t?null:this.lastReason??"no frame"}}async takeMedia(){return this.frozen=true,{frames:[...this.last?[this.last]:[],...this.taps,...this.video].sort((e,t)=>e.t-t.t).map(e=>({...e})),marks:[...this.marks],dropped:Object.values(this.dropped).reduce((e,t)=>e+t,0),reasons:{...this.dropped},stopped:this.stoppedReason,lastAgeMs:this.last?Ge()-this.last.t:null,settings:{maskAllText:this.masks.text,maskAllImages:this.masks.images,maskAllInputs:this.masks.inputs}}}resume(){this.frozen=false}clear(){this.run++,this.busy=false,this.tapTimer&&clearTimeout(this.tapTimer),this.tapTimer=null,this.inflight=null,this.pendingLast=null,this.taps=[],this.video=[],this.last=null,this.marks=[],this.dropped={},this.frozen=false,this.buttonLastT=null}stopAll(){this.run++,this.stopVideo(),this.tapTimer&&clearTimeout(this.tapTimer),this.tapTimer=null,this.listening&&(document.removeEventListener("pointerdown",this.onDown,{capture:true}),document.removeEventListener("pointerup",this.onUp,{capture:true}),this.listening=false),this.busy=false,this.enabled=false}async probe(){let e=null,t=null;try{e=hi(this.masks,true)}catch(n){t=n instanceof Error?n.message:String(n)}if(!e)return{ok:false,reason:t,failed:t,parts:[],buoyOpen:false,jpeg:null,w:0,h:0};try{let{jpeg:n}=await fi(e);return{ok:true,reason:null,failed:null,parts:e.parts,buoyOpen:e.buoyOpen,jpeg:n,w:e.w,h:e.h}}catch(n){return{ok:false,reason:n instanceof Error?n.message:String(n),failed:null,parts:e.parts,buoyOpen:e.buoyOpen,jpeg:null,w:e.w,h:e.h}}}drop(e){this.dropped[e]=(this.dropped[e]??0)+1,this.lastReason=e}take(e){let t=this.busy,n=this.makeFrame(e);if(!t&&this.busy){let a=n.finally(()=>{this.inflight===a&&(this.inflight=null)});this.inflight=a}return n}async makeFrame(e){if(!this.enabled||typeof document>"u"||e!=="last"&&this.frozen||e==="tap"&&(this.customer||!this.pictures))return false;if(this.busy)return this.drop("busy"),false;if(document.visibilityState==="hidden")return this.drop("app in background"),false;if(e!=="last"&&ci())return this.drop("a Buoy screen was open"),false;if(e!=="last"&&Ge()<this.easeUntil)return this.drop("skipped to keep the page fast"),false;let t=this.run;this.busy=true;let n;try{n=hi(this.masks)}catch(i){return this.busy=false,this.drop(i instanceof Me?i.message:"the page couldn't be checked"),false}if(n.buoyOpen&&e!=="last")return this.busy=false,this.drop("a Buoy screen was open"),false;let a=Ge(),r,o=0;try{({jpeg:r,mainMs:o}=await fi(n))}catch(i){return t===this.run&&(this.busy=false,this.drop(i instanceof Me?i.message:"couldn't make the picture")),false}return t!==this.run||(this.busy=false,this.noteSpeed(n.mainMs+o),this.frozen)?false:(this.keep({t:a,kind:e,w:n.w,h:n.h,jpeg:r,boxes:n.boxes}),true)}noteSpeed(e){if(e>100&&(this.easeUntil=Ge()+e*4),e<=250){this.slowInRow=0;return}++this.slowInRow>=3&&!this.stoppedReason&&(this.stoppedReason="Pictures stopped: each one took too long on this page.",this.stopVideo())}keep(e){if(e.kind==="last")this.last=e;else if(e.kind==="tap")this.taps.push(e),this.taps.length>10&&this.taps.shift();else{this.video.push(e);let t=e.t-(this.videoAlways?3e4:6e4),n=this.video.reduce((a,r)=>a+r.jpeg.length,0);for(;this.video.length&&(this.video[0].t<t||n>6291456*4/3);)n-=this.video.shift().jpeg.length}}};var Pn;function Pu(){if(!(typeof document>"u"||typeof window>"u")){if(!Pn){Pn=new Cu;let e=globalThis;if(e.__BUOY_E2E__===true){let t=Pn;e.__BUOY_FRAMES_TEST__={probe:()=>t.probe(),configure:n=>t.configure(n),takeMedia:()=>t.takeMedia(),resume:()=>t.resume()}}}return Pn}}import{addDroppedWhy as Ja,describeDroppedWhy as Lu,DROPPED_TO_FIT as gi,fitBugCaseMedia as Ou,validateBugCaseMedia as Ru}from"@buoy-gg/shared-ui/web";var mi=null,se=(()=>{try{return Pu()}catch(e){mi=e instanceof Error?e.message:String(e);return}})(),Y={},yi=false;function Ga(){return mi?"Pictures failed to load on this build.":se?null:dt.OS==="web"?"No pictures here: this page has no window to draw.":dt.OS!=="ios"&&dt.OS!=="android"?"No pictures on this platform yet.":"Pictures need a dev build."}function Ya(e={}){let t=Y;Y={...Y,...e};let n=["maskAllText","maskAllImages","maskAllInputs"].some(r=>t[r]===false&&Y[r]!==false);if(yi=true,!se)return;let a=Y.pictures!==false||Y.video!=="off";try{se.configure({pictures:Y.pictures!==false,video:Y.video??"manual",maskAllText:Y.maskAllText!==false,maskAllImages:Y.maskAllImages!==false,maskAllInputs:Y.maskAllInputs!==false,mode:Y.mode==="customer"?"customer":"internal"}),(Y.video==="off"||Y.mode==="customer")&&se.stopVideo(),(!a||n||t.mode!=="customer"&&Y.mode==="customer")&&se.clear()}catch{}}function Du(){yi||Ya()}function _u(){Y.video!=="off"&&Y.mode!=="customer"&&se?.startVideo(false)}function Nu(){se?.stopVideo()}function Mu(){se?.mark()}function ju(){try{se?.resume()}catch{}}function zu(){return se?se.probe():Promise.resolve({ok:false,reason:Ga()})}async function Wu(e){let t=Ga();if(t)return Ye(e,t);if(Y.pictures===false&&Y.video==="off")return e;let n,a=null;try{a=await vi(se.captureLast(),ki).catch(p=>({ok:false,reason:p instanceof Error?p.message:String(p)})),n=await vi(se.takeMedia(),ki)}catch(p){return Ye(e,`Pictures failed: ${p instanceof Error?p.message:String(p)}`)}let r=e.clock?.active?e.clock.offsetMs??0:0,o=e.touches.filter(p=>p.kind==="press"||p.kind==="longPress"||p.kind==="toggle"||p.kind==="slider"),i=n.frames.map(p=>({t:p.t+r,wall:p.t,kind:p.kind,w:p.w,h:p.h,jpeg:p.jpeg,boxes:p.boxes})),s=new Set,c=p=>{let y=[];for(let w of i)if(!(w.kind!=="tap"||w.tap!==void 0))for(let $ of o){if($.seq===void 0||s.has($.seq))continue;let A=p(w,$);A!==void 0&&A>=0&&A<3e3&&y.push({f:w,seq:$.seq,gap:A})}y.sort((w,$)=>w.gap-$.gap||$.seq-w.seq||$.f.wall-w.f.wall);for(let w of y)w.f.tap!==void 0||s.has(w.seq)||(w.f.tap=w.seq,s.add(w.seq))};c((p,y)=>{if(typeof y.wall!="number")return;let w=p.wall-y.wall;if(!(w>=2e3||w<-1e3))return w>=0?w:2e3-w});let d=p=>p<2e3?p:void 0;c((p,y)=>typeof y.wall=="number"?void 0:d(p.t-y.t)),r&&c((p,y)=>typeof y.wall=="number"?void 0:d(p.wall-y.t));let u=new Set(i.map(p=>p.tap).filter(p=>p!==void 0)),l=i.filter(p=>p.kind==="tap"&&p.tap===void 0).sort((p,y)=>(p.wall??p.t)-(y.wall??y.t)),h=o.filter(p=>p.seq!==void 0&&!u.has(p.seq)&&typeof p.wall!="number").sort((p,y)=>p.seq-y.seq);if(l.length&&l.length===h.length)(!!e.clock?.active||l.every((p,y)=>Math.abs(p.t-h[y].t)>6e4))&&l.forEach((p,y)=>p.tap=h[y].seq);else if(l.length&&l.length<h.length&&e.clock?.active){let p=h.slice(h.length-l.length);l.forEach((y,w)=>y.tap=p[w].seq)}let m=i.filter(p=>p.tap!==void 0).sort((p,y)=>p.wall-y.wall),g=m.map(p=>p.tap).sort((p,y)=>p-y);m.forEach((p,y)=>p.tap=g[y]);let k=Ru({frames:i,marks:n.marks.map(p=>p+r),settings:n.settings,dropped:n.dropped,droppedWhy:wi(n)}),f=k&&k.frames.length?{...e,media:k}:e;if(!k||!k.frames.length){let p=Object.entries(k?.droppedWhy??wi(n)),y=p.length?p.map(([w,$])=>$>1?`${w} (${$} times)`:w).join("; "):"no frame was taken";f=Ye(f,`No pictures: ${y}`)}else if(!k.frames.some(p=>p.kind==="last"))f=Ye(f,"No picture from right before the report. The newest picture is from earlier.");else if(a&&!a.ok&&typeof n.lastAgeMs=="number"&&n.lastAgeMs>Uu){let p=a.reason?` (${a.reason})`:"";f=Ye(f,`No new picture right before the report${p}. The main picture is ${Math.round(n.lastAgeMs/1e3)} s old.`)}return n.stopped&&(f=Ye(f,n.stopped)),f}function wi(e){let t={},n=0;for(let[r,o]of Object.entries(e.reasons??{}))typeof o!="number"||!(o>0)||(t=Ja(t,Vu[r]??r,o),n+=o);let a=typeof e.dropped=="number"&&Number.isFinite(e.dropped)?e.dropped:0;return Ja(t,gi,a-n)}var Vu={busy:"another picture was still being taken"};function bi(e,t){if(!e.media)return e;let n=Ou(e.media.frames,e.media.marks,{frames:150,bytes:t});if(!n.dropped)return e;let a={...e.media,frames:n.frames,dropped:e.media.dropped+n.dropped,droppedWhy:Ja(e.media.droppedWhy??{},gi,n.dropped)},r={...e,media:a};return a.frames.length?Ye(r,`Some pictures were left out to fit the case (${n.dropped}).`):(delete r.media,Ye(r,`No pictures fit in the case. ${a.dropped} were left out: ${Lu(a.droppedWhy)}.`))}var ki=8e3;function vi(e,t){let n;return Promise.race([e,new Promise((a,r)=>{n=setTimeout(()=>r(new Error("the phone took too long")),t)})]).finally(()=>clearTimeout(n))}var Uu=1e4;function Ye(e,t){return{...e,missing:[...e.missing,{part:"media",reason:t}]}}var Ln="https://buoy.gg",$t={},On={},Rn=null,Xa=false,Za=0;function Ii(){return Xa}var Qa=new Set,Ku=/^(localhost|127(\.\d{1,3}){3}|10(\.\d{1,3}){3}|192\.168(\.\d{1,3}){2}|172\.(1[6-9]|2\d|3[01])(\.\d{1,3}){2}|\[::1\]|[a-z0-9-]+\.local)$/i,Si=/^(https?):\/\/([a-z0-9.-]+|\[[0-9a-f:]+\])(:\d{1,5})?(?:[/?#].*)?$/i;function Dn(e){let t=Si.exec(e.trim());return t?t[1].toLowerCase()==="https"||Ku.test(t[2])?null:"Use https, or http only for this Mac or your local network.":"That isn't a web address."}function er(e){let t=Si.exec(e.trim());return`${t[1].toLowerCase()}://${t[2].toLowerCase()}${t[3]??""}`}function qu(e){if(e.server&&Dn(e.server))throw new Error(`configureBugLinks: ${Dn(e.server)}`);$t={...$t,...e,server:e.server?er(e.server):$t.server},e.media&&Ya(e.media),Nn()}function Xe(){return Rn||(Rn=(async()=>{let e=Za,t;try{t=await cu(Qo.bugLinks.settings())}catch{Rn=null,Nn();return}if(e===Za){try{let n=t?JSON.parse(t):{};typeof n.server=="string"&&!Dn(n.server)&&(On={server:er(n.server)})}catch{On={}}Xa=true,Nn()}})()),Rn}function ae(){return On.server??$t.server??Ln}function tr(){return $t.rules}var Ti=/^[A-Za-z0-9_-]{43}$/;function xi(){let e=$t.teamKey;if(e===void 0)try{e=process.env.EXPO_PUBLIC_BUOY_TEAM_KEY}catch{e=void 0}let t=(Array.isArray(e)?e:typeof e=="string"?e.split(","):[]).map(n=>String(n).trim()).filter(Boolean);return t.length?(t.some(n=>!Ti.test(n))&&console.warn("[bug-links] teamKey must be the 43-letter key id from the team list's admin page."),t.filter(n=>Ti.test(n))):null}async function _n(e){let t={};if(e!==null){let n=Dn(e);if(n)throw new Error(n);t={server:er(e)}}if(!await pu(Qo.bugLinks.settings(),JSON.stringify(t),{strict:true}).catch(()=>false))throw new Error("Buoy couldn't save the server (the storage may be full). Free some space, then try again.");return Za++,On=t,Xa=true,Nn(),ae()}function nr(e){return Qa.add(e),()=>Qa.delete(e)}function Nn(){for(let e of Qa)e()}var Mn=()=>`${lu.bugLinks.root()}_team_trust`,Fu=300*1e3,ar=new Map,Ze=null,At=null;async function $i(){let e=D()?globalThis.localStorage:void 0;return e?e.getItem(Mn()):du(Mn())}function Ai(){return Ze?Promise.resolve(Ze):(At??(At=(async()=>{let e;try{e=await $i()}catch(t){throw At=null,t}try{let t=e?JSON.parse(e):{},n=t&&typeof t=="object"?t:{};Ze=D()&&Xt?Ju(n,Xt):n}catch(t){if(At=null,D())throw t;Ze={}}return Ze})()),At)}var Ei=Promise.resolve(),Hu="buoy-bug-links-team-trust";function Bi(e){let t=()=>un(Hu,async()=>(D()&&(Ze=null,At=null),e())),n=Ei.then(t,t);return Ei=n.catch(()=>{}),n}var Xt=null;function Ju(e,t){let n=JSON.parse(JSON.stringify(e));for(let[a,r]of Object.entries(t)){let o=n[a]??(n[a]={roots:[],maxVersion:{}});for(let[i,s]of Object.entries(r))o.maxVersion[i]=Math.max(o.maxVersion[i]??0,s)}return n}async function Ci(){let e=JSON.stringify(Ze??{});if(D()){let t=await Zo(Mn(),e,{strict:true}).catch(()=>false);if(t)Xt=null;else{let n=Xt??{};for(let[a,r]of Object.entries(Ze??{})){let o=n[a]??(n[a]={});for(let[i,s]of Object.entries(r.maxVersion))o[i]=Math.max(o[i]??0,s)}Xt=n}return t}try{return await Zo(Mn(),e,{strict:true})}catch{return false}}var Zt=(e,t,n)=>({kind:"wait",code:e,message:t,teamKeyId:n});function Gu(e){let t=e??{};if(typeof t.owner!="string"||!Array.isArray(t.roots)||!Array.isArray(t.versions))return null;let n=t.current;return n!==null&&(typeof n?.teamKeyId!="string"||!Number.isSafeInteger(n?.keyVersion))?null:{owner:t.owner,roots:t.roots,versions:t.versions,current:n}}async function rr(e,t,n={}){if(!t)return Zt("signed_out","Sign in to Buoy so this bug can be locked to your team.");let a=`${e}|${t.slice(-16)}`,r=ar.get(a);if(r&&!n.fresh&&Date.now()-r.at<Fu&&!await Yu(e,t,r.pick))return r.pick;let o=await Bi(()=>Xu(e,t));return(o.kind!=="wait"||o.code!=="offline")&&ar.set(a,{at:Date.now(),pick:o}),o}async function Yu(e,t,n){if(n.kind!=="ok"||!D())return false;try{let a=xi();if(a&&!a.includes(n.target.teamKeyId))return true;let r=await $i(),o=(r?JSON.parse(r):{})[`${e}|${$e(t)??"unknown"}`];return!a&&o?.roots?.length&&!o.roots.includes(n.target.teamKeyId)?true:n.target.keyVersion<(o?.maxVersion?.[n.target.teamKeyId]??0)}catch{return true}}async function Xu(e,t){let n;try{let k=await Rd(e,t);if(k===null)return{kind:"off"};n=Gu(k)}catch(k){return k instanceof B&&k.code==="signed_out"?Zt("signed_out","Sign in to Buoy so this bug can be locked to your team."):k instanceof B&&k.code==="needs_pro"?{kind:"off"}:Zt("offline","Couldn't reach the team key. Buoy will lock this bug to your team later.")}if(!n)return Zt("untrusted","The server sent a team key Buoy can't read.");let a=n.owner;if(!n.roots.length)return{kind:"off",owner:a};let r=(k,f,p)=>({...Zt(k,f,p),owner:a}),o=n.current;if(!o)return r("no_current","Your team's key was retired after a team change. Once an admin makes a new one, Buoy locks this bug to it.");let i=n.roots.find(k=>k.teamKeyId===o.teamKeyId),s=n.versions.find(k=>k.teamKeyId===o.teamKeyId&&k.keyVersion===o.keyVersion),c=i?su(i.pub):null;if(!i||!s||!c)return r("untrusted","The server's team key is missing a part.");if(i.retiredAt||s.retiredAt)return r("no_current","Your team's key was retired. Once an admin makes a new one, Buoy locks this bug to it.");let d=xi(),u;try{u=await Ai()}catch{return r("untrusted","Buoy couldn't read which team keys this device trusts. It will lock this bug to your team later.")}let l=`${e}|${$e(t)??"unknown"}`,h=u[l]??{roots:[],maxVersion:{}};if(d){if(!d.includes(o.teamKeyId))return r("pin","This app's Buoy setup pins another team key. Update the teamKey setting.",o.teamKeyId)}else if(h.roots.length&&!h.roots.includes(o.teamKeyId))return r("new_root","Your team has a new key root. Open Bug links to trust it.",o.teamKeyId);let m;try{m=await uu(He(),c,{...s,owner:n.owner})}catch{return r("untrusted","The team key isn't signed by your team's root. Buoy didn't use it.")}let g=h.maxVersion[o.teamKeyId]??0;return o.keyVersion<g?r("untrusted","The server offered an older team key. Buoy didn't use it."):(!d&&!h.roots.length&&h.roots.push(o.teamKeyId),h.maxVersion[o.teamKeyId]=o.keyVersion,u[l]=h,await Ci()?{kind:"ok",target:{owner:n.owner,teamKeyId:o.teamKeyId,keyVersion:o.keyVersion,pub:m}}:r("untrusted","Buoy couldn't save which team keys this device trusts. It will lock this bug to your team later."))}function Zu(e,t,n){return Bi(()=>Qu(e,t,n))}async function Qu(e,t,n){let a=await Ai(),r=`${e}|${$e(n)??"unknown"}`;a[r]&&(a[r].roots=[t]);let o=await Ci();if(ar.clear(),!o)throw new Error("This device couldn't save the new team key. Free some space, then try again.")}var ec=7.5*1024*1024,ot=null,jn=null,or=new Set,zn=new Map,Et=new Map,ge=new Set;function it(e,t){let n=Et.get(e)??Promise.resolve(null),a=()=>un(`buoy-bug-links-link-${e}`,async()=>(D()&&await Fo(),t())),r=n.then(a,a),o=r.then(()=>R(e)??null,()=>R(e)??null);return Et.set(e,o),o.finally(()=>{Et.get(e)===o&&Et.delete(e)}),r}var le=[5e3,3e4,12e4,6e5,18e5],Pi=1500;async function Li(e,t){let n,a=new Promise(r=>{n=setTimeout(()=>r(false),t)});try{return await Promise.race([Td(e).catch(()=>false),a])}finally{clearTimeout(n)}}function Bt(){return ot}function Wn(e){return or.add(e),()=>or.delete(e)}function ir(){ot=null,Oi()}function sr(e){ot=e,Oi()}function Oi(){for(let e of or)e()}function tc(){return`bl_${Date.now().toString(36)}_${Math.floor(Math.random()*1e9).toString(36)}`}function nc(e){let t=e.console?.find(n=>n.level==="error")?.text;return{note:e.note||void 0,app:e.app?.id||void 0,version:e.app?.version||void 0,build:e.app?.build||void 0,route:e.route?.pathname||void 0,error:t?t.split(`
18
+ `)[0]:void 0}}async function ac(e,t,n,a){if(!e.caseTag||!e.card)return e.priority?{extras:{priority:e.priority}}:{};let r=He(),o={...e.card,note:(await Ba(t,e.key,{crypto:Ne()})).kase.note||void 0},i=await $o(r,e.key,e.caseTag,1,o,t),s=await rr(n,a),c=s.kind==="ok"?JSON.stringify(await Ao(r,s.target,e.key,e.caseTag)):void 0;return{extras:{card:i,wrap:c,owner:e.teamOwner,priority:e.priority},pick:s}}function lr(e){return e?.kind==="ok"?e.target.owner:e?.owner}function rc(e,t,n,a){return!e.caseTag||n==="saved"?{wrapPending:false,wrapWait:void 0}:a&&(!t||t.kind==="off")?{wrapPending:true,wrapWait:{code:"no_current",message:"Your team turned on its key. Buoy locks this bug to it soon."}}:!t||t.kind==="off"?{wrapPending:false,wrapWait:void 0}:t.kind==="wait"?{wrapPending:true,wrapWait:{code:t.code,message:t.message,teamKeyId:t.teamKeyId}}:{wrapPending:true,wrapWait:{code:"no_current",message:"Your team's key changed. Buoy locks this bug to the new one soon."}}}function Ct(e,t,n,a={}){if(ge.has(e)||ot&&ot.localId!==e&&ot.localId!==null)return;let r=R(e);sr({localId:e,phase:t,message:n,removed:r?.removed.length??0,url:r?.url,...a})}function Vn(e={}){return jn||(jn=(async()=>{sr({localId:null,phase:"capturing",message:"Saving the bug\u2026",removed:0});try{await Promise.all([Fe(),Xe()]);let t=await Wu(await Sd({note:e.note,rules:tr()})),n=await Ad(He()),a;try{a=await yn(t,Ne(),n)}catch(o){if(!(o instanceof xo&&o.code==="too_big"&&t.media))throw o;t=bi(t,0),a=await yn(t,Ne(),n)}for(let o of[2*1024*1024,512*1024,0]){if(a.blob.length<=ec||!t.media)break;t=bi(t,o),a=await yn(t,Ne(),n)}let r=tc();return await Yd({localId:r,key:a.key,header:a.header,note:t.note,priority:e.priority&&e.priority!=="normal"?e.priority:void 0,screen:t.route?.pathname,createdAt:t.createdAt,status:"sending",attempts:0,server:ae(),owner:$e(ee())??void 0,removed:t.scrub.items,caseTag:n.caseTag,keyProofHash:n.keyProofHash,card:nc(t),cardRevision:1},Ea(a.blob))||await _(r,{error:"This phone's storage is full, so the case lives only while the app stays open."}),await Qe(r)}catch(t){let n=t instanceof $d?"This bug was too big to check for private data, so nothing was sent.":t instanceof xo?t.message:`Couldn't save the bug: ${t instanceof Error?t.message:String(t)}`;return sr({localId:null,phase:"failed",message:n,removed:0}),null}finally{jn=null,ju()}})(),jn)}function Qe(e,t={}){let n=Et.get(e);return n&&!t.asMe?n:it(e,()=>Un(e,t)).then(async a=>a?.status==="sent"&&a.priorityPending?await Kn(e).catch(()=>null)??R(e)??a:a)}async function Un(e,t){await Xe();let n=R(e);if(!n)return ge.delete(e),null;if(n.status==="deleting")return hr(n);if(n.id&&!n.needsPut)return qd(e)&&!await Fd()&&me(e,le[1]),R(e)??n;if(dr(e),!n.id&&!Ii())return q(n,"Buoy couldn't read its settings just now. It will try again.","storage_read");let a=n.id?n.server??ae():ae(),r;try{r=await Jo(e)}catch{return q(n,"Buoy couldn't read this saved bug just now. It will try again.","storage_read")}let o=r?To(r):null;if(!o)return await _(e,{status:"failed",error:"The saved case is gone from this phone.",errorCode:"lost"}),Ct(e,"failed","The saved case is gone from this phone."),R(e)??null;if(n.id&&n.needsPut){let l=ee(),h=l?$e(l):null;if(h&&n.owner&&h!==n.owner&&!t.asMe)return q(n,"Someone else is signed in now. Open Bug links and tap Send as me to add the note anyway.","other_account",false);let m=n.blobVersion??0,g=n,k;if(g.card){let{kase:p}=await Ba(o,g.key,{crypto:Ne()});k={...g.card,note:p.note||void 0}}let f=async p=>{let y;return g.caseTag&&k&&(y={card:await $o(He(),g.key,g.caseTag,p,k,o),cardRevision:p}),Pd(a,g.id,g.editToken??"",o,y)};try{let p;try{p=await f((n.cardRevision??1)+1)}catch(A){let P=A instanceof B&&A.code==="conflict"?A.detail.cardRevision:void 0;if(typeof P!="number")throw A;P!==n.cardRevision&&(n=await _(e,{cardRevision:P})??{...n,cardRevision:P}),p=await f(P+1)}let{expiresAt:y,cardRevision:w}=p,$=R(e);return await _(e,{needsPut:($?.blobVersion??0)!==m,...k&&($?.blobVersion??0)===m?{card:k,note:k.note}:{},expiresAt:y===void 0?n.expiresAt:y,cardRevision:w??n.cardRevision,error:void 0,errorCode:void 0,attempts:0})??null}catch(p){if(p instanceof B&&p.retry)return q(n,"The note will reach the server when this phone is back online.",p.code);if(p instanceof B&&p.code==="conflict")return q(n,"The bug changed on the server at the same time. Buoy will send the note again.","conflict");let y=p instanceof Error?p.message:String(p);return q(n,`${y} Buoy will send the note again.`,p instanceof B?p.code:"error")}}let i=ee();if(!i)return q(n,"Sign in to Buoy to send this bug. It's saved on the phone.","signed_out");let s=$e(i);if(!n.owner&&s){let l=await _(e,{owner:s});if(D()&&!_e(e)&&l?.owner!==s)return q(n,"The browser's storage is full, so Buoy can't keep track of this send. Free some space; it will try again.","storage_full");n=l??{...n,owner:s}}if(n.owner&&s!==n.owner){if(!t.asMe)return q(n,"Someone else is signed in now. Open Bug links and tap Send as me to send it anyway.","other_account",false);let l=await _(e,{owner:s??void 0,teamOwner:void 0});if(D()&&!_e(e)&&(l?.owner!==(s??void 0)||l?.teamOwner!==void 0))return q(n,"The browser's storage is full, so Buoy can't keep track of this send. Free some space; it will try again.","storage_full");n=l??{...n,owner:s??void 0,teamOwner:void 0}}let c=n.removed.length;if(!n.id&&n.triedServer&&n.triedServer!==a){try{await Pa(n.triedServer,e,i)}catch(l){if(l instanceof B&&l.code==="signed_out")return q(n,"Buoy couldn't sign you in to the old server to move this bug. It's saved on the phone.","signed_out");if(l instanceof B&&l.retry&&l.status!==void 0)return q(n,"Buoy needs the old server once more before it moves this bug. It will try again.",l.code)}if(n.teamOwner){let l=await _(e,{teamOwner:void 0});if(D()&&!_e(e)&&l?.teamOwner!==void 0)return q(n,"The browser's storage is full, so Buoy can't keep track of this send. Free some space; it will try again.","storage_full");n=l??{...n,teamOwner:void 0}}}Ct(e,"sending","Sending the bug link\u2026");let d=await _(e,{status:"sending",server:a,triedServer:a});if(D()&&!_e(e)&&d?.triedServer!==a)return q(n,"The browser's storage is full, so Buoy can't keep track of this send. Free some space; it will try again.","storage_full");if(ge.has(e)||!R(e)||R(e)?.status==="deleting"){ge.delete(e);let l=R(e);return l?hr(l):null}let u="The browser's storage is full, so Buoy can't keep track of this send. Free some space; it will try again.";if(!n.editToken){let l=Ea(Ft(32)),h=await _(e,{editToken:l});if(D()&&!_e(e)&&h?.editToken!==l)return q(n,u,"storage_full");n=h??{...n,editToken:l}}try{if(n.caseTag&&!n.teamOwner){let w=lr(await rr(a,i,{fresh:true}));if(w){let $=await _(e,{teamOwner:w});if(D()&&!_e(e)&&$?.teamOwner!==w)return q(n,u,"storage_full");n=$??{...n,teamOwner:w}}}if(!await Jt(e))return q(n,u,"storage_full");let{extras:l,pick:h}=await ac(n,o,a,i),m=await Cd(a,i,o,{uploadId:e,editToken:n.editToken,extras:l}),g=async()=>{let w={id:m.id,editToken:m.editToken,server:a,status:"deleting"},$=R(e)?await _(e,w):void 0;if($&&$.id!==m.id&&Uo(e,w),$&&!await Jt(e))return me(e,le[1]),null;try{await Oo(a,m.id,{editToken:m.editToken}),ge.delete(e),R(e)&&!await Ho(e)&&me(e,le[1])}catch{$&&me(e,le[1])}return null};if(ge.has(e)||!R(e))return g();let k=Id(a,m.id,n.key),f={id:m.id,editToken:m.editToken,expiresAt:m.expiresAt,url:k,status:"sent",error:void 0,errorCode:void 0,nextTryAt:void 0,attempts:0,cardRevision:m.cardRevision??1,...rc(n,h,m.wrapStatus,m.teamKeys),...!n.teamOwner&&m.owner?{teamOwner:m.owner}:{}},p=await _(e,f);if(D()&&!_e(e)&&p?.id!==m.id){Uo(e,f),me(e,le[0]);let w=await Li(k,Pi);return Ct(e,"sent",w?"Bug link copied":"Bug link ready",{url:k,removed:c,copied:w}),R(e)??{...n,...f}}if(!p||ge.has(e)||p.status==="deleting")return g();let y=await Li(k,Pi);return Ct(e,"sent",y?"Bug link copied":"Bug link ready",{url:k,removed:c,copied:y}),R(e)?.needsPut?Un(e,t):p??null}catch(l){if(ge.has(e))return ge.delete(e),me(e,le[0]),null;if(l instanceof B&&l.retry)return q(n,l.message,l.code);if(l instanceof B&&l.code==="signed_out")return q(n,"Buoy couldn't sign you in to send this bug. It's saved on the phone.","signed_out");if(l instanceof B&&l.code==="conflict"&&l.status===409&&!R(e)?.id){try{await Pa(a,e,i)}catch(g){return q(n,g instanceof Error?g.message:String(g),g instanceof B?g.code:"error")}return q(n,"Buoy is sending this bug again.","conflict")}let h=l instanceof B&&l.code==="needs_pro"?"Bug links need Buoy Pro. The case is saved on this phone.":l instanceof Error?l.message:String(l),m=l instanceof B?l.code:"error";return await _(e,{status:"failed",error:h,errorCode:m}),Ct(e,"failed",h,{code:m}),R(e)??null}}async function q(e,t,n,a=true){let r=R(e.localId)??e,o=r.attempts+1,i=le[Math.min(o-1,le.length-1)];return await _(e.localId,{status:r.id||r.status==="deleting"?r.status:"waiting",error:t,errorCode:n,attempts:o,nextTryAt:a?Date.now()+i:void 0}),a&&me(e.localId,i),Ct(e.localId,"waiting",t,{code:n}),R(e.localId)??null}function me(e,t){dr(e),zn.set(e,setTimeout(()=>{zn.delete(e),Qe(e)},t))}function dr(e){let t=zn.get(e);t&&clearTimeout(t),zn.delete(e)}async function st(){await Fe();for(let{localId:e}of St())try{let t=R(e);if(!t||t.errorCode==="other_account"&&t.status!=="deleting")continue;t.status==="waiting"||t.status==="deleting"||t.needsPut?await Qe(e):t.status==="sent"&&t.wrapPending&&await ur(e),t=R(e),t?.status==="sent"&&t.priorityPending&&await Kn(e)}catch{}}function ur(e){return it(e,async()=>{let t=R(e);if(!t?.id||!t.wrapPending||!t.caseTag||!t.editToken||!t.server||t.status!=="sent")return t??null;let n=ee();if(!n||t.owner&&$e(n)!==t.owner)return await _(e,{wrapWait:{code:"other_account",message:"Sign in as the person who sent this bug, so Buoy can lock it to their team."}})??null;let a=await rr(t.server,n,{fresh:true});if(t.teamOwner&&lr(a)&&lr(a)!==t.teamOwner)return await _(e,{wrapWait:{code:"team_changed",message:"Your team changed since this bug was sent. Only its link opens it."}})??null;if(a.kind==="off")return a.owner&&t.teamOwner&&a.owner===t.teamOwner?await _(e,{wrapPending:false,wrapWait:void 0})??null:await _(e,{wrapWait:{code:"off",message:"Your team list isn't reachable right now. Buoy will try again."}})??null;if(a.kind==="wait")return await _(e,{wrapWait:{code:a.code,message:a.message,teamKeyId:a.teamKeyId}})??null;try{let r=await Ao(He(),a.target,t.key,t.caseTag);return await Ld(t.server,t.id,t.editToken,JSON.stringify(r),t.caseTag),await _(e,{wrapPending:false,wrapWait:void 0})??null}catch(r){let o=r instanceof Error?r.message:String(r);return await _(e,{wrapWait:{code:r instanceof B?r.code:"error",message:o}})??null}})}async function Kn(e,t){if(t){let n=await _(e,a=>a.status==="deleting"?null:{priority:t,priorityPending:true});if(!n||n.status==="deleting")return n??null}return it(e,async()=>{let n=R(e);if(!n||!n.priorityPending)return n??null;if(!n.id||!n.editToken||!n.server||n.status!=="sent")return n;if(n.owner&&$e(ee())!==n.owner)throw new Error("Someone else is signed in now. Sign in as the person who sent this bug to change its priority.");let a=n.priority??"normal";try{return await Od(n.server,n.id,n.editToken,a),await _(e,r=>(r.priority??"normal")===a?{priorityPending:false}:null)??null}catch(r){if(r instanceof B&&r.code==="priority_set"){let o=bt.find(i=>i===r.detail.priority);throw await _(e,{priorityPending:false,...o?{priority:o}:{}}),new Error("A teammate already set this bug's priority, so yours wasn't changed.")}if(r instanceof B&&(r.retry||r.code==="conflict"))return n;throw await _(e,o=>(o.priority??"normal")===a?{priorityPending:false}:null),r}})}async function cr(e,t){let n=await it(e,()=>oc(e,t));return n?.id?it(e,()=>Un(e,{})):n}async function oc(e,t){let n=R(e);if(!n)return null;let a;try{a=await Jo(e)}catch{throw new Error("Buoy couldn't read this saved bug just now. Try again.")}let r=a?To(a):null;if(!r)throw new Error("This case is no longer on the phone, so a note can't be added here.");let o=Ne(),{kase:i}=await Ba(r,n.key,{crypto:o}),s=xd({note:t.trim().slice(0,4e3)},tr());i.note=s.value.note||void 0;let c=[...i.scrub.items.filter(y=>!y.path.startsWith("$.note")),...s.removed.map(y=>({...y,path:`$.note${y.path.slice(1)}`}))],d={};for(let y of c)d[y.kind]=(d[y.kind]??0)+1;i.scrub={removed:c.length,byKind:d,items:c};let u=await yn(i,o,n.caseTag&&n.keyProofHash?{key:n.key,caseTag:n.caseTag,keyProofHash:n.keyProofHash}:{key:n.key}),l=R(e);if(!l||l.status==="deleting")return null;let h=(l.blobVersion??0)+1,m="Buoy couldn't save the note (the storage may be full), so it wasn't added.";if((l.id||l.triedServer)&&!l.needsPut){let y=await _(e,{needsPut:true});if(!await pr(e,y,w=>!!w.needsPut))throw new Error(m)}else if(!await Jt(e))throw new Error(m);let g=D()&&!_e(e),k=async()=>{a&&await Ma(e,a,l.blobVersion??0),(l.id||l.triedServer)&&!l.needsPut&&await _(e,{needsPut:false})},f=await Ma(e,Ea(u.blob),h);if(!f&&g)throw await k(),new Error(m);let p=await _(e,{note:i.note,card:n.card?{...n.card,note:i.note||void 0}:void 0,header:u.header,removed:i.scrub.items,needsPut:!!l.id||!!l.triedServer,blobVersion:h,...f?{}:{error:"The phone couldn't save the note. It goes up if the app stays open."}});if(g&&p?.blobVersion!==h)throw await k(),new Error(m);return p??null}async function Pt(e){let t=R(e);if(t){if(dr(e),ot?.localId===e&&ir(),Et.has(e)&&!t.id){ge.add(e);let n=await _(e,{status:"deleting",errorCode:void 0});if(!await pr(e,n,a=>a.status==="deleting"))throw ge.delete(e),new Error("The storage is full, so Buoy can't keep track of this cancel. Free some space, then cancel it again.");it(e,()=>Un(e,{}));return}await it(e,async()=>{let n=R(e);if(!n)return null;let a=n.status==="deleting"?n:await _(e,{status:"deleting",errorCode:void 0,nextTryAt:void 0});if(!await pr(e,a,r=>r.status==="deleting"))throw new Error("The storage is full, so Buoy can't keep track of this delete. Free some space, then delete it again.");return a?hr(a):null})}}async function pr(e,t,n){return D()?_e(e)||!!t&&n(t):Jt(e)}async function hr(e){if(ge.delete(e.localId),!await Jt(e.localId))return me(e.localId,le[1]),R(e.localId)??e;if(!e.id&&e.takenBackOnce&&e.nextTryAt&&e.nextTryAt>Date.now())return me(e.localId,e.nextTryAt-Date.now()),e;try{if(e.id&&e.server)await Oo(e.server,e.id,{editToken:e.editToken,credential:ee()??void 0});else if(e.triedServer){let t=ee();if(!t)return q(e,"Sign in to Buoy to finish deleting this bug link.","signed_out");if(e.owner&&$e(t)!==e.owner)return q(e,"Sign in as the person who sent this bug to finish deleting it.","other_account",false);if(await Pa(e.triedServer,e.localId,t),!e.takenBackOnce){let n=await _(e.localId,{takenBackOnce:true,error:void 0,errorCode:void 0,nextTryAt:Date.now()+le[2]});return me(e.localId,le[2]),n??null}}return await Ho(e.localId)?null:(me(e.localId,le[1]),R(e.localId)??null)}catch(t){return t instanceof B&&t.code==="signed_out"?q(e,"Sign in to Buoy to finish deleting this bug link.","signed_out"):(t instanceof B&&t.retry&&me(e.localId,le[1]),await _(e.localId,{error:t instanceof Error?t.message:String(t),errorCode:t instanceof B?t.code:"error"}),R(e.localId)??null)}}var Ri=null,Di=false,qn=new Set;function fr(e){Ri=e;for(let t of qn)t()}function ic(){return Ri}function sc(){return Di}function gr(e){Di=e;for(let t of qn)t()}function _i(e){return qn.add(e),()=>qn.delete(e)}import{getRegisteredToolModule as Ni}from"@buoy-gg/shared-ui/web";var mr=null,yr=null,Mi=false;function ji(){if(mr||Mi)return mr??null;let e=Ni("@buoy-gg/impersonate")?.impersonateStore??null;if(!e)try{e=Xn("@buoy-gg/impersonate/web").impersonateStore??null}catch{e=null}return mr=e,e}function zi(){if(yr||Mi)return yr??null;let e=Ni("@buoy-gg/scenarios")?.scenariosStore??null;if(!e)try{e=Xn("@buoy-gg/scenarios/web").scenariosStore??null}catch{e=null}return yr=e,e}var Wi=e=>e?.getSnapshot?.()??e?.getState?.();function lc(e){let t=[ji()?.subscribe(e),zi()?.subscribe(e)];return()=>t.forEach(n=>n?.())}function dc(){let e=Wi(ji());return!!(e?.isActive&&e.currentUser&&e.showBanner)}function uc(){return!!Wi(zi())?.active}function Vi(){return(dc()?1:0)|(uc()?2:0)}var Ui=50,cc=46,pc=52,hc=50;function fc(e,t){let n=Ui;return e&1&&(n=Math.max(n,Ui+cc)),e&2&&(n=Math.max(n,t+pc+hc)),n}import{Fragment as gc,jsx as C,jsxs as Ee}from"react/jsx-runtime";var et="bug-links-toast",wr="clock-chip",mc=12e3,yc=64,Fn=e=>Al().some(t=>t.id===e);function de({label:e,onPress:t,testID:n,tone:a,disabled:r}){return C(Le,{testID:n,accessibilityRole:"button",accessibilityLabel:e,accessibilityState:{disabled:!!r},disabled:r,onPress:t,style:[ve.button,r&&ve.dim],hitSlop:{top:8,bottom:8,left:4,right:4},children:C(O,{style:[ve.buttonText,a==="accent"&&ve.accent,a==="danger"&&ve.danger],children:e})})}var wc=typeof on<"u"&&on?116:64;function bc({id:e,revealToken:t}){let n=ln(Wn,Bt,Bt),[a,r]=ra(null),{width:o}=ea();if(sn(()=>{if(n?.phase!=="sent")return;let c=setTimeout(()=>{pt(et),ir()},mc);return()=>clearTimeout(c)},[n?.phase,n?.localId]),!n)return null;let i=n.phase==="capturing"||n.phase==="sending",s=n.phase==="sent"?n.removed?`${n.removed} private ${n.removed===1?"value":"values"} removed`:"Locked on this phone":n.phase==="waiting"?"Saved on this phone":n.phase==="failed"?"Not sent":"Taking out private data";return C($l,{id:e,revealToken:t,variant:"strip",dragFromSurface:true,defaultPlacement:"bottom",bottomClearance:wc,accessibilityLabel:"Move or hide the bug report",handleAdornment:C(oa,{size:12,color:X.color.textSecondary}),children:Ee(K,{style:[ve.row,{maxWidth:o-yc}],testID:"bug-links-toast",children:[i?C(aa,{size:"small",color:X.color.accent}):C(oa,{size:18,color:n.phase==="failed"?X.color.danger:X.color.accent}),Ee(K,{style:ve.text,children:[C(O,{style:ve.title,numberOfLines:2,testID:"bug-links-toast-title",children:n.message}),C(O,{style:ve.detail,numberOfLines:2,children:s})]}),n.phase==="sent"&&n.url&&n.localId?Ee(gc,{children:[C(de,{testID:"bug-links-toast-share",label:"Share",tone:"accent",onPress:()=>void Qn.share({message:n.url}).catch(()=>{})}),C(de,{testID:"bug-links-toast-note",label:"Note",onPress:()=>{fr(n.localId),pt(et),ia("bug-links")}}),a===n.localId?C(de,{testID:"bug-links-toast-delete-confirm",label:"Delete for all?",tone:"danger",onPress:()=>void Pt(n.localId).catch(()=>{})}):C(de,{testID:"bug-links-toast-delete",label:"Delete",tone:"danger",onPress:()=>r(n.localId)})]}):null,n.phase==="waiting"&&n.localId&&n.code==="signed_out"?C(de,{testID:"bug-links-toast-sign-in",label:"Sign in",tone:"accent",onPress:()=>{gr(true),pt(et),ia("bug-links")}}):n.phase==="waiting"&&n.localId&&n.code==="other_account"?C(de,{testID:"bug-links-toast-send-as-me",label:"Send as me",tone:"accent",onPress:()=>void Qe(n.localId,{asMe:true})}):n.phase==="waiting"&&n.localId?C(de,{testID:"bug-links-toast-retry",label:"Retry",tone:"accent",onPress:()=>void Qe(n.localId)}):null,n.phase==="sending"&&n.localId?C(de,{testID:"bug-links-toast-cancel",label:"Cancel",onPress:()=>void Pt(n.localId).catch(()=>{})}):null,i?null:C(Le,{testID:"bug-links-toast-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>{pt(et),ir()},style:ve.icon,children:C(qr,{size:16,color:X.color.textSecondary})})]})})}function Ki({testID:e,label:t,onPress:n,disabled:a,children:r,round:o}){return C(Le,{testID:e,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:!!a},disabled:a,onPress:n,activeOpacity:.7,hitSlop:{top:8,bottom:8,left:4,right:4},style:[o?H.close:H.square,a&&ve.dim],children:r})}function kc(){let e=ln(ht,be,be),t=ln(ht,uo,uo),n=ln(lc,Vi,Vi),a=Cl({minBottom:0}),{width:r}=ea(),[o,i]=ra(false),[s,c]=ra(0),d=!!e?.report.replay?.active;if(sn(()=>{if(!d)return c(0);let w=true,$=()=>void Aa().then(P=>w&&c(P.length));$();let A=setInterval($,3e3);return()=>{w=false,clearInterval(A)}},[d,e?.loadId]),sn(()=>{e||i(false)},[e]),sn(()=>{e?.notice&&i(true)},[e?.notice]),!e)return null;let u=e.report.steps.filter(w=>!w.ok).length,l=s>0||u>0||!!e.notice,h=e.notice?e.notice:[s?`${s} ${s===1?"request":"requests"} blocked`:null,u?`${u} ${u===1?"part":"parts"} didn't load`:null,d?null:"Live requests"].filter(Boolean).join(" \xB7 "),m={"this phone":"This phone differs",clock:"No Clock tool"},g=[...new Set(e.report.steps.filter(w=>w.warn).map(w=>m[w.part]??"See the details"))],k=h||g.join(" \xB7 "),f=e.title==="Bug case"?"Bug loaded":e.title,p=fc(n,a.top),y=e.undoGone?()=>void gn():()=>{Ut().then(()=>{be()?.undoBlocked&&i(true)})};return Ee(K,{style:[H.wrap,{top:p}],pointerEvents:"box-none",children:[Ee(K,{style:[H.banner,l&&H.bannerWarn],testID:"bug-links-loaded-bar",children:[Ee(Le,{testID:"bug-links-loaded-open",style:H.who,onPress:()=>i(w=>!w),activeOpacity:.7,accessibilityRole:"button",accessibilityLabel:o?"Hide what loaded":"Show what loaded",children:[C(K,{style:H.avatar,children:C(oa,{size:13,color:"#fff"})}),Ee(K,{style:{maxWidth:Math.min(200,r-150)},children:[C(O,{style:H.name,numberOfLines:1,children:f}),k?C(O,{style:[H.detail,l&&H.warn],numberOfLines:1,testID:"bug-links-loaded-detail",children:k}):null]})]}),e.canLoadAgain?C(Ki,{testID:"bug-links-load-again",label:"Load again",disabled:t,onPress:()=>void wt().catch(()=>{}),children:t?C(aa,{size:"small",color:X.color.accent}):C(O,{style:H.again,children:"\u21BB"})}):null,C(Ki,{testID:"bug-links-undo",label:e.undoGone?"End the bug case":"Restore my app",disabled:t,onPress:y,round:true,children:C(qr,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]}),o?Ee(K,{style:[H.card,{width:Math.min(340,r-24)}],testID:"bug-links-loaded-details",children:[C(O,{style:H.cardTitle,numberOfLines:2,children:e.title}),e.notice?C(O,{style:[H.line,H.warn],children:e.notice}):null,e.report.steps.map((w,$)=>C(O,{style:[H.line,(!w.ok||w.warn)&&H.warn],testID:`bug-links-loaded-step-${$}`,children:`${w.ok&&!w.warn?"\u2713":"\u26A0"} ${w.part}: ${w.detail}`},$)),s?C(O,{style:[H.line,H.warn],children:`\u26A0 ${s} ${s===1?"request":"requests"} blocked`}):null,Ee(K,{style:H.cardButtons,children:[d?C(de,{testID:"bug-links-leave-sandbox",label:"Use live requests",disabled:t,onPress:()=>void hn()}):null,C(de,{testID:"bug-links-loaded-more",label:"Bug Links",onPress:()=>{i(false),ia("bug-links")}})]}),Ee(K,{style:H.cardButtons,children:[e.canLoadAgain?C(de,{testID:"bug-links-details-load-again",label:t?"Working\u2026":"\u21BB Load again",disabled:t,onPress:()=>void wt().catch(()=>{})}):null,e.undoGone?null:C(de,{testID:"bug-links-details-undo",label:"Restore my app",tone:"accent",disabled:t,onPress:()=>void Ut()}),e.undoBlocked||e.undoGone?C(de,{testID:"bug-links-end",label:"End",tone:"danger",disabled:t,onPress:()=>void gn()}):null]})]}):null]})}var vc={id:et,render:e=>C(bc,{...e})},qi=false;function Ic(){if(qi)return;qi=true;let e=null;Wn(()=>{let r=Bt(),o=r?`${r.localId}:${r.phase}`:null;r&&o!==e&&!Fn(et)&&El(vc),!r&&Fn(et)&&pt(et),e=o});let t=null,n=false,a=()=>{if(n)return;let r=be()?.loadId??null;!r||t===r||!Fn(wr)||(n=true,setTimeout(()=>{n=false;let o=be()?.loadId??null;o&&t!==o&&Fn(wr)&&(t=o,pt(wr))},0))};ht(a),Bl(a),a()}var ve=Nt.create({row:{flexDirection:"row",alignItems:"center",gap:4,paddingLeft:8,paddingRight:2,paddingVertical:6,flexShrink:1},column:{flexShrink:1,paddingBottom:4},buttons:{flexDirection:"row",justifyContent:"flex-end",gap:4,paddingRight:2},text:{flexShrink:1,flexGrow:1,minWidth:0,marginLeft:4},title:{color:X.color.text,fontSize:14,fontWeight:"600"},detail:{color:X.color.textSecondary,fontSize:11},button:{paddingHorizontal:7,height:32,alignItems:"center",justifyContent:"center",borderRadius:16},buttonText:{color:X.color.text,fontSize:13,fontWeight:"600"},accent:{color:X.color.accent},dim:{opacity:.4},danger:{color:X.color.danger},icon:{width:28,height:32,alignItems:"center",justifyContent:"center",borderRadius:16}}),H=Nt.create({wrap:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:"#34C75940",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},bannerWarn:{borderColor:X.color.warning+"80"},who:{flexDirection:"row",alignItems:"center",gap:10,flexShrink:1},avatar:{width:24,height:24,borderRadius:12,backgroundColor:X.color.warning,alignItems:"center",justifyContent:"center"},name:{fontSize:14,fontWeight:"600",color:"#fff"},detail:{fontSize:11,color:X.color.textSecondary},warn:{color:X.color.warning},again:{color:X.color.accent,fontSize:16,fontWeight:"700",lineHeight:19},square:{width:28,height:28,borderRadius:8,borderWidth:1,borderColor:"#34C75940",backgroundColor:"rgba(52, 199, 89, 0.15)",alignItems:"center",justifyContent:"center"},close:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},card:{marginTop:8,backgroundColor:"rgba(20, 20, 20, 0.97)",borderWidth:1,borderColor:X.color.border,borderRadius:16,padding:12,gap:4,shadowColor:"#000",shadowOffset:{width:0,height:8},shadowOpacity:.35,shadowRadius:18,elevation:12},cardTitle:{color:"#fff",fontSize:14,fontWeight:"600",marginBottom:4},line:{color:X.color.textSecondary,fontSize:12,lineHeight:17},cardButtons:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",gap:4,marginTop:4}});import{Bug as Sc,Lock as Tc,createToolFactory as xc,defineToolPreset as Fi}from"@buoy-gg/shared-ui/web";import{useEffect as br,useRef as $c,useState as Ie,useSyncExternalStore as Ac}from"react";import{NightBadge as Ec,NightButton as Be,NightCard as lt,NightFootnote as je,NightSectionLabel as Lt,NightSegmented as Bc,NightSwitch as Cc,BuoySignInCard as Pc,copyToClipboard as Lc,readClipboardText as Oc,night as oe,useSafeAreaInsets as Rc}from"@buoy-gg/shared-ui/web";import{parseBugLink as Dc,unlockBugCase as _c}from"@buoy-gg/shared-ui/web";function Nc(e){let t=/^(https?:\/\/[^/?#]+)\/bug\//i.exec(e.trim());return t?t[1].toLowerCase():null}function Mc(e){let t=Nc(e);if(!t)throw new Error("That isn't a bug link. It looks like https://buoy.gg/bug/<id>#<key>.");if(!new Set([Ln,"https://www.buoy.gg",ae()].map(n=>n.toLowerCase())).has(t))throw new Error(`This link is for ${t}. Buoy only sends your sign-in to ${ae()}. If you trust ${t}, set it as the server in Bug links first.`);return t}async function Hi(e){let t=Dc(e);if(!t)throw new Error("That isn't a whole bug link. It should look like https://buoy.gg/bug/<id>#<key>.");await Xe();let n=Mc(e),a=ee();if(!a)throw new Error("Sign in to Buoy to open bug links.");let r=await Ro(n,t.id,a),{kase:o}=await _c(r,t.key,{crypto:Ne()});return{kase:o,id:t.id}}async function kr(e,t={}){let{kase:n,id:a}=await Hi(e);return pn(n,{...t,source:{id:a}})}import{useEffect as vr,useState as Ir,useSyncExternalStore as Ji}from"react";import{NightBadge as jc,NightButton as zc,NightCard as Wc,NightFootnote as Gi,NightSectionLabel as Vc,NightSegmented as Uc,night as Ot}from"@buoy-gg/shared-ui/web";import{base64UrlDecode as Kc,blobSha256 as qc,kitId as Fc,kitKey as Hc,openCard as Jc,openSecret as Gc,pairFrom as Yc,parseKit as Xc,parseWrap as Zc,unlockBugCase as Qc,unwrapCaseKey as ep,versionLockAad as tp}from"@buoy-gg/shared-ui/web";var Yi=1e3,Sr={kind:"idle"},ye=Sr,ze=null,Rt=null,V=null,ue=null,Qt=new Map,Ce=0,Hn=0,Tr=new Set;function en(){for(let e of Tr)e()}function we(){let e=ee();return e?`${ae()}|${$e(e)}`:null}function Jn(){return ye.kind==="idle"||ze===we()?ye:Sr}function np(e){return Tr.add(e),()=>Tr.delete(e)}function Xi(){Ce++,Hn++,ce(V),V=null,ue=null,Qt=new Map,ze=null,Rt=null,ye=Sr,en()}function ce(e){for(let t of e?.versions.values()??[])t.d.fill(0)}function xr(){return!(typeof on<"u"&&!on)}var Zi=(e,t)=>`${e}|${t}`;async function tn(e=0){let t=Ce;if(await Xe(),t!==Ce)return;if(!Ii()){ze=we(),ye={kind:"blocked",code:"error",message:"Buoy couldn't read its settings just now. Tap Refresh to try again."},en();return}let n=ee(),a=we();ze!==null&&a!==ze&&Xi(),ze===null&&V&&ue!==a&&(ce(V),V=null,ue=null);let r=Ce,o=++Hn,i=()=>o===Hn&&r===Ce&&we()===a,s=(h,m=Rt)=>{i()&&(ye=h,ze=a,Rt=m,en())};if(!n||!a)return s({kind:"blocked",code:"signed_out",message:"Sign in to Buoy to see your team's bugs."});let c=h=>i()?V&&ue===a&&V.owner===h.owner?(ce(h),V):(V&&V!==h&&ce(V),V=h,ue=a,h):(ce(h),null),d=ae();s(ye.kind==="ready"?{...ye,refreshing:true}:{kind:"loading"});let u=h=>{ce(h),V===h&&(V=null,ue=null),s({kind:"loading"},null)},l=()=>e>=2?s({kind:"blocked",code:"error",message:"Your team just changed. Tap Refresh."},null):tn(e+1);try{let h=V;if(h||(h=c(await Qi(d,n))),!h||!i())return;let m=[],g="",k=new Map,f=null;for(let A=0;A<Yi;A++){let P=await at(d,`/api/bugs?limit=100${f?`&before=${encodeURIComponent(f)}`:""}`,n);if(!i())return;if(P.owner&&P.owner!==h.owner)return u(h),l();m.push(...P.cases),g=P.me.accountId;for(let N of P.people??[])k.set(N.id,N.name);if(f=P.next,!f)break}Qt=k;let p=await ts(d,n,h,i);if(!i())return;if(p.unknownVersion){let A=await Qi(d,n);if(!i()||V!==h)return ce(A);if(A.owner!==h.owner)return ce(A),u(h),l();for(let[P,N]of h.cases)A.cases.set(P,N);if(ce(h),V=h=A,ue=a,await ts(d,n,h,i),!i())return}let y=await at(d,"/api/bugs?limit=1",n);if(!i())return;if(y.owner&&y.owner!==h.owner)return u(h),l();let w=ye.kind==="ready"&&Rt===h.owner?new Map(ye.bugs.map(A=>[A.id,A])):new Map,$=m.map(A=>{let P=ap(A,h,g),N=w.get(A.id);if(!N||N.rowRevision<=P.rowRevision)return P;let te=N.assignee?N.assignee===g?"You":Qt.get(N.assignee)??N.assignee:null;return{...P,status:N.status,assignee:N.assignee,assigneeName:te,rowRevision:N.rowRevision}});s({kind:"ready",me:g,bugs:$,refreshing:false},h.owner)}catch(h){let m=ns(h);(m.code==="signed_out"||m.code==="no_access"||m.code==="needs_pro")&&i()&&ue===a&&(ce(V),V=null,ue=null),s({kind:"blocked",...m})}finally{we()!==a&&ue===a&&(ce(V),V=null,ue=null)}}async function Qi(e,t){try{return await es(e,t)}catch(n){if(!(n instanceof $r))throw n;return es(e,t)}}var $r=class extends Error{};async function es(e,t){let n=He(),{teamKit:a}=await at(e,"/api/bugs/team-key/kit",t),r=await at(e,"/api/bugs/team-key",t),o=await at(e,"/api/bugs/team-key/locked",t);if(o.owner!==r.owner)throw new $r("The server sent keys for another team.");let i=Xc(a,"team"),s=null;try{if(await Fc(n,i,"team")!==o.kitId)throw new $r("Buoy sent a team kit that doesn't match your team's keys. Tap Refresh to try again.");s=await Hc(n,i,"team");let c=new Map,d={owner:o.owner,versions:c,cases:new Map};try{for(let u of o.versions){let l=r.versions.find(g=>g.teamKeyId===u.teamKeyId&&g.keyVersion===u.keyVersion),h=l?Kc(l.pub):null;if(!h)continue;let m=await Gc(n,s,tp(o.owner,u.teamKeyId,u.keyVersion),u.locked);try{c.set(Zi(u.teamKeyId,u.keyVersion),Yc(m,h))}finally{m.fill(0)}}}catch(u){throw ce(d),u}return d}finally{i.fill(0),s?.fill(0)}}async function ts(e,t,n,a){let r=He(),o=false,i=null;for(let s=0;s<Yi;s++){let c=await at(e,`/api/bugs/cards${i?`?before=${encodeURIComponent(i)}`:""}`,t);if(!a())return{unknownVersion:o};for(let d of c.cards){if(!a())return{unknownVersion:o};let u=n.cases.get(d.id);if(u&&u.cardRevision>=d.cardRevision&&(u.card||!d.card))continue;let l=()=>{a()&&u&&n.cases.get(d.id)===u&&u.cardRevision<d.cardRevision&&n.cases.delete(d.id)};if(!d.wrap||!d.caseTag||(d.owner??n.owner)!==n.owner){l();continue}try{let h=Zc(d.wrap),m=n.versions.get(Zi(h.teamKeyId,h.keyVersion));if(!m){o=true,l();continue}let g=await ep(r,h,n.owner,m,d.caseTag),k=null;if(d.card&&(k=await Jc(r,g,d.caseTag,d.cardRevision,d.card).catch(()=>null)),!a())return{unknownVersion:o};let f=n.cases.get(d.id);if(f&&f.cardRevision>d.cardRevision)continue;n.cases.set(d.id,{key:g,card:k,cardRevision:d.cardRevision})}catch{l()}}if(i=c.next,!i)break}return{unknownVersion:o}}function ap(e,t,n){let a=t.cases.get(e.id),r=a?.card??null,o=s=>s===n?"You":Qt.get(s)??s,i=r?.note?.split(`
19
+ `)[0]?.trim()||r?.error||(r?.route?`Bug on ${r.route}`:a?`Bug from ${new Date(e.createdAt).toLocaleString()}`:"Locked bug");return{id:e.id,title:i,priority:e.priority&&bt.includes(e.priority)?e.priority:"normal",status:e.status,assignee:e.assignee,assigneeName:e.assignee?o(e.assignee):null,reporter:e.mine?"You":e.reporter??o(e.senderId),createdAt:e.createdAt,build:r?.version?`${r.version}${r.build?` (${r.build})`:""}`:null,error:r?.error??null,repeatOf:e.duplicateOf??null,canOpen:!!r?.blobSha256,rowRevision:e.rowRevision}}function ns(e){if(e instanceof B){if(e.code==="signed_out")return{code:"signed_out",message:"Sign in to Buoy to see your team's bugs."};if(e.code==="needs_pro")return{code:"needs_pro",message:"The team list needs Buoy Pro or Business."};if(e.code==="offline")return{code:"offline",message:"Couldn't reach the bug links server. Tap Refresh to try again."};if(e.status===403)return{code:"no_access",message:"Your Buoy sign-in can send bugs but not read them. Ask your team admin, or sign in as yourself."};if(e.detail.error==="own_kits")return{code:"own_kits",message:"Your team keeps its own key. Open the list on buoy.gg or in Buoy Desktop."};if(e.status===404&&e.detail.error==="no_custody")return{code:"no_custody",message:"This server doesn't keep team keys. Open the list on the web or in Buoy Desktop."}}return{code:"error",message:e instanceof Error?e.message:String(e)}}async function as(e,t,n,a){if(!(!(e instanceof B)||t!==Ce||we()!==n||!a||V!==a)){if(e.status===404)return tn();(e.status===401||e.status===402||e.status===403)&&(ce(a),V=null,ue=null,Hn++,ye={kind:"blocked",...ns(e)},ze=n,en())}}var rs=e=>bt.indexOf(e.priority),rp=e=>e.status==="new"||e.status==="seen";function Ar(e,t,n){return e.filter(a=>t==="all"?true:rp(a)&&!a.repeatOf&&(t==="open"||a.assignee===n)).sort((a,r)=>(t==="all"?0:rs(a)-rs(r))||r.createdAt.localeCompare(a.createdAt))}async function os(e,t){let n=Jn(),a=n.kind==="ready"?n.bugs.find(g=>g.id===e):void 0,r=ee();if(!a||n.kind!=="ready"||!r)throw new Error("The list changed. Tap Refresh.");let o=Ce,i=we(),s=Rt,c=V,d=()=>o===Ce&&we()===i&&Rt===s,u;try{u=await at(ae(),`/api/bugs/${encodeURIComponent(e)}`,r,{method:"PATCH",body:{...t,rowRevision:a.rowRevision}})}catch(g){throw g instanceof B&&g.code==="conflict"?(d()&&await tn(),new Error("Someone changed this bug just now. This is the latest.")):(await as(g,o,i,c),g)}let l=ye;if(!d()||l.kind!=="ready")return;let h=u.rowRevision??a.rowRevision+1,m=l.me;ye={...l,bugs:l.bugs.map(g=>{if(g.id!==e||g.rowRevision>=h)return g;let k="assignee"in t?t.assignee?t.assignee===m?"You":Qt.get(t.assignee)??t.assignee:null:g.assigneeName;return{...g,...t,assigneeName:k,rowRevision:h}})},en()}async function op(e,t={}){if(!xr())throw new Error("Loading needs a dev build. Open this bug in your dev build to load it.");let n=ee(),a=we(),r=Ce,o=V,i=n&&a&&a===ze&&a===ue?o?.cases.get(e):void 0;if(!n||!i)throw new Error("This phone can't open that bug. Tap Refresh to read the list again.");let s=()=>r===Ce&&we()===a&&V===o,c=()=>new Error("The Bug Links screen closed, so Buoy stopped loading this bug."),d=i.card;if(!d?.blobSha256)throw new Error("This bug's note doesn't check out, so Buoy won't load it.");let u;try{u=await Ro(ae(),e,n)}catch(m){throw await as(m,r,a,o),m}if(!s())throw c();if(await qc(He(),u)!==d.blobSha256)throw new Error("This bug's file doesn't match its note, so Buoy won't load it.");let{kase:l}=await Qc(u,i.key,{crypto:Ne()});if(!s())throw c();let h=await pn(l,{...t,source:{id:e},stillWanted:s});if(!h.loaded&&!s())throw c();return h}import{Fragment as is,jsx as J,jsxs as tt}from"react/jsx-runtime";var ip={open:"Open",mine:"Mine",all:"All"},sp={urgent:{label:"Urgent",tone:"danger"},high:{label:"High",tone:"warning"},normal:{label:"Normal",tone:"neutral"},low:{label:"Low",tone:"info"}},lp={new:"New",seen:"Seen",fixed:"Fixed",wont_fix:"Won't fix"};function dp(e){let t=Math.max(0,(Date.now()-new Date(e).getTime())/1e3);return Number.isNaN(t)?e:t<60?"now":t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}function up({run:e,busy:t,onLoaded:n}){let a=Ji(np,Jn,Jn),[r,o]=Ir("open"),[i,s]=Ir(null);Ji(nr,ae,ae);let[,c]=Ir(0),d=we();vr(()=>{let g=setInterval(()=>c(k=>we()!==d?k+1:k),1e3);return()=>clearInterval(g)},[d]),vr(()=>{s(null),tn()},[d]),vr(()=>()=>Xi(),[]);let u=a.kind==="ready"?a.me:"",l=a.kind==="ready"?a.bugs:[],h=Ar(l,r,u),m={open:Ar(l,"open",u).length,mine:Ar(l,"mine",u).length,all:l.length};return tt(is,{children:[tt(K,{style:Q.head,children:[J(Vc,{children:"Team bugs"}),J(Le,{testID:"bug-links-team-refresh",accessibilityRole:"button",accessibilityLabel:"Refresh",onPress:()=>void tn(),style:Q.small,children:J(O,{style:Q.smallText,children:a.kind==="loading"||a.kind==="ready"&&a.refreshing?"Loading\u2026":"Refresh"})})]}),a.kind==="blocked"?J(O,{testID:"bug-links-team-blocked",style:[Q.meta,a.code!=="offline"&&Q.bad],children:a.message}):tt(is,{children:[J(Uc,{size:"sm",tabs:["open","mine","all"].map(g=>({key:g,label:`${ip[g]} ${m[g]}`})),activeKey:r,onChange:g=>o(g),testIDPrefix:"bug-links-team-view"}),a.kind==="ready"&&h.length===0?J(O,{testID:"bug-links-team-empty",style:Q.meta,children:r==="mine"?"Nothing is yours right now.":"No bugs here."}):null,h.map(g=>J(cp,{bug:g,me:u,open:i===g.id,onPress:()=>s(i===g.id?null:g.id),run:e,busy:t,onLoaded:n},g.id)),xr()?null:J(Gi,{children:"This is a release build, so Load is off here. Open the bug in your dev build to load it."})]})]})}function cp({bug:e,me:t,open:n,onPress:a,run:r,busy:o,onLoaded:i}){let s=e.status==="fixed"||e.status==="wont_fix",c=sp[e.priority],d=[e.reporter,dp(e.createdAt),e.build,e.assigneeName?`${e.assigneeName==="You"?"You have":`${e.assigneeName} has`} it`:null,s?lp[e.status]:null,e.repeatOf?"Repeat":null].filter(Boolean).join(" \xB7 "),u=(l,h,m)=>void r(l,async()=>(await os(e.id,h),m));return tt(Wc,{style:Q.card,children:[tt(Le,{testID:`bug-links-team-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:a,style:Q.inset,children:[tt(K,{style:Q.top,children:[J(O,{style:Q.title,numberOfLines:n?4:2,children:e.title}),e.priority!=="normal"?J(jc,{label:c.label,tone:c.tone}):null]}),J(O,{style:Q.meta,numberOfLines:2,children:d}),e.error&&e.error!==e.title?J(O,{style:[Q.meta,Q.bad],numberOfLines:n?3:1,children:e.error}):null]}),n?tt(K,{style:Q.actions,children:[xr()?J(zc,{testID:`bug-links-team-load-${e.id}`,label:o===`load-${e.id}`?"Loading\u2026":"Load",variant:"primary",disabled:!!o||!e.canOpen,onPress:()=>void r(`load-${e.id}`,async()=>{let l=await op(e.id);if(!l.loaded)throw new Error(l.steps.find(m=>!m.ok)?.detail??"The case didn't load.");let h=Jn();return h.kind==="ready"&&h.bugs.find(m=>m.id===e.id)?.status==="new"&&os(e.id,{status:"seen"}).catch(()=>{}),i(),"Loaded. The bar shows what came back."})}):null,e.canOpen?null:J(Gi,{tone:"danger",children:"This phone can't open this bug, so it can't load here."}),tt(K,{style:Q.row,children:[e.assignee===t?J(Gn,{label:"Let go",disabled:!!o,testID:`bug-links-team-unassign-${e.id}`,onPress:()=>u("assign",{assignee:null},"Let go.")}):J(Gn,{label:e.assignee?"Take it from them":"Take it",disabled:!!o,testID:`bug-links-team-assign-${e.id}`,onPress:()=>u("assign",{assignee:t},"It's yours.")}),s?J(Gn,{label:"Still broken",disabled:!!o,testID:`bug-links-team-reopen-${e.id}`,onPress:()=>u("status",{status:"seen"},"Opened again.")}):J(Gn,{label:"Fixed",disabled:!!o,testID:`bug-links-team-fixed-${e.id}`,onPress:()=>u("status",{status:"fixed"},"Marked fixed.")})]})]}):null]})}function Gn({label:e,onPress:t,testID:n,disabled:a}){return J(Le,{testID:n,onPress:t,disabled:a,accessibilityRole:"button",accessibilityLabel:e,style:[Q.small,a&&Q.off],children:J(O,{style:Q.smallText,children:e})})}var Q=Nt.create({head:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},card:{marginBottom:8},top:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8},title:{color:Ot.color.text,fontSize:15,fontWeight:"600",flexShrink:1},meta:{color:Ot.color.textSecondary,fontSize:12,marginTop:2},bad:{color:Ot.color.danger},inset:{paddingHorizontal:6,paddingVertical:2},actions:{marginTop:10,gap:8,paddingHorizontal:6},row:{flexDirection:"row",flexWrap:"wrap",gap:8},small:{paddingHorizontal:10,paddingVertical:6,borderRadius:Ot.radius.chip,backgroundColor:Ot.color.fill},off:{opacity:.5},smallText:{color:Ot.color.accent,fontSize:13,fontWeight:"600"}});import{Fragment as Dt,jsx as S,jsxs as G}from"react/jsx-runtime";var Er=(e,t)=>`${e} ${t}${e===1?"":"s"}`,pp={sending:{label:"Sending",tone:"info"},waiting:{label:"Waiting",tone:"warning"},sent:{label:"Sent",tone:"accent"},failed:{label:"Not sent",tone:"danger"},deleting:{label:"Deleting",tone:"neutral"}};function nn(e,t){return Ac(e,t,t)}function Br(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}var Yn;function hp(){if(Yn===void 0)try{Yn=Xn("@buoy-gg/core/web")}catch{Yn=null}return Yn?.useToolHost?.().close}var ss="";function ls(){let e=Rc(),t=nn(Na,St),n=nn(ht,be),a=nn(nr,ae),r=nn(_i,ic),o=nn(_i,sc),i=!ee()||t.some(T=>T.errorCode==="signed_out"),s=r?t.find(T=>T.localId===r):void 0,[c,d]=Ie(""),[u,l]=Ie("normal"),[h,m]=Ie(()=>ss),[g,k]=Ie(false),[f,p]=Ie(null),[y,w]=Ie(null),[$,A]=Ie(null),[P,N]=Ie([]),te=hp();br(()=>{if(!n?.report.replay?.active)return N([]);let T=true,v=()=>void Aa().then(I=>T&&N(I));v();let b=setInterval(v,3e3);return()=>{T=false,clearInterval(b)}},[n?.loadId,n?.report.replay?.active]),br(()=>(Fe(),Xe(),st(),()=>fr(null)),[]);let F=async(T,v)=>{Nr.dismiss(),p(T),w(null);try{let b=await v();b&&w({text:b,tone:"secondary",from:T})}catch(b){w({text:b instanceof Error?b.message:String(b),tone:"danger",from:T})}finally{p(null)}},M=kn();return G(Vr,{style:E.scroll,contentContainerStyle:[E.content,{paddingBottom:e.bottom+32}],keyboardShouldPersistTaps:"handled",children:[o?S(lt,{children:S(Pc,{onClose:()=>{gr(false),st()}})}):i?G(lt,{children:[S(O,{style:E.title,children:"Sign in to send bug links"}),S(je,{children:"Your team opens bug links with their own Buoy sign-in. Cases you make now wait on this phone until you sign in."}),S(Be,{testID:"bug-links-sign-in",label:"Sign in to Buoy",variant:"primary",onPress:()=>gr(true)})]}):null,s?G(Dt,{children:[S(Lt,{children:"Add a note"}),S(cs,{link:s,focused:true,run:F},s.localId)]}):null,S(Lt,{children:"Report a bug"}),G(lt,{children:[S(Mt,{testID:"bug-links-note",value:c,onChangeText:d,placeholder:"What went wrong? (you can skip this)",placeholderTextColor:oe.color.placeholder,style:E.input,multiline:true}),S(us,{value:u,onChange:l,testIDPrefix:"bug-links-priority"}),S(Be,{testID:"bug-links-report",label:f==="report"?"Saving\u2026":"Send a bug link",variant:"primary",disabled:!!f||!M,onPress:()=>void F("report",async()=>{await Vn({note:c.trim()||void 0,priority:u})&&(d(""),l("normal"))})}),S(je,{children:M?"Buoy saves the app's state, web calls, taps and screen. It takes out private data and locks the case on this phone. Only your team can open the link.":jo})]}),ee()?S(up,{run:F,busy:f,onLoaded:()=>te?.()}):null,ee()&&(y?.from==="assign"||y?.from==="status"||y?.from?.startsWith("load-"))?S(je,{tone:y.tone,style:E.message,children:y.text}):null,n?G(Dt,{children:[S(Lt,{children:"Loaded bug case"}),G(lt,{children:[S(O,{style:E.title,children:n.title}),S(O,{style:E.meta,children:`Reported ${Br(n.createdAt)}`}),n.report.steps.map((T,v)=>S(O,{style:[E.step,(!T.ok||T.warn)&&E.bad],testID:`bug-links-step-${v}`,children:`${T.warn?"\u26A0":T.ok?"\u2713":"\u2717"} ${T.part}: ${T.detail}`},v)),G(K,{style:E.rowButtons,children:[n.canLoadAgain?S(Be,{testID:"bug-links-body-load-again",label:"Load again",size:"md",fullWidth:false,onPress:()=>void F("again",async()=>{let T=await wt();if(!T.loaded)throw new Error(T.steps.find(v=>!v.ok)?.detail??"The case didn't load.")})}):null,n.report.replay?.active?S(Be,{testID:"bug-links-body-live",label:"Use live requests",size:"md",fullWidth:false,onPress:()=>void F("live",async()=>{let T=await hn();if(!T.ok)throw new Error(T.detail)})}):null,n.undoGone?null:S(Be,{testID:"bug-links-body-undo",label:"Restore my app",variant:"destructive",size:"md",fullWidth:false,onPress:()=>void F("undo",async()=>{let T=await Ut();if(be())throw new Error(T.find(v=>!v.ok&&v.part==="web calls")?.detail??T.find(v=>!v.ok)?.detail??"Restore didn't finish.");return"The app is back the way it was."})}),n.undoBlocked?S(Be,{testID:"bug-links-body-end",label:"End (keep the app as it is)",variant:"destructive",size:"md",fullWidth:false,onPress:()=>void F("end",async()=>{let T=await gn();if(!T.ok)throw new Error(T.detail)})}):null]}),P.length?G(Dt,{children:[S(O,{style:[E.step,E.bad],children:`Blocked ${P.length} calls the reporter's phone never made:`}),P.slice(0,8).map((T,v)=>S(O,{style:E.meta,numberOfLines:1,children:`${T.method} ${T.url}`},v))]}):null,S(je,{children:"Fixed it? Reload the app, then tap Load again to see if the bug is gone."})]})]}):null,S(Lt,{children:"Open a bug link"}),G(lt,{children:[G(K,{style:E.pasteRow,children:[S(Mt,{testID:"bug-links-open-input",value:h,onChangeText:m,placeholder:"https://buoy.gg/bug/\u2026#\u2026",placeholderTextColor:oe.color.placeholder,autoCapitalize:"none",autoCorrect:false,style:[E.input,E.pasteInput]}),S(Se,{label:"Paste",testID:"bug-links-open-paste",onPress:()=>void Oc().then(T=>{let v=T?.trim();v&&m(v)})})]}),y?.from==="open"?S(je,{tone:y.tone,style:E.message,children:y.text}):null,S(Be,{testID:"bug-links-open",label:f==="open"?"Opening\u2026":"Load bug",disabled:!!f||!h.trim(),onPress:()=>void F("open",async()=>{let T=await kr(h.trim(),{restart:g});if(!T.loaded)throw new Error(T.steps.find(v=>!v.ok)?.detail??"The case didn't load.");return ss=h.trim(),g||te?.(),g?"Loaded. The app restarts now, then loads it again.":"Loaded. The bar shows what came back."})}),G(K,{style:E.switchRow,children:[S(O,{style:E.meta,children:"Restart after loading (for values the app reads at start)"}),S(Cc,{testID:"bug-links-open-restart",value:g,onValueChange:k})]}),S(je,{children:"Loading needs a dev build. Web calls are answered from the case, and every other call is blocked."})]}),y&&y.from!=="open"&&y.from!=="assign"&&y.from!=="status"&&!y.from?.startsWith("load-")?S(je,{tone:y.tone,style:E.message,children:y.text}):null,S(Lt,{children:`Your bug links (${t.length})`}),t.length===0?S(je,{children:"Links you send from this phone show up here, so you never lose one."}):null,t.filter(T=>T!==s).map(T=>S(cs,{link:T,focused:false,run:F},T.localId)),S(Lt,{children:"Server"}),G(lt,{children:[S(Mt,{testID:"bug-links-server",value:$??a,onChangeText:A,autoCapitalize:"none",autoCorrect:false,style:E.input}),G(K,{style:E.rowButtons,children:[S(Be,{testID:"bug-links-server-save",label:"Save",size:"md",fullWidth:false,disabled:$===null,onPress:()=>void F("server",async()=>(await _n($.trim()),A(null),"Saved."))}),a!==Ln?S(Be,{testID:"bug-links-server-reset",label:"Use buoy.gg",size:"md",fullWidth:false,onPress:()=>void F("server",async()=>void await _n(null))}):null]}),S(je,{children:`Random numbers for the lock: ${M==="expo-uuid"?"Expo's native UUIDs":M==="getRandomValues"?"crypto.getRandomValues":"none found"}.`})]})]})}var ds={urgent:"Urgent",high:"High",normal:"Normal",low:"Low"};function us({value:e,onChange:t,testIDPrefix:n}){return G(K,{style:E.priority,children:[S(O,{style:E.meta,children:"How soon should it be fixed?"}),S(Bc,{size:"sm",tabs:bt.map(a=>({key:a,label:ds[a]})),activeKey:e,onChange:a=>t(a),testIDPrefix:n})]})}function cs({link:e,focused:t,run:n}){let[a,r]=Ie(t),[o,i]=Ie(e.note??""),[s,c]=Ie(false),d=Gd(e),u=$c(null);br(()=>{if(!t)return;r(true);let h=setTimeout(()=>u.current?.focus(),400);return()=>clearTimeout(h)},[t]);let l=pp[e.status];return G(lt,{style:E.linkCard,children:[G(K,{style:E.linkTop,children:[S(O,{style:E.title,numberOfLines:2,children:e.note?.split(`
20
+ `)[0]||(e.screen?`Bug on ${e.screen}`:`Bug from ${Br(e.createdAt)}`)}),S(Ec,{label:l.label,tone:l.tone})]}),S(O,{style:E.meta,children:`${e.priority&&e.priority!=="normal"?`${ds[e.priority]} \xB7 `:""}${Br(e.createdAt)} \xB7 ${Er(e.header.steps,"step")} \xB7 ${Er(e.header.errors,"error")} \xB7 ${Er(e.removed.length,"private value")} removed`}),e.error&&e.status!=="sent"?S(O,{style:[E.meta,E.bad],children:e.error}):null,e.status==="sent"&&e.needsPut?S(O,{testID:`bug-links-note-pending-${e.localId}`,style:[E.meta,E.bad],children:`Note waiting to send. ${e.error??"Buoy will try again."}`}):null,e.status==="sent"&&e.wrapPending?S(O,{testID:`bug-links-wrap-wait-${e.localId}`,style:[E.meta,E.bad],children:`Not locked to your team yet, so only this link opens it. ${e.wrapWait?.message??"Buoy will try again."}`}):null,a?G(Dt,{children:[S(us,{value:e.priority??"normal",onChange:h=>void n("priority",async()=>void await Kn(e.localId,h)),testIDPrefix:`bug-links-priority-${e.localId}`}),S(Mt,{ref:u,testID:`bug-links-note-${e.localId}`,value:o,onChangeText:i,placeholder:"What went wrong?",placeholderTextColor:oe.color.placeholder,style:E.input,multiline:true}),S(Be,{testID:`bug-links-note-save-${e.localId}`,label:"Save note",size:"md",onPress:()=>void n("note",async()=>{let h=await cr(e.localId,o);return r(false),fr(null),h?.needsPut?"Note saved on this phone. It goes up when Buoy can reach the server.":"Note saved. The link stays the same."})})]}):null,G(K,{style:E.rowButtons,children:[e.url?G(Dt,{children:[S(Se,{label:"Copy",onPress:()=>void Lc(e.url),testID:`bug-links-copy-${e.localId}`}),S(Se,{label:"Share",onPress:()=>void Qn.share({message:e.url}).catch(()=>{}),testID:`bug-links-share-${e.localId}`})]}):null,e.errorCode==="other_account"?S(Se,{label:"Send as me",onPress:()=>void n("send",async()=>void await Qe(e.localId,{asMe:true})),testID:`bug-links-send-as-me-${e.localId}`}):e.status==="waiting"||e.status==="failed"?S(Se,{label:"Send now",onPress:()=>void n("send",async()=>void await Qe(e.localId)),testID:`bug-links-send-${e.localId}`}):null,e.status==="sent"&&e.wrapPending&&e.wrapWait?.code==="new_root"&&e.wrapWait.teamKeyId&&e.server?S(Se,{label:"Trust new team key",onPress:()=>void n("send",async()=>(await Zu(e.server,e.wrapWait.teamKeyId,ee()),await ur(e.localId),"Locked to your team's new key.")),testID:`bug-links-trust-root-${e.localId}`}):e.status==="sent"&&e.wrapPending?S(Se,{label:"Lock to team",onPress:()=>void n("send",async()=>void await ur(e.localId)),testID:`bug-links-wrap-${e.localId}`}):null,!a&&d?S(Se,{label:"Note",onPress:()=>r(true),testID:`bug-links-edit-${e.localId}`}):null,s?G(Dt,{children:[S(Se,{label:"Delete for everyone?",danger:true,onPress:()=>void n("delete",async()=>void await Pt(e.localId)),testID:`bug-links-delete-confirm-${e.localId}`}),S(Se,{label:"Keep",onPress:()=>c(false),testID:`bug-links-delete-keep-${e.localId}`})]}):S(Se,{label:"Delete",danger:true,onPress:()=>e.id?c(true):void n("delete",async()=>void await Pt(e.localId)),testID:`bug-links-delete-${e.localId}`})]})]})}function Se({label:e,onPress:t,testID:n,danger:a}){return S(Le,{testID:n,onPress:t,accessibilityRole:"button",accessibilityLabel:e,style:E.small,children:S(O,{style:[E.smallText,a&&E.bad],children:e})})}var E=Nt.create({scroll:{flex:1},priority:{gap:6},content:{padding:oe.gutter,gap:8},input:{color:oe.color.text,backgroundColor:oe.color.surfaceElevated,borderRadius:oe.radius.input,paddingHorizontal:12,paddingVertical:10,fontSize:15,marginBottom:10,minHeight:44},title:{color:oe.color.text,fontSize:15,fontWeight:"600",flexShrink:1},pasteRow:{flexDirection:"row",alignItems:"center",gap:6},pasteInput:{flex:1},meta:{color:oe.color.textSecondary,fontSize:12,marginTop:2},step:{color:oe.color.textSecondary,fontSize:13,marginTop:4},bad:{color:oe.color.danger},rowButtons:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:10},linkCard:{marginBottom:8},linkTop:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8},small:{paddingHorizontal:10,paddingVertical:6,borderRadius:oe.radius.chip,backgroundColor:oe.color.fill},smallText:{color:oe.color.accent,fontSize:13,fontWeight:"600"},message:{marginVertical:4},switchRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8,marginTop:10}});import{jsx as ps}from"react/jsx-runtime";var an="#F43F5E";function fp(){return null}var gp=Fi({id:"report-bug",name:"REPORT BUG",description:"One tap: save this bug and copy a locked link to it",slot:"both",color:an,icon:({size:e,color:t})=>ps(Sc,{size:e,color:t??an}),component:fp,launchMode:"toggle-only",onPress:e=>{e?.closeMenu?.(),Vn()}}),hs=Fi({id:"bug-links",name:"BUG LINKS",description:"Report with a note, open a teammate's bug link, and see your links",slot:"both",color:an,icon:({size:e,color:t})=>ps(Tc,{size:e,color:t??an}),component:ls,modal:{subtitle:"locked bug reports your team can load"}}),mp=xc(hs);import{captureBugCase as yp,createSyncAdapter as wp}from"@buoy-gg/shared-ui/web";function nt(e){return e&&typeof e=="object"?e:{}}function We(e,t){let n=e[t];return typeof n=="string"&&n.trim()?n.trim():void 0}function rn(e,t=false){return{localId:e.localId,status:e.status,url:t?e.url:e.url?.split("#")[0],note:e.note,createdAt:e.createdAt,expiresAt:e.expiresAt,error:e.error,steps:e.header.steps,errors:e.header.errors,removed:e.removed.length,linkNeeded:e.status==="sent"&&!!e.wrapPending}}function Cr(){let e=be();return{server:ae(),randomSource:kn(),report:(()=>{let t=Bt();return t?{...t,url:t.url?.split("#")[0]}:null})(),loaded:e?{...e,undo:void 0,source:e.source?.id?{id:e.source.id}:null}:null,links:St().slice(0,20).map(t=>rn(t,false))}}var bp=wp({version:1,getSnapshot:Cr,subscribe(e){Fe(),Xe();let t=[Na(e),ht(e),Wn(e),nr(e)];return()=>t.forEach(n=>n())},actions:{getState:async()=>(await Promise.all([Fe(),Xe()]),{...Cr(),blocked:await Aa()}),report:async e=>{let t=We(nt(e),"priority"),n=bt.find(r=>r===t),a=await Vn({note:We(nt(e),"note"),priority:n});return a?{ok:a.status==="sent",...rn(a,true)}:{ok:false,error:Bt()?.message??"The report failed."}},capture:async e=>({ok:true,case:await yp({note:We(nt(e),"note"),rules:tr()})}),load:async e=>{let t=nt(e),n={replay:t.replay!==false,clock:t.clock!==false,sequence:t.sequence===true,restart:t.restart===true,otherApp:t.otherApp===true},a=We(t,"link");if(a){let r=await kr(a,n);return{ok:r.loaded,report:r}}if(t.case&&typeof t.case=="object"){let r=await pn(t.case,{...n,source:{id:We(t,"id")}});return{ok:r.loaded,report:r}}throw new Error("load needs `link` (a whole bug link) or `case` (an opened bug case).")},loadAgain:async()=>{let e=await wt();return{ok:e.loaded,report:e}},undo:async()=>{let e=await Ut();return{ok:!be()?.undoBlocked,steps:e}},end:async()=>gn(),leaveSandbox:async()=>hn(),listLinks:async()=>(await Fe(),{links:St().map(e=>rn(e,true))}),retry:async e=>{let t=We(nt(e),"localId");return t?await Qe(t):await st(),{ok:true,links:St().map(n=>rn(n))}},addNote:async e=>{let t=nt(e),n=We(t,"localId"),a=typeof t.note=="string"?t.note:void 0;if(!n||a===void 0)throw new Error("addNote needs `localId` and `note`.");let r=await cr(n,a);return r?{ok:true,...rn(r)}:{ok:false,error:"No link with that localId."}},deleteLink:async e=>{let t=We(nt(e),"localId");if(!t)throw new Error("deleteLink needs `localId`.");return await Pt(t),{ok:true}},setServer:async e=>{let t=nt(e),n=t.server===null?null:We(t,"server");if(n===void 0)throw new Error('setServer needs `server`, like "http://localhost:8898", or null.');return{ok:true,server:await _n(n)}}}});import{jsx as fs}from"react/jsx-runtime";function kp({children:e,style:t,testID:n}){return fs(K,{nativeID:"buoy-mask",collapsable:false,style:t,testID:n,children:e})}function vp({children:e,style:t,testID:n}){return fs(K,{nativeID:"buoy-unmask",collapsable:false,style:t,testID:n,children:e})}var gs=typeof navigator<"u"&&navigator.product==="ReactNative",ms=typeof window<"u"&&typeof document<"u";function Ip(){let e=0,t=()=>{e++;let n=e<20?100:1500;xl().then(a=>{!(a.watching.length>=3&&a.touches)&&e<60&&setTimeout(t,n)}).catch(()=>{e<60&&setTimeout(t,n)})};t()}function ys(e){if(!e)return"";try{let t=JSON.parse(e),n=t.block??(t.options?.replay!==false&&!!t.report?.replay?.active);return[t.undo?.undoId,t.createdAt,t.source?.id,t.phase,n].join("|")}catch{return e}}var ws="__buoyBugLinksBooted",Sp=globalThis[ws]===true;(gs||ms)&&!Sp&&(globalThis[ws]=true,Qr(),Ip(),Ic(),Xe(),Fe().then(()=>st()),kd(),Dr?.addEventListener?.("change",e=>{e==="active"&&st()}),!gs&&ms&&(document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&st()}),window.addEventListener("pageshow",e=>{e.persisted&&window.location.reload()}),window.addEventListener("storage",e=>{e.key===null?be()&&window.location.reload():e.key===Kr.bugLinks.loaded()&&ys(e.oldValue)!==ys(e.newValue)?window.location.reload():e.key===Kr.bugLinks.links()&&Fo()})));Du();export{an as BUG_LINKS_COLOR,bt as BUG_PRIORITIES,ls as BugLinksBody,kc as BugLinksOverlay,kp as BuoyMask,vp as BuoyUnmask,Ln as DEFAULT_SERVER,cr as addNote,ae as bugLinksServer,bp as bugLinksSyncAdapter,hs as bugLinksToolPreset,oo as buildSandbox,Ne as caseCrypto,qu as configureBugLinks,Ya as configureMedia,mp as createBugLinksTool,Pt as deleteLink,Hi as fetchBugLink,Cr as getBugLinksSnapshot,hn as leaveSandbox,wt as loadAgain,pn as loadBugCase,be as loadedCase,Mu as markBugHere,Ga as mediaUnavailableReason,St as myLinks,kr as openBugLink,Xo as phoneCaseCrypto,zu as probeFrame,kn as randomSource,Vn as reportBug,gp as reportBugToolPreset,Bt as reportState,st as retryWaiting,_d as setBugLinksCredentialProvider,_n as setBugLinksServer,Kn as setLinkPriority,_u as startRecording,Nu as stopRecording,ht as subscribeLoadedCase,Na as subscribeMyLinks,Wn as subscribeReportState,Ut as undoBugCase};
package/package.json CHANGED
@@ -1,6 +1,122 @@
1
1
  {
2
2
  "name": "@buoy-gg/bug-links",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "7.0.81",
4
+ "description": "Report a bug in one tap. Buoy captures the app state, web calls, console, taps and screen, takes out private data, locks it on the phone and gives you a link. A teammate opens the link and loads the bug.",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "lib/module/index.js",
9
+ "source": "src/index.tsx",
10
+ "files": [
11
+ "lib",
12
+ "ios",
13
+ "android/build.gradle",
14
+ "android/consumer-rules.pro",
15
+ "android/src",
16
+ "BuoyBugLinks.podspec"
17
+ ],
18
+ "dependencies": {
19
+ "@noble/ciphers": "1.3.0",
20
+ "@noble/curves": "1.9.7",
21
+ "@noble/hashes": "1.8.0",
22
+ "fflate": "^0.8.3",
23
+ "@buoy-gg/shared-ui": "^7.0.81"
24
+ },
25
+ "peerDependencies": {
26
+ "@buoy-gg/license": "7.0.81",
27
+ "react": "*"
28
+ },
29
+ "devDependencies": {
30
+ "@types/react": "^19.1.0",
31
+ "@types/react-native": "^0.73.0",
32
+ "typescript": "~5.8.3",
33
+ "@buoy-gg/license": "^7.0.81"
34
+ },
35
+ "react-native-builder-bob": {
36
+ "source": "src",
37
+ "output": "lib",
38
+ "targets": [
39
+ "commonjs",
40
+ "module",
41
+ [
42
+ "typescript",
43
+ {
44
+ "project": "tsconfig.build.json"
45
+ }
46
+ ]
47
+ ]
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/Buoy-gg/buoy.git",
52
+ "directory": "packages/bug-links"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/LovesWorking/react-native-buoy/issues"
56
+ },
57
+ "homepage": "https://buoy.gg/buoy/latest/docs/tools/bug-links",
58
+ "publishConfig": {
59
+ "access": "public",
60
+ "tag": "latest"
61
+ },
62
+ "keywords": [
63
+ "react-native",
64
+ "expo",
65
+ "devtools",
66
+ "debugging",
67
+ "bug-report",
68
+ "bug-reporting",
69
+ "qa",
70
+ "repro",
71
+ "session-replay",
72
+ "end-to-end-encryption"
73
+ ],
74
+ "exports": {
75
+ ".": {
76
+ "browser": {
77
+ "types": "./lib/typescript/index.d.ts",
78
+ "default": "./lib/web/index.mjs"
79
+ },
80
+ "import": {
81
+ "types": "./lib/typescript/index.d.ts",
82
+ "default": "./lib/module/index.js"
83
+ },
84
+ "require": {
85
+ "types": "./lib/typescript/index.d.ts",
86
+ "default": "./lib/commonjs/index.js"
87
+ }
88
+ },
89
+ "./web": {
90
+ "types": "./lib/typescript/index.d.ts",
91
+ "default": "./lib/web/index.mjs"
92
+ }
93
+ },
94
+ "peerDependenciesMeta": {
95
+ "@buoy-gg/core": {
96
+ "optional": true
97
+ },
98
+ "react-native": {
99
+ "optional": true
100
+ },
101
+ "react-native-web": {
102
+ "optional": true
103
+ },
104
+ "react-dom": {
105
+ "optional": true
106
+ }
107
+ },
108
+ "sideEffects": [
109
+ "./src/index.tsx",
110
+ "./lib/commonjs/index.js",
111
+ "./lib/module/index.js",
112
+ "./lib/web/**/*.mjs"
113
+ ],
114
+ "scripts": {
115
+ "build": "bob build && pnpm run build:web",
116
+ "typecheck": "tsc --noEmit",
117
+ "clean": "rimraf lib",
118
+ "test": "pnpm run typecheck",
119
+ "postinstall": "echo \"Run pnpm build to compile this package\"",
120
+ "build:web": "node ../../scripts/build-web.mjs bug-links"
121
+ }
6
122
  }