@lumen-stack/react 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +50 -21
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';var Rn=require('react'),sonner=require('sonner'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Rn__namespace=/*#__PURE__*/_interopNamespace(Rn);var I=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},$t=class extends I{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},Kt=class extends I{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},st=class extends I{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},wr="https://shakebugs.vercel.app",yr="/api/v1/sdk/submit",Er="/api/v1/sdk/error",Cr="0.13.2",Rr=5,Sr=new Set([502,503,504]),tn=class{apiKey;apiUrl;user;amplitude;#e=new Set;#t=0;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new I("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??wr).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${yr}`,r=this.#n(e),o=null;for(let a=0;a<3;a++){a>0&&await xr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof $t||i instanceof Kt||i instanceof I&&typeof i.status=="number"&&!Sr.has(i.status))throw i}}throw o instanceof Error?o:new st("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Rr)return;let t=(e.stack??"").split(`
|
|
3
3
|
`)[1]?.trim()??"",n=`${e.name}:${e.message}@${t}`;if(this.#e.has(n))return;this.#e.add(n),this.#t+=1;let r=typeof navigator<"u"?navigator:void 0,o=typeof performance<"u"?performance.memory:void 0,a;try{let s=new URL(window.location.href);a=s.origin+s.pathname;}catch{a=void 0;}let i={message:String(e.message??"").slice(0,1e3),name:String(e.name??"Error").slice(0,200),stack:e.stack?.slice(0,8e3),componentStack:e.componentStack?.slice(0,8e3),url:a,userAgent:r?.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},dpr:window.devicePixelRatio,deviceMemory:r?.deviceMemory,jsHeap:o?{used:o.usedJSHeapSize,limit:o.jsHeapSizeLimit}:void 0,sdkVersion:Cr,context:e.context};fetch(`${this.apiUrl}${Er}`,{method:"POST",headers:{"Content-Type":"application/json","X-Lumen-Api-Key":this.apiKey},body:JSON.stringify(i),keepalive:!0,credentials:"omit",mode:"cors"}).catch(()=>{});}catch{}}#n(e){let t=new FormData;e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),e.submitterEmail&&t.append("submitterEmail",e.submitterEmail),e.submitterFingerprint&&t.append("submitterFingerprint",e.submitterFingerprint);let n=e.context.amplitude??this.amplitude,r=n?{...e.context,amplitude:n}:e.context;return t.append("context",JSON.stringify(r)),e.screenshot&&t.append("screenshot",e.screenshot,kr(e.screenshot)),e.audio&&t.append("audio",e.audio,"audio"),e.audioDurationMs!=null&&t.append("audioDurationMs",String(e.audioDurationMs)),e.video&&t.append("video",e.video,"video"),e.videoDurationMs!=null&&t.append("videoDurationMs",String(e.videoDurationMs)),t}#r(e,t,n){return new Promise((r,o)=>{let a=new XMLHttpRequest;a.open("POST",e,true),a.setRequestHeader("X-Lumen-Api-Key",this.apiKey),a.responseType="text";let{onUploadProgress:i,signal:s}=n;i&&a.upload.addEventListener("progress",l=>{l.lengthComputable&&l.total>0&&i(Math.min(1,l.loaded/l.total));});let c=()=>{a.abort(),o(new st("Submit aborted."));};if(s){if(s.aborted){o(new st("Submit aborted."));return}s.addEventListener("abort",c,{once:true});}a.addEventListener("load",()=>{if(s&&s.removeEventListener("abort",c),a.status===403){o(new $t);return}if(a.status===429){let l=Number(a.getResponseHeader("Retry-After"))||60;o(new Kt(l));return}if(a.status<200||a.status>=300){o(new I(Mr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let l=JSON.parse(a.responseText);r(l);}catch{o(new I("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{s&&s.removeEventListener("abort",c),o(new st("Network error during submit."));}),a.send(t);})}};function kr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function xr(e){return new Promise(t=>setTimeout(t,e))}function Mr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var nn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function rn(e=nn){if(!e||typeof document>"u")return ()=>{};let t=[];for(let n of Array.from(document.querySelectorAll(e)))t.push({el:n,prev:n.style.visibility}),n.style.visibility="hidden";return ()=>{for(let{el:n,prev:r}of t)n.style.visibility=r;}}var Lr=2,Tr=1.5,Ar=820,Pr=12,Ye=8*1024*1024;async function ct(e={}){Mt();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return _r(await e.provider(),e)}catch(n){if(t==="custom")throw n;e.onWarning?.(["Custom capture provider failed; falling back to browser DOM capture."]);}if(t==="manual")throw new I("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return Yt(e);if(t==="dom")return qt(e);if(t==="custom")throw new I("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await qt(e)}catch(n){if(un()){let r=await Yt(e);return r.warnings=Ze(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function Ge(e,t=[]){Mt();let n=dt();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:Ze(t)}}var Wt=Promise.resolve();function qt(e){let t=Wt.then(()=>jt(e),()=>jt(e));return Wt=t.catch(()=>{}),t}async function jt(e){let t=await Hr(),n=e.target??document.documentElement,r=dt(),o=Fr(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),s=window.scrollY+(a?.offsetTop??0),c=Ur(e,r.width,r.height),l=Vr(n);!e.provider&&Br()&&l.unshift(`Lumen is capturing inside a React Native WebView with no native capture provider, so this screenshot is a DOM re-render \u2014 it won't match the native screen and omits native overlays/inputs. Wire createNativeCaptureProvider() with capture mode "custom" (see docs/native-screenshot-expo.md).`);let d=Dr(n);await ln(e.awaitAnimationsMs??Kr),await $r();let p=await t(n,{backgroundColor:null,logging:false,useCORS:true,allowTaint:false,width:r.width,height:r.height,windowWidth:o.width,windowHeight:o.height,scrollX:window.scrollX,scrollY:window.scrollY,x:i,y:s,scale:c,ignoreElements:b=>b instanceof HTMLElement&&(b.dataset.lumenCaptureIgnore==="true"||!!b.closest("[data-lumen-capture-ignore='true']")),onclone:(b,w)=>{Or(w,d),Nr(b);}}),C={blob:await sn(p,l),method:"web-dom",platform:"web",viewport:r,pixelRatio:c,warnings:Ze(l)};return C.warnings.length>0&&e.onWarning?.(C.warnings),C}var on=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function Nr(e){for(let t of Array.from(e.querySelectorAll(on))){if(t.nodeName==="INPUT"||t.nodeName==="TEXTAREA"){let n=t;n.value&&(n.value="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");continue}t.style.visibility="hidden";}}var Ir="[data-lumen-root], [data-lumen-capture-ignore='true']";function an(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(Ir))}function Dr(e){return an(e).map(t=>{if(t.matches(on))return {skip:true};let n=t.type;return n==="checkbox"||n==="radio"?{skip:false,checked:t.checked}:n==="file"?{skip:true}:{skip:false,value:t.value}})}function Or(e,t){let n=an(e);n.length===t.length&&n.forEach((r,o)=>{let a=t[o];!a||a.skip||(a.checked!==void 0?r.checked=a.checked:a.value!==void 0&&(r.value=a.value));});}function Br(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function Hr(){let{default:e}=await import('html2canvas-pro');return e}async function xt(e={}){if(Mt(),!un())throw new I("Browser screen capture is unavailable in this environment.","DISPLAY_MEDIA_UNAVAILABLE");let t=await navigator.mediaDevices.getDisplayMedia({video:true,audio:false}),n=null;try{n=document.createElement("video"),n.muted=!0,n.playsInline=!0,n.srcObject=t,await Wr(n);}catch(i){for(let s of t.getTracks())s.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(s=>s());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let s=i?.conceal??true,c=s?rn():()=>{};try{s&&await qr(r,3,400);let l=document.createElement("canvas");l.width=r.videoWidth,l.height=r.videoHeight;let d=l.getContext("2d");if(!d)throw new I("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");d.drawImage(r,0,0,l.width,l.height);let p=dt(),C=["Browser screen capture uses the window or tab selected by the user."],b={blob:await sn(l,C),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?l.width/p.width:void 0,warnings:Ze(C)};return e.onWarning?.(b.warnings),b}finally{c();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function Yt(e){let t=await xt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function _r(e,t){let n=dt(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:Ze(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function Vr(e){let t=new Set;e.querySelector("iframe")&&t.add("Embedded iframes may be blank or incomplete in DOM capture."),e.querySelector("video")&&t.add("Video frames may be blank or stale in DOM capture."),e.querySelector("canvas")&&t.add("Canvas/WebGL content may be blank if it is cross-origin tainted."),document.fonts&&document.fonts.status!=="loaded"&&t.add("Web fonts were still loading when the screenshot was captured.");let n=0;for(let r of Array.from(e.querySelectorAll("img"))){let o=r.currentSrc||r.src;if(o)try{new URL(o,window.location.href).origin!==window.location.origin&&!r.crossOrigin&&(n+=1);}catch{}}return n>0&&t.add(`${n} cross-origin image${n===1?"":"s"} without CORS may be omitted from the screenshot.`),Array.from(t)}async function sn(e,t){let n=await Gt(e,"image/png",.92);if(n.size<=Ye)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>Ye&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(Ye/n.size)*.9)),i=document.createElement("canvas");i.width=Math.max(1,Math.round(r.width*a)),i.height=Math.max(1,Math.round(r.height*a));let s=i.getContext("2d");if(!s)return n;s.drawImage(r,0,0,i.width,i.height),r=i;for(let c of [.86,.74,.62,.5])if(n=await Gt(r,"image/jpeg",c),n.size<=Ye)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>Ye&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function Gt(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new I("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function dt(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function Fr(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function Ur(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??Lr;zr()&&(o=Math.min(o,Tr));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(Pr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function zr(){let e=typeof navigator<"u"&&(navigator.maxTouchPoints??0)>0||typeof window<"u"&&"ontouchstart"in window,t=document.documentElement.clientWidth||window.innerWidth||0;return e&&t>0&&t<=Ar}function $r(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var Kr=400;async function ln(e){if(typeof document>"u"||typeof document.getAnimations!="function"||!(e>0))return;let t;try{t=document.getAnimations();}catch{return}let n=t.filter(a=>{if(a.playState!=="running")return false;let i=a.effect?.getComputedTiming?.();return !!i&&i.iterations!==1/0});if(n.length===0)return;let r=Promise.allSettled(n.map(a=>a.finished)).then(()=>{}),o=new Promise(a=>setTimeout(a,e));await Promise.race([r,o]);}function un(){return !!navigator.mediaDevices?.getDisplayMedia}async function Wr(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new I("Could not read screen capture video.","VIDEO_FAILED"));e.addEventListener("loadedmetadata",a,{once:true}),e.addEventListener("error",i,{once:true}),e.play().catch(i);});let t=performance.now(),n=1500;for(;e.videoWidth===0||e.videoHeight===0;){if(performance.now()-t>n)throw new I("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function qr(e,t,n){let r=e.requestVideoFrameCallback?.bind(e);if(typeof r!="function"){await new Promise(i=>setTimeout(i,Math.min(n,250)));return}let o=performance.now(),a=0;await new Promise(i=>{let s=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(s);};r(s),setTimeout(i,n);});}function Mt(){if(typeof window>"u"||typeof document>"u")throw new I("Screenshot capture can only run in the browser.","INVALID_ENV")}function Ze(e){return Array.from(new Set(e.filter(Boolean)))}var cn=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,jr=[/-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----[\s\S]*?-----END (?:[A-Z]+ )?PRIVATE KEY-----/g,/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,/\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA|ANVA|AIPA)[A-Z0-9]{16}\b/g,/\bgh[posru]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{18,}\b/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g,/\bAIza[A-Za-z0-9_-]{35}\b/g,/\b[srp]k_(?:live|test)_[A-Za-z0-9]{10,}\b/g,/\bsk-(?:proj-|ant-)?[A-Za-z0-9_-]{32,}\b/g];function Yr(e){let t=e.replace(/\D/g,"");if(t.length<13||t.length>19)return false;let n=0,r=false;for(let o=t.length-1;o>=0;o--){let a=t.charCodeAt(o)-48;r&&(a*=2,a>9&&(a-=9)),n+=a,r=!r;}return n%10===0}function Ct(e){let t=e;for(let n of jr)t=t.replace(n,"***");return t=t.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._\-+/=]+/gi,"$1 ***"),t=t.replace(/\b([A-Za-z_][\w-]*)"?\s*[=:]\s*("?)([^"\s&]{6,})\2/g,(n,r,o,a)=>/^(Bearer|Basic)$/i.test(a)?n:cn.test(r)?`${r}=${o}***${o}`:a.length>=24&&/^[A-Za-z0-9._\-+/=]+$/.test(a)&&!a.includes(" ")?`${r}=${o}${a.slice(0,4)}\u2026${o}`:n),t=t.replace(/\b\d(?:[ -]?\d){12,18}\b/g,n=>Yr(n)?"***":n),t=t.replace(/\b\d{3}-\d{2}-\d{4}\b/g,"***"),t=t.replace(/\b[\w.+-]+@[\w-]+\.[\w.-]+\b/g,"***@***"),t}function dn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])cn.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Ct(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Ct(e)}}function mn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return dn(e)}}var Zt=200,Xt=4096,pn=[],lt=[],Jt=false,Rt=null;function fn(e={}){Jt||typeof window>"u"||(Jt=true,Rt=e.ignoreUrlPrefix??null,Jr(),Qr(),eo());}function Gr(){return {consoleLog:pn.slice(),networkLog:lt.slice()}}function ut(e,t){e.push(t),e.length>Zt&&e.splice(0,e.length-Zt);}function Zr(e){let t=[];for(let r of e){if(typeof r=="string"){t.push(r);continue}if(r instanceof Error){t.push(`${r.name}: ${r.message}${r.stack?`
|
|
4
|
-
${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,Xr));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>Xt?n.slice(0,Xt)+"\u2026[truncated]":n}function Xr(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Jr(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let r=e[n]?.bind(e);r&&(e[n]=(...o)=>{try{ut(pn,{level:n,ts:Date.now(),message:Ct(Zr(o))});}catch{}r(...o);});}}function gn(e){return Rt?e.startsWith(Rt):false}function Qr(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let r=typeof t=="string"?t:t instanceof URL?t.toString():t.url,o=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(gn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ut(lt,{type:"fetch",method:o,url:St(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ut(lt,{type:"fetch",method:o,url:St(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function eo(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...a){return this.__lumen={method:String(r).toUpperCase(),url:typeof o=="string"?o:o.toString(),t:0},t.call(this,r,o,...a)},e.prototype.send=function(r){let o=this.__lumen;if(o&&!gn(o.url)){o.t=performance.now();let a=()=>{try{ut(lt,{type:"xhr",method:o.method,url:St(o.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-o.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,r??null)};}function to(e){return e.length>512?e.slice(0,512)+"\u2026":e}function St(e){return to(dn(e))}function hn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:Qt(e),consoleLog:[],networkLog:[]};let t=Gr();return {url:mn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:Qt(e),device:no(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function no(){let e={};try{e.screen={width:window.screen?.width??0,height:window.screen?.height??0},e.pixelRatio=window.devicePixelRatio??1,e.language=navigator.language,e.languages=Array.from(navigator.languages??[]),e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,e.colorScheme=window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light",e.referrer=document.referrer?mn(document.referrer):void 0,e.title=document.title||void 0,e.online=navigator.onLine,performance.getEntriesByType("navigation")[0]&&(e.uptimeMs=Math.round(performance.now()));}catch{}return e}function Qt(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var ro="[data-lumen-root]",oo="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function ao(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(kt(n))return true;return kt(e.target)}var en=["pointerdown","mousedown","touchstart","click"];function io(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of en)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of en)e.removeEventListener(n,t);}}function kt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(oo)?true:!!e.closest(ro):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?kt(e.host):false:false}var mt="lumen:shake",so=8e3,lo=50,uo=400;function co(e={}){return async function(){if(typeof window>"u")throw new I("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=po(),n=e.send??mo,r=e.timeoutMs??so,o=e.captureSettleMs??lo,a=e.awaitAnimationsMs??uo,i=vo(),s=rn(e.concealSelector===void 0?nn:e.concealSelector);try{await go(o,a);let c=await new Promise((p,C)=>{let b=window.setTimeout(()=>{t.pending.delete(i),C(new I("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:w=>{window.clearTimeout(b),p(w);},reject:w=>{window.clearTimeout(b),C(w);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(b),C(new I("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(c.error||!c.dataUrl)throw new I(c.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let l=wo(c.dataUrl),d=e.platform??bo();return {blob:l,method:d==="android"?"android-native":"ios-native",platform:d,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:c.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{s();}}}function mo(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new I("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function po(){if(window.__lumenNativeCapture)return window.__lumenNativeCapture;let e={pending:new Map,resolve(n,r,o){let a=e.pending.get(n);a&&(e.pending.delete(n),a.resolve({type:"lumen:capture-response",id:n,dataUrl:r,pixelRatio:o}));},reject(n,r){let o=e.pending.get(n);o&&(e.pending.delete(n),o.resolve({type:"lumen:capture-response",id:n,error:r}));}},t=n=>{let r=fo(n.data);if(!r||r.type!=="lumen:capture-response")return;let o=e.pending.get(r.id);o&&(e.pending.delete(r.id),o.resolve(r));};return window.addEventListener("message",t),document.addEventListener("message",t),window.__lumenNativeCapture=e,e}function fo(e){if(e&&typeof e=="object"&&"type"in e)return e;if(typeof e=="string")try{let t=JSON.parse(e);if(t&&typeof t=="object"&&t.type)return t}catch{}return null}async function go(e,t){await ln(t),await ho(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function ho(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function bo(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function vo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function wo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new I("Native host returned an invalid image data URL.","NATIVE_CAPTURE_FAILED");let n=t[1]||"image/png",r=!!t[2],o=t[3]??"";if(!r)return new Blob([decodeURIComponent(o)],{type:n});let a=atob(o),i=new Uint8Array(a.length);for(let s=0;s<a.length;s++)i[s]=a.charCodeAt(s);return new Blob([i],{type:n})}var Xe="lumen:keyboardchange",Lt="--lumen-keyboard-inset";function yo(e){if(typeof window>"u")return;let t=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):0;window.__lumenKeyboardInset=t,typeof document<"u"&&document.documentElement.style.setProperty(Lt,`${t}px`),window.dispatchEvent(new Event(Xe));}function Tt(){if(typeof window>"u")return null;let e=window.__lumenKeyboardInset;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof document<"u"&&typeof getComputedStyle=="function"){let t=getComputedStyle(document.documentElement).getPropertyValue(Lt).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function bn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new I("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new I("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(b=>MediaRecorder.isTypeSupported(b))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,c=false,l,d,p=new Promise((b,w)=>{l=b,d=w;});p.catch(()=>{}),r.addEventListener("dataavailable",b=>{b.data&&b.data.size>0&&o.push(b.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let L of t.getTracks())L.stop();if(c)return;if(c=true,s){d(new I("Recording cancelled.","RECORDER_STOPPED"));return}let b=performance.now()-a,w=r.mimeType||n||"audio/webm",M=new Blob(o,{type:w});l({blob:M,durationMs:b,mimeType:w});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function C(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){s=true,C(),i!==null&&window.clearTimeout(i),i=null;for(let b of t.getTracks())b.stop();},stop(){return C(),p}}}async function vn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new I("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new I("Screen capture was denied or cancelled.","SCREEN_DENIED")}let n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(w=>MediaRecorder.isTypeSupported(w))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,c=false,l,d,p=new Promise((w,M)=>{l=w,d=M;});p.catch(()=>{});function C(){i!==null&&(window.clearTimeout(i),i=null);for(let w of t.getTracks())w.stop();}r.addEventListener("dataavailable",w=>{w.data&&w.data.size>0&&o.push(w.data);}),r.addEventListener("stop",()=>{if(s)return;if(s=true,C(),c){d(new I("Recording cancelled.","RECORDER_STOPPED"));return}let w=r.mimeType||n||"video/webm";l({blob:new Blob(o,{type:w}),durationMs:performance.now()-a,mimeType:w});});function b(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(b,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",b),{stream:t,result:p,stop:b,cancel(){c=true,r.state!=="inactive"?r.stop():s||(s=true,C(),d(new I("Recording cancelled.","RECORDER_STOPPED")));}}}var At=Rn.createContext(null);function Je(){let e=Rn.useContext(At);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var wn=100;function yn(){if(typeof document>"u")return false;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;if(!e)return false;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?true:e.isContentEditable===true}var Qe={open:false,inset:0};function ko(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:Qe}if(e.vvHeight==null||!e.coarse||!e.editable)return Qe;let n=e.vvBaseline-e.vvHeight;return n>wn?{open:true,inset:Math.round(n)}:Qe}function et(e,t){let[n,r]=Rn.useState(Qe),o=Rn.useRef(0),a=Rn.useRef(t);return a.current=t,Rn.useEffect(()=>{if(!e){r(Qe);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,s=()=>{let p=yn(),C=a.current,b=Tt(),w=window.visualViewport??null;w&&C==null&&b==null&&!p&&(o.current=w.height),r(ko({editable:p,override:C,injected:b,vvBaseline:o.current,vvHeight:w?w.height:null,coarse:i}));},c=0,l=()=>{c||(c=window.requestAnimationFrame(()=>{c=0,s();}));},d=window.visualViewport;return d&&(o.current=d.height),l(),d?.addEventListener("resize",l),d?.addEventListener("scroll",l),document.addEventListener("focusin",l),document.addEventListener("focusout",l),window.addEventListener(Xe,l),()=>{c&&window.cancelAnimationFrame(c),d?.removeEventListener("resize",l),d?.removeEventListener("scroll",l),document.removeEventListener("focusin",l),document.removeEventListener("focusout",l),window.removeEventListener(Xe,l);}},[e]),n}var Nt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Cn(e,t=1){return Math.max(0,Math.min(t,e))}var Sn=Rn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},s){let c=Rn.useRef(null),l=Rn.useRef(null),d=Rn.useRef(null),[p,C]=Rn.useState(null),[b,w]=Rn.useState(false),[M,L]=Rn.useState(""),[S,T]=Rn.useState([]),h=Rn.useRef(null),y=Rn.useRef(false),B=Rn.useRef(0),P=Rn.useRef(false),[H,N]=Rn.useState([]),ae=Rn.useRef(0),D=Rn.useRef([]),K=Rn.useRef([]),X=Rn.useRef(S);X.current=S;let _=Rn.useRef(H);_.current=H;let j=Rn.useRef(null),be=Rn.useRef(i);be.current=i;let U=Rn.useCallback(()=>{be.current?.({canUndo:D.current.length>0,canRedo:K.current.length>0});},[]),Ne=Rn.useCallback((g,f)=>{N(k=>k.map(x=>x.id===g?{...x,text:f}:x));},[]),Ie=Rn.useCallback(g=>{N(k=>k.filter(x=>x.id!==g));let f=D.current.lastIndexOf("comment");f>=0&&D.current.splice(f,1),K.current=[],U();},[U]);Rn.useEffect(()=>{let g=j.current;if(g==null)return;j.current=null,d.current?.querySelector(`[data-bubble-id="${g}"] .lumen-bubble-text`)?.focus();},[H]),Rn.useEffect(()=>{T([]),N([]),w(false),D.current=[],K.current=[],U();},[t,U]),Rn.useEffect(()=>{let g=false,f=null;return (async()=>{try{let k=await createImageBitmap(t);if(g){k.close?.();return}f=k,C(k);}catch{}})(),()=>{g=true,f?.close?.();}},[t]),Rn.useEffect(()=>{if(!p)return;let g=c.current,f=l.current;if(!(!g||!f)){f.width=p.width,f.height=p.height;try{g.width=p.width,g.height=p.height;let k=g.getContext("2d");if(!k)return;k.imageSmoothingEnabled=!1,k.drawImage(p,0,0),w(!1);}catch{w(true);}}},[p]),Rn.useEffect(()=>{if(!b){L("");return}let g=URL.createObjectURL(t);return L(g),()=>{URL.revokeObjectURL(g);}},[b,t]),Rn.useEffect(()=>{let g=l.current;if(g)try{pt(g,S,h.current);}catch{}},[S]),Rn.useImperativeHandle(s,()=>({hasAnnotations:()=>S.length>0||H.some(g=>g.text.trim().length>0),reset:()=>{T([]),N([]),X.current=[],_.current=[],D.current=[],K.current=[],U();},undo:()=>{let g=D.current[D.current.length-1];if(g){if(g==="comment"){let f=_.current,k=f[f.length-1];if(!k)return;let x=f.slice(0,-1);_.current=x,K.current.push({type:"comment",item:k}),N(x);}else {let f=X.current,k=f[f.length-1];if(!k)return;let x=f.slice(0,-1);X.current=x,K.current.push({type:"anno",item:k}),T(x);}D.current.pop(),U();}},redo:()=>{let g=K.current[K.current.length-1];if(g){if(g.type==="comment"){let f=[..._.current,g.item];_.current=f,N(f);}else {let f=[...X.current,g.item];X.current=f,T(f);}D.current.push(g.type),K.current.pop(),U();}},async flatten(){let g=h.current,f=g?[...S,g]:S,k=H.filter(x=>x.text.trim().length>0);if(f.length===0&&k.length===0||!p||b)return t;try{let x=document.createElement("canvas");x.width=p.width,x.height=p.height;let O=x.getContext("2d");if(!O)return t;O.imageSmoothingEnabled=!1,O.drawImage(p,0,0);for(let z of f)It(O,z);let W=c.current?.clientWidth||p.width,Y=p.width/Math.max(W,1);for(let z of k)Ao(O,z,p.width,p.height,Y);return await new Promise(z=>{x.toBlob(J=>{z(J??t);},"image/jpeg",.85);})}catch{return t}}}),[S,H,p,t,b,U]);function ie(g){let f=l.current;if(!f)return {x:0,y:0};let k=f.getBoundingClientRect(),x=f.width/Math.max(k.width,1),O=f.height/Math.max(k.height,1);return {x:(g.clientX-k.left)*x,y:(g.clientY-k.top)*O}}function ve(){P.current||(P.current=true,requestAnimationFrame(()=>{P.current=false;let g=l.current;g&&pt(g,S,h.current);}));}function we(g){if(g.button!==void 0&&g.button!==0)return;if(n==="comment"){let k=l.current;if(!k)return;let x=k.getBoundingClientRect(),O=Cn((g.clientX-x.left)/Math.max(x.width,1),.72),W=Cn((g.clientY-x.top)/Math.max(x.height,1),.8),Y=++ae.current;N(z=>[...z,{id:Y,x:O,y:W,text:"",color:r}]),D.current.push("comment"),K.current=[],j.current=Y,U();return}try{g.currentTarget.setPointerCapture(g.pointerId);}catch{}y.current=true,a?.(true);let f=ie(g);n==="arrow"?h.current={kind:"arrow",from:f,to:f,color:r,width:o}:n==="rect"?h.current={kind:"rect",from:f,to:f,color:r,width:o}:h.current={kind:"freehand",points:[f],color:r,width:o},B.current=performance.now(),ve();}function se(g){if(!y.current||!h.current)return;let f=ie(g),k=h.current;if(k.kind==="arrow"||k.kind==="rect")k.to=f;else {let x=k.points[k.points.length-1],O=x?(x.x-f.x)**2+(x.y-f.y)**2:1/0,W=performance.now(),Y=W-B.current;(O>16||Y>16)&&(k.points.push(f),B.current=W);}ve();}function le(){if(!y.current)return;y.current=false,a?.(false);let g=h.current;if(h.current=null,!!g){if(g.kind==="arrow"||g.kind==="rect"){let f=g.to.x-g.from.x,k=g.to.y-g.from.y;if(f*f+k*k<16){let x=l.current;x&&pt(x,S,null);return}}else if(g.points.length<2){let f=l.current;f&&pt(f,S,null);return}T(f=>[...f,g].slice(-50)),D.current.push("anno"),K.current=[],U();}}return jsxRuntime.jsxs("div",{ref:d,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:c}),b&&M?jsxRuntime.jsx("img",{src:M,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsxRuntime.jsx("canvas",{ref:l,className:"lumen-annotate-overlay",onPointerDown:we,onPointerMove:se,onPointerUp:le,onPointerCancel:le}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:H.map(g=>jsxRuntime.jsx(Lo,{comment:g,onChange:Ne,onRemove:Ie},g.id))})]})});function Lo({comment:e,onChange:t,onRemove:n}){let r=Rn.useRef(null);return Rn.useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxRuntime.jsxs("div",{className:"lumen-bubble","data-bubble-id":e.id,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,"--lumen-bubble-accent":e.color},onPointerDown:o=>o.stopPropagation(),children:[jsxRuntime.jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsxRuntime.jsx("div",{ref:r,className:"lumen-bubble-text",contentEditable:true,suppressContentEditableWarning:true,role:"textbox","aria-label":"Comment text","data-placeholder":"Type a note\u2026",onInput:o=>t(e.id,o.currentTarget.textContent??"")}),jsxRuntime.jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function pt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)It(r,o);n&&It(r,n);}}function It(e,t){if(e.save(),e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",t.kind==="rect"){let n=Math.min(t.from.x,t.to.x),r=Math.min(t.from.y,t.to.y),o=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,r,o,a);}else if(t.kind==="freehand")To(e,t.points);else {let{from:n,to:r,width:o}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke();let a=Math.atan2(r.y-n.y,r.x-n.x),i=Math.max(12,o*4);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(r.x-i*Math.cos(a-Math.PI/7),r.y-i*Math.sin(a-Math.PI/7)),e.lineTo(r.x-i*Math.cos(a+Math.PI/7),r.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function To(e,t){if(t.length===0)return;e.beginPath();let n=t[0];if(!n)return;if(e.moveTo(n.x,n.y),t.length===1){e.arc(n.x,n.y,e.lineWidth/2,0,Math.PI*2),e.fill();return}if(t.length===2){let o=t[1];e.lineTo(o.x,o.y),e.stroke();return}for(let o=1;o<t.length-1;o++){let a=t[o],i=t[o+1],s=(a.x+i.x)/2,c=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,s,c);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function Ao(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,s=14*o,c=10*o,l=12*o,d=s*1.35,p=c*1.7,C=t.x*n,b=t.y*r,w=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${s}px ${Nt}`,e.textBaseline="top";let M=Po(e,a,w-i*2),L=M.reduce((P,H)=>Math.max(P,e.measureText(H).width),0),S=Math.min(w,Math.max(L,56*o)+i*2),T=i*2+p+M.length*d;No(e,C,b,S,T,l),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let h=C+18*o,y=b+T;e.beginPath(),e.moveTo(h,y-o),e.lineTo(h+13*o,y-o),e.lineTo(h+4*o,y+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${c}px ${Nt}`,e.fillText("COMMENT",C+i,b+i),e.fillStyle="#111318",e.font=`500 ${s}px ${Nt}`;let B=b+i+p;for(let P of M)e.fillText(P,C+i,B),B+=d;e.restore();}function Po(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let s=a?`${a} ${i}`:i;a&&e.measureText(s).width>n?(o.push(a),a=i):a=s;}return a&&o.push(a),o.length?o:[t]}function No(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function nt({children:e,...t}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...t,children:e})}function Io(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("path",{d:"M3 9a2 2 0 0 1 2-2h1.5l1-1.5h5l1 1.5H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),jsxRuntime.jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function Do(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsxRuntime.jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Oo(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsxRuntime.jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function ft(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function xn(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var Dt={shot:Io,video:Do,upload:Oo};function Mn(e){let t=e.videoWidth||1280,n=e.videoHeight||720,r=document.createElement("canvas");r.width=t,r.height=n;let o=r.getContext("2d");return o?(o.drawImage(e,0,0,t,n),new Promise(a=>r.toBlob(i=>a(i),"image/jpeg",.82))):Promise.resolve(null)}function Bo(e,t){return !Number.isFinite(t)||t<=0?Promise.resolve():new Promise(n=>{e.addEventListener("seeked",()=>n(),{once:true});try{e.currentTime=t;}catch{n();}})}var Ho=4e3;async function Ot(e){if(typeof document>"u")return {poster:null,durationMs:0};let t=URL.createObjectURL(e),n=document.createElement("video");n.muted=true,n.playsInline=true,n.preload="auto",n.src=t;let r=async()=>{await new Promise((c,l)=>{if(n.readyState>=2)return c();n.addEventListener("loadeddata",()=>c(),{once:true}),n.addEventListener("error",()=>l(new Error("video decode failed")),{once:true});}),await Bo(n,Math.min(.1,(n.duration||0)/2));let i=await Mn(n),s=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:s}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),Ho);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Bt(e){if(typeof document>"u")return null;let t=document.createElement("video");t.muted=true,t.playsInline=true,t.srcObject=e;try{return await t.play().catch(()=>{}),await new Promise(n=>{if(t.readyState>=2)return n();t.addEventListener("loadeddata",()=>n(),{once:!0}),window.setTimeout(n,600);}),await Mn(t)}catch{return null}finally{t.srcObject=null;}}async function Ht(){if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=1280,e.height=720;let t=e.getContext("2d");return t?(t.fillStyle="#0e0e12",t.fillRect(0,0,e.width,e.height),t.fillStyle="#52525b",t.beginPath(),t.moveTo(590,312),t.lineTo(590,408),t.lineTo(694,360),t.closePath(),t.fill(),new Promise(n=>e.toBlob(r=>n(r),"image/jpeg",.8))):null}var _t=60,_o=25*1024*1024,Ln=[{label:"Red",value:"rgb(239, 68, 68)"},{label:"Amber",value:"rgb(245, 158, 11)"},{label:"Blue",value:"rgb(59, 130, 246)"},{label:"Green",value:"rgb(34, 197, 94)"},{label:"Neutral",value:"rgb(244, 244, 245)"}],Tn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],An=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],Pn=[{value:"shot",label:"Screenshot",hint:"This page, instantly",primary:true},{value:"video",label:"Video",hint:"Record up to 60s"},{value:"upload",label:"Upload",hint:"Image or video"}];function Vt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:s,consumePendingVideo:c,canRecordScreen:l,consumeRecordStartError:d,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:b,keyboardInset:w}=Je(),[M,L]=Rn.useState(1),[S,T]=Rn.useState(null),[h,y]=Rn.useState({kind:"idle"}),[B,P]=Rn.useState(false),[H,N]=Rn.useState(0),[ae,D]=Rn.useState(null),[K,X]=Rn.useState(false),[_,j]=Rn.useState("arrow"),[be,U]=Rn.useState(Ln[0].value),[Ne,Ie]=Rn.useState(Tn[1].value),[ie,ve]=Rn.useState(""),[we,se]=Rn.useState("bug"),[le,g]=Rn.useState(r?.email??""),[f,k]=Rn.useState(null),[x,O]=Rn.useState(null),[W,Y]=Rn.useState(0),[z,J]=Rn.useState(null),[fe,Q]=Rn.useState(null),[ne,We]=Rn.useState(false),[ye,De]=Rn.useState({canUndo:false,canRedo:false}),Re=Rn.useRef(null),_e=Rn.useRef(null),Ve=Rn.useRef(null),Fe=Rn.useRef(null),Se=et(t,w),ge=Rn.useRef(false),ue=Rn.useRef(false);Rn.useEffect(()=>{t||(ue.current=false);},[t]),Rn.useEffect(()=>{if(!t)return;if(ue.current){ge.current=false;return}ue.current=true,ge.current=false,L(1),T(null),ve(""),O(null),Y(0),J(null),P(false),N(0),D(null),X(false),Q(null),De({canUndo:false,canRedo:false});let u=C();if(u){T("shot"),xe(u),y({kind:"ready",capture:u});return}let v=c();if(v)T("video"),J({blob:v.blob,durationMs:v.durationMs}),v.blob.size>_o&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),v.poster?y({kind:"ready",capture:Ge(v.poster,["Screen recording; preview is the first frame."])}):(y({kind:"capturing"}),(async()=>{let A=null;if(v.deriveBlobPoster)try{A=(await Ot(v.blob)).poster;}catch{A=null;}A=A??await Ht(),!ge.current&&y(A?{kind:"ready",capture:Ge(A,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let A=d();A?(T("video"),Q(A),y({kind:"idle"})):a?(T("shot"),y({kind:"ready",capture:a})):o?.mode==="manual"?y({kind:"manual"}):o?.provider&&!i?(T("shot"),ee(o.mode??"auto")):y({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ge.current=true;}},[t,o,a,i]),Rn.useEffect(()=>{if(!t)return;Fe.current=document.activeElement??null;let u=document.documentElement,v=u.style.overflow,A=u.style.paddingRight,te=window.innerWidth-u.clientWidth;u.style.overflow="hidden",te>0&&(u.style.paddingRight=`${te}px`);let re=false,Le=()=>{if(!re){re=true,u.style.overflow=v,u.style.paddingRight=A;try{Fe.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Le),()=>{window.removeEventListener("pagehide",Le),Le();}},[t]),Rn.useEffect(()=>{if(!t)return;function u(v){if(v.key==="Escape"){v.preventDefault(),n();return}if(v.key!=="Tab")return;let A=_e.current;if(!A)return;let te=Yo(A);if(te.length===0)return;let re=te[0],Le=te[te.length-1],Et=document.activeElement;v.shiftKey&&(Et===re||!A.contains(Et))?(v.preventDefault(),Le.focus()):!v.shiftKey&&Et===Le&&(v.preventDefault(),re.focus());}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,n]),Rn.useEffect(()=>{if(!t||!b)return;let u=Ve.current;if(!u)return;let v=A=>{A.target===u&&A.stopPropagation();};return u.addEventListener("pointerdown",v),u.addEventListener("click",v),u.addEventListener("touchstart",v,{passive:true}),()=>{u.removeEventListener("pointerdown",v),u.removeEventListener("click",v),u.removeEventListener("touchstart",v);}},[t,b]),Rn.useEffect(()=>{if(!t||!Se.open)return;let u=_e.current,v=document.activeElement;if(u&&v&&u.contains(v))try{v.scrollIntoView({block:"center"});}catch{}},[t,Se.open,Se.inset]),Rn.useEffect(()=>{if(!t||h.kind!=="manual")return;function u(v){let re=Array.from(v.clipboardData?.items??[]).find(Le=>Le.type.startsWith("image/"))?.getAsFile();re&&(v.preventDefault(),Ee(re));}return window.addEventListener("paste",u),()=>window.removeEventListener("paste",u)},[t,h.kind]),Rn.useEffect(()=>{if(!f)return;let u=Date.now(),v=window.setInterval(()=>{let A=Math.floor((Date.now()-u)/1e3);Y(A),A>=_t&&ze();},250);return ()=>window.clearInterval(v)},[f]);let ce=Rn.useRef(null);if(ce.current=f,Rn.useEffect(()=>{t||ce.current&&(ce.current.cancel(),ce.current=null,k(null),Y(0));},[t]),Rn.useEffect(()=>()=>{ce.current?.cancel();},[]),!t)return null;async function ee(u){ge.current=false,y({kind:"capturing"});try{let v=await ct({...o,mode:u,target:o?.target??document.documentElement});return ge.current?!1:(xe(v),y({kind:"ready",capture:v}),!0)}catch(v){return ge.current||y({kind:"manual",error:v instanceof Error?v.message:"Automatic screenshot capture was unavailable."}),false}}async function ke(u){T(u),Q(null),D(null),u!=="video"&&Me(),u==="shot"?await ee(o?.mode??"auto"):u==="video"?(J(null),y({kind:"idle"})):y({kind:"manual"});}async function Ee(u){if(u.type.startsWith("image/")){Me();let v=Ge(u,["Manual image upload used."]);y({kind:"ready",capture:v});return}if(u.type.startsWith("video/")){y({kind:"capturing"});try{let{poster:v,durationMs:A}=await Ot(u),te=v??await Ht();if(!te){y({kind:"manual",error:"Could not read that video."});return}let re=Ge(te,["Uploaded video; preview is the first frame."]);J({blob:u,durationMs:A}),y({kind:"ready",capture:re});}catch{y({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function xe(u){u.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function Ue(){try{let u=await bn(_t);k(u);}catch(u){sonner.toast.error(u instanceof Error?u.message:"Microphone unavailable");}}async function ze(){if(f)try{let u=await f.stop();O({blob:u.blob,durationMs:u.durationMs});}catch(u){sonner.toast.error(u instanceof Error?u.message:"Could not stop recording");}finally{k(null);}}function at(){f?.cancel(),k(null),O(null),Y(0);}function qe(u){let v=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!f&&!x?jsxRuntime.jsxs("button",{type:"button",onClick:Ue,className:u==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(xn,{}),"Record voice note"]}):null,f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx($o,{stream:f.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[W,"s / ",_t,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:ze,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:at,className:"lumen-btn-ghost",children:"Cancel"})]}):null,x&&!f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Wo,{blob:x.blob,durationMs:x.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>O(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return u==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[v,!f&&!x?jsxRuntime.jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),v]})}async function it(){Q(null);try{await s();}catch(u){sonner.toast.error(u instanceof Error?u.message:"Screen capture unavailable");}}function Me(){J(null);}let wt=h.kind==="ready";async function yt(){if(f&&await ze(),M===1){if(h.kind==="ready"){let u=await Re.current?.flatten();D(u??h.capture.blob),X(u!=null&&u!==h.capture.blob);}L(2);}else M===2?L(3):await R();}function he(){M>1&&L(u=>u-1);}async function R(){if(h.kind!=="ready")return;let u=ie.trim(),{capture:v}=h;P(true),N(0);try{let A=ae??v.blob,te=await e.submit({rawText:u.length>0?u:void 0,category:we,submitterEmail:le.trim()||void 0,screenshot:A,audio:x?.blob,audioDurationMs:x?.durationMs,video:z?.blob,videoDurationMs:z?.durationMs,context:hn(v)},{onUploadProgress:re=>N(Math.min(.95,re))});N(1),sonner.toast.success("Feedback sent \u2014 thank you."),te.id,n();}catch(A){sonner.toast.error(A instanceof Error?A.message:"Could not submit feedback"),P(false);}}function F(u){u.target===u.currentTarget&&!B&&n();}let $=Math.round(H*100),je=S==="video",gr=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,hr=S==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&gr,br=M===1&&!wt||B,vr=M<3?"Next":B?$<95?`Uploading ${$}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:Ve,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Se.inset?{"--lumen-keyboard-inset":`${Se.inset}px`}:void 0,onMouseDown:F,children:jsxRuntime.jsxs("div",{ref:_e,className:"lumen-modal","data-lumen-drawing":ne?"true":void 0,children:[jsxRuntime.jsx(zo,{onDismiss:n}),jsxRuntime.jsxs("header",{className:"lumen-modal-header",children:[jsxRuntime.jsxs("h2",{className:"lumen-modal-title",children:[jsxRuntime.jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsx(Vo,{step:M}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[M===1?jsxRuntime.jsx("div",{className:"lumen-pane",children:S===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:Pn.map(u=>{let v=Dt[u.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(u.primary?" lumen-method-primary":""),onClick:()=>ke(u.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(v,{})}),u.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:u.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:u.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:u.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:u.hint})]})]},u.value)})}),jsxRuntime.jsx("p",{className:"lumen-status lumen-method-help",children:"Choose how to capture your feedback."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method-switch",role:"group","aria-label":"Switch capture method",children:Pn.map(u=>{let v=Dt[u.value];return jsxRuntime.jsxs("button",{type:"button","aria-pressed":S===u.value,onClick:()=>ke(u.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx(v,{}),u.label]},u.value)})}),S==="video"&&h.kind==="idle"?jsxRuntime.jsx(Fo,{canRecord:l,onRecord:it,onUpload:()=>ke("upload"),error:fe}):null,h.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,h.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:S==="upload"?"Choose an image or video to attach \u2014 or paste an image.":h.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:S==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:S==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:u=>{let v=u.currentTarget.files?.[0];v&&Ee(v),u.currentTarget.value="";}})]})]}):null,h.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[je?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(gt,{label:"Arrow",active:_==="arrow",onClick:()=>j("arrow")}),jsxRuntime.jsx(gt,{label:"Box",active:_==="rect",onClick:()=>j("rect")}),jsxRuntime.jsx(gt,{label:"Draw",active:_==="freehand",onClick:()=>j("freehand")}),jsxRuntime.jsx(gt,{label:"Comment",active:_==="comment",onClick:()=>j("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:Ln.map(u=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:u.value},"aria-label":u.label,"aria-pressed":be===u.value,onClick:()=>U(u.value)},u.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Tn.map(u=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":u.label,"aria-pressed":Ne===u.value,onClick:()=>Ie(u.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:u.dot,height:u.dot}})},u.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.undo(),disabled:!ye.canUndo,children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.redo(),disabled:!ye.canRedo,children:"Redo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.reset(),disabled:!ye.canUndo,children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Sn,{ref:Re,screenshot:h.capture.blob,tool:_,color:be,strokeWidth:Ne,onDrawingChange:We,onHistoryChange:De})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>S&&ke(S),children:je?"\u21BB Re-record":"\u21BB Recapture"}),hr?jsxRuntime.jsxs("button",{type:"button",className:"lumen-btn-ghost lumen-exact-btn",onClick:()=>{p();},title:"Capture the real screen pixels \u2014 your browser will ask which tab or window to share, then you arrange the page and press Capture.",children:[jsxRuntime.jsx(ft,{})," Capture exact screen"]}):null,je?z?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(z.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:h.capture.method==="web-display-media"?"Exact screen captured":`${Nn(S)} captured \xB7 switch method above anytime`})]}),qe("capture")]}):null]})}):null,M===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:ie,onChange:u=>ve(u.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),qe("describe"),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:An.map(u=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":we===u.value,onClick:()=>se(u.value),children:u.label},u.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:le,onChange:u=>g(u.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,M===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[Nn(S),K?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>L(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:An.find(u=>u.value===we)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>L(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[ie.trim()?ie.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>L(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[x?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(x.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>O(null),children:"\xD7"})]}):null,z?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(z.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Me,children:"\xD7"})]}):null,le.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",le.trim()]}):null,!x&&!f?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{L(2),Ue();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[B?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":$,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${$}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:M===1?n:he,className:"lumen-btn-ghost",disabled:B,children:M===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:yt,className:"lumen-btn-primary",disabled:br,children:vr})]})]})]})})}function Nn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function Vo({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsxRuntime.jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxRuntime.jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsxRuntime.jsx("span",{className:"lumen-step-num",children:n.n}),jsxRuntime.jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function Fo({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[r?jsxRuntime.jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsxRuntime.jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsxRuntime.jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxRuntime.jsxs("div",{className:"lumen-record-copy",children:[jsxRuntime.jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsxRuntime.jsx("div",{className:"lumen-record-sub",children:"Tap to start. The sheet closes so you can record freely \u2014 a Stop button stays on screen, then the sheet returns with your clip. Max 60s."})]})]}):jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[jsxRuntime.jsx("p",{className:"lumen-record-unavailable",children:Uo()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function Uo(){if(typeof navigator>"u")return false;let e=navigator.userAgent||"";return /iPad|iPhone|iPod/.test(e)?true:/Macintosh/.test(e)&&typeof document<"u"&&"ontouchend"in document}function gt({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function zo({onDismiss:e}){let t=Rn.useRef(null),n=Rn.useRef(0),r=Rn.useRef(null);function o(s){s.currentTarget.setPointerCapture(s.pointerId),t.current=s.clientY,n.current=performance.now(),r.current=s.currentTarget.parentElement;}function a(s){if(t.current==null||!r.current)return;let c=Math.max(0,s.clientY-t.current);r.current.style.transform=`translateY(${c}px)`;}function i(s){if(t.current==null||!r.current)return;let c=Math.max(0,s.clientY-t.current),l=Math.max(1,performance.now()-n.current),d=c/l;r.current.style.transform="",r.current.style.transition="",t.current=null,(c>80||d>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function $o({stream:e}){let t=Rn.useRef(null);return Rn.useEffect(()=>{let n=t.current;if(!n)return;let r=Math.min(window.devicePixelRatio||1,2),o=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(o*r),n.height=Math.round(a*r);let i=n.getContext("2d");if(!i)return;i.scale(r,r);let s=window.AudioContext??window.webkitAudioContext;if(!s)return;let c=new s,l=c.createMediaStreamSource(e),d=c.createAnalyser();d.fftSize=1024,d.smoothingTimeConstant=.6,l.connect(d);let p=new Uint8Array(d.fftSize),C=18,b=3,w=3,M=Math.max(2,(o-b*(C-1))/C),L=Math.min(M/2,3),S=new Array(C).fill(0),T=0,h=false;function y(){if(h)return;d.getByteTimeDomainData(p);let B=Math.floor(p.length/C);i.clearRect(0,0,o,a),i.fillStyle=qo("--lumen-danger")||"rgb(239,68,68)";for(let P=0;P<C;P++){let H=0;for(let _=0;_<B;_++){let j=Math.abs((p[P*B+_]??128)-128);j>H&&(H=j);}let N=Math.min(1,H/128*1.8),ae=S[P]??0;S[P]=N>ae?N:ae+(N-ae)*.35;let D=Math.max(w,S[P]*a),K=P*(M+b),X=(a-D)/2;Ko(i,K,X,M,D,L),i.fill();}T=requestAnimationFrame(y);}return T=requestAnimationFrame(y),()=>{h=true,cancelAnimationFrame(T);try{l.disconnect();}catch{}c.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function Ko(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function Wo({blob:e,durationMs:t}){let[n,r]=Rn.useState("");return Rn.useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxRuntime.jsxs("div",{className:"lumen-audio-preview",children:[jsxRuntime.jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxRuntime.jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function qo(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var jo='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Yo(e){return Array.from(e.querySelectorAll(jo)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var ht=class extends Rn__namespace.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t,n){if(typeof document<"u"){let r=document.documentElement;r.style.overflow="",r.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),sonner.toast.error("Feedback widget hit a snag and was reset. Please try again.");try{let r=t instanceof Error?t:null;this.props.onError?.({message:r?.message??String(t),name:r?.name??"Error",stack:r?.stack,componentStack:n?.componentStack??void 0});}catch{}Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function Hn({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(Zo,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-rec-hud lumen-rec-hud-pending",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function Zo({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(0);Rn.useEffect(()=>{let s=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));s();let c=window.setInterval(s,250);return ()=>window.clearInterval(c)},[e,t]);let i=s=>`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`;return jsxRuntime.jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxRuntime.jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxRuntime.jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function _n({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,s=e.phase==="grabbing";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-cap-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[s?jsxRuntime.jsx("span",{className:"lumen-cap-hud-spinner","aria-hidden":"true"}):jsxRuntime.jsx("span",{className:"lumen-cap-hud-ico","aria-hidden":"true",children:jsxRuntime.jsx(ft,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:s?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:s,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:s,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Ft(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function Vn(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function Fn(e){return e instanceof Error?e:new Error(String(e))}function Un(e,t,n){let r=false,o=false,a=false,i=null;function s(){o||(o=true,n.onCancelled());}function c(d){o||(o=true,n.onResult(d));}function l(d){o||(o=true,n.onError(d));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(d=>{if(i=d,r){try{d.cancel();}catch{}s();return}if(n.onActive(d),a){n.onProcessing();try{d.stop();}catch{}}Promise.resolve(d.result).then(p=>{r?s():c(p);}).catch(p=>{r||Vn(p)?s():l(Fn(p));});}).catch(d=>{r||Vn(d)?s():l(Fn(d));}),{stop(){if(!(o||r||a)&&(a=true,i)){n.onProcessing();try{i.stop();}catch{}}},cancel(){if(!(o&&r)){if(r=true,i)try{i.cancel();}catch{}s();}}}}function zn(){if(typeof document>"u"||typeof window>"u")return 0;let e=window.innerWidth,t=window.innerHeight;if(e===0||t===0)return 0;let n=t-4,r=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],o=new Set,a=0;for(let i of r){let s=document.elementsFromPoint(i,n);for(let c of s){if(o.has(c))continue;o.add(c);let l=window.getComputedStyle(c);if(l.position!=="fixed"&&l.position!=="sticky")continue;let d=c.getBoundingClientRect();d.bottom<t-8||d.bottom>t+8||d.width<e*.6||d.height>a&&(a=d.height);}}return a}function Ut(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,r=window.innerHeight,o=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let s of Array.from(i)){let c=s.getBoundingClientRect();if(c.height===0||c.width===0)continue;let l=0;switch(t){case "bottom":if(c.bottom<r-8)break;l=Math.max(0,r-c.top);break;case "top":if(c.top>8)break;l=Math.max(0,c.bottom);break;case "left":if(c.left>8)break;l=Math.max(0,c.right);break;case "right":if(c.right<n-8)break;l=Math.max(0,n-c.left);break}l>o&&(o=l);}}return o}function $n(e){let[t,n]=Rn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Rn.useRef(t),o=oa(e.avoid),a=e.placement,i=e.offset.x,s=e.offset.y;return Rn.useEffect(()=>{if(typeof window>"u")return;let c=0,l=false,d=()=>{if(c=0,l)return;let M=a[0]==="b"?"bottom":"top",L=a[1]==="r"?"right":"left",S=0,T=0;e.avoid==="auto"&&M==="bottom"?S=zn():Array.isArray(e.avoid)&&(S=Ut(e.avoid,M),T=Ut(e.avoid,L));let h={bottom:M==="bottom"?s+S:0,top:M==="top"?s+S:0,right:L==="right"?i+T:0,left:L==="left"?i+T:0},y=r.current;(h.bottom!==y.bottom||h.top!==y.top||h.right!==y.right||h.left!==y.left)&&(r.current=h,n(h));},p=()=>{c||(c=window.requestAnimationFrame(d));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let b=typeof MutationObserver<"u"?new MutationObserver(p):null;b?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let w=window.visualViewport;return w?.addEventListener("resize",p),w?.addEventListener("scroll",p),()=>{l=true,c&&window.cancelAnimationFrame(c),C?.disconnect(),b?.disconnect(),window.removeEventListener("resize",p),w?.removeEventListener("resize",p),w?.removeEventListener("scroll",p);}},[a,i,s,o]),t}function oa(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var Kn=["mousedown","touchstart"];function Ke(e){let t=Rn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Rn.useRef(e.onClick);n.current=e.onClick;let r=Rn.useRef(e.isolate??true);r.current=e.isolate??true;let o=Rn.useRef(null);return Rn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=l=>{r.current&&l.stopPropagation(),t.current?.(l);},s=l=>{r.current&&l.stopPropagation(),n.current(l);},c=l=>{r.current&&l.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",s);for(let l of Kn)a.addEventListener(l,c,l==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",s);for(let l of Kn)a.removeEventListener(l,c);};},[])}function Yn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[s,c]=Rn.useState(null),l=Rn.useRef(null),d=$n(e),p=et(e.keyboard!=="off",i),C=Ke({onPointerDown:r,onClick:o,isolate:a}),b=Rn.useCallback(N=>{l.current=N,C(N);},[C]);Rn.useEffect(()=>{typeof document>"u"||c(t??document.body);},[t]);let w=e.placement,M=w[0]==="b"?"bottom":"top",L=w[1]==="r"?"right":"left",S=M==="bottom",T=p.open&&S&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,h=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&S&&p.inset<=0);if(ua(l,!n&&!h),!s)return null;let y=M==="bottom"?d.bottom:d.top,B=L==="right"?d.right:d.left,P=n||h,H={position:"fixed",[M]:e.safeArea?`calc(${y}px + env(safe-area-inset-${M}, 0px))`:`${y}px`,[L]:e.safeArea?`calc(${B}px + env(safe-area-inset-${L}, 0px))`:`${B}px`,zIndex:e.zIndex,transform:T?`translateY(-${T}px)`:void 0,opacity:P?0:1,pointerEvents:P?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:b,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:H,"aria-label":e.label,"aria-hidden":P?true:void 0,tabIndex:P?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),s)}function ua(e,t){let n=Rn.useRef(false);Rn.useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let r=window.setTimeout(()=>{let o=e.current;if(!o)return;let a=o.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,s=a.top+a.height/2,c=document.elementsFromPoint(i,s),l=Wn(window.getComputedStyle(o).zIndex);for(let d of c){if(d===o||o.contains(d))continue;if(Wn(window.getComputedStyle(d).zIndex)>l){n.current=true,console.warn("[lumen] trigger is occluded by",d);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function Wn(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function Gn({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),c=Ke({onPointerDown:r,onClick:o,isolate:a});return Rn.useEffect(()=>{if(typeof document>"u")return;let l=e instanceof HTMLElement?e:e.current??null;s(l);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:c,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),i):null}function Jn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),[c,l]=Rn.useState(false),d=Rn.useRef(null),p=Ke({onPointerDown:L=>{r?.(L),d.current={x:L.clientX,y:L.clientY},l(true);let S=L.currentTarget;try{S?.setPointerCapture?.(L.pointerId);}catch{}},onClick:o,isolate:a});if(Rn.useEffect(()=>{typeof document>"u"||s(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${c?" lumen-notch-expanded":""}`;function b(L){let S=d.current;if(!S)return;let T=L.clientX-S.x,h=L.clientY-S.y;(e.edge==="top"&&h>16||e.edge==="bottom"&&h<-16||e.edge==="right"&&T<-16||e.edge==="left"&&T>16)&&(d.current=null,o(L.nativeEvent));}function w(){d.current=null,l(false);}function M(){d.current=null,l(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:C,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:b,onPointerUp:w,onPointerCancel:M,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function Qn(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function Ea(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function er(e){return {kind:"floating",placement:e.placement??"br",offset:{x:e.offset?.x??16,y:e.offset?.y??16},safeArea:e.safeArea??true,avoid:e.avoid===false?false:e.avoid==null?"auto":Array.isArray(e.avoid)?e.avoid:[e.avoid],keyboard:Ea(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Sa={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function tr(e){let t=Rn.useId();Rn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${ka(t)}`,o={},a=(i,s)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,s);};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else {for(let[i,s]of Object.entries(Sa)){let c=e[s];typeof c=="string"&&c.length>0&&a(i,c);}typeof e.accent=="string"&&e.accent.length>0&&(a("--lumen-accent",e.accent),a("--lumen-primary",e.accent),a("--lumen-accent-fg","#ffffff")),(e.scheme==="light"||e.scheme==="dark")&&(o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e.scheme));}return n.setAttribute(r,""),()=>{n.removeAttribute(r);for(let[i,s]of Object.entries(o))i.startsWith("--")?s?n.style.setProperty(i,s):n.style.removeProperty(i):s==null?n.removeAttribute(i):n.setAttribute(i,s);}},[e,t]);}function ka(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var nr=Symbol.for("lumen.history.patched"),zt="lumen:locationchange";function La(){if(typeof window>"u")return;let e=window;if(e[nr])return;e[nr]=true;let t=()=>window.dispatchEvent(new Event(zt)),n=history.pushState;history.pushState=function(...o){let a=n.apply(this,o);return t(),a};let r=history.replaceState;history.replaceState=function(...o){let a=r.apply(this,o);return t(),a},window.addEventListener("popstate",t);}function rr(e){let[t,n]=Rn.useState(false);return Rn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;La();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(zt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(zt,r),window.removeEventListener("popstate",r);}},[e]),t}var Pa=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function or(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let r=n.webkit;if(r&&r.messageHandlers){t(true);return}let o=navigator.userAgent||"";Pa.some(a=>o.includes(a))&&t(true);},[]),e}var ir="lumen.config.v1.",Da=3600*1e3;function sr(e,t){let[n,r]=Rn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Rn.useEffect(()=>{if(typeof window>"u")return;let o=Fa(e);o&&r({trigger:o.trigger,enabled:ar(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),s=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(s,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);let l=await c.json(),d=lr(l.trigger);if(!d)throw new Error("Malformed config response");let p=Ha(l.trigger),C=ur(l.brand);Ua(e,d,p,C),r({trigger:d,enabled:ar(d),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(c=>c.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:c);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function ar(e){return e.kind!=="headless"}var Oa=["br","bl","tr","tl"],Ba=["top","right","bottom","left"];function lr(e){if(!e||typeof e!="object")return null;let t=e;if(t.enabled===false)return {kind:"headless"};let n=typeof t.label=="string"?t.label:"Feedback";return t.kind==="floating"?{kind:"floating",placement:Oa.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:Ba.find(o=>o===t.edge)??"top",label:n}:null}function Ha(e){return !e||typeof e!="object"?false:e.shake===true}var _a=/^#[0-9a-fA-F]{6}$/,Va=["auto","light","dark"];function ur(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&_a.test(t.accent)?t.accent:null;if(!n)return null;let r=Va.find(a=>a===t.mode)??"auto",o=typeof t.radius=="number"&&Number.isFinite(t.radius)?Math.min(20,Math.max(0,Math.round(t.radius))):10;return {accent:n,mode:r,radius:o}}function Fa(e){try{let t=window.localStorage.getItem(ir+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>Da)return null;let r=lr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:ur(n.brand)}:null}catch{return null}}function Ua(e,t,n,r){try{window.localStorage.setItem(ir+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function $a(e){if(e&&typeof e=="object")return e.type===mt;if(typeof e=="string")try{return JSON.parse(e).type===mt}catch{return false}return false}function Ka(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(s,c,l,d){if(!a)return a={x:s,y:c,z:l,t:d},false;if(d-a.t<o)return false;let p=Math.abs(s-a.x)+Math.abs(c-a.y)+Math.abs(l-a.z);return a={x:s,y:c,z:l,t:d},p<t?false:(i=i.filter(C=>d-C<r),i.push(d),i.length>=n?(i=[],true):false)}}}function cr(e,t,n){Rn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let d=Date.now();n||d-r<o||(r=d,t());}let i=d=>{$a(d.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let s=Ka(),c=d=>{let p=d.accelerationIncludingGravity??d.acceleration;!p||p.x==null||p.y==null||p.z==null||s.push(p.x,p.y,p.z,Date.now())&&a();},l=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return l&&window.addEventListener("devicemotion",c),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),l&&window.removeEventListener("devicemotion",c);}},[e,t,n]);}var mr="https://shakebugs.vercel.app",vt=60;function pr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function ja({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:s,portalTarget:c,capture:l,record:d,shakeToOpen:p,onOpenChange:C,beforeOpen:b,onTriggerActivate:w,isolateEvents:M=true,keyboardInset:L,suppressTrigger:S=false,children:T}){let[h,y]=Rn.useState(false),[B,P]=Rn.useState(false),[H,N]=Rn.useState(null),[ae,D]=Rn.useState(null),[K]=Rn.useState(false),[X]=Rn.useState(null),_=Rn.useRef(false),j=Rn.useRef(false),be=Rn.useRef(null),U=Rn.useMemo(()=>new tn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Rn.useEffect(()=>{fn({ignoreUrlPrefix:(t??mr).replace(/\/$/,"")});},[t]);let Ne=Rn.useRef(C);Ne.current=C,Rn.useEffect(()=>{if(!(typeof document>"u"))return h?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[h]);let Ie=Rn.useRef(null);Rn.useEffect(()=>{if(Ie.current===h)return;let R=Ie.current;Ie.current=h,R!==null&&Ne.current?.(h);},[h]);let ie=Rn.useRef(b);ie.current=b;let ve=Rn.useRef(w);ve.current=w;let we=Rn.useCallback(R=>{j.current=true,be.current=Promise.resolve().then(()=>ie.current?.(R)).then(()=>ve.current?.(R)).then(()=>{});},[]),se=Rn.useCallback(R=>{_.current||h||Q.current||Ee.current||(_.current=true,P(true),N(null),D(null),(async()=>{try{if(j.current?await be.current:(await ie.current?.(R),await ve.current?.(R)),l?.mode==="manual")N(null),D(null);else if(l?.provider)N(null),D(null);else {let F=await ct({...l,mode:l?.mode??"auto",target:l?.target??document.documentElement});N(F);}}catch(F){D(F instanceof Error?F:new Error(String(F)));}finally{j.current=false,be.current=null,_.current=false,P(false),y(true);}})());},[l,h]),le=Rn.useCallback(()=>{y(false),N(null),D(null);},[]),g=Rn.useCallback(U.submit.bind(U),[U]),[f,k]=Rn.useState(0),x=Rn.useCallback(()=>{_.current=false,P(false),y(false),N(null),D(null),k(R=>R+1);},[]),[O,W]=Rn.useState(null),[Y,z]=Rn.useState(null),J=Rn.useRef(null),fe=Rn.useRef(null),Q=Rn.useRef(false),ne=Rn.useRef(null),We=Rn.useRef(null),ye=Rn.useRef(null),De=Rn.useCallback((R,F=false)=>{if(J.current=null,fe.current=null,Q.current=false,W(null),!R){ne.current=null;return}We.current={blob:R.blob,durationMs:R.durationMs,poster:ne.current,deriveBlobPoster:F},ne.current=null,y(true);},[]);Rn.useEffect(()=>{if(!h)return;if(!d?.provider){z(null);return}let R=d.isAvailable;if(!R){z(true);return}let F=false;return Promise.resolve().then(()=>R()).then($=>{F||z($);}).catch(()=>{F||z(false);}),()=>{F=true;}},[h,d?.provider,d?.isAvailable]);let Re=Ft({hasProvider:!!d?.provider,providerAvailable:Y,hasGetDisplayMedia:pr()}).canRecord,_e=Rn.useCallback(async()=>{if(Q.current)return;if(ye.current=null,Ft({hasProvider:!!d?.provider,providerAvailable:Y,hasGetDisplayMedia:pr()}).usingProvider&&d?.provider){Q.current=true,ne.current=null,y(false),fe.current=Un(d.provider,{maxDurationSeconds:vt},{onStarting:()=>W({phase:"starting"}),onActive:$=>{W({phase:"recording",stream:$.stream??null,startedAt:Date.now(),maxSeconds:vt}),$.stream&&Bt($.stream).then(je=>{ne.current=je;}).catch(()=>{});},onProcessing:()=>W({phase:"processing"}),onResult:$=>De({blob:$.blob,durationMs:$.durationMs},true),onCancelled:()=>{fe.current=null,Q.current=false,ne.current=null,W(null),N(null),D(null),y(true);},onError:$=>{fe.current=null,Q.current=false,ne.current=null,W(null),ye.current=$.message||"Screen recording could not start.",y(true);}});return}if(J.current)return;let F=await vn(vt);J.current=F,Q.current=true,ne.current=null,W({phase:"recording",stream:F.stream,startedAt:Date.now(),maxSeconds:vt}),y(false),Bt(F.stream).then($=>{ne.current=$;}).catch(()=>{}),F.result.then($=>De($)).catch(()=>De(null));},[De,d?.provider,Y]),Ve=Rn.useCallback(()=>{fe.current?fe.current.stop():J.current?.stop();},[]),Fe=Rn.useCallback(()=>{if(fe.current){fe.current.cancel();return}let R=J.current;J.current=null,Q.current=false,ne.current=null,W(null),R?.cancel(),N(null),D(null),y(true);},[]),Se=Rn.useCallback(()=>{let R=We.current;return We.current=null,R},[]),ge=Rn.useCallback(()=>{let R=ye.current;return ye.current=null,R},[]);Rn.useEffect(()=>{h||(ye.current=null);},[h]);let[ue,ce]=Rn.useState(null),ee=Rn.useRef(null),ke=Rn.useRef(null),Ee=Rn.useRef(false),xe=Rn.useCallback(()=>{let R=ee.current;ee.current=null,Ee.current=false,R?.stop(),ce(null),y(true);},[]),Ue=Rn.useCallback(()=>{let R=ee.current;R&&(ce({phase:"grabbing"}),(async()=>{try{let F=await R.grab();if(ee.current!==R)return;ke.current=F,ee.current=null,Ee.current=!1,R.stop(),ce(null),y(!0);}catch{if(ee.current!==R)return;ee.current=null,Ee.current=false,R.stop(),ce(null),sonner.toast.error("Could not capture the screen. Please try again."),y(true);}})());},[]),ze=Rn.useCallback(async()=>{if(Ee.current)return;let R;try{R=await xt({...l});}catch{return}ee.current=R,Ee.current=true,R.onEnded(()=>xe()),ce({phase:"live"}),y(false);},[l,xe]),at=Rn.useCallback(()=>{let R=ke.current;return ke.current=null,R},[]);Rn.useEffect(()=>()=>{ee.current?.stop(),ee.current=null;},[]);let qe=or(),it=rr(i),Me=sr(a?"":e,t??mr);tr(s??Za(Me.brand));let wt=p??Me.shakeToOpen;cr(wt,se,h);let yt=Rn.useMemo(()=>({client:U,user:n,isOpen:h,isSubmitting:K,error:X,open:se,close:le,openCapture:se,closeCapture:le,submit:g,isNativeShell:qe,capture:l,initialCapture:H,initialCaptureError:ae,isOpening:B,startVideoSession:_e,stopVideoSession:Ve,cancelVideoSession:Fe,recording:O,consumePendingVideo:Se,canRecordScreen:Re,consumeRecordStartError:ge,startScreenCaptureSession:ze,grabScreenCaptureFrame:Ue,cancelScreenCaptureSession:xe,screenCapture:ue,consumePendingScreenshot:at,isolateEvents:M,keyboardInset:L}),[U,n,h,K,X,se,le,g,qe,l,H,ae,_e,Ve,Fe,O,Se,Re,ge,ze,Ue,xe,ue,at,B,M,L]),he=Ga({explicit:a,remote:Me.trigger,remoteLoading:Me.loading,floatingButton:o});return jsxRuntime.jsxs(At.Provider,{value:yt,children:[T,jsxRuntime.jsxs(ht,{onReset:x,onError:R=>U.reportClientError({...R,context:{open:h,opening:B,screenCapturePhase:ue?.phase,recordingPhase:O?.phase,initialCaptureMethod:H?.method,initialCapturePixelRatio:H?.pixelRatio,initialCaptureViewport:H?.viewport,hadInitialCaptureError:ae!=null}}),children:[he?.kind==="floating"?jsxRuntime.jsx(Yn,{config:er(he),portalTarget:c,hidden:it||S||B||O!=null||ue!=null,onPointerDown:we,onClick:R=>se(R),isolateEvents:M,keyboardInset:L}):null,he?.kind==="notch"?jsxRuntime.jsx(Jn,{config:Qn(he),portalTarget:c,hidden:it||S||B||O!=null||ue!=null,onPointerDown:we,onClick:R=>se(R),isolateEvents:M}):null,he?.kind==="inline"?jsxRuntime.jsx(Gn,{mount:he.mount,label:he.label??"Feedback",icon:he.icon,onPointerDown:we,onClick:R=>se(R),isolateEvents:M}):null,ue?jsxRuntime.jsx(_n,{state:ue,portalTarget:c,onCapture:Ue,onCancel:xe}):null,O?jsxRuntime.jsx(Hn,{state:O,portalTarget:c,onStop:Ve,onCancel:Fe}):null,jsxRuntime.jsx(Vt,{})]},f),jsxRuntime.jsx(Ya,{})]})}function Ya(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Ga(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Za(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Xa({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=Je(),s=["lumen-btn",e==="default"?"lumen-btn-primary":null,e==="ghost"?"lumen-btn-ghost":null,e==="outline"?"lumen-btn-outline":null,t?"lumen-btn-floating":null,n].filter(Boolean).join(" ");return jsxRuntime.jsx("button",{type:"button",className:s,"data-lumen-trigger":"",onClick:c=>{o?.(c),c.defaultPrevented||i(c.nativeEvent);},...a,children:r})}
|
|
4
|
+
${r.stack}`:""}`);continue}try{t.push(JSON.stringify(r,Xr));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>Xt?n.slice(0,Xt)+"\u2026[truncated]":n}function Xr(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Jr(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let r=e[n]?.bind(e);r&&(e[n]=(...o)=>{try{ut(pn,{level:n,ts:Date.now(),message:Ct(Zr(o))});}catch{}r(...o);});}}function gn(e){return Rt?e.startsWith(Rt):false}function Qr(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let r=typeof t=="string"?t:t instanceof URL?t.toString():t.url,o=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(gn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ut(lt,{type:"fetch",method:o,url:St(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ut(lt,{type:"fetch",method:o,url:St(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function eo(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(r,o,...a){return this.__lumen={method:String(r).toUpperCase(),url:typeof o=="string"?o:o.toString(),t:0},t.call(this,r,o,...a)},e.prototype.send=function(r){let o=this.__lumen;if(o&&!gn(o.url)){o.t=performance.now();let a=()=>{try{ut(lt,{type:"xhr",method:o.method,url:St(o.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-o.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,r??null)};}function to(e){return e.length>512?e.slice(0,512)+"\u2026":e}function St(e){return to(dn(e))}function hn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:Qt(e),consoleLog:[],networkLog:[]};let t=Gr();return {url:mn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:Qt(e),device:no(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function no(){let e={};try{e.screen={width:window.screen?.width??0,height:window.screen?.height??0},e.pixelRatio=window.devicePixelRatio??1,e.language=navigator.language,e.languages=Array.from(navigator.languages??[]),e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone,e.colorScheme=window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light",e.referrer=document.referrer?mn(document.referrer):void 0,e.title=document.title||void 0,e.online=navigator.onLine,performance.getEntriesByType("navigation")[0]&&(e.uptimeMs=Math.round(performance.now()));}catch{}return e}function Qt(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var ro="[data-lumen-root]",oo="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function ao(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(kt(n))return true;return kt(e.target)}var en=["pointerdown","mousedown","touchstart","click"];function io(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of en)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of en)e.removeEventListener(n,t);}}function kt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(oo)?true:!!e.closest(ro):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?kt(e.host):false:false}var mt="lumen:shake",so=8e3,lo=50,uo=400;function co(e={}){return async function(){if(typeof window>"u")throw new I("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=po(),n=e.send??mo,r=e.timeoutMs??so,o=e.captureSettleMs??lo,a=e.awaitAnimationsMs??uo,i=vo(),s=rn(e.concealSelector===void 0?nn:e.concealSelector);try{await go(o,a);let c=await new Promise((p,C)=>{let b=window.setTimeout(()=>{t.pending.delete(i),C(new I("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:w=>{window.clearTimeout(b),p(w);},reject:w=>{window.clearTimeout(b),C(w);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(b),C(new I("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(c.error||!c.dataUrl)throw new I(c.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let l=wo(c.dataUrl),d=e.platform??bo();return {blob:l,method:d==="android"?"android-native":"ios-native",platform:d,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:c.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{s();}}}function mo(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new I("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function po(){if(window.__lumenNativeCapture)return window.__lumenNativeCapture;let e={pending:new Map,resolve(n,r,o){let a=e.pending.get(n);a&&(e.pending.delete(n),a.resolve({type:"lumen:capture-response",id:n,dataUrl:r,pixelRatio:o}));},reject(n,r){let o=e.pending.get(n);o&&(e.pending.delete(n),o.resolve({type:"lumen:capture-response",id:n,error:r}));}},t=n=>{let r=fo(n.data);if(!r||r.type!=="lumen:capture-response")return;let o=e.pending.get(r.id);o&&(e.pending.delete(r.id),o.resolve(r));};return window.addEventListener("message",t),document.addEventListener("message",t),window.__lumenNativeCapture=e,e}function fo(e){if(e&&typeof e=="object"&&"type"in e)return e;if(typeof e=="string")try{let t=JSON.parse(e);if(t&&typeof t=="object"&&t.type)return t}catch{}return null}async function go(e,t){await ln(t),await ho(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function ho(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function bo(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function vo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function wo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new I("Native host returned an invalid image data URL.","NATIVE_CAPTURE_FAILED");let n=t[1]||"image/png",r=!!t[2],o=t[3]??"";if(!r)return new Blob([decodeURIComponent(o)],{type:n});let a=atob(o),i=new Uint8Array(a.length);for(let s=0;s<a.length;s++)i[s]=a.charCodeAt(s);return new Blob([i],{type:n})}var Xe="lumen:keyboardchange",Lt="--lumen-keyboard-inset";function yo(e){if(typeof window>"u")return;let t=typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):0;window.__lumenKeyboardInset=t,typeof document<"u"&&document.documentElement.style.setProperty(Lt,`${t}px`),window.dispatchEvent(new Event(Xe));}function Tt(){if(typeof window>"u")return null;let e=window.__lumenKeyboardInset;if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof document<"u"&&typeof getComputedStyle=="function"){let t=getComputedStyle(document.documentElement).getPropertyValue(Lt).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function bn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new I("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new I("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(b=>MediaRecorder.isTypeSupported(b))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,c=false,l,d,p=new Promise((b,w)=>{l=b,d=w;});p.catch(()=>{}),r.addEventListener("dataavailable",b=>{b.data&&b.data.size>0&&o.push(b.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let L of t.getTracks())L.stop();if(c)return;if(c=true,s){d(new I("Recording cancelled.","RECORDER_STOPPED"));return}let b=performance.now()-a,w=r.mimeType||n||"audio/webm",x=new Blob(o,{type:w});l({blob:x,durationMs:b,mimeType:w});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function C(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){s=true,C(),i!==null&&window.clearTimeout(i),i=null;for(let b of t.getTracks())b.stop();},stop(){return C(),p}}}async function vn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new I("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new I("Screen capture was denied or cancelled.","SCREEN_DENIED")}let n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(w=>MediaRecorder.isTypeSupported(w))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,c=false,l,d,p=new Promise((w,x)=>{l=w,d=x;});p.catch(()=>{});function C(){i!==null&&(window.clearTimeout(i),i=null);for(let w of t.getTracks())w.stop();}r.addEventListener("dataavailable",w=>{w.data&&w.data.size>0&&o.push(w.data);}),r.addEventListener("stop",()=>{if(s)return;if(s=true,C(),c){d(new I("Recording cancelled.","RECORDER_STOPPED"));return}let w=r.mimeType||n||"video/webm";l({blob:new Blob(o,{type:w}),durationMs:performance.now()-a,mimeType:w});});function b(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(b,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",b),{stream:t,result:p,stop:b,cancel(){c=true,r.state!=="inactive"?r.stop():s||(s=true,C(),d(new I("Recording cancelled.","RECORDER_STOPPED")));}}}var At=Rn.createContext(null);function Je(){let e=Rn.useContext(At);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var wn=100;function yn(){if(typeof document>"u")return false;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;if(!e)return false;let t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"?true:e.isContentEditable===true}var Qe={open:false,inset:0};function ko(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:Qe}if(e.vvHeight==null||!e.coarse||!e.editable)return Qe;let n=e.vvBaseline-e.vvHeight;return n>wn?{open:true,inset:Math.round(n)}:Qe}function et(e,t){let[n,r]=Rn.useState(Qe),o=Rn.useRef(0),a=Rn.useRef(t);return a.current=t,Rn.useEffect(()=>{if(!e){r(Qe);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,s=()=>{let p=yn(),C=a.current,b=Tt(),w=window.visualViewport??null;w&&C==null&&b==null&&!p&&(o.current=w.height),r(ko({editable:p,override:C,injected:b,vvBaseline:o.current,vvHeight:w?w.height:null,coarse:i}));},c=0,l=()=>{c||(c=window.requestAnimationFrame(()=>{c=0,s();}));},d=window.visualViewport;return d&&(o.current=d.height),l(),d?.addEventListener("resize",l),d?.addEventListener("scroll",l),document.addEventListener("focusin",l),document.addEventListener("focusout",l),window.addEventListener(Xe,l),()=>{c&&window.cancelAnimationFrame(c),d?.removeEventListener("resize",l),d?.removeEventListener("scroll",l),document.removeEventListener("focusin",l),document.removeEventListener("focusout",l),window.removeEventListener(Xe,l);}},[e]),n}var Nt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Cn(e,t=1){return Math.max(0,Math.min(t,e))}var Sn=Rn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},s){let c=Rn.useRef(null),l=Rn.useRef(null),d=Rn.useRef(null),[p,C]=Rn.useState(null),[b,w]=Rn.useState(false),[x,L]=Rn.useState(""),[M,T]=Rn.useState([]),h=Rn.useRef(null),y=Rn.useRef(false),B=Rn.useRef(0),P=Rn.useRef(false),[H,N]=Rn.useState([]),ae=Rn.useRef(0),D=Rn.useRef([]),K=Rn.useRef([]),W=Rn.useRef(M);W.current=M;let _=Rn.useRef(H);_.current=H;let Y=Rn.useRef(null),be=Rn.useRef(i);be.current=i;let U=Rn.useCallback(()=>{be.current?.({canUndo:D.current.length>0,canRedo:K.current.length>0});},[]),Ne=Rn.useCallback((g,f)=>{N(S=>S.map(k=>k.id===g?{...k,text:f}:k));},[]),Ie=Rn.useCallback(g=>{N(S=>S.filter(k=>k.id!==g));let f=D.current.lastIndexOf("comment");f>=0&&D.current.splice(f,1),K.current=[],U();},[U]);Rn.useEffect(()=>{let g=Y.current;if(g==null)return;Y.current=null,d.current?.querySelector(`[data-bubble-id="${g}"] .lumen-bubble-text`)?.focus();},[H]),Rn.useEffect(()=>{T([]),N([]),w(false),D.current=[],K.current=[],U();},[t,U]),Rn.useEffect(()=>{let g=false,f=null;return (async()=>{try{let S=await createImageBitmap(t);if(g){S.close?.();return}f=S,C(S);}catch{}})(),()=>{g=true,f?.close?.();}},[t]),Rn.useEffect(()=>{if(!p)return;let g=c.current,f=l.current;if(!(!g||!f)){f.width=p.width,f.height=p.height;try{g.width=p.width,g.height=p.height;let S=g.getContext("2d");if(!S)return;S.imageSmoothingEnabled=!1,S.drawImage(p,0,0),w(!1);}catch{w(true);}}},[p]),Rn.useEffect(()=>{if(!b){L("");return}let g=URL.createObjectURL(t);return L(g),()=>{URL.revokeObjectURL(g);}},[b,t]),Rn.useEffect(()=>{let g=l.current;if(g)try{pt(g,M,h.current);}catch{}},[M]),Rn.useImperativeHandle(s,()=>({hasAnnotations:()=>M.length>0||H.some(g=>g.text.trim().length>0),reset:()=>{T([]),N([]),W.current=[],_.current=[],D.current=[],K.current=[],U();},undo:()=>{let g=D.current[D.current.length-1];if(g){if(g==="comment"){let f=_.current,S=f[f.length-1];if(!S)return;let k=f.slice(0,-1);_.current=k,K.current.push({type:"comment",item:S}),N(k);}else {let f=W.current,S=f[f.length-1];if(!S)return;let k=f.slice(0,-1);W.current=k,K.current.push({type:"anno",item:S}),T(k);}D.current.pop(),U();}},redo:()=>{let g=K.current[K.current.length-1];if(g){if(g.type==="comment"){let f=[..._.current,g.item];_.current=f,N(f);}else {let f=[...W.current,g.item];W.current=f,T(f);}D.current.push(g.type),K.current.pop(),U();}},async flatten(){let g=h.current,f=g?[...M,g]:M,S=H.filter(k=>k.text.trim().length>0);if(f.length===0&&S.length===0||!p||b)return t;try{let k=document.createElement("canvas");k.width=p.width,k.height=p.height;let O=k.getContext("2d");if(!O)return t;O.imageSmoothingEnabled=!1,O.drawImage(p,0,0);for(let z of f)It(O,z);let q=c.current?.clientWidth||p.width,G=p.width/Math.max(q,1);for(let z of S)Ao(O,z,p.width,p.height,G);return await new Promise(z=>{k.toBlob(J=>{z(J??t);},"image/jpeg",.85);})}catch{return t}}}),[M,H,p,t,b,U]);function ie(g){let f=l.current;if(!f)return {x:0,y:0};let S=f.getBoundingClientRect(),k=f.width/Math.max(S.width,1),O=f.height/Math.max(S.height,1);return {x:(g.clientX-S.left)*k,y:(g.clientY-S.top)*O}}function ve(){P.current||(P.current=true,requestAnimationFrame(()=>{P.current=false;let g=l.current;g&&pt(g,W.current,h.current);}));}function we(g){if(g.button!==void 0&&g.button!==0)return;if(n==="comment"){let S=l.current;if(!S)return;let k=S.getBoundingClientRect(),O=Cn((g.clientX-k.left)/Math.max(k.width,1),.72),q=Cn((g.clientY-k.top)/Math.max(k.height,1),.8),G=++ae.current;N(z=>[...z,{id:G,x:O,y:q,text:"",color:r}]),D.current.push("comment"),K.current=[],Y.current=G,U();return}try{g.currentTarget.setPointerCapture(g.pointerId);}catch{}y.current=true,a?.(true);let f=ie(g);n==="arrow"?h.current={kind:"arrow",from:f,to:f,color:r,width:o}:n==="rect"?h.current={kind:"rect",from:f,to:f,color:r,width:o}:h.current={kind:"freehand",points:[f],color:r,width:o},B.current=performance.now(),ve();}function se(g){if(!y.current||!h.current)return;let f=ie(g),S=h.current;if(S.kind==="arrow"||S.kind==="rect")S.to=f;else {let k=S.points[S.points.length-1],O=k?(k.x-f.x)**2+(k.y-f.y)**2:1/0,q=performance.now(),G=q-B.current;(O>16||G>16)&&(S.points.push(f),B.current=q);}ve();}function le(){if(!y.current)return;y.current=false,a?.(false);let g=h.current;if(h.current=null,!!g){if(g.kind==="arrow"||g.kind==="rect"){let f=g.to.x-g.from.x,S=g.to.y-g.from.y;if(f*f+S*S<16){let k=l.current;k&&pt(k,W.current,null);return}}else if(g.points.length<2){let f=l.current;f&&pt(f,W.current,null);return}T(f=>[...f,g].slice(-50)),D.current.push("anno"),K.current=[],U();}}return jsxRuntime.jsxs("div",{ref:d,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:c}),b&&x?jsxRuntime.jsx("img",{src:x,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsxRuntime.jsx("canvas",{ref:l,className:"lumen-annotate-overlay",onPointerDown:we,onPointerMove:se,onPointerUp:le,onPointerCancel:le}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:H.map(g=>jsxRuntime.jsx(Lo,{comment:g,onChange:Ne,onRemove:Ie},g.id))})]})});function Lo({comment:e,onChange:t,onRemove:n}){let r=Rn.useRef(null);return Rn.useEffect(()=>{let o=r.current;o&&o.textContent!==e.text&&(o.textContent=e.text);},[]),jsxRuntime.jsxs("div",{className:"lumen-bubble","data-bubble-id":e.id,style:{left:`${e.x*100}%`,top:`${e.y*100}%`,"--lumen-bubble-accent":e.color},onPointerDown:o=>o.stopPropagation(),children:[jsxRuntime.jsx("span",{className:"lumen-bubble-label",children:"Comment"}),jsxRuntime.jsx("div",{ref:r,className:"lumen-bubble-text",contentEditable:true,suppressContentEditableWarning:true,role:"textbox","aria-label":"Comment text","data-placeholder":"Type a note\u2026",onInput:o=>t(e.id,o.currentTarget.textContent??"")}),jsxRuntime.jsx("button",{type:"button",className:"lumen-bubble-del","aria-label":"Remove comment",onPointerDown:o=>o.stopPropagation(),onClick:()=>n(e.id),children:"\xD7"})]})}function pt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)It(r,o);n&&It(r,n);}}function It(e,t){if(e.save(),e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",t.kind==="rect"){let n=Math.min(t.from.x,t.to.x),r=Math.min(t.from.y,t.to.y),o=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,r,o,a);}else if(t.kind==="freehand")To(e,t.points);else {let{from:n,to:r,width:o}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke();let a=Math.atan2(r.y-n.y,r.x-n.x),i=Math.max(12,o*4);e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(r.x-i*Math.cos(a-Math.PI/7),r.y-i*Math.sin(a-Math.PI/7)),e.lineTo(r.x-i*Math.cos(a+Math.PI/7),r.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function To(e,t){if(t.length===0)return;e.beginPath();let n=t[0];if(!n)return;if(e.moveTo(n.x,n.y),t.length===1){e.arc(n.x,n.y,e.lineWidth/2,0,Math.PI*2),e.fill();return}if(t.length===2){let o=t[1];e.lineTo(o.x,o.y),e.stroke();return}for(let o=1;o<t.length-1;o++){let a=t[o],i=t[o+1],s=(a.x+i.x)/2,c=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,s,c);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function Ao(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,s=14*o,c=10*o,l=12*o,d=s*1.35,p=c*1.7,C=t.x*n,b=t.y*r,w=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${s}px ${Nt}`,e.textBaseline="top";let x=Po(e,a,w-i*2),L=x.reduce((P,H)=>Math.max(P,e.measureText(H).width),0),M=Math.min(w,Math.max(L,56*o)+i*2),T=i*2+p+x.length*d;No(e,C,b,M,T,l),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let h=C+18*o,y=b+T;e.beginPath(),e.moveTo(h,y-o),e.lineTo(h+13*o,y-o),e.lineTo(h+4*o,y+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${c}px ${Nt}`,e.fillText("COMMENT",C+i,b+i),e.fillStyle="#111318",e.font=`500 ${s}px ${Nt}`;let B=b+i+p;for(let P of x)e.fillText(P,C+i,B),B+=d;e.restore();}function Po(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let s=a?`${a} ${i}`:i;a&&e.measureText(s).width>n?(o.push(a),a=i):a=s;}return a&&o.push(a),o.length?o:[t]}function No(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function nt({children:e,...t}){return jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...t,children:e})}function Io(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("path",{d:"M3 9a2 2 0 0 1 2-2h1.5l1-1.5h5l1 1.5H19a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"}),jsxRuntime.jsx("circle",{cx:"12",cy:"13",r:"3.2"})]})}function Do(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2.5"}),jsxRuntime.jsx("path",{d:"m16 10 5-3v10l-5-3"})]})}function Oo(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("path",{d:"M12 16V4m0 0 4 4m-4-4-4 4"}),jsxRuntime.jsx("path",{d:"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"})]})}function ft(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function xn(e){return jsxRuntime.jsxs(nt,{...e,children:[jsxRuntime.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),jsxRuntime.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]})}var Dt={shot:Io,video:Do,upload:Oo};function Mn(e){let t=e.videoWidth||1280,n=e.videoHeight||720,r=document.createElement("canvas");r.width=t,r.height=n;let o=r.getContext("2d");return o?(o.drawImage(e,0,0,t,n),new Promise(a=>r.toBlob(i=>a(i),"image/jpeg",.82))):Promise.resolve(null)}function Bo(e,t){return !Number.isFinite(t)||t<=0?Promise.resolve():new Promise(n=>{e.addEventListener("seeked",()=>n(),{once:true});try{e.currentTime=t;}catch{n();}})}var Ho=4e3;async function Ot(e){if(typeof document>"u")return {poster:null,durationMs:0};let t=URL.createObjectURL(e),n=document.createElement("video");n.muted=true,n.playsInline=true,n.preload="auto",n.src=t;let r=async()=>{await new Promise((c,l)=>{if(n.readyState>=2)return c();n.addEventListener("loadeddata",()=>c(),{once:true}),n.addEventListener("error",()=>l(new Error("video decode failed")),{once:true});}),await Bo(n,Math.min(.1,(n.duration||0)/2));let i=await Mn(n),s=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:s}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),Ho);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Bt(e){if(typeof document>"u")return null;let t=document.createElement("video");t.muted=true,t.playsInline=true,t.srcObject=e;try{return await t.play().catch(()=>{}),await new Promise(n=>{if(t.readyState>=2)return n();t.addEventListener("loadeddata",()=>n(),{once:!0}),window.setTimeout(n,600);}),await Mn(t)}catch{return null}finally{t.srcObject=null;}}async function Ht(){if(typeof document>"u")return null;let e=document.createElement("canvas");e.width=1280,e.height=720;let t=e.getContext("2d");return t?(t.fillStyle="#0e0e12",t.fillRect(0,0,e.width,e.height),t.fillStyle="#52525b",t.beginPath(),t.moveTo(590,312),t.lineTo(590,408),t.lineTo(694,360),t.closePath(),t.fill(),new Promise(n=>e.toBlob(r=>n(r),"image/jpeg",.8))):null}var _t=60,_o=25*1024*1024,Ln=[{label:"Red",value:"rgb(239, 68, 68)"},{label:"Amber",value:"rgb(245, 158, 11)"},{label:"Blue",value:"rgb(59, 130, 246)"},{label:"Green",value:"rgb(34, 197, 94)"},{label:"Neutral",value:"rgb(244, 244, 245)"}],Tn=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],An=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],Pn=[{value:"shot",label:"Screenshot",hint:"This page, instantly",primary:true},{value:"video",label:"Video",hint:"Record up to 60s"},{value:"upload",label:"Upload",hint:"Image or video"}];function Vt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:s,consumePendingVideo:c,canRecordScreen:l,consumeRecordStartError:d,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:b,keyboardInset:w}=Je(),[x,L]=Rn.useState(1),[M,T]=Rn.useState(null),[h,y]=Rn.useState({kind:"idle"}),[B,P]=Rn.useState(false),[H,N]=Rn.useState(0),[ae,D]=Rn.useState(null),[K,W]=Rn.useState(false),[_,Y]=Rn.useState("arrow"),[be,U]=Rn.useState(Ln[0].value),[Ne,Ie]=Rn.useState(Tn[1].value),[ie,ve]=Rn.useState(""),[we,se]=Rn.useState("bug"),[le,g]=Rn.useState(r?.email??""),[f,S]=Rn.useState(null),[k,O]=Rn.useState(null),[q,G]=Rn.useState(0),[z,J]=Rn.useState(null),[fe,Q]=Rn.useState(null),[ne,We]=Rn.useState(false),[ye,De]=Rn.useState({canUndo:false,canRedo:false}),Re=Rn.useRef(null),_e=Rn.useRef(null),Ve=Rn.useRef(null),Fe=Rn.useRef(null),Se=et(t,w),ge=Rn.useRef(false),ue=Rn.useRef(false);Rn.useEffect(()=>{t||(ue.current=false);},[t]),Rn.useEffect(()=>{if(!t)return;if(ue.current){ge.current=false;return}ue.current=true,ge.current=false,L(1),T(null),ve(""),O(null),G(0),J(null),P(false),N(0),D(null),W(false),Q(null),De({canUndo:false,canRedo:false});let u=C();if(u){T("shot"),xe(u),y({kind:"ready",capture:u});return}let v=c();if(v)T("video"),J({blob:v.blob,durationMs:v.durationMs}),v.blob.size>_o&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),v.poster?y({kind:"ready",capture:Ge(v.poster,["Screen recording; preview is the first frame."])}):(y({kind:"capturing"}),(async()=>{let A=null;if(v.deriveBlobPoster)try{A=(await Ot(v.blob)).poster;}catch{A=null;}A=A??await Ht(),!ge.current&&y(A?{kind:"ready",capture:Ge(A,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let A=d();A?(T("video"),Q(A),y({kind:"idle"})):a?(T("shot"),y({kind:"ready",capture:a})):o?.mode==="manual"?y({kind:"manual"}):o?.provider&&!i?(T("shot"),ee(o.mode??"auto")):y({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ge.current=true;}},[t,o,a,i]),Rn.useEffect(()=>{if(!t)return;Fe.current=document.activeElement??null;let u=document.documentElement,v=u.style.overflow,A=u.style.paddingRight,te=window.innerWidth-u.clientWidth;u.style.overflow="hidden",te>0&&(u.style.paddingRight=`${te}px`);let re=false,Le=()=>{if(!re){re=true,u.style.overflow=v,u.style.paddingRight=A;try{Fe.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Le),()=>{window.removeEventListener("pagehide",Le),Le();}},[t]),Rn.useEffect(()=>{if(!t)return;function u(v){if(v.key==="Escape"){v.preventDefault(),n();return}if(v.key!=="Tab")return;let A=_e.current;if(!A)return;let te=Yo(A);if(te.length===0)return;let re=te[0],Le=te[te.length-1],Et=document.activeElement;v.shiftKey&&(Et===re||!A.contains(Et))?(v.preventDefault(),Le.focus()):!v.shiftKey&&Et===Le&&(v.preventDefault(),re.focus());}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,n]),Rn.useEffect(()=>{if(!t||!b)return;let u=Ve.current;if(!u)return;let v=A=>{A.target===u&&A.stopPropagation();};return u.addEventListener("pointerdown",v),u.addEventListener("click",v),u.addEventListener("touchstart",v,{passive:true}),()=>{u.removeEventListener("pointerdown",v),u.removeEventListener("click",v),u.removeEventListener("touchstart",v);}},[t,b]),Rn.useEffect(()=>{if(!t||!Se.open)return;let u=_e.current,v=document.activeElement;if(u&&v&&u.contains(v))try{v.scrollIntoView({block:"center"});}catch{}},[t,Se.open,Se.inset]),Rn.useEffect(()=>{if(!t||h.kind!=="manual")return;function u(v){let re=Array.from(v.clipboardData?.items??[]).find(Le=>Le.type.startsWith("image/"))?.getAsFile();re&&(v.preventDefault(),Ee(re));}return window.addEventListener("paste",u),()=>window.removeEventListener("paste",u)},[t,h.kind]),Rn.useEffect(()=>{if(!f)return;let u=Date.now(),v=window.setInterval(()=>{let A=Math.floor((Date.now()-u)/1e3);G(A),A>=_t&&ze();},250);return ()=>window.clearInterval(v)},[f]);let ce=Rn.useRef(null);if(ce.current=f,Rn.useEffect(()=>{t||ce.current&&(ce.current.cancel(),ce.current=null,S(null),G(0));},[t]),Rn.useEffect(()=>()=>{ce.current?.cancel();},[]),!t)return null;async function ee(u){ge.current=false,y({kind:"capturing"});try{let v=await ct({...o,mode:u,target:o?.target??document.documentElement});return ge.current?!1:(xe(v),y({kind:"ready",capture:v}),!0)}catch(v){return ge.current||y({kind:"manual",error:v instanceof Error?v.message:"Automatic screenshot capture was unavailable."}),false}}async function ke(u){T(u),Q(null),D(null),u!=="video"&&Me(),u==="shot"?await ee(o?.mode??"auto"):u==="video"?(J(null),y({kind:"idle"})):y({kind:"manual"});}async function Ee(u){if(u.type.startsWith("image/")){Me();let v=Ge(u,["Manual image upload used."]);y({kind:"ready",capture:v});return}if(u.type.startsWith("video/")){y({kind:"capturing"});try{let{poster:v,durationMs:A}=await Ot(u),te=v??await Ht();if(!te){y({kind:"manual",error:"Could not read that video."});return}let re=Ge(te,["Uploaded video; preview is the first frame."]);J({blob:u,durationMs:A}),y({kind:"ready",capture:re});}catch{y({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function xe(u){u.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function Ue(){try{let u=await bn(_t);S(u);}catch(u){sonner.toast.error(u instanceof Error?u.message:"Microphone unavailable");}}async function ze(){if(f)try{let u=await f.stop();O({blob:u.blob,durationMs:u.durationMs});}catch(u){sonner.toast.error(u instanceof Error?u.message:"Could not stop recording");}finally{S(null);}}function at(){f?.cancel(),S(null),O(null),G(0);}function qe(u){let v=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!f&&!k?jsxRuntime.jsxs("button",{type:"button",onClick:Ue,className:u==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(xn,{}),"Record voice note"]}):null,f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx($o,{stream:f.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[q,"s / ",_t,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:ze,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:at,className:"lumen-btn-ghost",children:"Cancel"})]}):null,k&&!f?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Wo,{blob:k.blob,durationMs:k.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>O(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return u==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[v,!f&&!k?jsxRuntime.jsx("p",{className:"lumen-voice-capture-hint",children:"Say what went wrong while it\u2019s fresh."}):null]}):jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),v]})}async function it(){Q(null);try{await s();}catch(u){sonner.toast.error(u instanceof Error?u.message:"Screen capture unavailable");}}function Me(){J(null);}let wt=h.kind==="ready";async function yt(){if(f&&await ze(),x===1){if(h.kind==="ready"){let u=await Re.current?.flatten();D(u??h.capture.blob),W(u!=null&&u!==h.capture.blob);}L(2);}else x===2?L(3):await R();}function he(){x>1&&L(u=>u-1);}async function R(){if(h.kind!=="ready")return;let u=ie.trim(),{capture:v}=h;P(true),N(0);try{let A=ae??v.blob,te=await e.submit({rawText:u.length>0?u:void 0,category:we,submitterEmail:le.trim()||void 0,screenshot:A,audio:k?.blob,audioDurationMs:k?.durationMs,video:z?.blob,videoDurationMs:z?.durationMs,context:hn(v)},{onUploadProgress:re=>N(Math.min(.95,re))});N(1),sonner.toast.success("Feedback sent \u2014 thank you."),te.id,n();}catch(A){sonner.toast.error(A instanceof Error?A.message:"Could not submit feedback"),P(false);}}function F(u){u.target===u.currentTarget&&!B&&n();}let $=Math.round(H*100),je=M==="video",gr=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,hr=M==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&gr,br=x===1&&!wt||B,vr=x<3?"Next":B?$<95?`Uploading ${$}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:Ve,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Se.inset?{"--lumen-keyboard-inset":`${Se.inset}px`}:void 0,onMouseDown:F,children:jsxRuntime.jsxs("div",{ref:_e,className:"lumen-modal","data-lumen-drawing":ne?"true":void 0,children:[jsxRuntime.jsx(zo,{onDismiss:n}),jsxRuntime.jsxs("header",{className:"lumen-modal-header",children:[jsxRuntime.jsxs("h2",{className:"lumen-modal-title",children:[jsxRuntime.jsx("span",{className:"lumen-modal-title-dot","aria-hidden":"true"}),"Send feedback"]}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-icon-btn","aria-label":"Close",children:"\xD7"})]}),jsxRuntime.jsx(Vo,{step:x}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[x===1?jsxRuntime.jsx("div",{className:"lumen-pane",children:M===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:Pn.map(u=>{let v=Dt[u.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(u.primary?" lumen-method-primary":""),onClick:()=>ke(u.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(v,{})}),u.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:u.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:u.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:u.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:u.hint})]})]},u.value)})}),jsxRuntime.jsx("p",{className:"lumen-status lumen-method-help",children:"Choose how to capture your feedback."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-method-switch",role:"group","aria-label":"Switch capture method",children:Pn.map(u=>{let v=Dt[u.value];return jsxRuntime.jsxs("button",{type:"button","aria-pressed":M===u.value,onClick:()=>ke(u.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx(v,{}),u.label]},u.value)})}),M==="video"&&h.kind==="idle"?jsxRuntime.jsx(Fo,{canRecord:l,onRecord:it,onUpload:()=>ke("upload"),error:fe}):null,h.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,h.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:M==="upload"?"Choose an image or video to attach \u2014 or paste an image.":h.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:M==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:M==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:u=>{let v=u.currentTarget.files?.[0];v&&Ee(v),u.currentTarget.value="";}})]})]}):null,h.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[je?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(gt,{label:"Arrow",active:_==="arrow",onClick:()=>Y("arrow")}),jsxRuntime.jsx(gt,{label:"Box",active:_==="rect",onClick:()=>Y("rect")}),jsxRuntime.jsx(gt,{label:"Draw",active:_==="freehand",onClick:()=>Y("freehand")}),jsxRuntime.jsx(gt,{label:"Comment",active:_==="comment",onClick:()=>Y("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:Ln.map(u=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:u.value},"aria-label":u.label,"aria-pressed":be===u.value,onClick:()=>U(u.value)},u.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Tn.map(u=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":u.label,"aria-pressed":Ne===u.value,onClick:()=>Ie(u.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:u.dot,height:u.dot}})},u.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.undo(),disabled:!ye.canUndo,children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.redo(),disabled:!ye.canRedo,children:"Redo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.reset(),disabled:!ye.canUndo,children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Sn,{ref:Re,screenshot:h.capture.blob,tool:_,color:be,strokeWidth:Ne,onDrawingChange:We,onHistoryChange:De})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>M&&ke(M),children:je?"\u21BB Re-record":"\u21BB Recapture"}),hr?jsxRuntime.jsxs("button",{type:"button",className:"lumen-btn-ghost lumen-exact-btn",onClick:()=>{p();},title:"Capture the real screen pixels \u2014 your browser will ask which tab or window to share, then you arrange the page and press Capture.",children:[jsxRuntime.jsx(ft,{})," Capture exact screen"]}):null,je?z?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(z.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:h.capture.method==="web-display-media"?"Exact screen captured":`${Nn(M)} captured \xB7 switch method above anytime`})]}),qe("capture")]}):null]})}):null,x===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:ie,onChange:u=>ve(u.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),qe("describe"),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:An.map(u=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":we===u.value,onClick:()=>se(u.value),children:u.label},u.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:le,onChange:u=>g(u.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,x===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[Nn(M),K?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>L(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:An.find(u=>u.value===we)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>L(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[ie.trim()?ie.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>L(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[k?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(k.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>O(null),children:"\xD7"})]}):null,z?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(z.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Me,children:"\xD7"})]}):null,le.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",le.trim()]}):null,!k&&!f?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{L(2),Ue();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[B?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":$,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${$}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:x===1?n:he,className:"lumen-btn-ghost",disabled:B,children:x===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:yt,className:"lumen-btn-primary",disabled:br,children:vr})]})]})]})})}function Nn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function Vo({step:e}){let t=[{n:1,label:"Capture"},{n:2,label:"Describe"},{n:3,label:"Review"}];return jsxRuntime.jsx("div",{className:"lumen-stepper","aria-hidden":"true",children:t.map((n,r)=>jsxRuntime.jsxs("div",{className:"lumen-step"+(e===n.n?" lumen-step-active":"")+(e>n.n?" lumen-step-done":""),children:[jsxRuntime.jsx("span",{className:"lumen-step-num",children:n.n}),jsxRuntime.jsx("span",{className:"lumen-step-lbl",children:n.label}),r<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function Fo({canRecord:e,onRecord:t,onUpload:n,error:r}){return e?jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[r?jsxRuntime.jsxs("p",{className:"lumen-record-unavailable",role:"alert",children:[r," Try again, or switch to ",jsxRuntime.jsx("strong",{children:"Upload"})," to attach a video instead."]}):null,jsxRuntime.jsx("button",{type:"button",className:"lumen-record-btn","aria-label":"Start screen recording",onClick:t}),jsxRuntime.jsxs("div",{className:"lumen-record-copy",children:[jsxRuntime.jsx("div",{className:"lumen-record-title",children:"Record your screen"}),jsxRuntime.jsx("div",{className:"lumen-record-sub",children:"Tap to start. The sheet closes so you can record freely \u2014 a Stop button stays on screen, then the sheet returns with your clip. Max 60s."})]})]}):jsxRuntime.jsxs("div",{className:"lumen-record-prompt",children:[jsxRuntime.jsx("p",{className:"lumen-record-unavailable",children:Uo()?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available on iOS browsers. Record with Control Center\u2019s screen recorder, then attach the clip below."}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Screen recording isn\u2019t available in this browser. Upload a video to attach one instead."})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-record-upload",onClick:n,children:"Upload a video"})]})}function Uo(){if(typeof navigator>"u")return false;let e=navigator.userAgent||"";return /iPad|iPhone|iPod/.test(e)?true:/Macintosh/.test(e)&&typeof document<"u"&&"ontouchend"in document}function gt({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function zo({onDismiss:e}){let t=Rn.useRef(null),n=Rn.useRef(0),r=Rn.useRef(null);function o(s){s.currentTarget.setPointerCapture(s.pointerId),t.current=s.clientY,n.current=performance.now(),r.current=s.currentTarget.parentElement;}function a(s){if(t.current==null||!r.current)return;let c=Math.max(0,s.clientY-t.current);r.current.style.transform=`translateY(${c}px)`;}function i(s){if(t.current==null||!r.current)return;let c=Math.max(0,s.clientY-t.current),l=Math.max(1,performance.now()-n.current),d=c/l;r.current.style.transform="",r.current.style.transition="",t.current=null,(c>80||d>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function $o({stream:e}){let t=Rn.useRef(null);return Rn.useEffect(()=>{let n=t.current;if(!n)return;let r=Math.min(window.devicePixelRatio||1,2),o=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(o*r),n.height=Math.round(a*r);let i=n.getContext("2d");if(!i)return;i.scale(r,r);let s=window.AudioContext??window.webkitAudioContext;if(!s)return;let c=new s,l=c.createMediaStreamSource(e),d=c.createAnalyser();d.fftSize=1024,d.smoothingTimeConstant=.6,l.connect(d);let p=new Uint8Array(d.fftSize),C=18,b=3,w=3,x=Math.max(2,(o-b*(C-1))/C),L=Math.min(x/2,3),M=new Array(C).fill(0),T=0,h=false;function y(){if(h)return;d.getByteTimeDomainData(p);let B=Math.floor(p.length/C);i.clearRect(0,0,o,a),i.fillStyle=qo("--lumen-danger")||"rgb(239,68,68)";for(let P=0;P<C;P++){let H=0;for(let _=0;_<B;_++){let Y=Math.abs((p[P*B+_]??128)-128);Y>H&&(H=Y);}let N=Math.min(1,H/128*1.8),ae=M[P]??0;M[P]=N>ae?N:ae+(N-ae)*.35;let D=Math.max(w,M[P]*a),K=P*(x+b),W=(a-D)/2;Ko(i,K,W,x,D,L),i.fill();}T=requestAnimationFrame(y);}return T=requestAnimationFrame(y),()=>{h=true,cancelAnimationFrame(T);try{l.disconnect();}catch{}c.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function Ko(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,r,o,i);return}e.moveTo(t+i,n),e.arcTo(t+r,n,t+r,n+o,i),e.arcTo(t+r,n+o,t,n+o,i),e.arcTo(t,n+o,t,n,i),e.arcTo(t,n,t+r,n,i),e.closePath();}function Wo({blob:e,durationMs:t}){let[n,r]=Rn.useState("");return Rn.useEffect(()=>{let o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o);}},[e]),jsxRuntime.jsxs("div",{className:"lumen-audio-preview",children:[jsxRuntime.jsx("audio",{controls:true,preload:"metadata",src:n,className:"lumen-audio-el"}),jsxRuntime.jsxs("span",{className:"lumen-audio-meta",children:[Math.round(t/1e3),"s"]})]})}function qo(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var jo='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Yo(e){return Array.from(e.querySelectorAll(jo)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var ht=class extends Rn__namespace.Component{state={hasError:false};static getDerivedStateFromError(){return {hasError:true}}componentDidCatch(t,n){if(typeof document<"u"){let r=document.documentElement;r.style.overflow="",r.style.paddingRight="",document.body.removeAttribute("data-lumen-open");}console.error("[lumen] recovered from a widget error:",t),sonner.toast.error("Feedback widget hit a snag and was reset. Please try again.");try{let r=t instanceof Error?t:null;this.props.onError?.({message:r?.message??String(t),name:r?.name??"Error",stack:r?.stack,componentStack:n?.componentStack??void 0});}catch{}Promise.resolve().then(()=>this.props.onReset());}render(){return this.state.hasError?null:this.props.children}};function Hn({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(Zo,{startedAt:e.startedAt,maxSeconds:e.maxSeconds,onStop:n,onCancel:r}),i):reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-rec-hud lumen-rec-hud-pending",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-spinner","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-hud-time",children:e.phase==="starting"?"Starting\u2026":"Processing\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"})]}),i)}function Zo({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Rn.useState(0);Rn.useEffect(()=>{let s=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));s();let c=window.setInterval(s,250);return ()=>window.clearInterval(c)},[e,t]);let i=s=>`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`;return jsxRuntime.jsxs("div",{className:"lumen-rec-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-dot","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-rec-hud-time",children:[i(o)," ",jsxRuntime.jsxs("span",{className:"lumen-rec-hud-max",children:["/ ",i(t)]})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-rec-hud-cancel",onClick:r,"aria-label":"Discard recording",children:"Discard"}),jsxRuntime.jsxs("button",{type:"button",className:"lumen-rec-hud-stop",onClick:n,"aria-label":"Stop recording and return to feedback",children:[jsxRuntime.jsx("span",{className:"lumen-rec-hud-square","aria-hidden":"true"}),"Stop"]})]})}function _n({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Rn.useState(false);if(Rn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,s=e.phase==="grabbing";return reactDom.createPortal(jsxRuntime.jsxs("div",{className:"lumen-cap-hud",role:"status","aria-live":"polite","data-lumen-root":"true","data-lumen-capture-ignore":"true",children:[s?jsxRuntime.jsx("span",{className:"lumen-cap-hud-spinner","aria-hidden":"true"}):jsxRuntime.jsx("span",{className:"lumen-cap-hud-ico","aria-hidden":"true",children:jsxRuntime.jsx(ft,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:s?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:s,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:s,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Ft(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function Vn(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function Fn(e){return e instanceof Error?e:new Error(String(e))}function Un(e,t,n){let r=false,o=false,a=false,i=null;function s(){o||(o=true,n.onCancelled());}function c(d){o||(o=true,n.onResult(d));}function l(d){o||(o=true,n.onError(d));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(d=>{if(i=d,r){try{d.cancel();}catch{}s();return}if(n.onActive(d),a){n.onProcessing();try{d.stop();}catch{}}Promise.resolve(d.result).then(p=>{r?s():c(p);}).catch(p=>{r||Vn(p)?s():l(Fn(p));});}).catch(d=>{r||Vn(d)?s():l(Fn(d));}),{stop(){if(!(o||r||a)&&(a=true,i)){n.onProcessing();try{i.stop();}catch{}}},cancel(){if(!(o&&r)){if(r=true,i)try{i.cancel();}catch{}s();}}}}function zn(){if(typeof document>"u"||typeof window>"u")return 0;let e=window.innerWidth,t=window.innerHeight;if(e===0||t===0)return 0;let n=t-4,r=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],o=new Set,a=0;for(let i of r){let s=document.elementsFromPoint(i,n);for(let c of s){if(o.has(c))continue;o.add(c);let l=window.getComputedStyle(c);if(l.position!=="fixed"&&l.position!=="sticky")continue;let d=c.getBoundingClientRect();d.bottom<t-8||d.bottom>t+8||d.width<e*.6||d.height>a&&(a=d.height);}}return a}function Ut(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,r=window.innerHeight,o=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let s of Array.from(i)){let c=s.getBoundingClientRect();if(c.height===0||c.width===0)continue;let l=0;switch(t){case "bottom":if(c.bottom<r-8)break;l=Math.max(0,r-c.top);break;case "top":if(c.top>8)break;l=Math.max(0,c.bottom);break;case "left":if(c.left>8)break;l=Math.max(0,c.right);break;case "right":if(c.right<n-8)break;l=Math.max(0,n-c.left);break}l>o&&(o=l);}}return o}function $n(e){let[t,n]=Rn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Rn.useRef(t),o=oa(e.avoid),a=e.placement,i=e.offset.x,s=e.offset.y;return Rn.useEffect(()=>{if(typeof window>"u")return;let c=0,l=false,d=()=>{if(c=0,l)return;let x=a[0]==="b"?"bottom":"top",L=a[1]==="r"?"right":"left",M=0,T=0;e.avoid==="auto"&&x==="bottom"?M=zn():Array.isArray(e.avoid)&&(M=Ut(e.avoid,x),T=Ut(e.avoid,L));let h={bottom:x==="bottom"?s+M:0,top:x==="top"?s+M:0,right:L==="right"?i+T:0,left:L==="left"?i+T:0},y=r.current;(h.bottom!==y.bottom||h.top!==y.top||h.right!==y.right||h.left!==y.left)&&(r.current=h,n(h));},p=()=>{c||(c=window.requestAnimationFrame(d));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let b=typeof MutationObserver<"u"?new MutationObserver(p):null;b?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let w=window.visualViewport;return w?.addEventListener("resize",p),w?.addEventListener("scroll",p),()=>{l=true,c&&window.cancelAnimationFrame(c),C?.disconnect(),b?.disconnect(),window.removeEventListener("resize",p),w?.removeEventListener("resize",p),w?.removeEventListener("scroll",p);}},[a,i,s,o]),t}function oa(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var Kn=["mousedown","touchstart"];function Ke(e){let t=Rn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Rn.useRef(e.onClick);n.current=e.onClick;let r=Rn.useRef(e.isolate??true);r.current=e.isolate??true;let o=Rn.useRef(null);return Rn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=l=>{r.current&&l.stopPropagation(),t.current?.(l);},s=l=>{r.current&&l.stopPropagation(),n.current(l);},c=l=>{r.current&&l.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",s);for(let l of Kn)a.addEventListener(l,c,l==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",s);for(let l of Kn)a.removeEventListener(l,c);};},[])}function Yn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[s,c]=Rn.useState(null),l=Rn.useRef(null),d=$n(e),p=et(e.keyboard!=="off",i),C=Ke({onPointerDown:r,onClick:o,isolate:a}),b=Rn.useCallback(N=>{l.current=N,C(N);},[C]);Rn.useEffect(()=>{typeof document>"u"||c(t??document.body);},[t]);let w=e.placement,x=w[0]==="b"?"bottom":"top",L=w[1]==="r"?"right":"left",M=x==="bottom",T=p.open&&M&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,h=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&M&&p.inset<=0);if(ua(l,!n&&!h),!s)return null;let y=x==="bottom"?d.bottom:d.top,B=L==="right"?d.right:d.left,P=n||h,H={position:"fixed",[x]:e.safeArea?`calc(${y}px + env(safe-area-inset-${x}, 0px))`:`${y}px`,[L]:e.safeArea?`calc(${B}px + env(safe-area-inset-${L}, 0px))`:`${B}px`,zIndex:e.zIndex,transform:T?`translateY(-${T}px)`:void 0,opacity:P?0:1,pointerEvents:P?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:b,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:H,"aria-label":e.label,"aria-hidden":P?true:void 0,tabIndex:P?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),s)}function ua(e,t){let n=Rn.useRef(false);Rn.useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let r=window.setTimeout(()=>{let o=e.current;if(!o)return;let a=o.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,s=a.top+a.height/2,c=document.elementsFromPoint(i,s),l=Wn(window.getComputedStyle(o).zIndex);for(let d of c){if(d===o||o.contains(d))continue;if(Wn(window.getComputedStyle(d).zIndex)>l){n.current=true,console.warn("[lumen] trigger is occluded by",d);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function Wn(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function Gn({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),c=Ke({onPointerDown:r,onClick:o,isolate:a});return Rn.useEffect(()=>{if(typeof document>"u")return;let l=e instanceof HTMLElement?e:e.current??null;s(l);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:c,type:"button",className:"lumen-btn lumen-btn-primary","aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),i):null}function Jn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,s]=Rn.useState(null),[c,l]=Rn.useState(false),d=Rn.useRef(null),p=Ke({onPointerDown:L=>{r?.(L),d.current={x:L.clientX,y:L.clientY},l(true);let M=L.currentTarget;try{M?.setPointerCapture?.(L.pointerId);}catch{}},onClick:o,isolate:a});if(Rn.useEffect(()=>{typeof document>"u"||s(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${c?" lumen-notch-expanded":""}`;function b(L){let M=d.current;if(!M)return;let T=L.clientX-M.x,h=L.clientY-M.y;(e.edge==="top"&&h>16||e.edge==="bottom"&&h<-16||e.edge==="right"&&T<-16||e.edge==="left"&&T>16)&&(d.current=null,o(L.nativeEvent));}function w(){d.current=null,l(false);}function x(){d.current=null,l(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:C,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:b,onPointerUp:w,onPointerCancel:x,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),i)}function Qn(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function Ea(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function er(e){return {kind:"floating",placement:e.placement??"br",offset:{x:e.offset?.x??16,y:e.offset?.y??16},safeArea:e.safeArea??true,avoid:e.avoid===false?false:e.avoid==null?"auto":Array.isArray(e.avoid)?e.avoid:[e.avoid],keyboard:Ea(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Sa={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function tr(e){let t=Rn.useId();Rn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${ka(t)}`,o={},a=(i,s)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,s);};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else {for(let[i,s]of Object.entries(Sa)){let c=e[s];typeof c=="string"&&c.length>0&&a(i,c);}typeof e.accent=="string"&&e.accent.length>0&&(a("--lumen-accent",e.accent),a("--lumen-primary",e.accent),a("--lumen-accent-fg","#ffffff")),(e.scheme==="light"||e.scheme==="dark")&&(o["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e.scheme));}return n.setAttribute(r,""),()=>{n.removeAttribute(r);for(let[i,s]of Object.entries(o))i.startsWith("--")?s?n.style.setProperty(i,s):n.style.removeProperty(i):s==null?n.removeAttribute(i):n.setAttribute(i,s);}},[e,t]);}function ka(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var nr=Symbol.for("lumen.history.patched"),zt="lumen:locationchange";function La(){if(typeof window>"u")return;let e=window;if(e[nr])return;e[nr]=true;let t=()=>window.dispatchEvent(new Event(zt)),n=history.pushState;history.pushState=function(...o){let a=n.apply(this,o);return t(),a};let r=history.replaceState;history.replaceState=function(...o){let a=r.apply(this,o);return t(),a},window.addEventListener("popstate",t);}function rr(e){let[t,n]=Rn.useState(false);return Rn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;La();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(zt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(zt,r),window.removeEventListener("popstate",r);}},[e]),t}var Pa=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function or(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let r=n.webkit;if(r&&r.messageHandlers){t(true);return}let o=navigator.userAgent||"";Pa.some(a=>o.includes(a))&&t(true);},[]),e}var ir="lumen.config.v1.",Da=3600*1e3;function sr(e,t){let[n,r]=Rn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Rn.useEffect(()=>{if(typeof window>"u")return;let o=Fa(e);o&&r({trigger:o.trigger,enabled:ar(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),s=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(s,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);let l=await c.json(),d=lr(l.trigger);if(!d)throw new Error("Malformed config response");let p=Ha(l.trigger),C=ur(l.brand);Ua(e,d,p,C),r({trigger:d,enabled:ar(d),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(c=>c.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:c);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function ar(e){return e.kind!=="headless"}var Oa=["br","bl","tr","tl"],Ba=["top","right","bottom","left"];function lr(e){if(!e||typeof e!="object")return null;let t=e;if(t.enabled===false)return {kind:"headless"};let n=typeof t.label=="string"?t.label:"Feedback";return t.kind==="floating"?{kind:"floating",placement:Oa.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:Ba.find(o=>o===t.edge)??"top",label:n}:null}function Ha(e){return !e||typeof e!="object"?false:e.shake===true}var _a=/^#[0-9a-fA-F]{6}$/,Va=["auto","light","dark"];function ur(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&_a.test(t.accent)?t.accent:null;if(!n)return null;let r=Va.find(a=>a===t.mode)??"auto",o=typeof t.radius=="number"&&Number.isFinite(t.radius)?Math.min(20,Math.max(0,Math.round(t.radius))):10;return {accent:n,mode:r,radius:o}}function Fa(e){try{let t=window.localStorage.getItem(ir+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>Da)return null;let r=lr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:ur(n.brand)}:null}catch{return null}}function Ua(e,t,n,r){try{window.localStorage.setItem(ir+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function $a(e){if(e&&typeof e=="object")return e.type===mt;if(typeof e=="string")try{return JSON.parse(e).type===mt}catch{return false}return false}function Ka(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(s,c,l,d){if(!a)return a={x:s,y:c,z:l,t:d},false;if(d-a.t<o)return false;let p=Math.abs(s-a.x)+Math.abs(c-a.y)+Math.abs(l-a.z);return a={x:s,y:c,z:l,t:d},p<t?false:(i=i.filter(C=>d-C<r),i.push(d),i.length>=n?(i=[],true):false)}}}function cr(e,t,n){Rn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let d=Date.now();n||d-r<o||(r=d,t());}let i=d=>{$a(d.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let s=Ka(),c=d=>{let p=d.accelerationIncludingGravity??d.acceleration;!p||p.x==null||p.y==null||p.z==null||s.push(p.x,p.y,p.z,Date.now())&&a();},l=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return l&&window.addEventListener("devicemotion",c),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),l&&window.removeEventListener("devicemotion",c);}},[e,t,n]);}var mr="https://shakebugs.vercel.app",vt=60;function pr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function ja({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:s,portalTarget:c,capture:l,record:d,shakeToOpen:p,onOpenChange:C,beforeOpen:b,onTriggerActivate:w,isolateEvents:x=true,keyboardInset:L,suppressTrigger:M=false,children:T}){let[h,y]=Rn.useState(false),[B,P]=Rn.useState(false),[H,N]=Rn.useState(null),[ae,D]=Rn.useState(null),[K]=Rn.useState(false),[W]=Rn.useState(null),_=Rn.useRef(false),Y=Rn.useRef(false),be=Rn.useRef(null),U=Rn.useMemo(()=>new tn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Rn.useEffect(()=>{fn({ignoreUrlPrefix:(t??mr).replace(/\/$/,"")});},[t]);let Ne=Rn.useRef(C);Ne.current=C,Rn.useEffect(()=>{if(!(typeof document>"u"))return h?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[h]);let Ie=Rn.useRef(null);Rn.useEffect(()=>{if(Ie.current===h)return;let R=Ie.current;Ie.current=h,R!==null&&Ne.current?.(h);},[h]);let ie=Rn.useRef(b);ie.current=b;let ve=Rn.useRef(w);ve.current=w;let we=Rn.useCallback(R=>{Y.current=true,be.current=Promise.resolve().then(()=>ie.current?.(R)).then(()=>ve.current?.(R)).then(()=>{});},[]),se=Rn.useCallback(R=>{_.current||h||Q.current||Ee.current||(_.current=true,P(true),N(null),D(null),(async()=>{try{if(Y.current?await be.current:(await ie.current?.(R),await ve.current?.(R)),l?.mode==="manual")N(null),D(null);else if(l?.provider)N(null),D(null);else {let F=await ct({...l,mode:l?.mode??"auto",target:l?.target??document.documentElement});N(F);}}catch(F){D(F instanceof Error?F:new Error(String(F)));}finally{Y.current=false,be.current=null,_.current=false,P(false),y(true);}})());},[l,h]),le=Rn.useCallback(()=>{y(false),N(null),D(null);},[]),g=Rn.useCallback(U.submit.bind(U),[U]),[f,S]=Rn.useState(0),k=Rn.useCallback(()=>{_.current=false,P(false),y(false),N(null),D(null),S(R=>R+1);},[]),[O,q]=Rn.useState(null),[G,z]=Rn.useState(null),J=Rn.useRef(null),fe=Rn.useRef(null),Q=Rn.useRef(false),ne=Rn.useRef(null),We=Rn.useRef(null),ye=Rn.useRef(null),De=Rn.useCallback((R,F=false)=>{if(J.current=null,fe.current=null,Q.current=false,q(null),!R){ne.current=null;return}We.current={blob:R.blob,durationMs:R.durationMs,poster:ne.current,deriveBlobPoster:F},ne.current=null,y(true);},[]);Rn.useEffect(()=>{if(!h)return;if(!d?.provider){z(null);return}let R=d.isAvailable;if(!R){z(true);return}let F=false;return Promise.resolve().then(()=>R()).then($=>{F||z($);}).catch(()=>{F||z(false);}),()=>{F=true;}},[h,d?.provider,d?.isAvailable]);let Re=Ft({hasProvider:!!d?.provider,providerAvailable:G,hasGetDisplayMedia:pr()}).canRecord,_e=Rn.useCallback(async()=>{if(Q.current)return;if(ye.current=null,Ft({hasProvider:!!d?.provider,providerAvailable:G,hasGetDisplayMedia:pr()}).usingProvider&&d?.provider){Q.current=true,ne.current=null,y(false),fe.current=Un(d.provider,{maxDurationSeconds:vt},{onStarting:()=>q({phase:"starting"}),onActive:$=>{q({phase:"recording",stream:$.stream??null,startedAt:Date.now(),maxSeconds:vt}),$.stream&&Bt($.stream).then(je=>{ne.current=je;}).catch(()=>{});},onProcessing:()=>q({phase:"processing"}),onResult:$=>De({blob:$.blob,durationMs:$.durationMs},true),onCancelled:()=>{fe.current=null,Q.current=false,ne.current=null,q(null),N(null),D(null),y(true);},onError:$=>{fe.current=null,Q.current=false,ne.current=null,q(null),ye.current=$.message||"Screen recording could not start.",y(true);}});return}if(J.current)return;let F=await vn(vt);J.current=F,Q.current=true,ne.current=null,q({phase:"recording",stream:F.stream,startedAt:Date.now(),maxSeconds:vt}),y(false),Bt(F.stream).then($=>{ne.current=$;}).catch(()=>{}),F.result.then($=>De($)).catch(()=>De(null));},[De,d?.provider,G]),Ve=Rn.useCallback(()=>{fe.current?fe.current.stop():J.current?.stop();},[]),Fe=Rn.useCallback(()=>{if(fe.current){fe.current.cancel();return}let R=J.current;J.current=null,Q.current=false,ne.current=null,q(null),R?.cancel(),N(null),D(null),y(true);},[]),Se=Rn.useCallback(()=>{let R=We.current;return We.current=null,R},[]),ge=Rn.useCallback(()=>{let R=ye.current;return ye.current=null,R},[]);Rn.useEffect(()=>{h||(ye.current=null);},[h]);let[ue,ce]=Rn.useState(null),ee=Rn.useRef(null),ke=Rn.useRef(null),Ee=Rn.useRef(false),xe=Rn.useCallback(()=>{let R=ee.current;ee.current=null,Ee.current=false,R?.stop(),ce(null),y(true);},[]),Ue=Rn.useCallback(()=>{let R=ee.current;R&&(ce({phase:"grabbing"}),(async()=>{try{let F=await R.grab();if(ee.current!==R)return;ke.current=F,ee.current=null,Ee.current=!1,R.stop(),ce(null),y(!0);}catch{if(ee.current!==R)return;ee.current=null,Ee.current=false,R.stop(),ce(null),sonner.toast.error("Could not capture the screen. Please try again."),y(true);}})());},[]),ze=Rn.useCallback(async()=>{if(Ee.current)return;let R;try{R=await xt({...l});}catch{return}ee.current=R,Ee.current=true,R.onEnded(()=>xe()),ce({phase:"live"}),y(false);},[l,xe]),at=Rn.useCallback(()=>{let R=ke.current;return ke.current=null,R},[]);Rn.useEffect(()=>()=>{ee.current?.stop(),ee.current=null;},[]);let qe=or(),it=rr(i),Me=sr(a?"":e,t??mr);tr(s??Za(Me.brand));let wt=p??Me.shakeToOpen;cr(wt,se,h);let yt=Rn.useMemo(()=>({client:U,user:n,isOpen:h,isSubmitting:K,error:W,open:se,close:le,openCapture:se,closeCapture:le,submit:g,isNativeShell:qe,capture:l,initialCapture:H,initialCaptureError:ae,isOpening:B,startVideoSession:_e,stopVideoSession:Ve,cancelVideoSession:Fe,recording:O,consumePendingVideo:Se,canRecordScreen:Re,consumeRecordStartError:ge,startScreenCaptureSession:ze,grabScreenCaptureFrame:Ue,cancelScreenCaptureSession:xe,screenCapture:ue,consumePendingScreenshot:at,isolateEvents:x,keyboardInset:L}),[U,n,h,K,W,se,le,g,qe,l,H,ae,_e,Ve,Fe,O,Se,Re,ge,ze,Ue,xe,ue,at,B,x,L]),he=Ga({explicit:a,remote:Me.trigger,remoteLoading:Me.loading,floatingButton:o});return jsxRuntime.jsxs(At.Provider,{value:yt,children:[T,jsxRuntime.jsxs(ht,{onReset:k,onError:R=>U.reportClientError({...R,context:{open:h,opening:B,screenCapturePhase:ue?.phase,recordingPhase:O?.phase,initialCaptureMethod:H?.method,initialCapturePixelRatio:H?.pixelRatio,initialCaptureViewport:H?.viewport,hadInitialCaptureError:ae!=null}}),children:[he?.kind==="floating"?jsxRuntime.jsx(Yn,{config:er(he),portalTarget:c,hidden:it||M||B||O!=null||ue!=null,onPointerDown:we,onClick:R=>se(R),isolateEvents:x,keyboardInset:L}):null,he?.kind==="notch"?jsxRuntime.jsx(Jn,{config:Qn(he),portalTarget:c,hidden:it||M||B||O!=null||ue!=null,onPointerDown:we,onClick:R=>se(R),isolateEvents:x}):null,he?.kind==="inline"?jsxRuntime.jsx(Gn,{mount:he.mount,label:he.label??"Feedback",icon:he.icon,onPointerDown:we,onClick:R=>se(R),isolateEvents:x}):null,ue?jsxRuntime.jsx(_n,{state:ue,portalTarget:c,onCapture:Ue,onCancel:xe}):null,O?jsxRuntime.jsx(Hn,{state:O,portalTarget:c,onStop:Ve,onCancel:Fe}):null,jsxRuntime.jsx(Vt,{})]},f),jsxRuntime.jsx(Ya,{})]})}function Ya(){let[e,t]=Rn.useState(false);return Rn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Ga(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Za(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Xa({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=Je(),s=["lumen-btn",e==="default"?"lumen-btn-primary":null,e==="ghost"?"lumen-btn-ghost":null,e==="outline"?"lumen-btn-outline":null,t?"lumen-btn-floating":null,n].filter(Boolean).join(" ");return jsxRuntime.jsx("button",{type:"button",className:s,"data-lumen-trigger":"",onClick:c=>{o?.(c),c.defaultPrevented||i(c.nativeEvent);},...a,children:r})}
|
|
5
5
|
exports.CaptureModal=Vt;exports.FeedbackButton=Xa;exports.LUMEN_KEYBOARD_CSS_VAR=Lt;exports.LUMEN_KEYBOARD_EVENT=Xe;exports.LUMEN_SHAKE_MESSAGE=mt;exports.LumenProvider=ja;exports.createNativeCaptureProvider=co;exports.isLumenEventTarget=ao;exports.isolateLumenEvents=io;exports.readLumenKeyboardInset=Tt;exports.setLumenKeyboardInset=yo;exports.useKeyboardInset=et;exports.useLumen=Je;//# sourceMappingURL=index.cjs.map
|
|
6
6
|
//# sourceMappingURL=index.cjs.map
|