@mushi-mushi/web 1.31.1 → 1.31.2

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.
@@ -92,5 +92,5 @@
92
92
  z-index: 2147483647;
93
93
  cursor: crosshair;
94
94
  background: transparent;
95
- `,document.body.appendChild(f),f}function p(f,g){let m=document.elementsFromPoint(f,g),b=null;for(let P of m)if(!(P===r||P===e)){if(P.id==="mushi-mushi-widget"||P.closest("#mushi-mushi-widget"))return null;b=P;break}let C=0;for(;b?.shadowRoot&&C<20;){let P=b.shadowRoot.elementFromPoint(f,g);if(!P||P===b)break;b=P,C++;}return b}function h(f){if(!e)return;let g=f.getBoundingClientRect();e.style.left=`${g.left}px`,e.style.top=`${g.top}px`,e.style.width=`${g.width}px`,e.style.height=`${g.height}px`,e.style.display="block";}function k(f){let g=p(f.clientX,f.clientY);if(!g){n=null,e&&(e.style.display="none");return}n=g,h(g);}function S(f){f.preventDefault(),f.stopPropagation();}function T(f){f.preventDefault(),f.stopPropagation();let g=p(f.clientX,f.clientY);g&&L(s(g));}function E(f){f.key==="Escape"&&L(null);}function w(){n?.isConnected&&h(n);}function L(f){x(),i?.(f),i=null;}function M(){return t&&x(),new Promise(f=>{i=f,t=true,e=u(),r=d(),r.addEventListener("mousemove",k),r.addEventListener("click",T),r.addEventListener("pointerdown",S),r.addEventListener("mousedown",S),r.addEventListener("mouseup",S),document.addEventListener("keydown",E,true),window.addEventListener("scroll",w,{capture:true,passive:true});})}function x(){t&&(t=false,n=null,document.removeEventListener("keydown",E,true),window.removeEventListener("scroll",w,{capture:true}),r&&(r.remove(),r=null),e&&(e.remove(),e=null));}return {activate:M,deactivate:x,isActive:()=>t}}var Ga=120;function ki(){let t=[],e=()=>n("hashchange");n("initial");function r(a){t.push(a),t.length>Ga&&t.shift();}function n(a){typeof location>"u"||r({ts:Date.now(),kind:"route",payload:{source:a,route:sr(`${location.pathname}${location.search}${location.hash}`),href:sr(location.href)}});}function i(a){let s=a.target instanceof Element?a.target:null;if(!s)return;let u=s.closest('button,a,[role="button"],input,textarea,select,[data-mushi-track]')??s;r({ts:Date.now(),kind:"click",payload:{tag:u.tagName.toLowerCase(),id:u.id||void 0,text:Sp(u)}});}let o=Me({onPush:()=>n("pushState"),onReplace:()=>n("replaceState"),onPop:()=>n("popstate")});return window.addEventListener("hashchange",e),document.addEventListener("click",i,true),{setScreen(a){r({ts:Date.now(),kind:"screen",payload:a});},getEntries(a={}){return [...t,...(a.consoleLogs??[]).map(u=>({ts:u.timestamp,kind:"log",payload:{level:u.level,message:u.message}})),...(a.networkLogs??[]).map(u=>({ts:u.timestamp,kind:"request",payload:{method:u.method,url:u.url,status:u.status,duration:u.duration,error:u.error}}))].sort((u,d)=>u.ts-d.ts).slice(-Ga)},clear(){t.length=0;},destroy(){o(),window.removeEventListener("hashchange",e),document.removeEventListener("click",i,true);}}}function Sp(t){let e=(t.textContent??"").replace(/\s+/g," ").trim();return e?e.slice(0,80):void 0}var xp=6e4,Rp=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,kp=/^[0-9a-f]{20,}$/i,_p=/^\d+$/,Cp=/^[a-z0-9]{16,}$/i;function Ya(t){return t.length===0?t:Rp.test(t)||kp.test(t)||_p.test(t)||Cp.test(t)&&/\d/.test(t)?"[id]":t}function Tp(t,e,r){if(e.startsWith("#/")){let n=e.slice(1),i=n.indexOf("?"),o=i===-1?n:n.slice(0,i),a=r?.map(s=>s.startsWith("/#/")?s.slice(2):s);return "/#"+_i(o,a)}return _i(t,r)}function _i(t,e){let r=t.length>1&&t.endsWith("/")?t.slice(0,-1):t;if(e?.length){let n=Ap(r,e);if(n)return n}return "/"+r.split("/").filter(n=>n.length>0).map(Ya).join("/")}function Ap(t,e){let r=t.split("/").filter(i=>i.length>0),n=[...e].sort((i,o)=>o.split("/").length-i.split("/").length);for(let i of n){let o=i.split("/").filter(s=>s.length>0);if(o.length!==r.length)continue;let a=true;for(let s=0;s<o.length;s++){let u=o[s],d=r[s];if(!(u.startsWith("[")&&u.endsWith("]"))&&!u.startsWith(":")&&u!==d){a=false;break}}if(a)return "/"+o.join("/")}return null}function Ip(){if(typeof document>"u")return [];let t=new Set,e=document.querySelectorAll("[data-testid]");for(let r of Array.from(e)){let n=r.getAttribute("data-testid");n&&n.length>0&&n.length<120&&t.add(n);}return Array.from(t).sort()}function Mp(){if(typeof window>"u")return [];try{let t=new Set,e=i=>{new URLSearchParams(i).forEach((o,a)=>t.add(a));};e(window.location.search);let r=window.location.hash,n=r.indexOf("?");return r.startsWith("#/")&&n!==-1&&e(r.slice(n+1)),Array.from(t).sort()}catch{return []}}function Lp(){if(typeof document>"u")return null;let t=i=>(i??"").replace(/\s+/g," ").trim().slice(0,200),e=t(document.querySelector("h1")?.textContent);if(e)return e;let r=t(document.title);return r||t(document.querySelector("main")?.textContent)||null}async function Pp(t){if(!t||typeof crypto>"u"||!crypto.subtle)return null;try{let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e),n=new Uint8Array(r),i="";for(let o=0;o<n.length;o++)i+=n[o].toString(16).padStart(2,"0");return i}catch{return null}}function Ci(t){let{config:e,getRecentNetworkPaths:r,getUserId:n,getSessionId:i,onEvent:o}=t,a=e.throttleMs??xp,s=e.captureDomSummary!==false,u=e.userIdSource??"auto",d=new Map,p=null,h=null;async function k(){if(typeof window>"u")return;let L=Tp(window.location.pathname,window.location.hash,e.routeTemplates),M=Date.now(),x=d.get(L)??0;if(M-x<a)return;d.set(L,M);let f=null;u==="auto"?f=n()??i():u==="session-only"&&(f=i());let g={route:L,page_title:typeof document<"u"&&(document.title||"").slice(0,300)||null,dom_summary:s?Lp():null,testids:Ip(),network_paths:r().slice(-50),query_param_keys:Mp(),user_id_hash:await Pp(f),observed_at:new Date().toISOString()};o(g);}function S(){h||(h=setTimeout(()=>{h=null,k();},100));}function T(){if(typeof window>"u")return;let L=window.location.hash.startsWith("#/")?window.location.hash:"",M=window.location.pathname+window.location.search+L;M!==p&&(p=M,S());}if(typeof window>"u")return {destroy:()=>{},flushNow:()=>{}};let E=()=>T(),w=Me({onPush:E,onReplace:E,onPop:E});return window.addEventListener("hashchange",E),S(),{destroy(){w(),window.removeEventListener("hashchange",E),h&&(clearTimeout(h),h=null),d.clear();},flushNow(){d.clear(),k();}}}var Dp=3e4,Ai=400,$p=4,Op=2;function Xa(t,e,r){let n=u=>u.timestamp,i=u=>u.type===Op,o=u=>u.type===$p,a=Date.now()-e,s=0;for(let u=0;u<t.length;u++){let d=n(t[u]);if(typeof d=="number"&&d>=a)break;i(t[u])&&(s=o(t[u-1])?u-1:u);}if(t.length-s>r){for(let u=s+1;u<t.length;u++)if(i(t[u])&&t.length-u<=r){s=o(t[u-1])?u-1:u;break}}s>0&&t.splice(0,s);}function Ja(t){let e=[],r=false,n=o=>{if(!r)return;let a=o.target instanceof Element?o.target:null,s=a?.tagName?.toLowerCase()??"unknown",u=a?.closest("[data-testid]")?.getAttribute("data-testid")??void 0;e.push({type:"lite_click",timestamp:Date.now(),data:{tag:s,testId:u}}),e.length>Ai&&e.shift();},i=()=>{r=false,document.removeEventListener("click",n,true);};return {start(){r||(r=true,document.addEventListener("click",n,true));},stop:i,flush(){let o=Date.now()-t;return e.filter(a=>a.timestamp>=o)},destroy(){i(),e.length=0;}}}var Hp=['input[type="password"]',"[data-mushi-redact]"],Bp="rrweb",Oe=null,Qa=false;function Ti(t){if(!t||typeof t!="object")return null;let e=t;return typeof e.record=="function"?e:e.default&&typeof e.default.record=="function"?e.default:null}async function Fp(t){if(Oe)return Oe;if(typeof t=="function")try{if(Oe=Ti(await t()),Oe)return Oe}catch{}if(Oe=Ti(globalThis.rrweb),Oe)return Oe;try{let e=globalThis.__MUSHI_RRWEB_SPECIFIER__||Bp;return Oe=Ti(await import(e)),Oe}catch{return null}}async function Za(t){let e=t.maxDurationMs??Dp;if(t.mode==="lite")return Ja(e);let r=await Fp(t.loadRrweb);if(!r?.record)return Qa||(Qa=true,Tt({scope:"mushi"}).warn("capture.replay is 'rrweb' but rrweb could not be loaded, so replay is recording clicks only. Install rrweb and pass capture: { rrweb: () => import('rrweb') }.")),Ja(e);let n=r.record,i=[],o=null,a=false,s=[...new Set([...Hp,...t.redactSelectors??[]])],u=()=>{o?.(),o=null,a=false;};return {start(){a||(a=true,o=n({emit(d){i.push(d),Xa(i,e,Ai);},maskAllInputs:true,maskTextSelector:"*",blockSelector:s.join(","),checkoutEveryNms:e,sampling:{mousemove:false,mouseInteraction:true,scroll:150,media:800}})??null);},stop:u,flush(){return Xa(i,e,Ai),[...i]},destroy(){u(),i.length=0;}}}function eu(){try{let t=globalThis;return t.Sentry?t.Sentry:void 0}catch{return}}function Np(){try{return globalThis.__SENTRY_REPLAY__}catch{return}}function Up(){try{let t=globalThis,e=t.__SENTRY__,r=t.Sentry;return e?.version==="9"||r&&typeof r.lastEventId=="function"?e?.version==="9"?"v9":"v8":e?.version==="8"?"v8":r&&typeof r.getCurrentHub=="function"?"v7":"unknown"}catch{return "unknown"}}function Ii(t,e={}){let r=Math.max(0,e.breadcrumbsLimit??30),n={},i=eu();if(!i)return n;n.sdk=Up();try{let s=i;if(typeof s.lastEventId=="function")n.eventId=s.lastEventId()??void 0;else {let d=i.getCurrentHub?.()?.getScope?.();n.eventId=d?.getLastEventId?.()??void 0;}}catch{}let o;try{let s=i;typeof s.getCurrentScope=="function"?o=s.getCurrentScope():o=i.getCurrentHub?.()?.getScope?.();}catch{}if(o){try{let s=o.getUser?.();s&&(n.user={id:typeof s.id=="string"?s.id:void 0,email:typeof s.email=="string"?s.email:void 0,username:typeof s.username=="string"?s.username:void 0,ip_address:typeof s.ip_address=="string"?s.ip_address:void 0});}catch{}try{let s=o.getTags?.();if(s&&typeof s=="object"){let u={};for(let[d,p]of Object.entries(s))(typeof p=="string"||typeof p=="number"||typeof p=="boolean")&&(u[d]=p);Object.keys(u).length>0&&(n.tags=u);}}catch{}try{n.transactionName=o.getTransactionName?.()??o.getTransaction?.()?.name??void 0;}catch{}try{n.sessionId=o.getSession?.()?.sid??void 0;}catch{}try{let s=o.getBreadcrumbs?.()??o._breadcrumbs??[];if(Array.isArray(s)&&s.length>0){let u=s.slice(-r);n.breadcrumbs=u.map(d=>{let p=d;return {timestamp:typeof p.timestamp=="number"?p.timestamp<1e12?Math.round(p.timestamp*1e3):p.timestamp:void 0,category:typeof p.category=="string"?p.category:void 0,level:typeof p.level=="string"?p.level:void 0,message:typeof p.message=="string"?p.message:void 0,type:typeof p.type=="string"?p.type:void 0,data:p.data&&typeof p.data=="object"?p.data:void 0}});}}catch{}}try{let s=i,u;if(typeof s.getActiveSpan=="function"?u=s.getActiveSpan():o?.getSpan&&(u=o.getSpan()),u){let d=u.spanContext?.();n.traceId=d?.traceId??u.traceId??void 0,n.spanId=d?.spanId??u.spanId??void 0;}}catch{}let a;try{let s=i;typeof s.getClient=="function"?a=s.getClient():a=i.getCurrentHub?.()?.getClient?.();}catch{}if(a){try{let s=a.getOptions?.();s?.release&&(n.release=s.release),s?.environment&&(n.environment=s.environment);}catch{}try{let s=a.getDsn?.();if(s?.host&&s?.projectId&&n.eventId){let u=s.host.replace(/^o\d+\./,"");n.issueUrl=`https://${u}/issues/?query=${encodeURIComponent(n.eventId)}`;}}catch{}}try{let u=i.getReplay?.()??Np();n.replayId=u?.getReplayId?.()??void 0;}catch{}return n}function Mi(t,e={}){let r=eu();if(r){try{let n=r;typeof n.setTag=="function"&&(n.setTag("mushi.report_id",t),e.reportUrl&&n.setTag("mushi.report_url",e.reportUrl)),typeof n.setContext=="function"&&n.setContext("mushi_report",{id:t,...e.reportUrl?{url:e.reportUrl}:{},captured_at:new Date().toISOString()}),typeof n.addBreadcrumb=="function"&&n.addBreadcrumb({category:"mushi",type:"info",level:"info",message:`Mushi report submitted (${t})`,data:{report_id:t,...e.reportUrl?{url:e.reportUrl}:{}}});}catch{}try{let i=r.getCurrentHub?.()?.getScope?.();i&&(i.setTag?.("mushi.report_id",t),e.reportUrl&&i.setTag?.("mushi.report_url",e.reportUrl),i.setContext?.("mushi_report",{id:t,...e.reportUrl?{url:e.reportUrl}:{}}));}catch{}}}var qp=["/login","/logout","/signup","/sso/*","/auth/*"];function ru(t,e={}){let r=[];if(e.rageClick!==false){let E=function(w){let L=Date.now();if(w.target===T){if(S.push(L),S=S.filter(M=>L-M<500),S.length>=3){let M=w.target;t.onTrigger("rage_click",{element:M.tagName,id:M.id,text:M.textContent?.slice(0,50)}),S=[];}}else T=w.target,S=[L];};let S=[],T=null;document.addEventListener("click",E,true),r.push(()=>document.removeEventListener("click",E,true));}if(e.longTask!==false&&typeof PerformanceObserver<"u")try{let S=new PerformanceObserver(T=>{for(let E of T.getEntries())E.duration>5e3&&t.onTrigger("long_task",{duration:Math.round(E.duration),startTime:Math.round(E.startTime)});});S.observe({entryTypes:["longtask"]}),r.push(()=>S.disconnect());}catch{}let n=jp(e.apiCascade);if(n.enabled){let S=[],T=globalThis.fetch;globalThis.fetch=async function(...E){let[w,L]=E,M=tn(w),x=!!rn(w,L)||gr(M,{apiEndpoint:e.apiEndpoint,ignoreUrls:n.ignoreUrls});try{let f=await T.apply(this,E);return !x&&!f.ok&&f.status>=400&&tu(S,t),f}catch(f){throw x||tu(S,t),f}},r.push(()=>{globalThis.fetch=T;});}if((e.pageDwell===true||typeof e.pageDwell=="object"&&e.pageDwell!==null)&&typeof window<"u"){let M=function(b){return E.some(C=>C.endsWith("/*")?b.startsWith(C.slice(0,-2)):b===C||b.startsWith(C+"/"))},x=function(){let b=window.location?.pathname??"";M(b)||t.onTrigger("page_dwell",{thresholdMs:T,path:b});},f=function(){w&&clearTimeout(w);let b=window.location?.pathname??"";M(b)||(w=setTimeout(x,T));},g=function(){let b=window.location?.pathname??"";b!==L&&(L=b,f());};let S=typeof e.pageDwell=="object"?e.pageDwell??{}:{},T=S.thresholdMs||300*1e3,E=S.excludeRoutes!==void 0?S.excludeRoutes:qp,w=null,L=window.location?.pathname??"";f();let m=Me({onPush:g,onReplace:g,onPop:g});r.push(()=>{w&&clearTimeout(w),m();});}if((e.firstSession===true||typeof e.firstSession=="object"&&e.firstSession!==null)&&typeof window<"u"){let S=typeof e.firstSession=="object"?e.firstSession??{}:{},T=S.delayMs??45*1e3,E=S.storageKey??(e.projectId?`mushi:${e.projectId}:firstSessionShown`:"mushi:firstSessionShown"),w=false;try{w=window.localStorage?.getItem(E)==="1";}catch{}if(!w){let L=setTimeout(()=>{try{window.localStorage?.setItem(E,"1");}catch{}t.onTrigger("first_session",{delayMs:T});},T);r.push(()=>clearTimeout(L));}}if(e.errorBoundary){let S=function(E){or({message:E.message,filename:E.filename,ignoreErrors:e.ignoreErrors,denyUrls:e.denyUrls,allowUrls:e.allowUrls})||t.onTrigger("error_boundary",{message:E.message,filename:E.filename,lineno:E.lineno,colno:E.colno});},T=function(E){let w=E.reason instanceof Error?E.reason.message:String(E.reason);or({message:w,ignoreErrors:e.ignoreErrors,denyUrls:e.denyUrls,allowUrls:e.allowUrls})||t.onTrigger("error_boundary",{message:w,type:"unhandled_rejection"});};window.addEventListener("error",S),window.addEventListener("unhandledrejection",T),r.push(()=>{window.removeEventListener("error",S),window.removeEventListener("unhandledrejection",T);});}return {destroy(){r.forEach(S=>S());}}}function jp(t){return t===false?{enabled:false,ignoreUrls:[]}:t&&typeof t=="object"?{enabled:t.enabled!==false,ignoreUrls:t.ignoreUrls??[]}:{enabled:true,ignoreUrls:[]}}function tu(t,e){let r=Date.now();t.push(r);let n=t.filter(i=>r-i<1e4);n.length>=3&&(e.onTrigger("api_cascade",{failureCount:n.length,windowMs:1e4}),t.length=0);}var nu="mushi:lastDismiss",nn="mushi:consecDismiss",Li="mushi:lastShown";function on(t){try{return localStorage.getItem(t)}catch{return null}}function sn(t,e){try{localStorage.setItem(t,e);}catch{}}function iu(t={}){let e=t.maxProactivePerSession??2,r=t.dismissCooldownHours??24,n=t.suppressAfterDismissals??3,i=(t.reshowCooldownMinutes??30)*60*1e3,o=0,a=new Set;function s(h){let k=Date.now();if(parseInt(on(nn)??"0",10)>=n)return false;let T=on(nu);if(T&&k-parseInt(T,10)<r*60*60*1e3)return false;if(i>0&&o===0){let E=on(Li);if(E&&k-parseInt(E,10)<i)return false}return o>=e||a.has(h)?false:(a.add(h),o++,sn(Li,String(k)),true)}function u(){sn(nu,String(Date.now()));let h=parseInt(on(nn)??"0",10);sn(nn,String(h+1));}function d(){sn(nn,"0");}function p(){o=0,a.clear();try{localStorage.removeItem(Li);}catch{}}return {shouldShow:s,recordDismissal:u,recordSubmission:d,reset:p}}var Ye="@mushi-mushi/web",we="1.31.1";function lu(t,e){if(t.appVersion)return t.appVersion;let r=t.integrations?.vercel?.analyticsId;return r||e?.buildId}var He=null,an=class{constructor(){}static init(e){if(He)return Tt({scope:"mushi",level:"warn",format:"pretty"}).warn("Already initialized \u2014 call destroy() first to reinitialize"),He;if(typeof document>"u"||typeof window>"u")return du();let r={...Ln(),...e};if(!r.projectId||!r.apiKey){let n=Bo();throw new Error(n.message??"[mushi] projectId and apiKey are required \u2014 set NEXT_PUBLIC_MUSHI_* / VITE_MUSHI_* / MUSHI_* or pass them explicitly")}return r.enabled===false?du():(He=Kp(r),He)}static getInstance(){return He}static destroy(){He?.destroy(),He=null;}static diagnose(){return He?.diagnose()??Di()}};function Kp(t){No(t);let e=Fo(t),r=e.projectId,n=()=>te(r),i=e,o=t.debug??false?Tt({scope:"mushi",level:"debug",format:"pretty"}):Pn,a=null,s=null,u=Ho({projectId:e.projectId,apiKey:e.apiKey,...e.apiEndpoint?{apiEndpoint:e.apiEndpoint}:{},...typeof e.timeout=="number"?{timeout:e.timeout}:{},...typeof e.maxRetries=="number"?{maxRetries:e.maxRetries}:{},...e.circuitBreaker?{circuitBreaker:e.circuitBreaker}:{},...e.tunnel?{tunnel:e.tunnel}:{},getUserToken:()=>a,sdkPackage:Ye,sdkVersion:we}),d=null;if(e.trackSessions!==false){ts({client:u,sdkVersion:we,reporterToken:te(e.projectId)??null,projectId:e.projectId,analytics:e.analytics});try{d=Me({onPush:()=>Bn(),onPop:()=>Bn()});}catch{}}let p=Uo(e.preFilter),h=Ko(e.offline),k=fs({maxBurst:10,refillRate:1,refillIntervalMs:5e3}),S=Un();ls({client:u,projectId:e.projectId,sdkVersion:we,config:e.analytics,scrub:l=>S.scrub(l),getSessionId:bt});function T(l){return l.map(c=>{let y={...c};if(typeof c.message=="string"&&(y.message=S.scrub(c.message)),c.data&&typeof c.data=="object"){let I={};for(let[$,N]of Object.entries(c.data))I[$]=typeof N=="string"?S.scrub(N):N;y.data=I;}return y})}function E(l){return l&&l.map(c=>({...c,message:S.scrub(c.message),...c.stack?{stack:S.scrub(c.stack)}:{}}))}function w(l){if(!l)return;let c={};for(let[y,I]of Object.entries(l))c[y]=typeof I=="string"?S.scrub(I):I;return c}let L=null,M=null,x=null,f=null,g=null,m=null,b=ki(),C=null,P=0,v,K=`mushi:tester-jwt:${e.projectId}`;function Y(){try{return typeof localStorage<"u"?localStorage.getItem(K):null}catch{return null}}function j(){try{typeof localStorage<"u"&&localStorage.removeItem(K);}catch{}}async function ke(l){let c=await u.getTesterStatus(l);if(!c.ok||!c.data){j();return}let y=c.data;if(!y.is_tester||!y.tester_id){j();return}v.setTesterSession(l,{id:y.tester_id,public_handle:y.public_handle??null,display_name:y.display_name??null});let I=await u.getMyReputation(l);if(I.ok&&I.data){let $=I.data;$.reputation&&v.setTesterReputation($.reputation);}}function Be(){if(i.capture?.console!==false?L??=bi():(L?.destroy(),L=null),i.capture?.network!==false){let B={apiEndpoint:Pi(i),ignoreUrls:i.capture?.ignoreUrls,tracePropagation:i.capture?.tracePropagation,sessionId:bt()};M?M.updateOptions(B):M=gi(B);}else M?.destroy(),M=null;if(i.capture?.performance!==false?x??=xi():(x?.destroy(),x=null),i.capture?.screenshot!=="off"){let B={privacy:i.privacy,onFailed:Z=>v.setScreenshotError(true,Z)};i.capture?.screenshotProvider?f=null:f?f.updateOptions(B):f=wi(B);}else f=null;!f&&!i.capture?.screenshotProvider&&(O=null),v.setAllowScreenshotRemove(i.privacy?.allowUserRemoveScreenshot!==false),i.capture?.elementSelector!==false?g??=Ri():(g?.deactivate(),g=null,G=null),v.setCaptureAvailability({screenshot:(!!f||!!i.capture?.screenshotProvider)&&i.capture?.screenshot!=="off",element:!!g});let l=i.capture?.discoverInventory,c=l===true?{}:l&&typeof l=="object"?l:null;c!=null&&c.enabled!==false?(m?.destroy(),m=Ci({config:c,getRecentNetworkPaths:()=>M?M.getEntries().map(B=>{try{let Z=new URL(B.url,typeof window<"u"?window.location.href:"http://localhost");return Z.host&&typeof window<"u"&&Z.host!==window.location.host?null:Z.pathname}catch{return null}}).filter(B=>B!=null&&B.length>0&&B.length<200):[],getUserId:()=>R?.id??null,getSessionId:bt,onEvent:B=>{u.postDiscoveryEvent({...B,sdk_version:we}).catch(Z=>{o.debug("discovery emit failed",{err:String(Z)});});}})):(m?.destroy(),m=null);let I=i.capture?.replay??"off",$=i.replaySampleRate??1,N=$>=1||Math.random()<$,Q=i.replaysOnErrorSampleRate??0,ue=!N&&Q>0&&Math.random()<Q;if((I==="rrweb"||I==="lite")&&(N||ue)){let B=++P;Za({mode:I,loadRrweb:e.capture?.rrweb,redactSelectors:i.privacy?.redactSelectors}).then(Z=>{if(B!==P){Z.destroy();return}C?.destroy(),C=Z,C.start();});}else P++,C?.destroy(),C=null;}let me=new Map;function J(l,c){me.get(l)?.forEach(y=>y({type:l,data:c}));}let O=null,G=null,re=null,_e=false,Ce=true,Le=null,A=null,R=null,H=null,F={},U={},X=gs({max:50});X.add({category:"lifecycle",level:"info",message:"Mushi SDK init",data:{projectId:e.projectId,sdkVersion:we}});let Xe=null;Xe=rh(X);let Fe=false,it=false,he=new Set,ie=Ra(u);async function ge(){let l=await ie.getUpdates(n()),c=l.ok?l.data??null:null;if(c)for(let y of he)try{y(c);}catch{}return c}function Nt(){v.refreshReporterInboxQuiet(),he.size&&ge();}function z(){Le&&clearInterval(Le),Le=null,A&&typeof document<"u"&&document.removeEventListener("visibilitychange",A),A=null;}function Ut(){if(z(),!Ce)return;let l=5*6e4,c=()=>{typeof document<"u"&&document.visibilityState==="hidden"||ii(r)&&Nt();};Le=setInterval(c,l),typeof document<"u"&&(A=()=>{document.visibilityState==="visible"&&c();},document.addEventListener("visibilitychange",A)),c();}let ot=null;function st(){let l=i.notifications??e.notifications;v.setReporterChannels({email:!!ot?.emailEnabled&&l?.email!==false,push:!!(ot?.pushEnabled&&ot.vapidPublicKey)&&!!l?.webPush,emailPrefill:l?.emailFromIdentity?R?.email??"":""});}let St=[];function fu(){if(!ii(r))return;let l=globalThis.requestIdleCallback;if(l?l(()=>{v.preloadViews();},{timeout:8e3}):setTimeout(()=>{v.preloadViews();},3e3),e.notifications?.toast===false||!Sa(r))return;let c=async()=>{let I=await ge(),$=I&&typeof I.unread_total=="number"&&Array.isArray(I.latest)?I:null;if($&&!$.unread_total)return;await v.refreshReporterInboxQuiet(),($?v.showUpdatesFeedToast($,St):await v.showUpdatesToast(St))&&xa(r);},y=globalThis.requestIdleCallback;y?y(()=>{c();},{timeout:5e3}):setTimeout(()=>{c();},2e3);}async function mu(l){let c=te(r),y=await ie.markReportRead(l,c);if(y.ok)return y.data?.unread_total??null;let I=await u.listNotifications(c,{limit:50});if(!I.ok)return null;let $=(I.data?.notifications??[]).filter(N=>{let Q=N.payload??{};return !N.read_at&&(Q.reportId===l||N.report_id===l)});return await Promise.all($.map(N=>u.markNotificationRead(String(N.id),c))),null}function Oi(l,c){if(!i.rewards?.enabled)return;let y={client:u,config:i.rewards,projectId:r,userId:l,traits:c,reporterToken:n()};Ha(y),i.rewards.showInWidget!==false&&u.getMyPoints(l).then(I=>{if(!I.ok)return;let $=I.data;v.setRewardsState({tier:$.tier?{slug:$.tier.slug??"free",displayName:$.tier.display_name??"Free",pointsThreshold:$.tier.points_threshold??0}:null,nextTier:$.next_tier?{displayName:$.next_tier.display_name??"",pointsThreshold:$.next_tier.points_threshold??0}:null,totalPoints:$.total_points??0,pointsForReport:$.report_submit_pts??50});}).catch(()=>{});}async function Hi(){if(Fe)return null;it=false;let l=i.capture?.screenshotProvider;if(l){Fe=true;try{let $=await l();if($)return $}catch($){o.warn("screenshotProvider threw, falling back to built-in capturer",{error:$ instanceof Error?$.message:String($)}),it=$ instanceof Error&&($.name==="NotAllowedError"||$.name==="SecurityError"||/permission|denied/i.test($.message));}finally{Fe=false;}}if(!f)return null;Fe=true;let c=v.getIsOpen();c&&v.hidePanel();let y=document.getElementById("mushi-mushi-widget"),I=y?.style.visibility??"";y&&(y.style.visibility="hidden"),await new Promise($=>{requestAnimationFrame(()=>requestAnimationFrame(()=>$()));});try{return await f.take()}finally{Fe=false,y&&(y.style.visibility=I),c&&v.showPanel();}}async function Bi(l){let c=i.capture?.screenshot;!(f||i.capture?.screenshotProvider)||c==="off"||O||l==="open"&&c!=="auto"||l==="submit"&&c!=="on-report"&&c!=="auto"||(o.debug("Auto-capturing screenshot",{when:l,mode:c}),O=await Hi(),v.setScreenshotAttached(O!==null),v.setScreenshotPreview(O));}let un=nr(r).then(l=>l.slice(0,12)).catch(()=>null);v=new Yr(e.widget,{onSubmit:async({category:l,userCategory:c,description:y,intent:I})=>(o.info("Report submitted",{category:l,userCategory:c,intent:I}),qt?.recordSubmission(),await Bi("submit"),await bu(l,y,I,c)??{reportId:null,queuedOffline:true}),onOpen:()=>{o.debug("Widget opened"),Bi("open"),C?.start(),J("widget:opened");},onBrandFooterImpression:()=>{un.then(l=>{Ct("loop_impression",{placement:"widget"},l?{reserved:{$ref:l}}:void 0);});},onBrandFooterClick:()=>{un.then(l=>(Ct("loop_click",{placement:"widget"},l?{reserved:{$ref:l}}:void 0),ps()));},onClose:()=>{o.debug("Widget closed"),re&&(qt?.recordDismissal(),J("proactive:dismissed",{type:re})),O=null,G=null,re=null,J("widget:closed");},onScreenshotRequest:async()=>{if(!(!!f||!!i.capture?.screenshotProvider)||i.capture?.screenshot==="off"){o.warn("Screenshot requested but capture is disabled"),v.setScreenshotError(true,"unsupported");return}if(!Fe){o.debug("Taking screenshot"),v.setScreenshotCapturing(true);try{O=await Hi();}catch(c){o.warn("Screenshot capture threw",{error:c instanceof Error?c.message:String(c)}),O=null;}v.setScreenshotAttached(O!==null),v.setScreenshotPreview(O),O===null&&v.setScreenshotError(true,it?"permission":void 0);}},onScreenshotShareTabRequest:typeof navigator<"u"&&typeof navigator.mediaDevices?.getDisplayMedia=="function"?()=>{let l=navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:false,preferCurrentTab:true,selfBrowserSurface:"include"});l.catch(()=>{}),v.setScreenshotCapturing(true);let c=document.getElementById("mushi-mushi-widget");c&&(c.style.visibility="hidden");let y=i.privacy;Promise.resolve().then(()=>(su(),ou)).then(I=>I.grabMaskedTabFrame(l,[Si,"[data-mushi-redact]",...y?.redactSelectors??[],...y?.maskSelectors??[],...y?.blockSelectors??[]]),I=>{throw l.then($=>$.getTracks().forEach(N=>N.stop()),()=>{}),I}).then(I=>{O=I,v.setScreenshotAttached(true),v.setScreenshotPreview(I);}).catch(I=>{o.warn("Tab capture failed",{error:I instanceof Error?I.name:String(I)}),v.setScreenshotError(true,I instanceof Error&&I.name==="NotAllowedError"?"permission":"error");}).finally(()=>{c&&(c.style.visibility="");});}:void 0,onScreenshotRemove:()=>{o.debug("Screenshot attachment removed"),O=null,v.setScreenshotAttached(false);},onScreenshotAnnotateRequest:async l=>{if(!O||l.childElementCount>0)return;let c;try{let{createScreenshotAnnotation:Q}=await Promise.resolve().then(()=>(uu(),au));c=await Q(O,l);}catch(Q){o.warn("Screenshot annotation failed",{error:Q instanceof Error?Q.message:String(Q)});return}let y=document.createElement("div");y.className="mushi-annotate-toolbar";let I=Q=>{(O=c.getDataUrl(),v.setScreenshotAttached(true),v.setScreenshotPreview(O)),c.destroy(),y.remove();},$=[{id:"highlight",label:"\u270F\uFE0F Highlight"},{id:"blur",label:"\u{1F512} Blur"},{id:"arrow",label:"\u2197\uFE0F Arrow"}];for(let Q of $){let ue=document.createElement("button");ue.type="button",ue.className="mushi-attach-btn",ue.dataset.tool=Q.id,ue.textContent=Q.label,ue.addEventListener("click",()=>{c.setTool(Q.id),y.querySelectorAll("button[data-tool]").forEach(B=>B.classList.remove("active")),ue.classList.add("active");}),y.appendChild(ue);}y.querySelector('button[data-tool="highlight"]')?.classList.add("active");let N=document.createElement("button");N.type="button",N.className="mushi-attach-btn",N.textContent="\u2713 Done",N.addEventListener("click",()=>I()),y.appendChild(N),l.insertBefore(y,l.firstChild);},onElementSelectorRequest:async()=>{if(!g||i.capture?.elementSelector===false){o.warn("Element selector requested but it is disabled/unavailable"),v.setElementError(true);return}o.debug("Element selector activated"),v.setElementCapturing(true),v.hidePanel();try{let l=await g.activate();l?(G=l,v.setElementSelected(!0),o.debug("Element selected",{tagName:l.tagName,xpath:l.xpath})):v.setElementCapturing(!1);}catch(l){o.warn("Element selector threw",{error:l instanceof Error?l.message:String(l)}),v.setElementError(true);}finally{v.showPanel();}},async onReporterReportsRequest(){let l=await u.listReporterReports(te(r));if(!l.ok)throw new Error(l.error?.message??"Could not load reports");return St=l.data?.reports??[],St.length&&ni(r),St},onReporterMarkRead:l=>mu(l),async onReporterReportRequest(l){let c=await ie.getReport(l,te(r));return c.ok&&c.data?{report:c.data.report,timeline:c.data.timeline}:null},async onReporterEmailOptIn(l){let c=await ie.setPrefs(te(r),{email:l,channels:{email:true}});if(!c.ok)throw new Error(c.error?.code??"EMAIL_OPT_IN_FAILED")},async onReporterPushSubscribe(){let l=await cn.subscribeReporterPush();if(!l.ok)throw new Error(l.reason)},async onReporterCommentsRequest(l){let c=await u.listReporterComments(l,te(r));if(!c.ok)throw new Error(c.error?.message??"Could not load thread");return c.data?.comments??[]},async onReporterReply(l,c){let y=await u.replyToReporterReport(l,te(r),c);if(!y.ok)throw new Error(y.error?.message??"Could not send reply")},async onReporterFeedback(l,c,y){let I=await u.replyToReporterReport(l,te(r),y??"",c);if(!I.ok)throw new Error(I.error?.message??"Could not send feedback");return I.data?.feedback??null},async onReporterReopen(l,c){let y=await u.reopenReporterReport(l,te(r),c);if(!y.ok)throw new Error(y.error?.message??"Could not reopen report");return y.data?.outcome??null},async onFeatureBoardRequest(){let l=await u.listReporterFeatureBoard(te(r));if(!l.ok)throw new Error(l.error?.message??"Could not load community ideas");return l.data?.tickets??[]},async onFeatureBoardVote(l){let c=await u.voteReporterFeatureBoard(l,te(r));if(!c.ok)throw new Error(c.error?.message??"Could not vote");return c.data??{voted:true,action:"added"}},onLeaderboardOpen(){v.setLeaderboard(null,true),Fa(10).then(l=>{v.setLeaderboard(l,false);});},async onMushiSignIn(l){let c=await u.sendMagicLink(l);if(!c.ok)throw new Error(c.error?.message??"Could not send sign-in link");return {ok:true}},async onGlobalLeaderboardOpen(){v.setGlobalLeaderboard(null,true);try{let l=Y(),c=await u.getPublicLeaderboard(50),I=(c.ok?c.data?.leaderboard??[]:[]).map($=>({tester_id:$.tester_id,rank:$.rank,public_handle:$.public_handle,display_name:$.display_name,points_30d:$.points_30d,total_points:$.total_points??0,badge:$.badge_slug}));if(v.setGlobalLeaderboard(I,!1),l){let $=await u.getMyReputation(l);if($.ok&&$.data){let N=$.data;N.reputation&&v.setTesterReputation(N.reputation);}}}catch{v.setGlobalLeaderboard([],false);}},async onCrossAppReportsOpen(){let l=Y();if(!l){v.setCrossAppReports([],false);return}try{let c=await u.getCrossAppReports(l),y=c.ok?c.data?.reports??[]:[];v.setCrossAppReports(y,!1);}catch{v.setCrossAppReports([],false);}},onTesterSignOut(){j();},assistantEnabled:e.assistant?.enabled===true,...e.assistant?.label?{assistantLabel:e.assistant.label}:{},...e.assistant?.greeting?{assistantGreeting:e.assistant.greeting}:{},...e.assistant?.suggestions?{assistantSuggestions:e.assistant.suggestions}:{},async onAssistantAsk(l,c){let y=await u.askAssistant({message:l,threadId:c,context:s});return y.ok?y.data??null:null}}),un.then(l=>v.setBrandRef(l)),Be(),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>v.mount()):v.mount());let Fi=Y();Fi&&ke(Fi).catch(()=>j());let Ni=null,qt=null,ee=i.proactive;ee&&(ee.rageClick!==false||ee.longTask!==false||ee.apiCascade!==false||ee.errorBoundary===true||ee.pageDwell||ee.firstSession)&&typeof document<"u"&&(qt=iu(ee?.cooldown),Ni=ru({onTrigger:(l,c)=>{if(typeof navigator<"u"&&!navigator.onLine){o.debug("Proactive trigger suppressed: offline",{type:l});return}if(!qt.shouldShow(l)){o.debug("Proactive trigger suppressed by fatigue prevention",{type:l});return}o.info("Proactive trigger fired",{type:l,context:c}),re=l,J("proactive:triggered",{type:l,context:c}),l==="first_session"?v.pulseTrigger?.():v.open();}},{rageClick:ee?.rageClick,longTask:ee?.longTask,apiCascade:ee?.apiCascade,apiEndpoint:Pi(i),errorBoundary:ee?.errorBoundary,ignoreErrors:i.ignoreErrors,denyUrls:i.denyUrls,allowUrls:i.allowUrls,pageDwell:ee?.pageDwell,firstSession:ee?.firstSession,projectId:e.projectId}),o.debug("Proactive triggers enabled",{rageClick:ee?.rageClick!==false,longTask:ee?.longTask!==false,apiCascade:ee?.apiCascade!==false,errorBoundary:ee?.errorBoundary===true,pageDwell:!!ee?.pageDwell,firstSession:!!ee?.firstSession})),h.startAutoSync(u),h.flush(u).then(l=>{l.sent>0&&o.info("Synced offline reports",{sent:l.sent});});function ln(l){if(_e=true,Ce=l.reporterNotificationsEnabled!==false,ot=l.enabled===false?null:l.reporter??null,st(),l.enabled===false){i=e,Qp(t.projectId),Be(),v.updateConfig(i.widget),z(),o.debug("Runtime SDK config disabled; using bootstrap config",{version:l.version});return}i=_a(i,l,e),Be(),l.widget&&v.updateConfig(i.widget),Ce?Ut():z(),o.debug("Applied runtime SDK config",{version:l.version});}if(zp(t)){let l=Xp(t.projectId);l&&ln(l),u.getSdkConfig().then(c=>{c.ok&&c.data?(Jp(t.projectId,c.data),ln(c.data)):c.error&&o.debug("Runtime SDK config unavailable",c.error);}).catch(c=>{o.debug("Runtime SDK config fetch failed",{error:c instanceof Error?c.message:String(c)});});}else o.debug("Runtime SDK config disabled via runtimeConfig:false; using static bootstrap config");gu(),Ut(),fu(),o.info("Initialized",{projectId:t.projectId});async function gu(){if(i.widget?.outdatedBanner==="off")return;let l=Zp(Ye);l&&Ui(l);let c=await u.getLatestSdkVersion(Ye);!c.ok||!c.data||(eh(Ye,c.data),Ui(c.data));}function Ui(l){let c=l.latest,y=!!(c&&th(we,c));if(!y&&!l.deprecated)return;let I=l.deprecationMessage??(y?`Update ${Ye} to ${c}.`:null);o.warn("Mushi SDK is outdated",{package:Ye,current:we,latest:c,deprecated:l.deprecated,message:I}),Ws(i.widget?.outdatedBanner,!!i.debug,typeof location>"u"?void 0:location)&&v.setSdkFreshness({latest:c,current:we,deprecated:l.deprecated,message:I});}async function bu(l,c,y,I){let $=p.check(c);if(!$.passed){o.info("Report blocked by pre-filter",{reason:$.reason});return}let N=t.preFilter?.wasmClassifier;if(N)try{let q=await N.classify({description:c,category:l,url:typeof location<"u"?location.href:void 0,hasScreenshot:O!==null,hasSelectedElement:G!==null,hasNetworkErrors:M?.getEntries()?.some(be=>be.status>=400||!!be.error)??!1,hasConsoleErrors:L?.getEntries()?.some(be=>be.level==="error")??!1,proactiveTrigger:re??void 0});if(q.verdict==="block"){o.info("Report blocked by on-device classifier",{modelId:q.modelId,confidence:q.confidence,reason:q.reason});return}o.debug("On-device classifier verdict",{...q});}catch(q){o.warn("On-device classifier threw \u2014 falling through to server",{error:q instanceof Error?q.message:String(q)});}if(re!==null&&t.sampleRate!==void 0&&t.sampleRate<1&&(t.sampleRate<=0||Math.random()>t.sampleRate)){o.debug("Report dropped by sampleRate",{sampleRate:t.sampleRate,trigger:re});return}if(!k.tryConsume()){o.warn("Report throttled \u2014 rate limit exceeded");return}let ue=S.scrub(p.truncate(c)),B=t.sentry?Ii(t.sentry):void 0,Z=await zo().catch(()=>null),Ne=i.capture?.console===false?void 0:E(L?.getEntries()),Ue=i.capture?.network===false?void 0:M?.getEntries(),br=T(X.getAll()),Wi=w(Object.keys(U).length>0?{...U}:void 0),Vi=B?{...B,...B.breadcrumbs?{breadcrumbs:T(B.breadcrumbs)}:{},...B.tags?{tags:w(B.tags)}:{}}:void 0,Ki=O?await Ds(O).catch(()=>null):null,Er=false;O&&!Ki&&(Er=true,o.warn("Screenshot dropped \u2014 could not compress under wire budget"));let zi=Dn(),Te={id:$n(),projectId:t.projectId,category:l,...I?{userCategory:I}:{},description:ue,userIntent:y,environment:zi,consoleLogs:Ne,networkLogs:Ue,performanceMetrics:i.capture?.performance===false?void 0:x?.getMetrics(),timeline:b.getEntries({consoleLogs:Ne,networkLogs:Ue}),screenshotDataUrl:Ki??void 0,selectedElement:G??void 0,...C?{replayEvents:C.flush()}:{},metadata:{...F,...R?{user:R}:{},...B?.release?{sentryRelease:B.release}:{}},sessionId:bt(),reporterToken:te(r),...Z?{fingerprintHash:Z}:{},appVersion:lu(i,zi),sdkPackage:Ye,sdkVersion:we,proactiveTrigger:re??void 0,...br.length>0?{breadcrumbs:br}:{},...Wi?{tags:Wi}:{},...Vi?{sentryContext:Vi}:{},sentryEventId:B?.eventId,sentryReplayId:B?.replayId,createdAt:new Date().toISOString()};if(X.add({category:"lifecycle",level:"info",message:`Mushi report submitting (${l})`,data:{reportId:Te.id,category:l}}),t.integrations?.custom){let q={addMetadata(be,dn){Te.metadata[be]=dn;},setCategory(be){Te.category=be;},setDescription(be){Te.description=be;}};t.integrations.custom(q);}let W=Te,Gi=t.beforeSend??t.beforeSendFeedback;if(Gi)try{let q=await Promise.race([Promise.resolve(Gi(Te)),new Promise(be=>setTimeout(()=>be(Te),2e3))]);if(q===null){o.info("Report dropped by beforeSend hook",{reportId:Te.id});return}W=q;}catch(q){o.warn("beforeSend hook threw \u2014 sending unmodified report",{error:q instanceof Error?q.message:String(q)});}if(J("report:submitted",{reportId:W.id}),typeof navigator<"u"&&!navigator.onLine)return await h.enqueue(W),o.info("Offline \u2014 report queued",{reportId:W.id}),J("report:queued",{reportId:W.id}),{reportId:null,queuedOffline:true,failureKind:"offline"};let V=await u.submitReport(W);if(!V.ok&&V.error?.code==="PAYLOAD_TOO_LARGE"&&(Array.isArray(W.replayEvents)&&W.replayEvents.length>0&&(o.warn("Report too large \u2014 dropping replay buffer and retrying",{reportId:W.id}),W={...W,replayEvents:void 0},V=await u.submitReport(W)),!V.ok&&V.error?.code==="PAYLOAD_TOO_LARGE"&&W.screenshotDataUrl&&(o.warn("Report still too large \u2014 dropping screenshot and retrying",{reportId:W.id}),Er=true,W={...W,screenshotDataUrl:void 0},V=await u.submitReport(W))),V.ok){if(o.info("Report sent",{reportId:V.data?.reportId}),J("report:sent",{reportId:V.data?.reportId}),ni(r),Nt(),V.data?.cursorAgentId){let q=V.data;J("report:dispatched",{reportId:q.reportId,agentId:q.cursorAgentId,fixId:q.fixId});}X.add({category:"lifecycle",level:"info",message:`Mushi report sent (${V.data?.reportId??Te.id})`}),Ft({action:"report_submit",metadata:{category:l,reportId:V.data?.reportId??Te.id}});try{t.sentry&&V.data?.reportId&&Mi(V.data.reportId);}catch{}}else {if(V.error?.code==="PAYLOAD_TOO_LARGE"||V.error?.code==="SERIALIZE_FAILED")return o.warn("Report exceeds size limit after degradation \u2014 dropping",{reportId:W.id,error:V.error}),J("report:failed",{reportId:W.id,error:V.error}),X.add({category:"lifecycle",level:"error",message:`Mushi report dropped \u2014 payload too large (${W.id})`}),O=null,G=null,re=null,{reportId:null,queuedOffline:false,failureKind:"permanent",screenshotDropped:Er};{let q=V.error?.code??"",be=q==="HTTP_429"||q.includes("RATE_LIMIT"),dn=q==="HTTP_401"||q.includes("UNAUTHORIZED")||q.includes("INVALID_API_KEY")||q.includes("MISSING_API_KEY"),Eu=q==="HTTP_403"||q.includes("QUOTA")||q.includes("FORBIDDEN")||q==="feature_not_in_plan";if(dn||Eu)return o.warn("Report rejected \u2014 credentials/quota",{reportId:W.id,error:V.error}),J("report:failed",{reportId:W.id,error:V.error}),O=null,G=null,re=null,{reportId:null,queuedOffline:false,failureKind:"quota"};if(be)return o.warn("Report rate-limited \u2014 queued for retry",{reportId:W.id,error:V.error}),await h.enqueue(W),J("report:failed",{reportId:W.id,error:V.error}),O=null,G=null,re=null,{reportId:null,queuedOffline:true,failureKind:"rate_limited"};o.warn("Report failed, queuing for retry",{reportId:W.id,error:V.error}),await h.enqueue(W),J("report:failed",{reportId:W.id,error:V.error}),X.add({category:"lifecycle",level:"warning",message:`Mushi report queued for retry (${W.id})`});}}return O=null,G=null,re=null,V?.ok?{reportId:V.data?.reportId??Te.id,queuedOffline:false,screenshotDropped:Er}:{reportId:null,queuedOffline:true,failureKind:"retrying"}}let cn={report(l){v.open(l);},on(l,c){return me.has(l)||me.set(l,new Set),me.get(l).add(c),()=>me.get(l)?.delete(c)},setUser(l){R=l;},setMetadata(l,c){F[l]=c;},setScreen(l){b.setScreen(l);},isOpen(){return v.getIsOpen()},open(){v.open();},openWith(l){v.open({category:l});},show(){v.showTrigger();},hide(){v.hideTrigger();},attachTo(l,c){return v.attachTo(l,c)},setTrigger(l){v.setTrigger(l);},openReporter(){v.openReporter();},close(){v.close();},updateConfig(l){ln(l);},diagnose(){return Gp({apiEndpoint:Pi(i),widgetMounted:v.getIsMounted(),runtimeConfigLoaded:_e,captureScreenshotAvailable:f!==null,captureNetworkIntercepting:M!==null,widgetDiagnostics:v.getWidgetDiagnostics()})},destroy(){Ni?.destroy(),qt?.reset(),hs(),v.destroy(),L?.destroy(),M?.destroy(),x?.destroy(),g?.deactivate(),Na(),Xe?.(),Xe=null,m?.destroy(),m=null,b.destroy(),Aa(),C?.destroy(),C=null,h.stopAutoSync(),z(),d?.(),d=null,ns(),X.clear(),me.clear(),He=null,o.debug("Destroyed");},async captureEvent(l){if(!k.tryConsume())return o.warn("captureEvent throttled \u2014 rate limit exceeded"),null;let c=S.scrub(p.truncate(l.description)),y=l.category??"bug",I=t.sentry?Ii(t.sentry):void 0,$=T(X.getAll()),N=w(Object.keys(U).length===0&&!l.tags?void 0:{...U,...l.tags??{}}),Q=I?{...I,...I.breadcrumbs?{breadcrumbs:T(I.breadcrumbs)}:{},...I.tags?{tags:w(I.tags)}:{}}:void 0,ue=Dn(),B={id:$n(),projectId:t.projectId,category:y,description:c,environment:ue,timeline:b.getEntries(),metadata:{...l.metadata??{},...R?{user:R}:{},...l.error?{error:l.error}:{},...l.severity?{severity:l.severity}:{},...l.component?{component:l.component}:{},...l.source?{source:l.source}:{source:"captureEvent"}},...$.length>0?{breadcrumbs:$}:{},...N&&Object.keys(N).length>0?{tags:N}:{},...Q?{sentryContext:Q}:{},sessionId:bt(),reporterToken:te(r),appVersion:lu(i,ue),sdkPackage:Ye,sdkVersion:we,sentryEventId:I?.eventId,sentryReplayId:I?.replayId,createdAt:new Date().toISOString()},Z=B;if(i.beforeSendFeedback)try{let Ue=await Promise.race([Promise.resolve(i.beforeSendFeedback(B)),new Promise(br=>setTimeout(()=>br(B),2e3))]);if(Ue===null)return o.info("captureEvent dropped by beforeSendFeedback hook",{reportId:B.id}),null;Z=Ue;}catch(Ue){o.warn("captureEvent beforeSendFeedback threw \u2014 sending unmodified report",{error:Ue instanceof Error?Ue.message:String(Ue)});}if(J("report:submitted",{reportId:Z.id}),typeof navigator<"u"&&!navigator.onLine)return await h.enqueue(Z),J("report:queued",{reportId:Z.id}),null;let Ne=await u.submitReport(Z);if(Ne.ok){J("report:sent",{reportId:Ne.data?.reportId});try{t.sentry&&Ne.data?.reportId&&Mi(Ne.data.reportId);}catch{}return Ne.data?.reportId??null}return await h.enqueue(Z),J("report:failed",{reportId:Z.id,error:Ne.error}),null},async captureException(l,c){let y=bs(l),I=typeof c?.metadata?.filename=="string"?c.metadata.filename:void 0;if(or({message:y.message,filename:I,ignoreErrors:i.ignoreErrors,denyUrls:i.denyUrls,allowUrls:i.allowUrls}))return null;X.add({category:"lifecycle",level:"error",message:`Mushi.captureException(${y.name}): ${y.message}`,...y.stack?{data:{stack:y.stack.slice(0,500)}}:{}});let $=c?.description?.trim()||`${y.name}: ${y.message}`||"Uncaught exception";return cn.captureEvent({description:$,category:c?.category??"bug",severity:c?.severity??"high",...c?.component?{component:c.component}:{},...c?.tags?{tags:c.tags}:{},source:c?.source??"captureException",error:{name:y.name,message:y.message,...y.stack?{stack:y.stack}:{}},metadata:{...c?.metadata??{},...y.cause?{cause:y.cause}:{}}})},identify(l,c){let y=`${l}::${c?JSON.stringify(c):""}`;if(y!==H){if(H=y,R={id:l,...c?.email?{email:c.email}:{},...c?.name?{name:c.name}:{}},v.setIdentifiedUser(R.name||R.email?{name:R.name,email:R.email}:null),st(),c)for(let[I,$]of Object.entries(c))I!=="email"&&I!=="name"&&(F[`user.${I}`]=$);X.add({category:"lifecycle",level:"info",message:`Mushi.identify(${l})`}),ds(l,c??null),Oi(l,c?{email:c.email,name:c.name,provider:c.provider}:void 0);}},identifyWithToken(l){if(a=l&&typeof l=="string"?l:null,a){let c=ks(a);if(c?.sub){if(R?.id===c.sub){X.add({category:"lifecycle",level:"info",message:"Mushi.identifyWithToken() refreshed"});return}rs(c.sub),R={id:c.sub,...c.email?{email:c.email}:{},...c.name?{name:c.name}:{}},v.setIdentifiedUser(R.name||R.email?{name:R.name,email:R.email}:null),Oi(R.id,{email:R.email,name:R.name});}X.add({category:"lifecycle",level:"info",message:"Mushi.identifyWithToken()"});}else R=null,H=null,v.setIdentifiedUser(null),X.add({category:"lifecycle",level:"info",message:"Mushi.identifyWithToken(null)"});},publishPageContext(l){s=l&&l.route?l:null;},openAssistant(){v.openAssistantTab();},addBreadcrumb(l){X.add(l);},getBreadcrumbs(){return X.getAll()},setTag(l,c){typeof l!="string"||l.length===0||(U[l]=c);},setTags(l){if(!(!l||typeof l!="object"))for(let[c,y]of Object.entries(l))typeof c=="string"&&c.length>0&&(U[c]=y);},clearTag(l){if(typeof l=="string"&&l.length>0){delete U[l];return}for(let c of Object.keys(U))delete U[c];},async getReputation(){if(!R?.id)return null;let l=await u.getMyPoints(R.id);return l.ok?{totalPoints:l.data.total_points??0,points30d:l.data.points_30d??0,reputation:1,confirmedBugs:0,totalReports:0}:null},async getTier(){return R?.id?Ba(R.id):null},recordActivity(l,c){i.rewards?.enabled&&Ft({action:l,metadata:c});},track(l,c){return Ct(l,c)},setConsent(l){cs(l);},getAnonymousId(){return us()},pulseTrigger(){v.pulseTrigger?.();},async listMyReports(){let l=await u.listReporterReports(te(r));return l.ok?l.data?.reports??[]:[]},async listMyComments(l){let c=await u.listReporterComments(l,te(r));return c.ok?c.data?.comments??[]:[]},async replyToReport(l,c){let y=await u.replyToReporterReport(l,te(r),c);return y.ok?y.data?.comment??null:null},async submitFeedbackSignal(l,c,y){let I=await u.replyToReporterReport(l,te(r),y??"",c);return I.ok?I.data?.feedback??null:null},async reopenReport(l,c){let y=await u.reopenReporterReport(l,te(r),c);return y.ok?y.data?.outcome??null:null},openMyReports(){v.recorderOpenMyReports();},getReporterUpdates:ge,async markReportRead(l){let c=await ie.markReportRead(l,n());return c.ok?c.data?.unread_total??0:null},onReporterUpdate(l){return he.add(l),ge(),()=>{he.delete(l);}},async getNotificationPrefs(){let l=await ie.getPrefs(n());return l.ok?l.data??null:null},setNotificationPrefs:l=>ie.setPrefs(n(),l),async subscribeReporterPush(){let l=i.notifications?.webPush,c=ot?.vapidPublicKey??null;if(l&&!c){let y=await u.getSdkConfig();c=y.ok?y.data?.reporter?.vapidPublicKey??null:null;}return ka(ie,n(),l?l.serviceWorkerPath:null,c)},async getHallOfFame(l=20){let c=await u.getHallOfFame(l);return c.ok?c.data?.data??[]:[]}};if(typeof globalThis<"u"&&(e.debug??false)&&Ca(v),typeof window<"u"&&typeof localStorage<"u"){let l="mushi:last-run",c=null;try{let y=localStorage.getItem(l);c=y===null?null:y==="unfinished",localStorage.setItem(l,"unfinished");}catch{c=null;}try{window.addEventListener("pagehide",()=>{try{localStorage.setItem(l,"clean");}catch{}$o(),Oo();});}catch{}if(typeof e.onCrashedLastRun=="function")try{e.onCrashedLastRun(c);}catch(y){o.warn("onCrashedLastRun hook threw",{error:y instanceof Error?y.message:String(y)});}}let qi={on:()=>{},onReporterUpdate:()=>{},isOpen:false,getBreadcrumbs:[],captureEvent:null,captureException:null,getReputation:null,getTier:null,listMyReports:[],listMyComments:[],getHallOfFame:[],replyToReport:null,submitFeedbackSignal:null,reopenReport:null},ji=(l,c)=>{let y=c instanceof Error?c.message:String(c);o.debug(`Mushi.${l}() failed (swallowed)`,{error:y});try{X.add({category:"custom",level:"warning",message:`mushi.${l}() threw`,data:{error:y}});}catch{}};return (l=>new Proxy(l,{get(c,y,I){let $=Reflect.get(c,y,I);if(typeof $!="function")return $;let N=String(y),Q=()=>N==="diagnose"?Di():N in qi?qi[N]:void 0;return (...ue)=>{try{let B=$.apply(c,ue);return B&&typeof B.then=="function"?B.catch(Z=>(ji(N,Z),Q())):B}catch(B){return ji(N,B),Q()}}}}))(cn)}function Pi(t){return t.apiEndpoint??Yt}function zp(t){return t.runtimeConfig!==false}async function Gp(t){let e=await Yp(t.apiEndpoint);return {apiEndpointReachable:e.reachable,cspAllowsEndpoint:e.cspAllowed,widgetMounted:t.widgetMounted,shadowDomAvailable:typeof HTMLElement<"u"&&typeof HTMLElement.prototype.attachShadow=="function",dialogSupported:typeof HTMLDialogElement<"u",runtimeConfigLoaded:t.runtimeConfigLoaded,captureScreenshotAvailable:t.captureScreenshotAvailable,captureNetworkIntercepting:t.captureNetworkIntercepting,sdkVersion:we,widgetHostPointerSafe:t.widgetDiagnostics?.widgetHostPointerSafe??false,widgetHostBounds:t.widgetDiagnostics?.widgetHostBounds??null,widgetSuppressed:t.widgetDiagnostics?.widgetSuppressed??false,bannerRendered:t.widgetDiagnostics?.bannerRendered??false}}async function Di(){return {apiEndpointReachable:false,cspAllowsEndpoint:false,widgetMounted:false,shadowDomAvailable:typeof HTMLElement<"u"&&typeof HTMLElement.prototype.attachShadow=="function",dialogSupported:typeof HTMLDialogElement<"u",runtimeConfigLoaded:false,captureScreenshotAvailable:false,captureNetworkIntercepting:false,sdkVersion:we,widgetHostPointerSafe:false,widgetHostBounds:null,widgetSuppressed:false,bannerRendered:false}}async function Yp(t){if(typeof fetch>"u")return {reachable:false,cspAllowed:false};let e=typeof AbortController<"u"?new AbortController:null,r=e?setTimeout(()=>e.abort(),3e3):null;try{return {reachable:(await fetch(`${t.replace(/\/$/,"")}/health`,{method:"GET",cache:"no-store",...e?{signal:e.signal}:{},[ir]:"diagnose"})).ok,cspAllowed:!0}}catch{return {reachable:false,cspAllowed:false}}finally{r&&clearTimeout(r);}}function $i(t){return `mushi:sdk-config:${t}`}function hu(t){return `mushi:sdk-version:${t}`}function Xp(t){if(typeof localStorage>"u")return null;try{let e=localStorage.getItem($i(t));return e?JSON.parse(e).config??null:null}catch{return null}}function Jp(t,e){if(!(typeof localStorage>"u"))try{localStorage.setItem($i(t),JSON.stringify({cachedAt:Date.now(),config:e}));}catch{}}function Qp(t){if(!(typeof localStorage>"u"))try{localStorage.removeItem($i(t));}catch{}}function Zp(t){if(typeof localStorage>"u")return null;try{let e=localStorage.getItem(hu(t));if(!e)return null;let r=JSON.parse(e);return !r.data||!r.cachedAt||Date.now()-r.cachedAt>864e5?null:r.data}catch{return null}}function eh(t,e){if(!(typeof localStorage>"u"))try{localStorage.setItem(hu(t),JSON.stringify({cachedAt:Date.now(),data:e}));}catch{}}function th(t,e){let r=cu(t),n=cu(e);for(let i=0;i<Math.max(r.length,n.length);i++){let o=r[i]??0,a=n[i]??0;if(o<a)return true;if(o>a)return false}return false}function cu(t){return t.split(/[.-]/).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e))}function du(){return {report:()=>{},on:()=>()=>{},setUser:()=>{},setMetadata:()=>{},setScreen:()=>{},isOpen:()=>false,open:()=>{},close:()=>{},updateConfig:()=>{},diagnose:Di,openWith:()=>{},show:()=>{},hide:()=>{},attachTo:()=>()=>{},setTrigger:()=>{},openReporter:()=>{},destroy:()=>{He=null;},captureEvent:async()=>null,captureException:async()=>null,identify:()=>{},identifyWithToken:()=>{},publishPageContext:()=>{},openAssistant:()=>{},addBreadcrumb:()=>{},getBreadcrumbs:()=>[],setTag:()=>{},setTags:()=>{},clearTag:()=>{},getReputation:async()=>null,getTier:async()=>null,recordActivity:()=>{},track:()=>false,setConsent:()=>{},getAnonymousId:()=>null,pulseTrigger:()=>{},listMyReports:async()=>[],listMyComments:async()=>[],replyToReport:async()=>null,submitFeedbackSignal:async()=>null,reopenReport:async()=>null,openMyReports:()=>{},getHallOfFame:async()=>[],getReporterUpdates:async()=>null,markReportRead:async()=>null,onReporterUpdate:()=>()=>{},getNotificationPrefs:async()=>null,setNotificationPrefs:async()=>({ok:false}),subscribeReporterPush:async()=>({ok:false,reason:"off"})}}function rh(t){if(typeof window>"u")return ()=>{};let e=[];try{let r=i=>{t.add({category:"navigation",level:"info",message:`${i}: ${window.location.pathname}`,data:{url:window.location.href,kind:i}});},n=Me({onPush:()=>r("pushState"),onReplace:()=>r("replaceState"),onPop:()=>r("popstate")});e.push(n);}catch{}try{let r=console.error,n=console.warn,i=function(...a){try{t.add({category:"console",level:"error",message:a.map(pu).join(" ")});}catch{}return r.apply(this,a)},o=function(...a){try{t.add({category:"console",level:"warning",message:a.map(pu).join(" ")});}catch{}return n.apply(this,a)};console.error=i,console.warn=o,e.push(()=>{console.error===i&&(console.error=r),console.warn===o&&(console.warn=n);});}catch{}try{let r=n=>{try{let i=n.target;if(!(i instanceof Element))return;let o=i,a=0;for(;o&&a<10;){let s=o.getAttribute("data-testid");if(s){let u=(o.textContent??"").trim().slice(0,80);t.add({category:"ui.click",level:"info",message:`clicked ${s}${u?` \u2014 ${u}`:""}`,data:{testid:s,tag:o.tagName.toLowerCase()}});return}o=o.parentElement,a++;}}catch{}};document.addEventListener("click",r,{passive:!0,capture:!0}),e.push(()=>document.removeEventListener("click",r,!0));}catch{}return ()=>{for(let r of e)try{r();}catch{}}}function pu(t){try{if(t instanceof Error)return `${t.name}: ${t.message}`;if(typeof t=="object"&&t!==null){let r=JSON.stringify(t);return r.length>200?`${r.slice(0,200)}\u2026`:r}let e=String(t);return e.length>200?`${e.slice(0,200)}\u2026`:e}catch{return `[${typeof t}]`}}function nh(){let t=document.currentScript;if(t&&t.dataset&&t.dataset.project)return t;let e=Array.from(document.querySelectorAll("script[data-project][data-key]"));return e.length>0?e[e.length-1]:null}function ih(t){let e=t.project?.trim(),r=t.key?.trim();if(!e||!r)return null;let n={};t.trigger&&(n.trigger=t.trigger),t.theme&&(n.theme=t.theme),t.position&&(n.position=t.position),t.triggerText&&(n.triggerText=t.triggerText);let i=t.bannerVariant,o=t.bannerPosition;(i||o)&&(n.bannerConfig={...i?{variant:i}:{},...o?{position:o}:{}});let a={projectId:e,apiKey:r};return t.endpoint&&(a.apiEndpoint=t.endpoint),t.debug==="true"&&(a.debug=true),Object.keys(n).length>0&&(a.widget=n),a}function oh(){if(typeof document>"u"||typeof window>"u")return;let t=window;if(t.__mushiLoaderInit)return;let e=nh();if(!e)return;let r=ih(e.dataset);if(r){t.__mushiLoaderInit=true;try{an.init(r);}catch{}}}oh();
95
+ `,document.body.appendChild(f),f}function p(f,g){let m=document.elementsFromPoint(f,g),b=null;for(let P of m)if(!(P===r||P===e)){if(P.id==="mushi-mushi-widget"||P.closest("#mushi-mushi-widget"))return null;b=P;break}let C=0;for(;b?.shadowRoot&&C<20;){let P=b.shadowRoot.elementFromPoint(f,g);if(!P||P===b)break;b=P,C++;}return b}function h(f){if(!e)return;let g=f.getBoundingClientRect();e.style.left=`${g.left}px`,e.style.top=`${g.top}px`,e.style.width=`${g.width}px`,e.style.height=`${g.height}px`,e.style.display="block";}function k(f){let g=p(f.clientX,f.clientY);if(!g){n=null,e&&(e.style.display="none");return}n=g,h(g);}function S(f){f.preventDefault(),f.stopPropagation();}function T(f){f.preventDefault(),f.stopPropagation();let g=p(f.clientX,f.clientY);g&&L(s(g));}function E(f){f.key==="Escape"&&L(null);}function w(){n?.isConnected&&h(n);}function L(f){x(),i?.(f),i=null;}function M(){return t&&x(),new Promise(f=>{i=f,t=true,e=u(),r=d(),r.addEventListener("mousemove",k),r.addEventListener("click",T),r.addEventListener("pointerdown",S),r.addEventListener("mousedown",S),r.addEventListener("mouseup",S),document.addEventListener("keydown",E,true),window.addEventListener("scroll",w,{capture:true,passive:true});})}function x(){t&&(t=false,n=null,document.removeEventListener("keydown",E,true),window.removeEventListener("scroll",w,{capture:true}),r&&(r.remove(),r=null),e&&(e.remove(),e=null));}return {activate:M,deactivate:x,isActive:()=>t}}var Ga=120;function ki(){let t=[],e=()=>n("hashchange");n("initial");function r(a){t.push(a),t.length>Ga&&t.shift();}function n(a){typeof location>"u"||r({ts:Date.now(),kind:"route",payload:{source:a,route:sr(`${location.pathname}${location.search}${location.hash}`),href:sr(location.href)}});}function i(a){let s=a.target instanceof Element?a.target:null;if(!s)return;let u=s.closest('button,a,[role="button"],input,textarea,select,[data-mushi-track]')??s;r({ts:Date.now(),kind:"click",payload:{tag:u.tagName.toLowerCase(),id:u.id||void 0,text:Sp(u)}});}let o=Me({onPush:()=>n("pushState"),onReplace:()=>n("replaceState"),onPop:()=>n("popstate")});return window.addEventListener("hashchange",e),document.addEventListener("click",i,true),{setScreen(a){r({ts:Date.now(),kind:"screen",payload:a});},getEntries(a={}){return [...t,...(a.consoleLogs??[]).map(u=>({ts:u.timestamp,kind:"log",payload:{level:u.level,message:u.message}})),...(a.networkLogs??[]).map(u=>({ts:u.timestamp,kind:"request",payload:{method:u.method,url:u.url,status:u.status,duration:u.duration,error:u.error}}))].sort((u,d)=>u.ts-d.ts).slice(-Ga)},clear(){t.length=0;},destroy(){o(),window.removeEventListener("hashchange",e),document.removeEventListener("click",i,true);}}}function Sp(t){let e=(t.textContent??"").replace(/\s+/g," ").trim();return e?e.slice(0,80):void 0}var xp=6e4,Rp=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,kp=/^[0-9a-f]{20,}$/i,_p=/^\d+$/,Cp=/^[a-z0-9]{16,}$/i;function Ya(t){return t.length===0?t:Rp.test(t)||kp.test(t)||_p.test(t)||Cp.test(t)&&/\d/.test(t)?"[id]":t}function Tp(t,e,r){if(e.startsWith("#/")){let n=e.slice(1),i=n.indexOf("?"),o=i===-1?n:n.slice(0,i),a=r?.map(s=>s.startsWith("/#/")?s.slice(2):s);return "/#"+_i(o,a)}return _i(t,r)}function _i(t,e){let r=t.length>1&&t.endsWith("/")?t.slice(0,-1):t;if(e?.length){let n=Ap(r,e);if(n)return n}return "/"+r.split("/").filter(n=>n.length>0).map(Ya).join("/")}function Ap(t,e){let r=t.split("/").filter(i=>i.length>0),n=[...e].sort((i,o)=>o.split("/").length-i.split("/").length);for(let i of n){let o=i.split("/").filter(s=>s.length>0);if(o.length!==r.length)continue;let a=true;for(let s=0;s<o.length;s++){let u=o[s],d=r[s];if(!(u.startsWith("[")&&u.endsWith("]"))&&!u.startsWith(":")&&u!==d){a=false;break}}if(a)return "/"+o.join("/")}return null}function Ip(){if(typeof document>"u")return [];let t=new Set,e=document.querySelectorAll("[data-testid]");for(let r of Array.from(e)){let n=r.getAttribute("data-testid");n&&n.length>0&&n.length<120&&t.add(n);}return Array.from(t).sort()}function Mp(){if(typeof window>"u")return [];try{let t=new Set,e=i=>{new URLSearchParams(i).forEach((o,a)=>t.add(a));};e(window.location.search);let r=window.location.hash,n=r.indexOf("?");return r.startsWith("#/")&&n!==-1&&e(r.slice(n+1)),Array.from(t).sort()}catch{return []}}function Lp(){if(typeof document>"u")return null;let t=i=>(i??"").replace(/\s+/g," ").trim().slice(0,200),e=t(document.querySelector("h1")?.textContent);if(e)return e;let r=t(document.title);return r||t(document.querySelector("main")?.textContent)||null}async function Pp(t){if(!t||typeof crypto>"u"||!crypto.subtle)return null;try{let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e),n=new Uint8Array(r),i="";for(let o=0;o<n.length;o++)i+=n[o].toString(16).padStart(2,"0");return i}catch{return null}}function Ci(t){let{config:e,getRecentNetworkPaths:r,getUserId:n,getSessionId:i,onEvent:o}=t,a=e.throttleMs??xp,s=e.captureDomSummary!==false,u=e.userIdSource??"auto",d=new Map,p=null,h=null;async function k(){if(typeof window>"u")return;let L=Tp(window.location.pathname,window.location.hash,e.routeTemplates),M=Date.now(),x=d.get(L)??0;if(M-x<a)return;d.set(L,M);let f=null;u==="auto"?f=n()??i():u==="session-only"&&(f=i());let g={route:L,page_title:typeof document<"u"&&(document.title||"").slice(0,300)||null,dom_summary:s?Lp():null,testids:Ip(),network_paths:r().slice(-50),query_param_keys:Mp(),user_id_hash:await Pp(f),observed_at:new Date().toISOString()};o(g);}function S(){h||(h=setTimeout(()=>{h=null,k();},100));}function T(){if(typeof window>"u")return;let L=window.location.hash.startsWith("#/")?window.location.hash:"",M=window.location.pathname+window.location.search+L;M!==p&&(p=M,S());}if(typeof window>"u")return {destroy:()=>{},flushNow:()=>{}};let E=()=>T(),w=Me({onPush:E,onReplace:E,onPop:E});return window.addEventListener("hashchange",E),S(),{destroy(){w(),window.removeEventListener("hashchange",E),h&&(clearTimeout(h),h=null),d.clear();},flushNow(){d.clear(),k();}}}var Dp=3e4,Ai=400,$p=4,Op=2;function Xa(t,e,r){let n=u=>u.timestamp,i=u=>u.type===Op,o=u=>u.type===$p,a=Date.now()-e,s=0;for(let u=0;u<t.length;u++){let d=n(t[u]);if(typeof d=="number"&&d>=a)break;i(t[u])&&(s=o(t[u-1])?u-1:u);}if(t.length-s>r){for(let u=s+1;u<t.length;u++)if(i(t[u])&&t.length-u<=r){s=o(t[u-1])?u-1:u;break}}s>0&&t.splice(0,s);}function Ja(t){let e=[],r=false,n=o=>{if(!r)return;let a=o.target instanceof Element?o.target:null,s=a?.tagName?.toLowerCase()??"unknown",u=a?.closest("[data-testid]")?.getAttribute("data-testid")??void 0;e.push({type:"lite_click",timestamp:Date.now(),data:{tag:s,testId:u}}),e.length>Ai&&e.shift();},i=()=>{r=false,document.removeEventListener("click",n,true);};return {start(){r||(r=true,document.addEventListener("click",n,true));},stop:i,flush(){let o=Date.now()-t;return e.filter(a=>a.timestamp>=o)},destroy(){i(),e.length=0;}}}var Hp=['input[type="password"]',"[data-mushi-redact]"],Bp="rrweb",Oe=null,Qa=false;function Ti(t){if(!t||typeof t!="object")return null;let e=t;return typeof e.record=="function"?e:e.default&&typeof e.default.record=="function"?e.default:null}async function Fp(t){if(Oe)return Oe;if(typeof t=="function")try{if(Oe=Ti(await t()),Oe)return Oe}catch{}if(Oe=Ti(globalThis.rrweb),Oe)return Oe;try{let e=globalThis.__MUSHI_RRWEB_SPECIFIER__||Bp;return Oe=Ti(await import(e)),Oe}catch{return null}}async function Za(t){let e=t.maxDurationMs??Dp;if(t.mode==="lite")return Ja(e);let r=await Fp(t.loadRrweb);if(!r?.record)return Qa||(Qa=true,Tt({scope:"mushi"}).warn("capture.replay is 'rrweb' but rrweb could not be loaded, so replay is recording clicks only. Install rrweb and pass capture: { rrweb: () => import('rrweb') }.")),Ja(e);let n=r.record,i=[],o=null,a=false,s=[...new Set([...Hp,...t.redactSelectors??[]])],u=()=>{o?.(),o=null,a=false;};return {start(){a||(a=true,o=n({emit(d){i.push(d),Xa(i,e,Ai);},maskAllInputs:true,maskTextSelector:"*",blockSelector:s.join(","),checkoutEveryNms:e,sampling:{mousemove:false,mouseInteraction:true,scroll:150,media:800}})??null);},stop:u,flush(){return Xa(i,e,Ai),[...i]},destroy(){u(),i.length=0;}}}function eu(){try{let t=globalThis;return t.Sentry?t.Sentry:void 0}catch{return}}function Np(){try{return globalThis.__SENTRY_REPLAY__}catch{return}}function Up(){try{let t=globalThis,e=t.__SENTRY__,r=t.Sentry;return e?.version==="9"||r&&typeof r.lastEventId=="function"?e?.version==="9"?"v9":"v8":e?.version==="8"?"v8":r&&typeof r.getCurrentHub=="function"?"v7":"unknown"}catch{return "unknown"}}function Ii(t,e={}){let r=Math.max(0,e.breadcrumbsLimit??30),n={},i=eu();if(!i)return n;n.sdk=Up();try{let s=i;if(typeof s.lastEventId=="function")n.eventId=s.lastEventId()??void 0;else {let d=i.getCurrentHub?.()?.getScope?.();n.eventId=d?.getLastEventId?.()??void 0;}}catch{}let o;try{let s=i;typeof s.getCurrentScope=="function"?o=s.getCurrentScope():o=i.getCurrentHub?.()?.getScope?.();}catch{}if(o){try{let s=o.getUser?.();s&&(n.user={id:typeof s.id=="string"?s.id:void 0,email:typeof s.email=="string"?s.email:void 0,username:typeof s.username=="string"?s.username:void 0,ip_address:typeof s.ip_address=="string"?s.ip_address:void 0});}catch{}try{let s=o.getTags?.();if(s&&typeof s=="object"){let u={};for(let[d,p]of Object.entries(s))(typeof p=="string"||typeof p=="number"||typeof p=="boolean")&&(u[d]=p);Object.keys(u).length>0&&(n.tags=u);}}catch{}try{n.transactionName=o.getTransactionName?.()??o.getTransaction?.()?.name??void 0;}catch{}try{n.sessionId=o.getSession?.()?.sid??void 0;}catch{}try{let s=o.getBreadcrumbs?.()??o._breadcrumbs??[];if(Array.isArray(s)&&s.length>0){let u=s.slice(-r);n.breadcrumbs=u.map(d=>{let p=d;return {timestamp:typeof p.timestamp=="number"?p.timestamp<1e12?Math.round(p.timestamp*1e3):p.timestamp:void 0,category:typeof p.category=="string"?p.category:void 0,level:typeof p.level=="string"?p.level:void 0,message:typeof p.message=="string"?p.message:void 0,type:typeof p.type=="string"?p.type:void 0,data:p.data&&typeof p.data=="object"?p.data:void 0}});}}catch{}}try{let s=i,u;if(typeof s.getActiveSpan=="function"?u=s.getActiveSpan():o?.getSpan&&(u=o.getSpan()),u){let d=u.spanContext?.();n.traceId=d?.traceId??u.traceId??void 0,n.spanId=d?.spanId??u.spanId??void 0;}}catch{}let a;try{let s=i;typeof s.getClient=="function"?a=s.getClient():a=i.getCurrentHub?.()?.getClient?.();}catch{}if(a){try{let s=a.getOptions?.();s?.release&&(n.release=s.release),s?.environment&&(n.environment=s.environment);}catch{}try{let s=a.getDsn?.();if(s?.host&&s?.projectId&&n.eventId){let u=s.host.replace(/^o\d+\./,"");n.issueUrl=`https://${u}/issues/?query=${encodeURIComponent(n.eventId)}`;}}catch{}}try{let u=i.getReplay?.()??Np();n.replayId=u?.getReplayId?.()??void 0;}catch{}return n}function Mi(t,e={}){let r=eu();if(r){try{let n=r;typeof n.setTag=="function"&&(n.setTag("mushi.report_id",t),e.reportUrl&&n.setTag("mushi.report_url",e.reportUrl)),typeof n.setContext=="function"&&n.setContext("mushi_report",{id:t,...e.reportUrl?{url:e.reportUrl}:{},captured_at:new Date().toISOString()}),typeof n.addBreadcrumb=="function"&&n.addBreadcrumb({category:"mushi",type:"info",level:"info",message:`Mushi report submitted (${t})`,data:{report_id:t,...e.reportUrl?{url:e.reportUrl}:{}}});}catch{}try{let i=r.getCurrentHub?.()?.getScope?.();i&&(i.setTag?.("mushi.report_id",t),e.reportUrl&&i.setTag?.("mushi.report_url",e.reportUrl),i.setContext?.("mushi_report",{id:t,...e.reportUrl?{url:e.reportUrl}:{}}));}catch{}}}var qp=["/login","/logout","/signup","/sso/*","/auth/*"];function ru(t,e={}){let r=[];if(e.rageClick!==false){let E=function(w){let L=Date.now();if(w.target===T){if(S.push(L),S=S.filter(M=>L-M<500),S.length>=3){let M=w.target;t.onTrigger("rage_click",{element:M.tagName,id:M.id,text:M.textContent?.slice(0,50)}),S=[];}}else T=w.target,S=[L];};let S=[],T=null;document.addEventListener("click",E,true),r.push(()=>document.removeEventListener("click",E,true));}if(e.longTask!==false&&typeof PerformanceObserver<"u")try{let S=new PerformanceObserver(T=>{for(let E of T.getEntries())E.duration>5e3&&t.onTrigger("long_task",{duration:Math.round(E.duration),startTime:Math.round(E.startTime)});});S.observe({entryTypes:["longtask"]}),r.push(()=>S.disconnect());}catch{}let n=jp(e.apiCascade);if(n.enabled){let S=[],T=globalThis.fetch;globalThis.fetch=async function(...E){let[w,L]=E,M=tn(w),x=!!rn(w,L)||gr(M,{apiEndpoint:e.apiEndpoint,ignoreUrls:n.ignoreUrls});try{let f=await T.apply(this,E);return !x&&!f.ok&&f.status>=400&&tu(S,t),f}catch(f){throw x||tu(S,t),f}},r.push(()=>{globalThis.fetch=T;});}if((e.pageDwell===true||typeof e.pageDwell=="object"&&e.pageDwell!==null)&&typeof window<"u"){let M=function(b){return E.some(C=>C.endsWith("/*")?b.startsWith(C.slice(0,-2)):b===C||b.startsWith(C+"/"))},x=function(){let b=window.location?.pathname??"";M(b)||t.onTrigger("page_dwell",{thresholdMs:T,path:b});},f=function(){w&&clearTimeout(w);let b=window.location?.pathname??"";M(b)||(w=setTimeout(x,T));},g=function(){let b=window.location?.pathname??"";b!==L&&(L=b,f());};let S=typeof e.pageDwell=="object"?e.pageDwell??{}:{},T=S.thresholdMs||300*1e3,E=S.excludeRoutes!==void 0?S.excludeRoutes:qp,w=null,L=window.location?.pathname??"";f();let m=Me({onPush:g,onReplace:g,onPop:g});r.push(()=>{w&&clearTimeout(w),m();});}if((e.firstSession===true||typeof e.firstSession=="object"&&e.firstSession!==null)&&typeof window<"u"){let S=typeof e.firstSession=="object"?e.firstSession??{}:{},T=S.delayMs??45*1e3,E=S.storageKey??(e.projectId?`mushi:${e.projectId}:firstSessionShown`:"mushi:firstSessionShown"),w=false;try{w=window.localStorage?.getItem(E)==="1";}catch{}if(!w){let L=setTimeout(()=>{try{window.localStorage?.setItem(E,"1");}catch{}t.onTrigger("first_session",{delayMs:T});},T);r.push(()=>clearTimeout(L));}}if(e.errorBoundary){let S=function(E){or({message:E.message,filename:E.filename,ignoreErrors:e.ignoreErrors,denyUrls:e.denyUrls,allowUrls:e.allowUrls})||t.onTrigger("error_boundary",{message:E.message,filename:E.filename,lineno:E.lineno,colno:E.colno});},T=function(E){let w=E.reason instanceof Error?E.reason.message:String(E.reason);or({message:w,ignoreErrors:e.ignoreErrors,denyUrls:e.denyUrls,allowUrls:e.allowUrls})||t.onTrigger("error_boundary",{message:w,type:"unhandled_rejection"});};window.addEventListener("error",S),window.addEventListener("unhandledrejection",T),r.push(()=>{window.removeEventListener("error",S),window.removeEventListener("unhandledrejection",T);});}return {destroy(){r.forEach(S=>S());}}}function jp(t){return t===false?{enabled:false,ignoreUrls:[]}:t&&typeof t=="object"?{enabled:t.enabled!==false,ignoreUrls:t.ignoreUrls??[]}:{enabled:true,ignoreUrls:[]}}function tu(t,e){let r=Date.now();t.push(r);let n=t.filter(i=>r-i<1e4);n.length>=3&&(e.onTrigger("api_cascade",{failureCount:n.length,windowMs:1e4}),t.length=0);}var nu="mushi:lastDismiss",nn="mushi:consecDismiss",Li="mushi:lastShown";function on(t){try{return localStorage.getItem(t)}catch{return null}}function sn(t,e){try{localStorage.setItem(t,e);}catch{}}function iu(t={}){let e=t.maxProactivePerSession??2,r=t.dismissCooldownHours??24,n=t.suppressAfterDismissals??3,i=(t.reshowCooldownMinutes??30)*60*1e3,o=0,a=new Set;function s(h){let k=Date.now();if(parseInt(on(nn)??"0",10)>=n)return false;let T=on(nu);if(T&&k-parseInt(T,10)<r*60*60*1e3)return false;if(i>0&&o===0){let E=on(Li);if(E&&k-parseInt(E,10)<i)return false}return o>=e||a.has(h)?false:(a.add(h),o++,sn(Li,String(k)),true)}function u(){sn(nu,String(Date.now()));let h=parseInt(on(nn)??"0",10);sn(nn,String(h+1));}function d(){sn(nn,"0");}function p(){o=0,a.clear();try{localStorage.removeItem(Li);}catch{}}return {shouldShow:s,recordDismissal:u,recordSubmission:d,reset:p}}var Ye="@mushi-mushi/web",we="1.31.2";function lu(t,e){if(t.appVersion)return t.appVersion;let r=t.integrations?.vercel?.analyticsId;return r||e?.buildId}var He=null,an=class{constructor(){}static init(e){if(He)return Tt({scope:"mushi",level:"warn",format:"pretty"}).warn("Already initialized \u2014 call destroy() first to reinitialize"),He;if(typeof document>"u"||typeof window>"u")return du();let r={...Ln(),...e};if(!r.projectId||!r.apiKey){let n=Bo();throw new Error(n.message??"[mushi] projectId and apiKey are required \u2014 set NEXT_PUBLIC_MUSHI_* / VITE_MUSHI_* / MUSHI_* or pass them explicitly")}return r.enabled===false?du():(He=Kp(r),He)}static getInstance(){return He}static destroy(){He?.destroy(),He=null;}static diagnose(){return He?.diagnose()??Di()}};function Kp(t){No(t);let e=Fo(t),r=e.projectId,n=()=>te(r),i=e,o=t.debug??false?Tt({scope:"mushi",level:"debug",format:"pretty"}):Pn,a=null,s=null,u=Ho({projectId:e.projectId,apiKey:e.apiKey,...e.apiEndpoint?{apiEndpoint:e.apiEndpoint}:{},...typeof e.timeout=="number"?{timeout:e.timeout}:{},...typeof e.maxRetries=="number"?{maxRetries:e.maxRetries}:{},...e.circuitBreaker?{circuitBreaker:e.circuitBreaker}:{},...e.tunnel?{tunnel:e.tunnel}:{},getUserToken:()=>a,sdkPackage:Ye,sdkVersion:we}),d=null;if(e.trackSessions!==false){ts({client:u,sdkVersion:we,reporterToken:te(e.projectId)??null,projectId:e.projectId,analytics:e.analytics});try{d=Me({onPush:()=>Bn(),onPop:()=>Bn()});}catch{}}let p=Uo(e.preFilter),h=Ko(e.offline),k=fs({maxBurst:10,refillRate:1,refillIntervalMs:5e3}),S=Un();ls({client:u,projectId:e.projectId,sdkVersion:we,config:e.analytics,scrub:l=>S.scrub(l),getSessionId:bt});function T(l){return l.map(c=>{let y={...c};if(typeof c.message=="string"&&(y.message=S.scrub(c.message)),c.data&&typeof c.data=="object"){let I={};for(let[$,N]of Object.entries(c.data))I[$]=typeof N=="string"?S.scrub(N):N;y.data=I;}return y})}function E(l){return l&&l.map(c=>({...c,message:S.scrub(c.message),...c.stack?{stack:S.scrub(c.stack)}:{}}))}function w(l){if(!l)return;let c={};for(let[y,I]of Object.entries(l))c[y]=typeof I=="string"?S.scrub(I):I;return c}let L=null,M=null,x=null,f=null,g=null,m=null,b=ki(),C=null,P=0,v,K=`mushi:tester-jwt:${e.projectId}`;function Y(){try{return typeof localStorage<"u"?localStorage.getItem(K):null}catch{return null}}function j(){try{typeof localStorage<"u"&&localStorage.removeItem(K);}catch{}}async function ke(l){let c=await u.getTesterStatus(l);if(!c.ok||!c.data){j();return}let y=c.data;if(!y.is_tester||!y.tester_id){j();return}v.setTesterSession(l,{id:y.tester_id,public_handle:y.public_handle??null,display_name:y.display_name??null});let I=await u.getMyReputation(l);if(I.ok&&I.data){let $=I.data;$.reputation&&v.setTesterReputation($.reputation);}}function Be(){if(i.capture?.console!==false?L??=bi():(L?.destroy(),L=null),i.capture?.network!==false){let B={apiEndpoint:Pi(i),ignoreUrls:i.capture?.ignoreUrls,tracePropagation:i.capture?.tracePropagation,sessionId:bt()};M?M.updateOptions(B):M=gi(B);}else M?.destroy(),M=null;if(i.capture?.performance!==false?x??=xi():(x?.destroy(),x=null),i.capture?.screenshot!=="off"){let B={privacy:i.privacy,onFailed:Z=>v.setScreenshotError(true,Z)};i.capture?.screenshotProvider?f=null:f?f.updateOptions(B):f=wi(B);}else f=null;!f&&!i.capture?.screenshotProvider&&(O=null),v.setAllowScreenshotRemove(i.privacy?.allowUserRemoveScreenshot!==false),i.capture?.elementSelector!==false?g??=Ri():(g?.deactivate(),g=null,G=null),v.setCaptureAvailability({screenshot:(!!f||!!i.capture?.screenshotProvider)&&i.capture?.screenshot!=="off",element:!!g});let l=i.capture?.discoverInventory,c=l===true?{}:l&&typeof l=="object"?l:null;c!=null&&c.enabled!==false?(m?.destroy(),m=Ci({config:c,getRecentNetworkPaths:()=>M?M.getEntries().map(B=>{try{let Z=new URL(B.url,typeof window<"u"?window.location.href:"http://localhost");return Z.host&&typeof window<"u"&&Z.host!==window.location.host?null:Z.pathname}catch{return null}}).filter(B=>B!=null&&B.length>0&&B.length<200):[],getUserId:()=>R?.id??null,getSessionId:bt,onEvent:B=>{u.postDiscoveryEvent({...B,sdk_version:we}).catch(Z=>{o.debug("discovery emit failed",{err:String(Z)});});}})):(m?.destroy(),m=null);let I=i.capture?.replay??"off",$=i.replaySampleRate??1,N=$>=1||Math.random()<$,Q=i.replaysOnErrorSampleRate??0,ue=!N&&Q>0&&Math.random()<Q;if((I==="rrweb"||I==="lite")&&(N||ue)){let B=++P;Za({mode:I,loadRrweb:e.capture?.rrweb,redactSelectors:i.privacy?.redactSelectors}).then(Z=>{if(B!==P){Z.destroy();return}C?.destroy(),C=Z,C.start();});}else P++,C?.destroy(),C=null;}let me=new Map;function J(l,c){me.get(l)?.forEach(y=>y({type:l,data:c}));}let O=null,G=null,re=null,_e=false,Ce=true,Le=null,A=null,R=null,H=null,F={},U={},X=gs({max:50});X.add({category:"lifecycle",level:"info",message:"Mushi SDK init",data:{projectId:e.projectId,sdkVersion:we}});let Xe=null;Xe=rh(X);let Fe=false,it=false,he=new Set,ie=Ra(u);async function ge(){let l=await ie.getUpdates(n()),c=l.ok?l.data??null:null;if(c)for(let y of he)try{y(c);}catch{}return c}function Nt(){v.refreshReporterInboxQuiet(),he.size&&ge();}function z(){Le&&clearInterval(Le),Le=null,A&&typeof document<"u"&&document.removeEventListener("visibilitychange",A),A=null;}function Ut(){if(z(),!Ce)return;let l=5*6e4,c=()=>{typeof document<"u"&&document.visibilityState==="hidden"||ii(r)&&Nt();};Le=setInterval(c,l),typeof document<"u"&&(A=()=>{document.visibilityState==="visible"&&c();},document.addEventListener("visibilitychange",A)),c();}let ot=null;function st(){let l=i.notifications??e.notifications;v.setReporterChannels({email:!!ot?.emailEnabled&&l?.email!==false,push:!!(ot?.pushEnabled&&ot.vapidPublicKey)&&!!l?.webPush,emailPrefill:l?.emailFromIdentity?R?.email??"":""});}let St=[];function fu(){if(!ii(r))return;let l=globalThis.requestIdleCallback;if(l?l(()=>{v.preloadViews();},{timeout:8e3}):setTimeout(()=>{v.preloadViews();},3e3),e.notifications?.toast===false||!Sa(r))return;let c=async()=>{let I=await ge(),$=I&&typeof I.unread_total=="number"&&Array.isArray(I.latest)?I:null;if($&&!$.unread_total)return;await v.refreshReporterInboxQuiet(),($?v.showUpdatesFeedToast($,St):await v.showUpdatesToast(St))&&xa(r);},y=globalThis.requestIdleCallback;y?y(()=>{c();},{timeout:5e3}):setTimeout(()=>{c();},2e3);}async function mu(l){let c=te(r),y=await ie.markReportRead(l,c);if(y.ok)return y.data?.unread_total??null;let I=await u.listNotifications(c,{limit:50});if(!I.ok)return null;let $=(I.data?.notifications??[]).filter(N=>{let Q=N.payload??{};return !N.read_at&&(Q.reportId===l||N.report_id===l)});return await Promise.all($.map(N=>u.markNotificationRead(String(N.id),c))),null}function Oi(l,c){if(!i.rewards?.enabled)return;let y={client:u,config:i.rewards,projectId:r,userId:l,traits:c,reporterToken:n()};Ha(y),i.rewards.showInWidget!==false&&u.getMyPoints(l).then(I=>{if(!I.ok)return;let $=I.data;v.setRewardsState({tier:$.tier?{slug:$.tier.slug??"free",displayName:$.tier.display_name??"Free",pointsThreshold:$.tier.points_threshold??0}:null,nextTier:$.next_tier?{displayName:$.next_tier.display_name??"",pointsThreshold:$.next_tier.points_threshold??0}:null,totalPoints:$.total_points??0,pointsForReport:$.report_submit_pts??50});}).catch(()=>{});}async function Hi(){if(Fe)return null;it=false;let l=i.capture?.screenshotProvider;if(l){Fe=true;try{let $=await l();if($)return $}catch($){o.warn("screenshotProvider threw, falling back to built-in capturer",{error:$ instanceof Error?$.message:String($)}),it=$ instanceof Error&&($.name==="NotAllowedError"||$.name==="SecurityError"||/permission|denied/i.test($.message));}finally{Fe=false;}}if(!f)return null;Fe=true;let c=v.getIsOpen();c&&v.hidePanel();let y=document.getElementById("mushi-mushi-widget"),I=y?.style.visibility??"";y&&(y.style.visibility="hidden"),await new Promise($=>{requestAnimationFrame(()=>requestAnimationFrame(()=>$()));});try{return await f.take()}finally{Fe=false,y&&(y.style.visibility=I),c&&v.showPanel();}}async function Bi(l){let c=i.capture?.screenshot;!(f||i.capture?.screenshotProvider)||c==="off"||O||l==="open"&&c!=="auto"||l==="submit"&&c!=="on-report"&&c!=="auto"||(o.debug("Auto-capturing screenshot",{when:l,mode:c}),O=await Hi(),v.setScreenshotAttached(O!==null),v.setScreenshotPreview(O));}let un=nr(r).then(l=>l.slice(0,12)).catch(()=>null);v=new Yr(e.widget,{onSubmit:async({category:l,userCategory:c,description:y,intent:I})=>(o.info("Report submitted",{category:l,userCategory:c,intent:I}),qt?.recordSubmission(),await Bi("submit"),await bu(l,y,I,c)??{reportId:null,queuedOffline:true}),onOpen:()=>{o.debug("Widget opened"),Bi("open"),C?.start(),J("widget:opened");},onBrandFooterImpression:()=>{un.then(l=>{Ct("loop_impression",{placement:"widget"},l?{reserved:{$ref:l}}:void 0);});},onBrandFooterClick:()=>{un.then(l=>(Ct("loop_click",{placement:"widget"},l?{reserved:{$ref:l}}:void 0),ps()));},onClose:()=>{o.debug("Widget closed"),re&&(qt?.recordDismissal(),J("proactive:dismissed",{type:re})),O=null,G=null,re=null,J("widget:closed");},onScreenshotRequest:async()=>{if(!(!!f||!!i.capture?.screenshotProvider)||i.capture?.screenshot==="off"){o.warn("Screenshot requested but capture is disabled"),v.setScreenshotError(true,"unsupported");return}if(!Fe){o.debug("Taking screenshot"),v.setScreenshotCapturing(true);try{O=await Hi();}catch(c){o.warn("Screenshot capture threw",{error:c instanceof Error?c.message:String(c)}),O=null;}v.setScreenshotAttached(O!==null),v.setScreenshotPreview(O),O===null&&v.setScreenshotError(true,it?"permission":void 0);}},onScreenshotShareTabRequest:typeof navigator<"u"&&typeof navigator.mediaDevices?.getDisplayMedia=="function"?()=>{let l=navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:false,preferCurrentTab:true,selfBrowserSurface:"include"});l.catch(()=>{}),v.setScreenshotCapturing(true);let c=document.getElementById("mushi-mushi-widget");c&&(c.style.visibility="hidden");let y=i.privacy;Promise.resolve().then(()=>(su(),ou)).then(I=>I.grabMaskedTabFrame(l,[Si,"[data-mushi-redact]",...y?.redactSelectors??[],...y?.maskSelectors??[],...y?.blockSelectors??[]]),I=>{throw l.then($=>$.getTracks().forEach(N=>N.stop()),()=>{}),I}).then(I=>{O=I,v.setScreenshotAttached(true),v.setScreenshotPreview(I);}).catch(I=>{o.warn("Tab capture failed",{error:I instanceof Error?I.name:String(I)}),v.setScreenshotError(true,I instanceof Error&&I.name==="NotAllowedError"?"permission":"error");}).finally(()=>{c&&(c.style.visibility="");});}:void 0,onScreenshotRemove:()=>{o.debug("Screenshot attachment removed"),O=null,v.setScreenshotAttached(false);},onScreenshotAnnotateRequest:async l=>{if(!O||l.childElementCount>0)return;let c;try{let{createScreenshotAnnotation:Q}=await Promise.resolve().then(()=>(uu(),au));c=await Q(O,l);}catch(Q){o.warn("Screenshot annotation failed",{error:Q instanceof Error?Q.message:String(Q)});return}let y=document.createElement("div");y.className="mushi-annotate-toolbar";let I=Q=>{(O=c.getDataUrl(),v.setScreenshotAttached(true),v.setScreenshotPreview(O)),c.destroy(),y.remove();},$=[{id:"highlight",label:"\u270F\uFE0F Highlight"},{id:"blur",label:"\u{1F512} Blur"},{id:"arrow",label:"\u2197\uFE0F Arrow"}];for(let Q of $){let ue=document.createElement("button");ue.type="button",ue.className="mushi-attach-btn",ue.dataset.tool=Q.id,ue.textContent=Q.label,ue.addEventListener("click",()=>{c.setTool(Q.id),y.querySelectorAll("button[data-tool]").forEach(B=>B.classList.remove("active")),ue.classList.add("active");}),y.appendChild(ue);}y.querySelector('button[data-tool="highlight"]')?.classList.add("active");let N=document.createElement("button");N.type="button",N.className="mushi-attach-btn",N.textContent="\u2713 Done",N.addEventListener("click",()=>I()),y.appendChild(N),l.insertBefore(y,l.firstChild);},onElementSelectorRequest:async()=>{if(!g||i.capture?.elementSelector===false){o.warn("Element selector requested but it is disabled/unavailable"),v.setElementError(true);return}o.debug("Element selector activated"),v.setElementCapturing(true),v.hidePanel();try{let l=await g.activate();l?(G=l,v.setElementSelected(!0),o.debug("Element selected",{tagName:l.tagName,xpath:l.xpath})):v.setElementCapturing(!1);}catch(l){o.warn("Element selector threw",{error:l instanceof Error?l.message:String(l)}),v.setElementError(true);}finally{v.showPanel();}},async onReporterReportsRequest(){let l=await u.listReporterReports(te(r));if(!l.ok)throw new Error(l.error?.message??"Could not load reports");return St=l.data?.reports??[],St.length&&ni(r),St},onReporterMarkRead:l=>mu(l),async onReporterReportRequest(l){let c=await ie.getReport(l,te(r));return c.ok&&c.data?{report:c.data.report,timeline:c.data.timeline}:null},async onReporterEmailOptIn(l){let c=await ie.setPrefs(te(r),{email:l,channels:{email:true}});if(!c.ok)throw new Error(c.error?.code??"EMAIL_OPT_IN_FAILED")},async onReporterPushSubscribe(){let l=await cn.subscribeReporterPush();if(!l.ok)throw new Error(l.reason)},async onReporterCommentsRequest(l){let c=await u.listReporterComments(l,te(r));if(!c.ok)throw new Error(c.error?.message??"Could not load thread");return c.data?.comments??[]},async onReporterReply(l,c){let y=await u.replyToReporterReport(l,te(r),c);if(!y.ok)throw new Error(y.error?.message??"Could not send reply")},async onReporterFeedback(l,c,y){let I=await u.replyToReporterReport(l,te(r),y??"",c);if(!I.ok)throw new Error(I.error?.message??"Could not send feedback");return I.data?.feedback??null},async onReporterReopen(l,c){let y=await u.reopenReporterReport(l,te(r),c);if(!y.ok)throw new Error(y.error?.message??"Could not reopen report");return y.data?.outcome??null},async onFeatureBoardRequest(){let l=await u.listReporterFeatureBoard(te(r));if(!l.ok)throw new Error(l.error?.message??"Could not load community ideas");return l.data?.tickets??[]},async onFeatureBoardVote(l){let c=await u.voteReporterFeatureBoard(l,te(r));if(!c.ok)throw new Error(c.error?.message??"Could not vote");return c.data??{voted:true,action:"added"}},onLeaderboardOpen(){v.setLeaderboard(null,true),Fa(10).then(l=>{v.setLeaderboard(l,false);});},async onMushiSignIn(l){let c=await u.sendMagicLink(l);if(!c.ok)throw new Error(c.error?.message??"Could not send sign-in link");return {ok:true}},async onGlobalLeaderboardOpen(){v.setGlobalLeaderboard(null,true);try{let l=Y(),c=await u.getPublicLeaderboard(50),I=(c.ok?c.data?.leaderboard??[]:[]).map($=>({tester_id:$.tester_id,rank:$.rank,public_handle:$.public_handle,display_name:$.display_name,points_30d:$.points_30d,total_points:$.total_points??0,badge:$.badge_slug}));if(v.setGlobalLeaderboard(I,!1),l){let $=await u.getMyReputation(l);if($.ok&&$.data){let N=$.data;N.reputation&&v.setTesterReputation(N.reputation);}}}catch{v.setGlobalLeaderboard([],false);}},async onCrossAppReportsOpen(){let l=Y();if(!l){v.setCrossAppReports([],false);return}try{let c=await u.getCrossAppReports(l),y=c.ok?c.data?.reports??[]:[];v.setCrossAppReports(y,!1);}catch{v.setCrossAppReports([],false);}},onTesterSignOut(){j();},assistantEnabled:e.assistant?.enabled===true,...e.assistant?.label?{assistantLabel:e.assistant.label}:{},...e.assistant?.greeting?{assistantGreeting:e.assistant.greeting}:{},...e.assistant?.suggestions?{assistantSuggestions:e.assistant.suggestions}:{},async onAssistantAsk(l,c){let y=await u.askAssistant({message:l,threadId:c,context:s});return y.ok?y.data??null:null}}),un.then(l=>v.setBrandRef(l)),Be(),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>v.mount()):v.mount());let Fi=Y();Fi&&ke(Fi).catch(()=>j());let Ni=null,qt=null,ee=i.proactive;ee&&(ee.rageClick!==false||ee.longTask!==false||ee.apiCascade!==false||ee.errorBoundary===true||ee.pageDwell||ee.firstSession)&&typeof document<"u"&&(qt=iu(ee?.cooldown),Ni=ru({onTrigger:(l,c)=>{if(typeof navigator<"u"&&!navigator.onLine){o.debug("Proactive trigger suppressed: offline",{type:l});return}if(!qt.shouldShow(l)){o.debug("Proactive trigger suppressed by fatigue prevention",{type:l});return}o.info("Proactive trigger fired",{type:l,context:c}),re=l,J("proactive:triggered",{type:l,context:c}),l==="first_session"?v.pulseTrigger?.():v.open();}},{rageClick:ee?.rageClick,longTask:ee?.longTask,apiCascade:ee?.apiCascade,apiEndpoint:Pi(i),errorBoundary:ee?.errorBoundary,ignoreErrors:i.ignoreErrors,denyUrls:i.denyUrls,allowUrls:i.allowUrls,pageDwell:ee?.pageDwell,firstSession:ee?.firstSession,projectId:e.projectId}),o.debug("Proactive triggers enabled",{rageClick:ee?.rageClick!==false,longTask:ee?.longTask!==false,apiCascade:ee?.apiCascade!==false,errorBoundary:ee?.errorBoundary===true,pageDwell:!!ee?.pageDwell,firstSession:!!ee?.firstSession})),h.startAutoSync(u),h.flush(u).then(l=>{l.sent>0&&o.info("Synced offline reports",{sent:l.sent});});function ln(l){if(_e=true,Ce=l.reporterNotificationsEnabled!==false,ot=l.enabled===false?null:l.reporter??null,st(),l.enabled===false){i=e,Qp(t.projectId),Be(),v.updateConfig(i.widget),z(),o.debug("Runtime SDK config disabled; using bootstrap config",{version:l.version});return}i=_a(i,l,e),Be(),l.widget&&v.updateConfig(i.widget),Ce?Ut():z(),o.debug("Applied runtime SDK config",{version:l.version});}if(zp(t)){let l=Xp(t.projectId);l&&ln(l),u.getSdkConfig().then(c=>{c.ok&&c.data?(Jp(t.projectId,c.data),ln(c.data)):c.error&&o.debug("Runtime SDK config unavailable",c.error);}).catch(c=>{o.debug("Runtime SDK config fetch failed",{error:c instanceof Error?c.message:String(c)});});}else o.debug("Runtime SDK config disabled via runtimeConfig:false; using static bootstrap config");gu(),Ut(),fu(),o.info("Initialized",{projectId:t.projectId});async function gu(){if(i.widget?.outdatedBanner==="off")return;let l=Zp(Ye);l&&Ui(l);let c=await u.getLatestSdkVersion(Ye);!c.ok||!c.data||(eh(Ye,c.data),Ui(c.data));}function Ui(l){let c=l.latest,y=!!(c&&th(we,c));if(!y&&!l.deprecated)return;let I=l.deprecationMessage??(y?`Update ${Ye} to ${c}.`:null);o.warn("Mushi SDK is outdated",{package:Ye,current:we,latest:c,deprecated:l.deprecated,message:I}),Ws(i.widget?.outdatedBanner,!!i.debug,typeof location>"u"?void 0:location)&&v.setSdkFreshness({latest:c,current:we,deprecated:l.deprecated,message:I});}async function bu(l,c,y,I){let $=p.check(c);if(!$.passed){o.info("Report blocked by pre-filter",{reason:$.reason});return}let N=t.preFilter?.wasmClassifier;if(N)try{let q=await N.classify({description:c,category:l,url:typeof location<"u"?location.href:void 0,hasScreenshot:O!==null,hasSelectedElement:G!==null,hasNetworkErrors:M?.getEntries()?.some(be=>be.status>=400||!!be.error)??!1,hasConsoleErrors:L?.getEntries()?.some(be=>be.level==="error")??!1,proactiveTrigger:re??void 0});if(q.verdict==="block"){o.info("Report blocked by on-device classifier",{modelId:q.modelId,confidence:q.confidence,reason:q.reason});return}o.debug("On-device classifier verdict",{...q});}catch(q){o.warn("On-device classifier threw \u2014 falling through to server",{error:q instanceof Error?q.message:String(q)});}if(re!==null&&t.sampleRate!==void 0&&t.sampleRate<1&&(t.sampleRate<=0||Math.random()>t.sampleRate)){o.debug("Report dropped by sampleRate",{sampleRate:t.sampleRate,trigger:re});return}if(!k.tryConsume()){o.warn("Report throttled \u2014 rate limit exceeded");return}let ue=S.scrub(p.truncate(c)),B=t.sentry?Ii(t.sentry):void 0,Z=await zo().catch(()=>null),Ne=i.capture?.console===false?void 0:E(L?.getEntries()),Ue=i.capture?.network===false?void 0:M?.getEntries(),br=T(X.getAll()),Wi=w(Object.keys(U).length>0?{...U}:void 0),Vi=B?{...B,...B.breadcrumbs?{breadcrumbs:T(B.breadcrumbs)}:{},...B.tags?{tags:w(B.tags)}:{}}:void 0,Ki=O?await Ds(O).catch(()=>null):null,Er=false;O&&!Ki&&(Er=true,o.warn("Screenshot dropped \u2014 could not compress under wire budget"));let zi=Dn(),Te={id:$n(),projectId:t.projectId,category:l,...I?{userCategory:I}:{},description:ue,userIntent:y,environment:zi,consoleLogs:Ne,networkLogs:Ue,performanceMetrics:i.capture?.performance===false?void 0:x?.getMetrics(),timeline:b.getEntries({consoleLogs:Ne,networkLogs:Ue}),screenshotDataUrl:Ki??void 0,selectedElement:G??void 0,...C?{replayEvents:C.flush()}:{},metadata:{...F,...R?{user:R}:{},...B?.release?{sentryRelease:B.release}:{}},sessionId:bt(),reporterToken:te(r),...Z?{fingerprintHash:Z}:{},appVersion:lu(i,zi),sdkPackage:Ye,sdkVersion:we,proactiveTrigger:re??void 0,...br.length>0?{breadcrumbs:br}:{},...Wi?{tags:Wi}:{},...Vi?{sentryContext:Vi}:{},sentryEventId:B?.eventId,sentryReplayId:B?.replayId,createdAt:new Date().toISOString()};if(X.add({category:"lifecycle",level:"info",message:`Mushi report submitting (${l})`,data:{reportId:Te.id,category:l}}),t.integrations?.custom){let q={addMetadata(be,dn){Te.metadata[be]=dn;},setCategory(be){Te.category=be;},setDescription(be){Te.description=be;}};t.integrations.custom(q);}let W=Te,Gi=t.beforeSend??t.beforeSendFeedback;if(Gi)try{let q=await Promise.race([Promise.resolve(Gi(Te)),new Promise(be=>setTimeout(()=>be(Te),2e3))]);if(q===null){o.info("Report dropped by beforeSend hook",{reportId:Te.id});return}W=q;}catch(q){o.warn("beforeSend hook threw \u2014 sending unmodified report",{error:q instanceof Error?q.message:String(q)});}if(J("report:submitted",{reportId:W.id}),typeof navigator<"u"&&!navigator.onLine)return await h.enqueue(W),o.info("Offline \u2014 report queued",{reportId:W.id}),J("report:queued",{reportId:W.id}),{reportId:null,queuedOffline:true,failureKind:"offline"};let V=await u.submitReport(W);if(!V.ok&&V.error?.code==="PAYLOAD_TOO_LARGE"&&(Array.isArray(W.replayEvents)&&W.replayEvents.length>0&&(o.warn("Report too large \u2014 dropping replay buffer and retrying",{reportId:W.id}),W={...W,replayEvents:void 0},V=await u.submitReport(W)),!V.ok&&V.error?.code==="PAYLOAD_TOO_LARGE"&&W.screenshotDataUrl&&(o.warn("Report still too large \u2014 dropping screenshot and retrying",{reportId:W.id}),Er=true,W={...W,screenshotDataUrl:void 0},V=await u.submitReport(W))),V.ok){if(o.info("Report sent",{reportId:V.data?.reportId}),J("report:sent",{reportId:V.data?.reportId}),ni(r),Nt(),V.data?.cursorAgentId){let q=V.data;J("report:dispatched",{reportId:q.reportId,agentId:q.cursorAgentId,fixId:q.fixId});}X.add({category:"lifecycle",level:"info",message:`Mushi report sent (${V.data?.reportId??Te.id})`}),Ft({action:"report_submit",metadata:{category:l,reportId:V.data?.reportId??Te.id}});try{t.sentry&&V.data?.reportId&&Mi(V.data.reportId);}catch{}}else {if(V.error?.code==="PAYLOAD_TOO_LARGE"||V.error?.code==="SERIALIZE_FAILED")return o.warn("Report exceeds size limit after degradation \u2014 dropping",{reportId:W.id,error:V.error}),J("report:failed",{reportId:W.id,error:V.error}),X.add({category:"lifecycle",level:"error",message:`Mushi report dropped \u2014 payload too large (${W.id})`}),O=null,G=null,re=null,{reportId:null,queuedOffline:false,failureKind:"permanent",screenshotDropped:Er};{let q=V.error?.code??"",be=q==="HTTP_429"||q.includes("RATE_LIMIT"),dn=q==="HTTP_401"||q.includes("UNAUTHORIZED")||q.includes("INVALID_API_KEY")||q.includes("MISSING_API_KEY"),Eu=q==="HTTP_403"||q.includes("QUOTA")||q.includes("FORBIDDEN")||q==="feature_not_in_plan";if(dn||Eu)return o.warn("Report rejected \u2014 credentials/quota",{reportId:W.id,error:V.error}),J("report:failed",{reportId:W.id,error:V.error}),O=null,G=null,re=null,{reportId:null,queuedOffline:false,failureKind:"quota"};if(be)return o.warn("Report rate-limited \u2014 queued for retry",{reportId:W.id,error:V.error}),await h.enqueue(W),J("report:failed",{reportId:W.id,error:V.error}),O=null,G=null,re=null,{reportId:null,queuedOffline:true,failureKind:"rate_limited"};o.warn("Report failed, queuing for retry",{reportId:W.id,error:V.error}),await h.enqueue(W),J("report:failed",{reportId:W.id,error:V.error}),X.add({category:"lifecycle",level:"warning",message:`Mushi report queued for retry (${W.id})`});}}return O=null,G=null,re=null,V?.ok?{reportId:V.data?.reportId??Te.id,queuedOffline:false,screenshotDropped:Er}:{reportId:null,queuedOffline:true,failureKind:"retrying"}}let cn={report(l){v.open(l);},on(l,c){return me.has(l)||me.set(l,new Set),me.get(l).add(c),()=>me.get(l)?.delete(c)},setUser(l){R=l;},setMetadata(l,c){F[l]=c;},setScreen(l){b.setScreen(l);},isOpen(){return v.getIsOpen()},open(){v.open();},openWith(l){v.open({category:l});},show(){v.showTrigger();},hide(){v.hideTrigger();},attachTo(l,c){return v.attachTo(l,c)},setTrigger(l){v.setTrigger(l);},openReporter(){v.openReporter();},close(){v.close();},updateConfig(l){ln(l);},diagnose(){return Gp({apiEndpoint:Pi(i),widgetMounted:v.getIsMounted(),runtimeConfigLoaded:_e,captureScreenshotAvailable:f!==null,captureNetworkIntercepting:M!==null,widgetDiagnostics:v.getWidgetDiagnostics()})},destroy(){Ni?.destroy(),qt?.reset(),hs(),v.destroy(),L?.destroy(),M?.destroy(),x?.destroy(),g?.deactivate(),Na(),Xe?.(),Xe=null,m?.destroy(),m=null,b.destroy(),Aa(),C?.destroy(),C=null,h.stopAutoSync(),z(),d?.(),d=null,ns(),X.clear(),me.clear(),He=null,o.debug("Destroyed");},async captureEvent(l){if(!k.tryConsume())return o.warn("captureEvent throttled \u2014 rate limit exceeded"),null;let c=S.scrub(p.truncate(l.description)),y=l.category??"bug",I=t.sentry?Ii(t.sentry):void 0,$=T(X.getAll()),N=w(Object.keys(U).length===0&&!l.tags?void 0:{...U,...l.tags??{}}),Q=I?{...I,...I.breadcrumbs?{breadcrumbs:T(I.breadcrumbs)}:{},...I.tags?{tags:w(I.tags)}:{}}:void 0,ue=Dn(),B={id:$n(),projectId:t.projectId,category:y,description:c,environment:ue,timeline:b.getEntries(),metadata:{...l.metadata??{},...R?{user:R}:{},...l.error?{error:l.error}:{},...l.severity?{severity:l.severity}:{},...l.component?{component:l.component}:{},...l.source?{source:l.source}:{source:"captureEvent"}},...$.length>0?{breadcrumbs:$}:{},...N&&Object.keys(N).length>0?{tags:N}:{},...Q?{sentryContext:Q}:{},sessionId:bt(),reporterToken:te(r),appVersion:lu(i,ue),sdkPackage:Ye,sdkVersion:we,sentryEventId:I?.eventId,sentryReplayId:I?.replayId,createdAt:new Date().toISOString()},Z=B;if(i.beforeSendFeedback)try{let Ue=await Promise.race([Promise.resolve(i.beforeSendFeedback(B)),new Promise(br=>setTimeout(()=>br(B),2e3))]);if(Ue===null)return o.info("captureEvent dropped by beforeSendFeedback hook",{reportId:B.id}),null;Z=Ue;}catch(Ue){o.warn("captureEvent beforeSendFeedback threw \u2014 sending unmodified report",{error:Ue instanceof Error?Ue.message:String(Ue)});}if(J("report:submitted",{reportId:Z.id}),typeof navigator<"u"&&!navigator.onLine)return await h.enqueue(Z),J("report:queued",{reportId:Z.id}),null;let Ne=await u.submitReport(Z);if(Ne.ok){J("report:sent",{reportId:Ne.data?.reportId});try{t.sentry&&Ne.data?.reportId&&Mi(Ne.data.reportId);}catch{}return Ne.data?.reportId??null}return await h.enqueue(Z),J("report:failed",{reportId:Z.id,error:Ne.error}),null},async captureException(l,c){let y=bs(l),I=typeof c?.metadata?.filename=="string"?c.metadata.filename:void 0;if(or({message:y.message,filename:I,ignoreErrors:i.ignoreErrors,denyUrls:i.denyUrls,allowUrls:i.allowUrls}))return null;X.add({category:"lifecycle",level:"error",message:`Mushi.captureException(${y.name}): ${y.message}`,...y.stack?{data:{stack:y.stack.slice(0,500)}}:{}});let $=c?.description?.trim()||`${y.name}: ${y.message}`||"Uncaught exception";return cn.captureEvent({description:$,category:c?.category??"bug",severity:c?.severity??"high",...c?.component?{component:c.component}:{},...c?.tags?{tags:c.tags}:{},source:c?.source??"captureException",error:{name:y.name,message:y.message,...y.stack?{stack:y.stack}:{}},metadata:{...c?.metadata??{},...y.cause?{cause:y.cause}:{}}})},identify(l,c){let y=`${l}::${c?JSON.stringify(c):""}`;if(y!==H){if(H=y,R={id:l,...c?.email?{email:c.email}:{},...c?.name?{name:c.name}:{}},v.setIdentifiedUser(R.name||R.email?{name:R.name,email:R.email}:null),st(),c)for(let[I,$]of Object.entries(c))I!=="email"&&I!=="name"&&(F[`user.${I}`]=$);X.add({category:"lifecycle",level:"info",message:`Mushi.identify(${l})`}),ds(l,c??null),Oi(l,c?{email:c.email,name:c.name,provider:c.provider}:void 0);}},identifyWithToken(l){if(a=l&&typeof l=="string"?l:null,a){let c=ks(a);if(c?.sub){if(R?.id===c.sub){X.add({category:"lifecycle",level:"info",message:"Mushi.identifyWithToken() refreshed"});return}rs(c.sub),R={id:c.sub,...c.email?{email:c.email}:{},...c.name?{name:c.name}:{}},v.setIdentifiedUser(R.name||R.email?{name:R.name,email:R.email}:null),Oi(R.id,{email:R.email,name:R.name});}X.add({category:"lifecycle",level:"info",message:"Mushi.identifyWithToken()"});}else R=null,H=null,v.setIdentifiedUser(null),X.add({category:"lifecycle",level:"info",message:"Mushi.identifyWithToken(null)"});},publishPageContext(l){s=l&&l.route?l:null;},openAssistant(){v.openAssistantTab();},addBreadcrumb(l){X.add(l);},getBreadcrumbs(){return X.getAll()},setTag(l,c){typeof l!="string"||l.length===0||(U[l]=c);},setTags(l){if(!(!l||typeof l!="object"))for(let[c,y]of Object.entries(l))typeof c=="string"&&c.length>0&&(U[c]=y);},clearTag(l){if(typeof l=="string"&&l.length>0){delete U[l];return}for(let c of Object.keys(U))delete U[c];},async getReputation(){if(!R?.id)return null;let l=await u.getMyPoints(R.id);return l.ok?{totalPoints:l.data.total_points??0,points30d:l.data.points_30d??0,reputation:1,confirmedBugs:0,totalReports:0}:null},async getTier(){return R?.id?Ba(R.id):null},recordActivity(l,c){i.rewards?.enabled&&Ft({action:l,metadata:c});},track(l,c){return Ct(l,c)},setConsent(l){cs(l);},getAnonymousId(){return us()},pulseTrigger(){v.pulseTrigger?.();},async listMyReports(){let l=await u.listReporterReports(te(r));return l.ok?l.data?.reports??[]:[]},async listMyComments(l){let c=await u.listReporterComments(l,te(r));return c.ok?c.data?.comments??[]:[]},async replyToReport(l,c){let y=await u.replyToReporterReport(l,te(r),c);return y.ok?y.data?.comment??null:null},async submitFeedbackSignal(l,c,y){let I=await u.replyToReporterReport(l,te(r),y??"",c);return I.ok?I.data?.feedback??null:null},async reopenReport(l,c){let y=await u.reopenReporterReport(l,te(r),c);return y.ok?y.data?.outcome??null:null},openMyReports(){v.recorderOpenMyReports();},getReporterUpdates:ge,async markReportRead(l){let c=await ie.markReportRead(l,n());return c.ok?c.data?.unread_total??0:null},onReporterUpdate(l){return he.add(l),ge(),()=>{he.delete(l);}},async getNotificationPrefs(){let l=await ie.getPrefs(n());return l.ok?l.data??null:null},setNotificationPrefs:l=>ie.setPrefs(n(),l),async subscribeReporterPush(){let l=i.notifications?.webPush,c=ot?.vapidPublicKey??null;if(l&&!c){let y=await u.getSdkConfig();c=y.ok?y.data?.reporter?.vapidPublicKey??null:null;}return ka(ie,n(),l?l.serviceWorkerPath:null,c)},async getHallOfFame(l=20){let c=await u.getHallOfFame(l);return c.ok?c.data?.data??[]:[]}};if(typeof globalThis<"u"&&(e.debug??false)&&Ca(v),typeof window<"u"&&typeof localStorage<"u"){let l="mushi:last-run",c=null;try{let y=localStorage.getItem(l);c=y===null?null:y==="unfinished",localStorage.setItem(l,"unfinished");}catch{c=null;}try{window.addEventListener("pagehide",()=>{try{localStorage.setItem(l,"clean");}catch{}$o(),Oo();});}catch{}if(typeof e.onCrashedLastRun=="function")try{e.onCrashedLastRun(c);}catch(y){o.warn("onCrashedLastRun hook threw",{error:y instanceof Error?y.message:String(y)});}}let qi={on:()=>{},onReporterUpdate:()=>{},isOpen:false,getBreadcrumbs:[],captureEvent:null,captureException:null,getReputation:null,getTier:null,listMyReports:[],listMyComments:[],getHallOfFame:[],replyToReport:null,submitFeedbackSignal:null,reopenReport:null},ji=(l,c)=>{let y=c instanceof Error?c.message:String(c);o.debug(`Mushi.${l}() failed (swallowed)`,{error:y});try{X.add({category:"custom",level:"warning",message:`mushi.${l}() threw`,data:{error:y}});}catch{}};return (l=>new Proxy(l,{get(c,y,I){let $=Reflect.get(c,y,I);if(typeof $!="function")return $;let N=String(y),Q=()=>N==="diagnose"?Di():N in qi?qi[N]:void 0;return (...ue)=>{try{let B=$.apply(c,ue);return B&&typeof B.then=="function"?B.catch(Z=>(ji(N,Z),Q())):B}catch(B){return ji(N,B),Q()}}}}))(cn)}function Pi(t){return t.apiEndpoint??Yt}function zp(t){return t.runtimeConfig!==false}async function Gp(t){let e=await Yp(t.apiEndpoint);return {apiEndpointReachable:e.reachable,cspAllowsEndpoint:e.cspAllowed,widgetMounted:t.widgetMounted,shadowDomAvailable:typeof HTMLElement<"u"&&typeof HTMLElement.prototype.attachShadow=="function",dialogSupported:typeof HTMLDialogElement<"u",runtimeConfigLoaded:t.runtimeConfigLoaded,captureScreenshotAvailable:t.captureScreenshotAvailable,captureNetworkIntercepting:t.captureNetworkIntercepting,sdkVersion:we,widgetHostPointerSafe:t.widgetDiagnostics?.widgetHostPointerSafe??false,widgetHostBounds:t.widgetDiagnostics?.widgetHostBounds??null,widgetSuppressed:t.widgetDiagnostics?.widgetSuppressed??false,bannerRendered:t.widgetDiagnostics?.bannerRendered??false}}async function Di(){return {apiEndpointReachable:false,cspAllowsEndpoint:false,widgetMounted:false,shadowDomAvailable:typeof HTMLElement<"u"&&typeof HTMLElement.prototype.attachShadow=="function",dialogSupported:typeof HTMLDialogElement<"u",runtimeConfigLoaded:false,captureScreenshotAvailable:false,captureNetworkIntercepting:false,sdkVersion:we,widgetHostPointerSafe:false,widgetHostBounds:null,widgetSuppressed:false,bannerRendered:false}}async function Yp(t){if(typeof fetch>"u")return {reachable:false,cspAllowed:false};let e=typeof AbortController<"u"?new AbortController:null,r=e?setTimeout(()=>e.abort(),3e3):null;try{return {reachable:(await fetch(`${t.replace(/\/$/,"")}/health`,{method:"GET",cache:"no-store",...e?{signal:e.signal}:{},[ir]:"diagnose"})).ok,cspAllowed:!0}}catch{return {reachable:false,cspAllowed:false}}finally{r&&clearTimeout(r);}}function $i(t){return `mushi:sdk-config:${t}`}function hu(t){return `mushi:sdk-version:${t}`}function Xp(t){if(typeof localStorage>"u")return null;try{let e=localStorage.getItem($i(t));return e?JSON.parse(e).config??null:null}catch{return null}}function Jp(t,e){if(!(typeof localStorage>"u"))try{localStorage.setItem($i(t),JSON.stringify({cachedAt:Date.now(),config:e}));}catch{}}function Qp(t){if(!(typeof localStorage>"u"))try{localStorage.removeItem($i(t));}catch{}}function Zp(t){if(typeof localStorage>"u")return null;try{let e=localStorage.getItem(hu(t));if(!e)return null;let r=JSON.parse(e);return !r.data||!r.cachedAt||Date.now()-r.cachedAt>864e5?null:r.data}catch{return null}}function eh(t,e){if(!(typeof localStorage>"u"))try{localStorage.setItem(hu(t),JSON.stringify({cachedAt:Date.now(),data:e}));}catch{}}function th(t,e){let r=cu(t),n=cu(e);for(let i=0;i<Math.max(r.length,n.length);i++){let o=r[i]??0,a=n[i]??0;if(o<a)return true;if(o>a)return false}return false}function cu(t){return t.split(/[.-]/).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e))}function du(){return {report:()=>{},on:()=>()=>{},setUser:()=>{},setMetadata:()=>{},setScreen:()=>{},isOpen:()=>false,open:()=>{},close:()=>{},updateConfig:()=>{},diagnose:Di,openWith:()=>{},show:()=>{},hide:()=>{},attachTo:()=>()=>{},setTrigger:()=>{},openReporter:()=>{},destroy:()=>{He=null;},captureEvent:async()=>null,captureException:async()=>null,identify:()=>{},identifyWithToken:()=>{},publishPageContext:()=>{},openAssistant:()=>{},addBreadcrumb:()=>{},getBreadcrumbs:()=>[],setTag:()=>{},setTags:()=>{},clearTag:()=>{},getReputation:async()=>null,getTier:async()=>null,recordActivity:()=>{},track:()=>false,setConsent:()=>{},getAnonymousId:()=>null,pulseTrigger:()=>{},listMyReports:async()=>[],listMyComments:async()=>[],replyToReport:async()=>null,submitFeedbackSignal:async()=>null,reopenReport:async()=>null,openMyReports:()=>{},getHallOfFame:async()=>[],getReporterUpdates:async()=>null,markReportRead:async()=>null,onReporterUpdate:()=>()=>{},getNotificationPrefs:async()=>null,setNotificationPrefs:async()=>({ok:false}),subscribeReporterPush:async()=>({ok:false,reason:"off"})}}function rh(t){if(typeof window>"u")return ()=>{};let e=[];try{let r=i=>{t.add({category:"navigation",level:"info",message:`${i}: ${window.location.pathname}`,data:{url:window.location.href,kind:i}});},n=Me({onPush:()=>r("pushState"),onReplace:()=>r("replaceState"),onPop:()=>r("popstate")});e.push(n);}catch{}try{let r=console.error,n=console.warn,i=function(...a){try{t.add({category:"console",level:"error",message:a.map(pu).join(" ")});}catch{}return r.apply(this,a)},o=function(...a){try{t.add({category:"console",level:"warning",message:a.map(pu).join(" ")});}catch{}return n.apply(this,a)};console.error=i,console.warn=o,e.push(()=>{console.error===i&&(console.error=r),console.warn===o&&(console.warn=n);});}catch{}try{let r=n=>{try{let i=n.target;if(!(i instanceof Element))return;let o=i,a=0;for(;o&&a<10;){let s=o.getAttribute("data-testid");if(s){let u=(o.textContent??"").trim().slice(0,80);t.add({category:"ui.click",level:"info",message:`clicked ${s}${u?` \u2014 ${u}`:""}`,data:{testid:s,tag:o.tagName.toLowerCase()}});return}o=o.parentElement,a++;}}catch{}};document.addEventListener("click",r,{passive:!0,capture:!0}),e.push(()=>document.removeEventListener("click",r,!0));}catch{}return ()=>{for(let r of e)try{r();}catch{}}}function pu(t){try{if(t instanceof Error)return `${t.name}: ${t.message}`;if(typeof t=="object"&&t!==null){let r=JSON.stringify(t);return r.length>200?`${r.slice(0,200)}\u2026`:r}let e=String(t);return e.length>200?`${e.slice(0,200)}\u2026`:e}catch{return `[${typeof t}]`}}function nh(){let t=document.currentScript;if(t&&t.dataset&&t.dataset.project)return t;let e=Array.from(document.querySelectorAll("script[data-project][data-key]"));return e.length>0?e[e.length-1]:null}function ih(t){let e=t.project?.trim(),r=t.key?.trim();if(!e||!r)return null;let n={};t.trigger&&(n.trigger=t.trigger),t.theme&&(n.theme=t.theme),t.position&&(n.position=t.position),t.triggerText&&(n.triggerText=t.triggerText);let i=t.bannerVariant,o=t.bannerPosition;(i||o)&&(n.bannerConfig={...i?{variant:i}:{},...o?{position:o}:{}});let a={projectId:e,apiKey:r};return t.endpoint&&(a.apiEndpoint=t.endpoint),t.debug==="true"&&(a.debug=true),Object.keys(n).length>0&&(a.widget=n),a}function oh(){if(typeof document>"u"||typeof window>"u")return;let t=window;if(t.__mushiLoaderInit)return;let e=nh();if(!e)return;let r=ih(e.dataset);if(r){t.__mushiLoaderInit=true;try{an.init(r);}catch{}}}oh();
96
96
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mushi-mushi/web",
3
- "version": "1.31.1",
3
+ "version": "1.31.2",
4
4
  "description": "Bug report and user feedback widget for the web. The bug mediator for AI-built apps: plain-English diagnosis + a ready fix, in your editor.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -162,7 +162,7 @@
162
162
  }
163
163
  ],
164
164
  "dependencies": {
165
- "@mushi-mushi/core": "^1.31.0"
165
+ "@mushi-mushi/core": "^1.31.2"
166
166
  },
167
167
  "peerDependencies": {
168
168
  "rrweb": "^2.0.1"