@lumen-stack/react 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
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 u=new URL(window.location.href);a=u.origin+u.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}${jr}`,{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.priority&&t.append("priority",e.priority),e.source&&t.append("source",e.source),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:u}=n;i&&a.upload.addEventListener("progress",c=>{c.lengthComputable&&c.total>0&&i(Math.min(1,c.loaded/c.total));});let d=()=>{a.abort(),o(new pt("Submit aborted."));};if(u){if(u.aborted){o(new pt("Submit aborted."));return}u.addEventListener("abort",d,{once:true});}a.addEventListener("load",()=>{if(u&&u.removeEventListener("abort",d),a.status===403){o(new an);return}if(a.status===429){let c=Number(a.getResponseHeader("Retry-After"))||60;o(new sn(c));return}if(a.status<200||a.status>=300){o(new O(Qr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let c=JSON.parse(a.responseText);r(c);}catch{o(new O("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{u&&u.removeEventListener("abort",d),o(new pt("Network error during submit."));}),a.send(t);})}};function Xr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Jr(e){return new Promise(t=>setTimeout(t,e))}function Qr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var wn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function yn(e=wn){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 eo=2,to=1.5,no=820,ro=12,Je=8*1024*1024;async function bt(e={}){At();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return co(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 O("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return dn(e);if(t==="dom")return un(e);if(t==="custom")throw new O("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await un(e)}catch(n){if(Sn()){let r=await dn(e);return r.warnings=et(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function Qe(e,t=[]){At();let n=gt();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:et(t)}}var ln=Promise.resolve();function un(e){let t=ln.then(()=>cn(e),()=>cn(e));return ln=t.catch(()=>{}),t}async function cn(e){let t=await uo(),n=e.target??document.documentElement,r=gt(),o=po(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),u=window.scrollY+(a?.offsetTop??0),d=fo(e,r.width,r.height),c=mo(n);!e.provider&&lo()&&c.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 m=io(n);await Rn(e.awaitAnimationsMs??go),await bo();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:u,scale:d,ignoreElements:v=>v instanceof HTMLElement&&(v.dataset.lumenCaptureIgnore==="true"||!!v.closest("[data-lumen-capture-ignore='true']")),onclone:(v,y)=>{so(y,m),oo(v);}}),C={blob:await kn(p,c),method:"web-dom",platform:"web",viewport:r,pixelRatio:d,warnings:et(c)};return C.warnings.length>0&&e.onWarning?.(C.warnings),C}var En=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function oo(e){for(let t of Array.from(e.querySelectorAll(En))){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 ao="[data-lumen-root], [data-lumen-capture-ignore='true']";function Cn(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(ao))}function io(e){return Cn(e).map(t=>{if(t.matches(En))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 so(e,t){let n=Cn(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 lo(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function uo(){let{default:e}=await import('html2canvas-pro');return e}async function Nt(e={}){if(At(),!Sn())throw new O("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 vo(n);}catch(i){for(let u of t.getTracks())u.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(u=>u());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let u=i?.conceal??true,d=u?yn():()=>{};try{u&&await wo(r,3,400);let c=document.createElement("canvas");c.width=r.videoWidth,c.height=r.videoHeight;let m=c.getContext("2d");if(!m)throw new O("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");m.drawImage(r,0,0,c.width,c.height);let p=gt(),C=["Browser screen capture uses the window or tab selected by the user."],v={blob:await kn(c,C),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?c.width/p.width:void 0,warnings:et(C)};return e.onWarning?.(v.warnings),v}finally{d();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function dn(e){let t=await Nt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function co(e,t){let n=gt(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:et(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function mo(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 kn(e,t){let n=await mn(e,"image/png",.92);if(n.size<=Je)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>Je&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(Je/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 u=i.getContext("2d");if(!u)return n;u.drawImage(r,0,0,i.width,i.height),r=i;for(let d of [.86,.74,.62,.5])if(n=await mn(r,"image/jpeg",d),n.size<=Je)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>Je&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function mn(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new O("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function gt(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function po(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function fo(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??eo;ho()&&(o=Math.min(o,to));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(ro*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function ho(){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<=no}function bo(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var go=400;async function Rn(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 Sn(){return !!navigator.mediaDevices?.getDisplayMedia}async function vo(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new O("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 O("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function wo(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 u=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(u);};r(u),setTimeout(i,n);});}function At(){if(typeof window>"u"||typeof document>"u")throw new O("Screenshot capture can only run in the browser.","INVALID_ENV")}function et(e){return Array.from(new Set(e.filter(Boolean)))}var xn=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,yo=[/-----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 Eo(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 Mt(e){let t=e;for(let n of yo)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:xn.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=>Eo(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 Mn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])xn.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Mt(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Mt(e)}}function Pn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return Mn(e)}}var pn=200,fn=4096,Tn=[],ft=[],hn=false,Pt=null;function Ln(e={}){hn||typeof window>"u"||(hn=true,Pt=e.ignoreUrlPrefix??null,So(),xo(),Mo());}function Co(){return {consoleLog:Tn.slice(),networkLog:ft.slice()}}function ht(e,t){e.push(t),e.length>pn&&e.splice(0,e.length-pn);}function ko(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,Ro));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>fn?n.slice(0,fn)+"\u2026[truncated]":n}function Ro(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function So(){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{ht(Tn,{level:n,ts:Date.now(),message:Mt(ko(o))});}catch{}r(...o);});}}function Nn(e){return Pt?e.startsWith(Pt):false}function xo(){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(Nn(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ht(ft,{type:"fetch",method:o,url:Tt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ht(ft,{type:"fetch",method:o,url:Tt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Mo(){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&&!Nn(o.url)){o.t=performance.now();let a=()=>{try{ht(ft,{type:"xhr",method:o.method,url:Tt(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 Po(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Tt(e){return Po(Mn(e))}function An(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:bn(e),consoleLog:[],networkLog:[]};let t=Co();return {url:Pn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:bn(e),device:To(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function To(){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?Pn(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 bn(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var Lo="[data-lumen-root]",No="[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(Lt(n))return true;return Lt(e.target)}var gn=["pointerdown","mousedown","touchstart","click"];function Io(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of gn)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of gn)e.removeEventListener(n,t);}}function Lt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(No)?true:!!e.closest(Lo):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?Lt(e.host):false:false}var vt="lumen:shake",Do=8e3,Oo=50,Ho=400;function Bo(e={}){return async function(){if(typeof window>"u")throw new O("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=Fo(),n=e.send??_o,r=e.timeoutMs??Do,o=e.captureSettleMs??Oo,a=e.awaitAnimationsMs??Ho,i=Wo(),u=yn(e.concealSelector===void 0?wn:e.concealSelector);try{await Vo(o,a);let d=await new Promise((p,C)=>{let v=window.setTimeout(()=>{t.pending.delete(i),C(new O("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:y=>{window.clearTimeout(v),p(y);},reject:y=>{window.clearTimeout(v),C(y);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(v),C(new O("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(d.error||!d.dataUrl)throw new O(d.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let c=Ko(d.dataUrl),m=e.platform??$o();return {blob:c,method:m==="android"?"android-native":"ios-native",platform:m,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:d.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{u();}}}function _o(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new O("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function Fo(){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=Uo(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 Uo(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 Vo(e,t){await Rn(t),await zo(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function zo(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function $o(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function Wo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function Ko(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new O("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 u=0;u<a.length;u++)i[u]=a.charCodeAt(u);return new Blob([i],{type:n})}var tt="lumen:keyboardchange",It="--lumen-keyboard-inset";function qo(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(It,`${t}px`),window.dispatchEvent(new Event(tt));}function Dt(){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(It).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function In(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new O("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new O("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(v=>MediaRecorder.isTypeSupported(v))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((v,y)=>{c=v,m=y;});p.catch(()=>{}),r.addEventListener("dataavailable",v=>{v.data&&v.data.size>0&&o.push(v.data);}),r.addEventListener("stop",()=>{i!==null&&window.clearTimeout(i),i=null;for(let T of t.getTracks())T.stop();if(d)return;if(d=true,u){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let v=performance.now()-a,y=r.mimeType||n||"audio/webm",R=new Blob(o,{type:y});c({blob:R,durationMs:v,mimeType:y});}),r.start(),i=window.setTimeout(()=>{r.state!=="inactive"&&r.stop();},e*1e3);function C(){if(r.state!=="inactive")try{r.stop();}catch{}}return {stream:t,cancel(){u=true,C(),i!==null&&window.clearTimeout(i),i=null;for(let v of t.getTracks())v.stop();},stop(){return C(),p}}}async function Dn(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new O("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new O("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,u=false,d=false,c,m,p=new Promise((y,R)=>{c=y,m=R;});p.catch(()=>{});function C(){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(u)return;if(u=true,C(),d){m(new O("Recording cancelled.","RECORDER_STOPPED"));return}let y=r.mimeType||n||"video/webm";c({blob:new Blob(o,{type:y}),durationMs:performance.now()-a,mimeType:y});});function v(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(v,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",v),{stream:t,result:p,stop:v,cancel(){d=true,r.state!=="inactive"?r.stop():u||(u=true,C(),m(new O("Recording cancelled.","RECORDER_STOPPED")));}}}var Ot=Fn.createContext(null);function nt(){let e=Fn.useContext(Ot);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var On=100;function Hn(){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 rt={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)}:rt}if(e.vvHeight==null||!e.coarse||!e.editable)return rt;let n=e.vvBaseline-e.vvHeight;return n>On?{open:true,inset:Math.round(n)}:rt}function ot(e,t){let[n,r]=Fn.useState(rt),o=Fn.useRef(0),a=Fn.useRef(t);return a.current=t,Fn.useEffect(()=>{if(!e){r(rt);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,u=()=>{let p=Hn(),C=a.current,v=Dt(),y=window.visualViewport??null;y&&C==null&&v==null&&!p&&(o.current=y.height),r(Xo({editable:p,override:C,injected:v,vvBaseline:o.current,vvHeight:y?y.height:null,coarse:i}));},d=0,c=()=>{d||(d=window.requestAnimationFrame(()=>{d=0,u();}));},m=window.visualViewport;return m&&(o.current=m.height),c(),m?.addEventListener("resize",c),m?.addEventListener("scroll",c),document.addEventListener("focusin",c),document.addEventListener("focusout",c),window.addEventListener(tt,c),()=>{d&&window.cancelAnimationFrame(d),m?.removeEventListener("resize",c),m?.removeEventListener("scroll",c),document.removeEventListener("focusin",c),document.removeEventListener("focusout",c),window.removeEventListener(tt,c);}},[e]),n}var Bt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function _n(e,t=1){return Math.max(0,Math.min(t,e))}var Un=Fn__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},u){let d=Fn.useRef(null),c=Fn.useRef(null),m=Fn.useRef(null),[p,C]=Fn.useState(null),[v,y]=Fn.useState(false),[R,T]=Fn.useState(""),[S,L]=Fn.useState([]),b=Fn.useRef(null),E=Fn.useRef(false),H=Fn.useRef(0),N=Fn.useRef(false),[F,A]=Fn.useState([]),J=Fn.useRef(0),I=Fn.useRef([]),$=Fn.useRef([]),G=Fn.useRef(S);G.current=S;let W=Fn.useRef(F);W.current=F;let le=Fn.useRef(null),he=Fn.useRef(i);he.current=i;let V=Fn.useCallback(()=>{he.current?.({canUndo:I.current.length>0,canRedo:$.current.length>0});},[]),Oe=Fn.useCallback((h,w)=>{A(x=>x.map(P=>P.id===h?{...P,text:w}:P));},[]),He=Fn.useCallback(h=>{A(x=>x.filter(P=>P.id!==h));let w=I.current.lastIndexOf("comment");w>=0&&I.current.splice(w,1),$.current=[],V();},[V]);Fn.useEffect(()=>{let h=le.current;if(h==null)return;le.current=null,m.current?.querySelector(`[data-bubble-id="${h}"] .lumen-bubble-text`)?.focus();},[F]),Fn.useEffect(()=>{L([]),A([]),y(false),I.current=[],$.current=[],V();},[t,V]),Fn.useEffect(()=>{let h=false,w=null;return (async()=>{try{let x=await createImageBitmap(t);if(h){x.close?.();return}w=x,C(x);}catch{}})(),()=>{h=true,w?.close?.();}},[t]),Fn.useEffect(()=>{if(!p)return;let h=d.current,w=c.current;if(!(!h||!w)){w.width=p.width,w.height=p.height;try{h.width=p.width,h.height=p.height;let x=h.getContext("2d");if(!x)return;x.imageSmoothingEnabled=!1,x.drawImage(p,0,0),y(!1);}catch{y(true);}}},[p]),Fn.useEffect(()=>{if(!v){T("");return}let h=URL.createObjectURL(t);return T(h),()=>{URL.revokeObjectURL(h);}},[v,t]),Fn.useEffect(()=>{let h=c.current;if(h)try{wt(h,S,b.current);}catch{}},[S]),Fn.useImperativeHandle(u,()=>({hasAnnotations:()=>S.length>0||F.some(h=>h.text.trim().length>0),reset:()=>{L([]),A([]),G.current=[],W.current=[],I.current=[],$.current=[],V();},undo:()=>{let h=I.current[I.current.length-1];if(h){if(h==="comment"){let w=W.current,x=w[w.length-1];if(!x)return;let P=w.slice(0,-1);W.current=P,$.current.push({type:"comment",item:x}),A(P);}else {let w=G.current,x=w[w.length-1];if(!x)return;let P=w.slice(0,-1);G.current=P,$.current.push({type:"anno",item:x}),L(P);}I.current.pop(),V();}},redo:()=>{let h=$.current[$.current.length-1];if(h){if(h.type==="comment"){let w=[...W.current,h.item];W.current=w,A(w);}else {let w=[...G.current,h.item];G.current=w,L(w);}I.current.push(h.type),$.current.pop(),V();}},async flatten(){let h=b.current,w=h?[...S,h]:S,x=F.filter(P=>P.text.trim().length>0);if(w.length===0&&x.length===0||!p||v)return t;try{let P=document.createElement("canvas");P.width=p.width,P.height=p.height;let _=P.getContext("2d");if(!_)return t;_.imageSmoothingEnabled=!1,_.drawImage(p,0,0);for(let q of w)_t(_,q);let K=d.current?.clientWidth||p.width,re=p.width/Math.max(K,1);for(let q of x)na(_,q,p.width,p.height,re);return await new Promise(q=>{P.toBlob(pe=>{q(pe??t);},"image/jpeg",.85);})}catch{return t}}}),[S,F,p,t,v,V]);function be(h){let w=c.current;if(!w)return {x:0,y:0};let x=w.getBoundingClientRect(),P=w.width/Math.max(x.width,1),_=w.height/Math.max(x.height,1);return {x:(h.clientX-x.left)*P,y:(h.clientY-x.top)*_}}function Me(){N.current||(N.current=true,requestAnimationFrame(()=>{N.current=false;let h=c.current;h&&wt(h,G.current,b.current);}));}function Ce(h){if(h.button!==void 0&&h.button!==0)return;if(n==="comment"){let x=c.current;if(!x)return;let P=x.getBoundingClientRect(),_=_n((h.clientX-P.left)/Math.max(P.width,1),.72),K=_n((h.clientY-P.top)/Math.max(P.height,1),.8),re=++J.current;A(q=>[...q,{id:re,x:_,y:K,text:"",color:r}]),I.current.push("comment"),$.current=[],le.current=re,V();return}try{h.currentTarget.setPointerCapture(h.pointerId);}catch{}E.current=true,a?.(true);let w=be(h);n==="arrow"?b.current={kind:"arrow",from:w,to:w,color:r,width:o}:n==="rect"?b.current={kind:"rect",from:w,to:w,color:r,width:o}:b.current={kind:"freehand",points:[w],color:r,width:o},H.current=performance.now(),Me();}function oe(h){if(!E.current||!b.current)return;let w=be(h),x=b.current;if(x.kind==="arrow"||x.kind==="rect")x.to=w;else {let P=x.points[x.points.length-1],_=P?(P.x-w.x)**2+(P.y-w.y)**2:1/0,K=performance.now(),re=K-H.current;(_>16||re>16)&&(x.points.push(w),H.current=K);}Me();}function ke(){if(!E.current)return;E.current=false,a?.(false);let h=b.current;if(b.current=null,!!h){if(h.kind==="arrow"||h.kind==="rect"){let w=h.to.x-h.from.x,x=h.to.y-h.from.y;if(w*w+x*x<16){let P=c.current;P&&wt(P,G.current,null);return}}else if(h.points.length<2){let w=c.current;w&&wt(w,G.current,null);return}L(w=>[...w,h].slice(-50)),I.current.push("anno"),$.current=[],V();}}return jsxRuntime.jsxs("div",{ref:m,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:d}),v&&R?jsxRuntime.jsx("img",{src:R,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsxRuntime.jsx("canvas",{ref:c,className:"lumen-annotate-overlay",onPointerDown:Ce,onPointerMove:oe,onPointerUp:ke,onPointerCancel:ke}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:F.map(h=>jsxRuntime.jsx(ea,{comment:h,onChange:Oe,onRemove:He},h.id))})]})});function ea({comment:e,onChange:t,onRemove:n}){let r=Fn.useRef(null);return Fn.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 wt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)_t(r,o);n&&_t(r,n);}}function _t(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")ta(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 ta(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],u=(a.x+i.x)/2,d=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,u,d);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function na(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,u=14*o,d=10*o,c=12*o,m=u*1.35,p=d*1.7,C=t.x*n,v=t.y*r,y=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${u}px ${Bt}`,e.textBaseline="top";let R=ra(e,a,y-i*2),T=R.reduce((N,F)=>Math.max(N,e.measureText(F).width),0),S=Math.min(y,Math.max(T,56*o)+i*2),L=i*2+p+R.length*m;oa(e,C,v,S,L,c),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let b=C+18*o,E=v+L;e.beginPath(),e.moveTo(b,E-o),e.lineTo(b+13*o,E-o),e.lineTo(b+4*o,E+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${d}px ${Bt}`,e.fillText("COMMENT",C+i,v+i),e.fillStyle="#111318",e.font=`500 ${u}px ${Bt}`;let H=v+i+p;for(let N of R)e.fillText(N,C+i,H),H+=m;e.restore();}function ra(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let u=a?`${a} ${i}`:i;a&&e.measureText(u).width>n?(o.push(a),a=i):a=u;}return a&&o.push(a),o.length?o:[t]}function oa(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 Y({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 aa(e){return jsxRuntime.jsxs(Y,{...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 ia(e){return jsxRuntime.jsxs(Y,{...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 Ft(e){return jsxRuntime.jsxs(Y,{...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 zn(e){return jsxRuntime.jsx(Y,{...e,children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-8.5 8.5 9.5 9.5 0 0 1-3.5-.7L3 21l1.7-5.5A8.38 8.38 0 0 1 4 11.5 8.5 8.5 0 0 1 12.5 3 8.38 8.38 0 0 1 21 11.5Z"})})}function $n(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19 19 5"}),jsxRuntime.jsx("path",{d:"M11 5h8v8"})]})}function Wn(e){return jsxRuntime.jsx(Y,{...e,children:jsxRuntime.jsx("rect",{x:"4",y:"6",width:"16",height:"12",rx:"2"})})}function Ut(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19l1.5-5L16 4.5 19.5 8 10 17.5 5 19z"}),jsxRuntime.jsx("path",{d:"M14 6.5l3.5 3.5"})]})}function Kn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M9 8 4 13l5 5"}),jsxRuntime.jsx("path",{d:"M4 13h11a5 5 0 0 1 0 10h-1"})]})}function Vt(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),jsxRuntime.jsx("path",{d:"M21 4v4h-4"})]})}function qn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M15 8 20 13l-5 5"}),jsxRuntime.jsx("path",{d:"M20 13H9a5 5 0 0 0 0 10h1"})]})}function jn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M4 7h16"}),jsxRuntime.jsx("path",{d:"M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"}),jsxRuntime.jsx("path",{d:"M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"})]})}function Yn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),jsxRuntime.jsx("path",{d:"M16 3h3a2 2 0 0 1 2 2v3"}),jsxRuntime.jsx("path",{d:"M21 16v3a2 2 0 0 1-2 2h-3"}),jsxRuntime.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"})]})}function Gn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),jsxRuntime.jsx("path",{d:"M16 3v3a2 2 0 0 0 2 2h3"}),jsxRuntime.jsx("path",{d:"M21 16h-3a2 2 0 0 0-2 2v3"}),jsxRuntime.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"})]})}function Zn(e){return jsxRuntime.jsx(Y,{...e,strokeWidth:2.2,children:jsxRuntime.jsx("path",{d:"M15 6l-6 6 6 6"})})}function Xn(e){return jsxRuntime.jsx(Y,{...e,strokeWidth:1.9,children:jsxRuntime.jsx("path",{d:"M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z"})})}function it(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function zt(e){return jsxRuntime.jsxs(Y,{...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 yt={shot:aa,video:ia,upload:Ft};function Jn(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 sa(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 la=4e3;async function $t(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((d,c)=>{if(n.readyState>=2)return d();n.addEventListener("loadeddata",()=>d(),{once:true}),n.addEventListener("error",()=>c(new Error("video decode failed")),{once:true});}),await sa(n,Math.min(.1,(n.duration||0)/2));let i=await Jn(n),u=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:u}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),la);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Wt(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 Jn(t)}catch{return null}finally{t.srcObject=null;}}async function Kt(){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 qt=60,ua=25*1024*1024,Qn=[{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)"}],er=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],ca=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],da=[{value:"",label:"No priority"},{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],ma=[{value:"web",label:"Web"},{value:"ios-web",label:"iOS web"},{value:"android-web",label:"Android web"},{value:"ios-native",label:"iOS native"},{value:"android-native",label:"Android native"}];function pa(e){if(e.platform==="ios")return "ios-native";if(e.platform==="android")return "android-native";if(e.platform==="custom")return "custom";let t=typeof navigator<"u"&&navigator.userAgent||"";return /android/i.test(t)?"android-web":/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&typeof document<"u"&&"ontouchend"in document?"ios-web":"web"}function fa({value:e}){return e==="urgent"?jsxRuntime.jsx("span",{className:"lumen-pri-ic lumen-pri-urgent","aria-hidden":"true",children:"!"}):jsxRuntime.jsxs("span",{className:"lumen-pri-ic lumen-pri-bars","data-level":e==="high"?3:e==="medium"?2:1,"aria-hidden":"true",children:[jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{})]})}var jt=[{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 Yt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:u,consumePendingVideo:d,canRecordScreen:c,consumeRecordStartError:m,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:v,keyboardInset:y}=nt(),[R,T]=Fn.useState(1),[S,L]=Fn.useState(null),[b,E]=Fn.useState({kind:"idle"}),[H,N]=Fn.useState(false),[F,A]=Fn.useState(0),[J,I]=Fn.useState("arrow"),[$,G]=Fn.useState(Qn[0].value),[W,le]=Fn.useState(er[1].value),[he,V]=Fn.useState(""),[Oe,He]=Fn.useState("bug"),[be,Me]=Fn.useState(""),[Ce,oe]=Fn.useState(""),[ke,h]=Fn.useState(false),[w,x]=Fn.useState(false),[P,_]=Fn.useState(false),[K,re]=Fn.useState(false),[q,pe]=Fn.useState(false),[ge,Re]=Fn.useState(r?.email??""),[U,Pe]=Fn.useState(null),[ae,Se]=Fn.useState(null),[lt,Be]=Fn.useState(0),[ve,we]=Fn.useState(null),[ut,_e]=Fn.useState(null),[xe,Fe]=Fn.useState(false),[Q,Ke]=Fn.useState({canUndo:false,canRedo:false}),ue=Fn.useRef(null),Te=Fn.useRef(null),Ue=Fn.useRef(null),Ge=Fn.useRef(null),Ze=Fn.useRef(null),Le=ot(t,y),ye=Fn.useRef(false),Ne=Fn.useRef(false);Fn.useEffect(()=>{t||(Ne.current=false);},[t]),Fn.useEffect(()=>{if(!t)return;if(Ne.current){ye.current=false;return}Ne.current=true,ye.current=false,T(1),L(null),V(""),Se(null),Be(0),we(null),N(false),A(0),oe(""),pe(false),_e(null),Ke({canUndo:false,canRedo:false});let s=C();if(s){L("shot"),z(s),E({kind:"ready",capture:s});return}let g=d();if(g)L("video"),we({blob:g.blob,durationMs:g.durationMs}),g.blob.size>ua&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),g.poster?E({kind:"ready",capture:Qe(g.poster,["Screen recording; preview is the first frame."])}):(E({kind:"capturing"}),(async()=>{let D=null;if(g.deriveBlobPoster)try{D=(await $t(g.blob)).poster;}catch{D=null;}D=D??await Kt(),!ye.current&&E(D?{kind:"ready",capture:Qe(D,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let D=m();D?(L("video"),_e(D),E({kind:"idle"})):a?(L("shot"),E({kind:"ready",capture:a})):o?.mode==="manual"?E({kind:"manual"}):o?.provider&&!i?(L("shot"),ct(o.mode??"auto")):E({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{ye.current=true;}},[t,o,a,i]),Fn.useEffect(()=>{if(!t)return;Ze.current=document.activeElement??null;let s=document.documentElement,g=s.style.overflow,D=s.style.paddingRight,ie=window.innerWidth-s.clientWidth;s.style.overflow="hidden",ie>0&&(s.style.paddingRight=`${ie}px`);let ce=false,Ee=()=>{if(!ce){ce=true,s.style.overflow=g,s.style.paddingRight=D;try{Ze.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",Ee),()=>{window.removeEventListener("pagehide",Ee),Ee();}},[t]),Fn.useEffect(()=>{if(!t)return;function s(g){if(g.key==="Escape"){g.preventDefault(),n();return}if(g.key!=="Tab")return;let D=Ue.current;if(!D)return;let ie=Ra(D);if(ie.length===0)return;let ce=ie[0],Ee=ie[ie.length-1],xt=document.activeElement;g.shiftKey&&(xt===ce||!D.contains(xt))?(g.preventDefault(),Ee.focus()):!g.shiftKey&&xt===Ee&&(g.preventDefault(),ce.focus());}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),Fn.useEffect(()=>{if(!t||!v)return;let s=Ge.current;if(!s)return;let g=D=>{D.target===s&&D.stopPropagation();};return s.addEventListener("pointerdown",g),s.addEventListener("click",g),s.addEventListener("touchstart",g,{passive:true}),()=>{s.removeEventListener("pointerdown",g),s.removeEventListener("click",g),s.removeEventListener("touchstart",g);}},[t,v]),Fn.useEffect(()=>{if(!t||!Le.open)return;let s=Ue.current,g=document.activeElement;if(s&&g&&s.contains(g))try{g.scrollIntoView({block:"center"});}catch{}},[t,Le.open,Le.inset]),Fn.useEffect(()=>{if(!t||b.kind!=="manual")return;function s(g){let ce=Array.from(g.clipboardData?.items??[]).find(Ee=>Ee.type.startsWith("image/"))?.getAsFile();ce&&(g.preventDefault(),k(ce));}return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[t,b.kind]),Fn.useEffect(()=>{if(!U)return;let s=Date.now(),g=window.setInterval(()=>{let D=Math.floor((Date.now()-s)/1e3);Be(D),D>=qt&&Xe();},250);return ()=>window.clearInterval(g)},[U]);let Ve=Fn.useRef(null);if(Ve.current=U,Fn.useEffect(()=>{t||Ve.current&&(Ve.current.cancel(),Ve.current=null,Pe(null),Be(0));},[t]),Fn.useEffect(()=>()=>{Ve.current?.cancel();},[]),!t)return null;async function ct(s){ye.current=false,E({kind:"capturing"});try{let g=await bt({...o,mode:s,target:o?.target??document.documentElement});return ye.current?!1:(z(g),E({kind:"ready",capture:g}),!0)}catch(g){return ye.current||E({kind:"manual",error:g instanceof Error?g.message:"Automatic screenshot capture was unavailable."}),false}}async function ee(s){L(s),_e(null),s!=="video"&&St(),s==="shot"?await ct(o?.mode??"auto"):s==="video"?(we(null),E({kind:"idle"})):(E({kind:"manual"}),Te.current?.click());}async function k(s){if(s.type.startsWith("image/")){St();let g=Qe(s,["Manual image upload used."]);E({kind:"ready",capture:g});return}if(s.type.startsWith("video/")){E({kind:"capturing"});try{let{poster:g,durationMs:D}=await $t(s),ie=g??await Kt();if(!ie){E({kind:"manual",error:"Could not read that video."});return}let ce=Qe(ie,["Uploaded video; preview is the first frame."]);we({blob:s,durationMs:D}),E({kind:"ready",capture:ce});}catch{E({kind:"manual",error:"Could not read that video."});}return}sonner.toast.error("Choose an image (PNG, JPEG, WebP) or a video (MP4, WebM).");}function z(s){s.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function j(){try{let s=await In(qt);Pe(s);}catch(s){sonner.toast.error(s instanceof Error?s.message:"Microphone unavailable");}}async function Xe(){if(U)try{let s=await U.stop();Se({blob:s.blob,durationMs:s.durationMs});}catch(s){sonner.toast.error(s instanceof Error?s.message:"Could not stop recording");}finally{Pe(null);}}function _r(){U?.cancel(),Pe(null),Se(null),Be(0);}function Jt(s){let g=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!U&&!ae?jsxRuntime.jsxs("button",{type:"button",onClick:j,className:s==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(zt,{}),"Record voice note"]}):null,U?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(wa,{stream:U.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[lt,"s / ",qt,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:Xe,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:_r,className:"lumen-btn-ghost",children:"Cancel"})]}):null,ae&&!U?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ea,{blob:ae.blob,durationMs:ae.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Se(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return s==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[g,!U&&!ae?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)"}),g]})}async function Fr(){_e(null);try{await u();}catch(s){sonner.toast.error(s instanceof Error?s.message:"Screen capture unavailable");}}function St(){we(null);}let Ur=b.kind==="ready";async function Qt(){U&&await Xe(),R===1?(b.kind==="ready"&&!Ce&&oe(pa(b.capture)),T(2)):await tn();}function en(){R>1&&T(s=>s-1);}async function tn(){if(b.kind!=="ready")return;let s=he.trim(),{capture:g}=b;N(true),A(0);try{let ie=await ue.current?.flatten()??g.blob,ce=await e.submit({rawText:s.length>0?s:void 0,category:Oe,priority:be||void 0,source:Ce||void 0,submitterEmail:ge.trim()||void 0,screenshot:ie,audio:ae?.blob,audioDurationMs:ae?.durationMs,video:ve?.blob,videoDurationMs:ve?.durationMs,context:An(g)},{onUploadProgress:Ee=>A(Math.min(.95,Ee))});A(1),sonner.toast.success("Feedback sent \u2014 thank you."),ce.id,n();}catch(D){sonner.toast.error(D instanceof Error?D.message:"Could not submit feedback"),N(false);}}function Vr(s){s.target===s.currentTarget&&!H&&n();}let qe=Math.round(F*100),dt=S==="video",zr=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,nn=S==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&zr,rn=R===1&&!Ur||H,$r=R<3?"Next":H?qe<95?`Uploading ${qe}%\u2026`:"Almost done\u2026":"Send feedback",mt=R===1,on=R===2&&b.kind==="ready",Wr=mt||on;return jsxRuntime.jsx("div",{ref:Ge,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Le.inset?{"--lumen-keyboard-inset":`${Le.inset}px`}:void 0,onMouseDown:Vr,children:jsxRuntime.jsxs("div",{ref:Ue,className:"lumen-modal","data-lumen-drawing":xe?"true":void 0,"data-lumen-fs":Wr?"true":void 0,"data-lumen-expanded":q?"true":void 0,"data-lumen-review":on?"true":void 0,"data-lumen-sheet":mt&&w?"down":void 0,children:[jsxRuntime.jsx(va,{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(ha,{step:R}),jsxRuntime.jsx("input",{ref:Te,type:"file",accept:"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime",style:{display:"none"},onChange:s=>{let g=s.currentTarget.files?.[0];g&&k(g),s.currentTarget.value="";}}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[R===1||R===2?jsxRuntime.jsx("div",{className:"lumen-pane",children:S===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-top",children:jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})})}),jsxRuntime.jsxs("div",{className:"lumen-fs-center lumen-fs-picker",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-picker-head",children:[jsxRuntime.jsx("div",{className:"lumen-fs-picker-title",children:"How do you want to capture?"}),jsxRuntime.jsx("div",{className:"lumen-fs-picker-sub",children:"Pick a method to report this."})]}),jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(s.primary?" lumen-method-primary":""),onClick:()=>ee(s.value),disabled:b.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(g,{})}),s.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]})]},s.value)})})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[b.kind!=="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsx("div",{className:"lumen-fs-pill",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>ee(s.value),disabled:b.kind==="capturing",children:jsxRuntime.jsx(g,{})},s.value)})})})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-center",children:[S==="video"&&b.kind==="idle"?jsxRuntime.jsx(ba,{canRecord:c,onRecord:Fr,onUpload:()=>ee("upload"),error:ut}):null,b.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,b.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:S==="upload"?"Choose an image or video to attach \u2014 or paste an image.":b.error?"Automatic capture was unavailable. Upload or paste an image to continue.":"Upload or paste an image to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:S==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:S==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:s=>{let g=s.currentTarget.files?.[0];g&&k(g),s.currentTarget.value="";}})]})]}):null]})]}):null,b.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[R===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-expand",onClick:()=>pe(s=>!s),"aria-pressed":q,"aria-label":q?"Shrink capture":"Expand capture",title:q?"Shrink":"Expand to full screen",children:q?jsxRuntime.jsx(Gn,{}):jsxRuntime.jsx(Yn,{})}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-fs-chip",onClick:()=>_(s=>!s),"aria-haspopup":"menu","aria-expanded":P,children:[jsxRuntime.jsx(Vt,{})," Recapture",jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},"aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),P?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-recap-overlay",onClick:()=>_(false)}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap-menu",role:"menu",children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),S&&ee(S);},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(Vt,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Re-snap this view"}),jsxRuntime.jsx("small",{children:"Instant \xB7 masks sensitive fields"})]})]}),nn?jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),p();},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(it,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Capture exact pixels"}),jsxRuntime.jsx("small",{children:"Real screen \u2014 canvas, video & charts"})]})]}):null]})]}):null]})]}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsxs("div",{className:"lumen-fs-pill",role:"group","aria-label":"Tools and capture method",children:[dt?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn lumen-fs-pentog","data-on":!ke,onClick:()=>h(s=>!s),"aria-label":"Toggle markup tools",title:"Toggle markup tools",children:jsxRuntime.jsx(Ut,{})}),jsxRuntime.jsx("span",{className:"lumen-fs-pill-sep"})]}),jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":S===s.value,"aria-label":s.label,onClick:()=>ee(s.value),children:jsxRuntime.jsx(g,{})},s.value)})]})})]}),!dt&&!ke?jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(Et,{label:"Arrow",icon:jsxRuntime.jsx($n,{}),active:J==="arrow",onClick:()=>I("arrow")}),jsxRuntime.jsx(Et,{label:"Box",icon:jsxRuntime.jsx(Wn,{}),active:J==="rect",onClick:()=>I("rect")}),jsxRuntime.jsx(Et,{label:"Draw",icon:jsxRuntime.jsx(Ut,{}),active:J==="freehand",onClick:()=>I("freehand")}),jsxRuntime.jsx(Et,{label:"Comment",icon:jsxRuntime.jsx(zn,{}),active:J==="comment",onClick:()=>I("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsxs("div",{className:"lumen-fs-color",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-color-btn",style:{background:$},"aria-label":"Pick colour","aria-haspopup":"true","aria-expanded":K,onClick:()=>re(s=>!s)}),K?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-color-overlay",onClick:()=>re(false)}),jsxRuntime.jsx("div",{className:"lumen-fs-color-pop",role:"group","aria-label":"Colour",children:Qn.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:s.value},"aria-label":s.label,"aria-pressed":$===s.value,onClick:()=>{G(s.value),re(false);}},s.value))})]}):null]}),mt?null:jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:er.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":s.label,"aria-pressed":W===s.value,onClick:()=>le(s.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:s.dot,height:s.dot}})},s.value))}),mt?null:jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>ue.current?.undo(),disabled:!Q.canUndo,"aria-label":"Undo",title:"Undo",children:jsxRuntime.jsx(Kn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>ue.current?.redo(),disabled:!Q.canRedo,"aria-label":"Redo",title:"Redo",children:jsxRuntime.jsx(qn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>ue.current?.reset(),disabled:!Q.canUndo,"aria-label":"Clear",title:"Clear",children:jsxRuntime.jsx(jn,{})})]}):null]}):null,jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Un,{ref:ue,screenshot:b.capture.blob,tool:J,color:$,strokeWidth:W,onDrawingChange:Fe,onHistoryChange:Ke})}),R===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>S&&ee(S),children:dt?"\u21BB Re-record":"\u21BB Recapture"}),nn?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(it,{})," Capture exact screen"]}):null,dt?ve?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ve.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:b.capture.method==="web-display-media"?"Exact screen captured":`${tr(S)} captured \xB7 switch method above anytime`})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-compose",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-grab",onClick:()=>x(s=>!s),"aria-label":w?"Expand sheet":"Minimize sheet"}),jsxRuntime.jsxs("div",{className:"lumen-fs-field",children:[jsxRuntime.jsx("input",{className:"lumen-input lumen-fs-desc",value:he,onChange:s=>V(s.target.value),placeholder:"Describe what's wrong \u2014 or use voice"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-mic",onClick:j,"aria-label":"Record voice note",children:jsxRuntime.jsx(zt,{})})]}),Jt("capture"),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-fs-next",onClick:Qt,disabled:rn,children:"Next"})]})]}):null]}):null]})}):null,R===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-rv-pane",children:[jsxRuntime.jsx("div",{className:"lumen-rv-scrim","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"lumen-rv",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-head",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-back",onClick:en,children:[jsxRuntime.jsx(Zn,{}),"Back"]}),jsxRuntime.jsx("span",{className:"lumen-rv-title",children:"Review & send"}),jsxRuntime.jsx("span",{className:"lumen-rv-spacer","aria-hidden":"true"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-rows",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Description"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 tap to edit"})]}),jsxRuntime.jsx("textarea",{className:"lumen-input lumen-rv-desc",value:he,onChange:s=>V(s.target.value),rows:2,placeholder:"Describe what's wrong\u2026"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Type"}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Type",children:ca.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":Oe===s.value,onClick:()=>He(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Priority"}),jsxRuntime.jsx("div",{className:"lumen-rv-prio",role:"group","aria-label":"Priority",children:da.filter(s=>s.value!=="").map(s=>jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-prio-opt","aria-pressed":be===s.value,onClick:()=>Me(be===s.value?"":s.value),children:[jsxRuntime.jsx(fa,{value:s.value}),s.label]},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Platform"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 auto-detected \u2014 change if wrong"})]}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Platform",children:ma.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":Ce===s.value,onClick:()=>oe(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-row",children:[jsxRuntime.jsx("span",{className:"lumen-rv-rk",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-rv-rv",children:[tr(S),Q.canUndo?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>T(1),children:"edit"})]})]}),Jt("describe"),jsxRuntime.jsx("div",{className:"lumen-rv-attachrow",children:ve?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ve.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:St,children:"\xD7"})]}):jsxRuntime.jsxs("label",{className:"lumen-rv-attach",children:[jsxRuntime.jsx(Ft,{}),"Attach a video",jsxRuntime.jsx("input",{type:"file",accept:"video/mp4,video/webm,video/quicktime",onChange:s=>{let g=s.currentTarget.files?.[0];g&&we({blob:g,durationMs:0}),s.currentTarget.value="";}})]})})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-rv-send",onClick:tn,disabled:H,children:H?qe<95?`Uploading ${qe}%\u2026`:"Almost done\u2026":jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Xn,{}),"Send feedback"]})})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[H?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":qe,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${qe}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:R===1?n:en,className:"lumen-btn-ghost",disabled:H,children:R===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:Qt,className:"lumen-btn-primary",disabled:rn,children:$r})]})]})]})})}function tr(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function ha({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 ba({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:ga()?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 ga(){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 Et({label:e,active:t,onClick:n,icon:r}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,"aria-label":r?e:void 0,title:e,children:r??e})}function va({onDismiss:e}){let t=Fn.useRef(null),n=Fn.useRef(0),r=Fn.useRef(null);function o(u){u.currentTarget.setPointerCapture(u.pointerId),t.current=u.clientY,n.current=performance.now(),r.current=u.currentTarget.parentElement;}function a(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current);r.current.style.transform=`translateY(${d}px)`;}function i(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current),c=Math.max(1,performance.now()-n.current),m=d/c;r.current.style.transform="",r.current.style.transition="",t.current=null,(d>80||m>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function wa({stream:e}){let t=Fn.useRef(null);return Fn.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 u=window.AudioContext??window.webkitAudioContext;if(!u)return;let d=new u,c=d.createMediaStreamSource(e),m=d.createAnalyser();m.fftSize=1024,m.smoothingTimeConstant=.6,c.connect(m);let p=new Uint8Array(m.fftSize),C=18,v=3,y=3,R=Math.max(2,(o-v*(C-1))/C),T=Math.min(R/2,3),S=new Array(C).fill(0),L=0,b=false;function E(){if(b)return;m.getByteTimeDomainData(p);let H=Math.floor(p.length/C);i.clearRect(0,0,o,a),i.fillStyle=Ca("--lumen-danger")||"rgb(239,68,68)";for(let N=0;N<C;N++){let F=0;for(let W=0;W<H;W++){let le=Math.abs((p[N*H+W]??128)-128);le>F&&(F=le);}let A=Math.min(1,F/128*1.8),J=S[N]??0;S[N]=A>J?A:J+(A-J)*.35;let I=Math.max(y,S[N]*a),$=N*(R+v),G=(a-I)/2;ya(i,$,G,R,I,T),i.fill();}L=requestAnimationFrame(E);}return L=requestAnimationFrame(E),()=>{b=true,cancelAnimationFrame(L);try{c.disconnect();}catch{}d.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function ya(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 Ea({blob:e,durationMs:t}){let[n,r]=Fn.useState("");return Fn.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 Ca(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var ka='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ra(e){return Array.from(e.querySelectorAll(ka)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var Ct=class extends Fn__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 ir({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Fn.useState(false);if(Fn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(xa,{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 xa({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Fn.useState(0);Fn.useEffect(()=>{let u=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));u();let d=window.setInterval(u,250);return ()=>window.clearInterval(d)},[e,t]);let i=u=>`${Math.floor(u/60)}:${String(u%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 sr({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Fn.useState(false);if(Fn.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,u=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:[u?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(it,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:u?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:u,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:u,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Gt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function lr(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function ur(e){return e instanceof Error?e:new Error(String(e))}function cr(e,t,n){let r=false,o=false,a=false,i=null;function u(){o||(o=true,n.onCancelled());}function d(m){o||(o=true,n.onResult(m));}function c(m){o||(o=true,n.onError(m));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(m=>{if(i=m,r){try{m.cancel();}catch{}u();return}if(n.onActive(m),a){n.onProcessing();try{m.stop();}catch{}}Promise.resolve(m.result).then(p=>{r?u():d(p);}).catch(p=>{r||lr(p)?u():c(ur(p));});}).catch(m=>{r||lr(m)?u():c(ur(m));}),{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{}u();}}}}function dr(){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 u=document.elementsFromPoint(i,n);for(let d of u){if(o.has(d))continue;o.add(d);let c=window.getComputedStyle(d);if(c.position!=="fixed"&&c.position!=="sticky")continue;let m=d.getBoundingClientRect();m.bottom<t-8||m.bottom>t+8||m.width<e*.6||m.height>a&&(a=m.height);}}return a}function Zt(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 u of Array.from(i)){let d=u.getBoundingClientRect();if(d.height===0||d.width===0)continue;let c=0;switch(t){case "bottom":if(d.bottom<r-8)break;c=Math.max(0,r-d.top);break;case "top":if(d.top>8)break;c=Math.max(0,d.bottom);break;case "left":if(d.left>8)break;c=Math.max(0,d.right);break;case "right":if(d.right<n-8)break;c=Math.max(0,n-d.left);break}c>o&&(o=c);}}return o}function mr(e){let[t,n]=Fn.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Fn.useRef(t),o=Da(e.avoid),a=e.placement,i=e.offset.x,u=e.offset.y;return Fn.useEffect(()=>{if(typeof window>"u")return;let d=0,c=false,m=()=>{if(d=0,c)return;let R=a[0]==="b"?"bottom":"top",T=a[1]==="r"?"right":"left",S=0,L=0;e.avoid==="auto"&&R==="bottom"?S=dr():Array.isArray(e.avoid)&&(S=Zt(e.avoid,R),L=Zt(e.avoid,T));let b={bottom:R==="bottom"?u+S:0,top:R==="top"?u+S:0,right:T==="right"?i+L:0,left:T==="left"?i+L:0},E=r.current;(b.bottom!==E.bottom||b.top!==E.top||b.right!==E.right||b.left!==E.left)&&(r.current=b,n(b));},p=()=>{d||(d=window.requestAnimationFrame(m));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let v=typeof MutationObserver<"u"?new MutationObserver(p):null;v?.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),()=>{c=true,d&&window.cancelAnimationFrame(d),C?.disconnect(),v?.disconnect(),window.removeEventListener("resize",p),y?.removeEventListener("resize",p),y?.removeEventListener("scroll",p);}},[a,i,u,o]),t}function Da(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var pr=["mousedown","touchstart"];function Ye(e){let t=Fn.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Fn.useRef(e.onClick);n.current=e.onClick;let r=Fn.useRef(e.isolate??true);r.current=e.isolate??true;let o=Fn.useRef(null);return Fn.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=c=>{r.current&&c.stopPropagation(),t.current?.(c);},u=c=>{r.current&&c.stopPropagation(),n.current(c);},d=c=>{r.current&&c.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",u);for(let c of pr)a.addEventListener(c,d,c==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",u);for(let c of pr)a.removeEventListener(c,d);};},[])}function gr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[u,d]=Fn.useState(null),c=Fn.useRef(null),m=mr(e),p=ot(e.keyboard!=="off",i),C=Ye({onPointerDown:r,onClick:o,isolate:a}),v=Fn.useCallback(A=>{c.current=A,C(A);},[C]);Fn.useEffect(()=>{typeof document>"u"||d(t??document.body);},[t]);let y=e.placement,R=y[0]==="b"?"bottom":"top",T=y[1]==="r"?"right":"left",S=R==="bottom",L=p.open&&S&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,b=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&S&&p.inset<=0);if(Fa(c,!n&&!b),!u)return null;let E=R==="bottom"?m.bottom:m.top,H=T==="right"?m.right:m.left,N=n||b,F={position:"fixed",[R]:e.safeArea?`calc(${E}px + env(safe-area-inset-${R}, 0px))`:`${E}px`,[T]:e.safeArea?`calc(${H}px + env(safe-area-inset-${T}, 0px))`:`${H}px`,zIndex:e.zIndex,transform:L?`translateY(-${L}px)`:void 0,opacity:N?0:1,pointerEvents:N?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:v,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:F,"aria-label":e.label,"aria-hidden":N?true:void 0,tabIndex:N?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),u)}function Fa(e,t){let n=Fn.useRef(false);Fn.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,u=a.top+a.height/2,d=document.elementsFromPoint(i,u),c=fr(window.getComputedStyle(o).zIndex);for(let m of d){if(m===o||o.contains(m))continue;if(fr(window.getComputedStyle(m).zIndex)>c){n.current=true,console.warn("[lumen] trigger is occluded by",m);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function fr(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function vr({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=Fn.useState(null),d=Ye({onPointerDown:r,onClick:o,isolate:a});return Fn.useEffect(()=>{if(typeof document>"u")return;let c=e instanceof HTMLElement?e:e.current??null;u(c);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:d,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 Er({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=Fn.useState(null),[d,c]=Fn.useState(false),m=Fn.useRef(null),p=Ye({onPointerDown:T=>{r?.(T),m.current={x:T.clientX,y:T.clientY},c(true);let S=T.currentTarget;try{S?.setPointerCapture?.(T.pointerId);}catch{}},onClick:o,isolate:a});if(Fn.useEffect(()=>{typeof document>"u"||u(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${d?" lumen-notch-expanded":""}`;function v(T){let S=m.current;if(!S)return;let L=T.clientX-S.x,b=T.clientY-S.y;(e.edge==="top"&&b>16||e.edge==="bottom"&&b<-16||e.edge==="right"&&L<-16||e.edge==="left"&&L>16)&&(m.current=null,o(T.nativeEvent));}function y(){m.current=null,c(false);}function R(){m.current=null,c(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:C,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:v,onPointerUp:y,onPointerCancel:R,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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 Cr(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function Xa(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function kr(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:Xa(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var ei={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function Rr(e){let t=Fn.useId();Fn.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${ti(t)}`,o={},a=(i,u)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,u);};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,u]of Object.entries(ei)){let d=e[u];typeof d=="string"&&d.length>0&&a(i,d);}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,u]of Object.entries(o))i.startsWith("--")?u?n.style.setProperty(i,u):n.style.removeProperty(i):u==null?n.removeAttribute(i):n.setAttribute(i,u);}},[e,t]);}function ti(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Sr=Symbol.for("lumen.history.patched"),Xt="lumen:locationchange";function oi(){if(typeof window>"u")return;let e=window;if(e[Sr])return;e[Sr]=true;let t=()=>window.dispatchEvent(new Event(Xt)),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 xr(e){let[t,n]=Fn.useState(false);return Fn.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;oi();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Xt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Xt,r),window.removeEventListener("popstate",r);}},[e]),t}var si=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function Mr(){let[e,t]=Fn.useState(false);return Fn.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||"";si.some(a=>o.includes(a))&&t(true);},[]),e}var Tr="lumen.config.v1.",ci=3600*1e3;function Lr(e,t){let[n,r]=Fn.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Fn.useEffect(()=>{if(typeof window>"u")return;let o=bi(e);o&&r({trigger:o.trigger,enabled:Pr(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),u=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(u,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.json(),m=Nr(c.trigger);if(!m)throw new Error("Malformed config response");let p=pi(c.trigger),C=Ar(c.brand);gi(e,m,p,C),r({trigger:m,enabled:Pr(m),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(d=>d.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:d);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Pr(e){return e.kind!=="headless"}var di=["br","bl","tr","tl"],mi=["top","right","bottom","left"];function Nr(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:di.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:mi.find(o=>o===t.edge)??"top",label:n}:null}function pi(e){return !e||typeof e!="object"?false:e.shake===true}var fi=/^#[0-9a-fA-F]{6}$/,hi=["auto","light","dark"];function Ar(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&fi.test(t.accent)?t.accent:null;if(!n)return null;let r=hi.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 bi(e){try{let t=window.localStorage.getItem(Tr+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>ci)return null;let r=Nr(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:Ar(n.brand)}:null}catch{return null}}function gi(e,t,n,r){try{window.localStorage.setItem(Tr+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function wi(e){if(e&&typeof e=="object")return e.type===vt;if(typeof e=="string")try{return JSON.parse(e).type===vt}catch{return false}return false}function yi(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(u,d,c,m){if(!a)return a={x:u,y:d,z:c,t:m},false;if(m-a.t<o)return false;let p=Math.abs(u-a.x)+Math.abs(d-a.y)+Math.abs(c-a.z);return a={x:u,y:d,z:c,t:m},p<t?false:(i=i.filter(C=>m-C<r),i.push(m),i.length>=n?(i=[],true):false)}}}function Ir(e,t,n){Fn.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let m=Date.now();n||m-r<o||(r=m,t());}let i=m=>{wi(m.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let u=yi(),d=m=>{let p=m.accelerationIncludingGravity??m.acceleration;!p||p.x==null||p.y==null||p.z==null||u.push(p.x,p.y,p.z,Date.now())&&a();},c=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return c&&window.addEventListener("devicemotion",d),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),c&&window.removeEventListener("devicemotion",d);}},[e,t,n]);}var Or="https://shakebugs.vercel.app",Rt=60;function Hr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function ki({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:u,portalTarget:d,capture:c,record:m,shakeToOpen:p,onOpenChange:C,beforeOpen:v,onTriggerActivate:y,isolateEvents:R=true,keyboardInset:T,suppressTrigger:S=false,children:L}){let[b,E]=Fn.useState(false),[H,N]=Fn.useState(false),[F,A]=Fn.useState(null),[J,I]=Fn.useState(null),[$]=Fn.useState(false),[G]=Fn.useState(null),W=Fn.useRef(false),le=Fn.useRef(false),he=Fn.useRef(null),V=Fn.useMemo(()=>new vn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Fn.useEffect(()=>{Ln({ignoreUrlPrefix:(t??Or).replace(/\/$/,"")});},[t]);let Oe=Fn.useRef(C);Oe.current=C,Fn.useEffect(()=>{if(!(typeof document>"u"))return b?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[b]);let He=Fn.useRef(null);Fn.useEffect(()=>{if(He.current===b)return;let k=He.current;He.current=b,k!==null&&Oe.current?.(b);},[b]);let be=Fn.useRef(v);be.current=v;let Me=Fn.useRef(y);Me.current=y;let Ce=Fn.useCallback(k=>{le.current=true,he.current=Promise.resolve().then(()=>be.current?.(k)).then(()=>Me.current?.(k)).then(()=>{});},[]),oe=Fn.useCallback(k=>{W.current||b||Re.current||ue.current||(W.current=true,N(true),A(null),I(null),(async()=>{try{if(le.current?await he.current:(await be.current?.(k),await Me.current?.(k)),c?.mode==="manual")A(null),I(null);else if(c?.provider)A(null),I(null);else {let z=await bt({...c,mode:c?.mode??"auto",target:c?.target??document.documentElement});A(z);}}catch(z){I(z instanceof Error?z:new Error(String(z)));}finally{le.current=false,he.current=null,W.current=false,N(false),E(true);}})());},[c,b]),ke=Fn.useCallback(()=>{E(false),A(null),I(null);},[]),h=Fn.useCallback(V.submit.bind(V),[V]),[w,x]=Fn.useState(0),P=Fn.useCallback(()=>{W.current=false,N(false),E(false),A(null),I(null),x(k=>k+1);},[]),[_,K]=Fn.useState(null),[re,q]=Fn.useState(null),pe=Fn.useRef(null),ge=Fn.useRef(null),Re=Fn.useRef(false),U=Fn.useRef(null),Pe=Fn.useRef(null),ae=Fn.useRef(null),Se=Fn.useCallback((k,z=false)=>{if(pe.current=null,ge.current=null,Re.current=false,K(null),!k){U.current=null;return}Pe.current={blob:k.blob,durationMs:k.durationMs,poster:U.current,deriveBlobPoster:z},U.current=null,E(true);},[]);Fn.useEffect(()=>{if(!b)return;if(!m?.provider){q(null);return}let k=m.isAvailable;if(!k){q(true);return}let z=false;return Promise.resolve().then(()=>k()).then(j=>{z||q(j);}).catch(()=>{z||q(false);}),()=>{z=true;}},[b,m?.provider,m?.isAvailable]);let lt=Gt({hasProvider:!!m?.provider,providerAvailable:re,hasGetDisplayMedia:Hr()}).canRecord,Be=Fn.useCallback(async()=>{if(Re.current)return;if(ae.current=null,Gt({hasProvider:!!m?.provider,providerAvailable:re,hasGetDisplayMedia:Hr()}).usingProvider&&m?.provider){Re.current=true,U.current=null,E(false),ge.current=cr(m.provider,{maxDurationSeconds:Rt},{onStarting:()=>K({phase:"starting"}),onActive:j=>{K({phase:"recording",stream:j.stream??null,startedAt:Date.now(),maxSeconds:Rt}),j.stream&&Wt(j.stream).then(Xe=>{U.current=Xe;}).catch(()=>{});},onProcessing:()=>K({phase:"processing"}),onResult:j=>Se({blob:j.blob,durationMs:j.durationMs},true),onCancelled:()=>{ge.current=null,Re.current=false,U.current=null,K(null),A(null),I(null),E(true);},onError:j=>{ge.current=null,Re.current=false,U.current=null,K(null),ae.current=j.message||"Screen recording could not start.",E(true);}});return}if(pe.current)return;let z=await Dn(Rt);pe.current=z,Re.current=true,U.current=null,K({phase:"recording",stream:z.stream,startedAt:Date.now(),maxSeconds:Rt}),E(false),Wt(z.stream).then(j=>{U.current=j;}).catch(()=>{}),z.result.then(j=>Se(j)).catch(()=>Se(null));},[Se,m?.provider,re]),ve=Fn.useCallback(()=>{ge.current?ge.current.stop():pe.current?.stop();},[]),we=Fn.useCallback(()=>{if(ge.current){ge.current.cancel();return}let k=pe.current;pe.current=null,Re.current=false,U.current=null,K(null),k?.cancel(),A(null),I(null),E(true);},[]),ut=Fn.useCallback(()=>{let k=Pe.current;return Pe.current=null,k},[]),_e=Fn.useCallback(()=>{let k=ae.current;return ae.current=null,k},[]);Fn.useEffect(()=>{b||(ae.current=null);},[b]);let[xe,Fe]=Fn.useState(null),Q=Fn.useRef(null),Ke=Fn.useRef(null),ue=Fn.useRef(false),Te=Fn.useCallback(()=>{let k=Q.current;Q.current=null,ue.current=false,k?.stop(),Fe(null),E(true);},[]),Ue=Fn.useCallback(()=>{let k=Q.current;k&&(Fe({phase:"grabbing"}),(async()=>{try{let z=await k.grab();if(Q.current!==k)return;Ke.current=z,Q.current=null,ue.current=!1,k.stop(),Fe(null),E(!0);}catch{if(Q.current!==k)return;Q.current=null,ue.current=false,k.stop(),Fe(null),sonner.toast.error("Could not capture the screen. Please try again."),E(true);}})());},[]),Ge=Fn.useCallback(async()=>{if(ue.current)return;let k;try{k=await Nt({...c});}catch{return}Q.current=k,ue.current=true,k.onEnded(()=>Te()),Fe({phase:"live"}),E(false);},[c,Te]),Ze=Fn.useCallback(()=>{let k=Ke.current;return Ke.current=null,k},[]);Fn.useEffect(()=>()=>{Q.current?.stop(),Q.current=null;},[]);let Le=Mr(),ye=xr(i),Ne=Lr(a?"":e,t??Or);Rr(u??xi(Ne.brand));let Ve=p??Ne.shakeToOpen;Ir(Ve,oe,b);let ct=Fn.useMemo(()=>({client:V,user:n,isOpen:b,isSubmitting:$,error:G,open:oe,close:ke,openCapture:oe,closeCapture:ke,submit:h,isNativeShell:Le,capture:c,initialCapture:F,initialCaptureError:J,isOpening:H,startVideoSession:Be,stopVideoSession:ve,cancelVideoSession:we,recording:_,consumePendingVideo:ut,canRecordScreen:lt,consumeRecordStartError:_e,startScreenCaptureSession:Ge,grabScreenCaptureFrame:Ue,cancelScreenCaptureSession:Te,screenCapture:xe,consumePendingScreenshot:Ze,isolateEvents:R,keyboardInset:T}),[V,n,b,$,G,oe,ke,h,Le,c,F,J,Be,ve,we,_,ut,lt,_e,Ge,Ue,Te,xe,Ze,H,R,T]),ee=Si({explicit:a,remote:Ne.trigger,remoteLoading:Ne.loading,floatingButton:o});return jsxRuntime.jsxs(Ot.Provider,{value:ct,children:[L,jsxRuntime.jsxs(Ct,{onReset:P,onError:k=>V.reportClientError({...k,context:{open:b,opening:H,screenCapturePhase:xe?.phase,recordingPhase:_?.phase,initialCaptureMethod:F?.method,initialCapturePixelRatio:F?.pixelRatio,initialCaptureViewport:F?.viewport,hadInitialCaptureError:J!=null}}),children:[ee?.kind==="floating"?jsxRuntime.jsx(gr,{config:kr(ee),portalTarget:d,hidden:ye||S||H||_!=null||xe!=null,onPointerDown:Ce,onClick:k=>oe(k),isolateEvents:R,keyboardInset:T}):null,ee?.kind==="notch"?jsxRuntime.jsx(Er,{config:Cr(ee),portalTarget:d,hidden:ye||S||H||_!=null||xe!=null,onPointerDown:Ce,onClick:k=>oe(k),isolateEvents:R}):null,ee?.kind==="inline"?jsxRuntime.jsx(vr,{mount:ee.mount,label:ee.label??"Feedback",icon:ee.icon,onPointerDown:Ce,onClick:k=>oe(k),isolateEvents:R}):null,xe?jsxRuntime.jsx(sr,{state:xe,portalTarget:d,onCapture:Ue,onCancel:Te}):null,_?jsxRuntime.jsx(ir,{state:_,portalTarget:d,onStop:ve,onCancel:we}):null,jsxRuntime.jsx(Yt,{})]},w),jsxRuntime.jsx(Ri,{})]})}function Ri(){let[e,t]=Fn.useState(false);return Fn.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Si(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function xi(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Mi({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=nt(),u=["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:u,"data-lumen-trigger":"",onClick:d=>{o?.(d),d.defaultPrevented||i(d.nativeEvent);},...a,children:r})}
|
|
5
|
-
exports.CaptureModal=Yt;exports.FeedbackButton=Mi;exports.LUMEN_KEYBOARD_CSS_VAR=It;exports.LUMEN_KEYBOARD_EVENT=tt;exports.LUMEN_SHAKE_MESSAGE=vt;exports.LumenProvider=
|
|
2
|
+
'use strict';var Un=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 Un__namespace=/*#__PURE__*/_interopNamespace(Un);var I=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},an=class extends I{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},sn=class extends I{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},pt=class extends I{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},qr="https://shakebugs.vercel.app",jr="/api/v1/sdk/submit",Yr="/api/v1/sdk/error",ln="0.15.1",Gr=5,Zr=new Set([502,503,504]),wn=class{apiKey;apiUrl;user;amplitude;#e=new Set;#t=0;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new I("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??qr).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${jr}`,r=this.#n(e),o=null;for(let a=0;a<3;a++){a>0&&await Jr(2**a*250);try{return await this.#r(n,r,t)}catch(i){if(o=i,i instanceof an||i instanceof sn||i instanceof I&&typeof i.status=="number"&&!Zr.has(i.status))throw i}}throw o instanceof Error?o:new pt("Submit failed after 3 attempts.")}reportClientError(e){try{if(typeof window>"u"||this.#t>=Gr)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 u=new URL(window.location.href);a=u.origin+u.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:ln,context:e.context};fetch(`${this.apiUrl}${Yr}`,{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;t.append("sdkVersion",ln),e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),e.priority&&t.append("priority",e.priority),e.source&&t.append("source",e.source),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:u}=n;i&&a.upload.addEventListener("progress",c=>{c.lengthComputable&&c.total>0&&i(Math.min(1,c.loaded/c.total));});let d=()=>{a.abort(),o(new pt("Submit aborted."));};if(u){if(u.aborted){o(new pt("Submit aborted."));return}u.addEventListener("abort",d,{once:true});}a.addEventListener("load",()=>{if(u&&u.removeEventListener("abort",d),a.status===403){o(new an);return}if(a.status===429){let c=Number(a.getResponseHeader("Retry-After"))||60;o(new sn(c));return}if(a.status<200||a.status>=300){o(new I(Qr(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let c=JSON.parse(a.responseText);r(c);}catch{o(new I("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{u&&u.removeEventListener("abort",d),o(new pt("Network error during submit."));}),a.send(t);})}};function Xr(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Jr(e){return new Promise(t=>setTimeout(t,e))}function Qr(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var yn='[data-lumen-root], [data-lumen-capture-ignore="true"]';function En(e=yn){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 eo=2,to=1.5,no=820,ro=12,Je=8*1024*1024;async function bt(e={}){At();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return co(await e.provider(),e)}catch(n){if(t==="custom")throw n;e.onWarning?.(["Custom capture provider failed; falling back to browser DOM capture."]);}if(t==="manual")throw new I("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return mn(e);if(t==="dom")return cn(e);if(t==="custom")throw new I("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await cn(e)}catch(n){if(xn()){let r=await mn(e);return r.warnings=et(["DOM screenshot failed; used browser screen permission fallback.",...r.warnings]),e.onWarning?.(r.warnings),r}throw n}}function Qe(e,t=[]){At();let n=gt();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:et(t)}}var un=Promise.resolve();function cn(e){let t=un.then(()=>dn(e),()=>dn(e));return un=t.catch(()=>{}),t}async function dn(e){let t=await uo(),n=e.target??document.documentElement,r=gt(),o=po(),a=window.visualViewport,i=window.scrollX+(a?.offsetLeft??0),u=window.scrollY+(a?.offsetTop??0),d=fo(e,r.width,r.height),c=mo(n);!e.provider&&lo()&&c.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 m=io(n);await Sn(e.awaitAnimationsMs??go),await bo();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:u,scale:d,ignoreElements:k=>k instanceof HTMLElement&&(k.dataset.lumenCaptureIgnore==="true"||!!k.closest("[data-lumen-capture-ignore='true']")),onclone:(k,y)=>{so(y,m),oo(k);}}),C={blob:await kn(p,c),method:"web-dom",platform:"web",viewport:r,pixelRatio:d,warnings:et(c)};return C.warnings.length>0&&e.onWarning?.(C.warnings),C}var Cn=['input[type="password"]','input[autocomplete^="cc-"]','input[autocomplete="one-time-code"]',"[data-lumen-mask]"].join(", ");function oo(e){for(let t of Array.from(e.querySelectorAll(Cn))){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 ao="[data-lumen-root], [data-lumen-capture-ignore='true']";function Rn(e){return Array.from(e.querySelectorAll("input")).filter(t=>!t.closest(ao))}function io(e){return Rn(e).map(t=>{if(t.matches(Cn))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 so(e,t){let n=Rn(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 lo(){return typeof window<"u"&&typeof window.ReactNativeWebView<"u"}async function uo(){let{default:e}=await import('html2canvas-pro');return e}async function Nt(e={}){if(At(),!xn())throw new I("Browser screen capture is unavailable in this environment.","DISPLAY_MEDIA_UNAVAILABLE");let t=await navigator.mediaDevices.getDisplayMedia({video:true,audio:false}),n=null;try{n=document.createElement("video"),n.muted=!0,n.playsInline=!0,n.srcObject=t,await vo(n);}catch(i){for(let u of t.getTracks())u.stop();throw i}let r=n,o=false,a=[];for(let i of t.getTracks())i.addEventListener("ended",()=>{o||a.forEach(u=>u());});return {stream:t,onEnded(i){a.push(i);},async grab(i){let u=i?.conceal??true,d=u?En():()=>{};try{u&&await wo(r,3,400);let c=document.createElement("canvas");c.width=r.videoWidth,c.height=r.videoHeight;let m=c.getContext("2d");if(!m)throw new I("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");m.drawImage(r,0,0,c.width,c.height);let p=gt(),C=["Browser screen capture uses the window or tab selected by the user."],k={blob:await kn(c,C),method:"web-display-media",platform:"web",viewport:p,pixelRatio:p.width>0?c.width/p.width:void 0,warnings:et(C)};return e.onWarning?.(k.warnings),k}finally{d();}},stop(){if(!o){o=true;for(let i of t.getTracks())i.stop();r.srcObject=null;}}}}async function mn(e){let t=await Nt(e);try{return await t.grab({conceal:!1})}finally{t.stop();}}function co(e,t){let n=gt(),r={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:et(e.warnings??[])};return r.warnings.length>0&&t.onWarning?.(r.warnings),r}function mo(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 kn(e,t){let n=await pn(e,"image/png",.92);if(n.size<=Je)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let r=e,o=0;for(;n.size>Je&&o<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(Je/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 u=i.getContext("2d");if(!u)return n;u.drawImage(r,0,0,i.width,i.height),r=i;for(let d of [.86,.74,.62,.5])if(n=await pn(r,"image/jpeg",d),n.size<=Je)return n;if(o+=1,i.width<480||i.height<320)break}return n.size>Je&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function pn(e,t,n){return new Promise((r,o)=>{e.toBlob(a=>{if(!a){o(new I("Could not encode screenshot.","ENCODE_FAILED"));return}r(a);},t,n);})}function gt(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function po(){let e=document.documentElement;return {width:Math.round(e.clientWidth||window.innerWidth),height:Math.round(e.clientHeight||window.innerHeight)}}function fo(e,t,n){let r=window.devicePixelRatio??1,o=e.maxScale??eo;ho()&&(o=Math.min(o,to));let a=Math.max(1,Math.min(r,o)),i=Math.sqrt(ro*1e6/Math.max(1,t*n));return Math.max(1,Math.min(a,i))}function ho(){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<=no}function bo(){return typeof requestAnimationFrame!="function"?new Promise(e=>setTimeout(e,32)):new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())))}var go=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 xn(){return !!navigator.mediaDevices?.getDisplayMedia}async function vo(e){await new Promise((r,o)=>{let a=()=>r(),i=()=>o(new I("Could not read screen capture video.","VIDEO_FAILED"));e.addEventListener("loadedmetadata",a,{once:true}),e.addEventListener("error",i,{once:true}),e.play().catch(i);});let t=performance.now(),n=1500;for(;e.videoWidth===0||e.videoHeight===0;){if(performance.now()-t>n)throw new I("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(r=>requestAnimationFrame(()=>r()));}}async function wo(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 u=()=>{if(a+=1,a>=t||performance.now()-o>=n){i();return}r(u);};r(u),setTimeout(i,n);});}function At(){if(typeof window>"u"||typeof document>"u")throw new I("Screenshot capture can only run in the browser.","INVALID_ENV")}function et(e){return Array.from(new Set(e.filter(Boolean)))}var Mn=/^(token|access_token|refresh_token|id_token|api_?key|key|secret|password|passwd|pwd|auth|authorization|sig|signature|session|sessionid|sid|email|jwt)$/i,yo=[/-----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 Eo(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 Mt(e){let t=e;for(let n of yo)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:Mn.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=>Eo(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 Pn(e){try{let t=new URL(e,"http://relative.invalid");for(let r of [...t.searchParams.keys()])Mn.test(r)&&t.searchParams.set(r,"***");t.hash="";let n=t.toString();return Mt(t.host==="relative.invalid"?n.replace(/^http:\/\/relative\.invalid/,""):n)}catch{return Mt(e)}}function Tn(e){try{let t=new URL(e);return `${t.origin}${t.pathname}`}catch{return Pn(e)}}var fn=200,hn=4096,Ln=[],ft=[],bn=false,Pt=null;function Nn(e={}){bn||typeof window>"u"||(bn=true,Pt=e.ignoreUrlPrefix??null,So(),xo(),Mo());}function Co(){return {consoleLog:Ln.slice(),networkLog:ft.slice()}}function ht(e,t){e.push(t),e.length>fn&&e.splice(0,e.length-fn);}function Ro(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,ko));}catch{t.push(String(r));}}let n=t.join(" ");return n.length>hn?n.slice(0,hn)+"\u2026[truncated]":n}function ko(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function So(){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{ht(Ln,{level:n,ts:Date.now(),message:Mt(Ro(o))});}catch{}r(...o);});}}function An(e){return Pt?e.startsWith(Pt):false}function xo(){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(An(r))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ht(ft,{type:"fetch",method:o,url:Tt(r),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ht(ft,{type:"fetch",method:o,url:Tt(r),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function Mo(){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&&!An(o.url)){o.t=performance.now();let a=()=>{try{ht(ft,{type:"xhr",method:o.method,url:Tt(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 Po(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Tt(e){return Po(Pn(e))}function In(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:gn(e),consoleLog:[],networkLog:[]};let t=Co();return {url:Tn(window.location.href),userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:gn(e),device:To(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function To(){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?Tn(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 gn(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}var Lo="[data-lumen-root]",No="[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(Lt(n))return true;return Lt(e.target)}var vn=["pointerdown","mousedown","touchstart","click"];function Io(e){if(!e||typeof e.addEventListener!="function")return ()=>{};let t=n=>n.stopPropagation();for(let n of vn)e.addEventListener(n,t,n==="touchstart"?{passive:true}:void 0);return ()=>{for(let n of vn)e.removeEventListener(n,t);}}function Lt(e){return e?typeof Element<"u"&&e instanceof Element?e.matches(No)?true:!!e.closest(Lo):typeof ShadowRoot<"u"&&e instanceof ShadowRoot?Lt(e.host):false:false}var vt="lumen:shake",Do=8e3,Oo=50,Bo=400;function Ho(e={}){return async function(){if(typeof window>"u")throw new I("Native capture bridge requires a WebView/browser window.","INVALID_ENV");let t=Fo(),n=e.send??_o,r=e.timeoutMs??Do,o=e.captureSettleMs??Oo,a=e.awaitAnimationsMs??Bo,i=Wo(),u=En(e.concealSelector===void 0?yn:e.concealSelector);try{await Vo(o,a);let d=await new Promise((p,C)=>{let k=window.setTimeout(()=>{t.pending.delete(i),C(new I("Native screenshot timed out; the host did not respond.","NATIVE_CAPTURE_TIMEOUT"));},r);t.pending.set(i,{resolve:y=>{window.clearTimeout(k),p(y);},reject:y=>{window.clearTimeout(k),C(y);}});try{n({type:"lumen:capture-request",id:i,afterScreenUpdates:!0});}catch{t.pending.delete(i),window.clearTimeout(k),C(new I("Could not reach the native host for screen capture.","NATIVE_CAPTURE_UNAVAILABLE"));}});if(d.error||!d.dataUrl)throw new I(d.error??"Native screenshot returned no image.","NATIVE_CAPTURE_FAILED");let c=Ko(d.dataUrl),m=e.platform??$o();return {blob:c,method:m==="android"?"android-native":"ios-native",platform:m,viewport:{width:Math.round(window.innerWidth),height:Math.round(window.innerHeight)},pixelRatio:d.pixelRatio??window.devicePixelRatio??1,warnings:[]}}finally{u();}}}function _o(e){let t=window.ReactNativeWebView;if(!t?.postMessage)throw new I("window.ReactNativeWebView is unavailable; pass a custom `send`.","NATIVE_CAPTURE_UNAVAILABLE");t.postMessage(JSON.stringify(e));}function Fo(){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=Uo(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 Uo(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 Vo(e,t){await Sn(t),await zo(),e>0&&await new Promise(n=>window.setTimeout(n,e));}function zo(){return new Promise(e=>{requestAnimationFrame(()=>e());})}function $o(){let e=navigator.userAgent||"";return /android/i.test(e)?"android":"ios"}function Wo(){return `lumen-cap-${typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function Ko(e){let t=/^data:([^;,]*)(;base64)?,(.*)$/s.exec(e);if(!t)throw new I("Native host returned an invalid image data URL.","NATIVE_CAPTURE_FAILED");let n=t[1]||"image/png",r=!!t[2],o=t[3]??"";if(!r)return new Blob([decodeURIComponent(o)],{type:n});let a=atob(o),i=new Uint8Array(a.length);for(let u=0;u<a.length;u++)i[u]=a.charCodeAt(u);return new Blob([i],{type:n})}var tt="lumen:keyboardchange",It="--lumen-keyboard-inset";function qo(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(It,`${t}px`),window.dispatchEvent(new Event(tt));}function Dt(){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(It).trim();if(t){let n=parseFloat(t);if(Number.isFinite(n)&&n>=0)return n}}return null}async function Dn(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new I("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new I("Microphone access denied or unavailable.","MIC_DENIED")}let n=window.AudioContext??window.webkitAudioContext,r=null,o=null,a=t;if(n)try{r=new n,r.state==="suspended"&&r.resume().catch(()=>{});let x=r.createMediaStreamSource(t);o=r.createAnalyser(),o.fftSize=1024,o.smoothingTimeConstant=.6,x.connect(o);let f=r.createMediaStreamDestination();x.connect(f),a=f.stream;}catch{r&&r.close().catch(()=>{}),r=null,o=null,a=t;}let i=()=>{for(let x of t.getTracks())x.stop();r&&r.state!=="closed"&&r.close().catch(()=>{});},u=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(x=>MediaRecorder.isTypeSupported(x))??"",d=new MediaRecorder(a,u?{mimeType:u}:void 0),c=[],m=performance.now(),p=null,C=false,k=false,y,S,T=new Promise((x,f)=>{y=x,S=f;});T.catch(()=>{}),d.addEventListener("dataavailable",x=>{x.data&&x.data.size>0&&c.push(x.data);}),d.addEventListener("stop",()=>{if(p!==null&&window.clearTimeout(p),p=null,i(),k)return;if(k=true,C){S(new I("Recording cancelled.","RECORDER_STOPPED"));return}let x=performance.now()-m,f=d.mimeType||u||"audio/webm",w=new Blob(c,{type:f});y({blob:w,durationMs:x,mimeType:f});}),d.start(),p=window.setTimeout(()=>{d.state!=="inactive"&&d.stop();},e*1e3);function R(){if(d.state!=="inactive")try{d.stop();}catch{}}return {stream:t,analyser:o,cancel(){C=true,R(),p!==null&&window.clearTimeout(p),p=null,i();},stop(){return R(),T}}}async function On(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new I("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new I("Screen capture was denied or cancelled.","SCREEN_DENIED")}let n=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(y=>MediaRecorder.isTypeSupported(y))??"",r=new MediaRecorder(t,n?{mimeType:n}:void 0),o=[],a=performance.now(),i=null,u=false,d=false,c,m,p=new Promise((y,S)=>{c=y,m=S;});p.catch(()=>{});function C(){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(u)return;if(u=true,C(),d){m(new I("Recording cancelled.","RECORDER_STOPPED"));return}let y=r.mimeType||n||"video/webm";c({blob:new Blob(o,{type:y}),durationMs:performance.now()-a,mimeType:y});});function k(){r.state!=="inactive"&&r.stop();}return r.start(),i=window.setTimeout(k,e*1e3),t.getVideoTracks()[0]?.addEventListener("ended",k),{stream:t,result:p,stop:k,cancel(){d=true,r.state!=="inactive"?r.stop():u||(u=true,C(),m(new I("Recording cancelled.","RECORDER_STOPPED")));}}}var Ot=Un.createContext(null);function nt(){let e=Un.useContext(Ot);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var Bn=100;function Hn(){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 rt={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)}:rt}if(e.vvHeight==null||!e.coarse||!e.editable)return rt;let n=e.vvBaseline-e.vvHeight;return n>Bn?{open:true,inset:Math.round(n)}:rt}function ot(e,t){let[n,r]=Un.useState(rt),o=Un.useRef(0),a=Un.useRef(t);return a.current=t,Un.useEffect(()=>{if(!e){r(rt);return}if(typeof window>"u")return;let i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,u=()=>{let p=Hn(),C=a.current,k=Dt(),y=window.visualViewport??null;y&&C==null&&k==null&&!p&&(o.current=y.height),r(Xo({editable:p,override:C,injected:k,vvBaseline:o.current,vvHeight:y?y.height:null,coarse:i}));},d=0,c=()=>{d||(d=window.requestAnimationFrame(()=>{d=0,u();}));},m=window.visualViewport;return m&&(o.current=m.height),c(),m?.addEventListener("resize",c),m?.addEventListener("scroll",c),document.addEventListener("focusin",c),document.addEventListener("focusout",c),window.addEventListener(tt,c),()=>{d&&window.cancelAnimationFrame(d),m?.removeEventListener("resize",c),m?.removeEventListener("scroll",c),document.removeEventListener("focusin",c),document.removeEventListener("focusout",c),window.removeEventListener(tt,c);}},[e]),n}var Ht='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif';function Fn(e,t=1){return Math.max(0,Math.min(t,e))}var Vn=Un__namespace.forwardRef(function({screenshot:t,tool:n,color:r="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:a,onHistoryChange:i},u){let d=Un.useRef(null),c=Un.useRef(null),m=Un.useRef(null),[p,C]=Un.useState(null),[k,y]=Un.useState(false),[S,T]=Un.useState(""),[R,x]=Un.useState([]),f=Un.useRef(null),w=Un.useRef(false),D=Un.useRef(0),H=Un.useRef(false),[U,O]=Un.useState([]),oe=Un.useRef(0),A=Un.useRef([]),V=Un.useRef([]),te=Un.useRef(R);te.current=R;let ne=Un.useRef(U);ne.current=U;let Ee=Un.useRef(null),fe=Un.useRef(i);fe.current=i;let z=Un.useCallback(()=>{fe.current?.({canUndo:A.current.length>0,canRedo:V.current.length>0});},[]),Oe=Un.useCallback((b,v)=>{O(M=>M.map(L=>L.id===b?{...L,text:v}:L));},[]),Be=Un.useCallback(b=>{O(M=>M.filter(L=>L.id!==b));let v=A.current.lastIndexOf("comment");v>=0&&A.current.splice(v,1),V.current=[],z();},[z]);Un.useEffect(()=>{let b=Ee.current;if(b==null)return;Ee.current=null,m.current?.querySelector(`[data-bubble-id="${b}"] .lumen-bubble-text`)?.focus();},[U]),Un.useEffect(()=>{x([]),O([]),y(false),A.current=[],V.current=[],z();},[t,z]),Un.useEffect(()=>{let b=false,v=null;return (async()=>{try{let M=await createImageBitmap(t);if(b){M.close?.();return}v=M,C(M);}catch{}})(),()=>{b=true,v?.close?.();}},[t]),Un.useEffect(()=>{if(!p)return;let b=d.current,v=c.current;if(!(!b||!v)){v.width=p.width,v.height=p.height;try{b.width=p.width,b.height=p.height;let M=b.getContext("2d");if(!M)return;M.imageSmoothingEnabled=!1,M.drawImage(p,0,0),y(!1);}catch{y(true);}}},[p]),Un.useEffect(()=>{if(!k){T("");return}let b=URL.createObjectURL(t);return T(b),()=>{URL.revokeObjectURL(b);}},[k,t]),Un.useEffect(()=>{let b=c.current;if(b)try{wt(b,R,f.current);}catch{}},[R]),Un.useImperativeHandle(u,()=>({hasAnnotations:()=>R.length>0||U.some(b=>b.text.trim().length>0),reset:()=>{x([]),O([]),te.current=[],ne.current=[],A.current=[],V.current=[],z();},undo:()=>{let b=A.current[A.current.length-1];if(b){if(b==="comment"){let v=ne.current,M=v[v.length-1];if(!M)return;let L=v.slice(0,-1);ne.current=L,V.current.push({type:"comment",item:M}),O(L);}else {let v=te.current,M=v[v.length-1];if(!M)return;let L=v.slice(0,-1);te.current=L,V.current.push({type:"anno",item:M}),x(L);}A.current.pop(),z();}},redo:()=>{let b=V.current[V.current.length-1];if(b){if(b.type==="comment"){let v=[...ne.current,b.item];ne.current=v,O(v);}else {let v=[...te.current,b.item];te.current=v,x(v);}A.current.push(b.type),V.current.pop(),z();}},async flatten(){let b=f.current,v=b?[...R,b]:R,M=U.filter(L=>L.text.trim().length>0);if(v.length===0&&M.length===0||!p||k)return t;try{let L=document.createElement("canvas");L.width=p.width,L.height=p.height;let _=L.getContext("2d");if(!_)return t;_.imageSmoothingEnabled=!1,_.drawImage(p,0,0);for(let K of v)_t(_,K);let W=d.current?.clientWidth||p.width,re=p.width/Math.max(W,1);for(let K of M)na(_,K,p.width,p.height,re);return await new Promise(K=>{L.toBlob(me=>{K(me??t);},"image/jpeg",.85);})}catch{return t}}}),[R,U,p,t,k,z]);function he(b){let v=c.current;if(!v)return {x:0,y:0};let M=v.getBoundingClientRect(),L=v.width/Math.max(M.width,1),_=v.height/Math.max(M.height,1);return {x:(b.clientX-M.left)*L,y:(b.clientY-M.top)*_}}function Me(){H.current||(H.current=true,requestAnimationFrame(()=>{H.current=false;let b=c.current;b&&wt(b,te.current,f.current);}));}function Ce(b){if(b.button!==void 0&&b.button!==0)return;if(n==="comment"){let M=c.current;if(!M)return;let L=M.getBoundingClientRect(),_=Fn((b.clientX-L.left)/Math.max(L.width,1),.72),W=Fn((b.clientY-L.top)/Math.max(L.height,1),.8),re=++oe.current;O(K=>[...K,{id:re,x:_,y:W,text:"",color:r}]),A.current.push("comment"),V.current=[],Ee.current=re,z();return}try{b.currentTarget.setPointerCapture(b.pointerId);}catch{}w.current=true,a?.(true);let v=he(b);n==="arrow"?f.current={kind:"arrow",from:v,to:v,color:r,width:o}:n==="rect"?f.current={kind:"rect",from:v,to:v,color:r,width:o}:f.current={kind:"freehand",points:[v],color:r,width:o},D.current=performance.now(),Me();}function ae(b){if(!w.current||!f.current)return;let v=he(b),M=f.current;if(M.kind==="arrow"||M.kind==="rect")M.to=v;else {let L=M.points[M.points.length-1],_=L?(L.x-v.x)**2+(L.y-v.y)**2:1/0,W=performance.now(),re=W-D.current;(_>16||re>16)&&(M.points.push(v),D.current=W);}Me();}function Re(){if(!w.current)return;w.current=false,a?.(false);let b=f.current;if(f.current=null,!!b){if(b.kind==="arrow"||b.kind==="rect"){let v=b.to.x-b.from.x,M=b.to.y-b.from.y;if(v*v+M*M<16){let L=c.current;L&&wt(L,te.current,null);return}}else if(b.points.length<2){let v=c.current;v&&wt(v,te.current,null);return}x(v=>[...v,b].slice(-50)),A.current.push("anno"),V.current=[],z();}}return jsxRuntime.jsxs("div",{ref:m,className:"lumen-annotate-frame","data-lumen-tool":n,children:[jsxRuntime.jsx("canvas",{ref:d}),k&&S?jsxRuntime.jsx("img",{src:S,alt:"","aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"fill",pointerEvents:"none"}}):null,jsxRuntime.jsx("canvas",{ref:c,className:"lumen-annotate-overlay",onPointerDown:Ce,onPointerMove:ae,onPointerUp:Re,onPointerCancel:Re}),jsxRuntime.jsx("div",{className:"lumen-bubble-layer",children:U.map(b=>jsxRuntime.jsx(ea,{comment:b,onChange:Oe,onRemove:Be},b.id))})]})});function ea({comment:e,onChange:t,onRemove:n}){let r=Un.useRef(null);return Un.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 wt(e,t,n){let r=e.getContext("2d");if(r){r.clearRect(0,0,e.width,e.height);for(let o of t)_t(r,o);n&&_t(r,n);}}function _t(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")ta(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 ta(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],u=(a.x+i.x)/2,d=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,u,d);}let r=t[t.length-1];e.lineTo(r.x,r.y),e.stroke();}function na(e,t,n,r,o){let a=t.text.trim();if(!a)return;let i=10*o,u=14*o,d=10*o,c=12*o,m=u*1.35,p=d*1.7,C=t.x*n,k=t.y*r,y=Math.min(n*.6,n-C-8*o);e.save(),e.font=`500 ${u}px ${Ht}`,e.textBaseline="top";let S=ra(e,a,y-i*2),T=S.reduce((H,U)=>Math.max(H,e.measureText(U).width),0),R=Math.min(y,Math.max(T,56*o)+i*2),x=i*2+p+S.length*m;oa(e,C,k,R,x,c),e.fillStyle="#ffffff",e.fill(),e.lineWidth=Math.max(1,o),e.strokeStyle="rgba(0,0,0,0.10)",e.stroke();let f=C+18*o,w=k+x;e.beginPath(),e.moveTo(f,w-o),e.lineTo(f+13*o,w-o),e.lineTo(f+4*o,w+9*o),e.closePath(),e.fillStyle="#ffffff",e.fill(),e.fillStyle=t.color||"rgb(239, 68, 68)",e.font=`700 ${d}px ${Ht}`,e.fillText("COMMENT",C+i,k+i),e.fillStyle="#111318",e.font=`500 ${u}px ${Ht}`;let D=k+i+p;for(let H of S)e.fillText(H,C+i,D),D+=m;e.restore();}function ra(e,t,n){let r=t.split(/\s+/).filter(Boolean),o=[],a="";for(let i of r){let u=a?`${a} ${i}`:i;a&&e.measureText(u).width>n?(o.push(a),a=i):a=u;}return a&&o.push(a),o.length?o:[t]}function oa(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 Y({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 aa(e){return jsxRuntime.jsxs(Y,{...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 ia(e){return jsxRuntime.jsxs(Y,{...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 Ft(e){return jsxRuntime.jsxs(Y,{...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 $n(e){return jsxRuntime.jsx(Y,{...e,children:jsxRuntime.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-8.5 8.5 9.5 9.5 0 0 1-3.5-.7L3 21l1.7-5.5A8.38 8.38 0 0 1 4 11.5 8.5 8.5 0 0 1 12.5 3 8.38 8.38 0 0 1 21 11.5Z"})})}function Wn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19 19 5"}),jsxRuntime.jsx("path",{d:"M11 5h8v8"})]})}function Kn(e){return jsxRuntime.jsx(Y,{...e,children:jsxRuntime.jsx("rect",{x:"4",y:"6",width:"16",height:"12",rx:"2"})})}function Ut(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M5 19l1.5-5L16 4.5 19.5 8 10 17.5 5 19z"}),jsxRuntime.jsx("path",{d:"M14 6.5l3.5 3.5"})]})}function qn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M9 8 4 13l5 5"}),jsxRuntime.jsx("path",{d:"M4 13h11a5 5 0 0 1 0 10h-1"})]})}function Vt(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),jsxRuntime.jsx("path",{d:"M21 4v4h-4"})]})}function jn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M15 8 20 13l-5 5"}),jsxRuntime.jsx("path",{d:"M20 13H9a5 5 0 0 0 0 10h1"})]})}function Yn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M4 7h16"}),jsxRuntime.jsx("path",{d:"M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"}),jsxRuntime.jsx("path",{d:"M6 7l1 13a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-13"})]})}function Gn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3"}),jsxRuntime.jsx("path",{d:"M16 3h3a2 2 0 0 1 2 2v3"}),jsxRuntime.jsx("path",{d:"M21 16v3a2 2 0 0 1-2 2h-3"}),jsxRuntime.jsx("path",{d:"M3 16v3a2 2 0 0 0 2 2h3"})]})}function Zn(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3"}),jsxRuntime.jsx("path",{d:"M16 3v3a2 2 0 0 0 2 2h3"}),jsxRuntime.jsx("path",{d:"M21 16h-3a2 2 0 0 0-2 2v3"}),jsxRuntime.jsx("path",{d:"M3 16h3a2 2 0 0 1 2 2v3"})]})}function Xn(e){return jsxRuntime.jsx(Y,{...e,strokeWidth:2.2,children:jsxRuntime.jsx("path",{d:"M15 6l-6 6 6 6"})})}function Jn(e){return jsxRuntime.jsx(Y,{...e,strokeWidth:1.9,children:jsxRuntime.jsx("path",{d:"M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z"})})}function it(e){return jsxRuntime.jsxs(Y,{...e,children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"13",rx:"2"}),jsxRuntime.jsx("path",{d:"M8 21h8M12 17v4"})]})}function zt(e){return jsxRuntime.jsxs(Y,{...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 yt={shot:aa,video:ia,upload:Ft};function Qn(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 sa(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 la=4e3;async function $t(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((d,c)=>{if(n.readyState>=2)return d();n.addEventListener("loadeddata",()=>d(),{once:true}),n.addEventListener("error",()=>c(new Error("video decode failed")),{once:true});}),await sa(n,Math.min(.1,(n.duration||0)/2));let i=await Qn(n),u=Number.isFinite(n.duration)?n.duration*1e3:0;return {poster:i,durationMs:u}},o,a=new Promise(i=>{o=window.setTimeout(()=>i({poster:null,durationMs:0}),la);});try{return await Promise.race([r().catch(()=>({poster:null,durationMs:0})),a])}finally{window.clearTimeout(o),n.removeAttribute("src"),URL.revokeObjectURL(t);}}async function Wt(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 Qn(t)}catch{return null}finally{t.srcObject=null;}}async function Kt(){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 qt=60,ua=25*1024*1024,er=[{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)"}],tr=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],ca=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],da=[{value:"",label:"No priority"},{value:"urgent",label:"Urgent"},{value:"high",label:"High"},{value:"medium",label:"Medium"},{value:"low",label:"Low"}],ma=[{value:"web",label:"Web"},{value:"ios-web",label:"iOS web"},{value:"android-web",label:"Android web"},{value:"ios-native",label:"iOS native"},{value:"android-native",label:"Android native"}];function pa(e){if(e.platform==="ios")return "ios-native";if(e.platform==="android")return "android-native";if(e.platform==="custom")return "custom";let t=typeof navigator<"u"&&navigator.userAgent||"";return /android/i.test(t)?"android-web":/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&typeof document<"u"&&"ontouchend"in document?"ios-web":"web"}function fa({value:e}){return e==="urgent"?jsxRuntime.jsx("span",{className:"lumen-pri-ic lumen-pri-urgent","aria-hidden":"true",children:"!"}):jsxRuntime.jsxs("span",{className:"lumen-pri-ic lumen-pri-bars","data-level":e==="high"?3:e==="medium"?2:1,"aria-hidden":"true",children:[jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{}),jsxRuntime.jsx("i",{})]})}var jt=[{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 Yt(){let{client:e,isOpen:t,closeCapture:n,user:r,capture:o,initialCapture:a,initialCaptureError:i,startVideoSession:u,consumePendingVideo:d,canRecordScreen:c,consumeRecordStartError:m,startScreenCaptureSession:p,consumePendingScreenshot:C,isolateEvents:k,keyboardInset:y}=nt(),[S,T]=Un.useState(1),[R,x]=Un.useState(null),[f,w]=Un.useState({kind:"idle"}),[D,H]=Un.useState(false),[U,O]=Un.useState(0),[oe,A]=Un.useState("arrow"),[V,te]=Un.useState(er[0].value),[ne,Ee]=Un.useState(tr[1].value),[fe,z]=Un.useState(""),[Oe,Be]=Un.useState("bug"),[he,Me]=Un.useState(""),[Ce,ae]=Un.useState(""),[Re,b]=Un.useState(false),[v,M]=Un.useState(false),[L,_]=Un.useState(false),[W,re]=Un.useState(false),[K,me]=Un.useState(false),[be,ke]=Un.useState(r?.email??""),[F,Pe]=Un.useState(null),[ie,Se]=Un.useState(null),[lt,He]=Un.useState(0),[ge,ve]=Un.useState(null),[ut,_e]=Un.useState(null),[xe,Fe]=Un.useState(false),[X,We]=Un.useState({canUndo:false,canRedo:false}),le=Un.useRef(null),Te=Un.useRef(null),Ke=Un.useRef(null),Ge=Un.useRef(null),Ze=Un.useRef(null),Le=ot(t,y),we=Un.useRef(false),Ne=Un.useRef(false);Un.useEffect(()=>{t||(Ne.current=false);},[t]),Un.useEffect(()=>{if(!t)return;if(Ne.current){we.current=false;return}Ne.current=true,we.current=false,T(1),x(null),z(""),Se(null),He(0),ve(null),H(false),O(0),ae(""),me(false),_e(null),We({canUndo:false,canRedo:false});let s=C();if(s){x("shot"),$(s),w({kind:"ready",capture:s});return}let g=d();if(g)x("video"),ve({blob:g.blob,durationMs:g.durationMs}),g.blob.size>ua&&sonner.toast.warning("This recording is large and may be too big to upload. Try a shorter clip if the upload fails."),g.poster?w({kind:"ready",capture:Qe(g.poster,["Screen recording; preview is the first frame."])}):(w({kind:"capturing"}),(async()=>{let N=null;if(g.deriveBlobPoster)try{N=(await $t(g.blob)).poster;}catch{N=null;}N=N??await Kt(),!we.current&&w(N?{kind:"ready",capture:Qe(N,["Screen recording; preview is the first frame."])}:{kind:"manual"});})());else {let N=m();N?(x("video"),_e(N),w({kind:"idle"})):a?(x("shot"),w({kind:"ready",capture:a})):o?.mode==="manual"?w({kind:"manual"}):o?.provider&&!i?(x("shot"),ct(o.mode??"auto")):w({kind:"manual",error:i?.message??"Automatic screenshot capture was unavailable."});}return ()=>{we.current=true;}},[t,o,a,i]),Un.useEffect(()=>{if(!t)return;Ze.current=document.activeElement??null;let s=document.documentElement,g=s.style.overflow,N=s.style.paddingRight,j=window.innerWidth-s.clientWidth;s.style.overflow="hidden",j>0&&(s.style.paddingRight=`${j}px`);let ue=false,ye=()=>{if(!ue){ue=true,s.style.overflow=g,s.style.paddingRight=N;try{Ze.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",ye),()=>{window.removeEventListener("pagehide",ye),ye();}},[t]),Un.useEffect(()=>{if(!t)return;function s(g){if(g.key==="Escape"){g.preventDefault(),n();return}if(g.key!=="Tab")return;let N=Ke.current;if(!N)return;let j=ka(N);if(j.length===0)return;let ue=j[0],ye=j[j.length-1],xt=document.activeElement;g.shiftKey&&(xt===ue||!N.contains(xt))?(g.preventDefault(),ye.focus()):!g.shiftKey&&xt===ye&&(g.preventDefault(),ue.focus());}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[t,n]),Un.useEffect(()=>{if(!t||!k)return;let s=Ge.current;if(!s)return;let g=N=>{N.target===s&&N.stopPropagation();};return s.addEventListener("pointerdown",g),s.addEventListener("click",g),s.addEventListener("touchstart",g,{passive:true}),()=>{s.removeEventListener("pointerdown",g),s.removeEventListener("click",g),s.removeEventListener("touchstart",g);}},[t,k]),Un.useEffect(()=>{if(!t||!Le.open||typeof window>"u")return;let s=document.scrollingElement??document.documentElement,g=()=>{(window.scrollX!==0||window.scrollY!==0)&&window.scrollTo(0,0),s&&s.scrollTop!==0&&(s.scrollTop=0);};window.addEventListener("scroll",g,{passive:true}),document.addEventListener("scroll",g,{passive:true});let N=[0,60,180,360].map(j=>window.setTimeout(g,j));return g(),()=>{window.removeEventListener("scroll",g),document.removeEventListener("scroll",g);for(let j of N)window.clearTimeout(j);}},[t,Le.open,Le.inset]),Un.useEffect(()=>{if(!t||f.kind!=="manual")return;function s(g){let ue=Array.from(g.clipboardData?.items??[]).find(ye=>ye.type.startsWith("image/"))?.getAsFile();ue&&(g.preventDefault(),E(ue));}return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[t,f.kind]),Un.useEffect(()=>{if(!F)return;let s=Date.now(),g=window.setInterval(()=>{let N=Math.floor((Date.now()-s)/1e3);He(N),N>=qt&&Xe();},250);return ()=>window.clearInterval(g)},[F]);let Ue=Un.useRef(null);if(Ue.current=F,Un.useEffect(()=>{t||Ue.current&&(Ue.current.cancel(),Ue.current=null,Pe(null),He(0));},[t]),Un.useEffect(()=>()=>{Ue.current?.cancel();},[]),!t)return null;async function ct(s){we.current=false,w({kind:"capturing"});try{let g=await bt({...o,mode:s,target:o?.target??document.documentElement});return we.current?!1:($(g),w({kind:"ready",capture:g}),!0)}catch(g){return we.current||w({kind:"manual",error:g instanceof Error?g.message:"Automatic screenshot capture was unavailable."}),false}}async function J(s){x(s),_e(null),s!=="video"&&St(),s==="shot"?await ct(o?.mode??"auto"):s==="video"?(ve(null),w({kind:"idle"})):(w({kind:"manual"}),Te.current?.click());}async function E(s){if(s.type.startsWith("image/")){St();let g=Qe(s,["Manual image upload used."]);w({kind:"ready",capture:g});return}if(s.type.startsWith("video/")){w({kind:"capturing"});try{let{poster:g,durationMs:N}=await $t(s),j=g??await Kt();if(!j){w({kind:"manual",error:"Could not read that video."});return}let ue=Qe(j,["Uploaded video; preview is the first frame."]);ve({blob:s,durationMs:N}),w({kind:"ready",capture:ue});}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 $(s){s.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function q(){try{let s=await Dn(qt);Pe(s);}catch(s){sonner.toast.error(s instanceof Error?s.message:"Microphone unavailable");}}async function Xe(){if(F)try{let s=await F.stop();Se({blob:s.blob,durationMs:s.durationMs});}catch(s){sonner.toast.error(s instanceof Error?s.message:"Could not stop recording");}finally{Pe(null);}}function Fr(){F?.cancel(),Pe(null),Se(null),He(0);}function Jt(s){let g=jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!F&&!ie?jsxRuntime.jsxs("button",{type:"button",onClick:q,className:s==="capture"?"lumen-voice-capture-btn":"lumen-btn-ghost",children:[jsxRuntime.jsx(zt,{}),"Record voice note"]}):null,F?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(wa,{analyser:F.analyser}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[lt,"s / ",qt,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:Xe,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:Fr,className:"lumen-btn-ghost",children:"Cancel"})]}):null,ie&&!F?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ea,{blob:ie.blob,durationMs:ie.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Se(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]});return s==="capture"?jsxRuntime.jsxs("div",{className:"lumen-voice-capture",children:[g,!F&&!ie?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)"}),g]})}async function Ur(){_e(null);try{await u();}catch(s){sonner.toast.error(s instanceof Error?s.message:"Screen capture unavailable");}}function St(){ve(null);}let Vr=f.kind==="ready";async function Qt(){F&&await Xe(),S===1?(f.kind==="ready"&&!Ce&&ae(pa(f.capture)),T(2)):await tn();}function en(){S>1&&T(s=>s-1);}async function tn(){if(f.kind!=="ready")return;let s=fe.trim(),{capture:g}=f;H(true),O(0);try{let j=await le.current?.flatten()??g.blob,ue=await e.submit({rawText:s.length>0?s:void 0,category:Oe,priority:he||void 0,source:Ce||void 0,submitterEmail:be.trim()||void 0,screenshot:j,audio:ie?.blob,audioDurationMs:ie?.durationMs,video:ge?.blob,videoDurationMs:ge?.durationMs,context:In(g)},{onUploadProgress:ye=>O(Math.min(.95,ye))});O(1),sonner.toast.success("Feedback sent \u2014 thank you."),ue.id,n();}catch(N){sonner.toast.error(N instanceof Error?N.message:"Could not submit feedback"),H(false);}}function zr(s){s.target===s.currentTarget&&!D&&n();}let qe=Math.round(U*100),dt=R==="video",$r=typeof navigator<"u"&&!!navigator.mediaDevices?.getDisplayMedia,nn=R==="shot"&&!o?.provider&&o?.allowTrueScreen!==false&&$r,rn=S===1&&!Vr||D,Wr=S<3?"Next":D?qe<95?`Uploading ${qe}%\u2026`:"Almost done\u2026":"Send feedback",mt=S===1,on=S===2&&f.kind==="ready",Kr=mt||on;return jsxRuntime.jsx("div",{ref:Ge,role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",style:Le.inset?{"--lumen-keyboard-inset":`${Le.inset}px`}:void 0,onMouseDown:zr,children:jsxRuntime.jsxs("div",{ref:Ke,className:"lumen-modal","data-lumen-drawing":xe?"true":void 0,"data-lumen-fs":Kr?"true":void 0,"data-lumen-expanded":K?"true":void 0,"data-lumen-review":on?"true":void 0,"data-lumen-sheet":mt&&v?"down":void 0,children:[jsxRuntime.jsx(va,{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(ha,{step:S}),jsxRuntime.jsx("input",{ref:Te,type:"file",accept:"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime",style:{display:"none"},onChange:s=>{let g=s.currentTarget.files?.[0];g&&E(g),s.currentTarget.value="";}}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[S===1||S===2?jsxRuntime.jsx("div",{className:"lumen-pane",children:R===null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-top",children:jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})})}),jsxRuntime.jsxs("div",{className:"lumen-fs-center lumen-fs-picker",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-picker-head",children:[jsxRuntime.jsx("div",{className:"lumen-fs-picker-title",children:"How do you want to capture?"}),jsxRuntime.jsx("div",{className:"lumen-fs-picker-sub",children:"Pick a method to report this."})]}),jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn"+(s.primary?" lumen-method-primary":""),onClick:()=>J(s.value),disabled:f.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-ico",children:jsxRuntime.jsx(g,{})}),s.primary?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-method-text",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]}),jsxRuntime.jsx("span",{className:"lumen-method-badge",children:"Fastest"})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:s.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:s.hint})]})]},s.value)})})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[f.kind!=="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"})}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsx("div",{className:"lumen-fs-pill",role:"group","aria-label":"Capture method",children:jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":R===s.value,"aria-label":s.label,onClick:()=>J(s.value),disabled:f.kind==="capturing",children:jsxRuntime.jsx(g,{})},s.value)})})})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-center",children:[R==="video"&&f.kind==="idle"?jsxRuntime.jsx(ba,{canRecord:c,onRecord:Ur,onUpload:()=>J("upload"),error:ut}):null,f.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,f.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:R==="upload"?"Choose an image or video to attach \u2014 or paste an image.":f.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:R==="upload"?"Choose a file \u2014 image or video":"Choose or paste an image"}),jsxRuntime.jsx("input",{type:"file",accept:R==="upload"?"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime":"image/png,image/jpeg,image/webp",onChange:s=>{let g=s.currentTarget.files?.[0];g&&E(g),s.currentTarget.value="";}})]})]}):null]})]}):null,f.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[S===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-fs-top",children:[jsxRuntime.jsxs("div",{className:"lumen-fs-toprow lumen-fs-row-corners",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-x",onClick:n,"aria-label":"Close",children:"\u2715"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-chip lumen-fs-expand",onClick:()=>me(s=>!s),"aria-pressed":K,"aria-label":K?"Shrink capture":"Expand capture",title:K?"Shrink":"Expand to full screen",children:K?jsxRuntime.jsx(Zn,{}):jsxRuntime.jsx(Gn,{})}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-fs-chip",onClick:()=>_(s=>!s),"aria-haspopup":"menu","aria-expanded":L,children:[jsxRuntime.jsx(Vt,{})," Recapture",jsxRuntime.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.6},"aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M6 9l6 6 6-6"})})]}),L?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-recap-overlay",onClick:()=>_(false)}),jsxRuntime.jsxs("div",{className:"lumen-fs-recap-menu",role:"menu",children:[jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),R&&J(R);},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(Vt,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Re-snap this view"}),jsxRuntime.jsx("small",{children:"Instant \xB7 masks sensitive fields"})]})]}),nn?jsxRuntime.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(false),p();},children:[jsxRuntime.jsx("span",{className:"lumen-fs-mi-ic",children:jsxRuntime.jsx(it,{})}),jsxRuntime.jsxs("span",{children:[jsxRuntime.jsx("b",{children:"Capture exact pixels"}),jsxRuntime.jsx("small",{children:"Real screen \u2014 canvas, video & charts"})]})]}):null]})]}):null]})]}),jsxRuntime.jsx("div",{className:"lumen-fs-toprow lumen-fs-row-pill",children:jsxRuntime.jsxs("div",{className:"lumen-fs-pill",role:"group","aria-label":"Tools and capture method",children:[dt?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn lumen-fs-pentog","data-on":!Re,onClick:()=>b(s=>!s),"aria-label":"Toggle markup tools",title:"Toggle markup tools",children:jsxRuntime.jsx(Ut,{})}),jsxRuntime.jsx("span",{className:"lumen-fs-pill-sep"})]}),jt.map(s=>{let g=yt[s.value];return jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-pill-btn","aria-pressed":R===s.value,"aria-label":s.label,onClick:()=>J(s.value),children:jsxRuntime.jsx(g,{})},s.value)})]})})]}),!dt&&!Re?jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(Et,{label:"Arrow",icon:jsxRuntime.jsx(Wn,{}),active:oe==="arrow",onClick:()=>A("arrow")}),jsxRuntime.jsx(Et,{label:"Box",icon:jsxRuntime.jsx(Kn,{}),active:oe==="rect",onClick:()=>A("rect")}),jsxRuntime.jsx(Et,{label:"Draw",icon:jsxRuntime.jsx(Ut,{}),active:oe==="freehand",onClick:()=>A("freehand")}),jsxRuntime.jsx(Et,{label:"Comment",icon:jsxRuntime.jsx($n,{}),active:oe==="comment",onClick:()=>A("comment")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsxs("div",{className:"lumen-fs-color",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-color-btn",style:{background:V},"aria-label":"Pick colour","aria-haspopup":"true","aria-expanded":W,onClick:()=>re(s=>!s)}),W?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"lumen-fs-color-overlay",onClick:()=>re(false)}),jsxRuntime.jsx("div",{className:"lumen-fs-color-pop",role:"group","aria-label":"Colour",children:er.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:s.value},"aria-label":s.label,"aria-pressed":V===s.value,onClick:()=>{te(s.value),re(false);}},s.value))})]}):null]}),mt?null:jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:tr.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":s.label,"aria-pressed":ne===s.value,onClick:()=>Ee(s.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:s.dot,height:s.dot}})},s.value))}),mt?null:jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>le.current?.undo(),disabled:!X.canUndo,"aria-label":"Undo",title:"Undo",children:jsxRuntime.jsx(qn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>le.current?.redo(),disabled:!X.canRedo,"aria-label":"Redo",title:"Redo",children:jsxRuntime.jsx(jn,{})}),jsxRuntime.jsx("button",{type:"button",className:"lumen-tool",onClick:()=>le.current?.reset(),disabled:!X.canUndo,"aria-label":"Clear",title:"Clear",children:jsxRuntime.jsx(Yn,{})})]}):null]}):null,jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(Vn,{ref:le,screenshot:f.capture.blob,tool:oe,color:V,strokeWidth:ne,onDrawingChange:Fe,onHistoryChange:We})}),S===1?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>R&&J(R),children:dt?"\u21BB Re-record":"\u21BB Recapture"}),nn?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(it,{})," Capture exact screen"]}):null,dt?ge?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(ge.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsx("span",{className:"lumen-cap-note",children:f.capture.method==="web-display-media"?"Exact screen captured":`${nr(R)} captured \xB7 switch method above anytime`})]}),jsxRuntime.jsxs("div",{className:"lumen-fs-compose",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-grab",onClick:()=>M(s=>!s),"aria-label":v?"Expand sheet":"Minimize sheet"}),jsxRuntime.jsxs("div",{className:"lumen-fs-field",children:[jsxRuntime.jsx("input",{className:"lumen-input lumen-fs-desc",value:fe,onChange:s=>z(s.target.value),placeholder:"Describe what's wrong \u2014 or use voice"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-fs-mic",onClick:q,"aria-label":"Record voice note",children:jsxRuntime.jsx(zt,{})})]}),Jt("capture"),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-fs-next",onClick:Qt,disabled:rn,children:"Next"})]})]}):null]}):null]})}):null,S===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-rv-pane",children:[jsxRuntime.jsx("div",{className:"lumen-rv-scrim","aria-hidden":"true"}),jsxRuntime.jsxs("div",{className:"lumen-rv",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-head",children:[jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-back",onClick:en,children:[jsxRuntime.jsx(Xn,{}),"Back"]}),jsxRuntime.jsx("span",{className:"lumen-rv-title",children:"Review & send"}),jsxRuntime.jsx("span",{className:"lumen-rv-spacer","aria-hidden":"true"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-rows",children:[jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Description"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 tap to edit"})]}),jsxRuntime.jsx("textarea",{className:"lumen-input lumen-rv-desc",value:fe,onChange:s=>z(s.target.value),rows:2,placeholder:"Describe what's wrong\u2026"})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Type"}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Type",children:ca.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":Oe===s.value,onClick:()=>Be(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsx("span",{className:"lumen-rv-k",children:"Priority"}),jsxRuntime.jsx("div",{className:"lumen-rv-prio",role:"group","aria-label":"Priority",children:da.filter(s=>s.value!=="").map(s=>jsxRuntime.jsxs("button",{type:"button",className:"lumen-rv-prio-opt","aria-pressed":he===s.value,onClick:()=>Me(he===s.value?"":s.value),children:[jsxRuntime.jsx(fa,{value:s.value}),s.label]},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-set",children:[jsxRuntime.jsxs("span",{className:"lumen-rv-k",children:["Platform"," ",jsxRuntime.jsx("span",{className:"lumen-rv-muted",children:"\xB7 auto-detected \u2014 change if wrong"})]}),jsxRuntime.jsx("div",{className:"lumen-rv-chips",role:"group","aria-label":"Platform",children:ma.map(s=>jsxRuntime.jsx("button",{type:"button",className:"lumen-rv-chip","aria-pressed":Ce===s.value,onClick:()=>ae(s.value),children:s.label},s.value))})]}),jsxRuntime.jsxs("div",{className:"lumen-rv-row",children:[jsxRuntime.jsx("span",{className:"lumen-rv-rk",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-rv-rv",children:[nr(R),X.canUndo?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>T(1),children:"edit"})]})]}),Jt("describe"),jsxRuntime.jsx("div",{className:"lumen-rv-attachrow",children:ge?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(ge.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:St,children:"\xD7"})]}):jsxRuntime.jsxs("label",{className:"lumen-rv-attach",children:[jsxRuntime.jsx(Ft,{}),"Attach a video",jsxRuntime.jsx("input",{type:"file",accept:"video/mp4,video/webm,video/quicktime",onChange:s=>{let g=s.currentTarget.files?.[0];g&&ve({blob:g,durationMs:0}),s.currentTarget.value="";}})]})})]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-primary lumen-rv-send",onClick:tn,disabled:D,children:D?qe<95?`Uploading ${qe}%\u2026`:"Almost done\u2026":jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Jn,{}),"Send feedback"]})})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[D?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":qe,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${qe}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:S===1?n:en,className:"lumen-btn-ghost",disabled:D,children:S===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:Qt,className:"lumen-btn-primary",disabled:rn,children:Wr})]})]})]})})}function nr(e){return e==="video"?"Screen recording":e==="upload"?"Upload":"Screenshot"}function ha({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 ba({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:ga()?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 ga(){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 Et({label:e,active:t,onClick:n,icon:r}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,"aria-label":r?e:void 0,title:e,children:r??e})}function va({onDismiss:e}){let t=Un.useRef(null),n=Un.useRef(0),r=Un.useRef(null);function o(u){u.currentTarget.setPointerCapture(u.pointerId),t.current=u.clientY,n.current=performance.now(),r.current=u.currentTarget.parentElement;}function a(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current);r.current.style.transform=`translateY(${d}px)`;}function i(u){if(t.current==null||!r.current)return;let d=Math.max(0,u.clientY-t.current),c=Math.max(1,performance.now()-n.current),m=d/c;r.current.style.transform="",r.current.style.transition="",t.current=null,(d>80||m>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:o,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function wa({analyser:e}){let t=Un.useRef(null);return Un.useEffect(()=>{let n=t.current;if(!n||!e)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 u=e,d=new Uint8Array(u.fftSize),c=18,m=3,p=3,C=Math.max(2,(o-m*(c-1))/c),k=Math.min(C/2,3),y=new Array(c).fill(0),S=0,T=false;function R(){if(T)return;u.getByteTimeDomainData(d);let x=Math.floor(d.length/c);i.clearRect(0,0,o,a),i.fillStyle=Ca("--lumen-danger")||"rgb(239,68,68)";for(let f=0;f<c;f++){let w=0;for(let A=0;A<x;A++){let V=Math.abs((d[f*x+A]??128)-128);V>w&&(w=V);}let D=Math.min(1,w/128*1.8),H=y[f]??0;y[f]=D>H?D:H+(D-H)*.35;let U=Math.max(p,y[f]*a),O=f*(C+m),oe=(a-U)/2;ya(i,O,oe,C,U,k),i.fill();}S=requestAnimationFrame(R);}return S=requestAnimationFrame(R),()=>{T=true,cancelAnimationFrame(S);}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function ya(e,t,n,r,o,a){let i=Math.min(a,r/2,o/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.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 Ea({blob:e,durationMs:t}){let[n,r]=Un.useState("");return Un.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 Ca(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var Ra='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function ka(e){return Array.from(e.querySelectorAll(Ra)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}var Ct=class extends Un__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 sr({state:e,portalTarget:t,onStop:n,onCancel:r}){let[o,a]=Un.useState(false);if(Un.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body;return e.phase==="recording"?reactDom.createPortal(jsxRuntime.jsx(xa,{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 xa({startedAt:e,maxSeconds:t,onStop:n,onCancel:r}){let[o,a]=Un.useState(0);Un.useEffect(()=>{let u=()=>a(Math.min(t,Math.max(0,Math.floor((Date.now()-e)/1e3))));u();let d=window.setInterval(u,250);return ()=>window.clearInterval(d)},[e,t]);let i=u=>`${Math.floor(u/60)}:${String(u%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 lr({state:e,portalTarget:t,onCapture:n,onCancel:r}){let[o,a]=Un.useState(false);if(Un.useEffect(()=>a(true),[]),!o||typeof document>"u")return null;let i=t??document.body,u=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:[u?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(it,{})}),jsxRuntime.jsx("span",{className:"lumen-cap-hud-text",children:u?"Capturing\u2026":"Arrange the screen, then capture"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-cancel",onClick:r,disabled:u,children:"Cancel"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-cap-hud-capture",onClick:n,disabled:u,"aria-label":"Capture this screen and return to feedback",children:"Capture"})]}),i)}function Gt(e){let t=e.hasProvider&&e.providerAvailable!==false;return {canRecord:t||e.hasGetDisplayMedia,usingProvider:t}}function ur(e){return typeof e=="object"&&e!==null&&e.code==="RECORDER_STOPPED"}function cr(e){return e instanceof Error?e:new Error(String(e))}function dr(e,t,n){let r=false,o=false,a=false,i=null;function u(){o||(o=true,n.onCancelled());}function d(m){o||(o=true,n.onResult(m));}function c(m){o||(o=true,n.onError(m));}return n.onStarting(),Promise.resolve().then(()=>e(t)).then(m=>{if(i=m,r){try{m.cancel();}catch{}u();return}if(n.onActive(m),a){n.onProcessing();try{m.stop();}catch{}}Promise.resolve(m.result).then(p=>{r?u():d(p);}).catch(p=>{r||ur(p)?u():c(cr(p));});}).catch(m=>{r||ur(m)?u():c(cr(m));}),{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{}u();}}}}function mr(){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 u=document.elementsFromPoint(i,n);for(let d of u){if(o.has(d))continue;o.add(d);let c=window.getComputedStyle(d);if(c.position!=="fixed"&&c.position!=="sticky")continue;let m=d.getBoundingClientRect();m.bottom<t-8||m.bottom>t+8||m.width<e*.6||m.height>a&&(a=m.height);}}return a}function Zt(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 u of Array.from(i)){let d=u.getBoundingClientRect();if(d.height===0||d.width===0)continue;let c=0;switch(t){case "bottom":if(d.bottom<r-8)break;c=Math.max(0,r-d.top);break;case "top":if(d.top>8)break;c=Math.max(0,d.bottom);break;case "left":if(d.left>8)break;c=Math.max(0,d.right);break;case "right":if(d.right<n-8)break;c=Math.max(0,n-d.left);break}c>o&&(o=c);}}return o}function pr(e){let[t,n]=Un.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),r=Un.useRef(t),o=Da(e.avoid),a=e.placement,i=e.offset.x,u=e.offset.y;return Un.useEffect(()=>{if(typeof window>"u")return;let d=0,c=false,m=()=>{if(d=0,c)return;let S=a[0]==="b"?"bottom":"top",T=a[1]==="r"?"right":"left",R=0,x=0;e.avoid==="auto"&&S==="bottom"?R=mr():Array.isArray(e.avoid)&&(R=Zt(e.avoid,S),x=Zt(e.avoid,T));let f={bottom:S==="bottom"?u+R:0,top:S==="top"?u+R:0,right:T==="right"?i+x:0,left:T==="left"?i+x:0},w=r.current;(f.bottom!==w.bottom||f.top!==w.top||f.right!==w.right||f.left!==w.left)&&(r.current=f,n(f));},p=()=>{d||(d=window.requestAnimationFrame(m));};p();let C=typeof ResizeObserver<"u"?new ResizeObserver(p):null;C?.observe(document.documentElement);let k=typeof MutationObserver<"u"?new MutationObserver(p):null;k?.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),()=>{c=true,d&&window.cancelAnimationFrame(d),C?.disconnect(),k?.disconnect(),window.removeEventListener("resize",p),y?.removeEventListener("resize",p),y?.removeEventListener("scroll",p);}},[a,i,u,o]),t}function Da(e){return e===false?"false":e==="auto"?"auto":e.join("|")}var fr=["mousedown","touchstart"];function Ye(e){let t=Un.useRef(e.onPointerDown);t.current=e.onPointerDown;let n=Un.useRef(e.onClick);n.current=e.onClick;let r=Un.useRef(e.isolate??true);r.current=e.isolate??true;let o=Un.useRef(null);return Un.useCallback(a=>{if(o.current?.(),o.current=null,!a)return;let i=c=>{r.current&&c.stopPropagation(),t.current?.(c);},u=c=>{r.current&&c.stopPropagation(),n.current(c);},d=c=>{r.current&&c.stopPropagation();};a.addEventListener("pointerdown",i),a.addEventListener("click",u);for(let c of fr)a.addEventListener(c,d,c==="touchstart"?{passive:true}:void 0);o.current=()=>{a.removeEventListener("pointerdown",i),a.removeEventListener("click",u);for(let c of fr)a.removeEventListener(c,d);};},[])}function vr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true,keyboardInset:i}){let[u,d]=Un.useState(null),c=Un.useRef(null),m=pr(e),p=ot(e.keyboard!=="off",i),C=Ye({onPointerDown:r,onClick:o,isolate:a}),k=Un.useCallback(O=>{c.current=O,C(O);},[C]);Un.useEffect(()=>{typeof document>"u"||d(t??document.body);},[t]);let y=e.placement,S=y[0]==="b"?"bottom":"top",T=y[1]==="r"?"right":"left",R=S==="bottom",x=p.open&&R&&(e.keyboard==="lift"||e.keyboard==="auto"&&p.inset>0)?p.inset:0,f=p.open&&(e.keyboard==="hide"||e.keyboard==="auto"&&R&&p.inset<=0);if(Fa(c,!n&&!f),!u)return null;let w=S==="bottom"?m.bottom:m.top,D=T==="right"?m.right:m.left,H=n||f,U={position:"fixed",[S]:e.safeArea?`calc(${w}px + env(safe-area-inset-${S}, 0px))`:`${w}px`,[T]:e.safeArea?`calc(${D}px + env(safe-area-inset-${T}, 0px))`:`${D}px`,zIndex:e.zIndex,transform:x?`translateY(-${x}px)`:void 0,opacity:H?0:1,pointerEvents:H?"none":"auto",transition:"opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1)"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:k,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:U,"aria-label":e.label,"aria-hidden":H?true:void 0,tabIndex:H?-1:0,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),u)}function Fa(e,t){let n=Un.useRef(false);Un.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,u=a.top+a.height/2,d=document.elementsFromPoint(i,u),c=hr(window.getComputedStyle(o).zIndex);for(let m of d){if(m===o||o.contains(m))continue;if(hr(window.getComputedStyle(m).zIndex)>c){n.current=true,console.warn("[lumen] trigger is occluded by",m);break}}},250);return ()=>window.clearTimeout(r)},[t,e]);}function hr(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function wr({mount:e,label:t,icon:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=Un.useState(null),d=Ye({onPointerDown:r,onClick:o,isolate:a});return Un.useEffect(()=>{if(typeof document>"u")return;let c=e instanceof HTMLElement?e:e.current??null;u(c);},[e]),i?reactDom.createPortal(jsxRuntime.jsxs("button",{ref:d,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 Cr({config:e,portalTarget:t,hidden:n,onPointerDown:r,onClick:o,isolateEvents:a=true}){let[i,u]=Un.useState(null),[d,c]=Un.useState(false),m=Un.useRef(null),p=Ye({onPointerDown:T=>{r?.(T),m.current={x:T.clientX,y:T.clientY},c(true);let R=T.currentTarget;try{R?.setPointerCapture?.(T.pointerId);}catch{}},onClick:o,isolate:a});if(Un.useEffect(()=>{typeof document>"u"||u(t??document.body);},[t]),!i)return null;let C=`lumen-notch lumen-notch-${e.edge}${d?" lumen-notch-expanded":""}`;function k(T){let R=m.current;if(!R)return;let x=T.clientX-R.x,f=T.clientY-R.y;(e.edge==="top"&&f>16||e.edge==="bottom"&&f<-16||e.edge==="right"&&x<-16||e.edge==="left"&&x>16)&&(m.current=null,o(T.nativeEvent));}function y(){m.current=null,c(false);}function S(){m.current=null,c(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:p,type:"button",className:C,style:{zIndex:e.zIndex,opacity:n?0:1,pointerEvents:n?"none":"auto"},"aria-label":e.label,"aria-hidden":n?true:void 0,tabIndex:n?-1:0,onPointerMove:k,onPointerUp:y,onPointerCancel:S,onMouseEnter:()=>c(true),onMouseLeave:()=>c(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 Rr(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function Xa(e){return e===false?"off":e===true?"hide":e==="auto"||e==="lift"||e==="hide"?e:"auto"}function kr(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:Xa(e.hideOnKeyboard),zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var ei={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-radius":"radius"};function Sr(e){let t=Un.useId();Un.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,r=`data-lumen-theme-${ti(t)}`,o={},a=(i,u)=>{o[i]=n.style.getPropertyValue(i)||null,n.style.setProperty(i,u);};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,u]of Object.entries(ei)){let d=e[u];typeof d=="string"&&d.length>0&&a(i,d);}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,u]of Object.entries(o))i.startsWith("--")?u?n.style.setProperty(i,u):n.style.removeProperty(i):u==null?n.removeAttribute(i):n.setAttribute(i,u);}},[e,t]);}function ti(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var xr=Symbol.for("lumen.history.patched"),Xt="lumen:locationchange";function oi(){if(typeof window>"u")return;let e=window;if(e[xr])return;e[xr]=true;let t=()=>window.dispatchEvent(new Event(Xt)),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 Mr(e){let[t,n]=Un.useState(false);return Un.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;oi();let r=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return r(),window.addEventListener(Xt,r),window.addEventListener("popstate",r),()=>{window.removeEventListener(Xt,r),window.removeEventListener("popstate",r);}},[e]),t}var si=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function Pr(){let[e,t]=Un.useState(false);return Un.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||"";si.some(a=>o.includes(a))&&t(true);},[]),e}var Lr="lumen.config.v1.",ci=3600*1e3;function Nr(e,t){let[n,r]=Un.useState(()=>({trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:true}));return Un.useEffect(()=>{if(typeof window>"u")return;let o=bi(e);o&&r({trigger:o.trigger,enabled:Tr(o.trigger),shakeToOpen:o.shake,brand:o.brand,loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),u=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(u,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);let c=await d.json(),m=Ar(c.trigger);if(!m)throw new Error("Malformed config response");let p=pi(c.trigger),C=Ir(c.brand);gi(e,m,p,C),r({trigger:m,enabled:Tr(m),shakeToOpen:p,brand:C,loading:false});}).catch(()=>{r(d=>d.loading?{trigger:null,enabled:true,shakeToOpen:false,brand:null,loading:false}:d);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Tr(e){return e.kind!=="headless"}var di=["br","bl","tr","tl"],mi=["top","right","bottom","left"];function Ar(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:di.find(o=>o===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:mi.find(o=>o===t.edge)??"top",label:n}:null}function pi(e){return !e||typeof e!="object"?false:e.shake===true}var fi=/^#[0-9a-fA-F]{6}$/,hi=["auto","light","dark"];function Ir(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.accent=="string"&&fi.test(t.accent)?t.accent:null;if(!n)return null;let r=hi.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 bi(e){try{let t=window.localStorage.getItem(Lr+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>ci)return null;let r=Ar(n.trigger);return r?{fetchedAt:n.fetchedAt,trigger:r,shake:n.shake===!0,brand:Ir(n.brand)}:null}catch{return null}}function gi(e,t,n,r){try{window.localStorage.setItem(Lr+e,JSON.stringify({fetchedAt:Date.now(),trigger:t,shake:n,brand:r}));}catch{}}function wi(e){if(e&&typeof e=="object")return e.type===vt;if(typeof e=="string")try{return JSON.parse(e).type===vt}catch{return false}return false}function yi(e={}){let t=e.threshold??18,n=e.neededHits??3,r=e.windowMs??700,o=e.throttleMs??60,a=null,i=[];return {push(u,d,c,m){if(!a)return a={x:u,y:d,z:c,t:m},false;if(m-a.t<o)return false;let p=Math.abs(u-a.x)+Math.abs(d-a.y)+Math.abs(c-a.z);return a={x:u,y:d,z:c,t:m},p<t?false:(i=i.filter(C=>m-C<r),i.push(m),i.length>=n?(i=[],true):false)}}}function Dr(e,t,n){Un.useEffect(()=>{if(!e||typeof window>"u")return;let r=0,o=1500;function a(){let m=Date.now();n||m-r<o||(r=m,t());}let i=m=>{wi(m.data)&&a();};window.addEventListener("message",i),document.addEventListener("message",i);let u=yi(),d=m=>{let p=m.accelerationIncludingGravity??m.acceleration;!p||p.x==null||p.y==null||p.z==null||u.push(p.x,p.y,p.z,Date.now())&&a();},c=typeof window.DeviceMotionEvent<"u"&&typeof window.DeviceMotionEvent.requestPermission!="function";return c&&window.addEventListener("devicemotion",d),()=>{window.removeEventListener("message",i),document.removeEventListener("message",i),c&&window.removeEventListener("devicemotion",d);}},[e,t,n]);}var Br="https://shakebugs.vercel.app",kt=60;function Hr(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"}function Ri({apiKey:e,apiUrl:t,user:n,amplitude:r,floatingButton:o=true,trigger:a,hideOn:i,theme:u,portalTarget:d,capture:c,record:m,shakeToOpen:p,onOpenChange:C,beforeOpen:k,onTriggerActivate:y,isolateEvents:S=true,keyboardInset:T,suppressTrigger:R=false,children:x}){let[f,w]=Un.useState(false),[D,H]=Un.useState(false),[U,O]=Un.useState(null),[oe,A]=Un.useState(null),[V]=Un.useState(false),[te]=Un.useState(null),ne=Un.useRef(false),Ee=Un.useRef(false),fe=Un.useRef(null),z=Un.useMemo(()=>new wn({apiKey:e,apiUrl:t,user:n,amplitude:r}),[e,t,n?.id,n?.email,n?.name,r?.userId,r?.deviceId,r?.sessionId]);Un.useEffect(()=>{Nn({ignoreUrlPrefix:(t??Br).replace(/\/$/,"")});},[t]);let Oe=Un.useRef(C);Oe.current=C,Un.useEffect(()=>{if(!(typeof document>"u"))return f?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[f]);let Be=Un.useRef(null);Un.useEffect(()=>{if(Be.current===f)return;let E=Be.current;Be.current=f,E!==null&&Oe.current?.(f);},[f]);let he=Un.useRef(k);he.current=k;let Me=Un.useRef(y);Me.current=y;let Ce=Un.useCallback(E=>{Ee.current=true,fe.current=Promise.resolve().then(()=>he.current?.(E)).then(()=>Me.current?.(E)).then(()=>{});},[]),ae=Un.useCallback(E=>{ne.current||f||ke.current||le.current||(ne.current=true,H(true),O(null),A(null),(async()=>{try{if(Ee.current?await fe.current:(await he.current?.(E),await Me.current?.(E)),c?.mode==="manual")O(null),A(null);else if(c?.provider)O(null),A(null);else {let $=await bt({...c,mode:c?.mode??"auto",target:c?.target??document.documentElement});O($);}}catch($){A($ instanceof Error?$:new Error(String($)));}finally{Ee.current=false,fe.current=null,ne.current=false,H(false),w(true);}})());},[c,f]),Re=Un.useCallback(()=>{w(false),O(null),A(null);},[]),b=Un.useCallback(z.submit.bind(z),[z]),[v,M]=Un.useState(0),L=Un.useCallback(()=>{ne.current=false,H(false),w(false),O(null),A(null),M(E=>E+1);},[]),[_,W]=Un.useState(null),[re,K]=Un.useState(null),me=Un.useRef(null),be=Un.useRef(null),ke=Un.useRef(false),F=Un.useRef(null),Pe=Un.useRef(null),ie=Un.useRef(null),Se=Un.useCallback((E,$=false)=>{if(me.current=null,be.current=null,ke.current=false,W(null),!E){F.current=null;return}Pe.current={blob:E.blob,durationMs:E.durationMs,poster:F.current,deriveBlobPoster:$},F.current=null,w(true);},[]);Un.useEffect(()=>{if(!f)return;if(!m?.provider){K(null);return}let E=m.isAvailable;if(!E){K(true);return}let $=false;return Promise.resolve().then(()=>E()).then(q=>{$||K(q);}).catch(()=>{$||K(false);}),()=>{$=true;}},[f,m?.provider,m?.isAvailable]);let lt=Gt({hasProvider:!!m?.provider,providerAvailable:re,hasGetDisplayMedia:Hr()}).canRecord,He=Un.useCallback(async()=>{if(ke.current)return;if(ie.current=null,Gt({hasProvider:!!m?.provider,providerAvailable:re,hasGetDisplayMedia:Hr()}).usingProvider&&m?.provider){ke.current=true,F.current=null,w(false),be.current=dr(m.provider,{maxDurationSeconds:kt},{onStarting:()=>W({phase:"starting"}),onActive:q=>{W({phase:"recording",stream:q.stream??null,startedAt:Date.now(),maxSeconds:kt}),q.stream&&Wt(q.stream).then(Xe=>{F.current=Xe;}).catch(()=>{});},onProcessing:()=>W({phase:"processing"}),onResult:q=>Se({blob:q.blob,durationMs:q.durationMs},true),onCancelled:()=>{be.current=null,ke.current=false,F.current=null,W(null),O(null),A(null),w(true);},onError:q=>{be.current=null,ke.current=false,F.current=null,W(null),ie.current=q.message||"Screen recording could not start.",w(true);}});return}if(me.current)return;let $=await On(kt);me.current=$,ke.current=true,F.current=null,W({phase:"recording",stream:$.stream,startedAt:Date.now(),maxSeconds:kt}),w(false),Wt($.stream).then(q=>{F.current=q;}).catch(()=>{}),$.result.then(q=>Se(q)).catch(()=>Se(null));},[Se,m?.provider,re]),ge=Un.useCallback(()=>{be.current?be.current.stop():me.current?.stop();},[]),ve=Un.useCallback(()=>{if(be.current){be.current.cancel();return}let E=me.current;me.current=null,ke.current=false,F.current=null,W(null),E?.cancel(),O(null),A(null),w(true);},[]),ut=Un.useCallback(()=>{let E=Pe.current;return Pe.current=null,E},[]),_e=Un.useCallback(()=>{let E=ie.current;return ie.current=null,E},[]);Un.useEffect(()=>{f||(ie.current=null);},[f]);let[xe,Fe]=Un.useState(null),X=Un.useRef(null),We=Un.useRef(null),le=Un.useRef(false),Te=Un.useCallback(()=>{let E=X.current;X.current=null,le.current=false,E?.stop(),Fe(null),w(true);},[]),Ke=Un.useCallback(()=>{let E=X.current;E&&(Fe({phase:"grabbing"}),(async()=>{try{let $=await E.grab();if(X.current!==E)return;We.current=$,X.current=null,le.current=!1,E.stop(),Fe(null),w(!0);}catch{if(X.current!==E)return;X.current=null,le.current=false,E.stop(),Fe(null),sonner.toast.error("Could not capture the screen. Please try again."),w(true);}})());},[]),Ge=Un.useCallback(async()=>{if(le.current)return;let E;try{E=await Nt({...c});}catch{return}X.current=E,le.current=true,E.onEnded(()=>Te()),Fe({phase:"live"}),w(false);},[c,Te]),Ze=Un.useCallback(()=>{let E=We.current;return We.current=null,E},[]);Un.useEffect(()=>()=>{X.current?.stop(),X.current=null;},[]);let Le=Pr(),we=Mr(i),Ne=Nr(a?"":e,t??Br);Sr(u??xi(Ne.brand));let Ue=p??Ne.shakeToOpen;Dr(Ue,ae,f);let ct=Un.useMemo(()=>({client:z,user:n,isOpen:f,isSubmitting:V,error:te,open:ae,close:Re,openCapture:ae,closeCapture:Re,submit:b,isNativeShell:Le,capture:c,initialCapture:U,initialCaptureError:oe,isOpening:D,startVideoSession:He,stopVideoSession:ge,cancelVideoSession:ve,recording:_,consumePendingVideo:ut,canRecordScreen:lt,consumeRecordStartError:_e,startScreenCaptureSession:Ge,grabScreenCaptureFrame:Ke,cancelScreenCaptureSession:Te,screenCapture:xe,consumePendingScreenshot:Ze,isolateEvents:S,keyboardInset:T}),[z,n,f,V,te,ae,Re,b,Le,c,U,oe,He,ge,ve,_,ut,lt,_e,Ge,Ke,Te,xe,Ze,D,S,T]),J=Si({explicit:a,remote:Ne.trigger,remoteLoading:Ne.loading,floatingButton:o});return jsxRuntime.jsxs(Ot.Provider,{value:ct,children:[x,jsxRuntime.jsxs(Ct,{onReset:L,onError:E=>z.reportClientError({...E,context:{open:f,opening:D,screenCapturePhase:xe?.phase,recordingPhase:_?.phase,initialCaptureMethod:U?.method,initialCapturePixelRatio:U?.pixelRatio,initialCaptureViewport:U?.viewport,hadInitialCaptureError:oe!=null}}),children:[J?.kind==="floating"?jsxRuntime.jsx(vr,{config:kr(J),portalTarget:d,hidden:we||R||D||_!=null||xe!=null,onPointerDown:Ce,onClick:E=>ae(E),isolateEvents:S,keyboardInset:T}):null,J?.kind==="notch"?jsxRuntime.jsx(Cr,{config:Rr(J),portalTarget:d,hidden:we||R||D||_!=null||xe!=null,onPointerDown:Ce,onClick:E=>ae(E),isolateEvents:S}):null,J?.kind==="inline"?jsxRuntime.jsx(wr,{mount:J.mount,label:J.label??"Feedback",icon:J.icon,onPointerDown:Ce,onClick:E=>ae(E),isolateEvents:S}):null,xe?jsxRuntime.jsx(lr,{state:xe,portalTarget:d,onCapture:Ke,onCancel:Te}):null,_?jsxRuntime.jsx(sr,{state:_,portalTarget:d,onStop:ge,onCancel:ve}):null,jsxRuntime.jsx(Yt,{})]},v),jsxRuntime.jsx(ki,{})]})}function ki(){let[e,t]=Un.useState(false);return Un.useEffect(()=>{t(!document.querySelector("[data-sonner-toaster]"));},[]),e?jsxRuntime.jsx(sonner.Toaster,{position:"top-center",style:{zIndex:2147483647}}):null}function Si(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function xi(e){if(e)return {accent:e.accent,radius:`${e.radius}px`,scheme:e.mode}}function Mi({variant:e="default",floating:t=false,className:n,children:r="Feedback",onClick:o,...a}){let{openCapture:i}=nt(),u=["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:u,"data-lumen-trigger":"",onClick:d=>{o?.(d),d.defaultPrevented||i(d.nativeEvent);},...a,children:r})}
|
|
5
|
+
exports.CaptureModal=Yt;exports.FeedbackButton=Mi;exports.LUMEN_KEYBOARD_CSS_VAR=It;exports.LUMEN_KEYBOARD_EVENT=tt;exports.LUMEN_SHAKE_MESSAGE=vt;exports.LumenProvider=Ri;exports.createNativeCaptureProvider=Ho;exports.isLumenEventTarget=Ao;exports.isolateLumenEvents=Io;exports.readLumenKeyboardInset=Dt;exports.setLumenKeyboardInset=qo;exports.useKeyboardInset=ot;exports.useLumen=nt;//# sourceMappingURL=index.cjs.map
|
|
6
6
|
//# sourceMappingURL=index.cjs.map
|