@sphoro/bugcatch-web-sdk 0.17.0 → 0.18.0

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 (51) hide show
  1. package/README.md +69 -4
  2. package/dist/bugcatch-call.es.js +586 -0
  3. package/dist/bugcatch-call.es.js.map +1 -0
  4. package/dist/bugcatch-call.umd.js +2 -0
  5. package/dist/bugcatch-call.umd.js.map +1 -0
  6. package/dist/bugcatch-core.es.js +3214 -0
  7. package/dist/bugcatch-core.es.js.map +1 -0
  8. package/dist/bugcatch-panel.es.js +2402 -0
  9. package/dist/bugcatch-panel.es.js.map +1 -0
  10. package/dist/bugcatch-panel.umd.js +1240 -0
  11. package/dist/bugcatch-panel.umd.js.map +1 -0
  12. package/dist/bugcatch.es.js +2 -5625
  13. package/dist/bugcatch.es.js.map +1 -1
  14. package/dist/bugcatch.standalone.umd.js +1536 -0
  15. package/dist/bugcatch.standalone.umd.js.map +1 -0
  16. package/dist/bugcatch.umd.js +89 -1224
  17. package/dist/bugcatch.umd.js.map +1 -1
  18. package/package.json +6 -6
  19. package/src/announcements.js +147 -0
  20. package/src/busy.js +18 -0
  21. package/src/call.js +7 -0
  22. package/src/capture.js +9 -0
  23. package/src/chunks.js +56 -0
  24. package/src/gesture.js +33 -0
  25. package/src/icons.js +18 -0
  26. package/src/identity.js +13 -8
  27. package/src/incoming-call.js +8 -30
  28. package/src/index.d.ts +50 -0
  29. package/src/index.js +138 -35
  30. package/src/lazy.js +23 -0
  31. package/src/notice.js +68 -0
  32. package/src/panel/call.js +242 -0
  33. package/src/panel/compose.js +416 -0
  34. package/src/panel/composer.js +235 -0
  35. package/src/panel/icons.js +34 -0
  36. package/src/panel/index.js +251 -0
  37. package/src/panel/known.js +130 -0
  38. package/src/panel/messages.js +176 -0
  39. package/src/panel/notices.js +34 -0
  40. package/src/panel/picks.js +61 -0
  41. package/src/panel/refs.js +321 -0
  42. package/src/panel/render.js +124 -0
  43. package/src/panel/signin.js +228 -0
  44. package/src/panel/styles.js +960 -0
  45. package/src/panel/thread.js +384 -0
  46. package/src/session.js +8 -3
  47. package/src/umd/call.js +6 -0
  48. package/src/umd/lazy.js +98 -0
  49. package/src/umd/panel.js +6 -0
  50. package/src/updates.js +20 -7
  51. package/src/widget.js +250 -3260
