@lumen-stack/react 0.12.2 → 0.12.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
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 N=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},zt=class extends N{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},$t=class extends N{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},at=class extends N{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},br="https://shakebugs.vercel.app",vr="/api/v1/sdk/submit",wr="/api/v1/sdk/error",yr="0.13.2",Er=5,Cr=new Set([502,503,504]),en=class{apiKey;apiUrl;user;amplitude;#e=new Set;#t=0;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new N("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??br).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${vr}`,r=this.#n(e),o=null;for(let a=0;a<3;a++){a>0&&await Sr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof zt||i instanceof $t||i instanceof N&&typeof i.status=="number"&&!Cr.has(i.status))throw i}}throw o instanceof Error?o:new at("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Er)return;let t=(e.stack??"").split(`
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:yr,context:e.context};fetch(`${this.apiUrl}${wr}`,{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,Rr(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",u=>{u.lengthComputable&&u.total>0&&i(Math.min(1,u.loaded/u.total));});let l=()=>{a.abort(),o(new at("Submit aborted."));};if(s){if(s.aborted){o(new at("Submit aborted."));return}s.addEventListener("abort",l,{once:true});}a.addEventListener("load",()=>{if(s&&s.removeEventListener("abort",l),a.status===403){o(new zt);return}if(a.status===429){let u=Number(a.getResponseHeader("Retry-After"))||60;o(new $t(u));return}if(a.status<200||a.status>=300){o(new N(kr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let u=JSON.parse(a.responseText);r(u);}catch{o(new N("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{s&&s.removeEventListener("abort",l),o(new at("Network error during submit."));}),a.send(t);})}};function Rr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Sr(e){return new Promise(t=>setTimeout(t,e))}function kr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var tn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function nn(e=tn){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 xr=2,Mr=1.5,Lr=820,Tr=12,We=8*1024*1024;async function lt(e={}){xt();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return Br(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 N("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return jt(e);if(t==="dom")return Wt(e);if(t==="custom")throw new N("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await Wt(e)}catch(n){if(ln()){let r=await jt(e);return r.warnings=je(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function qe(e,t=[]){xt();let n=ut();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:je(t)}}var Kt=Promise.resolve();function Wt(e){let t=Kt.then(()=>qt(e),()=>qt(e));return Kt=t.catch(()=>{}),t}async function qt(e){let t=await Or(),n=e.target??document.documentElement,r=ut(),o=_r(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),s=window.scrollY+(a?.offsetTop??0),l=Vr(e,r.width,r.height),u=Hr(n);!e.provider&&Dr()&&u.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=Nr(n);await sn(e.awaitAnimationsMs??zr),await Ur();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:l,ignoreElements:w=>w instanceof HTMLElement&&(w.dataset.lumenCaptureIgnore==="true"||!!w.closest("[data-lumen-capture-ignore='true']")),onclone:(w,g)=>{Ir(g,d),Pr(w);}}),b={blob:await an(p,u),method:"web-dom",platform:"web",viewport:r,pixelRatio:l,warnings:je(u)};return b.warnings.length>0&&e.onWarning?.(b.warnings),b}var rn=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function Pr(e){for(let t of Array.from(e.querySelectorAll(rn))){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 Ar="[data-lumen-root], [data-lumen-capture-ignore='true']";function on(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(Ar))}function Nr(e){return on(e).map(t=>{if(t.matches(rn))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 Ir(e,t){let n=on(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 Dr(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function Or(){let{default:e}=await import('html2canvas-pro');return e}async function kt(e={}){if(xt(),!ln())throw new N("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 $r(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,l=s?nn():()=>{};try{s&&await Kr(r,3,400);let u=document.createElement("canvas");u.width=r.videoWidth,u.height=r.videoHeight;let d=u.getContext("2d");if(!d)throw new N("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");d.drawImage(r,0,0,u.width,u.height);let p=ut(),b=["Browser screen capture uses the window or tab selected by the user."],w={blob:await an(u,b),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?u.width/p.width:void 0,warnings:je(b)};return e.onWarning?.(w.warnings),w}finally{l();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function jt(e){let t=await kt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function Br(e,t){let n=ut(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:je(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function Hr(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 an(e,t){let n=await Yt(e,"image/png",.92);if(n.size<=We)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>We&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(We/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 l of [.86,.74,.62,.5])if(n=await Yt(r,"image/jpeg",l),n.size<=We)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>We&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function Yt(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new N("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function ut(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function _r(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function Vr(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??xr;Fr()&&(o=Math.min(o,Mr));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(Tr*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function Fr(){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<=Lr}function Ur(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var zr=400;async function sn(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 ln(){return !!navigator.mediaDevices?.getDisplayMedia}async function $r(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new N("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 N("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function Kr(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 xt(){if(typeof window>"u"||typeof document>"u")throw new N("Screenshot capture can only run in the browser.","INVALID_ENV")}function je(e){return Array.from(new Set(e.filter(Boolean)))}var un=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,Wr=[/-----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 qr(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 Et(e){let t=e;for(let n of Wr)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:un.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=>qr(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 cn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])un.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Et(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Et(e)}}function dn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return cn(e)}}var Gt=200,Zt=4096,mn=[],it=[],Xt=false,Ct=null;function pn(e={}){Xt||typeof window>"u"||(Xt=true,Ct=e.ignoreUrlPrefix??null,Zr(),Xr(),Jr());}function jr(){return {consoleLog:mn.slice(),networkLog:it.slice()}}function st(e,t){e.push(t),e.length>Gt&&e.splice(0,e.length-Gt);}function Yr(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,Gr));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>Zt?n.slice(0,Zt)+"\u2026[truncated]":n}function Gr(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function Zr(){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{st(mn,{level:n,ts:Date.now(),message:Et(Yr(o))});}catch{}r(...o);});}}function fn(e){return Ct?e.startsWith(Ct):false}function Xr(){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(fn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return st(it,{type:"fetch",method:o,url:Rt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw st(it,{type:"fetch",method:o,url:Rt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Jr(){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&&!fn(o.url)){o.t=performance.now();let a=()=>{try{st(it,{type:"xhr",method:o.method,url:Rt(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 Qr(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Rt(e){return Qr(cn(e))}function gn(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:Jt(e),consoleLog:[],networkLog:[]};let t=jr();return {url:dn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:Jt(e),device:eo(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function eo(){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?dn(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 Jt(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var to="[data-lumen-root]",no="[data-lumen-root], [data-lumen-trigger], [data-lumen-capture-ignore='true']";function ro(e){let t=typeof e.composedPath=="function"?e.composedPath():[];for(let n of t)if(St(n))return true;return St(e.target)}var Qt=["pointerdown","mousedown","touchstart","click"];function oo(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of Qt)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of Qt)e.removeEventListener(n,t);}}function St(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(no)?true:!!e.closest(to):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?St(e.host):false:false}var ct="lumen:shake",ao=8e3,io=50,so=400;function lo(e={}){return async function(){if(typeof window>"u")throw new N("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=co(),n=e.send??uo,r=e.timeoutMs??ao,o=e.captureSettleMs??io,a=e.awaitAnimationsMs??so,i=ho(),s=nn(e.concealSelector===void 0?tn:e.concealSelector);try{await po(o,a);let l=await new Promise((p,b)=>{let w=window.setTimeout(()=>{t.pending.delete(i),b(new N("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:g=>{window.clearTimeout(w),p(g);},reject:g=>{window.clearTimeout(w),b(g);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(w),b(new N("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(l.error||!l.dataUrl)throw new N(l.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let u=bo(l.dataUrl),d=e.platform??go();return {blob:u,method:d==="android"?"android-native":"ios-native",platform:d,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:l.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{s();}}}function uo(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new N("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function co(){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=mo(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 mo(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 po(e,t){await sn(t),await fo(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function fo(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function go(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function ho(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function bo(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new N("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 Ye="lumen:keyboardchange",Mt="--lumen-keyboard-inset";function vo(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(Mt,`${t}px`),window.dispatchEvent(new Event(Ye));}function Lt(){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(Mt).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function hn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new N("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new N("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(w=>MediaRecorder.isTypeSupported(w))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((w,g)=>{u=w,d=g;});p.catch(()=>{}),r.addEventListener("dataavailable",w=>{w.data&&w.data.size>0&&o.push(w.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let x of t.getTracks())x.stop();if(l)return;if(l=true,s){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let w=performance.now()-a,g=r.mimeType||n||"audio/webm",S=new Blob(o,{type:g});u({blob:S,durationMs:w,mimeType:g});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function b(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){s=true,b(),i!==null&&window.clearTimeout(i),i=null;for(let w of t.getTracks())w.stop();},stop(){return b(),p}}}async function bn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new N("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new N("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(g=>MediaRecorder.isTypeSupported(g))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,l=false,u,d,p=new Promise((g,S)=>{u=g,d=S;});p.catch(()=>{});function b(){i!==null&&(window.clearTimeout(i),i=null);for(let g of t.getTracks())g.stop();}r.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&o.push(g.data);}),r.addEventListener("stop",()=>{if(s)return;if(s=true,b(),l){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let g=r.mimeType||n||"video/webm";u({blob:new Blob(o,{type:g}),durationMs:performance.now()-a,mimeType:g});});function w(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(w,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",w),{stream:t,result:p,stop:w,cancel(){l=true,r.state!=="inactive"?r.stop():s||(s=true,b(),d(new N("Recording cancelled.","RECORDER_STOPPED")));}}}var Tt=Rn.createContext(null);function Ge(){let e=Rn.useContext(Tt);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var vn=100;function wn(){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 Ze={open:false,inset:0};function Ro(e){let t=e.override??e.injected;if(t!=null){let r=t>1&&e.editable;return r?{open:r,inset:Math.round(t)}:Ze}if(e.vvHeight==null||!e.coarse||!e.editable)return Ze;let n=e.vvBaseline-e.vvHeight;return n>vn?{open:true,inset:Math.round(n)}:Ze}function Xe(e,t){let[n,r]=Rn.useState(Ze),o=Rn.useRef(0),a=Rn.useRef(t);return a.current=t,Rn.useEffect(()=>{if(!e){r(Ze);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,s=()=>{let p=wn(),b=a.current,w=Lt(),g=window.visualViewport??null;g&&b==null&&w==null&&!p&&(o.current=g.height),r(Ro({editable:p,override:b,injected:w,vvBaseline:o.current,vvHeight:g?g.height:null,coarse:i}));},l=0,u=()=>{l||(l=window.requestAnimationFrame(()=>{l=0,s();}));},d=window.visualViewport;return d&&(o.current=d.height),u(),d?.addEventListener("resize",u),d?.addEventListener("scroll",u),document.addEventListener("focusin",u),document.addEventListener("focusout",u),window.addEventListener(Ye,u),()=>{l&&window.cancelAnimationFrame(l),d?.removeEventListener("resize",u),d?.removeEventListener("scroll",u),document.removeEventListener("focusin",u),document.removeEventListener("focusout",u),window.removeEventListener(Ye,u);}},[e]),n}var At='-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},i){let s=Rn.useRef(null),l=Rn.useRef(null),u=Rn.useRef(null),[d,p]=Rn.useState(null),[b,w]=Rn.useState([]),g=Rn.useRef(null),S=Rn.useRef(false),x=Rn.useRef(0),M=Rn.useRef(false),[L,h]=Rn.useState([]),R=Rn.useRef(0),I=Rn.useRef([]),A=Rn.useRef(null),_=Rn.useCallback((f,y)=>{h(k=>k.map(T=>T.id===f?{...T,text:y}:T));},[]),D=Rn.useCallback(f=>{h(k=>k.filter(T=>T.id!==f));let y=I.current.lastIndexOf("comment");y>=0&&I.current.splice(y,1);},[]);Rn.useEffect(()=>{let f=A.current;if(f==null)return;A.current=null,u.current?.querySelector(`[data-bubble-id="${f}"] .lumen-bubble-text`)?.focus();},[L]),Rn.useEffect(()=>{let f=false,y=null;return (async()=>{try{let k=await createImageBitmap(t);if(f){k.close?.();return}y=k,p(k);}catch{}})(),()=>{f=true,y?.close?.();}},[t]),Rn.useEffect(()=>{if(!d)return;let f=s.current,y=l.current;if(!f||!y)return;f.width=d.width,f.height=d.height,y.width=d.width,y.height=d.height;let k=f.getContext("2d");k&&(k.imageSmoothingEnabled=false,k.drawImage(d,0,0));},[d]),Rn.useEffect(()=>{let f=l.current;f&&dt(f,b,g.current);},[b]),Rn.useImperativeHandle(i,()=>({hasAnnotations:()=>b.length>0||L.some(f=>f.text.trim().length>0),reset:()=>{w([]),h([]),I.current=[];},undo:()=>{(I.current.pop()??"anno")==="comment"?h(y=>y.length===0?y:y.slice(0,-1)):w(y=>y.length===0?y:y.slice(0,-1));},async flatten(){let f=g.current,y=f?[...b,f]:b,k=L.filter(U=>U.text.trim().length>0);if(y.length===0&&k.length===0||!d)return t;let T=document.createElement("canvas");T.width=d.width,T.height=d.height;let F=T.getContext("2d");if(!F)return t;F.imageSmoothingEnabled=false,F.drawImage(d,0,0);for(let U of y)Nt(F,U);let K=s.current?.clientWidth||d.width,j=d.width/Math.max(K,1);for(let U of k)Lo(F,U,d.width,d.height,j);return await new Promise(U=>{T.toBlob(oe=>{U(oe??t);},"image/jpeg",.85);})}}),[b,L,d,t]);function J(f){let y=l.current;if(!y)return {x:0,y:0};let k=y.getBoundingClientRect(),T=y.width/Math.max(k.width,1),F=y.height/Math.max(k.height,1);return {x:(f.clientX-k.left)*T,y:(f.clientY-k.top)*F}}function H(){M.current||(M.current=true,requestAnimationFrame(()=>{M.current=false;let f=l.current;f&&dt(f,b,g.current);}));}function Ce(f){if(f.button!==void 0&&f.button!==0)return;if(n==="comment"){let k=l.current;if(!k)return;let T=k.getBoundingClientRect(),F=Cn((f.clientX-T.left)/Math.max(T.width,1),.72),K=Cn((f.clientY-T.top)/Math.max(T.height,1),.8),j=++R.current;h(U=>[...U,{id:j,x:F,y:K,text:"",color:r}]),I.current.push("comment"),A.current=j;return}try{f.currentTarget.setPointerCapture(f.pointerId);}catch{}S.current=true,a?.(true);let y=J(f);n==="arrow"?g.current={kind:"arrow",from:y,to:y,color:r,width:o}:n==="rect"?g.current={kind:"rect",from:y,to:y,color:r,width:o}:g.current={kind:"freehand",points:[y],color:r,width:o},x.current=performance.now(),H();}function be(f){if(!S.current||!g.current)return;let y=J(f),k=g.current;if(k.kind==="arrow"||k.kind==="rect")k.to=y;else {let T=k.points[k.points.length-1],F=T?(T.x-y.x)**2+(T.y-y.y)**2:1/0,K=performance.now(),j=K-x.current;(F>16||j>16)&&(k.points.push(y),x.current=K);}H();}function V(){if(!S.current)return;S.current=false,a?.(false);let f=g.current;if(g.current=null,!!f){if(f.kind==="arrow"||f.kind==="rect"){let y=f.to.x-f.from.x,k=f.to.y-f.from.y;if(y*y+k*k<16){let T=l.current;T&&dt(T,b,null);return}}else if(f.points.length<2){let y=l.current;y&&dt(y,b,null);return}w(y=>[...y,f].slice(-50)),I.current.push("anno");}}return jsxRuntime.jsxs("div",{ref:u,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:s}),jsxRuntime.jsx("canvas",{ref:l,className:"lumen-annotate-overlay",onPointerDown:Ce,onPointerMove:be,onPointerUp:V,onPointerCancel:V}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:L.map(f=>jsxRuntime.jsx(xo,{comment:f,onChange:_,onRemove:D},f.id))})]})});function xo({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 dt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)Nt(r,o);n&&Nt(r,n);}}function Nt(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")Mo(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 Mo(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,l=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,s,l);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function Lo(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,s=14*o,l=10*o,u=12*o,d=s*1.35,p=l*1.7,b=t.x*n,w=t.y*r,g=Math.min(n*.6,n-b-8*o);e.save(),e.font=`500 ${s}px ${At}`,e.textBaseline="top";let S=To(e,a,g-i*2),x=S.reduce((A,_)=>Math.max(A,e.measureText(_).width),0),M=Math.min(g,Math.max(x,56*o)+i*2),L=i*2+p+S.length*d;Po(e,b,w,M,L,u),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let h=b+18*o,R=w+L;e.beginPath(),e.moveTo(h,R-o),e.lineTo(h+13*o,R-o),e.lineTo(h+4*o,R+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${l}px ${At}`,e.fillText("COMMENT",b+i,w+i),e.fillStyle="#111318",e.font=`500 ${s}px ${At}`;let I=w+i+p;for(let A of S)e.fillText(A,b+i,I),I+=d;e.restore();}function To(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 Po(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 Qe({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 Ao(e){return jsxRuntime.jsxs(Qe,{...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 No(e){return jsxRuntime.jsxs(Qe,{...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 Io(e){return jsxRuntime.jsxs(Qe,{...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 mt(e){return jsxRuntime.jsxs(Qe,{...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(Qe,{...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 It={shot:Ao,video:No,upload:Io};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 Do(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 Oo=4e3;async function Dt(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((l,u)=>{if(n.readyState>=2)return l();n.addEventListener("loadeddata",()=>l(),{once:true}),n.addEventListener("error",()=>u(new Error("video decode failed")),{once:true});}),await Do(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}),Oo);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Ot(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 Bt(){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 Ht=60,Bo=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}],Pn=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],An=[{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 _t(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:s,consumePendingVideo:l,canRecordScreen:u,consumeRecordStartError:d,startScreenCaptureSession:p,consumePendingScreenshot:b,isolateEvents:w,keyboardInset:g}=Ge(),[S,x]=Rn.useState(1),[M,L]=Rn.useState(null),[h,R]=Rn.useState({kind:"idle"}),[I,A]=Rn.useState(false),[_,D]=Rn.useState(0),[J,H]=Rn.useState(null),[Ce,be]=Rn.useState(false),[V,f]=Rn.useState("arrow"),[y,k]=Rn.useState(Ln[0].value),[T,F]=Rn.useState(Tn[1].value),[K,j]=Rn.useState(""),[U,oe]=Rn.useState("bug"),[Re,nt]=Rn.useState(r?.email??""),[W,Ie]=Rn.useState(null),[Q,Y]=Rn.useState(null),[de,Se]=Rn.useState(0),[ae,ee]=Rn.useState(null),[me,G]=Rn.useState(null),[te,Fe]=Rn.useState(false),pe=Rn.useRef(null),ke=Rn.useRef(null),Ue=Rn.useRef(null),ze=Rn.useRef(null),ve=Xe(t,g),ie=Rn.useRef(false),De=Rn.useRef(false);Rn.useEffect(()=>{t||(De.current=false);},[t]),Rn.useEffect(()=>{if(!t)return;if(De.current){ie.current=false;return}De.current=true,ie.current=false,x(1),L(null),j(""),Y(null),Se(0),ee(null),A(false),D(0),H(null),be(false),G(null);let c=b();if(c){L("shot"),Oe(c),R({kind:"ready",capture:c});return}let v=l();if(v)L("video"),ee({blob:v.blob,durationMs:v.durationMs}),v.blob.size>Bo&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),v.poster?R({kind:"ready",capture:qe(v.poster,["Screen recording; preview is the first frame."])}):(R({kind:"capturing"}),(async()=>{let P=null;if(v.deriveBlobPoster)try{P=(await Dt(v.blob)).poster;}catch{P=null;}P=P??await Bt(),!ie.current&&R(P?{kind:"ready",capture:qe(P,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let P=d();P?(L("video"),G(P),R({kind:"idle"})):a?(L("shot"),R({kind:"ready",capture:a})):o?.mode==="manual"?R({kind:"manual"}):o?.provider&&!i?(L("shot"),fe(o.mode??"auto")):R({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ie.current=true;}},[t,o,a,i]),Rn.useEffect(()=>{if(!t)return;ze.current=document.activeElement??null;let c=document.documentElement,v=c.style.overflow,P=c.style.paddingRight,X=window.innerWidth-c.clientWidth;c.style.overflow="hidden",X>0&&(c.style.paddingRight=`${X}px`);let ne=false,Me=()=>{if(!ne){ne=true,c.style.overflow=v,c.style.paddingRight=P;try{ze.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Me),()=>{window.removeEventListener("pagehide",Me),Me();}},[t]),Rn.useEffect(()=>{if(!t)return;function c(v){if(v.key==="Escape"){v.preventDefault(),n();return}if(v.key!=="Tab")return;let P=ke.current;if(!P)return;let X=qo(P);if(X.length===0)return;let ne=X[0],Me=X[X.length-1],yt=document.activeElement;v.shiftKey&&(yt===ne||!P.contains(yt))?(v.preventDefault(),Me.focus()):!v.shiftKey&&yt===Me&&(v.preventDefault(),ne.focus());}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,n]),Rn.useEffect(()=>{if(!t||!w)return;let c=Ue.current;if(!c)return;let v=P=>{P.target===c&&P.stopPropagation();};return c.addEventListener("pointerdown",v),c.addEventListener("click",v),c.addEventListener("touchstart",v,{passive:true}),()=>{c.removeEventListener("pointerdown",v),c.removeEventListener("click",v),c.removeEventListener("touchstart",v);}},[t,w]),Rn.useEffect(()=>{if(!t||!ve.open)return;let c=ke.current,v=document.activeElement;if(c&&v&&c.contains(v))try{v.scrollIntoView({block:"center"});}catch{}},[t,ve.open,ve.inset]),Rn.useEffect(()=>{if(!t||h.kind!=="manual")return;function c(v){let ne=Array.from(v.clipboardData?.items??[]).find(Me=>Me.type.startsWith("image/"))?.getAsFile();ne&&(v.preventDefault(),Z(ne));}return window.addEventListener("paste",c),()=>window.removeEventListener("paste",c)},[t,h.kind]),Rn.useEffect(()=>{if(!W)return;let c=Date.now(),v=window.setInterval(()=>{let P=Math.floor((Date.now()-c)/1e3);Se(P),P>=Ht&&ye();},250);return ()=>window.clearInterval(v)},[W]);let xe=Rn.useRef(null);if(xe.current=W,Rn.useEffect(()=>{t||xe.current&&(xe.current.cancel(),xe.current=null,Ie(null),Se(0));},[t]),Rn.useEffect(()=>()=>{xe.current?.cancel();},[]),!t)return null;async function fe(c){ie.current=false,R({kind:"capturing"});try{let v=await lt({...o,mode:c,target:o?.target??document.documentElement});return ie.current?!1:(Oe(v),R({kind:"ready",capture:v}),!0)}catch(v){return ie.current||R({kind:"manual",error:v instanceof Error?v.message:"Automatic screenshot capture was unavailable."}),false}}async function ge(c){L(c),G(null),H(null),c!=="video"&&Be(),c==="shot"?await fe(o?.mode??"auto"):c==="video"?(ee(null),R({kind:"idle"})):R({kind:"manual"});}async function Z(c){if(c.type.startsWith("image/")){Be();let v=qe(c,["Manual image upload used."]);R({kind:"ready",capture:v});return}if(c.type.startsWith("video/")){R({kind:"capturing"});try{let{poster:v,durationMs:P}=await Dt(c),X=v??await Bt();if(!X){R({kind:"manual",error:"Could not read that video."});return}let ne=qe(X,["Uploaded video; preview is the first frame."]);ee({blob:c,durationMs:P}),R({kind:"ready",capture:ne});}catch{R({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function Oe(c){c.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function we(){try{let c=await hn(Ht);Ie(c);}catch(c){sonner.toast.error(c instanceof Error?c.message:"Microphone unavailable");}}async function ye(){if(W)try{let c=await W.stop();Y({blob:c.blob,durationMs:c.durationMs});}catch(c){sonner.toast.error(c instanceof Error?c.message:"Could not stop recording");}finally{Ie(null);}}function $e(){W?.cancel(),Ie(null),Y(null),Se(0);}function Ke(c){let v=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!W&&!Q?jsxRuntime.jsxs("button",{type:"button",onClick:we,className:c==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(xn,{}),"Record voice note"]}):null,W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(Uo,{stream:W.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[de,"s / ",Ht,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:ye,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:$e,className:"lumen-btn-ghost",children:"Cancel"})]}):null,Q&&!W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($o,{blob:Q.blob,durationMs:Q.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Y(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return c==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[v,!W&&!Q?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 rt(){G(null);try{await s();}catch(c){sonner.toast.error(c instanceof Error?c.message:"Screen capture unavailable");}}function Be(){ee(null);}let ot=h.kind==="ready";async function He(){if(W&&await ye(),S===1){if(h.kind==="ready"){let c=await pe.current?.flatten();H(c??h.capture.blob),be(c!=null&&c!==h.capture.blob);}x(2);}else S===2?x(3):await vt();}function bt(){S>1&&x(c=>c-1);}async function vt(){if(h.kind!=="ready")return;let c=K.trim(),{capture:v}=h;A(true),D(0);try{let P=J??v.blob,X=await e.submit({rawText:c.length>0?c:void 0,category:U,submitterEmail:Re.trim()||void 0,screenshot:P,audio:Q?.blob,audioDurationMs:Q?.durationMs,video:ae?.blob,videoDurationMs:ae?.durationMs,context:gn(v)},{onUploadProgress:ne=>D(Math.min(.95,ne))});D(1),sonner.toast.success("Feedback sent \u2014 thank you."),X.id,n();}catch(P){sonner.toast.error(P instanceof Error?P.message:"Could not submit feedback"),A(false);}}function he(c){c.target===c.currentTarget&&!I&&n();}let C=Math.round(_*100),O=M==="video",z=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,wt=M==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&z,gr=S===1&&!ot||I,hr=S<3?"Next":I?C<95?`Uploading ${C}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:Ue,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:ve.inset?{"--lumen-keyboard-inset":`${ve.inset}px`}:void 0,onMouseDown:he,children:jsxRuntime.jsxs("div",{ref:ke,className:"lumen-modal","data-lumen-drawing":te?"true":void 0,children:[jsxRuntime.jsx(Fo,{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(Ho,{step:S}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[S===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:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(c.primary?" lumen-method-primary":""),onClick:()=>ge(c.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(v,{})}),c.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:c.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:c.hint})]})]},c.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:An.map(c=>{let v=It[c.value];return jsxRuntime.jsxs("button",{type:"button","aria-pressed":M===c.value,onClick:()=>ge(c.value),disabled:h.kind==="capturing",children:[jsxRuntime.jsx(v,{}),c.label]},c.value)})}),M==="video"&&h.kind==="idle"?jsxRuntime.jsx(_o,{canRecord:u,onRecord:rt,onUpload:()=>ge("upload"),error:me}):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:c=>{let v=c.currentTarget.files?.[0];v&&Z(v),c.currentTarget.value="";}})]})]}):null,h.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[O?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(pt,{label:"Arrow",active:V==="arrow",onClick:()=>f("arrow")}),jsxRuntime.jsx(pt,{label:"Box",active:V==="rect",onClick:()=>f("rect")}),jsxRuntime.jsx(pt,{label:"Draw",active:V==="freehand",onClick:()=>f("freehand")}),jsxRuntime.jsx(pt,{label:"Comment",active:V==="comment",onClick:()=>f("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:Ln.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:c.value},"aria-label":c.label,"aria-pressed":y===c.value,onClick:()=>k(c.value)},c.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:Tn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":c.label,"aria-pressed":T===c.value,onClick:()=>F(c.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:c.dot,height:c.dot}})},c.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.undo(),children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>pe.current?.reset(),children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Sn,{ref:pe,screenshot:h.capture.blob,tool:V,color:y,strokeWidth:T,onDrawingChange:Fe})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>M&&ge(M),children:O?"\u21BB Re-record":"\u21BB Recapture"}),wt?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(mt,{})," Capture exact screen"]}):null,O?ae?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ae.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`})]}),Ke("capture")]}):null]})}):null,S===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:K,onChange:c=>j(c.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),Ke("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:Pn.map(c=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":U===c.value,onClick:()=>oe(c.value),children:c.label},c.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:Re,onChange:c=>nt(c.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,S===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),Ce?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(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:Pn.find(c=>c.value===U)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(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:[K.trim()?K.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>x(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:[Q?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(Q.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>Y(null),children:"\xD7"})]}):null,ae?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ae.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Be,children:"\xD7"})]}):null,Re.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",Re.trim()]}):null,!Q&&!W?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{x(2),we();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[I?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":C,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${C}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:S===1?n:bt,className:"lumen-btn-ghost",disabled:I,children:S===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:He,className:"lumen-btn-primary",disabled:gr,children:hr})]})]})]})})}function Nn(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function Ho({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 _o({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:Vo()?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 Vo(){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 pt({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function Fo({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 l=Math.max(0,s.clientY-t.current);r.current.style.transform=`translateY(${l}px)`;}function i(s){if(t.current==null||!r.current)return;let l=Math.max(0,s.clientY-t.current),u=Math.max(1,performance.now()-n.current),d=l/u;r.current.style.transform="",r.current.style.transition="",t.current=null,(l>80||d>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function Uo({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 l=new s,u=l.createMediaStreamSource(e),d=l.createAnalyser();d.fftSize=1024,d.smoothingTimeConstant=.6,u.connect(d);let p=new Uint8Array(d.fftSize),b=18,w=3,g=3,S=Math.max(2,(o-w*(b-1))/b),x=Math.min(S/2,3),M=new Array(b).fill(0),L=0,h=false;function R(){if(h)return;d.getByteTimeDomainData(p);let I=Math.floor(p.length/b);i.clearRect(0,0,o,a),i.fillStyle=Ko("--lumen-danger")||"rgb(239,68,68)";for(let A=0;A<b;A++){let _=0;for(let V=0;V<I;V++){let f=Math.abs((p[A*I+V]??128)-128);f>_&&(_=f);}let D=Math.min(1,_/128*1.8),J=M[A]??0;M[A]=D>J?D:J+(D-J)*.35;let H=Math.max(g,M[A]*a),Ce=A*(S+w),be=(a-H)/2;zo(i,Ce,be,S,H,x),i.fill();}L=requestAnimationFrame(R);}return L=requestAnimationFrame(R),()=>{h=true,cancelAnimationFrame(L);try{u.disconnect();}catch{}l.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function zo(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 $o({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 Ko(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var Wo='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function qo(e){return Array.from(e.querySelectorAll(Wo)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var ft=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(Yo,{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 Yo({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 l=window.setInterval(s,250);return ()=>window.clearInterval(l)},[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(mt,{})}),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 Vt(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 l(d){o||(o=true,n.onResult(d));}function u(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():l(p);}).catch(p=>{r||Vn(p)?s():u(Fn(p));});}).catch(d=>{r||Vn(d)?s():u(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 l of s){if(o.has(l))continue;o.add(l);let u=window.getComputedStyle(l);if(u.position!=="fixed"&&u.position!=="sticky")continue;let d=l.getBoundingClientRect();d.bottom<t-8||d.bottom>t+8||d.width<e*.6||d.height>a&&(a=d.height);}}return a}function Ft(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 l=s.getBoundingClientRect();if(l.height===0||l.width===0)continue;let u=0;switch(t){case "bottom":if(l.bottom<r-8)break;u=Math.max(0,r-l.top);break;case "top":if(l.top>8)break;u=Math.max(0,l.bottom);break;case "left":if(l.left>8)break;u=Math.max(0,l.right);break;case "right":if(l.right<n-8)break;u=Math.max(0,n-l.left);break}u>o&&(o=u);}}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=na(e.avoid),a=e.placement,i=e.offset.x,s=e.offset.y;return Rn.useEffect(()=>{if(typeof window>"u")return;let l=0,u=false,d=()=>{if(l=0,u)return;let S=a[0]==="b"?"bottom":"top",x=a[1]==="r"?"right":"left",M=0,L=0;e.avoid==="auto"&&S==="bottom"?M=zn():Array.isArray(e.avoid)&&(M=Ft(e.avoid,S),L=Ft(e.avoid,x));let h={bottom:S==="bottom"?s+M:0,top:S==="top"?s+M:0,right:x==="right"?i+L:0,left:x==="left"?i+L:0},R=r.current;(h.bottom!==R.bottom||h.top!==R.top||h.right!==R.right||h.left!==R.left)&&(r.current=h,n(h));},p=()=>{l||(l=window.requestAnimationFrame(d));};p();let b=typeof ResizeObserver<"u"?new ResizeObserver(p):null;b?.observe(document.documentElement);let w=typeof MutationObserver<"u"?new MutationObserver(p):null;w?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let g=window.visualViewport;return g?.addEventListener("resize",p),g?.addEventListener("scroll",p),()=>{u=true,l&&window.cancelAnimationFrame(l),b?.disconnect(),w?.disconnect(),window.removeEventListener("resize",p),g?.removeEventListener("resize",p),g?.removeEventListener("scroll",p);}},[a,i,s,o]),t}function na(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var Kn=["mousedown","touchstart"];function Ve(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=u=>{r.current&&u.stopPropagation(),t.current?.(u);},s=u=>{r.current&&u.stopPropagation(),n.current(u);},l=u=>{r.current&&u.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",s);for(let u of Kn)a.addEventListener(u,l,u==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",s);for(let u of Kn)a.removeEventListener(u,l);};},[])}function Yn({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[s,l]=Rn.useState(null),u=Rn.useRef(null),d=$n(e),p=Xe(e.keyboard!=="off",i),b=Ve({onPointerDown:r,onClick:o,isolate:a}),w=Rn.useCallback(D=>{u.current=D,b(D);},[b]);Rn.useEffect(()=>{typeof document>"u"||l(t??document.body);},[t]);let g=e.placement,S=g[0]==="b"?"bottom":"top",x=g[1]==="r"?"right":"left",M=S==="bottom",L=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(sa(u,!n&&!h),!s)return null;let R=S==="bottom"?d.bottom:d.top,I=x==="right"?d.right:d.left,A=n||h,_={position:"fixed",[S]:e.safeArea?`calc(${R}px + env(safe-area-inset-${S}, 0px))`:`${R}px`,[x]:e.safeArea?`calc(${I}px + env(safe-area-inset-${x}, 0px))`:`${I}px`,zIndex:e.zIndex,transform:L?`translateY(-${L}px)`:void 0,opacity:A?0:1,pointerEvents:A?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:w,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:_,"aria-label":e.label,"aria-hidden":A?true:void 0,tabIndex:A?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),s)}function sa(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,l=document.elementsFromPoint(i,s),u=Wn(window.getComputedStyle(o).zIndex);for(let d of l){if(d===o||o.contains(d))continue;if(Wn(window.getComputedStyle(d).zIndex)>u){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),l=Ve({onPointerDown:r,onClick:o,isolate:a});return Rn.useEffect(()=>{if(typeof document>"u")return;let u=e instanceof HTMLElement?e:e.current??null;s(u);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:l,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),[l,u]=Rn.useState(false),d=Rn.useRef(null),p=Ve({onPointerDown:x=>{r?.(x),d.current={x:x.clientX,y:x.clientY},u(true);let M=x.currentTarget;try{M?.setPointerCapture?.(x.pointerId);}catch{}},onClick:o,isolate:a});if(Rn.useEffect(()=>{typeof document>"u"||s(t??document.body);},[t]),!i)return null;let b=`lumen-notch lumen-notch-${e.edge}${l?" lumen-notch-expanded":""}`;function w(x){let M=d.current;if(!M)return;let L=x.clientX-M.x,h=x.clientY-M.y;(e.edge==="top"&&h>16||e.edge==="bottom"&&h<-16||e.edge==="right"&&L<-16||e.edge==="left"&&L>16)&&(d.current=null,o(x.nativeEvent));}function g(){d.current=null,u(false);}function S(){d.current=null,u(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:b,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:w,onPointerUp:g,onPointerCancel:S,onMouseEnter:()=>u(true),onMouseLeave:()=>u(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 wa(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:wa(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Ca={"--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-${Ra(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(Ca)){let l=e[s];typeof l=="string"&&l.length>0&&a(i,l);}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 Ra(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var nr=Symbol.for("lumen.history.patched"),Ut="lumen:locationchange";function xa(){if(typeof window>"u")return;let e=window;if(e[nr])return;e[nr]=true;let t=()=>window.dispatchEvent(new Event(Ut)),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;xa();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Ut,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Ut,r),window.removeEventListener("popstate",r);}},[e]),t}var Ta=["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||"";Ta.some(a=>o.includes(a))&&t(true);},[]),e}var ir="lumen.config.v1.",Na=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=_a(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 l=>{if(!l.ok)throw new Error(`HTTP ${l.status}`);let u=await l.json(),d=lr(u.trigger);if(!d)throw new Error("Malformed config response");let p=Oa(u.trigger),b=ur(u.brand);Va(e,d,p,b),r({trigger:d,enabled:ar(d),shakeToOpen:p,brand:b,loading:false});}).catch(()=>{r(l=>l.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:l);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function ar(e){return e.kind!=="headless"}var Ia=["br","bl","tr","tl"],Da=["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:Ia.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:Da.find(o=>o===t.edge)??"top",label:n}:null}function Oa(e){return !e||typeof e!="object"?false:e.shake===true}var Ba=/^#[0-9a-fA-F]{6}$/,Ha=["auto","light","dark"];function ur(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&Ba.test(t.accent)?t.accent:null;if(!n)return null;let r=Ha.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 _a(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>Na)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 Va(e,t,n,r){try{window.localStorage.setItem(ir+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function Ua(e){if(e&&typeof e=="object")return e.type===ct;if(typeof e=="string")try{return JSON.parse(e).type===ct}catch{return false}return false}function za(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(s,l,u,d){if(!a)return a={x:s,y:l,z:u,t:d},false;if(d-a.t<o)return false;let p=Math.abs(s-a.x)+Math.abs(l-a.y)+Math.abs(u-a.z);return a={x:s,y:l,z:u,t:d},p<t?false:(i=i.filter(b=>d-b<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=>{Ua(d.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let s=za(),l=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();},u=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return u&&window.addEventListener("devicemotion",l),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),u&&window.removeEventListener("devicemotion",l);}},[e,t,n]);}var mr="https://shakebugs.vercel.app",ht=60;function pr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function Wa({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:s,portalTarget:l,capture:u,record:d,shakeToOpen:p,onOpenChange:b,beforeOpen:w,onTriggerActivate:g,isolateEvents:S=true,keyboardInset:x,suppressTrigger:M=false,children:L}){let[h,R]=Rn.useState(false),[I,A]=Rn.useState(false),[_,D]=Rn.useState(null),[J,H]=Rn.useState(null),[Ce]=Rn.useState(false),[be]=Rn.useState(null),V=Rn.useRef(false),f=Rn.useRef(false),y=Rn.useRef(null),k=Rn.useMemo(()=>new en({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Rn.useEffect(()=>{pn({ignoreUrlPrefix:(t??mr).replace(/\/$/,"")});},[t]);let T=Rn.useRef(b);T.current=b,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 F=Rn.useRef(null);Rn.useEffect(()=>{if(F.current===h)return;let C=F.current;F.current=h,C!==null&&T.current?.(h);},[h]);let K=Rn.useRef(w);K.current=w;let j=Rn.useRef(g);j.current=g;let U=Rn.useCallback(C=>{f.current=true,y.current=Promise.resolve().then(()=>K.current?.(C)).then(()=>j.current?.(C)).then(()=>{});},[]),oe=Rn.useCallback(C=>{V.current||h||G.current||we.current||(V.current=true,A(true),D(null),H(null),(async()=>{try{if(f.current?await y.current:(await K.current?.(C),await j.current?.(C)),u?.mode==="manual")D(null),H(null);else if(u?.provider)D(null),H(null);else {let O=await lt({...u,mode:u?.mode??"auto",target:u?.target??document.documentElement});D(O);}}catch(O){H(O instanceof Error?O:new Error(String(O)));}finally{f.current=false,y.current=null,V.current=false,A(false),R(true);}})());},[u,h]),Re=Rn.useCallback(()=>{R(false),D(null),H(null);},[]),nt=Rn.useCallback(k.submit.bind(k),[k]),[W,Ie]=Rn.useState(0),Q=Rn.useCallback(()=>{V.current=false,A(false),R(false),D(null),H(null),Ie(C=>C+1);},[]),[Y,de]=Rn.useState(null),[Se,ae]=Rn.useState(null),ee=Rn.useRef(null),me=Rn.useRef(null),G=Rn.useRef(false),te=Rn.useRef(null),Fe=Rn.useRef(null),pe=Rn.useRef(null),ke=Rn.useCallback((C,O=false)=>{if(ee.current=null,me.current=null,G.current=false,de(null),!C){te.current=null;return}Fe.current={blob:C.blob,durationMs:C.durationMs,poster:te.current,deriveBlobPoster:O},te.current=null,R(true);},[]);Rn.useEffect(()=>{if(!h)return;if(!d?.provider){ae(null);return}let C=d.isAvailable;if(!C){ae(true);return}let O=false;return Promise.resolve().then(()=>C()).then(z=>{O||ae(z);}).catch(()=>{O||ae(false);}),()=>{O=true;}},[h,d?.provider,d?.isAvailable]);let Ue=Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).canRecord,ze=Rn.useCallback(async()=>{if(G.current)return;if(pe.current=null,Vt({hasProvider:!!d?.provider,providerAvailable:Se,hasGetDisplayMedia:pr()}).usingProvider&&d?.provider){G.current=true,te.current=null,R(false),me.current=Un(d.provider,{maxDurationSeconds:ht},{onStarting:()=>de({phase:"starting"}),onActive:z=>{de({phase:"recording",stream:z.stream??null,startedAt:Date.now(),maxSeconds:ht}),z.stream&&Ot(z.stream).then(wt=>{te.current=wt;}).catch(()=>{});},onProcessing:()=>de({phase:"processing"}),onResult:z=>ke({blob:z.blob,durationMs:z.durationMs},true),onCancelled:()=>{me.current=null,G.current=false,te.current=null,de(null),D(null),H(null),R(true);},onError:z=>{me.current=null,G.current=false,te.current=null,de(null),pe.current=z.message||"Screen recording could not start.",R(true);}});return}if(ee.current)return;let O=await bn(ht);ee.current=O,G.current=true,te.current=null,de({phase:"recording",stream:O.stream,startedAt:Date.now(),maxSeconds:ht}),R(false),Ot(O.stream).then(z=>{te.current=z;}).catch(()=>{}),O.result.then(z=>ke(z)).catch(()=>ke(null));},[ke,d?.provider,Se]),ve=Rn.useCallback(()=>{me.current?me.current.stop():ee.current?.stop();},[]),ie=Rn.useCallback(()=>{if(me.current){me.current.cancel();return}let C=ee.current;ee.current=null,G.current=false,te.current=null,de(null),C?.cancel(),D(null),H(null),R(true);},[]),De=Rn.useCallback(()=>{let C=Fe.current;return Fe.current=null,C},[]),xe=Rn.useCallback(()=>{let C=pe.current;return pe.current=null,C},[]);Rn.useEffect(()=>{h||(pe.current=null);},[h]);let[fe,ge]=Rn.useState(null),Z=Rn.useRef(null),Oe=Rn.useRef(null),we=Rn.useRef(false),ye=Rn.useCallback(()=>{let C=Z.current;Z.current=null,we.current=false,C?.stop(),ge(null),R(true);},[]),$e=Rn.useCallback(()=>{let C=Z.current;C&&(ge({phase:"grabbing"}),(async()=>{try{let O=await C.grab();if(Z.current!==C)return;Oe.current=O,Z.current=null,we.current=!1,C.stop(),ge(null),R(!0);}catch{if(Z.current!==C)return;Z.current=null,we.current=false,C.stop(),ge(null),sonner.toast.error("Could not capture the screen. Please try again."),R(true);}})());},[]),Ke=Rn.useCallback(async()=>{if(we.current)return;let C;try{C=await kt({...u});}catch{return}Z.current=C,we.current=true,C.onEnded(()=>ye()),ge({phase:"live"}),R(false);},[u,ye]),rt=Rn.useCallback(()=>{let C=Oe.current;return Oe.current=null,C},[]);Rn.useEffect(()=>()=>{Z.current?.stop(),Z.current=null;},[]);let Be=or(),ot=rr(i),He=sr(a?"":e,t??mr);tr(s??Ya(He.brand));let bt=p??He.shakeToOpen;cr(bt,oe,h);let vt=Rn.useMemo(()=>({client:k,user:n,isOpen:h,isSubmitting:Ce,error:be,open:oe,close:Re,openCapture:oe,closeCapture:Re,submit:nt,isNativeShell:Be,capture:u,initialCapture:_,initialCaptureError:J,isOpening:I,startVideoSession:ze,stopVideoSession:ve,cancelVideoSession:ie,recording:Y,consumePendingVideo:De,canRecordScreen:Ue,consumeRecordStartError:xe,startScreenCaptureSession:Ke,grabScreenCaptureFrame:$e,cancelScreenCaptureSession:ye,screenCapture:fe,consumePendingScreenshot:rt,isolateEvents:S,keyboardInset:x}),[k,n,h,Ce,be,oe,Re,nt,Be,u,_,J,ze,ve,ie,Y,De,Ue,xe,Ke,$e,ye,fe,rt,I,S,x]),he=ja({explicit:a,remote:He.trigger,remoteLoading:He.loading,floatingButton:o});return jsxRuntime.jsxs(Tt.Provider,{value:vt,children:[L,jsxRuntime.jsxs(ft,{onReset:Q,onError:C=>k.reportClientError({...C,context:{open:h,opening:I,screenCapturePhase:fe?.phase,recordingPhase:Y?.phase,initialCaptureMethod:_?.method,initialCapturePixelRatio:_?.pixelRatio,initialCaptureViewport:_?.viewport,hadInitialCaptureError:J!=null}}),children:[he?.kind==="floating"?jsxRuntime.jsx(Yn,{config:er(he),portalTarget:l,hidden:ot||M||I||Y!=null||fe!=null,onPointerDown:U,onClick:C=>oe(C),isolateEvents:S,keyboardInset:x}):null,he?.kind==="notch"?jsxRuntime.jsx(Jn,{config:Qn(he),portalTarget:l,hidden:ot||M||I||Y!=null||fe!=null,onPointerDown:U,onClick:C=>oe(C),isolateEvents:S}):null,he?.kind==="inline"?jsxRuntime.jsx(Gn,{mount:he.mount,label:he.label??"Feedback",icon:he.icon,onPointerDown:U,onClick:C=>oe(C),isolateEvents:S}):null,fe?jsxRuntime.jsx(_n,{state:fe,portalTarget:l,onCapture:$e,onCancel:ye}):null,Y?jsxRuntime.jsx(Hn,{state:Y,portalTarget:l,onStop:ve,onCancel:ie}):null,jsxRuntime.jsx(_t,{})]},W),jsxRuntime.jsx(qa,{})]})}function qa(){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 ja(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function Ya(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Ga({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=Ge(),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:l=>{o?.(l),l.defaultPrevented||i(l.nativeEvent);},...a,children:r})}
5
- exports.CaptureModal=_t;exports.FeedbackButton=Ga;exports.LUMEN_KEYBOARD_CSS_VAR=Mt;exports.LUMEN_KEYBOARD_EVENT=Ye;exports.LUMEN_SHAKE_MESSAGE=ct;exports.LumenProvider=Wa;exports.createNativeCaptureProvider=lo;exports.isLumenEventTarget=ro;exports.isolateLumenEvents=oo;exports.readLumenKeyboardInset=Lt;exports.setLumenKeyboardInset=vo;exports.useKeyboardInset=Xe;exports.useLumen=Ge;//# sourceMappingURL=index.cjs.map
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 N=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},$t=class extends N{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},Kt=class extends N{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},it=class extends N{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 N("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 kr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof $t||i instanceof Kt||i instanceof N&&typeof i.status=="number"&&!Sr.has(i.status))throw i}}throw o instanceof Error?o:new it("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Rr)return;let t=(e.stack??"").split(`
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,xr(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 it("Submit aborted."));};if(s){if(s.aborted){o(new it("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 N(Mr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let l=JSON.parse(a.responseText);r(l);}catch{o(new N("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{s&&s.removeEventListener("abort",c),o(new it("Network error during submit."));}),a.send(t);})}};function xr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function kr(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 ut(e={}){kt();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 N("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 N("`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=[]){kt();let n=ct();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=ct(),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:g=>g instanceof HTMLElement&&(g.dataset.lumenCaptureIgnore==="true"||!!g.closest("[data-lumen-capture-ignore='true']")),onclone:(g,y)=>{Or(y,d),Nr(g);}}),R={blob:await sn(p,l),method:"web-dom",platform:"web",viewport:r,pixelRatio:c,warnings:Ze(l)};return R.warnings.length>0&&e.onWarning?.(R.warnings),R}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(kt(),!un())throw new N("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 N("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");d.drawImage(r,0,0,l.width,l.height);let p=ct(),R=["Browser screen capture uses the window or tab selected by the user."],g={blob:await sn(l,R),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?l.width/p.width:void 0,warnings:Ze(R)};return e.onWarning?.(g.warnings),g}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=ct(),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 N("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function ct(){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 N("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 N("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 kt(){if(typeof window>"u"||typeof document>"u")throw new N("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 Et(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 Et(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Et(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=[],st=[],Jt=false,Ct=null;function fn(e={}){Jt||typeof window>"u"||(Jt=true,Ct=e.ignoreUrlPrefix??null,Jr(),Qr(),eo());}function Gr(){return {consoleLog:pn.slice(),networkLog:st.slice()}}function lt(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{lt(pn,{level:n,ts:Date.now(),message:Et(Zr(o))});}catch{}r(...o);});}}function gn(e){return Ct?e.startsWith(Ct):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 lt(st,{type:"fetch",method:o,url:Rt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw lt(st,{type:"fetch",method:o,url:Rt(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{lt(st,{type:"xhr",method:o.method,url:Rt(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 Rt(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(St(n))return true;return St(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 St(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(oo)?true:!!e.closest(ro):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?St(e.host):false:false}var dt="lumen:shake",so=8e3,lo=50,uo=400;function co(e={}){return async function(){if(typeof window>"u")throw new N("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,R)=>{let g=window.setTimeout(()=>{t.pending.delete(i),R(new N("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:y=>{window.clearTimeout(g),p(y);},reject:y=>{window.clearTimeout(g),R(y);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(g),R(new N("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(c.error||!c.dataUrl)throw new N(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 N("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 N("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",Mt="--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(Mt,`${t}px`),window.dispatchEvent(new Event(Xe));}function Lt(){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(Mt).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 N("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new N("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(g=>MediaRecorder.isTypeSupported(g))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,c=false,l,d,p=new Promise((g,y)=>{l=g,d=y;});p.catch(()=>{}),r.addEventListener("dataavailable",g=>{g.data&&g.data.size>0&&o.push(g.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let k of t.getTracks())k.stop();if(c)return;if(c=true,s){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let g=performance.now()-a,y=r.mimeType||n||"audio/webm",C=new Blob(o,{type:y});l({blob:C,durationMs:g,mimeType:y});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function R(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){s=true,R(),i!==null&&window.clearTimeout(i),i=null;for(let g of t.getTracks())g.stop();},stop(){return R(),p}}}async function vn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new N("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new N("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(y=>MediaRecorder.isTypeSupported(y))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,s=false,c=false,l,d,p=new Promise((y,C)=>{l=y,d=C;});p.catch(()=>{});function R(){i!==null&&(window.clearTimeout(i),i=null);for(let y of t.getTracks())y.stop();}r.addEventListener("dataavailable",y=>{y.data&&y.data.size>0&&o.push(y.data);}),r.addEventListener("stop",()=>{if(s)return;if(s=true,R(),c){d(new N("Recording cancelled.","RECORDER_STOPPED"));return}let y=r.mimeType||n||"video/webm";l({blob:new Blob(o,{type:y}),durationMs:performance.now()-a,mimeType:y});});function g(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(g,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",g),{stream:t,result:p,stop:g,cancel(){c=true,r.state!=="inactive"?r.stop():s||(s=true,R(),d(new N("Recording cancelled.","RECORDER_STOPPED")));}}}var Tt=Rn.createContext(null);function Je(){let e=Rn.useContext(Tt);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 xo(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(),R=a.current,g=Lt(),y=window.visualViewport??null;y&&R==null&&g==null&&!p&&(o.current=y.height),r(xo({editable:p,override:R,injected:g,vvBaseline:o.current,vvHeight:y?y.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,R]=Rn.useState(null),[g,y]=Rn.useState([]),C=Rn.useRef(null),k=Rn.useRef(false),M=Rn.useRef(0),A=Rn.useRef(false),[h,w]=Rn.useState([]),O=Rn.useRef(0),T=Rn.useRef([]),I=Rn.useRef([]),D=Rn.useRef(g);D.current=g;let $=Rn.useRef(h);$.current=h;let F=Rn.useRef(null),be=Rn.useRef(i);be.current=i;let z=Rn.useCallback(()=>{be.current?.({canUndo:T.current.length>0,canRedo:I.current.length>0});},[]),K=Rn.useCallback((f,b)=>{w(S=>S.map(L=>L.id===f?{...L,text:b}:L));},[]),Z=Rn.useCallback(f=>{w(S=>S.filter(L=>L.id!==f));let b=T.current.lastIndexOf("comment");b>=0&&T.current.splice(b,1),I.current=[],z();},[z]);Rn.useEffect(()=>{let f=F.current;if(f==null)return;F.current=null,d.current?.querySelector(`[data-bubble-id="${f}"] .lumen-bubble-text`)?.focus();},[h]),Rn.useEffect(()=>{y([]),w([]),T.current=[],I.current=[],z();},[t,z]),Rn.useEffect(()=>{let f=false,b=null;return (async()=>{try{let S=await createImageBitmap(t);if(f){S.close?.();return}b=S,R(S);}catch{}})(),()=>{f=true,b?.close?.();}},[t]),Rn.useEffect(()=>{if(!p)return;let f=c.current,b=l.current;if(!f||!b)return;f.width=p.width,f.height=p.height,b.width=p.width,b.height=p.height;let S=f.getContext("2d");S&&(S.imageSmoothingEnabled=false,S.drawImage(p,0,0));},[p]),Rn.useEffect(()=>{let f=l.current;f&&mt(f,g,C.current);},[g]),Rn.useImperativeHandle(s,()=>({hasAnnotations:()=>g.length>0||h.some(f=>f.text.trim().length>0),reset:()=>{y([]),w([]),D.current=[],$.current=[],T.current=[],I.current=[],z();},undo:()=>{let f=T.current[T.current.length-1];if(f){if(f==="comment"){let b=$.current,S=b[b.length-1];if(!S)return;let L=b.slice(0,-1);$.current=L,I.current.push({type:"comment",item:S}),w(L);}else {let b=D.current,S=b[b.length-1];if(!S)return;let L=b.slice(0,-1);D.current=L,I.current.push({type:"anno",item:S}),y(L);}T.current.pop(),z();}},redo:()=>{let f=I.current[I.current.length-1];if(f){if(f.type==="comment"){let b=[...$.current,f.item];$.current=b,w(b);}else {let b=[...D.current,f.item];D.current=b,y(b);}T.current.push(f.type),I.current.pop(),z();}},async flatten(){let f=C.current,b=f?[...g,f]:g,S=h.filter(H=>H.text.trim().length>0);if(b.length===0&&S.length===0||!p)return t;let L=document.createElement("canvas");L.width=p.width,L.height=p.height;let W=L.getContext("2d");if(!W)return t;W.imageSmoothingEnabled=false,W.drawImage(p,0,0);for(let H of b)It(W,H);let B=c.current?.clientWidth||p.width,X=p.width/Math.max(B,1);for(let H of S)Ao(W,H,p.width,p.height,X);return await new Promise(H=>{L.toBlob(j=>{H(j??t);},"image/jpeg",.85);})}}),[g,h,p,t,z]);function ve(f){let b=l.current;if(!b)return {x:0,y:0};let S=b.getBoundingClientRect(),L=b.width/Math.max(S.width,1),W=b.height/Math.max(S.height,1);return {x:(f.clientX-S.left)*L,y:(f.clientY-S.top)*W}}function ae(){A.current||(A.current=true,requestAnimationFrame(()=>{A.current=false;let f=l.current;f&&mt(f,g,C.current);}));}function Pe(f){if(f.button!==void 0&&f.button!==0)return;if(n==="comment"){let S=l.current;if(!S)return;let L=S.getBoundingClientRect(),W=Cn((f.clientX-L.left)/Math.max(L.width,1),.72),B=Cn((f.clientY-L.top)/Math.max(L.height,1),.8),X=++O.current;w(H=>[...H,{id:X,x:W,y:B,text:"",color:r}]),T.current.push("comment"),I.current=[],F.current=X,z();return}try{f.currentTarget.setPointerCapture(f.pointerId);}catch{}k.current=true,a?.(true);let b=ve(f);n==="arrow"?C.current={kind:"arrow",from:b,to:b,color:r,width:o}:n==="rect"?C.current={kind:"rect",from:b,to:b,color:r,width:o}:C.current={kind:"freehand",points:[b],color:r,width:o},M.current=performance.now(),ae();}function Ne(f){if(!k.current||!C.current)return;let b=ve(f),S=C.current;if(S.kind==="arrow"||S.kind==="rect")S.to=b;else {let L=S.points[S.points.length-1],W=L?(L.x-b.x)**2+(L.y-b.y)**2:1/0,B=performance.now(),X=B-M.current;(W>16||X>16)&&(S.points.push(b),M.current=B);}ae();}function ie(){if(!k.current)return;k.current=false,a?.(false);let f=C.current;if(C.current=null,!!f){if(f.kind==="arrow"||f.kind==="rect"){let b=f.to.x-f.from.x,S=f.to.y-f.from.y;if(b*b+S*S<16){let L=l.current;L&&mt(L,g,null);return}}else if(f.points.length<2){let b=l.current;b&&mt(b,g,null);return}y(b=>[...b,f].slice(-50)),T.current.push("anno"),I.current=[],z();}}return jsxRuntime.jsxs("div",{ref:d,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:c}),jsxRuntime.jsx("canvas",{ref:l,className:"lumen-annotate-overlay",onPointerDown:Pe,onPointerMove:Ne,onPointerUp:ie,onPointerCancel:ie}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:h.map(f=>jsxRuntime.jsx(Lo,{comment:f,onChange:K,onRemove:Z},f.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 mt(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,R=t.x*n,g=t.y*r,y=Math.min(n*.6,n-R-8*o);e.save(),e.font=`500 ${s}px ${Nt}`,e.textBaseline="top";let C=Po(e,a,y-i*2),k=C.reduce((T,I)=>Math.max(T,e.measureText(I).width),0),M=Math.min(y,Math.max(k,56*o)+i*2),A=i*2+p+C.length*d;No(e,R,g,M,A,l),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let h=R+18*o,w=g+A;e.beginPath(),e.moveTo(h,w-o),e.lineTo(h+13*o,w-o),e.lineTo(h+4*o,w+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",R+i,g+i),e.fillStyle="#111318",e.font=`500 ${s}px ${Nt}`;let O=g+i+p;for(let T of C)e.fillText(T,R+i,O),O+=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 tt({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(tt,{...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(tt,{...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(tt,{...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 pt(e){return jsxRuntime.jsxs(tt,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function kn(e){return jsxRuntime.jsxs(tt,{...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:R,isolateEvents:g,keyboardInset:y}=Je(),[C,k]=Rn.useState(1),[M,A]=Rn.useState(null),[h,w]=Rn.useState({kind:"idle"}),[O,T]=Rn.useState(false),[I,D]=Rn.useState(0),[$,F]=Rn.useState(null),[be,z]=Rn.useState(false),[K,Z]=Rn.useState("arrow"),[ve,ae]=Rn.useState(Ln[0].value),[Pe,Ne]=Rn.useState(Tn[1].value),[ie,f]=Rn.useState(""),[b,S]=Rn.useState("bug"),[L,W]=Rn.useState(r?.email??""),[B,X]=Rn.useState(null),[H,j]=Rn.useState(null),[pe,Ce]=Rn.useState(0),[se,te]=Rn.useState(null),[fe,J]=Rn.useState(null),[ne,We]=Rn.useState(false),[we,Ie]=Rn.useState({canUndo:false,canRedo:false}),Re=Rn.useRef(null),He=Rn.useRef(null),_e=Rn.useRef(null),Ve=Rn.useRef(null),Se=et(t,y),ge=Rn.useRef(false),le=Rn.useRef(false);Rn.useEffect(()=>{t||(le.current=false);},[t]),Rn.useEffect(()=>{if(!t)return;if(le.current){ge.current=false;return}le.current=true,ge.current=false,k(1),A(null),f(""),j(null),Ce(0),te(null),T(false),D(0),F(null),z(false),J(null),Ie({canUndo:false,canRedo:false});let u=R();if(u){A("shot"),ke(u),w({kind:"ready",capture:u});return}let v=c();if(v)A("video"),te({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?w({kind:"ready",capture:Ge(v.poster,["Screen recording; preview is the first frame."])}):(w({kind:"capturing"}),(async()=>{let P=null;if(v.deriveBlobPoster)try{P=(await Ot(v.blob)).poster;}catch{P=null;}P=P??await Ht(),!ge.current&&w(P?{kind:"ready",capture:Ge(P,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let P=d();P?(A("video"),J(P),w({kind:"idle"})):a?(A("shot"),w({kind:"ready",capture:a})):o?.mode==="manual"?w({kind:"manual"}):o?.provider&&!i?(A("shot"),Q(o.mode??"auto")):w({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ge.current=true;}},[t,o,a,i]),Rn.useEffect(()=>{if(!t)return;Ve.current=document.activeElement??null;let u=document.documentElement,v=u.style.overflow,P=u.style.paddingRight,ee=window.innerWidth-u.clientWidth;u.style.overflow="hidden",ee>0&&(u.style.paddingRight=`${ee}px`);let re=false,Le=()=>{if(!re){re=true,u.style.overflow=v,u.style.paddingRight=P;try{Ve.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 P=He.current;if(!P)return;let ee=Yo(P);if(ee.length===0)return;let re=ee[0],Le=ee[ee.length-1],yt=document.activeElement;v.shiftKey&&(yt===re||!P.contains(yt))?(v.preventDefault(),Le.focus()):!v.shiftKey&&yt===Le&&(v.preventDefault(),re.focus());}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,n]),Rn.useEffect(()=>{if(!t||!g)return;let u=_e.current;if(!u)return;let v=P=>{P.target===u&&P.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,g]),Rn.useEffect(()=>{if(!t||!Se.open)return;let u=He.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(),ye(re));}return window.addEventListener("paste",u),()=>window.removeEventListener("paste",u)},[t,h.kind]),Rn.useEffect(()=>{if(!B)return;let u=Date.now(),v=window.setInterval(()=>{let P=Math.floor((Date.now()-u)/1e3);Ce(P),P>=_t&&Ue();},250);return ()=>window.clearInterval(v)},[B]);let ue=Rn.useRef(null);if(ue.current=B,Rn.useEffect(()=>{t||ue.current&&(ue.current.cancel(),ue.current=null,X(null),Ce(0));},[t]),Rn.useEffect(()=>()=>{ue.current?.cancel();},[]),!t)return null;async function Q(u){ge.current=false,w({kind:"capturing"});try{let v=await ut({...o,mode:u,target:o?.target??document.documentElement});return ge.current?!1:(ke(v),w({kind:"ready",capture:v}),!0)}catch(v){return ge.current||w({kind:"manual",error:v instanceof Error?v.message:"Automatic screenshot capture was unavailable."}),false}}async function xe(u){A(u),J(null),F(null),u!=="video"&&Me(),u==="shot"?await Q(o?.mode??"auto"):u==="video"?(te(null),w({kind:"idle"})):w({kind:"manual"});}async function ye(u){if(u.type.startsWith("image/")){Me();let v=Ge(u,["Manual image upload used."]);w({kind:"ready",capture:v});return}if(u.type.startsWith("video/")){w({kind:"capturing"});try{let{poster:v,durationMs:P}=await Ot(u),ee=v??await Ht();if(!ee){w({kind:"manual",error:"Could not read that video."});return}let re=Ge(ee,["Uploaded video; preview is the first frame."]);te({blob:u,durationMs:P}),w({kind:"ready",capture:re});}catch{w({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function ke(u){u.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function Fe(){try{let u=await bn(_t);X(u);}catch(u){sonner.toast.error(u instanceof Error?u.message:"Microphone unavailable");}}async function Ue(){if(B)try{let u=await B.stop();j({blob:u.blob,durationMs:u.durationMs});}catch(u){sonner.toast.error(u instanceof Error?u.message:"Could not stop recording");}finally{X(null);}}function ot(){B?.cancel(),X(null),j(null),Ce(0);}function qe(u){let v=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!B&&!H?jsxRuntime.jsxs("button",{type:"button",onClick:Fe,className:u==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(kn,{}),"Record voice note"]}):null,B?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:B.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[pe,"s / ",_t,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:Ue,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:ot,className:"lumen-btn-ghost",children:"Cancel"})]}):null,H&&!B?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Wo,{blob:H.blob,durationMs:H.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>j(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return u==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[v,!B&&!H?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 at(){J(null);try{await s();}catch(u){sonner.toast.error(u instanceof Error?u.message:"Screen capture unavailable");}}function Me(){te(null);}let vt=h.kind==="ready";async function wt(){if(B&&await Ue(),C===1){if(h.kind==="ready"){let u=await Re.current?.flatten();F(u??h.capture.blob),z(u!=null&&u!==h.capture.blob);}k(2);}else C===2?k(3):await x();}function he(){C>1&&k(u=>u-1);}async function x(){if(h.kind!=="ready")return;let u=ie.trim(),{capture:v}=h;T(true),D(0);try{let P=$??v.blob,ee=await e.submit({rawText:u.length>0?u:void 0,category:b,submitterEmail:L.trim()||void 0,screenshot:P,audio:H?.blob,audioDurationMs:H?.durationMs,video:se?.blob,videoDurationMs:se?.durationMs,context:hn(v)},{onUploadProgress:re=>D(Math.min(.95,re))});D(1),sonner.toast.success("Feedback sent \u2014 thank you."),ee.id,n();}catch(P){sonner.toast.error(P instanceof Error?P.message:"Could not submit feedback"),T(false);}}function V(u){u.target===u.currentTarget&&!O&&n();}let U=Math.round(I*100),je=M==="video",gr=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,hr=M==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&gr,br=C===1&&!vt||O,vr=C<3?"Next":O?U<95?`Uploading ${U}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{ref:_e,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:V,children:jsxRuntime.jsxs("div",{ref:He,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:C}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[C===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:()=>xe(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:()=>xe(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:at,onUpload:()=>xe("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&&ye(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(ft,{label:"Arrow",active:K==="arrow",onClick:()=>Z("arrow")}),jsxRuntime.jsx(ft,{label:"Box",active:K==="rect",onClick:()=>Z("rect")}),jsxRuntime.jsx(ft,{label:"Draw",active:K==="freehand",onClick:()=>Z("freehand")}),jsxRuntime.jsx(ft,{label:"Comment",active:K==="comment",onClick:()=>Z("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":ve===u.value,onClick:()=>ae(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":Pe===u.value,onClick:()=>Ne(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:!we.canUndo,children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.redo(),disabled:!we.canRedo,children:"Redo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>Re.current?.reset(),disabled:!we.canUndo,children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Sn,{ref:Re,screenshot:h.capture.blob,tool:K,color:ve,strokeWidth:Pe,onDrawingChange:We,onHistoryChange:Ie})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>M&&xe(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(pt,{})," Capture exact screen"]}):null,je?se?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(se.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,C===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=>f(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":b===u.value,onClick:()=>S(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:L,onChange:u=>W(u.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,C===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),be?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>k(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===b)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>k(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:()=>k(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:[H?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(H.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>j(null),children:"\xD7"})]}):null,se?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(se.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Me,children:"\xD7"})]}):null,L.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",L.trim()]}):null,!H&&!B?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{k(2),Fe();},children:"+ Voice note"}):null]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[O?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":U,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${U}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:C===1?n:he,className:"lumen-btn-ghost",disabled:O,children:C===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:wt,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 ft({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),R=18,g=3,y=3,C=Math.max(2,(o-g*(R-1))/R),k=Math.min(C/2,3),M=new Array(R).fill(0),A=0,h=false;function w(){if(h)return;d.getByteTimeDomainData(p);let O=Math.floor(p.length/R);i.clearRect(0,0,o,a),i.fillStyle=qo("--lumen-danger")||"rgb(239,68,68)";for(let T=0;T<R;T++){let I=0;for(let K=0;K<O;K++){let Z=Math.abs((p[T*O+K]??128)-128);Z>I&&(I=Z);}let D=Math.min(1,I/128*1.8),$=M[T]??0;M[T]=D>$?D:$+(D-$)*.35;let F=Math.max(y,M[T]*a),be=T*(C+g),z=(a-F)/2;Ko(i,be,z,C,F,k),i.fill();}A=requestAnimationFrame(w);}return A=requestAnimationFrame(w),()=>{h=true,cancelAnimationFrame(A);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 gt=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(pt,{})}),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 C=a[0]==="b"?"bottom":"top",k=a[1]==="r"?"right":"left",M=0,A=0;e.avoid==="auto"&&C==="bottom"?M=zn():Array.isArray(e.avoid)&&(M=Ut(e.avoid,C),A=Ut(e.avoid,k));let h={bottom:C==="bottom"?s+M:0,top:C==="top"?s+M:0,right:k==="right"?i+A:0,left:k==="left"?i+A:0},w=r.current;(h.bottom!==w.bottom||h.top!==w.top||h.right!==w.right||h.left!==w.left)&&(r.current=h,n(h));},p=()=>{c||(c=window.requestAnimationFrame(d));};p();let R=typeof ResizeObserver<"u"?new ResizeObserver(p):null;R?.observe(document.documentElement);let g=typeof MutationObserver<"u"?new MutationObserver(p):null;g?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",p);let y=window.visualViewport;return y?.addEventListener("resize",p),y?.addEventListener("scroll",p),()=>{l=true,c&&window.cancelAnimationFrame(c),R?.disconnect(),g?.disconnect(),window.removeEventListener("resize",p),y?.removeEventListener("resize",p),y?.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),R=Ke({onPointerDown:r,onClick:o,isolate:a}),g=Rn.useCallback(D=>{l.current=D,R(D);},[R]);Rn.useEffect(()=>{typeof document>"u"||c(t??document.body);},[t]);let y=e.placement,C=y[0]==="b"?"bottom":"top",k=y[1]==="r"?"right":"left",M=C==="bottom",A=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 w=C==="bottom"?d.bottom:d.top,O=k==="right"?d.right:d.left,T=n||h,I={position:"fixed",[C]:e.safeArea?`calc(${w}px + env(safe-area-inset-${C}, 0px))`:`${w}px`,[k]:e.safeArea?`calc(${O}px + env(safe-area-inset-${k}, 0px))`:`${O}px`,zIndex:e.zIndex,transform:A?`translateY(-${A}px)`:void 0,opacity:T?0:1,pointerEvents:T?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:g,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:I,"aria-label":e.label,"aria-hidden":T?true:void 0,tabIndex:T?-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:k=>{r?.(k),d.current={x:k.clientX,y:k.clientY},l(true);let M=k.currentTarget;try{M?.setPointerCapture?.(k.pointerId);}catch{}},onClick:o,isolate:a});if(Rn.useEffect(()=>{typeof document>"u"||s(t??document.body);},[t]),!i)return null;let R=`lumen-notch lumen-notch-${e.edge}${c?" lumen-notch-expanded":""}`;function g(k){let M=d.current;if(!M)return;let A=k.clientX-M.x,h=k.clientY-M.y;(e.edge==="top"&&h>16||e.edge==="bottom"&&h<-16||e.edge==="right"&&A<-16||e.edge==="left"&&A>16)&&(d.current=null,o(k.nativeEvent));}function y(){d.current=null,l(false);}function C(){d.current=null,l(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:R,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:g,onPointerUp:y,onPointerCancel:C,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-${xa(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 xa(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),R=ur(l.brand);Ua(e,d,p,R),r({trigger:d,enabled:ar(d),shakeToOpen:p,brand:R,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===dt;if(typeof e=="string")try{return JSON.parse(e).type===dt}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(R=>d-R<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",bt=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:R,beforeOpen:g,onTriggerActivate:y,isolateEvents:C=true,keyboardInset:k,suppressTrigger:M=false,children:A}){let[h,w]=Rn.useState(false),[O,T]=Rn.useState(false),[I,D]=Rn.useState(null),[$,F]=Rn.useState(null),[be]=Rn.useState(false),[z]=Rn.useState(null),K=Rn.useRef(false),Z=Rn.useRef(false),ve=Rn.useRef(null),ae=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 Pe=Rn.useRef(R);Pe.current=R,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 Ne=Rn.useRef(null);Rn.useEffect(()=>{if(Ne.current===h)return;let x=Ne.current;Ne.current=h,x!==null&&Pe.current?.(h);},[h]);let ie=Rn.useRef(g);ie.current=g;let f=Rn.useRef(y);f.current=y;let b=Rn.useCallback(x=>{Z.current=true,ve.current=Promise.resolve().then(()=>ie.current?.(x)).then(()=>f.current?.(x)).then(()=>{});},[]),S=Rn.useCallback(x=>{K.current||h||J.current||ye.current||(K.current=true,T(true),D(null),F(null),(async()=>{try{if(Z.current?await ve.current:(await ie.current?.(x),await f.current?.(x)),l?.mode==="manual")D(null),F(null);else if(l?.provider)D(null),F(null);else {let V=await ut({...l,mode:l?.mode??"auto",target:l?.target??document.documentElement});D(V);}}catch(V){F(V instanceof Error?V:new Error(String(V)));}finally{Z.current=false,ve.current=null,K.current=false,T(false),w(true);}})());},[l,h]),L=Rn.useCallback(()=>{w(false),D(null),F(null);},[]),W=Rn.useCallback(ae.submit.bind(ae),[ae]),[B,X]=Rn.useState(0),H=Rn.useCallback(()=>{K.current=false,T(false),w(false),D(null),F(null),X(x=>x+1);},[]),[j,pe]=Rn.useState(null),[Ce,se]=Rn.useState(null),te=Rn.useRef(null),fe=Rn.useRef(null),J=Rn.useRef(false),ne=Rn.useRef(null),We=Rn.useRef(null),we=Rn.useRef(null),Ie=Rn.useCallback((x,V=false)=>{if(te.current=null,fe.current=null,J.current=false,pe(null),!x){ne.current=null;return}We.current={blob:x.blob,durationMs:x.durationMs,poster:ne.current,deriveBlobPoster:V},ne.current=null,w(true);},[]);Rn.useEffect(()=>{if(!h)return;if(!d?.provider){se(null);return}let x=d.isAvailable;if(!x){se(true);return}let V=false;return Promise.resolve().then(()=>x()).then(U=>{V||se(U);}).catch(()=>{V||se(false);}),()=>{V=true;}},[h,d?.provider,d?.isAvailable]);let Re=Ft({hasProvider:!!d?.provider,providerAvailable:Ce,hasGetDisplayMedia:pr()}).canRecord,He=Rn.useCallback(async()=>{if(J.current)return;if(we.current=null,Ft({hasProvider:!!d?.provider,providerAvailable:Ce,hasGetDisplayMedia:pr()}).usingProvider&&d?.provider){J.current=true,ne.current=null,w(false),fe.current=Un(d.provider,{maxDurationSeconds:bt},{onStarting:()=>pe({phase:"starting"}),onActive:U=>{pe({phase:"recording",stream:U.stream??null,startedAt:Date.now(),maxSeconds:bt}),U.stream&&Bt(U.stream).then(je=>{ne.current=je;}).catch(()=>{});},onProcessing:()=>pe({phase:"processing"}),onResult:U=>Ie({blob:U.blob,durationMs:U.durationMs},true),onCancelled:()=>{fe.current=null,J.current=false,ne.current=null,pe(null),D(null),F(null),w(true);},onError:U=>{fe.current=null,J.current=false,ne.current=null,pe(null),we.current=U.message||"Screen recording could not start.",w(true);}});return}if(te.current)return;let V=await vn(bt);te.current=V,J.current=true,ne.current=null,pe({phase:"recording",stream:V.stream,startedAt:Date.now(),maxSeconds:bt}),w(false),Bt(V.stream).then(U=>{ne.current=U;}).catch(()=>{}),V.result.then(U=>Ie(U)).catch(()=>Ie(null));},[Ie,d?.provider,Ce]),_e=Rn.useCallback(()=>{fe.current?fe.current.stop():te.current?.stop();},[]),Ve=Rn.useCallback(()=>{if(fe.current){fe.current.cancel();return}let x=te.current;te.current=null,J.current=false,ne.current=null,pe(null),x?.cancel(),D(null),F(null),w(true);},[]),Se=Rn.useCallback(()=>{let x=We.current;return We.current=null,x},[]),ge=Rn.useCallback(()=>{let x=we.current;return we.current=null,x},[]);Rn.useEffect(()=>{h||(we.current=null);},[h]);let[le,ue]=Rn.useState(null),Q=Rn.useRef(null),xe=Rn.useRef(null),ye=Rn.useRef(false),ke=Rn.useCallback(()=>{let x=Q.current;Q.current=null,ye.current=false,x?.stop(),ue(null),w(true);},[]),Fe=Rn.useCallback(()=>{let x=Q.current;x&&(ue({phase:"grabbing"}),(async()=>{try{let V=await x.grab();if(Q.current!==x)return;xe.current=V,Q.current=null,ye.current=!1,x.stop(),ue(null),w(!0);}catch{if(Q.current!==x)return;Q.current=null,ye.current=false,x.stop(),ue(null),sonner.toast.error("Could not capture the screen. Please try again."),w(true);}})());},[]),Ue=Rn.useCallback(async()=>{if(ye.current)return;let x;try{x=await xt({...l});}catch{return}Q.current=x,ye.current=true,x.onEnded(()=>ke()),ue({phase:"live"}),w(false);},[l,ke]),ot=Rn.useCallback(()=>{let x=xe.current;return xe.current=null,x},[]);Rn.useEffect(()=>()=>{Q.current?.stop(),Q.current=null;},[]);let qe=or(),at=rr(i),Me=sr(a?"":e,t??mr);tr(s??Za(Me.brand));let vt=p??Me.shakeToOpen;cr(vt,S,h);let wt=Rn.useMemo(()=>({client:ae,user:n,isOpen:h,isSubmitting:be,error:z,open:S,close:L,openCapture:S,closeCapture:L,submit:W,isNativeShell:qe,capture:l,initialCapture:I,initialCaptureError:$,isOpening:O,startVideoSession:He,stopVideoSession:_e,cancelVideoSession:Ve,recording:j,consumePendingVideo:Se,canRecordScreen:Re,consumeRecordStartError:ge,startScreenCaptureSession:Ue,grabScreenCaptureFrame:Fe,cancelScreenCaptureSession:ke,screenCapture:le,consumePendingScreenshot:ot,isolateEvents:C,keyboardInset:k}),[ae,n,h,be,z,S,L,W,qe,l,I,$,He,_e,Ve,j,Se,Re,ge,Ue,Fe,ke,le,ot,O,C,k]),he=Ga({explicit:a,remote:Me.trigger,remoteLoading:Me.loading,floatingButton:o});return jsxRuntime.jsxs(Tt.Provider,{value:wt,children:[A,jsxRuntime.jsxs(gt,{onReset:H,onError:x=>ae.reportClientError({...x,context:{open:h,opening:O,screenCapturePhase:le?.phase,recordingPhase:j?.phase,initialCaptureMethod:I?.method,initialCapturePixelRatio:I?.pixelRatio,initialCaptureViewport:I?.viewport,hadInitialCaptureError:$!=null}}),children:[he?.kind==="floating"?jsxRuntime.jsx(Yn,{config:er(he),portalTarget:c,hidden:at||M||O||j!=null||le!=null,onPointerDown:b,onClick:x=>S(x),isolateEvents:C,keyboardInset:k}):null,he?.kind==="notch"?jsxRuntime.jsx(Jn,{config:Qn(he),portalTarget:c,hidden:at||M||O||j!=null||le!=null,onPointerDown:b,onClick:x=>S(x),isolateEvents:C}):null,he?.kind==="inline"?jsxRuntime.jsx(Gn,{mount:he.mount,label:he.label??"Feedback",icon:he.icon,onPointerDown:b,onClick:x=>S(x),isolateEvents:C}):null,le?jsxRuntime.jsx(_n,{state:le,portalTarget:c,onCapture:Fe,onCancel:ke}):null,j?jsxRuntime.jsx(Hn,{state:j,portalTarget:c,onStop:_e,onCancel:Ve}):null,jsxRuntime.jsx(Vt,{})]},B),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
+ exports.CaptureModal=Vt;exports.FeedbackButton=Xa;exports.LUMEN_KEYBOARD_CSS_VAR=Mt;exports.LUMEN_KEYBOARD_EVENT=Xe;exports.LUMEN_SHAKE_MESSAGE=dt;exports.LumenProvider=ja;exports.createNativeCaptureProvider=co;exports.isLumenEventTarget=ao;exports.isolateLumenEvents=io;exports.readLumenKeyboardInset=Lt;exports.setLumenKeyboardInset=yo;exports.useKeyboardInset=et;exports.useLumen=Je;//# sourceMappingURL=index.cjs.map
6
6
  //# sourceMappingURL=index.cjs.map