@lumen-stack/react 0.15.2 → 0.16.0

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