@@ -0,0 +1,1536 @@
1
+ (function(U,K){typeof exports=="object"&&typeof module<"u"?module.exports=K():typeof define=="function"&&define.amd?define(K):(U=typeof globalThis<"u"?globalThis:U||self,U.BugCatch=K())})(this,function(){"use strict";var xn=U=>{throw TypeError(U)};var wr=(U,K,ae)=>K.has(U)||xn("Cannot "+ae);var kn=(U,K,ae)=>K.has(U)?xn("Cannot add the same private member more than once"):K instanceof WeakSet?K.add(U):K.set(U,ae);var H=(U,K,ae)=>(wr(U,K,"access private method"),ae);var B,De,Sn,oe,$n,st,Ne,Ue,ct,Cn,Tn,En,_e,In;const U="[REDACTED]",K=new Set(["auth","bearer","session","sid","phpsessid","otp","pass","passwd","pwd","sig","codeverifier"]),ae=["token","secret","password","passwd","apikey","signature","credential","sessionid","privatekey","accesskey","authorization"],Ln=new Set(["key","code","state","nonce","salt","hash"]),lt=[/eyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]+/g,/(?:AKIA|ASIA|AROA|AIDA|AGPA|ANPA|ANVA|APKA)[0-9A-Z]{16}/g,/AIza[\w-]{35}/g,/gh[pousr]_[A-Za-z0-9]{36,}/g,/github_pat_\w{22,}/g,/[sprk]k_(?:live|test)_[0-9A-Za-z]{10,}/g,/xox[abposr]-[A-Za-z0-9-]{10,}/g,/sk-ant-[\w-]{20,}/g,/sk-[\w-]{20,}/g,/glpat-[\w-]{20,}/g,/shp(?:at|ss|ca|pa)_[A-Za-z0-9]{32}/g],An=/\bBearer\s+[\w.~+/=-]{8,}/gi,Mn=/^([A-Za-z][A-Za-z0-9+.-]*:\/\/)([^/?#@]+)@/;function dt(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function Bn(t){return dt(t).toLowerCase().replace(/[^a-z0-9]/g,"")}function Rn(t){return t.length>=20?!0:lt.some(e=>(e.lastIndex=0,e.test(t)))}function jn(t,e){const n=Bn(t);if(!n)return!1;if(K.has(n))return!0;for(const o of ae)if(n.includes(o))return!0;return Ln.has(n)?Rn(dt(e)):!1}function Pe(t){return t.split("&").map(e=>{const n=e.indexOf("=");if(n===-1)return e;const o=e.slice(0,n),a=e.slice(n+1);return a&&jn(o,a)?`${o}=${U}`:e}).join("&")}function ut(t){let e=t;for(const n of lt)n.lastIndex=0,e=e.replace(n,U);return e}function pt(t){if(t==null)return t;let e=String(t);if(!e)return e;e=e.replace(Mn,`$1${U}@`);const n=e.indexOf("#");let o=n===-1?e:e.slice(0,n),a=n===-1?"":e.slice(n);const r=o.indexOf("?");if(r!==-1&&(o=o.slice(0,r+1)+Pe(o.slice(r+1))),a.length>1){const i=a.slice(1),s=i.indexOf("?");s!==-1?a=`#${i.slice(0,s+1)}${Pe(i.slice(s+1))}`:i.includes("=")&&(a=`#${Pe(i)}`)}return ut(o+a)}function On(t){if(t==null)return t;let e=String(t);return e&&(e=e.replace(/[A-Za-z][A-Za-z0-9+.-]{0,30}:\/\/[^\s"'<>)\]]+/g,n=>pt(n)),e=e.replace(An,`Bearer ${U}`),ut(e))}function ke(t){const e=[];return{push(n){e.push(n),e.length>t&&e.splice(0,e.length-t)},all:()=>e.slice(),clear:()=>{e.length=0},get size(){return e.length}}}const ht=["log","info","warn","error","debug"];function zn(t,{levels:e=["warn","error","log","info"]}={}){const n={};for(const o of ht)n[o]=console[o],e.includes(o)&&(console[o]=(...a)=>{try{t.push({level:o,text:a.map(bt).join(" ").slice(0,2e3),at:new Date().toISOString()})}catch{}n[o].apply(console,a)});return()=>{for(const o of ht)console[o]=n[o]}}function Qn(t,{slowMs:e=2e3}={}){const n=window.fetch,o=XMLHttpRequest.prototype.open,a=XMLHttpRequest.prototype.send;return n&&(window.fetch=async function(...i){var f,d,u;const s=performance.now(),c=typeof i[0]=="string"?i[0]:(f=i[0])==null?void 0:f.url,l=((d=i[1])==null?void 0:d.method)||(typeof i[0]=="object"?(u=i[0])==null?void 0:u.method:"GET")||"GET";try{const g=await n.apply(this,i);return Ke(t,{url:c,method:l,status:g.status,ms:Math.round(performance.now()-s),slowMs:e}),g}catch(g){throw Ke(t,{url:c,method:l,status:0,error:String((g==null?void 0:g.message)||g),ms:Math.round(performance.now()-s),slowMs:e}),g}}),XMLHttpRequest.prototype.open=function(i,s,...c){return this.__bc={method:i,url:s,started:0},o.call(this,i,s,...c)},XMLHttpRequest.prototype.send=function(...i){return this.__bc&&(this.__bc.started=performance.now(),this.addEventListener("loadend",()=>{Ke(t,{url:this.__bc.url,method:this.__bc.method,status:this.status,ms:Math.round(performance.now()-this.__bc.started),slowMs:e})})),a.apply(this,i)},()=>{n&&(window.fetch=n),XMLHttpRequest.prototype.open=o,XMLHttpRequest.prototype.send=a}}function Ke(t,{url:e,method:n,status:o,ms:a,error:r,slowMs:i}){try{t.push({url:pt(String(e)).slice(0,500),method:n,status:o,ms:a,error:r===void 0?void 0:On(r),failed:o===0||o>=400,slow:a>=i,at:new Date().toISOString()})}catch{}}function Hn(t){const e=o=>{const a=String(o.message||"Error"),r=o.filename?` (${o.filename}:${o.lineno}:${o.colno})`:"";t.push({level:"error",text:(/^uncaught/i.test(a)?a:`Uncaught ${a}`)+r,at:new Date().toISOString()})},n=o=>{t.push({level:"error",text:`Unhandled rejection: ${bt(o.reason)}`,at:new Date().toISOString()})};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",n),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",n)}}async function ft(){const t=gt();try{if(navigator.getBattery){const e=await navigator.getBattery();t.battery=Math.round(e.level*100),t.charging=e.charging}}catch{}return t}function gt(){var e,n,o,a,r,i,s,c,l;const t=window.navigator||{};return{userAgent:t.userAgent,platform:t.platform,language:t.language,languages:t.languages?[...t.languages]:null,online:t.onLine,cookieEnabled:t.cookieEnabled,maxTouchPoints:t.maxTouchPoints??null,viewport:{width:window.innerWidth,height:window.innerHeight},screen:{width:(e=window.screen)==null?void 0:e.width,height:(n=window.screen)==null?void 0:n.height,availWidth:(o=window.screen)==null?void 0:o.availWidth,availHeight:(a=window.screen)==null?void 0:a.availHeight,colorDepth:(r=window.screen)==null?void 0:r.colorDepth,orientation:((s=(i=window.screen)==null?void 0:i.orientation)==null?void 0:s.type)||null},devicePixelRatio:window.devicePixelRatio,referrer:document.referrer||null,title:document.title,capturedAt:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffsetMinutes:new Date().getTimezoneOffset(),browserMode:t.webdriver?"Automated":"Normal",doNotTrack:t.doNotTrack||null,hardwareConcurrency:t.hardwareConcurrency??null,deviceMemory:t.deviceMemory??null,connection:t.connection?{effectiveType:t.connection.effectiveType,downlink:t.connection.downlink,rtt:t.connection.rtt,saveData:t.connection.saveData}:null,prefersColorScheme:(c=window.matchMedia)!=null&&c.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light",prefersReducedMotion:((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches)||!1}}function bt(t){if(typeof t=="string")return t;if(t instanceof Error)return`${t.name}: ${t.message}`;try{return JSON.stringify(t)}catch{return String(t)}}const mt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M4 11.5a7.5 7 0 0 1 7.5-7h1a7.5 7 0 0 1 0 14H9l-4.2 2.6a.5.5 0 0 1-.76-.5l.5-3.1A7 7 0 0 1 4 11.5z"/><path d="M8.5 11.5h.01M12 11.5h.01M15.5 11.5h.01" stroke-width="2.6"/></svg>',qn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9.5l6 6 6-6"/></svg>',Dn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4.2"/><path d="M12 2.6v2.2M12 19.2v2.2M2.6 12h2.2M19.2 12h2.2M5.4 5.4l1.6 1.6M17 17l1.6 1.6M18.6 5.4L17 7M7 17l-1.6 1.6"/></svg>',Nn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M20 13.4A8.2 8.2 0 1 1 10.6 4a6.6 6.6 0 0 0 9.4 9.4z"/></svg>',Un='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><rect x="2.8" y="4.4" width="18.4" height="12.6" rx="2.2"/><path d="M8.6 20.2h6.8"/><path d="M12 4.4v12.6"/><path d="M12 7.2a3.6 3.6 0 0 1 0 7.2z" fill="currentColor" stroke="none"/></svg>',re='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5.2M12 16.3h.01"/></svg>',fe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>',ie='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.8l4.6 4.4L19 7"/></svg>',yt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 11v5.5M12 7.7h.01"/></svg>',_n='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.3 4.2a2 2 0 0 1 3.4 0l7.6 13.1a2 2 0 0 1-1.7 3H4.4a2 2 0 0 1-1.7-3z"/><path d="M12 9.5v4.2M12 17h.01"/></svg>';function wt(t,e){console.warn(`[BugCatch] ${t}`,...e?[e]:[]);const n=new Error("[BugCatch] part of the widget could not be loaded — check the connection and try again.");return e&&(n.cause=e),n}function vt(t){let e=null;return(...n)=>(e||(e=t(...n).catch(o=>{throw e=null,o})),e)}const xt=vt(()=>Promise.resolve().then(()=>Ga).catch(t=>{throw wt("the report panel could not be loaded.",t)})),Se=vt(()=>Promise.resolve().then(()=>gr).catch(t=>{throw wt("the calling code could not be loaded.",t)})),Pn={info:yt,success:ie,warning:_n,critical:re};function kt(t,{where:e,onDismiss:n}){const o=document.createElement("div");o.className=`notice tone-${t.tone} at-${e}`,o.setAttribute("role","status");const a=document.createElement("span");a.className="notice-ico",a.setAttribute("aria-hidden","true"),a.innerHTML=Pn[t.tone]||yt;const r=document.createElement("div");r.className="notice-text";const i=document.createElement("strong");if(i.textContent=t.title,r.append(i),t.body){const s=document.createElement("p");s.textContent=t.body,r.append(s)}if(t.ctaHref&&t.ctaLabel){const s=document.createElement("a");s.className="notice-cta",s.href=t.ctaHref,s.textContent=t.ctaLabel,/^https?:/i.test(t.ctaHref)&&(s.target="_blank",s.rel="noopener noreferrer"),r.append(s)}if(o.append(a,r),t.dismissible&&n){const s=document.createElement("button");s.type="button",s.className="notice-x",s.setAttribute("aria-label","Dismiss this notice"),s.innerHTML=fe,s.addEventListener("click",()=>n(t)),o.append(s)}return o}const St={"bottom-right":"bottom:20px;right:20px;","bottom-left":"bottom:20px;left:20px;","top-right":"top:20px;right:20px;","top-left":"top:20px;left:20px;"},$t=[{value:"light",label:"Light",icon:Dn},{value:"dark",label:"Dark",icon:Nn},{value:"auto",label:"System default",icon:Un}],Ct="bugcatch:theme";function Kn(){try{const t=localStorage.getItem(Ct);return $t.some(e=>e.value===t)?t:null}catch{return null}}function Vn(t){try{localStorage.setItem(Ct,t)}catch{}}const Fn=t=>`
2
+ :host { all: initial; }
3
+ :host {
4
+ --bc-accent: ${t};
5
+ --bc-on-accent: #fff;
6
+ --bc-bg: #fff;
7
+ --bc-elevated: #fff;
8
+ --bc-fg: #14161c;
9
+ --bc-muted: #5f6673;
10
+ --bc-faint: #9aa1ad;
11
+ --bc-border: #e6e8ee;
12
+ --bc-subtle: #f4f5f8;
13
+ --bc-raised: #fff;
14
+ --bc-danger: #dc2626;
15
+ --bc-ok: #059669;
16
+ --bc-warn: #b45309;
17
+ /* The lockup's own two colours, kept off --bc-accent on purpose: that one is
18
+ the customer's brand, and this mark is ours. Values are the light cut of
19
+ brand/sphoro-bugcatch-primary.svg, pulled up from near-black so the mark
20
+ identifies itself without out-shouting the host's page. */
21
+ --bc-brand-ink: #4b5563;
22
+ --bc-brand-mark: #5647ee;
23
+ --bc-shadow: 0 24px 64px rgba(10,12,16,.22), 0 4px 14px rgba(10,12,16,.08);
24
+ --bc-shadow-sm: 0 1px 2px rgba(10,12,16,.06), 0 1px 1px rgba(10,12,16,.04);
25
+ --bc-dur: 240ms;
26
+ --bc-ease: cubic-bezier(.22,1,.36,1);
27
+ /* The system everything below is drawn from. Derived tokens are written in
28
+ terms of the ones above, so a host that overrides --bc-accent or the
29
+ palette gets a coherent result without touching these. */
30
+ --bc-accent-soft: color-mix(in srgb, var(--bc-accent) 10%, var(--bc-bg));
31
+ --bc-accent-line: color-mix(in srgb, var(--bc-accent) 32%, var(--bc-border));
32
+ --bc-ring: 0 0 0 3px color-mix(in srgb, var(--bc-accent) 22%, transparent);
33
+ --bc-r-sm: 8px;
34
+ --bc-r-md: 12px;
35
+ --bc-r-lg: 18px;
36
+ --bc-r-xl: 22px;
37
+ --bc-fs-xs: 11.5px;
38
+ --bc-fs-sm: 12.5px;
39
+ --bc-fs-md: 14px;
40
+ --bc-fs-lg: 16px;
41
+ --bc-pad: 18px;
42
+ }
43
+ :host(.bc-dark) {
44
+ --bc-bg: #14161c;
45
+ --bc-elevated: #1c1f27;
46
+ --bc-fg: #eef0f4;
47
+ --bc-muted: #a3aab6;
48
+ --bc-faint: #6f7682;
49
+ --bc-border: #2a2e38;
50
+ --bc-subtle: #1f222a;
51
+ --bc-raised: #363d4b;
52
+ --bc-warn: #f59e0b;
53
+ --bc-brand-ink: #9aa1ad;
54
+ --bc-brand-mark: #9b8fff;
55
+ --bc-shadow: 0 24px 64px rgba(0,0,0,.6), 0 4px 14px rgba(0,0,0,.4);
56
+ --bc-shadow-sm: 0 1px 2px rgba(0,0,0,.4);
57
+ --bc-accent-soft: color-mix(in srgb, var(--bc-accent) 18%, var(--bc-bg));
58
+ }
59
+ @media (prefers-color-scheme: dark) {
60
+ :host(.bc-auto) {
61
+ --bc-bg: #14161c;
62
+ --bc-elevated: #1c1f27;
63
+ --bc-fg: #eef0f4;
64
+ --bc-muted: #a3aab6;
65
+ --bc-faint: #6f7682;
66
+ --bc-border: #2a2e38;
67
+ --bc-subtle: #1f222a;
68
+ --bc-raised: #363d4b;
69
+ --bc-warn: #f59e0b;
70
+ --bc-brand-ink: #9aa1ad;
71
+ --bc-brand-mark: #9b8fff;
72
+ --bc-shadow: 0 24px 64px rgba(0,0,0,.6), 0 4px 14px rgba(0,0,0,.4);
73
+ --bc-shadow-sm: 0 1px 2px rgba(0,0,0,.4);
74
+ --bc-accent-soft: color-mix(in srgb, var(--bc-accent) 18%, var(--bc-bg));
75
+ }
76
+ }
77
+
78
+ * { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
79
+ svg { width: 1em; height: 1em; display: block; }
80
+ /* The hidden attribute has to actually hide. Nearly every element in here is given a
81
+ display by a rule below, and any of them beats the attribute's own UA style
82
+ — which is why .dock and .launcher each had to say so themselves. Said once,
83
+ for all of them, so the next element hidden from JavaScript works. */
84
+ [hidden] { display: none !important; }
85
+ .sr-only {
86
+ position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
87
+ overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
88
+ }
89
+
90
+ /* One focus ring for everything clickable, so keyboard users never have to
91
+ guess where they are. Fields draw their own ring (a glow, not an outline). */
92
+ button:focus-visible, a:focus-visible, select:focus-visible, [tabindex]:focus-visible {
93
+ outline: 2px solid var(--bc-accent); outline-offset: 2px;
94
+ }
95
+
96
+ /* Motion is decoration here — every animation below is an entrance or a state
97
+ hint, so switching them off costs nothing but the polish. */
98
+ @media (prefers-reduced-motion: reduce) {
99
+ *, *::before, *::after {
100
+ animation-duration: .01ms !important;
101
+ animation-iteration-count: 1 !important;
102
+ transition-duration: .01ms !important;
103
+ }
104
+ }
105
+
106
+ @keyframes bc-launcher-in { from { opacity: 0; transform: translateY(12px) scale(.86) } to { opacity: 1; transform: none } }
107
+ @keyframes bc-item-in { from { opacity: 0; transform: translateY(8px) scale(.96) } to { opacity: 1; transform: none } }
108
+
109
+ /* ---------- dock: theme switch stacked above the launcher ---------- */
110
+ .dock {
111
+ position: fixed; z-index: 2147483000;
112
+ display: flex; flex-direction: column; gap: 10px;
113
+ }
114
+ .dock[hidden] { display: none; }
115
+ /* While the panel is open the switch rises above the scrim so it stays usable
116
+ — the panel shares the shadow root, so a change re-themes the open form. */
117
+ .dock.over { z-index: 2147483002; }
118
+ .dock.at-right { align-items: flex-end; }
119
+ .dock.at-left { align-items: flex-start; }
120
+ /* Anchored to the top, "above the launcher" would be off-screen, so the
121
+ switch goes under it and the launcher stays the outermost thing. */
122
+ .dock.at-top { flex-direction: column-reverse; }
123
+
124
+ .themer {
125
+ display: inline-flex; align-items: center; gap: 2px;
126
+ padding: 3px; border-radius: 999px;
127
+ background: var(--bc-elevated); border: 1px solid var(--bc-border);
128
+ box-shadow: 0 6px 18px rgba(10,12,16,.14), 0 1px 3px rgba(10,12,16,.08);
129
+ animation: bc-launcher-in 420ms var(--bc-ease) both;
130
+ }
131
+ .themer button {
132
+ display: grid; place-items: center;
133
+ width: 28px; height: 28px; padding: 0;
134
+ border: none; border-radius: 999px; background: transparent;
135
+ color: var(--bc-muted); cursor: pointer;
136
+ transition: background var(--bc-dur) var(--bc-ease), color var(--bc-dur) var(--bc-ease), transform 140ms var(--bc-ease);
137
+ }
138
+ .themer button svg { font-size: 15px; }
139
+ .themer button:hover { background: var(--bc-subtle); color: var(--bc-fg); }
140
+ .themer button:active { transform: scale(.92); }
141
+ .themer button[aria-pressed="true"] { background: var(--bc-accent); color: var(--bc-on-accent); }
142
+ .themer button[aria-pressed="true"]:hover { background: var(--bc-accent); filter: brightness(1.06); }
143
+
144
+ /* ---------- launcher ---------- */
145
+ .launcher {
146
+ position: relative;
147
+ display: inline-flex; align-items: center; gap: 9px;
148
+ height: 48px; padding: 0 20px 0 16px; border: none; border-radius: 999px;
149
+ background: var(--bc-accent); color: var(--bc-on-accent);
150
+ font-size: var(--bc-fs-md); font-weight: 620; line-height: 1; letter-spacing: -.01em;
151
+ cursor: pointer;
152
+ box-shadow: 0 10px 28px color-mix(in srgb, var(--bc-accent) 34%, rgba(10,12,16,.2)), 0 2px 6px rgba(10,12,16,.16);
153
+ transition: transform var(--bc-dur) var(--bc-ease), box-shadow var(--bc-dur) var(--bc-ease), filter 160ms linear, padding var(--bc-dur) var(--bc-ease);
154
+ animation: bc-launcher-in 420ms var(--bc-ease) both;
155
+ }
156
+ /* Two glyphs in one box: the bubble when closed, a chevron when open, turned
157
+ into each other so the button reads as the panel's own handle. */
158
+ .launcher .ico { position: relative; width: 20px; height: 20px; flex: none; }
159
+ .launcher .ico > span {
160
+ position: absolute; inset: 0;
161
+ transition: transform 320ms var(--bc-ease), opacity 200ms ease;
162
+ }
163
+ .launcher .ico svg { width: 20px; height: 20px; }
164
+ .launcher .ico .when-open { opacity: 0; transform: rotate(-90deg) scale(.6); }
165
+ .launcher[aria-expanded="true"] .ico .when-closed { opacity: 0; transform: rotate(90deg) scale(.6); }
166
+ .launcher[aria-expanded="true"] .ico .when-open { opacity: 1; transform: none; }
167
+ .launcher:hover { transform: translateY(-2px); filter: brightness(1.06); }
168
+ .launcher:active { transform: translateY(0) scale(.97); transition-duration: 90ms; }
169
+ .launcher:focus-visible { outline-offset: 3px; }
170
+ .launcher[hidden] { display: none; }
171
+
172
+ /* ---------- messages ----------
173
+ The panel's banner, and the load-failure card below — which is drawn when
174
+ the panel's own sheet never arrived, so these rules live in this one. */
175
+ .msg {
176
+ display: flex; align-items: flex-start; gap: 8px;
177
+ font-size: var(--bc-fs-sm); line-height: 1.45; padding: 10px 12px; border-radius: var(--bc-r-md); margin-bottom: 14px;
178
+ animation: bc-item-in 240ms var(--bc-ease) both;
179
+ }
180
+ .msg svg { flex: none; font-size: 15px; margin-top: 1px; }
181
+ .msg.err { background: color-mix(in srgb, var(--bc-danger) 10%, var(--bc-bg)); color: var(--bc-danger); border: 1px solid color-mix(in srgb, var(--bc-danger) 30%, transparent); }
182
+ .msg.info { background: var(--bc-subtle); color: var(--bc-muted); border: 1px solid var(--bc-border); }
183
+
184
+ /* ---------- announcements ----------
185
+ What the project's team is telling visitors (notice.js): beside the launcher
186
+ for the ones written for that, and at the top of the panel for all of them.
187
+ In this sheet because the card beside the button exists before the panel's
188
+ does. The tone is a colour and an icon; the site's accent is the info one. */
189
+ .notice {
190
+ --tone: var(--bc-accent);
191
+ display: flex; align-items: flex-start; gap: 10px;
192
+ padding: 12px 12px 12px 14px; border-radius: var(--bc-r-md);
193
+ background: color-mix(in srgb, var(--tone) 7%, var(--bc-elevated));
194
+ border: 1px solid color-mix(in srgb, var(--tone) 28%, var(--bc-border));
195
+ color: var(--bc-fg);
196
+ font-size: var(--bc-fs-sm); line-height: 1.45; text-align: left;
197
+ animation: bc-item-in 240ms var(--bc-ease) both;
198
+ }
199
+ .notice.tone-success { --tone: var(--bc-ok); }
200
+ .notice.tone-warning { --tone: var(--bc-warn); }
201
+ .notice.tone-critical { --tone: var(--bc-danger); }
202
+ .notice-ico { flex: none; color: var(--tone); font-size: 16px; margin-top: 1px; }
203
+ .notice-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
204
+ .notice-text strong { display: block; font-weight: 650; letter-spacing: -.005em; }
205
+ .notice-text p { margin: 2px 0 0; color: var(--bc-muted); white-space: pre-line; }
206
+ .notice-cta {
207
+ display: inline-block; margin-top: 6px;
208
+ color: var(--tone); font-weight: 620; text-decoration: none;
209
+ }
210
+ .notice-cta:hover { text-decoration: underline; text-underline-offset: 2px; }
211
+ .notice-x {
212
+ flex: none; display: grid; place-items: center;
213
+ width: 26px; height: 26px; margin: -4px -4px 0 0; padding: 0;
214
+ border: 0; border-radius: 999px; background: transparent;
215
+ color: var(--bc-muted); cursor: pointer;
216
+ }
217
+ .notice-x:hover { background: color-mix(in srgb, var(--tone) 12%, transparent); color: var(--bc-fg); }
218
+ .notice-x svg { font-size: 14px; }
219
+ /* Beside the button it floats over somebody else's page: opaque, lifted, and
220
+ never taller than a glance. The whole text is in the panel. */
221
+ .notice.at-launcher {
222
+ width: min(320px, calc(100vw - 40px));
223
+ box-shadow: 0 10px 28px rgba(10,12,16,.14), 0 1px 3px rgba(10,12,16,.08);
224
+ }
225
+ .notice.at-launcher .notice-text p {
226
+ display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
227
+ }
228
+ .notice.at-panel { margin-bottom: 10px; }
229
+
230
+ /* The dock sits in a corner of a page the widget does not own. On a notched
231
+ phone that corner is under the home indicator, and in landscape it is under
232
+ the camera housing. env() is 0 everywhere else, so the offsets are unchanged
233
+ on hardware that has no insets. */
234
+ .dock {
235
+ padding-bottom: env(safe-area-inset-bottom, 0px);
236
+ padding-right: env(safe-area-inset-right, 0px);
237
+ padding-left: env(safe-area-inset-left, 0px);
238
+ }
239
+
240
+ /* The dock's own share of the phone and touch rules; the panel's sheet carries
241
+ the rest. */
242
+ @media (max-width: 480px) {
243
+ /* The panel is a full-screen sheet with its own close button, and a launcher
244
+ floating over its send button would be in the way. */
245
+ .dock.over { display: none; }
246
+ }
247
+ @media (pointer: coarse) {
248
+ /* The theme switch's buttons are small glyphs whose boxes cannot grow without
249
+ moving the launcher under them, so each keeps its size and gets an
250
+ invisible target drawn around it instead. */
251
+ .themer button { position: relative; }
252
+ .themer button::after {
253
+ content: '';
254
+ position: absolute;
255
+ inset: -8px;
256
+ }
257
+ /* The themer's three buttons sit side by side, so their expanders would
258
+ overlap each other without a gap to grow into. */
259
+ .themer { gap: 4px; }
260
+ .notice-x { width: 36px; height: 36px; margin: -9px -8px -6px 0; }
261
+ }
262
+ /* Hover is a lie on a touchscreen: it latches on tap and stays. The launcher's
263
+ lift in particular was left applied after the panel closed. */
264
+ @media (hover: none) {
265
+ .launcher:hover { transform: none; filter: none; }
266
+ .themer button:hover { transform: none; }
267
+ }
268
+
269
+ /* ---------- while the panel's code is on its way ----------
270
+ Usually it is already here — it is fetched once the page is idle, and again
271
+ as a pointer reaches the button. On a slow first press the launcher says it
272
+ heard, rather than looking as though it did nothing. */
273
+ .launcher[aria-busy="true"] { cursor: progress; }
274
+ .launcher[aria-busy="true"] .ico { animation: bc-busy 700ms ease-in-out infinite alternate; }
275
+ @keyframes bc-busy { to { opacity: .4; } }
276
+
277
+ /* ---------- the panel's code would not load ----------
278
+ Said above the launcher, in the form's own error style, with the retry: the
279
+ network dropped, or a Content-Security-Policy refused the file. */
280
+ .loadfail {
281
+ margin: 0; max-width: min(320px, calc(100vw - 40px));
282
+ align-items: center; box-shadow: var(--bc-shadow-sm);
283
+ }
284
+ .loadfail > span { flex: 1; }
285
+ .loadfail button {
286
+ flex: none; padding: 2px 4px; border: 0; border-radius: 6px;
287
+ background: none; color: inherit; font: inherit; font-weight: 650; cursor: pointer;
288
+ }
289
+ .loadfail button[data-act="retry"] { text-decoration: underline; text-underline-offset: 2px; }
290
+ .loadfail button svg { font-size: 13px; margin: 0; }
291
+ `;function Wn(t){const e=document.createElement("div");e.setAttribute("data-bugcatch","widget");let n=Kn()||Yn(t.config.theme);e.className=Tt(n);const o=e.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=Fn(t.config.accent||"#4F46E5"),o.appendChild(a);const r=St[t.config.widgetPosition]?t.config.widgetPosition:"bottom-right",i=document.createElement("div");i.className=`dock ${r.includes("right")?"at-right":"at-left"}`+(r.startsWith("top")?" at-top":""),i.style.cssText=St[r];const s=document.createElement("div");s.className="themer",s.setAttribute("role","group"),s.setAttribute("aria-label","Report widget theme"),s.innerHTML=$t.map(C=>`<button type="button" data-theme="${C.value}" title="${C.label}" aria-label="${C.label}" aria-pressed="${C.value===n}">${C.icon}</button>`).join(""),s.addEventListener("click",C=>{const S=C.target.closest("button[data-theme]");!S||S.dataset.theme===n||(n=S.dataset.theme,e.className=Tt(n),Vn(n),s.querySelectorAll("button").forEach(x=>{x.setAttribute("aria-pressed",String(x.dataset.theme===n))}))});const c=document.createElement("button");c.className="launcher",c.type="button",c.innerHTML=`<span class="ico" aria-hidden="true"><span class="when-closed">${mt}</span><span class="when-open">${qn}</span></span><span>Report a bug</span>`,c.setAttribute("aria-haspopup","dialog"),c.setAttribute("aria-expanded","false");let l=null;c.addEventListener("click",()=>{if(l){l.close();return}l=f()});function f(){w(),b();let C=null,S=!1;const x=()=>{S=!0,c.removeAttribute("aria-busy"),l=null},v={close:()=>C?C.close():x(),destroy:()=>C?C.destroy():x()};return c.setAttribute("aria-busy","true"),xt(t.config.chunkBase).then(({openPanel:k})=>{S||(c.removeAttribute("aria-busy"),i.classList.add("over"),c.setAttribute("aria-expanded","true"),C=k({root:o,host:e,dock:i,client:t,preloadCall:g,onClose:()=>{l=null,i.classList.remove("over"),c.setAttribute("aria-expanded","false")}}))},()=>{S||(x(),m())}),v}const d=()=>{xt(t.config.chunkBase).catch(()=>{})};for(const C of["pointerenter","touchstart","focus"])c.addEventListener(C,d,{once:!0,passive:!0});const u=Et(d);function g(){Se(t.config.chunkBase).catch(()=>{})}let y=null;function m(){w(),y=document.createElement("div"),y.className="msg err loadfail",y.setAttribute("role","alert"),y.innerHTML=`${re}<span>The report form didn't load. Check your connection and try again.</span><button type="button" data-act="retry">Try again</button><button type="button" data-act="dismiss" aria-label="Dismiss">${fe}</button>`,y.querySelector('[data-act="retry"]').addEventListener("click",()=>{c.focus(),l||(l=f())}),y.querySelector('[data-act="dismiss"]').addEventListener("click",()=>{c.focus(),w()}),i.prepend(y)}function w(){y==null||y.remove(),y=null}let p=null;function h(C){b(),p=kt(C,{where:"launcher",onDismiss:S=>{t.dismissAnnouncement(S),c.focus(),b()}}),y?y.after(p):i.prepend(p)}function b(){p==null||p.remove(),p=null}const T=t.config.announcements===!1?()=>{}:Et(()=>{t.announcements().then(C=>{const S=C.find(x=>x.placement==="launcher");S&&!l&&e.isConnected&&h(S)}).catch(()=>{})});return i.append(s,c),o.appendChild(i),document.body.appendChild(e),t.widgetControls={open:()=>{l||c.click()},close:()=>{l==null||l.close()},isOpen:()=>!!l},()=>{u(),T(),l==null||l.destroy(),e.remove(),t.widgetControls=null}}function Yn(t){return t==="dark"||t==="light"?t:"auto"}function Tt(t){return t==="dark"?"bc-dark":t==="light"?"bc-light":"bc-auto"}function Et(t){let e=()=>{};const n=()=>{if(typeof requestIdleCallback=="function"){const o=requestIdleCallback(t,{timeout:5e3});e=()=>cancelIdleCallback(o)}else{const o=setTimeout(t,1500);e=()=>clearTimeout(o)}};return document.readyState==="complete"?n():(window.addEventListener("load",n,{once:!0}),e=()=>window.removeEventListener("load",n)),()=>e()}const Xn="Too many requests are being sent from here at the moment. Please try again in a minute.";function ue(t){return t||Xn}const Jn=typeof window<"u"&&window.fetch?window.fetch.bind(window):null,Zn=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.open:null,Gn=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype.send:null,It=["image/png","image/jpeg","image/webp","image/gif","video/webm","video/mp4","audio/webm","audio/ogg","audio/mpeg","audio/mp4","audio/wav","application/pdf","text/plain","text/csv","application/json","application/zip","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],$e=["image/png","image/jpeg","image/webp","video/webm","video/mp4"],eo=()=>{var t;return!!((t=navigator==null?void 0:navigator.mediaDevices)!=null&&t.getUserMedia&&typeof MediaRecorder<"u")},to=()=>{var t;return!!((t=navigator==null?void 0:navigator.mediaDevices)!=null&&t.getDisplayMedia&&typeof MediaRecorder<"u")},no=()=>{var t;return!!((t=navigator==null?void 0:navigator.mediaDevices)!=null&&t.getDisplayMedia)};function Ce(t,e=It){const n=String(t||"").split(";")[0].trim().toLowerCase();return e.includes(n)?n:null}async function oo(){const t=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:1},audio:!1});try{const e=t.getVideoTracks()[0],n=document.createElement("video");n.srcObject=t,n.muted=!0,n.playsInline=!0,await n.play(),await new Promise(s=>requestAnimationFrame(()=>requestAnimationFrame(s)));const{width:o,height:a}=e.getSettings(),r=document.createElement("canvas");r.width=o||n.videoWidth,r.height=a||n.videoHeight,r.getContext("2d").drawImage(n,0,0,r.width,r.height);const i=await new Promise(s=>r.toBlob(s,"image/png"));if(!i)throw new Error("The browser returned an empty screenshot.");return{blob:i,mime:"image/png",kind:"SCREENSHOT"}}finally{t.getTracks().forEach(e=>e.stop())}}async function ao({maxMs:t=12e4,onTick:e,onAutoStop:n}={}){const o=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1}),a=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(g=>MediaRecorder.isTypeSupported(g))||"video/webm",r=new MediaRecorder(o,{mimeType:a,videoBitsPerSecond:25e5}),i=[];r.ondataavailable=g=>{g.data.size&&i.push(g.data)},r.start(1e3);const s=Date.now(),c=setInterval(()=>e==null?void 0:e(Math.floor((Date.now()-s)/1e3)),500),l=()=>{clearInterval(c),clearTimeout(u),o.getTracks().forEach(g=>g.stop())},f=new Promise(g=>{r.onstop=()=>{l(),g(new Blob(i,{type:a}))}}),d=()=>{r.state!=="inactive"&&r.stop(),n==null||n()};o.getVideoTracks()[0].addEventListener("ended",d);const u=setTimeout(d,t);return{mime:a,maxMs:t,async stop(){return clearTimeout(u),r.state!=="inactive"&&r.stop(),{blob:await f,mime:a,kind:"VIDEO"}},cancel(){l(),r.state!=="inactive"&&r.stop()}}}async function ro({maxMs:t=12e4,onTick:e,onAutoStop:n}={}){const o=await navigator.mediaDevices.getUserMedia({audio:!0}),a=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg"].find(g=>MediaRecorder.isTypeSupported(g))||"",r=new MediaRecorder(o,a?{mimeType:a}:void 0),i=[];r.ondataavailable=g=>{g.data.size&&i.push(g.data)},r.start(1e3);const s=Date.now(),c=setInterval(()=>e==null?void 0:e(Math.floor((Date.now()-s)/1e3)),500),l=()=>{clearInterval(c),clearTimeout(u),o.getTracks().forEach(g=>g.stop())},f=new Promise(g=>{r.onstop=()=>{l(),g(new Blob(i,{type:r.mimeType||a}))}}),u=setTimeout(()=>{r.state!=="inactive"&&r.stop(),n==null||n()},t);return{mime:r.mimeType||a,maxMs:t,async stop(){clearTimeout(u),r.state!=="inactive"&&r.stop();const g=await f;return{blob:g,mime:g.type||r.mimeType||a,kind:"AUDIO"}},cancel(){l(),r.state!=="inactive"&&r.stop()}}}async function io({apiBase:t,apiKey:e,blob:n,mime:o,onProgress:a}){var l;const r=Ce(o||n.type);if(!r)throw new Error(`[BugCatch] ${o||n.type||"that file"} can't be attached.`);const i=await Jn(`${t}/ingest/presign`,{method:"POST",headers:{"Content-Type":"application/json","X-BugCatch-Key":e},body:JSON.stringify({mime:r})});if(i.status===429){let f="";try{f=((l=await i.json())==null?void 0:l.message)||""}catch{}throw new Error(`[BugCatch] ${ue(typeof f=="string"?f:"")}`)}if(!i.ok)throw new Error(`[BugCatch] could not start the upload (HTTP ${i.status}).`);const{key:s,uploadUrl:c}=await i.json();return await so(c,n,r,a),{storageKey:s,mime:r}}function so(t,e,n,o){return new Promise((a,r)=>{const i=new XMLHttpRequest;Zn.call(i,"PUT",t,!0),i.setRequestHeader("Content-Type",n),i.upload.onprogress=s=>{s.lengthComputable&&(o==null||o(s.loaded/s.total))},i.onload=()=>{i.status>=200&&i.status<300?a():r(new Error(`[BugCatch] upload failed (HTTP ${i.status}).`))},i.onerror=()=>r(new Error("[BugCatch] the browser blocked the upload to storage. If this is a new environment, the media bucket is probably missing its CORS policy.")),i.onabort=()=>r(new Error("[BugCatch] upload cancelled.")),Gn.call(i,e)})}function pe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Te(t){const e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const Ee="bugcatch.watch",Lt=[2e3,5e3,15e3,3e4,6e4],co=5e3;let ge=null;function lo(t){ge=t||null}const Ve=()=>ge?`${Ee}:${ge}`:Ee;function Fe(){return ge?`?projectId=${encodeURIComponent(ge)}`:""}function P(){try{const t=window.localStorage;return(t==null?void 0:t.getItem(Ve()))||(t==null?void 0:t.getItem(Ee))||null}catch{return null}}function We(t){var e;if(t)try{(e=window.localStorage)==null||e.setItem(Ve(),t)}catch{}}function se(){var t,e;try{(t=window.localStorage)==null||t.removeItem(Ve()),(e=window.localStorage)==null||e.removeItem(Ee)}catch{}At()}const Ie="bugcatch.unread";function uo(t){return[(t==null?void 0:t.bugId)||"report",(t==null?void 0:t.kind)||"status",(t==null?void 0:t.at)||""].join("|")}function be(){var t;try{const e=(t=window.localStorage)==null?void 0:t.getItem(Ie),n=e?JSON.parse(e):[];return Array.isArray(n)?n.filter(o=>o&&typeof o.id=="string"):[]}catch{return[]}}function Le(t){var e,n;try{t.length?(e=window.localStorage)==null||e.setItem(Ie,JSON.stringify(t)):(n=window.localStorage)==null||n.removeItem(Ie)}catch{}}function po(t){const e={...t,id:uo(t)},n=be().filter(o=>o.id!==e.id);return n.push(e),Le(n.slice(-20)),e}function ho(t){const e=be().filter(n=>n.id!==t);return Le(e),e}function fo(t){const e=be().filter(n=>n.bugId!==t);return Le(e),e}function At(){return Le([]),[]}function go(t,e){let n=t,o=n.indexOf(`
292
+
293
+ `);for(;o!==-1;){const a=n.slice(0,o);n=n.slice(o+2);const r=a.split(`
294
+ `).filter(i=>i.startsWith("data:")).map(i=>i.slice(5).trim()).join(`
295
+ `);if(r)try{e(JSON.parse(r))}catch{}o=n.indexOf(`
296
+
297
+ `)}return n}async function bo({apiBase:t}){const e=P();if(!e)return{reporter:null,reports:[]};const n=await fetch(`${t}/ingest/watch/reports${Fe()}`,{headers:{Authorization:`Bearer ${e}`}});if(n.status===401)return se(),{reporter:null,reports:[]};if(!n.ok)throw new Error(`[BugCatch] could not load your reports (HTTP ${n.status})`);return n.json()}async function mo({apiBase:t,bugId:e}){const n=P();if(!n)return null;const o=await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}${Fe()}`,{headers:{Authorization:`Bearer ${n}`}});if(o.status===401)return se(),null;if(o.status===404)return null;if(!o.ok)throw new Error(`[BugCatch] could not load that report (HTTP ${o.status})`);return o.json()}async function yo({apiBase:t,bugId:e,body:n,attachments:o}){const a=P();if(!a)throw new Error("[BugCatch] nothing filed from this browser yet.");const r=await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}/messages`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({...n?{body:n}:{},...o!=null&&o.length?{attachments:o}:{}})});if(r.status===401)throw se(),new Error("[BugCatch] this browser can no longer prove it filed that report.");if(!r.ok){let i="";try{const s=await r.json();i=Array.isArray(s.message)?s.message.join(", "):s.message||""}catch{}throw r.status===429?new Error(ue(i)):new Error(i||`[BugCatch] could not send that (HTTP ${r.status}).`)}return r.json()}async function wo({apiBase:t,apiKey:e,projectId:n}){const o={agent:!1,live:!1};try{const a=await fetch(`${t}/ingest/calls?projectId=${encodeURIComponent(n)}`,{headers:{"X-BugCatch-Key":e}});if(!a.ok)return o;const r=await a.json();return r!=null&&r.available?r.kinds&&typeof r.kinds=="object"?{agent:!1,live:!!r.kinds.live}:{agent:!1,live:r.kind==="live"}:o}catch{return o}}async function vo({apiBase:t,apiKey:e,token:n,payload:o,watchToken:a}){const r=await fetch(`${t}/ingest/calls`,{method:"POST",headers:{"Content-Type":"application/json","X-BugCatch-Key":e,...n?{"X-BugCatch-Session":n}:{}},body:JSON.stringify(a?{...o,watchToken:a}:o)});if(!r.ok){let i="";try{const c=await r.json();i=Array.isArray(c.message)?c.message.join(", "):c.message||""}catch{}const s=new Error(r.status===429?ue(i):i||`[BugCatch] the call could not be started (HTTP ${r.status}).`);throw s.status=r.status,s}return r.json()}async function Mt({apiBase:t,bugId:e}){const n=P();if(!n)return!1;try{const o=await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}/live-call`,{headers:{Authorization:`Bearer ${n}`}});if(!o.ok)return!1;const a=await o.json();return!!(a!=null&&a.offered)}catch{return!1}}async function xo({apiBase:t,bugId:e}){const n=P();if(!n)throw new Error("[BugCatch] nothing filed from this browser yet.");const o=await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}/live-call`,{method:"POST",headers:{Authorization:`Bearer ${n}`}});if(o.status===401)throw se(),new Error("[BugCatch] this browser can no longer prove it filed that report.");if(!o.ok){let a="";try{const r=await o.json();a=Array.isArray(r.message)?r.message.join(", "):r.message||""}catch{}throw new Error(a||`[BugCatch] the call could not be started (HTTP ${o.status}).`)}return o.json()}async function ko({apiBase:t,bugId:e,callId:n}){const o=P();if(o)try{await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}/live-call/${encodeURIComponent(n)}/give-up`,{method:"POST",headers:{Authorization:`Bearer ${o}`}})}catch{}}async function So({apiBase:t,bugId:e,callId:n}){const o=P();if(!o)throw new Error("[BugCatch] nothing filed from this browser yet.");const a=await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}/live-call/${encodeURIComponent(n)}/answer`,{method:"POST",headers:{Authorization:`Bearer ${o}`}});if(a.status===401)throw se(),new Error("[BugCatch] this browser can no longer prove it filed that report.");if(a.status===409)throw new Error("[BugCatch] that call is no longer ringing.");if(!a.ok){let r="";try{const i=await a.json();r=Array.isArray(i.message)?i.message.join(", "):i.message||""}catch{}throw new Error(r||`[BugCatch] the call could not be answered (HTTP ${a.status}).`)}return a.json()}async function Bt({apiBase:t,bugId:e,callId:n}){const o=P();if(o)try{await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}/live-call/${encodeURIComponent(n)}/decline`,{method:"POST",headers:{Authorization:`Bearer ${o}`}})}catch{}}function $o({apiBase:t,onUpdate:e}){let n=!0,o=0,a=null;async function r(){const i=P();if(!i)throw new Error("nothing filed from this browser yet");a=new AbortController;const s=await fetch(`${t}/ingest/watch/stream${Fe()}`,{headers:{Authorization:`Bearer ${i}`,Accept:"text/event-stream"},signal:a.signal});if(s.status===401)throw n=!1,se(),new Error("subscription no longer valid");if(!s.ok||!s.body)throw new Error(`stream failed (${s.status})`);const c=Date.now(),l=s.body.getReader(),f=new TextDecoder;let d="";try{for(;;){const{value:u,done:g}=await l.read();if(g)break;d+=f.decode(u,{stream:!0}),d=go(d,y=>{if(y.type!=="ping")try{e(y)}catch{}})}}finally{Date.now()-c>=co&&(o=0)}}return(async()=>{for(;n;){try{await r()}catch(s){if((s==null?void 0:s.name)==="AbortError")return}if(!n)return;const i=Lt[Math.min(o,Lt.length-1)];o+=1,await new Promise(s=>setTimeout(s,i))}})(),()=>{n=!1,a==null||a.abort(),a=null}}const Co={OPEN:"is open",IN_PROGRESS:"is being worked on",RESOLVED:"has been fixed",CLOSED:"has been closed"},To={status:null,severity:"#e8912a",assignment:"#4da3ff",reply:"#35b87f"};function Rt(t){return t!=null&&t.summary?t.summary:`Your report ${Co[t==null?void 0:t.status]||"was updated"}`}function Eo(t){var e;return(t==null?void 0:t.kind)==="reply"&&((e=t.reply)!=null&&e.body)?`${t.reply.author?`${t.reply.author}: `:""}${t.reply.body}`:(t==null?void 0:t.title)||""}function Io(t){const e=Date.parse(t||"");if(!Number.isFinite(e))return"";const n=Math.round((Date.now()-e)/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const o=Math.round(n/60);if(o<24)return`${o}h ago`;const a=Math.round(o/24);return a===1?"yesterday":`${a}d ago`}function Lo(){var t;try{const e=document.querySelector('[data-bugcatch="widget"]'),n=(t=e==null?void 0:e.shadowRoot)==null?void 0:t.querySelector(".dock"),o=(n==null?void 0:n.getBoundingClientRect().height)||0;return o?Math.round(o)+12:0}catch{return 0}}function Ao({accent:t="#4F46E5",position:e="bottom-right",onRead:n=null,onReadAll:o=null,onCall:a=null}={}){const[r,i]=String(e).split("-"),s=r==="top",c=i==="left",l=new Map;let f=null,d=null;function u(){return f!=null&&f.isConnected||(f=document.createElement("div"),f.setAttribute("data-bugcatch","updates"),f.style.cssText=["position:fixed",`${s?"top":"bottom"}:${20+Lo()}px`,`${c?"left":"right"}:20px`,"z-index:2147482998","display:flex","flex-direction:column","gap:10px",`align-items:${c?"flex-start":"flex-end"}`,"width:min(320px,calc(100vw - 40px))","pointer-events:none"].join(";"),document.body.appendChild(f)),f}function g(p){if(!p._bcShown){p.remove();return}p.style.opacity="0",p.style.transform=`translateY(${s?-8:8}px)`,setTimeout(()=>p.remove(),250)}function y(p,h){const b=document.createElement("button");return b.type="button",b.textContent=p,b.style.cssText=["padding:5px 11px",`border:${h?"0":"1px solid rgba(236,238,242,.24)"}`,"border-radius:6px",`background:${h?t:"transparent"}`,`color:${h?"#fff":"#eceef2"}`,"font:600 12px/1.4 inherit","cursor:pointer","white-space:nowrap"].join(";"),b}function m(p){var v;const h=document.createElement("div");h.setAttribute("role","status"),h.style.cssText=["box-sizing:border-box","width:100%","padding:12px 14px","border-radius:10px","background:#1b1e26","color:#eceef2",'font:13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif',"box-shadow:0 12px 30px rgba(0,0,0,0.45)",`border-left:3px solid ${To[p==null?void 0:p.kind]||t}`,"opacity:0",`transform:translateY(${s?-8:8}px)`,"transition:opacity .2s ease,transform .2s ease","pointer-events:auto"].join(";");const b=document.createElement("div");b.style.cssText="font-weight:600;margin-bottom:2px",b.textContent=Rt(p);const T=document.createElement("div");T.style.cssText=(p==null?void 0:p.kind)==="reply"?"color:#a4abba;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden":"color:#a4abba",T.textContent=Eo(p);const C=document.createElement("div");C.style.cssText="display:flex;align-items:center;gap:8px;margin-top:10px;flex-wrap:wrap";const S=document.createElement("span");S.style.cssText="color:#7b8394;font-size:11px;margin-right:auto",S.textContent=Io(p==null?void 0:p.at);const x=y("Mark as read",!1);if(x.setAttribute("aria-label",`Mark as read: ${Rt(p)}`),x.addEventListener("click",()=>n==null?void 0:n(p.id)),C.append(S,x),(v=p==null?void 0:p.call)!=null&&v.offered&&typeof a=="function"){const k=y("Talk it through",!0);k.addEventListener("click",()=>a(p)),C.insertBefore(k,x)}return h.append(b,T,C),h}function w(p){const h=document.createElement("div");h.style.cssText=["box-sizing:border-box","width:100%","display:flex","align-items:center","gap:8px","padding:8px 12px","border-radius:10px","background:#1b1e26","color:#a4abba",'font:12px/1.4 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif',"box-shadow:0 12px 30px rgba(0,0,0,0.45)","pointer-events:auto"].join(";");const b=document.createElement("span");b.style.cssText="margin-right:auto",b.textContent=`${p} more update${p===1?"":"s"}`;const T=y("Mark all as read",!1);return T.style.cssText+=";padding:4px 9px",T.addEventListener("click",()=>o==null?void 0:o()),h.append(b,T),h}return{render(p){const h=Array.isArray(p)?p:[];if(!h.length){for(const k of l.values())g(k);l.clear(),d==null||d.remove(),d=null,f==null||f.remove(),f=null;return}const b=h.slice(-3),T=new Set(b.map(k=>k.id)),C=u();for(const[k,O]of l)T.has(k)||(g(O),l.delete(k));const S=[];for(const k of b){if(l.has(k.id))continue;const O=m(k);l.set(k.id,O),S.push(O)}const x=s?[...b].reverse():b;for(const k of x)C.appendChild(l.get(k.id));const v=h.length-b.length;v>0?(d==null||d.remove(),d=w(v),s?C.appendChild(d):C.insertBefore(d,C.firstChild)):(d==null||d.remove(),d=null),requestAnimationFrame(()=>{for(const k of S)k.isConnected&&(k._bcShown=!0,k.style.opacity="1",k.style.transform="translateY(0)")})},destroy(){l.clear(),d=null,f==null||f.remove(),f=null}}}async function Mo({apiBase:t,apiKey:e,projectId:n,sessionToken:o}){try{const a=await fetch(`${t}/ingest/known-issues?projectId=${encodeURIComponent(n)}`,{headers:Ye(e,o)});if(!a.ok)return[];const r=await a.json();return Array.isArray(r==null?void 0:r.issues)?r.issues:[]}catch{return[]}}async function Bo({apiBase:t,apiKey:e,projectId:n,q:o,sessionToken:a,signal:r}){try{const i=`${t}/ingest/known-issues/match?projectId=${encodeURIComponent(n)}&q=${encodeURIComponent(o)}`,s=await fetch(i,{headers:Ye(e,a),signal:r});if(!s.ok)return[];const c=await s.json();return Array.isArray(c==null?void 0:c.issues)?c.issues:[]}catch{return[]}}async function Ro({apiBase:t,apiKey:e,projectId:n,bugId:o,reporterEmail:a,reporterName:r,metadata:i,logs:s,sessionToken:c}){const l=P(),f=await fetch(`${t}/ingest/known-issues/${encodeURIComponent(o)}/join`,{method:"POST",headers:Ye(e,c),body:JSON.stringify({projectId:n,reporterEmail:a,reporterName:r,metadata:i,logs:s,...l?{watchToken:l}:{}})});if(!f.ok)throw new Error(await jo(f));const d=await f.json();return d!=null&&d.watchToken&&We(d.watchToken),d}function Ye(t,e){return{"Content-Type":"application/json","X-BugCatch-Key":t,...e?{"X-BugCatch-Session":e}:{}}}async function jo(t){let e="";try{const n=await t.json();e=Array.isArray(n.message)?n.message.join(", "):n.message||""}catch{}return t.status===429?ue(e):e||`Could not add you to this issue (HTTP ${t.status})`}async function Oo({apiBase:t,bugId:e,...n}){const o=P();if(!o)throw new Error("This browser cannot access that report.");const a=await fetch(`${t}/ingest/watch/reports/${encodeURIComponent(e)}/verification`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(n)}),r=await a.json().catch(()=>({}));if(!a.ok)throw new Error(r.message||"Could not record feedback. Please refresh and try again.");return r}const zo="bugcatch.session.",Xe=t=>`${zo}${t}`,Je=new Map;function te(t){var e;if(!t)return null;try{const n=(e=window.localStorage)==null?void 0:e.getItem(Xe(t));if(n){const o=JSON.parse(n);if(o!=null&&o.token)return o}}catch{}return Je.get(t)||null}function Qo(t,e){var o;if(!t||!(e!=null&&e.token))return;const n={token:e.token,email:e.email||null,name:e.name||null};Je.set(t,n);try{(o=window.localStorage)==null||o.setItem(Xe(t),JSON.stringify(n))}catch{}}function Ze(t){var e;if(t){Je.delete(t);try{(e=window.localStorage)==null||e.removeItem(Xe(t))}catch{}}}function Ae({apiKey:t,token:e}){return{"Content-Type":"application/json","X-BugCatch-Key":t,...e?{"X-BugCatch-Session":e}:{}}}async function jt(t){let e="";try{const n=await t.json();e=Array.isArray(n.message)?n.message.join(", "):n.message||""}catch{}return t.status===429?ue(e):e||`Request failed (HTTP ${t.status})`}async function Ho({apiBase:t,apiKey:e,projectId:n,token:o}){const a={mode:"off",signedIn:null,signedOutReason:null};try{const r=await fetch(`${t}/ingest/login?projectId=${encodeURIComponent(n)}`,{headers:Ae({apiKey:e,token:o})});if(!r.ok)return a;const i=await r.json();return{mode:i.mode==="optional"||i.mode==="required"?i.mode:"off",signedIn:i.signedIn||null,signedOutReason:i.signedOutReason||null}}catch{return a}}async function qo({apiBase:t,apiKey:e,projectId:n,email:o,name:a}){const r=await fetch(`${t}/ingest/login/start`,{method:"POST",headers:Ae({apiKey:e}),body:JSON.stringify({projectId:n,email:o,...a?{name:a}:{}})});if(!r.ok)throw new Error(await jt(r));return r.json()}async function Do({apiBase:t,apiKey:e,projectId:n,email:o,code:a}){const r=await fetch(`${t}/ingest/login`,{method:"POST",headers:Ae({apiKey:e}),body:JSON.stringify({projectId:n,email:o,code:a})});if(!r.ok)throw new Error(await jt(r));const i=await r.json(),s={token:i.sessionToken,email:i.email,name:i.name};return Qo(n,s),s}async function No({apiBase:t,apiKey:e,projectId:n,token:o}){if(Ze(n),!o)return{signedOut:!0};try{await fetch(`${t}/ingest/logout`,{method:"POST",headers:Ae({apiKey:e,token:o}),body:JSON.stringify({projectId:n})})}catch{}return{signedOut:!0}}let Ot=!1;if(typeof window<"u"&&window.addEventListener)for(const t of["pointerdown","keydown","touchstart"])window.addEventListener(t,()=>{Ot=!0},{once:!0,capture:!0,passive:!0});function Uo(){return Ot}const _o=2e4,zt=120,Ge=200;function Qt(t){if(typeof t!="string"||!t.trim()||t.length>400)return null;try{return new RegExp(t.trim(),"gi")}catch{return null}}const Ht=t=>String(t).replace(/\s+/g," ").trim().slice(0,zt);function qt(t,e){const n=t&&t.normalize;if(n==="phone"){const o=e.replace(/\D/g,"");return o.length===10?o:o.length===12&&o.startsWith("91")?o.slice(2):o.length===11&&o.startsWith("0")?o.slice(1):e}return n==="upper"?e.toUpperCase():e}function Dt(t){const e=t.length>1&&t[1]!==void 0?t[1]:t[0];return typeof e!="string"||!e.trim()?null:{value:Ht(e),start:t.index,end:t.index+t[0].length}}function Po(t,e){return((t.slice(e.start,e.valueStart)+t.slice(e.valueEnd,e.end)).match(/[a-z]/gi)||[]).length}const Ko=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[A-Za-z0-9][\w-]{5,40}/gi,Nt=/[\w-]/;function Vo(t,e){const n=(t||[]).filter(u=>u&&u.scan!==!1&&u.pattern),o=[],a=[],r=(e||[]).map(u=>typeof u=="string"?u.slice(0,_o):"");r.forEach((u,g)=>{u&&n.forEach((y,m)=>{const w=Qt(y.pattern);if(!w)return;let p,h=0;for(w.lastIndex=0;(p=w.exec(u))!==null&&!(++h>Ge);){if(p[0]===""){w.lastIndex+=1;continue}const b=Dt(p);if(!b)continue;const T=p.length>1&&p[1]!==void 0?p[1]:p[0],C=p.index+Math.max(0,p[0].indexOf(T)),S={block:g,order:m,key:y.key,label:y.label,value:qt(y,b.value),start:b.start,end:b.end,valueStart:C,valueEnd:C+T.length};S.weight=Po(u,S),o.push(S)}})});const i=o.filter(u=>!o.some(g=>g!==u&&g.block===u.block&&g.key!==u.key&&g.valueStart<=u.valueStart&&g.valueEnd>=u.valueEnd&&g.weight>u.weight)),s=new Map;for(const u of i){const g=u.value.toLowerCase();s.has(g)||s.set(g,{value:u.value,keys:new Map});const y=s.get(g);y.keys.has(u.key)||y.keys.set(u.key,{key:u.key,label:u.label,order:u.order})}const c=[],l=[],f=new Map;for(const u of s.values()){const g=[...u.keys.values()].sort((w,p)=>w.order-p.order);if(g.length>1){l.push({value:u.value,kinds:g.map(({key:w,label:p})=>({key:w,label:p}))});continue}const[{key:y,label:m}]=g;f.has(y)||f.set(y,[]),f.get(y).push({key:y,label:m,value:u.value})}for(const u of f.values())if(u.length===1)c.push(u[0]);else for(const g of u)l.push({value:g.value,kinds:[{key:g.key,label:g.label}]});const d=new Set(s.keys());return r.forEach((u,g)=>{if(!u)return;const y=o.filter(h=>h.block===g),m=new RegExp(Ko.source,"gi");let w,p=0;for(;(w=m.exec(u))!==null&&++p<=Ge;){const h=w.index,b=h+w[0].length;if(y.some(k=>h<k.end&&b>k.start))continue;const T=u[h-1]||"",C=u[b]||"";if(Nt.test(T)||Nt.test(C)||T==="/"||T==="@"||C==="@"||T==="."||C==="."&&/\w/.test(u[b+1]||"")||!/\d/.test(w[0]))continue;const S=Ht(w[0]),x=S.toLowerCase();if(d.has(x))continue;const v=(t||[]).filter(k=>k&&Ut(k,S)).map(({key:k,label:O})=>({key:k,label:O}));v.length&&(d.add(x),a.push({value:S,kinds:v}))}}),{found:c,conflicts:l,loose:a}}function Ut(t,e){const n=typeof e=="string"?e.trim():"";if(!n||n.length>zt)return null;const o=Qt(t&&(t.valuePattern||t.pattern));if(!o)return null;let a,r=0;for(o.lastIndex=0;(a=o.exec(n))!==null&&!(++r>Ge);){if(a[0]===""){o.lastIndex+=1;continue}const i=a.index+a[0].length===n.length,s=a.index===0||a.index===1;if(i&&s){const c=Dt(a);if(c)return qt(t,c.value)}}return null}async function Fo({apiBase:t,apiKey:e,projectId:n}){const o={policy:"off",fields:[]};try{const a=await fetch(`${t}/ingest/reference-fields?projectId=${encodeURIComponent(n)}`,{headers:{"X-BugCatch-Key":e}});if(!a.ok)return o;const r=await a.json(),i=r.policy==="optional"||r.policy==="required"?r.policy:"off",s=Array.isArray(r.fields)?r.fields:[];return s.length?{policy:i,fields:s}:o}catch{return o}}const Wo=/Did this answer your question\?/i;async function Yo({apiBase:t,apiKey:e,projectId:n}){try{const o=await fetch(`${t}/ingest/agent-issues?projectId=${encodeURIComponent(n)}`,{headers:{"X-BugCatch-Key":e}});if(!o.ok)return[];const a=await o.json();return(Array.isArray(a==null?void 0:a.issues)?a.issues:[]).filter(r=>r&&typeof r.key=="string"&&typeof r.title=="string").map(r=>({key:r.key,title:r.title,hint:typeof r.hint=="string"?r.hint:""}))}catch{return[]}}const Xo=5*6e4,_t="bugcatch:announcements:seen",Jo=40,Zo=["info","success","warning","critical"],Pt=t=>`bugcatch:announcements:${t}`;async function Go({apiBase:t,apiKey:e,projectId:n,fresh:o=!1}){var a;if(!o){const r=ia(n);if(r)return r}try{const r=await fetch(`${t}/ingest/announcements?projectId=${encodeURIComponent(n)}`,{headers:{"X-BugCatch-Key":e}}),i=r.ok?ra((a=await r.json())==null?void 0:a.announcements):[];return sa(n,i),i}catch{return[]}}function ea(t,{on:e=oa(),seen:n=Vt()}={}){return(t||[]).filter(o=>aa(o,e)&&!(o.dismissible&&n.includes(Kt(o))))}function ta(t){if(!(!(t!=null&&t.id)||!t.dismissible))try{const e=Kt(t),n=[...Vt().filter(o=>o!==e),e];localStorage.setItem(_t,JSON.stringify(n.slice(-Jo)))}catch{}}function na(t){return typeof t!="string"||!t||t.startsWith("//")?null:t.startsWith("/")||/^(https?:\/\/|mailto:)./i.test(t)?t:null}function oa(t=new Date){const e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function aa(t,e){return!(t.startsOn&&e<t.startsOn||t.endsOn&&e>t.endsOn)}function Kt(t){return`${t.id}#${t.revision||0}`}function ra(t){return(Array.isArray(t)?t:[]).filter(e=>e&&typeof e.id=="string"&&typeof e.title=="string"&&e.title.trim()).map(e=>{const n=e.placement==="launcher"?"launcher":"panel",o=na(e.ctaHref);return{id:e.id,revision:Number.isInteger(e.revision)?e.revision:0,title:e.title,body:typeof e.body=="string"?e.body:"",tone:Zo.includes(e.tone)?e.tone:"info",ctaLabel:o&&typeof e.ctaLabel=="string"?e.ctaLabel:"",ctaHref:o&&typeof e.ctaLabel=="string"?o:"",placement:n,dismissible:n==="launcher"||e.dismissible!==!1,startsOn:typeof e.startsOn=="string"?e.startsOn:"",endsOn:typeof e.endsOn=="string"?e.endsOn:""}})}function Vt(){try{const t=JSON.parse(localStorage.getItem(_t)||"[]");return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}catch{return[]}}function ia(t){try{const e=JSON.parse(localStorage.getItem(Pt(t))||"null");if(!e||!Array.isArray(e.list)||typeof e.at!="number")return null;const n=Date.now()-e.at;return n>=0&&n<Xo?e.list:null}catch{return null}}function sa(t,e){try{localStorage.setItem(Pt(t),JSON.stringify({at:Date.now(),list:e}))}catch{}}const Me=120,ca=500,Be=30,la=1e3,et={loanId:["loanId","loanNumber"],applicationId:["applicationId"],customerNumber:["customerNumber","customerId"]},da=/[\u0000-\u001f\u007f]/;function ua(t){if(typeof t=="number")return Number.isFinite(t)?String(t):null;if(typeof t!="string")return null;const e=t.trim();return!e||e.length>Me||da.test(e)?null:e}function J(t){return t===null?"null":Array.isArray(t)?"an array":typeof t=="object"?"an object":`a ${typeof t}`}function tt(t,e,n,o,a){for(const r of n){if(!(r in t)||t[r]===void 0||t[r]===null||t[r]==="")continue;const i=ua(t[r]);if(i)return i;const s=t[r];a(typeof s=="string"&&s.trim().length>Me?`${o}.${r} is longer than ${Me} characters and was dropped — pass the identifier itself, not a sentence or a URL.`:`${o}.${r} should be a string or number, got ${J(s)} — it was dropped.`)}return null}function Ft(t){if(t===null||typeof t=="boolean")return{ok:!0,value:t};if(typeof t=="number")return Number.isFinite(t)?{ok:!0,value:t}:{ok:!1};if(typeof t=="string")return{ok:!0,value:t.slice(0,ca)};if(typeof t=="object")try{const e=JSON.stringify(t);if(e&&e.length<=la)return{ok:!0,value:JSON.parse(e)}}catch{}return{ok:!1}}const Wt=["email","name","phone"],pa=new Set(["id","userId",...Wt,...Object.values(et).flat()]);function Yt(t,e=()=>{}){if(t==null)return null;if(typeof t!="object"||Array.isArray(t))return e(`identify() takes an object like { id, email, name } or null, got ${J(t)} — ignored.`),null;const n={};try{const o=tt(t,"id",["id","userId"],"identify()",e);o&&(n.id=o);for(const r of Wt){const i=t[r];if(i==null||i==="")continue;if(r==="phone"&&typeof i=="number"&&Number.isFinite(i)){n.phone=String(i);continue}if(typeof i!="string"){e(`identify().${r} should be a string, got ${J(i)} — it was dropped.`);continue}const s=i.trim().slice(0,r==="name"?200:Me);s&&(r==="email"&&!s.includes("@")&&e(`identify().email "${s}" does not look like an email address — reports cannot be threaded or followed up without one.`),n[r]=s)}for(const[r,i]of Object.entries(et)){const s=tt(t,r,i,"identify()",e);s&&(n[r]=s)}let a=0;for(const[r,i]of Object.entries(t)){if(pa.has(r)||i===void 0||typeof i=="function")continue;if(a>=Be){e(`identify() was given more than ${Be} extra fields; the rest were dropped.`);break}const s=Ft(i);if(!s.ok){e(`identify().${r} could not be sent (${J(i)} too large or not serialisable) — dropped.`);continue}n[r]=s.value,a+=1}}catch{}return!n.id&&!n.email&&e("identify() was called without an id or email — reports will not be attributed to anyone, and nothing can be looked up by user."),n}function Xt(t,e,n=()=>{}){if(e===null)return{};const o={...t||{}};if(e===void 0)return o;if(typeof e!="object"||Array.isArray(e))return n(`setContext() takes an object like { loanId, screen } or null, got ${J(e)} — ignored.`),o;try{const a=new Map;for(const[r,i]of Object.entries(et))for(const s of i)a.set(s,r);for(const[r,i]of Object.entries(e)){const s=a.get(r);if(i==null){delete o[s||r];continue}if(s){const l=tt({[r]:i},s,[r],"setContext()",n);l?o[s]=l:delete o[s];continue}if(typeof i=="function")continue;if(!(r in o)&&Object.keys(o).length>=Be){n(`setContext() holds at most ${Be} keys; "${r}" was dropped.`);continue}const c=Ft(i);if(!c.ok){n(`setContext().${r} could not be sent (${J(i)} too large or not serialisable) — dropped.`);continue}o[r]=c.value}}catch{}return o}const Jt=["apiBase","apiKey","projectId","consoleLimit","networkLimit","captureConsole","captureNetwork","captureErrors","widget","widgetPosition","theme","accent","attachments","maxAttachments","maxAttachmentBytes","maxRecordingMs","beforeSend","user","context","updates","updateToast","onUpdate","voice","onCallState","onIncomingCall","onReportSubmitted","onAssistantPhase","onError","debug","drafts","knownIssues","agentIssues","release","environment","buildId","chunkBase","announcements"],ha=["beforeSend","onUpdate","onCallState","onIncomingCall","onReportSubmitted","onAssistantPhase","onError"];function fa(t){const e=t.toLowerCase().replace(/[-_]/g,"");return Jt.find(n=>n.toLowerCase()===e)||null}const Zt=/^(your[_-]|<|xxx|todo|changeme)/i,ga=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ba(t,{pageHost:e=""}={}){const n=[],o=[];if(!t||typeof t!="object")return n.push("init() takes an options object: BugCatch.init({ apiBase, apiKey, projectId })."),{errors:n,warnings:o};const{apiKey:a,projectId:r,apiBase:i}=t;a?typeof a!="string"?n.push(`apiKey must be a string, got ${J(a)}.`):Zt.test(a)?n.push(`apiKey is still the placeholder "${a}" — paste the key you saved when you created it.`):ga.test(a)?o.push("apiKey looks like a project id — did you swap apiKey and projectId?"):a.startsWith("bc_")||o.push('apiKey does not look like a BugCatch key (they start with "bc_live_") — reports will be refused with HTTP 401.'):n.push("apiKey is required — create one under Workspace Settings → API Keys."),r?typeof r!="string"?n.push(`projectId must be a string, got ${J(r)}.`):Zt.test(r)?n.push(`projectId is still the placeholder "${r}".`):r.startsWith("bc_")?o.push("projectId looks like an API key — did you swap apiKey and projectId?"):/\s/.test(r)&&o.push("projectId contains whitespace — check it was copied cleanly."):n.push("projectId is required — copy it from Project Settings → Web SDK."),i==null?!e||/^(localhost|127\.|0\.0\.0\.0|\[::1\])/.test(e)||o.push("apiBase is not set, so reports go to http://localhost:3000 — set apiBase to your BugCatch API URL."):(typeof i!="string"||!/^https?:\/\//.test(i))&&o.push(`apiBase should be an absolute http(s) URL, got ${JSON.stringify(i)}.`);for(const s of Object.keys(t)){if(Jt.includes(s))continue;const c=fa(s);o.push(c?`unknown option "${s}" — did you mean "${c}"?`:`unknown option "${s}" is ignored.`)}for(const s of ha){const c=t[s];c!=null&&typeof c!="function"&&o.push(`${s} should be a function, got ${J(c)} — it will not be called.`)}return{errors:n,warnings:o}}function ma(t){return typeof t=="string"?t.replace(/\/+$/,""):t}const me={name:"@sphoro/bugcatch-web-sdk",version:"0.18.0"},ye={apiBase:"http://localhost:3000",apiKey:null,projectId:null,consoleLimit:100,networkLimit:50,captureConsole:!0,captureNetwork:!0,captureErrors:!0,widget:!0,widgetPosition:"bottom-right",theme:"auto",accent:"#4F46E5",announcements:!0,attachments:!0,maxAttachments:5,maxAttachmentBytes:25*1024*1024,maxRecordingMs:12e4,beforeSend:null,user:null,updates:!0,updateToast:!0,onUpdate:null,voice:!0,onCallState:null,onIncomingCall:null,onReportSubmitted:null,onAssistantPhase:null,onError:null,context:null,chunkBase:null,debug:!1};function ya(t){const e=P();return e?{...t,watchToken:e}:t}class Gt{constructor(){kn(this,B);this.config={...ye},this.started=!1,this.teardown=[],this.consoleBuffer=ke(ye.consoleLimit),this.networkBuffer=ke(ye.networkLimit),this.stopWatching=null,this.notifier=null,this.call=null,this.callStarting=!1,this.ringing=null,this.listeners=new Map,this.context={},this.warned=new Set,this.phases=new Map}warn(e){this.warned.has(e)||(this.warned.add(e),console.warn(`[BugCatch] ${e}`))}debugLog(...e){this.config.debug&&console.info("[BugCatch]",...e)}init(e={}){if(this.started)return console.warn("[BugCatch] init() called twice — ignoring the second call."),this;const{errors:n,warnings:o}=ba(e,{pageHost:typeof location<"u"?location.hostname:""});if(n.length)throw new Error(`[BugCatch] ${n[0]}`);for(const r of o)this.warn(r);const a=this.config.user;return this.config={...ye,...e,apiBase:ma(e.apiBase??ye.apiBase)},this.config.user=e.user!==void 0?Yt(e.user,r=>this.warn(r.replace("identify()","init({ user })"))):a||null,e.context&&this.setContext(e.context),this.consoleBuffer=ke(this.config.consoleLimit),this.networkBuffer=ke(this.config.networkLimit),this.config.captureConsole&&this.teardown.push(zn(this.consoleBuffer)),this.config.captureNetwork&&this.teardown.push(Qn(this.networkBuffer)),this.config.captureErrors&&this.teardown.push(Hn(this.consoleBuffer)),lo(this.config.projectId),this.config.widget&&this.teardown.push(Wn(this)),this.config.updates&&P()&&(this.startWatching(),queueMicrotask(()=>H(this,B,oe).call(this))),this.started=!0,H(this,B,Sn).call(this),this.debugLog("initialised",{version:me.version,apiBase:this.config.apiBase,projectId:this.config.projectId,user:this.config.user,context:this.context}),this}startWatching(){if(this.stopWatching)return this;this.stopWatching=$o({apiBase:this.config.apiBase,onUpdate:n=>{if(n!=null&&n.incomingCall){H(this,B,En).call(this,n);return}if(n!=null&&n.callWithdrawn){H(this,B,_e).call(this,n.callWithdrawn.callId);return}const o=po(n);typeof this.config.onUpdate=="function"&&this.config.onUpdate(o),this.emit("update",o),H(this,B,oe).call(this)}}),this.teardown.push(()=>{var n;return(n=this.stopWatching)==null?void 0:n.call(this)}),this.teardown.push(()=>H(this,B,_e).call(this));const e=n=>{(n.key===Ie||n.key===null)&&H(this,B,oe).call(this)};return window.addEventListener("storage",e),this.teardown.push(()=>window.removeEventListener("storage",e)),this}on(e,n){if(typeof n!="function")return()=>{};const o=this.listeners.get(e)||new Set;return o.add(n),this.listeners.set(e,o),()=>this.off(e,n)}off(e,n){var o;return(o=this.listeners.get(e))==null||o.delete(n),this}emit(e,n){for(const o of this.listeners.get(e)||[])try{o(n)}catch(a){console.error(`[BugCatch] a '${e}' listener threw:`,a)}}unreadUpdates(){return be()}markUpdateRead(e){return ho(e),H(this,B,oe).call(this),this}markReportRead(e){return fo(e),H(this,B,oe).call(this),this}markUpdatesRead(){return At(),H(this,B,oe).call(this),this}async verifyFix(e,{result:n,resolvedAt:o,note:a}){const r=n==="STILL_HAPPENING"?await H(this,B,Ue).call(this,{}):{};return Oo({apiBase:this.config.apiBase,bugId:e,result:n,resolvedAt:o,note:a,metadata:r.metadata,logs:r.logs})}async myReport(e){const n=await mo({apiBase:this.config.apiBase,bugId:e});return H(this,B,$n).call(this,e,n==null?void 0:n.assistant),n}replyToReport(e,{body:n,attachments:o}={}){return yo({apiBase:this.config.apiBase,bugId:e,body:n,attachments:o})}async canCallNow(){return!!await this.callKind()}async callKind(){return(await this.callKinds()).live?"live":null}async callKinds(){var n;const e={agent:!1,live:!1};return!this.config.voice||!((n=this.config.user)!=null&&n.email)?e:this.kinds!==void 0?this.kinds:(this.kinds=await wo({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId}),this.kinds)}canCall(e){return this.config.voice?Mt({apiBase:this.config.apiBase,bugId:e}):Promise.resolve(!1)}async startCall(e){var n;if(!this.config.voice)throw new Error("[BugCatch] calling is switched off.");if(this.call||this.callStarting)throw new Error("[BugCatch] a call is already running.");this.callStarting=!0;try{if(!await this.callKind())throw new Error((n=this.config.user)!=null&&n.email?"[BugCatch] calling is not available on this project.":"[BugCatch] a call needs to know who is calling — call identify() with an email first.");return await H(this,B,Tn).call(this,e)}finally{this.callStarting=!1}}startLiveCall(e){return this.startCall(e)}canCallTeam(e){return this.config.voice?Mt({apiBase:this.config.apiBase,bugId:e}):Promise.resolve(!1)}endCall(){var e;return(e=this.call)==null||e.hangUp(),this.call=null,this}myReports(){return bo({apiBase:this.config.apiBase})}hasReports(){return!!P()}forgetReports(){var e;return(e=this.stopWatching)==null||e.call(this),this.stopWatching=null,this.endCall(),se(),H(this,B,oe).call(this),this}identify(e){const n=Yt(e,o=>this.warn(o));return e!=null&&!n?this:(this.config.user=n,this.debugLog("identify",n),this)}setContext(e){return this.context=Xt(this.context,e,n=>this.warn(n)),this.debugLog("context",this.context),this}getContext(){return{...this.context}}open(){return this.started?this.widgetControls?(this.widgetControls.open(),this):(this.warn("open() needs the built-in widget; it was turned off with widget: false."),this):(this.warn("open() was called before init() — nothing to open yet."),this)}close(){var e;return(e=this.widgetControls)==null||e.close(),this}isOpen(){var e;return!!((e=this.widgetControls)!=null&&e.isOpen())}async uploadAttachment(e,n,o){if(!this.started)throw new Error("[BugCatch] call init() first.");return io({apiBase:this.config.apiBase,apiKey:this.config.apiKey,blob:e,mime:n||(e==null?void 0:e.type),onProgress:o})}async report({title:e,description:n="",priority:o="MEDIUM",metadata:a={},attachments:r=[],references:i=[],context:s=null,issue:c=null}={}){var w,p,h,b,T,C,S,x;if(!this.started)throw new Error("[BugCatch] call init() first.");if(typeof e!="string"||!e.trim())throw new Error("[BugCatch] a title is required.");["LOW","MEDIUM","HIGH","CRITICAL"].includes(String(o).toUpperCase())||(this.warn(`priority "${o}" is not one of LOW, MEDIUM, HIGH, CRITICAL — sent as MEDIUM.`),o="MEDIUM");const l=(r||[]).filter(v=>(v==null?void 0:v.storageKey)&&Ce(v.mime,$e)).map(v=>({type:v.type==="VIDEO"?"VIDEO":"SCREENSHOT",storageKey:v.storageKey,mime:Ce(v.mime,$e)})),f=(Array.isArray(i)?i:[]).filter(v=>v&&typeof v.key=="string"&&v.key&&(typeof v.value=="string"||typeof v.value=="number")).map(v=>({key:v.key.slice(0,64),value:String(v.value).trim().slice(0,120)})).filter(v=>v.value);Array.isArray(i)&&f.length<i.length&&this.warn("report({ references }) takes [{ key, value }] with string values; malformed entries were dropped.");let d=await H(this,B,Ue).call(this,{title:e.trim(),description:typeof n=="string"?n:String(n??""),priority:String(o).toUpperCase(),metadata:a,media:l,references:f,context:s,issue:typeof c=="string"&&c?c.slice(0,32):null});const u=H(this,B,ct).call(this,d);if(u===!1)return{cancelled:!0};d=u,this.debugLog("sending report",{title:d.title,user:(w=d.metadata)==null?void 0:w.user,context:(p=d.metadata)==null?void 0:p.context,references:d.references,console:(T=(b=(h=d.logs)==null?void 0:h.console)==null?void 0:b.entries)==null?void 0:T.length,network:(x=(S=(C=d.logs)==null?void 0:C.network)==null?void 0:S.entries)==null?void 0:x.length});const g=te(this.config.projectId);let y;try{y=await fetch(`${this.config.apiBase}/ingest/bugs`,{method:"POST",headers:{"Content-Type":"application/json","X-BugCatch-Key":this.config.apiKey,...g!=null&&g.token?{"X-BugCatch-Session":g.token}:{}},body:JSON.stringify(ya(d))})}catch(v){const k=new Error(`[BugCatch] could not reach ${this.config.apiBase} — check apiBase, and that this site's origin is allowed by the API.`);throw k.cause=v,H(this,B,Ne).call(this,"report",k),k}if(y.status===401&&g&&Ze(this.config.projectId),!y.ok){let v="";try{const O=await y.json();v=Array.isArray(O.message)?O.message.join(", "):O.message||""}catch{}y.status===401&&!g&&(v||(v="the apiKey was not accepted")),y.status===403&&(v||(v="the apiKey is not allowed to report to this projectId"));const k=y.status===429?new Error(`[BugCatch] ${ue(v)}`):new Error(`[BugCatch] report failed (HTTP ${y.status})${v?": "+v:""}`);throw k.status=y.status,H(this,B,Ne).call(this,"report",k),k}const m=await y.json();return H(this,B,st).call(this,m,{title:d.title??e.trim(),via:"form"}),m.watchToken&&(We(m.watchToken),this.config.updates&&this.startWatching()),m}loginState(){var e;return Ho({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId,token:(e=te(this.config.projectId))==null?void 0:e.token})}referenceFields(){return this.refFields?this.refFields:(this.refFields=Fo({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId}),this.refFields)}agentIssues(){return this.agentIssueList?this.agentIssueList:(this.agentIssueList=Yo({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId}),this.agentIssueList)}async announcements(){const e=await Go({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId});return ea(e)}dismissAnnouncement(e){ta(e)}signedInAs(){const e=te(this.config.projectId);return e?{email:e.email,name:e.name}:null}signIn(e,{name:n}={}){var o;return qo({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId,email:e,name:n??((o=this.config.user)==null?void 0:o.name)??null})}async confirmSignIn(e,n){var a;const o=await Do({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId,email:e,code:n});return(a=this.config.user)!=null&&a.email||(this.config.user={email:o.email,name:o.name||void 0}),this.emit("signin",{email:o.email,name:o.name}),{email:o.email,name:o.name}}async signOut(){var o;const e=te(this.config.projectId),n=await No({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId,token:e==null?void 0:e.token});return e!=null&&e.email&&((o=this.config.user)==null?void 0:o.email)===e.email&&(this.config.user=null),this.emit("signout",{email:(e==null?void 0:e.email)||null}),n}knownIssues(){var e;return Mo({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId,sessionToken:(e=te(this.config.projectId))==null?void 0:e.token})}matchKnownIssues(e,{signal:n}={}){var o;return Bo({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId,q:e||"",sessionToken:(o=te(this.config.projectId))==null?void 0:o.token,signal:n})}async meToo(e,{email:n,name:o}={}){var i,s;const a=te(this.config.projectId),r=await ft();return Ro({apiBase:this.config.apiBase,apiKey:this.config.apiKey,projectId:this.config.projectId,bugId:e,reporterEmail:n||((i=this.config.user)==null?void 0:i.email),reporterName:o||((s=this.config.user)==null?void 0:s.name),metadata:{...r,user:this.config.user||void 0,...Object.keys(this.context).length?{context:this.context}:{},sdk:me},logs:{console:{entries:this.consoleBuffer.all()},network:{entries:this.networkBuffer.all()}},sessionToken:a==null?void 0:a.token})}snapshot(){return{user:this.config.user||null,context:{...this.context},console:this.consoleBuffer.all(),network:this.networkBuffer.all(),environment:gt()}}clear(){this.consoleBuffer.clear(),this.networkBuffer.clear()}destroy(){this.endCall(),this.teardown.forEach(e=>{try{e()}catch{}}),this.teardown=[],this.notifier=null,this.started=!1}}B=new WeakSet,De=function(e,n){const o=this.config[e];if(typeof o=="function")try{o(n)}catch(a){console.error(`[BugCatch] your ${e} callback threw:`,a)}},Sn=function(){if(typeof window>"u"||typeof fetch!="function")return;const e=`bugcatch:hello:${this.config.projectId}`,n=new Date().toISOString().slice(0,10);try{if(window.localStorage.getItem(e)===n)return}catch{}const o=setTimeout(()=>{try{window.localStorage.setItem(e,n)}catch{}fetch(`${this.config.apiBase}/ingest/hello`,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json","X-BugCatch-Key":this.config.apiKey},body:JSON.stringify({projectId:this.config.projectId,version:me.version,identify:!!this.config.user,context:!!(this.context&&Object.keys(this.context).length),widget:!!this.config.widget,environment:this.config.environment||null,release:this.config.release||null})}).catch(()=>{})},5e3);this.teardown.push(()=>clearTimeout(o))},oe=function(){const e=be();if(this.emit("unread",{count:e.length,updates:e}),!!this.config.updateToast){if(!this.notifier){if(!e.length)return;this.notifier=Ao({accent:this.config.accent,position:this.config.widgetPosition,onRead:n=>this.markUpdateRead(n),onReadAll:()=>this.markUpdatesRead(),onCall:this.config.voice?n=>{this.markUpdateRead(n.id),this.startCall(n.bugId)}:null}),this.teardown.push(()=>{var n;return(n=this.notifier)==null?void 0:n.destroy()})}this.notifier.render(e)}},$n=function(e,n){const o=n==null?void 0:n.phase;if(!e||typeof o!="string"||this.phases.get(e)===o)return;this.phases.set(e,o);const a={bugId:e,phase:o,title:n.title??null,detail:n.detail??null};this.debugLog("assistant",a),H(this,B,De).call(this,"onAssistantPhase",a),this.emit("assistant",a)},st=function(e,{title:n,via:o}){if(!(e!=null&&e.id))return;const a={bugId:e.id,title:n??null,via:o,result:e};this.debugLog("report accepted",a),H(this,B,De).call(this,"onReportSubmitted",a),this.emit("report",a)},Ne=function(e,n){H(this,B,De).call(this,"onError",{action:e,error:n}),this.emit("error",{action:e,error:n})},Ue=async function({title:e,description:n="",priority:o="MEDIUM",metadata:a={},media:r=[],references:i=[],context:s=null,issue:c=null}){var f,d;const l=s?Xt(this.context,s,u=>this.warn(u.replace("setContext()","report({ context })"))):this.context;return{projectId:this.config.projectId,...e?{title:e}:{},description:n,priority:o,url:window.location.href,reporterEmail:(f=this.config.user)==null?void 0:f.email,reporterName:(d=this.config.user)==null?void 0:d.name,metadata:{...await ft(),release:this.config.release,environment:this.config.environment,buildId:this.config.buildId,...a,user:this.config.user||void 0,...Object.keys(l).length?{context:l}:{},sdk:me},logs:{console:{entries:this.consoleBuffer.all()},network:{entries:this.networkBuffer.all()}},...r.length?{attachments:r}:{},...i.length?{references:i}:{},...c?{issue:c}:{}}},ct=function(e){if(typeof this.config.beforeSend!="function")return e;let n;try{n=this.config.beforeSend(e)}catch(o){return this.warn(`beforeSend threw, so nothing was sent: ${(o==null?void 0:o.message)||o}`),!1}return n===!1?!1:n&&typeof n=="object"?n:e},Cn=async function(){const e=te(this.config.projectId),n=H(this,B,ct).call(this,await H(this,B,Ue).call(this,{}));if(n===!1)return this.debugLog("call cancelled by beforeSend"),{cancelled:!0};let o;try{o=await vo({apiBase:this.config.apiBase,apiKey:this.config.apiKey,token:e==null?void 0:e.token,payload:n,watchToken:P()})}catch(a){throw a.status===401&&e&&Ze(this.config.projectId),H(this,B,Ne).call(this,"call",a),a}return H(this,B,st).call(this,o,{title:null,via:"call"}),o.watchToken&&(We(o.watchToken),this.config.updates&&this.startWatching()),o},Tn=async function(e){const{joinLiveCall:n,liveCallSupported:o,openMicrophone:a}=await Se(this.config.chunkBase);if(!o())throw new Error("[BugCatch] this browser cannot make live calls.");const r=await a();let i,s=null;try{if(e)i=await xo({apiBase:this.config.apiBase,bugId:e});else if(s=await H(this,B,Cn).call(this),e=s.id,i=s.live_call,!(i!=null&&i.realtime_url)){const l=new Error(`[BugCatch] the report was filed, but the team could not be rung${s.call_error?`: ${s.call_error}`:"."}`);throw l.filed=s,l.reason=s.call_error||null,l}}catch(l){for(const f of r.getTracks())f.stop();throw l}const c=await n({realtimeUrl:i.realtime_url,stream:r,ringsUntil:i.rings_until,onState:(l,f)=>{(l==="ended"||l==="failed"||l==="missed")&&(this.call=null),l==="missed"&&ko({apiBase:this.config.apiBase,bugId:e,callId:i.call_id}),typeof this.config.onCallState=="function"&&this.config.onCallState(l,{bugId:e,live:!0,...f}),this.emit("call",{bugId:e,live:!0,state:l,...f})}});return this.call=c,Object.assign(c,{bugId:e,callId:i.call_id,live:!0,filed:s,recorded:!!i.recorded})},En=function(e){var a;const n=e.incomingCall;if(!this.config.voice||((a=this.ringing)==null?void 0:a.callId)===n.callId||this.call||this.callStarting)return;H(this,B,_e).call(this);const o={callId:n.callId,dismiss:()=>{}};this.ringing=o,Se(this.config.chunkBase).then(({liveCallSupported:r,showIncomingCall:i})=>{if(this.ringing!==o||(this.ringing=null,!r())||this.call||this.callStarting)return;const s=i({call:n,accent:this.config.accent,position:this.config.widgetPosition,touched:Uo,onAnswer:()=>{H(this,B,In).call(this,e.bugId,n)},onDecline:()=>{this.ringing=null,Bt({apiBase:this.config.apiBase,bugId:e.bugId,callId:n.callId}),this.emit("incoming-call",{bugId:e.bugId,callId:n.callId,state:"declined"})},onExpire:()=>{this.ringing=null,this.emit("incoming-call",{bugId:e.bugId,callId:n.callId,state:"missed"})}});if(this.ringing={callId:n.callId,dismiss:s},typeof this.config.onIncomingCall=="function")try{this.config.onIncomingCall({bugId:e.bugId,...n})}catch{}this.emit("incoming-call",{bugId:e.bugId,callId:n.callId,state:"ringing"})},()=>{this.ringing===o&&(this.ringing=null)})},_e=function(e){if(this.ringing&&!(e&&this.ringing.callId!==e)){try{this.ringing.dismiss()}catch{}this.ringing=null}},In=async function(e,n){if(this.ringing=null,this.call||this.callStarting)return;this.callStarting=!0;let o,a;try{const i=await Se(this.config.chunkBase);a=i.joinLiveCall,o=await i.openMicrophone()}catch(i){this.callStarting=!1,Bt({apiBase:this.config.apiBase,bugId:e,callId:n.callId}),this.emit("incoming-call",{bugId:e,callId:n.callId,state:"failed",error:i});return}let r;try{r=await So({apiBase:this.config.apiBase,bugId:e,callId:n.callId})}catch(i){for(const s of o.getTracks())s.stop();this.callStarting=!1,this.emit("incoming-call",{bugId:e,callId:n.callId,state:"missed",error:i});return}try{const i=await a({realtimeUrl:r.realtime_url,stream:o,onState:(s,c)=>{(s==="ended"||s==="failed"||s==="missed")&&(this.call=null),typeof this.config.onCallState=="function"&&this.config.onCallState(s,{bugId:e,live:!0,incoming:!0,...c}),this.emit("call",{bugId:e,live:!0,incoming:!0,state:s,...c})}});this.call=i,this.emit("incoming-call",{bugId:e,callId:n.callId,state:"answered"})}catch(i){for(const s of o.getTracks())s.stop();this.emit("incoming-call",{bugId:e,callId:n.callId,state:"failed",error:i})}finally{this.callStarting=!1}};const nt=new Gt;nt.Client=Gt,nt.version=me.version;const wa='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8.5A1.5 1.5 0 0 1 4.5 7h2.2a1 1 0 0 0 .83-.45l.94-1.4A1 1 0 0 1 9.3 4.7h5.4a1 1 0 0 1 .83.45l.94 1.4a1 1 0 0 0 .83.45h2.2A1.5 1.5 0 0 1 21 8.5v9A1.5 1.5 0 0 1 19.5 19h-15A1.5 1.5 0 0 1 3 17.5z"/><circle cx="12" cy="13" r="3.4"/></svg>',va='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="6" width="12.5" height="12" rx="2.2"/><path d="M15.5 10.8l4.2-2.6a.6.6 0 0 1 .92.5v6.6a.6.6 0 0 1-.92.5l-4.2-2.6z"/></svg>',en='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 11.5l-7.6 7.6a4.6 4.6 0 0 1-6.5-6.5l8-8a3.2 3.2 0 0 1 4.5 4.5l-8 8a1.8 1.8 0 0 1-2.5-2.5l7.1-7.1"/></svg>',tn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="2.5" width="6" height="11" rx="3"/><path d="M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M9 21h6"/></svg>',nn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12l16-8-6 16-2.6-6.2L4 12Z"/></svg>',xa='<svg viewBox="0 0 24 24" fill="currentColor"><rect x="7" y="7" width="10" height="10" rx="2"/></svg>',ka='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 5.5L8 12l6.5 6.5"/></svg>',Re='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M6.2 3.5h3l1.5 3.7-2 1.4a11.5 11.5 0 0 0 5.7 5.7l1.4-2 3.7 1.5v3a1.8 1.8 0 0 1-2 1.8A15.6 15.6 0 0 1 4.4 5.5a1.8 1.8 0 0 1 1.8-2z"/></svg>',Sa='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 12a8 8 0 1 1-2.6-5.9M20 4v4.5h-4.5"/></svg>',we='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.5c.5 4.6 2.9 7 7.5 7.5v.1c-4.6.5-7 2.9-7.5 7.5h-.1c-.5-4.6-2.9-7-7.5-7.5V10c4.6-.5 7-2.9 7.5-7.5z"/><path d="M18.6 15.2c.2 1.9 1.2 2.9 3.1 3.1v.1c-1.9.2-2.9 1.2-3.1 3.1h-.1c-.2-1.9-1.2-2.9-3.1-3.1v-.1c1.9-.2 2.9-1.2 3.1-3.1z" opacity=".7"/></svg>',$a='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9.5 6l6 6-6 6"/></svg>',Ca='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 13.5l2.6-7.2A1.5 1.5 0 0 1 7.5 5.3h9a1.5 1.5 0 0 1 1.4 1L20.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5H5A1.5 1.5 0 0 1 3.5 18z"/><path d="M3.5 13.5h4.8l1.2 2.2h5l1.2-2.2h4.8"/></svg>',Ta='<svg class="bc-brand" viewBox="0 0 254 60" fill="none" role="img" aria-label="sphoro BugCatch"><g fill="currentColor"><path transform="translate(0.00 40.00) scale(0.04000 -0.04000)" d="M276.00 -14.00Q179.00 -14.00 117.00 28.00Q55.00 70.00 42.00 148.00L158.00 178.00Q165.00 143.00 181.50 123.00Q198.00 103.00 222.50 94.50Q247.00 86.00 276.00 86.00Q320.00 86.00 341.00 101.50Q362.00 117.00 362.00 140.00Q362.00 163.00 342.00 175.50Q322.00 188.00 278.00 196.00L250.00 201.00Q198.00 211.00 155.00 228.50Q112.00 246.00 86.00 277.00Q60.00 308.00 60.00 357.00Q60.00 431.00 114.00 470.50Q168.00 510.00 256.00 510.00Q339.00 510.00 394.00 473.00Q449.00 436.00 466.00 376.00L349.00 340.00Q341.00 378.00 316.50 394.00Q292.00 410.00 256.00 410.00Q220.00 410.00 201.00 397.50Q182.00 385.00 182.00 363.00Q182.00 339.00 202.00 327.50Q222.00 316.00 256.00 310.00L284.00 305.00Q340.00 295.00 385.50 278.50Q431.00 262.00 457.50 231.50Q484.00 201.00 484.00 149.00Q484.00 71.00 427.50 28.50Q371.00 -14.00 276.00 -14.00Z"/><path transform="translate(19.56 40.00) scale(0.04000 -0.04000)" d="M70.00 -200.00V496.00H194.00V436.00H212.00Q229.00 465.00 265.00 487.50Q301.00 510.00 368.00 510.00Q428.00 510.00 479.00 480.50Q530.00 451.00 561.00 394.00Q592.00 337.00 592.00 256.00V240.00Q592.00 159.00 561.00 102.00Q530.00 45.00 479.00 15.50Q428.00 -14.00 368.00 -14.00Q323.00 -14.00 292.50 -3.50Q262.00 7.00 243.50 23.50Q225.00 40.00 214.00 57.00H196.00V-200.00ZM330.00 96.00Q389.00 96.00 427.50 133.50Q466.00 171.00 466.00 243.00V253.00Q466.00 325.00 427.00 362.50Q388.00 400.00 330.00 400.00Q272.00 400.00 233.00 362.50Q194.00 325.00 194.00 253.00V243.00Q194.00 171.00 233.00 133.50Q272.00 96.00 330.00 96.00Z"/><path transform="translate(43.68 40.00) scale(0.04000 -0.04000)" d="M70.00 0.00V700.00H196.00V435.00H214.00Q222.00 451.00 239.00 467.00Q256.00 483.00 284.50 493.50Q313.00 504.00 357.00 504.00Q415.00 504.00 458.50 477.50Q502.00 451.00 526.00 404.50Q550.00 358.00 550.00 296.00V0.00H424.00V286.00Q424.00 342.00 396.50 370.00Q369.00 398.00 318.00 398.00Q260.00 398.00 228.00 359.50Q196.00 321.00 196.00 252.00V0.00Z"/><path transform="translate(66.92 40.00) scale(0.04000 -0.04000)" d="M306.00 -14.00Q232.00 -14.00 173.00 16.00Q114.00 46.00 80.00 103.00Q46.00 160.00 46.00 240.00V256.00Q46.00 336.00 80.00 393.00Q114.00 450.00 173.00 480.00Q232.00 510.00 306.00 510.00Q380.00 510.00 439.00 480.00Q498.00 450.00 532.00 393.00Q566.00 336.00 566.00 256.00V240.00Q566.00 160.00 532.00 103.00Q498.00 46.00 439.00 16.00Q380.00 -14.00 306.00 -14.00ZM306.00 98.00Q364.00 98.00 402.00 135.50Q440.00 173.00 440.00 243.00V253.00Q440.00 323.00 402.50 360.50Q365.00 398.00 306.00 398.00Q248.00 398.00 210.00 360.50Q172.00 323.00 172.00 253.00V243.00Q172.00 173.00 210.00 135.50Q248.00 98.00 306.00 98.00Z"/><path transform="translate(90.00 40.00) scale(0.04000 -0.04000)" d="M70.00 0.00V496.00H194.00V440.00H212.00Q223.00 470.00 248.50 484.00Q274.00 498.00 308.00 498.00H368.00V386.00H306.00Q258.00 386.00 227.00 360.50Q196.00 335.00 196.00 282.00V0.00Z"/><path transform="translate(104.44 40.00) scale(0.04000 -0.04000)" d="M306.00 -14.00Q232.00 -14.00 173.00 16.00Q114.00 46.00 80.00 103.00Q46.00 160.00 46.00 240.00V256.00Q46.00 336.00 80.00 393.00Q114.00 450.00 173.00 480.00Q232.00 510.00 306.00 510.00Q380.00 510.00 439.00 480.00Q498.00 450.00 532.00 393.00Q566.00 336.00 566.00 256.00V240.00Q566.00 160.00 532.00 103.00Q498.00 46.00 439.00 16.00Q380.00 -14.00 306.00 -14.00ZM306.00 98.00Q364.00 98.00 402.00 135.50Q440.00 173.00 440.00 243.00V253.00Q440.00 323.00 402.50 360.50Q365.00 398.00 306.00 398.00Q248.00 398.00 210.00 360.50Q172.00 323.00 172.00 253.00V243.00Q172.00 173.00 210.00 135.50Q248.00 98.00 306.00 98.00Z"/></g><rect x="139.52" y="16" width="1.6" height="26" rx="0.8" fill="var(--bc-brand-mark, #5647ee)" opacity="0.4"/><g fill="var(--bc-brand-mark, #5647ee)"><path transform="translate(154.52 35.00) scale(0.01400 -0.01400)" d="M46.35 0.00V105.85H139.75V594.15H46.35V700.00H404.08Q467.38 700.00 514.79 678.41Q562.20 656.83 588.70 617.33Q615.20 577.83 615.20 523.35V513.70Q615.20 465.52 597.03 434.76Q578.85 404.00 553.91 387.24Q528.98 370.48 506.28 363.30V346.35Q528.98 340.35 555.24 323.50Q581.50 306.65 600.00 275.48Q618.50 244.30 618.50 194.48V184.48Q618.50 126.65 591.41 85.24Q564.33 43.83 516.83 21.91Q469.33 0.00 406.85 0.00ZM259.85 109.15H392.60Q441.20 109.15 469.80 132.60Q498.40 156.05 498.40 198.55V208.20Q498.40 250.70 470.21 274.15Q442.02 297.60 392.60 297.60H259.85ZM259.85 406.75H391.65Q437.55 406.75 466.32 430.11Q495.10 453.48 495.10 493.80V503.80Q495.10 544.95 466.74 567.90Q438.37 590.85 391.65 590.85H259.85Z"/><path transform="translate(167.00 35.00) scale(0.01400 -0.01400)" d="M335.30 -14.00Q251.22 -14.00 190.60 16.63Q129.97 47.25 97.56 104.96Q65.15 162.68 65.15 243.03V700.00H185.25V239.73Q185.25 170.48 224.03 131.99Q262.80 93.50 335.30 93.50Q407.80 93.50 446.57 131.99Q485.35 170.48 485.35 239.73V700.00H605.45V243.03Q605.45 162.68 573.13 104.96Q540.80 47.25 480.09 16.63Q419.38 -14.00 335.30 -14.00Z"/><path transform="translate(179.60 35.00) scale(0.01400 -0.01400)" d="M311.85 -14.00Q238.45 -14.00 179.69 18.50Q120.92 51.00 86.69 113.67Q52.45 176.35 52.45 266.87V433.13Q52.45 569.00 128.01 641.50Q203.57 714.00 332.35 714.00Q460.13 714.00 529.23 645.59Q598.33 577.17 598.33 460.87V456.70H479.87V464.52Q479.87 504.67 463.76 536.86Q447.65 569.05 414.99 587.77Q382.32 606.50 332.35 606.50Q257.63 606.50 215.09 560.70Q172.55 514.90 172.55 435.13V264.87Q172.55 185.93 215.09 138.89Q257.63 91.85 334.00 91.85Q410.02 91.85 445.12 132.83Q480.22 173.80 480.22 237.92V249.67H302.85V351.88H598.33V0.00H487.52V69.10H470.57Q462.70 50.87 446.06 31.44Q429.42 12.00 397.64 -1.00Q365.85 -14.00 311.85 -14.00Z"/><path transform="translate(192.05 35.00) scale(0.01400 -0.01400)" d="M332.35 -14.00Q203.57 -14.00 128.01 58.50Q52.45 131.00 52.45 266.87V433.13Q52.45 569.00 128.01 641.50Q203.57 714.00 332.35 714.00Q460.13 714.00 529.58 643.85Q599.03 573.70 599.03 451.57V445.75H480.57V455.22Q480.57 521.42 444.15 563.96Q407.72 606.50 332.35 606.50Q257.63 606.50 215.09 560.70Q172.55 514.90 172.55 435.13V264.87Q172.55 185.93 215.09 139.71Q257.63 93.50 332.35 93.50Q407.72 93.50 444.15 136.45Q480.57 179.40 480.57 244.78V262.25H599.03V248.43Q599.03 126.30 529.58 56.15Q460.13 -14.00 332.35 -14.00Z"/><path transform="translate(204.25 35.00) scale(0.01400 -0.01400)" d="M19.75 0.00 211.62 700.00H421.33L613.20 0.00H489.27L447.42 159.60H185.53L143.68 0.00ZM214.25 270.40H418.70L324.95 624.87H308.00Z"/><path transform="translate(216.31 35.00) scale(0.01400 -0.01400)" d="M233.95 0.00V590.85H24.70V700.00H563.30V590.85H354.05V0.00Z"/><path transform="translate(227.75 35.00) scale(0.01400 -0.01400)" d="M332.35 -14.00Q203.57 -14.00 128.01 58.50Q52.45 131.00 52.45 266.87V433.13Q52.45 569.00 128.01 641.50Q203.57 714.00 332.35 714.00Q460.13 714.00 529.58 643.85Q599.03 573.70 599.03 451.57V445.75H480.57V455.22Q480.57 521.42 444.15 563.96Q407.72 606.50 332.35 606.50Q257.63 606.50 215.09 560.70Q172.55 514.90 172.55 435.13V264.87Q172.55 185.93 215.09 139.71Q257.63 93.50 332.35 93.50Q407.72 93.50 444.15 136.45Q480.57 179.40 480.57 244.78V262.25H599.03V248.43Q599.03 126.30 529.58 56.15Q460.13 -14.00 332.35 -14.00Z"/><path transform="translate(239.95 35.00) scale(0.01400 -0.01400)" d="M69.50 0.00V700.00H189.60V405.58H466.40V700.00H586.50V0.00H466.40V296.42H189.60V0.00Z"/></g></svg>',Ea=`
298
+ @keyframes bc-fade-in { from { opacity: 0 } to { opacity: 1 } }
299
+ @keyframes bc-fade-out { to { opacity: 0 } }
300
+ @keyframes bc-panel-in { from { opacity: 0; transform: translateY(14px) scale(.965) } to { opacity: 1; transform: none } }
301
+ @keyframes bc-panel-out { to { opacity: 0; transform: translateY(10px) scale(.975) } }
302
+ @keyframes bc-sheet-in { from { transform: translateY(100%) } to { transform: none } }
303
+ @keyframes bc-sheet-out { to { transform: translateY(100%) } }
304
+ @keyframes bc-rise { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
305
+ @keyframes bc-pulse { 0%, 100% { opacity: 1; transform: scale(1) } 50% { opacity: .3; transform: scale(.78) } }
306
+ @keyframes bc-spin { to { transform: rotate(360deg) } }
307
+ @keyframes bc-pop { 0% { transform: scale(.5); opacity: 0 } 65% { transform: scale(1.1) } 100% { transform: scale(1); opacity: 1 } }
308
+ @keyframes bc-nudge { 25% { transform: translateX(-3px) } 75% { transform: translateX(3px) } }
309
+ @keyframes bc-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45 } 30% { transform: translateY(-3px); opacity: 1 } }
310
+ @keyframes bc-shimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }
311
+
312
+ /* ---------- scrim + panel ---------- */
313
+ .scrim {
314
+ position: fixed; inset: 0; z-index: 2147483001;
315
+ background: rgba(10,12,16,.32);
316
+ animation: bc-fade-in 200ms ease both;
317
+ }
318
+ .scrim.closing { animation: bc-fade-out 170ms ease both; }
319
+
320
+ /* The panel belongs to the launcher, so it opens out of that corner rather
321
+ than in the middle of the screen. --bc-dock-h is measured at open time
322
+ because the dock's height depends on whether the launcher is showing.
323
+ A column: the header and footer stay put and only the middle scrolls. */
324
+ .panel {
325
+ position: fixed;
326
+ display: flex; flex-direction: column;
327
+ width: calc(100vw - 40px); max-width: 420px;
328
+ max-height: calc(100vh - var(--bc-dock-h, 84px) - 52px);
329
+ overflow: hidden;
330
+ background: var(--bc-bg); color: var(--bc-fg);
331
+ border-radius: var(--bc-r-xl); box-shadow: var(--bc-shadow);
332
+ border: 1px solid color-mix(in srgb, var(--bc-border) 70%, transparent);
333
+ animation: bc-panel-in 340ms var(--bc-ease) both;
334
+ }
335
+ /* A conversation wants a height of its own, so the thread fills the panel
336
+ rather than shrinking to its first two messages. */
337
+ .panel.is-chat { height: 640px; }
338
+ .scrim.at-right .panel { right: 20px; transform-origin: bottom right; }
339
+ .scrim.at-left .panel { left: 20px; transform-origin: bottom left; }
340
+ .scrim.at-bottom .panel { bottom: calc(20px + var(--bc-dock-h, 84px) + 12px); }
341
+ .scrim.at-top .panel { top: calc(20px + var(--bc-dock-h, 84px) + 12px); transform-origin: top right; }
342
+ .scrim.closing .panel { animation: bc-panel-out 170ms ease both; }
343
+
344
+ /* ---------- header ---------- */
345
+ .head {
346
+ flex: none; position: relative;
347
+ display: flex; align-items: center; gap: 12px;
348
+ padding: 16px 14px 14px var(--bc-pad);
349
+ background: linear-gradient(180deg, var(--bc-accent-soft), var(--bc-bg));
350
+ border-bottom: 1px solid var(--bc-border);
351
+ }
352
+ .head .mark, .avatar {
353
+ flex: none; display: grid; place-items: center; position: relative;
354
+ width: 38px; height: 38px; border-radius: 50%;
355
+ background: linear-gradient(140deg, var(--bc-accent), color-mix(in srgb, var(--bc-accent) 60%, #fff));
356
+ color: var(--bc-on-accent); font-size: 19px;
357
+ box-shadow: 0 4px 12px color-mix(in srgb, var(--bc-accent) 30%, transparent);
358
+ }
359
+ /* The little "online" dot says someone — or something — is on the other end. */
360
+ .head .mark::after {
361
+ content: ''; position: absolute; right: -1px; bottom: -1px;
362
+ width: 11px; height: 11px; border-radius: 50%;
363
+ background: #22c55e; border: 2px solid var(--bc-bg);
364
+ }
365
+ .head .titles { flex: 1; min-width: 0; }
366
+ .head h2 {
367
+ margin: 0 0 2px; font-size: var(--bc-fs-lg); font-weight: 680; letter-spacing: -.02em; line-height: 1.25;
368
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
369
+ }
370
+ .head p { margin: 0; font-size: var(--bc-fs-sm); line-height: 1.45; color: var(--bc-muted); }
371
+ .icon-btn {
372
+ flex: none; display: grid; place-items: center;
373
+ width: 32px; height: 32px; padding: 0; font-size: 16px;
374
+ border: none; border-radius: 10px; background: none; color: var(--bc-muted);
375
+ cursor: pointer; transition: background 160ms, color 160ms, transform 160ms var(--bc-ease);
376
+ }
377
+ .icon-btn:hover { background: color-mix(in srgb, var(--bc-fg) 7%, transparent); color: var(--bc-fg); }
378
+ .icon-btn:active { transform: scale(.92); }
379
+ .icon-btn.back { margin: 0 -6px 0 -8px; }
380
+
381
+ .body {
382
+ flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
383
+ padding: 16px var(--bc-pad) 6px;
384
+ }
385
+
386
+ label { display: block; font-size: var(--bc-fs-sm); font-weight: 620; color: var(--bc-fg); margin-bottom: 7px; }
387
+ label .opt { font-weight: 450; color: var(--bc-faint); }
388
+ input[type=text], input[type=email], textarea {
389
+ width: 100%; padding: 11px 13px; font-size: var(--bc-fs-md); line-height: 1.45;
390
+ color: var(--bc-fg); background: var(--bc-elevated);
391
+ border: 1px solid var(--bc-border); border-radius: var(--bc-r-md);
392
+ transition: border-color 160ms, box-shadow 160ms, background 160ms;
393
+ }
394
+ input[type=text]::placeholder, input[type=email]::placeholder, textarea::placeholder { color: var(--bc-faint); }
395
+ input[type=text]:hover, input[type=email]:hover, textarea:hover { border-color: color-mix(in srgb, var(--bc-fg) 18%, var(--bc-border)); }
396
+ input[type=text]:focus, input[type=email]:focus, textarea:focus {
397
+ outline: none; border-color: var(--bc-accent); box-shadow: var(--bc-ring);
398
+ }
399
+ input.invalid, input.invalid:focus, textarea.invalid {
400
+ border-color: var(--bc-danger); animation: bc-nudge 240ms ease;
401
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--bc-danger) 16%, transparent);
402
+ }
403
+ .field-err {
404
+ display: flex; align-items: center; gap: 6px;
405
+ margin: 7px 0 0; font-size: var(--bc-fs-xs); font-weight: 550; color: var(--bc-danger);
406
+ animation: bc-rise 200ms var(--bc-ease) both;
407
+ }
408
+ .field-err svg { font-size: 13px; flex: none; }
409
+ textarea { min-height: 88px; resize: vertical; }
410
+ .field { margin-bottom: 16px; }
411
+ .field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
412
+ .field-head .count { font-size: var(--bc-fs-xs); color: var(--bc-faint); font-variant-numeric: tabular-nums; }
413
+
414
+ /* The draft line: a quiet note, or a card offering to pick up where they left off. */
415
+ .compose > .note { font-size: var(--bc-fs-xs); color: var(--bc-faint); margin: -4px 0 10px; }
416
+ .compose > .note:empty { display: none; }
417
+ .compose > .note:has(button) {
418
+ display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
419
+ margin: 0 0 14px; padding: 10px 12px; border-radius: var(--bc-r-md);
420
+ background: var(--bc-accent-soft); border: 1px solid var(--bc-accent-line);
421
+ font-size: var(--bc-fs-sm); color: var(--bc-fg);
422
+ }
423
+ .compose > .note button {
424
+ padding: 5px 11px; font: inherit; font-size: var(--bc-fs-xs); font-weight: 620;
425
+ border-radius: 999px; cursor: pointer;
426
+ border: 1px solid var(--bc-accent); background: var(--bc-accent); color: var(--bc-on-accent);
427
+ }
428
+ .compose > .note button[data-discard] { background: transparent; color: var(--bc-muted); border-color: var(--bc-border); }
429
+
430
+ /* ---------- what is already known ----------
431
+ A help surface in front of the form, not a step in it. Everything here is
432
+ dismissible by ignoring it: the reporter can read what is already known and
433
+ leave, tap "this is happening to me too" and leave, or type straight past all
434
+ of it and file the report they came to file. Nothing is ever in their way,
435
+ because a reporter who feels handled rather than helped stops reporting. */
436
+ .known { margin-bottom: 16px; }
437
+ .known .known-h {
438
+ margin: 0 0 8px; font-size: 11px; font-weight: 680; letter-spacing: .06em;
439
+ text-transform: uppercase; color: var(--bc-faint);
440
+ }
441
+ .known .issue {
442
+ display: flex; align-items: center; gap: 10px;
443
+ padding: 10px 12px; margin-bottom: 6px;
444
+ background: var(--bc-subtle); border: 1px solid var(--bc-border); border-radius: var(--bc-r-md);
445
+ animation: bc-rise 240ms var(--bc-ease) both;
446
+ }
447
+ .known .issue.is-joined { border-color: color-mix(in srgb, var(--bc-ok) 55%, var(--bc-border)); }
448
+ .known .issue .who { flex: 1; min-width: 0; }
449
+ .known .issue .t {
450
+ display: block; font-size: 13px; font-weight: 620; line-height: 1.4;
451
+ color: var(--bc-fg); overflow-wrap: anywhere;
452
+ }
453
+ .known .issue .meta {
454
+ display: block; margin-top: 3px; font-size: var(--bc-fs-xs); line-height: 1.45; color: var(--bc-muted);
455
+ }
456
+ .known .issue .join {
457
+ flex: none; padding: 7px 12px; font-size: 12px; font-weight: 620;
458
+ color: var(--bc-accent); background: var(--bc-bg);
459
+ border: 1px solid var(--bc-accent-line); border-radius: 999px; cursor: pointer;
460
+ transition: background 160ms, border-color 160ms;
461
+ }
462
+ .known .issue .join:hover { border-color: var(--bc-accent); background: var(--bc-accent-soft); }
463
+ .known .issue .join:disabled { color: var(--bc-ok); border-color: var(--bc-border); background: var(--bc-bg); cursor: default; opacity: 1; }
464
+ .known .ask { display: flex; gap: 8px; margin: 2px 0 8px; }
465
+ .known .ask input { flex: 1; min-width: 0; }
466
+ .known .ask button { flex: none; }
467
+ .known .err { margin: 6px 0 0; font-size: 12px; line-height: 1.45; color: var(--bc-danger); }
468
+
469
+ /* ---------- questions the assistant answers by itself ---------- */
470
+ .picks { margin-bottom: 16px; }
471
+ .picks .picks-h {
472
+ margin: 0 0 8px; font-size: 11px; font-weight: 680; letter-spacing: .06em;
473
+ text-transform: uppercase; color: var(--bc-faint);
474
+ }
475
+ .picks .picks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
476
+ .picks .pick {
477
+ display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
478
+ padding: 9px 11px; text-align: left; cursor: pointer; font: inherit;
479
+ color: var(--bc-fg); background: var(--bc-subtle);
480
+ border: 1px solid var(--bc-border); border-radius: var(--bc-r-md);
481
+ transition: background 160ms, border-color 160ms, transform 160ms;
482
+ animation: bc-rise 240ms var(--bc-ease) both;
483
+ }
484
+ .picks .pick:hover { border-color: var(--bc-accent-line); background: var(--bc-accent-soft); }
485
+ .picks .pick[aria-pressed="true"] { border-color: var(--bc-accent); background: var(--bc-accent-soft); }
486
+ .picks .pick .t { font-size: 13px; font-weight: 620; line-height: 1.35; overflow-wrap: anywhere; }
487
+ .picks .pick .h { font-size: var(--bc-fs-xs); line-height: 1.4; color: var(--bc-muted); }
488
+ .picks .picks-note {
489
+ display: flex; gap: 6px; align-items: flex-start; margin: 8px 0 0;
490
+ font-size: 12px; line-height: 1.45; color: var(--bc-muted);
491
+ }
492
+ .picks .picks-note svg { flex: none; margin-top: 2px; color: var(--bc-ok); }
493
+
494
+ /* ---------- who is reporting ----------
495
+ A strip above the form rather than a screen in front of it: where signing in
496
+ is optional this is a line the reporter may ignore, and it should read as
497
+ one. Where it is required the composer below is not rendered at all and this
498
+ strip is the whole panel. */
499
+ .whoami {
500
+ display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
501
+ margin-bottom: 16px; padding: 10px 12px;
502
+ font-size: var(--bc-fs-sm); line-height: 1.45; color: var(--bc-muted);
503
+ background: var(--bc-subtle); border: 1px solid var(--bc-border); border-radius: var(--bc-r-md);
504
+ }
505
+ .whoami.asking { display: block; padding: 14px; }
506
+ .whoami .who { flex: 1; min-width: 0; }
507
+ .whoami .who strong { color: var(--bc-fg); font-weight: 620; word-break: break-all; }
508
+ .link {
509
+ padding: 0; font: inherit; font-size: var(--bc-fs-sm); font-weight: 620; line-height: 1.45;
510
+ color: var(--bc-accent); background: none; border: none; cursor: pointer; border-radius: 4px;
511
+ }
512
+ .link:hover { text-decoration: underline; text-underline-offset: 2px; }
513
+ .link:disabled { color: var(--bc-faint); cursor: default; text-decoration: none; }
514
+ .whoami .why { margin: 0 0 10px; font-size: var(--bc-fs-sm); line-height: 1.5; color: var(--bc-muted); }
515
+ .whoami .why strong { color: var(--bc-fg); font-weight: 620; word-break: break-all; }
516
+ .whoami .row { display: flex; gap: 8px; align-items: stretch; }
517
+ .whoami .row input { flex: 1; min-width: 0; }
518
+ .whoami .row button { flex: none; }
519
+ .whoami .after { display: flex; gap: 14px; align-items: center; margin-top: 9px; }
520
+ .whoami .err { color: var(--bc-danger); }
521
+ .whoami .code { letter-spacing: .28em; font-variant-numeric: tabular-nums; }
522
+
523
+ /* ---------- which record is this about ----------
524
+ Drawn only after Send has been pressed and only when what they wrote did not
525
+ already answer it, so most people never see this at all. Presented as the
526
+ assistant asking one friendly follow-up, not as a form field that appeared. */
527
+ .refs {
528
+ position: relative;
529
+ margin-bottom: 16px; padding: 14px;
530
+ font-size: var(--bc-fs-sm); line-height: 1.45; color: var(--bc-muted);
531
+ background: var(--bc-accent-soft);
532
+ border: 1px solid var(--bc-accent-line); border-radius: var(--bc-r-lg);
533
+ animation: bc-item-in 280ms var(--bc-ease) both;
534
+ }
535
+ .refs .ask-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 11px; }
536
+ .refs .ask-head .avatar { width: 28px; height: 28px; font-size: 14px; box-shadow: none; }
537
+ .refs .ask-head strong { display: block; font-size: 13.5px; font-weight: 650; color: var(--bc-fg); margin-bottom: 1px; }
538
+ .refs .why { margin: 0; font-size: var(--bc-fs-sm); line-height: 1.5; color: var(--bc-muted); }
539
+ .refs .row { display: flex; gap: 8px; align-items: stretch; }
540
+ .refs .row input { flex: 1; min-width: 0; background: var(--bc-bg); }
541
+ .refs select {
542
+ flex: none; max-width: 45%; padding: 10px 10px; font-size: 13px;
543
+ color: var(--bc-fg); background: var(--bc-bg);
544
+ border: 1px solid var(--bc-border); border-radius: var(--bc-r-md);
545
+ }
546
+ .refs select:focus { outline: none; border-color: var(--bc-accent); box-shadow: var(--bc-ring); }
547
+ .refs .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
548
+ .refs .chips button {
549
+ padding: 5px 11px; font: inherit; font-size: 12px; font-weight: 600; border-radius: 999px; cursor: pointer;
550
+ color: var(--bc-muted); background: var(--bc-bg); border: 1px solid var(--bc-border);
551
+ transition: background 160ms, color 160ms, border-color 160ms;
552
+ }
553
+ .refs .chips button[aria-pressed="true"] { color: var(--bc-on-accent); background: var(--bc-accent); border-color: var(--bc-accent); }
554
+ .refs .hint { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--bc-muted); }
555
+ .refs .after { display: flex; gap: 12px; align-items: center; margin-top: 9px; }
556
+ .refs .err { color: var(--bc-danger); font-weight: 550; }
557
+ .refs .link { margin-top: 10px; font-size: 12px; color: var(--bc-muted); }
558
+ .refs .link:hover { color: var(--bc-fg); }
559
+ .refs .chips.cands button { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 550; }
560
+ /* "We read your ID" — under the description, while they type. */
561
+ .ref-found {
562
+ display: flex; align-items: center; gap: 6px;
563
+ margin: -6px 0 14px; font-size: 12px; line-height: 1.45; color: var(--bc-muted);
564
+ }
565
+ .ref-found svg { width: 14px; height: 14px; flex: none; color: var(--bc-ok); }
566
+ .ref-found b { font-weight: 600; color: var(--bc-fg); }
567
+
568
+ /* ---------- severity ---------- */
569
+ .seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px; background: var(--bc-subtle); border: 1px solid var(--bc-border); border-radius: var(--bc-r-md); }
570
+ .seg button {
571
+ display: inline-flex; align-items: center; justify-content: center; gap: 6px;
572
+ padding: 8px 4px; font-size: var(--bc-fs-sm); font-weight: 550; line-height: 1;
573
+ color: var(--bc-muted); background: none; border: none; border-radius: 9px;
574
+ cursor: pointer; transition: background 180ms var(--bc-ease), color 180ms, box-shadow 180ms;
575
+ }
576
+ .seg button::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--sev, var(--bc-faint)); opacity: .55; transition: opacity 180ms; }
577
+ .seg button[data-prio="LOW"] { --sev: #94a3b8; }
578
+ .seg button[data-prio="MEDIUM"] { --sev: #3b82f6; }
579
+ .seg button[data-prio="HIGH"] { --sev: #f59e0b; }
580
+ .seg button[data-prio="CRITICAL"] { --sev: #ef4444; }
581
+ .seg button:hover { color: var(--bc-fg); }
582
+ .seg button[aria-pressed=true] {
583
+ background: var(--bc-raised); color: var(--bc-fg); font-weight: 650;
584
+ box-shadow: 0 1px 3px rgba(10,12,16,.14), 0 0 0 1px color-mix(in srgb, var(--bc-border) 60%, transparent);
585
+ }
586
+ .seg button[aria-pressed=true]::before { opacity: 1; }
587
+ .seg button:focus-visible { outline-offset: -2px; }
588
+
589
+ /* ---------- attachments ---------- */
590
+ .tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
591
+ .tool {
592
+ display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
593
+ padding: 12px 8px; font-size: 12px; font-weight: 600; line-height: 1;
594
+ color: var(--bc-fg); background: var(--bc-elevated);
595
+ border: 1px dashed color-mix(in srgb, var(--bc-fg) 20%, var(--bc-border)); border-radius: var(--bc-r-md); cursor: pointer;
596
+ transition: border-color 160ms, background 160ms, color 160ms, transform 160ms var(--bc-ease);
597
+ }
598
+ .tool svg { font-size: 19px; color: var(--bc-muted); transition: color 160ms; }
599
+ .tool:hover:not(:disabled) { border-color: var(--bc-accent); border-style: solid; background: var(--bc-accent-soft); transform: translateY(-1px); }
600
+ .tool:hover:not(:disabled) svg { color: var(--bc-accent); }
601
+ .tool:active:not(:disabled) { transform: translateY(0) scale(.98); }
602
+ .tool:disabled { opacity: .45; cursor: not-allowed; }
603
+ .attach-hint { margin: 8px 0 0; font-size: var(--bc-fs-xs); color: var(--bc-faint); }
604
+
605
+ .thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
606
+ .thumbs:empty { display: none; }
607
+ .thumb {
608
+ position: relative; width: 76px; height: 76px; flex: none;
609
+ border-radius: var(--bc-r-md); overflow: hidden;
610
+ border: 1px solid var(--bc-border); background: var(--bc-subtle);
611
+ box-shadow: var(--bc-shadow-sm);
612
+ animation: bc-item-in 300ms var(--bc-ease) both;
613
+ }
614
+ .thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
615
+ .thumb .kind {
616
+ position: absolute; left: 4px; bottom: 4px;
617
+ display: inline-flex; align-items: center; gap: 3px;
618
+ padding: 2px 5px; border-radius: 5px;
619
+ background: rgba(10,12,16,.72); color: #fff; font-size: 9.5px; font-weight: 600; line-height: 1.3;
620
+ }
621
+ .thumb .drop {
622
+ position: absolute; top: 4px; right: 4px;
623
+ width: 20px; height: 20px; font-size: 11px; border-radius: 50%;
624
+ background: rgba(10,12,16,.7); color: #fff; border: none;
625
+ display: grid; place-items: center; cursor: pointer;
626
+ opacity: 0; transition: opacity 160ms, background 160ms;
627
+ }
628
+ .thumb:hover .drop, .thumb:focus-within .drop { opacity: 1; }
629
+ .thumb .drop:hover { background: var(--bc-danger); }
630
+ .thumb .veil {
631
+ position: absolute; inset: 0; display: grid; place-items: center; gap: 6px;
632
+ background: rgba(10,12,16,.62); color: #fff; font-size: 10.5px; font-weight: 600;
633
+ align-content: center;
634
+ }
635
+ .thumb .veil.err { background: color-mix(in srgb, var(--bc-danger) 82%, transparent); }
636
+ .spinner {
637
+ width: 17px; height: 17px; border-radius: 50%;
638
+ border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
639
+ animation: bc-spin 720ms linear infinite;
640
+ }
641
+ .bar { width: 46px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.3); overflow: hidden; }
642
+ .bar i { display: block; height: 100%; width: 0; background: #fff; transition: width 180ms linear; }
643
+ .veil button {
644
+ background: none; border: none; color: #fff; font-size: 14px; padding: 2px;
645
+ cursor: pointer; display: grid; place-items: center;
646
+ }
647
+
648
+ /* ---------- footer ---------- */
649
+ .foot {
650
+ flex: none;
651
+ display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
652
+ padding: 12px var(--bc-pad); border-top: 1px solid var(--bc-border);
653
+ background: var(--bc-bg);
654
+ }
655
+ .foot .spacer { flex: 1; }
656
+ .foot .note { flex-basis: 100%; order: -1; font-size: var(--bc-fs-xs); color: var(--bc-muted); }
657
+ .foot .note:empty { display: none; }
658
+ /* Quiet, but still legible: this sits in someone else's product, so it identifies
659
+ where the report goes without competing with their interface. Quiet is bought
660
+ with colour (--bc-brand-ink sits a step below body text) rather than with a
661
+ blanket opacity — the BUGCATCH half is only about 3px of cap height at this
662
+ size, and dimming it on top of that left it as a smudge in both themes. */
663
+ .powered {
664
+ flex: none; display: flex; align-items: center; justify-content: center; gap: 6px;
665
+ padding: 7px var(--bc-pad) 9px; font-size: 10.5px; color: var(--bc-faint);
666
+ background: var(--bc-subtle); border-top: 1px solid var(--bc-border);
667
+ }
668
+ .brand-credit { display: flex; align-items: center; transition: color 0.15s; border-radius: 4px; }
669
+ .bc-brand { height: 16px; width: auto; display: block; color: var(--bc-brand-ink); }
670
+ .brand-credit:hover .bc-brand { color: var(--bc-fg); }
671
+ button.ghost, button.primary {
672
+ display: inline-flex; align-items: center; justify-content: center; gap: 7px;
673
+ height: 38px; padding: 0 15px; font: inherit; font-size: 13px; font-weight: 620; line-height: 1;
674
+ border-radius: 999px; cursor: pointer; white-space: nowrap;
675
+ transition: transform 160ms var(--bc-ease), filter 160ms, background 160ms, border-color 160ms, color 160ms, box-shadow 160ms;
676
+ }
677
+ button.ghost { background: var(--bc-bg); border: 1px solid var(--bc-border); color: var(--bc-fg); }
678
+ button.ghost:hover:not(:disabled) { background: var(--bc-subtle); border-color: color-mix(in srgb, var(--bc-fg) 20%, var(--bc-border)); }
679
+ button.ghost svg, button.primary svg { font-size: 15px; }
680
+ button.primary {
681
+ padding: 0 18px;
682
+ background: var(--bc-accent); border: 1px solid var(--bc-accent); color: var(--bc-on-accent);
683
+ box-shadow: 0 4px 12px color-mix(in srgb, var(--bc-accent) 30%, transparent);
684
+ }
685
+ button.primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); }
686
+ button.primary:active:not(:disabled) { transform: none; }
687
+ button:disabled { opacity: .5; cursor: not-allowed; }
688
+ button.primary:disabled { box-shadow: none; }
689
+ button.primary .spinner { border-color: rgba(255,255,255,.4); border-top-color: #fff; width: 14px; height: 14px; }
690
+ button.quiet {
691
+ padding: 0 4px; height: 38px; font: inherit; font-size: 13px; font-weight: 600;
692
+ border: none; background: none; color: var(--bc-muted); cursor: pointer; border-radius: 8px;
693
+ }
694
+ button.quiet:hover { color: var(--bc-accent); }
695
+
696
+ /* ---------- your reports ---------- */
697
+ .history {
698
+ flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
699
+ padding: 8px 12px 14px;
700
+ }
701
+ /* On the conversation screen the inner thread does the scrolling, so this
702
+ wrapper must not — two nested scrollers means the composer drifts out of
703
+ reach exactly when someone reaches for it. */
704
+ .history.chatting {
705
+ overflow: hidden; display: flex; flex-direction: column; padding: 0;
706
+ }
707
+ .history .row {
708
+ display: flex; align-items: center; gap: 12px;
709
+ padding: 12px 10px; border-bottom: 1px solid var(--bc-border);
710
+ }
711
+ .history .row:last-child { border-bottom: 0; }
712
+ .history .who { flex: 1; min-width: 0; }
713
+ .history .ttl {
714
+ display: block; font-size: 13.5px; font-weight: 600; color: var(--bc-fg);
715
+ overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
716
+ }
717
+ .history .sub { display: block; margin-top: 3px; font-size: var(--bc-fs-xs); color: var(--bc-faint); }
718
+ .history .row-ico {
719
+ flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
720
+ background: var(--bc-subtle); color: var(--bc-muted); font-size: 16px;
721
+ }
722
+ .history .chev { flex: none; color: var(--bc-faint); font-size: 15px; transition: transform 160ms var(--bc-ease), color 160ms; }
723
+ .empty {
724
+ display: flex; flex-direction: column; align-items: center; gap: 10px;
725
+ padding: 40px 16px; text-align: center; font-size: var(--bc-fs-sm); color: var(--bc-muted);
726
+ }
727
+ .empty .empty-ico {
728
+ display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
729
+ background: var(--bc-accent-soft); color: var(--bc-accent); font-size: 20px;
730
+ }
731
+ .skel {
732
+ display: block; height: 12px; border-radius: 6px; margin: 6px 0;
733
+ background: linear-gradient(90deg, var(--bc-subtle) 25%, color-mix(in srgb, var(--bc-fg) 8%, var(--bc-subtle)) 50%, var(--bc-subtle) 75%);
734
+ background-size: 200% 100%; animation: bc-shimmer 1.4s linear infinite;
735
+ }
736
+ /* A history row is a button now — it opens the report — so the UA styling has
737
+ to go, and the hit area has to read as one. */
738
+ .history button.row {
739
+ width: 100%; background: none; border: 0; margin-bottom: 2px;
740
+ font: inherit; color: inherit; text-align: left; cursor: pointer;
741
+ border-radius: var(--bc-r-md); transition: background 160ms;
742
+ animation: bc-rise 260ms var(--bc-ease) both;
743
+ }
744
+ .history button.row:hover { background: var(--bc-subtle); }
745
+ .history button.row:hover .chev { transform: translateX(2px); color: var(--bc-accent); }
746
+ .history button.row:focus-visible { outline-offset: -2px; }
747
+
748
+ /* ---------- one report, and what happened to it ---------- */
749
+ .report-head {
750
+ flex: none;
751
+ display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
752
+ padding: 10px var(--bc-pad); border-bottom: 1px solid var(--bc-border);
753
+ background: var(--bc-bg);
754
+ }
755
+ .report-head .ttl { font-size: 13px; font-weight: 620; color: var(--bc-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
756
+ .report-head .sub { font-size: var(--bc-fs-xs); color: var(--bc-faint); }
757
+ .report-head .pill { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
758
+
759
+ /* The thread scrolls; the composer under it does not. Both live inside the
760
+ panel, which stops scrolling as a whole on this screen — a composer that
761
+ scrolls away is a composer people think isn't there. */
762
+ .thread {
763
+ flex: 1 1 auto; min-height: 140px;
764
+ display: flex; flex-direction: column; gap: 4px;
765
+ padding: 14px var(--bc-pad) 12px; overflow-y: auto; overscroll-behavior: contain;
766
+ }
767
+
768
+ /* The day a run of messages happened on, as a centred label on a rule. */
769
+ .day-sep {
770
+ display: flex; align-items: center; gap: 10px; margin: 10px 0 6px;
771
+ font-size: 11px; font-weight: 620; letter-spacing: .02em; color: var(--bc-faint);
772
+ }
773
+ .day-sep::before, .day-sep::after { content: ''; flex: 1; height: 1px; background: var(--bc-border); }
774
+
775
+ /* A status change is not a message and is not drawn as one: no side, no
776
+ bubble, no author. Centred and quiet, the way every chat marks the things
777
+ that happened rather than the things that were said. */
778
+ .sys {
779
+ align-self: center; max-width: 90%; text-align: center; margin: 6px 0;
780
+ padding: 4px 10px; border-radius: 999px; background: var(--bc-subtle);
781
+ font-size: var(--bc-fs-xs); line-height: 1.45; color: var(--bc-muted);
782
+ animation: bc-fade-in 240ms ease both;
783
+ }
784
+ .sys .dot {
785
+ display: inline-block; width: 6px; height: 6px; margin-right: 6px;
786
+ border-radius: 50%; background: var(--bc-muted); vertical-align: middle;
787
+ }
788
+ .sys .t { color: var(--bc-faint); }
789
+ .sys.k-status .dot { background: #4da3ff; }
790
+ .sys.k-severity .dot { background: #e8912a; }
791
+ .sys.k-assignment .dot { background: #8b7dff; }
792
+ .sys.k-filed .dot { background: var(--bc-faint); }
793
+
794
+ /* ---------- the conversation ----------
795
+
796
+ A status change and a message are different things and are drawn as such: a
797
+ change is a line on the rail above, a message is a bubble with a side. The
798
+ reporter's own words sit right and accented, the other side's left beside an
799
+ avatar that says who it is — the arrangement every chat has taught people to
800
+ read without a legend. */
801
+ .msg-row, .typing-row {
802
+ display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 8px;
803
+ max-width: 88%; margin-top: 10px;
804
+ animation: bc-rise 260ms var(--bc-ease) both;
805
+ }
806
+ .msg-row.cont { margin-top: 3px; }
807
+ .msg-row > *, .typing-row > * { grid-column: 2; }
808
+ /* Fixed rows, so the avatar lines up with the bubble whatever else the
809
+ message carries (a name above it, answers or a time below it). */
810
+ .msg-row > .msg-who, .typing-row > .msg-who { grid-row: 1; }
811
+ .msg-row > .bubble, .typing-row > .bubble { grid-row: 2; }
812
+ .msg-row > .quick { grid-row: 3; }
813
+ .msg-row > .msg-when { grid-row: 4; }
814
+ .msg-row > .av, .typing-row > .av { grid-column: 1; grid-row: 2; align-self: end; }
815
+ /* In a run of messages the avatar sits by the last bubble and the time under
816
+ it, the way a chat marks where one turn ends. */
817
+ .msg-row:has(+ .msg-row.cont) > .av { visibility: hidden; }
818
+ .msg-row:has(+ .msg-row.cont) > .msg-when { display: none; }
819
+ .msg-row.theirs, .typing-row { align-self: flex-start; }
820
+ .msg-row.mine { align-self: flex-end; grid-template-columns: minmax(0, 1fr); justify-items: end; }
821
+ .msg-row.mine > * { grid-column: 1; }
822
+ .av {
823
+ display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
824
+ font-size: 11px; font-weight: 700; letter-spacing: .02em;
825
+ background: color-mix(in srgb, var(--bc-fg) 10%, var(--bc-bg)); color: var(--bc-fg);
826
+ }
827
+ .av.bot {
828
+ background: linear-gradient(140deg, var(--bc-accent), color-mix(in srgb, var(--bc-accent) 60%, #fff));
829
+ color: var(--bc-on-accent); font-size: 14px;
830
+ }
831
+ .msg-who { font-size: var(--bc-fs-xs); font-weight: 620; color: var(--bc-muted); padding: 0 4px 4px; }
832
+ .msg-who.auto { color: var(--bc-accent); display: inline-flex; align-items: center; gap: 5px; }
833
+ .msg-who .tag {
834
+ padding: 1px 6px; border-radius: 999px; font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
835
+ text-transform: uppercase; background: var(--bc-accent-soft); color: var(--bc-accent);
836
+ }
837
+ .bubble {
838
+ justify-self: start; max-width: 100%;
839
+ padding: 9px 13px; border-radius: 18px; font-size: 13.5px; line-height: 1.5;
840
+ background: var(--bc-subtle); color: var(--bc-fg);
841
+ border: 1px solid var(--bc-border);
842
+ border-bottom-left-radius: 6px;
843
+ }
844
+ /* pre-wrap belongs to the text, not the box — on the box it would also render
845
+ the markup's own indentation. */
846
+ .msg-text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
847
+ .msg-row.mine .bubble {
848
+ justify-self: end;
849
+ background: var(--bc-accent); border-color: var(--bc-accent); color: var(--bc-on-accent);
850
+ border-bottom-left-radius: 18px; border-bottom-right-radius: 6px;
851
+ }
852
+ .msg-row.cont.theirs .bubble { border-top-left-radius: 6px; }
853
+ .msg-row.cont.mine .bubble { border-top-right-radius: 6px; }
854
+ /* A reply nobody wrote: tinted with the accent and labelled "Assistant" above
855
+ it, so it reads the same to someone who cannot see the colour at all. */
856
+ .msg-row.auto .bubble { background: var(--bc-accent-soft); border-color: var(--bc-accent-line); }
857
+ /* An attachment-only message has no text to wrap, so the bubble would be an
858
+ empty coloured box around it. */
859
+ .bubble.silent { padding: 0; background: none !important; border: 0; }
860
+ .msg-when { font-size: 10.5px; color: var(--bc-faint); padding: 4px 4px 0; }
861
+ .msg-row.pending { opacity: .6; }
862
+ .msg-row.pending .msg-when::after { content: ' · Sending…'; }
863
+ .msg-row.failed .bubble { border: 1px solid var(--bc-danger); }
864
+ .msg-row.failed .msg-when { color: var(--bc-danger); }
865
+ .msg-row.failed .msg-when::after { content: ' · Not sent'; }
866
+
867
+ /* The assistant, thinking. Three dots in a bubble where its next message will be. */
868
+ .typing { display: inline-flex; align-items: center; gap: 4px; padding: 12px 14px; justify-self: start; }
869
+ .typing i {
870
+ width: 7px; height: 7px; border-radius: 50%; background: var(--bc-accent); opacity: .45;
871
+ animation: bc-typing 1.2s ease-in-out infinite;
872
+ }
873
+ .typing i:nth-child(2) { animation-delay: .15s; }
874
+ .typing i:nth-child(3) { animation-delay: .3s; }
875
+ .typing-row .msg-when { padding-top: 4px; }
876
+
877
+ .att { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
878
+ .bubble.silent .att { margin-top: 0; }
879
+ .att img {
880
+ display: block; max-width: 100%; max-height: 190px; border-radius: var(--bc-r-md);
881
+ border: 1px solid var(--bc-border); object-fit: cover; cursor: zoom-in;
882
+ }
883
+ .att audio { width: 232px; max-width: 100%; height: 34px; }
884
+ .att video { max-width: 100%; max-height: 190px; border-radius: var(--bc-r-md); }
885
+ .att .file {
886
+ display: flex; align-items: center; gap: 8px; text-decoration: none;
887
+ padding: 8px 10px; border-radius: 10px; font-size: 12px;
888
+ background: var(--bc-elevated); border: 1px solid var(--bc-border); color: var(--bc-fg);
889
+ }
890
+ .att .file:hover { border-color: var(--bc-accent); }
891
+ .att .file .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
892
+ .att .file .sz { flex: none; color: var(--bc-faint); font-size: 11px; }
893
+
894
+ /* ---------- the assistant's live card ----------
895
+ A status header pinned between the report and the conversation: where the
896
+ investigation is, as words and as a stepper. It does not scroll with the
897
+ thread, because "is anything happening?" is the question on screen the
898
+ whole time. */
899
+ .assistant {
900
+ flex: none; position: relative; overflow: hidden;
901
+ margin: 10px 12px 0; padding: 12px 14px 12px;
902
+ border-radius: var(--bc-r-lg); border: 1px solid var(--bc-border);
903
+ background: var(--bc-subtle);
904
+ transition: background 400ms ease, border-color 400ms ease;
905
+ }
906
+ .assistant.analyzing, .assistant.confirming, .assistant.needs_info {
907
+ background: var(--bc-accent-soft); border-color: var(--bc-accent-line);
908
+ }
909
+ .assistant.resolved { background: color-mix(in srgb, var(--bc-ok) 9%, var(--bc-bg)); border-color: color-mix(in srgb, var(--bc-ok) 35%, var(--bc-border)); }
910
+ /* On a call: the call's own card is what they are watching. This one states
911
+ what is happening and stops moving — no spinner, no travelling bar. */
912
+ .assistant.calling { background: var(--bc-bg); }
913
+ .assistant.calling .as-progress i { transition: none; }
914
+ .as-body.entering { animation: bc-rise 360ms var(--bc-ease) both; }
915
+ .as-top { display: flex; gap: 11px; align-items: center; }
916
+ .as-orb {
917
+ flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
918
+ color: var(--bc-on-accent); font-size: 15px;
919
+ background: linear-gradient(140deg, var(--bc-accent), color-mix(in srgb, var(--bc-accent) 60%, #fff));
920
+ }
921
+ .assistant.resolved .as-orb { background: var(--bc-ok); }
922
+ .assistant.reviewing .as-orb { background: color-mix(in srgb, var(--bc-fg) 55%, var(--bc-bg)); }
923
+ .as-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: as-rot .8s linear infinite; }
924
+ @keyframes as-rot { to { transform: rotate(360deg); } }
925
+ .as-text { min-width: 0; flex: 1; }
926
+ .as-title { font-weight: 650; font-size: 13.5px; letter-spacing: -.01em; color: var(--bc-fg); }
927
+ .as-detail { font-size: 12px; line-height: 1.45; color: var(--bc-muted); margin-top: 2px; }
928
+ .as-progress {
929
+ height: 4px; margin: 12px 0 0; border-radius: 999px; overflow: hidden;
930
+ background: color-mix(in srgb, var(--bc-fg) 9%, transparent);
931
+ }
932
+ .as-progress i {
933
+ display: block; height: 100%; border-radius: inherit; background: var(--bc-accent);
934
+ transition: width 700ms var(--bc-ease);
935
+ }
936
+ .assistant.resolved .as-progress i { background: var(--bc-ok); }
937
+ .assistant.analyzing .as-progress i {
938
+ background: linear-gradient(90deg, var(--bc-accent) 0%, color-mix(in srgb, var(--bc-accent) 45%, #fff) 50%, var(--bc-accent) 100%);
939
+ background-size: 200% 100%; animation: bc-shimmer 1.6s linear infinite;
940
+ }
941
+ .as-steps {
942
+ list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
943
+ margin: 8px 0 0; padding: 0; font-size: 10.5px; color: var(--bc-faint);
944
+ }
945
+ .as-steps li { display: flex; align-items: center; gap: 5px; min-width: 0; white-space: nowrap; }
946
+ .as-steps li .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
947
+ .as-steps li .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
948
+ .as-steps li.done { color: var(--bc-muted); }
949
+ .as-steps li.done .dot { background: var(--bc-accent); border-color: var(--bc-accent); }
950
+ .assistant.resolved .as-steps li.done .dot { background: var(--bc-ok); border-color: var(--bc-ok); }
951
+ .as-steps li.active { color: var(--bc-fg); font-weight: 650; }
952
+ .as-steps li.active .dot { border-color: var(--bc-accent); background: var(--bc-bg); animation: as-pulse 1.2s ease-in-out infinite; }
953
+ @keyframes as-pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--bc-accent) 25%, transparent); } }
954
+ @media (prefers-reduced-motion: reduce) { .as-spin, .as-steps li.active .dot, .assistant.analyzing .as-progress i, .typing i { animation: none; } }
955
+
956
+ /* Quick answers under the confirm question — only on the latest message. */
957
+ .msg-row .quick { display: none; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
958
+ .msg-row:last-child .quick { display: flex; }
959
+ .quick button {
960
+ display: inline-flex; align-items: center; gap: 6px;
961
+ font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px; cursor: pointer;
962
+ border: 1px solid var(--bc-accent); background: var(--bc-bg); color: var(--bc-accent);
963
+ transition: background 160ms, color 160ms, transform 160ms var(--bc-ease);
964
+ animation: bc-item-in 300ms var(--bc-ease) both;
965
+ }
966
+ .quick button:first-child { background: var(--bc-accent); color: var(--bc-on-accent); }
967
+ .quick button:nth-child(2) { animation-delay: 60ms; }
968
+ .quick button svg { font-size: 13px; }
969
+ .quick button:hover { transform: translateY(-1px); background: var(--bc-accent-soft); }
970
+ .quick button:first-child:hover { background: var(--bc-accent); filter: brightness(1.07); }
971
+
972
+ /* ---------- the composer ---------- */
973
+ .composer {
974
+ flex: none; position: relative;
975
+ padding: 10px 12px max(12px, env(safe-area-inset-bottom, 0px));
976
+ /* The panel's own background, not --bc-elevated: the two are the same white
977
+ in light mode but differ in dark, where a raised composer reads as a band
978
+ laid over the panel rather than the foot of it. */
979
+ background: var(--bc-bg);
980
+ border-top: 1px solid var(--bc-border);
981
+ }
982
+ /* One rounded field holding the tools, the text and the send button — the
983
+ shape every chat box has, so nobody has to look for where to type. */
984
+ .composer .row {
985
+ display: flex; align-items: flex-end; gap: 4px;
986
+ padding: 5px; border-radius: 22px;
987
+ background: var(--bc-subtle); border: 1px solid var(--bc-border);
988
+ transition: border-color 160ms, box-shadow 160ms;
989
+ }
990
+ .composer .row:focus-within { border-color: var(--bc-accent); box-shadow: var(--bc-ring); }
991
+ .composer textarea {
992
+ flex: 1; min-width: 0; min-height: 34px; max-height: 120px; resize: none; padding: 7px 6px;
993
+ font: inherit; font-size: 13.5px; line-height: 1.45;
994
+ color: var(--bc-fg); background: transparent; border: 0; border-radius: 0;
995
+ }
996
+ .composer textarea:hover, .composer textarea:focus { border: 0; box-shadow: none; outline: none; }
997
+ .composer .tools { display: flex; gap: 0; grid-template-columns: none; }
998
+ .composer .tool {
999
+ width: 34px; height: 34px; min-height: 0; padding: 0; display: grid; place-items: center; cursor: pointer;
1000
+ border-radius: 50%; border: 0; background: none; font-size: 17px;
1001
+ color: var(--bc-muted);
1002
+ }
1003
+ .composer .tool svg { font-size: 17px; }
1004
+ .composer .tool:hover:not(:disabled) { background: color-mix(in srgb, var(--bc-fg) 8%, transparent); color: var(--bc-fg); border: 0; transform: none; }
1005
+ .composer .tool:hover:not(:disabled) svg { color: var(--bc-fg); }
1006
+ .composer .tool:disabled { opacity: .4; cursor: default; }
1007
+ .composer .tool.recording { color: var(--bc-danger); background: color-mix(in srgb, var(--bc-danger) 12%, transparent); }
1008
+ .composer .tool.recording svg { color: var(--bc-danger); }
1009
+ .composer .send {
1010
+ width: 34px; height: 34px; flex: none; border-radius: 50%; cursor: pointer; font-size: 16px;
1011
+ background: var(--bc-accent); border: 0; color: var(--bc-on-accent);
1012
+ display: grid; place-items: center;
1013
+ transition: transform 160ms var(--bc-ease), opacity 160ms, filter 160ms;
1014
+ }
1015
+ .composer .send:hover:not(:disabled) { filter: brightness(1.08); transform: scale(1.05); }
1016
+ .composer .send:disabled { opacity: .35; cursor: default; background: var(--bc-faint); }
1017
+ .composer .staged { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 8px; }
1018
+ .composer .chip {
1019
+ display: flex; align-items: center; gap: 6px; max-width: 200px;
1020
+ padding: 5px 7px 5px 10px; border-radius: 999px; font-size: var(--bc-fs-xs);
1021
+ background: var(--bc-subtle); border: 1px solid var(--bc-border); color: var(--bc-muted);
1022
+ animation: bc-item-in 240ms var(--bc-ease) both;
1023
+ }
1024
+ .composer .chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bc-fg); }
1025
+ .composer .chip button {
1026
+ flex: none; width: 18px; height: 18px; display: grid; place-items: center;
1027
+ border: 0; border-radius: 50%; background: none; color: var(--bc-faint); cursor: pointer;
1028
+ }
1029
+ .composer .chip button:hover { color: var(--bc-danger); }
1030
+ .composer .chip.uploading { border-style: dashed; }
1031
+ .composer .note { padding: 6px 6px 0; font-size: var(--bc-fs-xs); color: var(--bc-muted); }
1032
+ .composer .note.err { color: var(--bc-danger); }
1033
+ .reccount { font-variant-numeric: tabular-nums; }
1034
+
1035
+ /* Status carries the only colour in this list, so it is the thing the eye
1036
+ lands on — which is what someone opening this screen came to check. */
1037
+ .pill {
1038
+ flex: none; display: inline-flex; align-items: center; gap: 5px;
1039
+ font-size: 11px; font-weight: 650;
1040
+ padding: 3px 9px; border-radius: 999px;
1041
+ color: var(--bc-muted); background: var(--bc-subtle);
1042
+ }
1043
+ .pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
1044
+ .pill.open { color: #c2410c; background: color-mix(in srgb, #f59e0b 14%, var(--bc-bg)); }
1045
+ .pill.in_progress { color: #1d6fd1; background: color-mix(in srgb, #3b82f6 14%, var(--bc-bg)); }
1046
+ .pill.resolved { color: #0f8a5a; background: color-mix(in srgb, #10b981 14%, var(--bc-bg)); }
1047
+ .pill.closed { color: var(--bc-muted); }
1048
+ :host(.bc-dark) .pill.open { color: #fbbf24; }
1049
+ :host(.bc-dark) .pill.in_progress { color: #7cb8ff; }
1050
+ :host(.bc-dark) .pill.resolved { color: #4ade9a; }
1051
+ @media (prefers-color-scheme: dark) {
1052
+ :host(.bc-auto) .pill.open { color: #fbbf24; }
1053
+ :host(.bc-auto) .pill.in_progress { color: #7cb8ff; }
1054
+ :host(.bc-auto) .pill.resolved { color: #4ade9a; }
1055
+ }
1056
+
1057
+ /* ---------- does the fix work ---------- */
1058
+ .fix-verification {
1059
+ flex: none; margin: 10px 12px 0; padding: 12px 14px;
1060
+ border-radius: var(--bc-r-lg); border: 1px solid color-mix(in srgb, var(--bc-ok) 35%, var(--bc-border));
1061
+ background: color-mix(in srgb, var(--bc-ok) 8%, var(--bc-bg));
1062
+ font-size: var(--bc-fs-sm); color: var(--bc-fg);
1063
+ animation: bc-rise 280ms var(--bc-ease) both;
1064
+ }
1065
+ .fix-verification p { margin: 0 0 8px; font-weight: 620; }
1066
+ .fix-verification textarea { min-height: 56px; margin-bottom: 8px; font-size: 13px; background: var(--bc-bg); }
1067
+ .fix-verification button {
1068
+ padding: 7px 13px; font: inherit; font-size: 12.5px; font-weight: 620; border-radius: 999px; cursor: pointer;
1069
+ border: 1px solid var(--bc-border); background: var(--bc-bg); color: var(--bc-fg);
1070
+ }
1071
+ .fix-verification button[data-result="CONFIRMED"] { background: var(--bc-ok); border-color: var(--bc-ok); color: #fff; }
1072
+ .fix-verification .feedback-status { margin: 6px 0 0; font-weight: 450; color: var(--bc-danger); font-size: var(--bc-fs-xs); }
1073
+ .fix-verification .feedback-status:empty { display: none; }
1074
+
1075
+ /* A call in progress, in place of the form.
1076
+ ---------------------------------------------------------------------------
1077
+ Deliberately not styled as a chat. Nothing arrives here to read — the
1078
+ conversation is happening out loud — so this is a state, a line of
1079
+ reassurance about the report, and a way to hang up. */
1080
+ .call { display: flex; flex-direction: column; padding: 26px 0 0; animation: bc-fade-in 240ms ease both; }
1081
+ .call-head, .call-note { padding: 0 var(--bc-pad); }
1082
+ .call-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
1083
+ .call-head strong { font-size: 15.5px; font-weight: 680; letter-spacing: -.01em; }
1084
+ .call-dot {
1085
+ width: 9px; height: 9px; border-radius: 50%; background: var(--bc-accent);
1086
+ animation: bc-call-pulse 1.6s ease-in-out infinite;
1087
+ }
1088
+ .call-dot.off { background: var(--bc-faint); animation: none; }
1089
+ @keyframes bc-call-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
1090
+ /* Said while it is still ringing, because that is when somebody is deciding
1091
+ whether it is worth waiting. */
1092
+ .call-note { margin: 0 0 18px; font-size: 13px; color: var(--bc-muted); line-height: 1.55; }
1093
+
1094
+ /* ---------- the same call, on top of the report it is about ---------- */
1095
+ /* A bar rather than its own screen, unlike the one the composer opens. The
1096
+ thread underneath is exactly what both people are talking about, so taking it
1097
+ off screen would be taking away the only shared reference. */
1098
+ .livecall {
1099
+ flex: none;
1100
+ display: flex; align-items: center; gap: 9px;
1101
+ margin: 10px 12px 0; padding: 9px 11px;
1102
+ border: 1px solid var(--bc-accent-line); border-radius: var(--bc-r-md);
1103
+ background: var(--bc-accent-soft); font-size: var(--bc-fs-sm); color: var(--bc-fg);
1104
+ animation: bc-rise 240ms var(--bc-ease) both;
1105
+ }
1106
+ .livecall .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1107
+ .livecall .call-kept { font-size: 11px; opacity: .75; }
1108
+ .livecall .secs { font-variant-numeric: tabular-nums; color: var(--bc-muted); }
1109
+ .livecall .act {
1110
+ padding: 5px 11px; border-radius: 999px; border: 1px solid var(--bc-border);
1111
+ background: var(--bc-bg); color: var(--bc-fg);
1112
+ font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
1113
+ }
1114
+ .livecall .act:hover { background: var(--bc-subtle); }
1115
+ .livecall .act.danger { border-color: transparent; background: var(--bc-danger); color: #fff; }
1116
+ .livecall.over { color: var(--bc-muted); background: var(--bc-subtle); border-color: var(--bc-border); }
1117
+ .call-note code { font-size: 11px; }
1118
+ @media (prefers-reduced-motion: reduce) { .call-dot { animation: none; } }
1119
+
1120
+ /* div.done, not .done: the assistant's stepper marks finished steps li.done,
1121
+ and this screen's padding was landing on every one of them. */
1122
+ div.done { padding: 44px 26px 44px; text-align: center; animation: bc-fade-in 240ms ease both; }
1123
+ .done .tick {
1124
+ width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%;
1125
+ display: grid; place-items: center; font-size: 26px;
1126
+ background: color-mix(in srgb, var(--bc-ok) 14%, transparent); color: var(--bc-ok);
1127
+ box-shadow: 0 0 0 8px color-mix(in srgb, var(--bc-ok) 6%, transparent);
1128
+ animation: bc-pop 420ms var(--bc-ease) both;
1129
+ }
1130
+ .done h3 { margin: 0 0 6px; font-size: 17px; font-weight: 680; letter-spacing: -.015em; }
1131
+ .done p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--bc-muted); }
1132
+ .done code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 1px 5px; border-radius: 5px; background: var(--bc-subtle); color: var(--bc-fg); }
1133
+ /* The likely wait. Set apart from the reference line above it by a rule rather
1134
+ than by weight: one is bookkeeping and the other is the answer to the
1135
+ question the reporter actually has, and they should not read as one
1136
+ paragraph. */
1137
+ .done .eta {
1138
+ margin: 14px auto 0;
1139
+ padding-top: 12px;
1140
+ border-top: 1px solid var(--bc-border);
1141
+ max-width: 30ch;
1142
+ line-height: 1.5;
1143
+ }
1144
+ .done .eta strong { color: var(--bc-fg); font-weight: 620; }
1145
+ /* The same figure on the report the reporter came back to. Sits under the
1146
+ status pill in the header block, muted — it is context, not the headline the
1147
+ status is. */
1148
+ .report-head .eta-line {
1149
+ grid-column: 1 / -1;
1150
+ font-size: var(--bc-fs-xs);
1151
+ color: var(--bc-muted);
1152
+ margin-top: 2px;
1153
+ }
1154
+
1155
+ /* ---------- recording bar ---------- */
1156
+ .recbar {
1157
+ position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
1158
+ z-index: 2147483002;
1159
+ display: flex; align-items: center; gap: 12px;
1160
+ padding: 8px 8px 8px 16px; border-radius: 999px;
1161
+ background: var(--bc-elevated); color: var(--bc-fg);
1162
+ border: 1px solid var(--bc-border); box-shadow: var(--bc-shadow);
1163
+ animation: bc-item-in 300ms var(--bc-ease) both;
1164
+ }
1165
+ .recbar .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bc-danger); animation: bc-pulse 1.4s ease-in-out infinite; }
1166
+ .recbar .time { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 650; min-width: 38px; }
1167
+ .recbar .hint { font-size: 12px; color: var(--bc-muted); }
1168
+ .recbar button { height: 34px; padding: 0 14px; font-size: 12.5px; font-weight: 620; border-radius: 999px; cursor: pointer; }
1169
+ .recbar .stop { background: var(--bc-danger); border: 1px solid var(--bc-danger); color: #fff; }
1170
+ .recbar .stop:hover { filter: brightness(1.08); }
1171
+
1172
+ /* ---------- phones ----------------------------------------------------------
1173
+ This widget runs inside a shadow root on somebody else's site, so its own
1174
+ stylesheet is the whole story: the host page cannot correct any of this, and
1175
+ anything that goes wrong here goes wrong on their site, in front of their
1176
+ visitor, at the moment that visitor is already annoyed enough to file a bug.
1177
+ -------------------------------------------------------------------------- */
1178
+
1179
+ /* 100vh on a phone is the viewport with the browser chrome hidden, so the
1180
+ panel could be taller than the space it actually has and put "Send report"
1181
+ under the address bar. */
1182
+ @supports (height: 100dvh) {
1183
+ .panel { max-height: calc(100dvh - var(--bc-dock-h, 84px) - 52px); }
1184
+ }
1185
+
1186
+ /* Short desktop windows: the chat height gives way to the space there is. */
1187
+ @media (max-height: 820px) { .panel.is-chat { height: calc(100vh - var(--bc-dock-h, 84px) - 52px); } }
1188
+
1189
+ /* A phone gets the whole screen: a sheet that slides up from the bottom, with
1190
+ the notch and the home indicator kept clear. The dock steps aside while it
1191
+ is open — the sheet has its own close button, and a launcher floating over
1192
+ the send button would be in the way of the one thing that matters. */
1193
+ @media (max-width: 480px) {
1194
+ .scrim { background: rgba(10,12,16,.4); }
1195
+ .panel, .scrim.at-right .panel, .scrim.at-left .panel, .scrim.at-bottom .panel, .scrim.at-top .panel {
1196
+ inset: 0; width: 100%; max-width: none; height: 100%; max-height: none;
1197
+ border-radius: 0; border: 0;
1198
+ animation: bc-sheet-in 380ms var(--bc-ease) both;
1199
+ }
1200
+ @supports (height: 100dvh) { .panel { height: 100dvh; max-height: none; } }
1201
+ .panel.is-chat { height: 100%; }
1202
+ .scrim.closing .panel { animation: bc-sheet-out 200ms ease both; }
1203
+ .head { padding-top: max(14px, env(safe-area-inset-top, 0px)); padding-left: max(var(--bc-pad), env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
1204
+ .foot, .powered { padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
1205
+ .foot + .powered { padding-bottom: max(9px, env(safe-area-inset-bottom, 0px)); }
1206
+ .foot:has(+ .powered) { padding-bottom: 12px; }
1207
+ .recbar .hint { display: none; }
1208
+ .msg-row, .typing-row { max-width: 92%; }
1209
+ }
1210
+
1211
+ @media (pointer: coarse) {
1212
+ /* iOS zooms the whole page when a field it focuses is under 16px, and does
1213
+ not zoom back out. On the host's site that is not the widget's page to
1214
+ zoom — the visitor is left on a magnified checkout wondering what they
1215
+ touched. !important because this is a property of the device, not a
1216
+ preference about type. */
1217
+ input, textarea, select { font-size: 16px !important; }
1218
+
1219
+ /* 44px is the floor a thumb hits reliably. Every control in this form was
1220
+ under it, on the one surface in the product designed for someone who is
1221
+ not an operator and gets no second attempt. */
1222
+ .seg button { min-height: 44px; }
1223
+ .tool { min-height: 56px; }
1224
+ button.primary, button.ghost { height: 44px; }
1225
+ .composer .send, .composer .tool { width: 40px; height: 40px; min-height: 0; }
1226
+ textarea { min-height: 104px; }
1227
+ .composer textarea { min-height: 40px; }
1228
+
1229
+ /* The close button and the thumbnails' remove buttons are small glyphs whose
1230
+ boxes cannot grow without moving what is beside them, so each keeps its
1231
+ size and gets an invisible target drawn around it instead. The theme
1232
+ switch gets the same in the launcher's own sheet (widget.js). */
1233
+ .head .icon-btn, .thumb .drop, .brand-credit { position: relative; }
1234
+ .thumb .drop { position: absolute; opacity: 1; }
1235
+ .head .icon-btn::after, .thumb .drop::after, .brand-credit::after {
1236
+ content: '';
1237
+ position: absolute;
1238
+ inset: -8px;
1239
+ }
1240
+ }
1241
+
1242
+ /* Hover is a lie on a touchscreen: it latches on tap and stays. */
1243
+ @media (hover: none) {
1244
+ .tool:hover:not(:disabled) { transform: none; }
1245
+ }
1246
+ `;function ot({title:t,sub:e,id:n="",back:o=!1}){return`
1247
+ <div class="head">
1248
+ ${o?`<button class="icon-btn back" type="button" data-act="back" aria-label="Back to your reports">${ka}</button>`:""}
1249
+ <div class="mark" aria-hidden="true">${we}</div>
1250
+ <div class="titles">
1251
+ <h2${n?` id="${n}"`:""}>${E(t)}</h2>
1252
+ <p>${E(e)}</p>
1253
+ </div>
1254
+ <button class="icon-btn" type="button" data-act="close" aria-label="Close">${fe}</button>
1255
+ </div>`}function at(t,e){return`<div class="empty"><span class="empty-ico" aria-hidden="true">${e}</span>${E(t)}</div>`}function Ia(t){return Array.from({length:t},()=>`
1256
+ <div class="row" aria-hidden="true">
1257
+ <span class="row-ico"></span>
1258
+ <span class="who"><span class="skel" style="width:70%"></span><span class="skel" style="width:40%;height:9px"></span></span>
1259
+ </div>`).join("")+'<span class="sr-only">Loading…</span>'}function La(){return`
1260
+ <div aria-hidden="true" style="display:flex;flex-direction:column;gap:10px;padding-top:6px">
1261
+ <span class="skel" style="width:42%;height:34px;border-radius:16px;align-self:center"></span>
1262
+ <span class="skel" style="width:66%;height:52px;border-radius:18px"></span>
1263
+ <span class="skel" style="width:48%;height:38px;border-radius:18px;align-self:flex-end"></span>
1264
+ </div>
1265
+ <span class="sr-only">Loading…</span>`}function Aa(t){const e=String(t).trim().split(/\s+/).filter(Boolean);return e.length?(e[0][0]+(e.length>1?e[e.length-1][0]:"")).toUpperCase():"?"}function ve(t){const e=new Date(t);return Number.isFinite(e.getTime())?`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`:null}function Ma(t){const e=new Date(t),n=new Date,o=new Date(n.getFullYear(),n.getMonth(),n.getDate()-1);if(ve(e)===ve(n))return"Today";if(ve(e)===ve(o))return"Yesterday";try{return e.toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short",...e.getFullYear()!==n.getFullYear()?{year:"numeric"}:{}})}catch{return je(t)}}function on(t){const e=new Date(t);if(!Number.isFinite(e.getTime()))return"";try{return e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}catch{return""}}function an(t){return t.scrollHeight-t.scrollTop-t.clientHeight<40}function xe(t,{smooth:e=!1}={}){const n=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;e&&!n&&t.scrollTo?t.scrollTo({top:t.scrollHeight,behavior:"smooth"}):t.scrollTop=t.scrollHeight}function rt(t){return{OPEN:"Open",IN_PROGRESS:"In progress",RESOLVED:"Fixed",CLOSED:"Closed"}[t]||String(t||"").toLowerCase()}function je(t){const e=new Date(t).getTime();if(!Number.isFinite(e))return"";const n=Math.floor((Date.now()-e)/864e5);if(n<=0)return"today";if(n===1)return"yesterday";if(n<30)return`${n} days ago`;const o=Math.floor(n/30);return o===1?"a month ago":`${o} months ago`}function E(t){return String(t).replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}const Ba=7*24*60*60*1e3;let Oe;function Ra(){return Oe||(Oe=new Promise((t,e)=>{const n=indexedDB.open("bugcatch-drafts",1);n.onupgradeneeded=()=>n.result.createObjectStore("drafts"),n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error),n.onblocked=()=>e(new Error("Draft storage is blocked."))}).catch(t=>{throw Oe=null,t})),Oe}function ja(t,e){var n,o;return JSON.stringify([t.apiBase,t.projectId,e||((n=t.user)==null?void 0:n.email)||((o=t.user)==null?void 0:o.id)||"anonymous"])}async function ze(t,e){const n=await Ra();return new Promise((o,a)=>{const r=n.transaction("drafts",e===void 0?"readonly":"readwrite"),i=r.objectStore("drafts"),s=e===void 0?i.get(t):e===null?i.delete(t):i.put({...e,savedAt:Date.now()},t);r.oncomplete=()=>o(s.result),r.onerror=()=>a(r.error),r.onabort=()=>a(r.error||new Error("Draft was not saved."))})}async function Oa(t){const e=await ze(t);return e&&Date.now()-e.savedAt>Ba?(await ze(t,null),null):e||null}const rn=[{value:"LOW",label:"Low"},{value:"MEDIUM",label:"Medium"},{value:"HIGH",label:"High"},{value:"CRITICAL",label:"Critical"}],sn="MEDIUM";function za(t){const e=t.attachments!==!1,n=e&&no(),o=e&&to();return`
1266
+ <div class="compose">
1267
+ <div class="field">
1268
+ <label for="bc-title">What went wrong?</label>
1269
+ <input id="bc-title" type="text" placeholder="e.g. The checkout button does nothing" autocomplete="off"
1270
+ aria-describedby="bc-title-err" />
1271
+ <p class="field-err" id="bc-title-err" hidden></p>
1272
+ </div>
1273
+ <div class="field">
1274
+ <label for="bc-desc">Anything else that helps <span class="opt">(optional)</span></label>
1275
+ <textarea id="bc-desc" placeholder="What you were doing, what you expected, what happened instead."></textarea>
1276
+ </div>
1277
+ <!-- Drawn only when this project asks for an identifier and the report
1278
+ does not already carry one. Between the description and the
1279
+ severity because that is where it belongs in the reading order:
1280
+ it is a question about what they just typed. -->
1281
+ <div class="refs" hidden></div>
1282
+ <div class="field">
1283
+ <label id="bc-prio-l">How much is it getting in your way?</label>
1284
+ <div class="seg" role="group" aria-labelledby="bc-prio-l">
1285
+ ${rn.map(a=>`
1286
+ <button type="button" data-prio="${a.value}" aria-pressed="${a.value===sn}">${a.label}</button>
1287
+ `).join("")}
1288
+ </div>
1289
+ </div>
1290
+ ${e?`
1291
+ <div class="field">
1292
+ <div class="field-head">
1293
+ <label id="bc-att-l">Show us <span class="opt">(optional)</span></label>
1294
+ <span class="count" aria-live="polite"></span>
1295
+ </div>
1296
+ <div class="tools" role="group" aria-labelledby="bc-att-l">
1297
+ ${n?`<button class="tool" type="button" data-act="shot">${wa}Screenshot</button>`:""}
1298
+ ${o?`<button class="tool" type="button" data-act="rec">${va}Record screen</button>`:""}
1299
+ <button class="tool" type="button" data-act="file">${en}Upload file</button>
1300
+ </div>
1301
+ <div class="thumbs"></div>
1302
+ <input type="file" accept="${$e.join(",")}" multiple hidden />
1303
+ </div>`:""}
1304
+ </div>`}function Qa(t){var he,le,de,z;const{client:e,cfg:n,root:o,host:a,dock:r,scrim:i,$:s,say:c,titleInput:l,descInput:f,compose:d,sendBtn:u,note:g}=t,y=s(".thumbs"),m=i.querySelector("input[type=file]"),w=[];let p=sn,h=null;const b=document.createElement("div");b.setAttribute("role","status"),b.className="note",d.prepend(b);const T=ja(n,(he=e.signedInAs())==null?void 0:he.email);let C=n.drafts===!1,S=!1,x=Promise.resolve(),v;function k(){if(clearTimeout(v),!C||S||n.drafts===!1)return x;const $=l.value||f.value||w.length?{title:l.value,description:f.value,priority:p,items:w.map(({blob:A,mime:q,kind:Q})=>({blob:A,mime:q,kind:Q}))}:null;return x=x.catch(()=>{}).then(()=>ze(T,$)).then(()=>{b.textContent=$?"Draft saved on this device":""}).catch(()=>{b.textContent="Draft could not be saved. Keep this tab open."}),x}function O(){clearTimeout(v),v=setTimeout(k,250)}d.addEventListener("input",O),d.addEventListener("change",O);const F=()=>{k()};window.addEventListener("pagehide",F);function Z(){w.filter($=>$.status==="failed").forEach(ne)}window.addEventListener("online",Z),n.drafts!==!1&&(d.inert=!0,Oa(T).then($=>{t.closed||!$||(b.innerHTML='<span>You have an unfinished report on this device.</span> <button type="button" data-resume>Resume report</button> <button type="button" data-discard>Discard</button>',b.querySelector("[data-resume]").onclick=()=>{l.value=$.title||"",f.value=$.description||"",p=rn.some(A=>A.value===$.priority)?$.priority:"MEDIUM",i.querySelectorAll("[data-prio]").forEach(A=>A.setAttribute("aria-pressed",String(A.dataset.prio===p)));for(const A of($.items||[]).slice(0,n.maxAttachments??5))G(A);C=!0,k()},b.querySelector("[data-discard]").onclick=()=>{C=!0,k()})}).catch(()=>{b.textContent="Draft storage is unavailable. Keep this tab open."}).finally(()=>{d.inert=!1,b.querySelector("[data-resume]")||(C=!0)})),t.onDestroy(()=>{var $;k(),clearTimeout(v),window.removeEventListener("pagehide",F),window.removeEventListener("online",Z),h==null||h.cancel(),w.forEach(A=>A.previewUrl&&URL.revokeObjectURL(A.previewUrl)),($=o.querySelector(".recbar"))==null||$.remove()}),i.querySelectorAll("[data-prio]").forEach($=>{$.addEventListener("click",()=>{p=$.dataset.prio,O(),i.querySelectorAll("[data-prio]").forEach(A=>{A.setAttribute("aria-pressed",String(A===$))})})});const Y=s("#bc-title-err");function L($){Y.hidden=!$,Y.innerHTML=$?`${re}<span>${E($)}</span>`:"",l.classList.toggle("invalid",!!$),l.setAttribute("aria-invalid",String(!!$))}l.addEventListener("input",()=>{l.value.trim()&&L("")});function j(){const $=w.some(Q=>Q.status==="uploading");u.disabled=t.sending||$||w.some(Q=>Q.status==="failed"),g.textContent=$?"Waiting for the upload to finish…":w.some(Q=>Q.status==="failed")?"Retry or remove failed attachments before sending.":"";const A=n.maxAttachments??5;i.querySelectorAll(".tool").forEach(Q=>{Q.disabled=t.sending||w.length>=A});const q=s(".field-head .count");q&&(q.textContent=w.length?`${w.length} of ${A}`:"")}t.refreshSendState=j;function R($){var ee;const A=$.el,q=$.kind==="VIDEO"?"Video":"Shot",Q=$.kind==="VIDEO"?`<video src="${$.previewUrl}" muted playsinline preload="metadata"></video>`:`<img src="${$.previewUrl}" alt="" />`;let _="";$.status==="uploading"?_=`<div class="veil"><div class="spinner"></div><div class="bar"><i style="width:${Math.round($.progress*100)}%"></i></div></div>`:$.status==="failed"&&(_=`<div class="veil err"><button type="button" data-act="retry" aria-label="Retry upload">${Sa}</button>Failed</div>`),A.innerHTML=`
1305
+ ${Q}
1306
+ <span class="kind">${q} · ${pe($.size)}</span>
1307
+ <button class="drop" type="button" data-act="drop" aria-label="Remove ${q.toLowerCase()}">${fe}</button>
1308
+ ${_}`,A.querySelector('[data-act="drop"]').addEventListener("click",()=>N($)),(ee=A.querySelector('[data-act="retry"]'))==null||ee.addEventListener("click",()=>ne($))}function N($){const A=w.indexOf($);A>=0&&w.splice(A,1),$.previewUrl&&URL.revokeObjectURL($.previewUrl),$.el.remove(),k(),j()}async function ne($){$.status="uploading",$.progress=0,R($),j();try{const{storageKey:A,mime:q}=await e.uploadAttachment($.blob,$.mime,Q=>{$.progress=Q;const _=$.el.querySelector(".bar i");_&&(_.style.width=`${Math.round(Q*100)}%`)});$.storageKey=A,$.mime=q,$.status="ready"}catch(A){$.status="failed",c(A.message.replace("[BugCatch] ",""))}R($),j()}function G({blob:$,mime:A,kind:q}){const Q=n.maxAttachmentBytes??26214400;if($.size>Q){c(`That file is ${pe($.size)} — the limit is ${pe(Q)}.`);return}const _=Ce(A||$.type,$e);if(!_){c("Only PNG, JPEG, WebP, WebM and MP4 files can be attached to a report.");return}const ee={blob:$,kind:q,mime:_,size:$.size,previewUrl:URL.createObjectURL($),status:"uploading",progress:0,storageKey:null,el:document.createElement("div")};ee.el.className="thumb",w.push(ee),y.appendChild(ee.el),c(""),k(),ne(ee)}async function ce($){a.style.opacity="0",a.style.pointerEvents="none",await new Promise(A=>requestAnimationFrame(()=>requestAnimationFrame(A)));try{return await $()}finally{a.style.opacity="",a.style.pointerEvents=""}}(le=i.querySelector('[data-act="shot"]'))==null||le.addEventListener("click",async()=>{try{const $=await ce(oo);G($)}catch($){($==null?void 0:$.name)!=="NotAllowedError"&&c(`Screenshot failed: ${$.message}`)}}),(de=i.querySelector('[data-act="file"]'))==null||de.addEventListener("click",()=>m.click()),m==null||m.addEventListener("change",()=>{const $=(n.maxAttachments??5)-w.length;[...m.files].slice(0,Math.max($,0)).forEach(A=>{G({blob:A,mime:A.type,kind:A.type.startsWith("video/")?"VIDEO":"SCREENSHOT"})}),m.value=""}),(z=i.querySelector('[data-act="rec"]'))==null||z.addEventListener("click",async()=>{const $=n.maxRecordingMs??12e4;let A;try{h=await ao({maxMs:$,onTick:q=>{A&&(A.querySelector(".time").textContent=Te(q))},onAutoStop:()=>{h&&W({keep:!0})}})}catch(q){(q==null?void 0:q.name)!=="NotAllowedError"&&c(`Recording failed: ${q.message}`);return}i.style.display="none",r.hidden=!0,A=document.createElement("div"),A.className="recbar",A.innerHTML=`
1309
+ <span class="dot"></span>
1310
+ <span class="time">0:00</span>
1311
+ <span class="hint">Recording — up to ${Te(Math.round($/1e3))}</span>
1312
+ <button class="stop" type="button">Stop</button>
1313
+ <button class="ghost" type="button">Discard</button>`,A.querySelector(".stop").addEventListener("click",()=>W({keep:!0})),A.querySelector(".ghost").addEventListener("click",()=>W({keep:!1})),o.appendChild(A),A.querySelector(".stop").focus()});async function W({keep:$}){var q;const A=h;if(A){if(h=null,(q=o.querySelector(".recbar"))==null||q.remove(),i.style.display="",r.hidden=!1,!$){A.cancel(),l.focus();return}try{const Q=await A.stop();Q.blob.size?G(Q):c("That recording came back empty — nothing was captured.")}catch(Q){c(`Recording failed: ${Q.message}`)}l.focus()}}t.isRecording=()=>!!h,t.stopRecording=W,u.addEventListener("click",async()=>{var q;const $=l.value;if(!$.trim()){L("Add a few words about what went wrong — a short sentence is plenty."),l.focus();return}if(t.holdForReference())return;t.sending=!0,c(""),j();const A=u.innerHTML;u.innerHTML='<span class="spinner" aria-hidden="true"></span>Sending…';try{const Q=await e.report({title:$,description:f.value,priority:p,references:t.answeredReference(),issue:((q=t.pickedIssue())==null?void 0:q.key)||null,attachments:w.filter(_=>_.status==="ready").map(_=>({type:_.kind,storageKey:_.storageKey,mime:_.mime}))});if(Q!=null&&Q.cancelled){t.sending=!1,u.innerHTML=A,j();return}S=!0,clearTimeout(v),await x,n.drafts!==!1&&await ze(T,null).catch(()=>{}),t.succeed(Q)}catch(Q){t.sending=!1,u.innerHTML=A,c(Q.message.replace("[BugCatch] ","")),j(),t.recheckSignIn()}})}function Ha(t){const{client:e,say:n,titleInput:o,descInput:a,sendBtn:r,refsBox:i}=t;let s={policy:"off",fields:[]},c=!1,l=null,f="",d="",u=[],g="ask",y=!1,m=!1;e.referenceFields().then(L=>{s=L,C()}).catch(()=>{});function w(){return s.policy==="off"||!s.fields.length?{found:[],conflicts:[],loose:[]}:Vo(s.fields,[o.value,a.value])}function p(L=w()){return L.found.length>0&&L.conflicts.length===0}function h(){return!l||!f.trim()?[]:[{key:l,value:f.trim().slice(0,120)}]}const b=document.createElement("p");b.className="ref-found",b.setAttribute("aria-live","polite"),b.hidden=!0,a.closest(".field").after(b);let T;function C(){const L=w();if(p(L)){const j=L.found.slice(0,2).map(R=>`${E(R.label)} <b>${E(x(R.value))}</b>`).join(", ");b.innerHTML=`${ie}<span>Found your ${j} — no need to add it again.</span>`,b.hidden=!1,c&&!h().length&&(c=!1,O())}else b.hidden=!0,b.innerHTML=""}const S=()=>{clearTimeout(T),T=setTimeout(C,250)};o.addEventListener("input",S),a.addEventListener("input",S);function x(L){return L.length>20?`${L.slice(0,8)}…${L.slice(-4)}`:L}function v(L){const j=L.trim().toLowerCase();return u.find(R=>R.value.toLowerCase()===j)||null}function k(L){f=L.value,L.kinds.length===1?l=L.kinds[0].key:L.kinds.some(j=>j.key===l)||(l=null),d="",m=!1}function O(){var le,de;if(!c){i.hidden=!0,i.innerHTML="";return}const L=s.fields.find(z=>z.key===l)||null,j=s.policy!=="required",R=v(f),N=R&&R.kinds.length>1?s.fields.filter(z=>R.kinds.some($=>$.key===z.key)):s.fields,ne=u.length>1&&u.every(z=>z.kinds.length===1&&z.kinds[0].key===u[0].kinds[0].key),G={confirm:u.length>1?["Which one is this about?","We found more than one ID in your message. Pick the one this problem is about."]:["Is this the right ID?","This could be more than one kind of ID. Tell us which it is."],suggest:["Is this your ID?","We spotted this in your message. Tell us what it is so we can find your record."],ask:j?["One more thing","So we can find your record — this helps us answer faster."]:["We need one detail","We need one of these to look this up."]}[g];i.hidden=!1;const ce=N.length>6;i.innerHTML=`
1314
+ <div class="ask-head">
1315
+ <span class="avatar" aria-hidden="true">${we}</span>
1316
+ <div>
1317
+ <strong>${E(G[0])}</strong>
1318
+ <p class="why">${E(G[1])}</p>
1319
+ </div>
1320
+ </div>
1321
+ ${u.length>1?`
1322
+ <div class="chips cands" role="group" aria-label="IDs found in your message">
1323
+ ${u.map((z,$)=>`
1324
+ <button type="button" data-ref-cand="${$}" title="${E(z.value)}"
1325
+ aria-pressed="${!!R&&R===z}">${E(x(z.value))}</button>
1326
+ `).join("")}
1327
+ </div>`:""}
1328
+ ${N.length>1&&!ce&&!ne?`
1329
+ <div class="chips" role="group" aria-label="Which detail you are giving">
1330
+ ${N.map(z=>`
1331
+ <button type="button" data-ref-kind="${E(z.key)}" aria-pressed="${!!L&&z.key===L.key}">${E(z.label)}</button>
1332
+ `).join("")}
1333
+ </div>`:""}
1334
+ <div class="row">
1335
+ ${ce?`
1336
+ <select class="ref-kind" aria-label="Which detail you are giving">
1337
+ ${L?"":'<option value="" selected disabled>What is it?</option>'}
1338
+ ${N.map(z=>`
1339
+ <option value="${E(z.key)}" ${L&&z.key===L.key?"selected":""}>${E(z.label)}</option>
1340
+ `).join("")}
1341
+ </select>`:""}
1342
+ <input class="ref-value${d?" invalid":""}" type="${(L==null?void 0:L.inputMode)==="email"?"email":"text"}"
1343
+ inputmode="${E((L==null?void 0:L.inputMode)==="numeric"||(L==null?void 0:L.inputMode)==="tel"?"numeric":"text")}"
1344
+ value="${E(f)}"
1345
+ placeholder="${E(L?L.placeholder||L.label:"Your ID")}"
1346
+ aria-label="${E(L?L.label:"Your ID")}" ${d?'aria-invalid="true"':""} />
1347
+ </div>
1348
+ ${L!=null&&L.hint?`<p class="hint">${E(L.hint)}</p>`:""}
1349
+ ${d?`<p class="field-err" role="alert">${re}<span>${E(d)}</span></p>`:""}
1350
+ ${j?`<button type="button" class="link" data-act="ref-skip">${g==="ask"?"I don't have this — send without it":"Not sure — send as it is"}</button>`:""}`,i.querySelectorAll("[data-ref-cand]").forEach(z=>{z.addEventListener("click",()=>{k(u[Number(z.dataset.refCand)]),O()})}),i.querySelectorAll("[data-ref-kind]").forEach(z=>{z.addEventListener("click",()=>{l=z.dataset.refKind,d="",m=!1,O()})});const W=i.querySelector(".ref-value");W.addEventListener("input",()=>{f=W.value,d="",m=!1}),W.addEventListener("keydown",z=>{z.key==="Enter"&&(z.preventDefault(),r.click())}),(le=i.querySelector(".ref-kind"))==null||le.addEventListener("change",z=>{var $;l=z.target.value,d="",O(),($=i.querySelector(".ref-value"))==null||$.focus()}),(de=i.querySelector('[data-act="ref-skip"]'))==null||de.addEventListener("click",()=>{y=!0,c=!1,l=null,f="",d="",m=!1,O(),n("")}),((!L&&f?i.querySelector("[data-ref-kind], .ref-kind"):null)||W).focus()}function F(L){if(u=L.conflicts.length?L.conflicts:L.loose.slice(0,4),g=L.conflicts.length?"confirm":L.loose.length?"suggest":"ask",c=!0,u.length)if(u.length===1)k(u[0]);else{f="";const[j]=u;l=u.every(N=>N.kinds.length===1&&N.kinds[0].key===j.kinds[0].key)?j.kinds[0].key:null}else l=l||s.fields[0].key;O()}function Z(){if(s.policy==="off"||!s.fields.length||h().length)return!1;const L=w();return p(L)||y&&s.policy!=="required"?!1:L}function Y(){if(c&&f.trim()&&!l)return d="Pick what this ID is.",O(),!0;const L=Z();if(L)return c?O():F(L),n(""),!0;if(l&&f.trim()){const j=s.fields.find(R=>R.key===l);if(!m&&j&&!Ut(j,f))return d=`That does not look like a ${j.label.toLowerCase()}. Press Send again to use it anyway.`,m=!0,O(),!0}return!1}t.holdForReference=Y,t.answeredReference=h}const qa=3;function Da(t){const{client:e,cfg:n,notices:o}=t;let a=[];function r(){const s=a.slice(0,qa);o.replaceChildren(...s.map(c=>kt(c,{where:"panel",onDismiss:i}))),o.hidden=s.length===0}function i(s){e.dismissAnnouncement(s),a=a.filter(c=>c!==s),r(),t.titleInput.focus()}n.announcements!==!1&&typeof e.announcements=="function"&&e.announcements().then(s=>{t.closed||(a=s,r())}).catch(()=>{})}function Na(t){const{client:e,cfg:n,titleInput:o,known:a}=t;let r=[],i="",s=null,c=null;function l(){n.knownIssues!==!1&&e.knownIssues().then(y=>{r=y,u()}).catch(()=>{})}let f=null;function d(y){if(n.knownIssues===!1)return;clearTimeout(f),c==null||c.abort();const m=(y||"").trim();if(m.length<3){l();return}f=setTimeout(()=>{c=new AbortController,e.matchKnownIssues(m,{signal:c.signal}).then(w=>{w.length&&(r=w,u())}).catch(()=>{})},250)}function u(){if(!r.length){a.hidden=!0,a.innerHTML="";return}a.hidden=!1,a.innerHTML=`
1351
+ <p class="known-h">Already reported</p>
1352
+ ${r.map(y=>`
1353
+ <div class="issue ${y.joined?"is-joined":""}">
1354
+ <span class="who">
1355
+ <span class="t">${E(y.title)}</span>
1356
+ <span class="meta">${E(g(y))}</span>
1357
+ </span>
1358
+ <button class="join" type="button" data-join="${E(y.id)}"
1359
+ ${y.joined?"disabled":""}>${y.joined?"Following":"Me too"}</button>
1360
+ </div>
1361
+ ${s===y.id?`
1362
+ <div class="ask">
1363
+ <input type="email" class="join-email" placeholder="you@example.com"
1364
+ aria-label="Your email, so we can tell you when this is fixed" />
1365
+ <button class="ghost" type="button" data-join-confirm="${E(y.id)}">Follow</button>
1366
+ </div>`:""}
1367
+ `).join("")}
1368
+ ${i?`<p class="err">${E(i)}</p>`:""}`}function g(y){const m=y.status==="IN_PROGRESS"?"Being worked on now":"Not fixed yet",w=y.affectedCount===0?"":` · ${y.affectedCount} ${y.affectedCount===1?"person has":"people have"} said this is happening to them`;return`${m} · reported ${je(y.since)}${w}`}a.addEventListener("click",async y=>{var b,T,C,S,x;const m=y.target.closest("[data-join]"),w=y.target.closest("[data-join-confirm]");if(!m&&!w)return;const p=(w||m).getAttribute(w?"data-join-confirm":"data-join");i="";const h=((T=(b=a.querySelector(".join-email"))==null?void 0:b.value)==null?void 0:T.trim())||((C=e.signedInAs())==null?void 0:C.email)||((S=e.config.user)==null?void 0:S.email);if(!h){s=p,u(),(x=a.querySelector(".join-email"))==null||x.focus();return}try{const v=await e.meToo(p,{email:h});s=null,r=r.map(k=>k.id===p?{...k,joined:!0,affectedCount:v.affectedCount??k.affectedCount}:k),u()}catch(v){i=v.message.replace("[BugCatch] ",""),u()}}),l(),o.addEventListener("input",()=>d(o.value))}function Ua(t){const{client:e,cfg:n,titleInput:o,descInput:a,picks:r}=t;let i=[],s=null;function c(){if(!i.length){r.hidden=!0,r.innerHTML="";return}r.hidden=!1,r.innerHTML=`
1369
+ <p class="picks-h">Get an answer right away</p>
1370
+ <div class="picks-grid" role="group" aria-label="Common questions">
1371
+ ${i.map(l=>`
1372
+ <button type="button" class="pick" data-pick="${E(l.key)}"
1373
+ aria-pressed="${(s==null?void 0:s.key)===l.key}">
1374
+ <span class="t">${E(l.title)}</span>
1375
+ ${l.hint?`<span class="h">${E(l.hint)}</span>`:""}
1376
+ </button>`).join("")}
1377
+ </div>
1378
+ ${s?`<p class="picks-note">${ie}<span>Our assistant will check your account and reply here. Add anything else below, then send.</span></p>`:""}`}r.addEventListener("click",l=>{const f=l.target.closest("[data-pick]");if(!f)return;const d=i.find(g=>g.key===f.dataset.pick);if(!d)return;const u=s&&o.value.trim()===s.title;(s==null?void 0:s.key)===d.key?(s=null,u&&(o.value="")):(s=d,(!o.value.trim()||u)&&(o.value=d.title)),o.dispatchEvent(new Event("input",{bubbles:!0})),c(),s&&a.focus()}),n.agentIssues!==!1&&typeof e.agentIssues=="function"&&e.agentIssues().then(l=>{i=l,c()}).catch(()=>{}),t.pickedIssue=()=>s}function _a(t){const{client:e,scrim:n,say:o,callBtn:a,close:r}=t;let i=!1;function s(){e.callKind().then(f=>{f&&(i=!0,t.preloadCall(),a.hidden=t.mustSignIn())}).catch(()=>{})}s(),a.addEventListener("click",async()=>{t.sending=!0,o(""),t.refreshSendState(),a.disabled=!0,a.innerHTML='<span class="spinner"></span>Ringing…';try{const f=await e.startCall();c(f)}catch(f){t.sending=!1,a.disabled=!1,a.innerHTML=`${Re}Talk to the team`,t.refreshSendState(),f.filed?t.succeed(f.filed,{callFailed:f.reason||"The call could not be started."}):(o(f.message.replace("[BugCatch] ","")),t.recheckSignIn())}});function c(f){const d=n.querySelector(".panel"),u=f!=null&&f.bugId?String(f.bugId).slice(0,8):null;d.innerHTML=`
1379
+ <div class="call">
1380
+ <div class="call-head">
1381
+ <span class="call-dot" aria-hidden="true"></span>
1382
+ <strong class="call-state">Ringing…</strong>
1383
+ </div>
1384
+ <p class="call-note">
1385
+ We're ringing the team now. Someone will pick up if they're free — your report${u?` <code>${E(u)}</code>`:""} is already filed either way, so nothing is lost if nobody answers.
1386
+ </p>
1387
+ <div class="foot">
1388
+ <span class="spacer"></span>
1389
+ <button class="primary" type="button" data-act="hangup">Cancel</button>
1390
+ </div>
1391
+ </div>`;const g=d.querySelector(".call-state"),y=d.querySelector(".call-dot"),m={ringing:"Ringing the team…",connecting:"Someone answered — connecting…",connected:"Connected",missed:"Nobody was free",ended:"Call ended",failed:"The call dropped"},w=["ended","failed","missed"],p=e.on("call",({state:h})=>{if(g.textContent=m[h]||h,y.classList.toggle("off",w.includes(h)),w.includes(h)&&(d.querySelector('[data-act="hangup"]').textContent="Close",h==="missed")){const b=d.querySelector(".call-note");b&&(b.textContent="Nobody was free to pick up just now. Your report is filed and the team will reply in the chat.")}});d.querySelector('[data-act="hangup"]').addEventListener("click",()=>{p(),e.endCall(),r()})}function l(f,d,u){const g=document.createElement("div");g.className="livecall",g.innerHTML=`
1392
+ <span class="call-dot" aria-hidden="true"></span>
1393
+ <span class="who" role="status" aria-live="polite">Calling the team…</span>
1394
+ <span class="secs" hidden></span>
1395
+ ${u!=null&&u.recorded?'<span class="call-kept">This call is recorded.</span>':""}
1396
+ <button class="act" type="button" data-act="mute" hidden>Mute</button>
1397
+ <button class="act danger" type="button" data-act="hangup">Cancel</button>`,f.insertBefore(g,d);const y=g.querySelector(".who"),m=g.querySelector(".secs"),w=g.querySelector(".call-dot"),p=g.querySelector('[data-act="mute"]'),h=g.querySelector('[data-act="hangup"]');let b=null;const T=()=>{b&&(clearInterval(b),b=null)},C=x=>{T(),w.classList.add("off"),g.classList.add("over"),y.textContent=x,m.hidden=!0,p.hidden=!0,h.textContent="Dismiss",h.classList.remove("danger")},S=e.on("call",({state:x})=>{if(x==="ringing"&&(y.textContent="Calling the team…"),x==="connecting"&&(y.textContent="Someone answered — connecting…"),x==="connected"){y.textContent="You're on a call with the team",p.hidden=!1,m.hidden=!1;const v=Date.now();T(),b=setInterval(()=>{m.textContent=Te(Math.floor((Date.now()-v)/1e3))},1e3),m.textContent="0s"}x==="missed"&&C("Nobody was free. Send a message instead and the team will pick it up."),x==="ended"&&C("Call ended."),x==="failed"&&C("The call dropped.")});p.addEventListener("click",()=>{const x=u.setMuted(!u.isMuted());p.textContent=x?"Unmute":"Mute",y.textContent=x?"You're muted":"You're on a call with the team"}),h.addEventListener("click",()=>{S(),T(),e.endCall(),g.remove(),t.refreshThread(t.openReportId())})}t.offerCall=s,t.callOffered=()=>i,t.showLiveCall=l}function Pa(t){var S;const{client:e,say:n,compose:o,sendBtn:a,historyBtn:r,callBtn:i,whoami:s}=t;let c={mode:e.lastLoginMode||"off",signedIn:null},l="idle",f=((S=e.config.user)==null?void 0:S.email)||"",d="",u=!1,g="";const y=()=>c.mode==="required"&&!c.signedIn;function m(){const x=y();o.hidden=x,a.hidden=x,r&&(r.hidden=x),x?i.hidden=!0:t.callOffered()&&(i.hidden=!1)}function w(){var v;if(c.mode==="off"){s.hidden=!0,s.innerHTML="";return}s.hidden=!1,s.classList.toggle("asking",l!=="idle");const x=g?`<div class="after err">${E(g)}</div>`:"";if(l==="idle"){if(c.signedIn){s.innerHTML=`<span class="who">Signed in as <strong>${E(c.signedIn.email)}</strong></span><button type="button" class="link" data-act="signout">Sign out</button>`;return}const k=(v=e.config.user)==null?void 0:v.email;s.innerHTML=`<span class="who">${c.mode==="required"?"Sign in to report a bug here.":k?`Reporting as <strong>${E(k)}</strong>.`:"Reporting anonymously — sign in and we can tell you what happens next."}</span><button type="button" class="link" data-act="signin">Sign in</button>`;return}if(l==="email"){s.innerHTML=`
1398
+ <p class="why">Sign in with any email address — we'll send you a code.
1399
+ It's how you hear back about this report${c.mode==="required"?", and this project asks for it":""}.</p>
1400
+ <div class="row">
1401
+ <input type="email" data-fld="email" value="${E(f)}"
1402
+ placeholder="you@example.com" autocomplete="email" spellcheck="false"
1403
+ aria-label="Your email address" ${u?"disabled":""} />
1404
+ <button type="button" class="primary" data-act="code" ${u?"disabled":""}>
1405
+ ${u?"Sending…":"Send code"}
1406
+ </button>
1407
+ </div>
1408
+ ${x}
1409
+ ${c.mode==="optional"?'<div class="after"><button type="button" class="link" data-act="skip">Not now</button></div>':""}`;return}s.innerHTML=`
1410
+ <p class="why">We sent a code to <strong>${E(f)}</strong>. It expires in ten minutes.</p>
1411
+ <div class="row">
1412
+ <input type="text" class="code" data-fld="code" value="${E(d)}"
1413
+ placeholder="123456" inputmode="numeric" autocomplete="one-time-code"
1414
+ maxlength="8" aria-label="The code we emailed you" ${u?"disabled":""} />
1415
+ <button type="button" class="primary" data-act="confirm" ${u?"disabled":""}>
1416
+ ${u?"Checking…":"Sign in"}
1417
+ </button>
1418
+ </div>
1419
+ ${x}
1420
+ <div class="after">
1421
+ <button type="button" class="link" data-act="resend" ${u?"disabled":""}>Send it again</button>
1422
+ <button type="button" class="link" data-act="signin-back" ${u?"disabled":""}>Use another address</button>
1423
+ </div>`}function p({focus:x=!1}={}){var k;if(w(),m(),!x||u)return;const v=s.querySelector("[data-fld]");v&&(v.focus(),(k=v.setSelectionRange)==null||k.call(v,v.value.length,v.value.length))}s.addEventListener("input",x=>{const v=x.target.closest("[data-fld]");v&&(v.dataset.fld==="email"?f=v.value:d=v.value)}),s.addEventListener("keydown",x=>{x.key!=="Enter"||!x.target.closest("[data-fld]")||(x.preventDefault(),l==="email"?h():b())});async function h({resent:x=!1}={}){const v=f.trim();if(!v){g="Enter the address to send the code to.",p({focus:!0});return}u=!0,g="",p();try{await e.signIn(v),f=v,x||(d=""),l="code"}catch(k){g=k.message}finally{u=!1,p({focus:!0})}}async function b(){const x=d.trim();if(!x){g="Enter the code we emailed you.",p({focus:!0});return}u=!0,g="",p();try{const v=await e.confirmSignIn(f.trim(),x);c.signedIn=v,l="idle",d="",n(""),t.offerCall()}catch(v){g=v.message}finally{u=!1,p({focus:l!=="idle"})}}s.addEventListener("click",async x=>{const v=x.target.closest("button[data-act]");if(!v)return;const k=v.dataset.act;if(k==="signin"){l="email",g="",p({focus:!0});return}if(k==="skip"){l="idle",g="",p();return}if(k==="signin-back"){l="email",g="",d="",p({focus:!0});return}if(k==="code"){h();return}if(k==="resend"){h({resent:!0});return}if(k==="confirm"){b();return}if(k==="signout"){u=!0,p();try{await e.signOut()}finally{c.signedIn=null,u=!1,l=c.mode==="required"?"email":"idle",p({focus:l!=="idle"})}}});async function T({announce:x=!1}={}){const v=await e.loginState();c={mode:v.mode,signedIn:v.signedIn},e.lastLoginMode=v.mode,y()&&l==="idle"&&(l="email"),c.signedIn&&(l="idle"),x&&v.signedOutReason&&n(v.signedOutReason,"info"),p()}T({announce:!0}).catch(()=>{});function C(){c.mode!=="off"&&T().catch(()=>{})}t.mustSignIn=y,t.recheckSignIn=C}function cn(t){const e=t||[];if(!e.length)return"";let n=null,o=null;return e.map(a=>{var f,d,u,g;const r=ve(a.at),i=r&&r!==n?`<div class="day-sep" role="separator">${E(Ma(a.at))}</div>`:"";if(i&&(n=r,o=null),!a.from)return o=null,i+Va(a);const s={from:a.from,author:(f=a.reply)==null?void 0:f.author,automated:(d=a.reply)==null?void 0:d.automated,body:(u=a.reply)==null?void 0:u.body,at:a.at,attachments:(g=a.reply)==null?void 0:g.attachments},c=Ka(s),l=o&&o.who===c&&Math.abs(new Date(a.at).getTime()-new Date(o.at).getTime())<5*6e4;return o={who:c,at:a.at},i+ln(s,l?"cont":"")}).join("")}function Ka(t){return t.from==="reporter"?"me":t.automated?"assistant":`team:${t.author||""}`}function Va(t){const e=on(t.at);return`
1424
+ <div class="sys k-${E(t.kind)}">
1425
+ <span class="dot" aria-hidden="true"></span>${E(t.summary||"")}${e?`
1426
+ <span class="t">· ${E(e)}</span>`:""}
1427
+ </div>`}function ln(t,e=""){const n=t.from==="reporter",o=t.body||"",a=t.attachments||[],r=!n&&!!t.automated,i=o?`<span class="msg-text">${E(o)}</span>`:"",s=a.length?`<div class="att">${a.map(Wa).join("")}</div>`:"";let c="",l="";if(r)c='<span class="msg-who auto">Assistant <span class="tag">AI</span></span>',l=`<span class="av bot" aria-hidden="true">${we}</span>`;else if(!n){const d=t.author||"Support team";c=`<span class="msg-who">${E(d)}</span>`,l=`<span class="av" aria-hidden="true">${E(Aa(d))}</span>`}e.includes("cont")&&(c="");const f=r&&/it goes to the same person/i.test(o)?`<div class="quick" role="group" aria-label="Answer">
1428
+ <button type="button" data-quick="Yes, this is the problem">${ie}That's right</button>
1429
+ <button type="button" data-quick="No, that is not the problem">That's not it</button>
1430
+ </div>`:r&&Wo.test(o)?`<div class="quick" role="group" aria-label="Did this answer your question?">
1431
+ <button type="button" data-quick="Yes, that answers it">${ie}Yes, that answers it</button>
1432
+ <button type="button" data-quick="No, I still need help">No, I still need help</button>
1433
+ </div>`:"";return`
1434
+ <div class="msg-row ${n?"mine":"theirs"} ${r?"auto":""} ${e}">
1435
+ ${l}
1436
+ ${c}
1437
+ <div class="bubble ${o?"":"silent"}">${i}${s}</div>
1438
+ ${f}
1439
+ <span class="msg-when">${E(on(t.at)||je(t.at))}</span>
1440
+ </div>`}function Fa(){return`
1441
+ <div class="typing-row">
1442
+ <span class="av bot" aria-hidden="true">${we}</span>
1443
+ <span class="msg-who auto">Assistant <span class="tag">AI</span></span>
1444
+ <div class="bubble typing" role="img" aria-label="The assistant is working on it"><i></i><i></i><i></i></div>
1445
+ </div>`}function Wa(t){const e=E(t.name||"attachment");if(!t.url)return`<span class="file"><span class="nm">${e}</span></span>`;const n=E(t.url);return t.type==="SCREENSHOT"?`<a href="${n}" target="_blank" rel="noopener noreferrer"><img src="${n}" alt="${e}" loading="lazy"></a>`:t.type==="AUDIO"?`<audio controls preload="metadata" src="${n}"></audio>`:t.type==="VIDEO"?`<video controls preload="metadata" src="${n}"></video>`:`
1446
+ <a class="file" href="${n}" target="_blank" rel="noopener noreferrer" download>
1447
+ <span class="nm">${e}</span>
1448
+ ${t.size?`<span class="sz">${E(pe(t.size))}</span>`:""}
1449
+ </a>`}function Ya(t,e,n,o){var C;const{client:a,cfg:r}=t,i=document.createElement("div");i.className="composer",i.innerHTML=`
1450
+ <div class="staged" hidden></div>
1451
+ <div class="row">
1452
+ <div class="tools">
1453
+ ${r.attachments===!1?"":`
1454
+ <button class="tool" type="button" data-act="attach" title="Attach a file" aria-label="Attach a file">${en}</button>
1455
+ <button class="tool" type="button" data-act="voice" title="Record a voice note" aria-label="Record a voice note">${tn}</button>`}
1456
+ <button class="tool" type="button" data-act="livecall" title="Call the team" aria-label="Call the team" hidden>${Re}</button>
1457
+ </div>
1458
+ <textarea rows="1" placeholder="Write a reply…" aria-label="Write a reply"></textarea>
1459
+ <button class="send" type="button" data-act="send" title="Send" aria-label="Send" disabled>${nn}</button>
1460
+ </div>
1461
+ <div class="note" hidden></div>
1462
+ <input type="file" hidden multiple accept="${It.join(",")}">`,e.appendChild(i);const s=i.querySelector(".staged"),c=i.querySelector("textarea"),l=i.querySelector('[data-act="send"]'),f=i.querySelector('[data-act="voice"]'),d=i.querySelector('[data-act="livecall"]'),u=i.querySelector("input[type=file]"),g=i.querySelector(".note"),y=[];let m=null,w=!1;function p(S,x=""){g.hidden=!S,g.className=`note ${x}`,g.textContent=S||""}function h(){const S=y.filter(x=>x.storageKey);l.disabled=w||!c.value.trim()&&!S.length,s.hidden=!y.length,s.innerHTML=y.map((x,v)=>`
1463
+ <span class="chip ${x.storageKey?"":"uploading"}">
1464
+ <span class="nm">${E(x.name)}</span>
1465
+ <span class="sz">${x.storageKey?pe(x.size):"sending…"}</span>
1466
+ <button type="button" data-drop="${v}" aria-label="Remove ${E(x.name)}">${fe}</button>
1467
+ </span>`).join("");for(const x of s.querySelectorAll("[data-drop]"))x.addEventListener("click",()=>{y.splice(Number(x.dataset.drop),1),h()})}async function b(S,x,v){const k={name:v,size:S.size,storageKey:null};y.push(k),h();try{const{storageKey:O,mime:F}=await a.uploadAttachment(S,x);k.storageKey=O,k.mime=F}catch(O){y.splice(y.indexOf(k),1),p(O.message||"That file could not be sent.","err")}h()}c.addEventListener("input",()=>{c.style.height="auto",c.style.height=`${Math.min(c.scrollHeight,120)}px`,h()}),c.addEventListener("keydown",S=>{S.key==="Enter"&&!S.shiftKey&&!S.isComposing&&(S.preventDefault(),T())}),(C=i.querySelector('[data-act="attach"]'))==null||C.addEventListener("click",()=>u.click()),u.addEventListener("change",()=>{p("");for(const S of u.files){if(S.size>a.config.maxAttachmentBytes){p(`${S.name} is larger than ${pe(a.config.maxAttachmentBytes)}.`,"err");continue}b(S,S.type,S.name)}u.value=""}),f&&!eo()&&(f.disabled=!0,f.title="This browser cannot record audio"),f==null||f.addEventListener("click",async()=>{if(m){const S=m;m=null,f.classList.remove("recording"),f.innerHTML=tn,p("");const{blob:x,mime:v}=await S.stop();x.size&&b(x,v,"Voice note");return}try{p(""),m=await ro({maxMs:a.config.maxRecordingMs,onTick:S=>p(`Recording — ${Te(S)}. Tap the mic to stop.`),onAutoStop:()=>f.click()}),f.classList.add("recording"),f.innerHTML=xa}catch{m=null,p("The microphone is not available — check the browser permission.","err")}}),a.canCallTeam(o).then(S=>{S&&(d.hidden=!1,t.preloadCall())}).catch(()=>{}),d.addEventListener("click",async()=>{d.disabled=!0,p("");try{const S=await a.startLiveCall(o);t.showLiveCall(e,n,S)}catch(S){p(S.message.replace("[BugCatch] ",""),"err")}finally{d.disabled=!1}}),l.addEventListener("click",T),n.addEventListener("click",S=>{var v,k;const x=(k=(v=S.target).closest)==null?void 0:k.call(v,"[data-quick]");!x||w||(c.value=x.dataset.quick,T())});async function T(){var v;const S=c.value.trim(),x=y.filter(k=>k.storageKey);if(!(w||!S&&!x.length)){w=!0,h(),p(""),n.insertAdjacentHTML("beforeend",ln({from:"reporter",body:S,at:new Date().toISOString(),attachments:x.map(k=>({type:"FILE",name:k.name,size:k.size}))},"pending")),xe(n,{smooth:!0});try{await a.replyToReport(o,{body:S,attachments:x.map(k=>({storageKey:k.storageKey,mime:k.mime,name:k.name,size:k.size}))}),c.value="",c.style.height="auto",y.length=0,await t.refreshThread(o)}catch(k){(v=n.querySelector(".msg-row.pending"))==null||v.classList.replace("pending","failed"),p(k.message||"That could not be sent — try again.","err")}finally{w=!1,h()}}}h()}const it=new WeakMap;function Xa(t){var y;const{client:e,scrim:n,close:o}=t;let a=null;function r(m,{callFailed:w=null}={}){if(m!=null&&m.id&&!w){c(m.id,{fresh:!0}).then(p=>{p||i(m,{callFailed:w})});return}i(m,{callFailed:w})}function i(m,{callFailed:w=null}={}){var T;const p=m!=null&&m.id?String(m.id).slice(0,8):null,h=(T=m==null?void 0:m.estimate)!=null&&T.label?String(m.estimate.label):null,b=w?`<p class="eta">${E(w)} Your report is filed, and the team will reply in the chat.</p>`:"";n.querySelector(".panel").innerHTML=`
1468
+ <div class="done">
1469
+ <div class="tick">${ie}</div>
1470
+ <h3>Thanks — that's on its way.</h3>
1471
+ <p>${p?`Filed as <code>${E(p)}</code>.`:"The team has what they need to reproduce it."}</p>
1472
+ ${b}
1473
+ ${h?`<p class="eta">Reports like this usually take <strong>${E(h)}</strong>. We'll let you know when it moves.</p>`:""}
1474
+ </div>`,setTimeout(o,b?6e3:h?4e3:2e3)}async function s(){const m=n.querySelector(".panel");clearTimeout(l),a=null,m.classList.remove("is-chat"),m.innerHTML=`
1475
+ ${ot({title:"Your reports",sub:"Everything you've reported, and where each one got to."})}
1476
+ <div class="history" aria-busy="true">${Ia(3)}</div>`,m.querySelector('[data-act="close"]').addEventListener("click",o);let w=[];try{({reports:w}=await e.myReports())}catch{const h=m.querySelector(".history");h&&(h.innerHTML=at("Couldn't load your reports just now.",re));return}const p=m.querySelector(".history");if(p){p.removeAttribute("aria-busy"),p.innerHTML=w.length?w.map((h,b)=>`
1477
+ <button class="row" type="button" data-report="${E(h.id)}" style="animation-delay:${Math.min(b,8)*30}ms">
1478
+ <span class="row-ico" aria-hidden="true">${mt}</span>
1479
+ <span class="who">
1480
+ <span class="ttl">${E(h.title)}</span>
1481
+ <span class="sub">${E(h.reference)} · ${E(je(h.createdAt))}</span>
1482
+ </span>
1483
+ <span class="pill ${E(String(h.status).toLowerCase())}">${E(rt(h.status))}</span>
1484
+ <span class="chev" aria-hidden="true">${$a}</span>
1485
+ </button>`).join(""):at("You haven't reported anything yet.",Ca);for(const h of p.querySelectorAll("[data-report]"))h.addEventListener("click",()=>c(h.dataset.report))}}async function c(m,{fresh:w=!1}={}){var S;const p=n.querySelector(".panel");clearTimeout(l),p.classList.add("is-chat"),p.innerHTML=`
1486
+ ${ot({back:!0,title:w?"Looking into it":"Your report",sub:w?"Our assistant is on it — it may ask you a question here.":"Everything that has happened, and a way to answer."})}
1487
+ <div class="history chatting" aria-busy="true"><div class="thread">${La()}</div></div>`,p.querySelector('[data-act="close"]').addEventListener("click",o),p.querySelector('[data-act="back"]').addEventListener("click",s);let h=null;try{h=await e.myReport(m)}catch{h=null}const b=p.querySelector(".history");if(!b||!p.querySelector('[data-act="back"]'))return!1;if(!h)return w?(p.classList.remove("is-chat"),!1):(b.removeAttribute("aria-busy"),b.innerHTML=at("Couldn't load that report just now.",re),!1);a=m,e.markReportRead(m);const T=cn(h.timeline);b.classList.add("chatting"),b.removeAttribute("aria-busy"),b.innerHTML=`
1488
+ <div class="report-head">
1489
+ <span class="ttl">${E(h.title)}</span>
1490
+ <span class="sub">${E(h.reference)} · ${E(h.project||"")}</span>
1491
+ <span class="pill ${E(String(h.status).toLowerCase())}">${E(rt(h.status))}</span>
1492
+ ${(S=h.estimate)!=null&&S.label?`<span class="eta-line">Usually takes ${E(String(h.estimate.label))}</span>`:""}
1493
+ </div>
1494
+ <div class="thread" role="log" aria-live="polite" aria-label="Conversation">${T}</div>`;const C=b.querySelector(".thread");return it.set(C,T),xe(C),d(b,h),h.canReply&&Ya(t,b,C,m),f(b,h,m),xe(C),!0}let l=null;function f(m,w,p){var Z,Y,L;clearTimeout(l);const h=w.assistant,b=m.querySelector(".thread");let T=m.querySelector(".assistant");if(!h){T==null||T.remove(),(Z=b==null?void 0:b.querySelector(".typing-row"))==null||Z.remove();return}const C=(T==null?void 0:T.dataset.phase)||null;T||(T=document.createElement("div"),T.setAttribute("role","status"),T.setAttribute("aria-live","polite"),(Y=m.querySelector(".report-head"))==null||Y.after(T)),T.className=`assistant ${E(h.phase)}`,T.dataset.phase=h.phase;const S=h.steps||[],x=S.filter(j=>j.state==="done").length,v=S.some(j=>j.state==="active")?.5:0,k=S.length?Math.round((x+v)/S.length*100):0,O=`
1495
+ <div class="as-body${C&&C!==h.phase?" entering":""}">
1496
+ <div class="as-top">
1497
+ <span class="as-orb" aria-hidden="true">${h.phase==="analyzing"?'<span class="as-spin"></span>':h.phase==="calling"?Re:h.phase==="resolved"?ie:we}</span>
1498
+ <div class="as-text">
1499
+ <div class="as-title">${E(h.title)}</div>
1500
+ <div class="as-detail">${E(h.detail)}</div>
1501
+ </div>
1502
+ </div>
1503
+ </div>
1504
+ ${S.length?`
1505
+ <div class="as-progress" role="progressbar" aria-label="Progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${k}"><i style="width:${k}%"></i></div>
1506
+ <ol class="as-steps">${S.map(j=>`<li class="${E(j.state)}"${j.state==="active"?' aria-current="step"':""}><span class="dot"></span><span class="lbl">${E(j.label)}</span></li>`).join("")}</ol>`:""}`,F=JSON.stringify([h.phase,h.title,h.detail,S]);if(T.dataset.key!==F){const j=T.querySelector(".as-progress i"),R=j==null?void 0:j.style.width;T.innerHTML=O,T.dataset.key=F;const N=T.querySelector(".as-progress i");N&&R&&(N.style.width=R,requestAnimationFrame(()=>{N.style.width=`${k}%`}))}if(b){const j=an(b),R=b.querySelector(".typing-row");h.phase!=="analyzing"?R==null||R.remove():(!R||R!==b.lastElementChild)&&(R==null||R.remove(),b.insertAdjacentHTML("beforeend",Fa()),j&&xe(b))}h.phase==="analyzing"?l=setTimeout(()=>u(p),3e3):h.phase==="calling"?l=setTimeout(()=>u(p),1e4):h.phase==="needs_info"&&C!=="needs_info"&&((L=m.querySelector(".composer textarea"))==null||L.focus())}function d(m,w){var h,b;if((h=m.querySelector(".fix-verification"))==null||h.remove(),!w.resolvedAt||!["RESOLVED","CLOSED"].includes(w.status))return;const p=document.createElement("div");p.className="fix-verification",w.verification?p.textContent=w.verification==="CONFIRMED"?"You confirmed that this fix works.":"Your feedback was recorded.":(p.innerHTML='<p>Does the fix work for you?</p><textarea maxlength="4000" aria-label="Fix feedback" placeholder="What happens when you try again? (optional)"></textarea><button type="button" data-result="CONFIRMED">It works now</button> <button type="button" data-result="STILL_HAPPENING">Still happening</button><p class="feedback-status" role="status"></p>',p.querySelectorAll("[data-result]").forEach(T=>{T.onclick=async()=>{p.querySelectorAll("button").forEach(C=>{C.disabled=!0});try{await e.verifyFix(w.id,{result:T.dataset.result,resolvedAt:w.resolvedAt,note:p.querySelector("textarea").value}),await c(w.id)}catch(C){p.querySelector(".feedback-status").textContent=C.message,p.querySelectorAll("button").forEach(S=>{S.disabled=!1})}}})),(b=m.querySelector(".report-head"))==null||b.after(p)}async function u(m){const w=n.querySelector(".history.chatting"),p=w==null?void 0:w.querySelector(".thread");if(!p||a!==m)return;let h=null;try{h=await e.myReport(m)}catch{}if(t.closed||!h||a!==m)return;d(w,h);const b=an(p),T=cn(h.timeline);it.get(p)!==T&&(p.innerHTML=T,it.set(p,T)),f(w,h,m),b&&xe(p);const C=w.querySelector(".report-head .pill");C&&(C.className=`pill ${String(h.status).toLowerCase()}`,C.textContent=rt(h.status))}const g=e.on("update",m=>{!a||(m==null?void 0:m.bugId)!==a||(e.markReportRead(a),u(a))});t.onDestroy(()=>{g(),clearTimeout(l)}),(y=n.querySelector('[data-act="history"]'))==null||y.addEventListener("click",s),t.succeed=r,t.refreshThread=u,t.openReportId=()=>a}function Ja({root:t,host:e,dock:n,client:o,onClose:a,preloadCall:r=()=>{}}){Za(t);const i=o.config,s=document.createElement("div");s.className=`scrim ${n.classList.contains("at-left")?"at-left":"at-right"} ${n.classList.contains("at-top")?"at-top":"at-bottom"}`,s.style.setProperty("--bc-dock-h",`${Math.round(n.getBoundingClientRect().height)}px`),s.innerHTML=`
1507
+ <div class="panel" role="dialog" aria-modal="true" aria-labelledby="bc-h">
1508
+ ${ot({id:"bc-h",title:"Tell us what went wrong",sub:"Our assistant starts looking right away. We attach the page details for you."})}
1509
+ <div class="body">
1510
+ <div class="slot" role="alert"></div>
1511
+ <!-- What the project's team is telling visitors. Drawn only when it
1512
+ has published something. -->
1513
+ <div class="notices" hidden></div>
1514
+ <div class="whoami" hidden></div>
1515
+ <!-- The questions the assistant can answer from their account and
1516
+ close by itself. Drawn only when the project offers any. -->
1517
+ <div class="picks" hidden></div>
1518
+ <div class="known" hidden></div>
1519
+ ${za(i)}
1520
+ </div>
1521
+ <div class="foot">
1522
+ <span class="note" aria-live="polite"></span>
1523
+ ${o.hasReports()?'<button class="quiet" type="button" data-act="history">Your reports</button>':""}
1524
+ <span class="spacer"></span>
1525
+ <!-- Hidden until the API confirms this project can take a call, which
1526
+ most cannot. Drawn here rather than as a second launcher because it
1527
+ is the same errand as Send report — the difference is only whether
1528
+ the reporter would rather say it than type it. -->
1529
+ <button class="ghost" type="button" data-act="call" hidden>${Re}Talk to the team</button>
1530
+ <button class="primary" type="button" data-act="send">Send report ${nn}</button>
1531
+ </div>
1532
+ <div class="powered">Powered by
1533
+ <a class="brand-credit" href="https://bugcatch.sphoro.com" target="_blank" rel="noopener noreferrer" aria-label="BugCatch">${Ta}</a>
1534
+ </div>
1535
+ </div>`;const c=b=>s.querySelector(b),l=c(".slot"),f=[],d={client:o,cfg:i,root:t,host:e,dock:n,scrim:s,$:c,titleInput:c("#bc-title"),descInput:c("#bc-desc"),compose:c(".compose"),sendBtn:c('[data-act="send"]'),callBtn:c('[data-act="call"]'),historyBtn:c('[data-act="history"]'),note:c(".foot .note"),whoami:c(".whoami"),refsBox:c(".refs"),notices:c(".notices"),known:c(".known"),picks:c(".picks"),sending:!1,closed:!1,say:h,close:w,preloadCall:r,onDestroy:b=>{f.push(b)},refreshSendState:null,isRecording:null,stopRecording:null,holdForReference:null,answeredReference:null,pickedIssue:null,offerCall:null,callOffered:null,showLiveCall:null,mustSignIn:null,recheckSignIn:null,succeed:null,refreshThread:null,openReportId:null};Qa(d),Ha(d),Da(d),Na(d),Ua(d),_a(d),Pa(d),Xa(d);const u=document.activeElement,g=document.documentElement.style,y=g.overflow;g.overflow="hidden";function m(){d.closed||(f.forEach(b=>b()),d.closed=!0,g.overflow=y,document.removeEventListener("keydown",p,!0),s.remove(),n.hidden=!1,e.style.opacity="",a==null||a())}function w(){var b;if(!d.closed){s.classList.add("closing"),setTimeout(m,160);try{(b=u==null?void 0:u.focus)==null||b.call(u)}catch{}}}function p(b){if(b.key==="Escape"){if(b.stopPropagation(),d.isRecording()){d.stopRecording({keep:!1});return}d.sending||w();return}if(b.key!=="Tab"||d.isRecording())return;const T=[...s.querySelectorAll("button:not(:disabled), input:not([hidden]), textarea, select, [href]")].filter(v=>v.offsetParent!==null||v===document.activeElement);if(!T.length)return;const C=T[0],S=T[T.length-1],x=s.getRootNode().activeElement;b.shiftKey&&x===C?(b.preventDefault(),S.focus()):!b.shiftKey&&x===S&&(b.preventDefault(),C.focus())}document.addEventListener("keydown",p,!0),s.addEventListener("click",b=>{b.target===s&&!d.sending&&w()}),c('[data-act="close"]').addEventListener("click",w);function h(b,T="err"){l.innerHTML=b?`<div class="msg ${T}">${T==="err"?re:""}<span>${E(b)}</span></div>`:""}return t.appendChild(s),d.refreshSendState(),d.titleInput.focus(),{destroy:m,close:w}}function Za(t){if(t.querySelector("style[data-panel]"))return;const e=document.createElement("style");e.setAttribute("data-panel",""),e.textContent=Ea;const n=t.querySelector("style");n?n.after(e):t.prepend(e)}const Ga=Object.freeze(Object.defineProperty({__proto__:null,openPanel:Ja},Symbol.toStringTag,{value:"Module"})),dn=8e3;function er(t=dn){const e=window.AudioContext||window.webkitAudioContext;try{return new e({sampleRate:t})}catch{return new e}}async function tr(t){if(t.state==="suspended")try{await t.resume()}catch{}}function nr(t,e,n){const o=e/n,a=new Float32Array(Math.floor(t.length/o));for(let r=0;r<a.length;r++){const i=Math.floor(r*o),s=Math.min(Math.floor((r+1)*o),t.length);let c=0;for(let l=i;l<s;l++)c+=t[l];a[r]=s>i?c/(s-i):0}return a}const or=132,un=32635;function ar(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++){const o=Math.max(-1,Math.min(1,t[n]));let a=Math.round(o*32767);const r=a<0?128:0;r&&(a=-a),a>un&&(a=un),a+=or;let i=7;for(let c=16384;!(a&c)&&i>0;i--,c>>=1);const s=a>>i+3&15;e[n]=~(r|i<<4|s)&255}return e}const rr=512;function ir(t,e,n,o=dn){const a=t.createMediaStreamSource(e),r=t.createScriptProcessor(rr,1,1);r.onaudioprocess=s=>{const c=s.inputBuffer.getChannelData(0),l=t.sampleRate===o?c:nr(c,t.sampleRate,o);n(ar(l))},a.connect(r);const i=t.createGain();return i.gain.value=0,r.connect(i),i.connect(t.destination),{stop(){r.onaudioprocess=null;try{a.disconnect()}catch{}try{r.disconnect()}catch{}try{i.disconnect()}catch{}}}}const sr="voiceai.realtime.v1",cr=[{urls:"stun:stun.l.google.com:19302"}];function pn(){return navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,channelCount:1}})}function hn(){var t;return typeof window<"u"&&typeof window.RTCPeerConnection=="function"&&!!((t=navigator.mediaDevices)!=null&&t.getUserMedia)}async function lr({realtimeUrl:t,stream:e,ringsUntil:n,onState:o,onAudioBlocked:a,onMicrophone:r}){const i=(I,M)=>{try{o==null||o(I,M)}catch{}},s=I=>{try{a==null||a(I)}catch{}},c=I=>{try{r==null||r(I)}catch{}};if(!hn()){const I=new Error("[BugCatch] this browser cannot make live calls.");throw i("failed",{reason:"unsupported"}),I}let l=e;if(!l)try{l=await pn()}catch(I){throw i("failed",{reason:"microphone",error:String((I==null?void 0:I.name)||I)}),I}let f;try{f=await dr(t)}catch(I){throw gn(l),i("failed",{reason:"connect"}),I}let d=null,u=null,g=!1,y=null,m=null,w=null,p=!1,h=null,b=null,T=!1;const C=[];let S=!1,x=!1,v=!1,k=null,O=null,F=0;const Z=2e3,Y=5e3,L=3e4,j=4,R=(I,M)=>{if(!g){g=!0,y&&(clearTimeout(y),y=null),A(),b==null||b(),b=null,G(),h==null||h(),h=null;try{d==null||d.close()}catch{}gn(l),u&&(u.srcObject=null,u.remove(),u=null);try{f.readyState===WebSocket.OPEN&&f.close(1e3,"call over")}catch{}i(I,M)}},N=I=>{f.readyState===WebSocket.OPEN&&f.send(JSON.stringify(I))},ne=async()=>{if(T||w||g||!m||!m.audio&&!m.transcript)return;T=!0;const I=m.encoding||"mulaw";if(I!=="mulaw"){fn(`this call is kept as ${I}, which this SDK cannot produce.`);return}const M=Number(m.sample_rate)||8e3;try{const D=er(M);if(await tr(D),g){try{D.close()}catch{}return}const X=ir(D,l,V=>{f.readyState===WebSocket.OPEN&&f.send(V)},M);w={context:D,tap:X}}catch(D){fn(`could not send the copy this call is keeping: ${String((D==null?void 0:D.message)||D)}`)}};function G(){if(T=!1,!w)return;const{context:I,tap:M}=w;w=null;try{M.stop()}catch{}try{I.close()}catch{}}function ce(){var M;if(!u||g)return;let I;try{I=(M=u.play)==null?void 0:M.call(u)}catch{he();return}if(!I||typeof I.then!="function"){W();return}I.then(W,he)}function W(){h==null||h(),h=null,p&&(p=!1,s(!1))}function he(){g||(p||(p=!0,s(!0)),le())}function le(){if(h||typeof window>"u"||typeof window.addEventListener!="function")return;const I=()=>ce(),M=["pointerdown","keydown","touchstart"];for(const D of M)window.addEventListener(D,I,{capture:!0,passive:!0});h=()=>{for(const D of M)try{window.removeEventListener(D,I,{capture:!0})}catch{}}}const de=I=>{d=new RTCPeerConnection({iceServers:I!=null&&I.length?I:cr});for(const M of l.getAudioTracks())d.addTrack(M,l);b=_(),d.onicecandidate=M=>{M.candidate&&N({type:"signal",signal:{kind:"candidate",payload:M.candidate.toJSON()}})},d.ontrack=M=>{var X;const[D]=M.streams;D&&(u||(u=document.createElement("audio"),u.autoplay=!0,u.playsInline=!0,(X=u.setAttribute)==null||X.call(u,"playsinline",""),u.style.cssText="position:fixed;width:0;height:0;opacity:0;pointer-events:none",document.body.appendChild(u)),u.srcObject=D,ce())},d.onconnectionstatechange=z,d.oniceconnectionstatechange=z};function z(){if(!d||g)return;const I=d.connectionState||d.iceConnectionState;if(I==="connected"||I==="completed"){x=!0,F=0,A(),v=!1,i("connected");return}if(I==="disconnected"){if(!x)return;$(Z);return}if(I==="failed"){if(!x){R("failed",{reason:"ice"});return}$(0)}}function $(I){g||(v||(v=!0,i("reconnecting"),O=setTimeout(()=>R("failed",{reason:"network"}),L)),!k&&(k=setTimeout(q,I)))}function A(){k&&(clearTimeout(k),k=null),O&&(clearTimeout(O),O=null)}async function q(){if(k=null,g||!d)return;const I=d.connectionState||d.iceConnectionState;if(!(I==="connected"||I==="completed")){if(!S){N({type:"signal",signal:{kind:"restart",payload:{}}}),k=setTimeout(q,Y);return}F>=j||(F+=1,await Q(),k=setTimeout(q,Y))}}async function Q(){if(!(g||!d))try{const I=await d.createOffer({iceRestart:!0});await d.setLocalDescription(I),N({type:"signal",signal:{kind:"offer",payload:d.localDescription.toJSON()}})}catch{}}function _(){let M=null,D=!1;const X=V=>{if(M&&(clearTimeout(M),M=null),V){if(!D)return;D=!1,c(!0);return}D||(M=setTimeout(()=>{M=null,!g&&(D=!0,c(!1))},600))};for(const V of l.getAudioTracks())V.onmute=()=>X(!1),V.onunmute=()=>X(!0),V.onended=()=>{M&&(clearTimeout(M),M=null),!D&&(D=!0,c(!1))};return()=>{M&&(clearTimeout(M),M=null);for(const V of l.getAudioTracks())V.onmute=null,V.onunmute=null,V.onended=null}}const ee=async()=>{try{const I=await d.createOffer();await d.setLocalDescription(I),N({type:"signal",signal:{kind:"offer",payload:d.localDescription.toJSON()}})}catch{R("failed",{reason:"negotiation"})}},br=async I=>{try{await d.setRemoteDescription(new RTCSessionDescription(I));const M=await d.createAnswer();await d.setLocalDescription(M),N({type:"signal",signal:{kind:"answer",payload:d.localDescription.toJSON()}}),await mn()}catch{R("failed",{reason:"negotiation"})}},mn=async()=>{for(;C.length;){const I=C.shift();try{await d.addIceCandidate(new RTCIceCandidate(I))}catch{}}};let yn=Promise.resolve();f.onmessage=I=>{yn=yn.then(()=>mr(I)).catch(()=>{})};const mr=async I=>{var D,X,V,wn,vn;if(typeof I.data!="string")return;let M;try{M=JSON.parse(I.data)}catch{return}switch(M.type){case"session.created":{if(de((D=M.data)==null?void 0:D.ice_servers),m=((X=M.data)==null?void 0:X.capture)||null,(V=M.data)!=null&&V.peer_present){i("connecting"),ne();break}i("ringing"),yr();break}case"peer.joined":{y&&(clearTimeout(y),y=null),i("connecting"),S=!!((wn=M.data)!=null&&wn.should_offer),S&&await ee(),ne();break}case"signal":{if(!d)break;const{kind:He,payload:qe}=M.data||{};if(He==="offer")await br(qe);else if(He==="answer")try{await d.setRemoteDescription(new RTCSessionDescription(qe)),await mn()}catch{R("failed",{reason:"negotiation"})}else if(He==="candidate")if(d.remoteDescription)try{await d.addIceCandidate(new RTCIceCandidate(qe))}catch{}else C.push(qe);else He==="restart"&&S&&await Q();break}case"peer.left":R("ended",{reason:"peer_left"});break;case"error":R("failed",{reason:"server",detail:(vn=M.error)==null?void 0:vn.detail});break;case"session.ended":R("ended",{reason:"server"});break}};f.onclose=()=>R("ended",{reason:"disconnected"}),f.onerror=()=>R("failed",{reason:"socket"});function yr(){if(!n)return;const I=new Date(n).getTime()-Date.now();Number.isFinite(I)&&(y=setTimeout(()=>R("missed"),Math.max(0,I)))}return{hangUp(){N({type:"session.end"}),R("ended",{reason:"hung_up"})},setMuted(I){for(const M of l.getAudioTracks())M.enabled=!I;return I},isMuted(){return l.getAudioTracks().every(I=>!I.enabled)}}}function dr(t){return new Promise((e,n)=>{let o;try{o=new WebSocket(t,sr)}catch(a){n(a);return}o.onopen=()=>{o.onopen=null,o.onerror=null,e(o)},o.onerror=()=>{o.onopen=null,o.onerror=null,n(new Error("[BugCatch] could not connect the call."))}})}function fn(t){try{console.warn(`[BugCatch] ${t}`)}catch{}}function gn(t){var e;for(const n of((e=t==null?void 0:t.getTracks)==null?void 0:e.call(t))??[])try{n.stop()}catch{}}const Qe={cycleMs:3e3,peak:.045,bursts:[{at:0,seconds:.4,hz:[440,660]},{at:.55,seconds:.4,hz:[440,660]}]};function ur(){var t;try{return!!((t=navigator.userActivation)!=null&&t.hasBeenActive)}catch{return!1}}function pr(t){if(!t()&&!ur())return()=>{};const e=typeof window<"u"&&(window.AudioContext||window.webkitAudioContext);if(!e)return()=>{};let n;try{n=new e}catch{return()=>{}}let o=!1,a=null;const r=[],i=({at:l,seconds:f,hz:d})=>{const u=n.currentTime+l,g=n.createGain();g.connect(n.destination),g.gain.setValueAtTime(0,u),g.gain.linearRampToValueAtTime(Qe.peak,u+.02),g.gain.setValueAtTime(Qe.peak,u+f-.06),g.gain.linearRampToValueAtTime(0,u+f);for(const y of d){const m=n.createOscillator();m.type="sine",m.frequency.value=y,m.connect(g),m.start(u),m.stop(u+f+.02),r.push(m)}},s=()=>{if(!o)try{Qe.bursts.forEach(i)}catch{}},c=()=>{o||(s(),a=setInterval(s,Qe.cycleMs))};return n.state==="running"?c():n.resume().then(c).catch(()=>{}),()=>{o=!0,a&&clearInterval(a);for(const l of r)try{l.stop()}catch{}try{n.close()}catch{}}}function hr(t){const e=Date.parse(t||"");return Number.isNaN(e)?0:Math.max(0,Math.round((e-Date.now())/1e3))}const bn=["flex:1","padding:9px 12px","border:0","border-radius:8px","font:600 13px/1.4 inherit","cursor:pointer"].join(";");function fr({call:t,accent:e="#5b6ef5",position:n="bottom-right",onAnswer:o,onDecline:a,onExpire:r,touched:i=()=>!1}){if(typeof document>"u"||!document.body)return()=>{};const[s,c]=String(n).split("-"),l=document.createElement("div");l.setAttribute("role","alertdialog"),l.setAttribute("aria-live","assertive"),l.setAttribute("aria-label",`${t.from||"Support"} is calling about ${t.reference}`),l.style.cssText=["position:fixed",`${s==="top"?"top":"bottom"}:20px`,`${c==="left"?"left":"right"}:20px`,"z-index:2147483647","width:300px","max-width:calc(100vw - 40px)","padding:14px","border-radius:12px","background:#1b1e26","color:#eceef2",'font:13px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif',"box-shadow:0 18px 44px rgba(0,0,0,0.5)",`border:1px solid ${e}`,"opacity:0","transform:translateY(8px)","transition:opacity .2s ease,transform .2s ease"].join(";");const f=document.createElement("div");f.style.cssText="font-weight:600;font-size:14px;margin-bottom:2px",f.textContent=`${t.from||"Support"} is calling`;const d=document.createElement("div");d.style.cssText="color:#a4abba;margin-bottom:10px",d.textContent=t.project?`About your report ${t.reference} · ${t.project}`:`About your report ${t.reference}`;const u=document.createElement("div");u.style.cssText="color:#7d8598;font-size:12px;margin-bottom:10px";const g=document.createElement("button");g.type="button",g.textContent="Answer",g.style.cssText=`${bn};background:${e};color:#fff`;const y=document.createElement("button");y.type="button",y.textContent="Not now",y.style.cssText=`${bn};background:#2b2f3a;color:#c8cedb`;const m=document.createElement("div");if(m.style.cssText="display:flex;gap:8px",m.append(g,y),l.append(f,d,u),t.recorded){const C=document.createElement("div");C.style.cssText="color:#7d8598;font-size:12px;margin-bottom:10px",C.textContent="This call will be recorded.",l.append(C)}l.append(m),document.body.appendChild(l);const w=pr(i);let p=!1,h=null;const b=()=>{p||(p=!0,h&&clearInterval(h),w(),l.style.opacity="0",l.style.transform="translateY(8px)",setTimeout(()=>l.remove(),250))},T=()=>{const C=hr(t.ringsUntil);if(u.textContent=C?`Ringing — ${C}s`:"The call has stopped ringing.",!C){b();try{r==null||r()}catch{}}};return T(),h=setInterval(T,1e3),g.addEventListener("click",()=>{b();try{o==null||o()}catch{}}),y.addEventListener("click",()=>{b();try{a==null||a()}catch{}}),requestAnimationFrame(()=>{l.style.opacity="1",l.style.transform="translateY(0)"}),b}const gr=Object.freeze(Object.defineProperty({__proto__:null,joinLiveCall:lr,liveCallSupported:hn,openMicrophone:pn,showIncomingCall:fr},Symbol.toStringTag,{value:"Module"}));return nt});
1536
+ //# sourceMappingURL=bugcatch.standalone.umd.js.map