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