@lumen-stack/react 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -1
- package/dist/index.d.ts +43 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var
|
|
3
|
-
${o.stack}`:""}`);continue}try{t.push(JSON.stringify(o,on));}catch{t.push(String(o));}}let n=t.join(" ");return n.length>4096?n.slice(0,4096)+"\u2026[truncated]":n}function on(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function rn(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let o=e[n]?.bind(e);o&&(e[n]=(...r)=>{try{ie(Ge,{level:n,ts:Date.now(),message:nn(r)});}catch{}o(...r);});}}function Ze(e){return he?e.startsWith(he):false}function an(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let o=typeof t=="string"?t:t instanceof URL?t.toString():t.url,r=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(Ze(o))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ie(ae,{type:"fetch",method:r,url:we(o),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ie(ae,{type:"fetch",method:r,url:we(o),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function sn(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(o,r,...a){return this.__lumen={method:String(o).toUpperCase(),url:typeof r=="string"?r:r.toString(),t:0},t.call(this,o,r,...a)},e.prototype.send=function(o){let r=this.__lumen;if(r&&!Ze(r.url)){r.t=performance.now();let a=()=>{try{ie(ae,{type:"xhr",method:r.method,url:we(r.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-r.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,o??null)};}function we(e){return e.length>512?e.slice(0,512)+"\u2026":e}function Qe(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:We(e),consoleLog:[],networkLog:[]};let t=tn();return {url:window.location.href,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:We(e),device:ln(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function ln(){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||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 We(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}async function et(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new L("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new L("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(u=>MediaRecorder.isTypeSupported(u))??"",o=new MediaRecorder(t,n?{mimeType:n}:void 0),r=[],a=performance.now(),i=null;o.addEventListener("dataavailable",u=>{u.data&&u.data.size>0&&r.push(u.data);}),o.start(),i=window.setTimeout(()=>{o.state!=="inactive"&&o.stop();},e*1e3);function s(){i!==null&&window.clearTimeout(i),i=null;for(let u of t.getTracks())u.stop();}return {stream:t,cancel(){try{o.state!=="inactive"&&o.stop();}catch{}s();},stop(){return new Promise((u,c)=>{if(o.state==="inactive"){s(),c(new L("Recorder already stopped.","RECORDER_STOPPED"));return}o.addEventListener("stop",()=>{let f=performance.now()-a,b=o.mimeType||n||"audio/webm",v=new Blob(r,{type:b});s(),u({blob:v,durationMs:f,mimeType:b});},{once:true}),o.stop();})}}}async function tt(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new L("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new L("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(c=>MediaRecorder.isTypeSupported(c))??"",o=new MediaRecorder(t,n?{mimeType:n}:void 0),r=[],a=performance.now(),i=null;o.addEventListener("dataavailable",c=>{c.data&&c.data.size>0&&r.push(c.data);}),o.start(),i=window.setTimeout(()=>{o.state!=="inactive"&&o.stop();},e*1e3);let s=t.getVideoTracks()[0];s&&s.addEventListener("ended",()=>{o.state!=="inactive"&&o.stop();});function u(){i!==null&&window.clearTimeout(i),i=null;for(let c of t.getTracks())c.stop();}return {stream:t,cancel(){try{o.state!=="inactive"&&o.stop();}catch{}u();},stop(){return new Promise((c,f)=>{if(o.state==="inactive"){u(),f(new L("Recorder already stopped.","RECORDER_STOPPED"));return}o.addEventListener("stop",()=>{let b=performance.now()-a,v=o.mimeType||n||"video/webm",x=new Blob(r,{type:v});u(),c({blob:x,durationMs:b,mimeType:v});},{once:true}),o.stop();})}}}var ve=react.createContext(null);function Z(){let e=react.useContext(ve);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}function rt({screenshot:e,tool:t,color:n="rgb(239, 68, 68)",strokeWidth:o=4,onDrawingChange:r,ref:a}){let i=react.useRef(null),s=react.useRef(null),u=react.useRef(null),[c,f]=react.useState(null),[b,v]=react.useState([]),x=react.useRef(null),y=react.useRef(false),E=react.useRef(0),C=react.useRef(false);react.useEffect(()=>{let m=false,p=null;return (async()=>{try{let w=await createImageBitmap(e);if(m){w.close?.();return}p=w,f(w);}catch{}})(),()=>{m=true,p?.close?.();}},[e]),react.useEffect(()=>{if(!c)return;let m=i.current,p=s.current;if(!m||!p)return;m.width=c.width,m.height=c.height,p.width=c.width,p.height=c.height;let w=m.getContext("2d");w&&(w.imageSmoothingEnabled=false,w.drawImage(c,0,0));},[c]),react.useEffect(()=>{let m=s.current;m&&le(m,b,x.current);},[b]),react.useImperativeHandle(a,()=>({hasAnnotations:()=>b.length>0,reset:()=>v([]),undo:()=>v(m=>m.length===0?m:m.slice(0,-1)),async flatten(){let m=x.current,p=m?[...b,m]:b;if(p.length===0||!c)return e;let w=document.createElement("canvas");w.width=c.width,w.height=c.height;let k=w.getContext("2d");if(!k)return e;k.imageSmoothingEnabled=false,k.drawImage(c,0,0);for(let P of p)xe(k,P);return await new Promise(P=>{w.toBlob(D=>{P(D??e);},"image/jpeg",.85);})}}),[b,c,e]);function R(m){let p=s.current;if(!p)return {x:0,y:0};let w=p.getBoundingClientRect(),k=p.width/Math.max(w.width,1),P=p.height/Math.max(w.height,1);return {x:(m.clientX-w.left)*k,y:(m.clientY-w.top)*P}}function N(){C.current||(C.current=true,requestAnimationFrame(()=>{C.current=false;let m=s.current;m&&le(m,b,x.current);}));}function M(m){if(m.button!==void 0&&m.button!==0)return;try{m.currentTarget.setPointerCapture(m.pointerId);}catch{}y.current=true,r?.(true);let p=R(m);t==="arrow"?x.current={kind:"arrow",from:p,to:p,color:n,width:o}:t==="rect"?x.current={kind:"rect",from:p,to:p,color:n,width:o}:x.current={kind:"freehand",points:[p],color:n,width:o},E.current=performance.now(),N();}function S(m){if(!y.current||!x.current)return;let p=R(m),w=x.current;if(w.kind==="arrow"||w.kind==="rect")w.to=p;else {let k=w.points[w.points.length-1],P=k?(k.x-p.x)**2+(k.y-p.y)**2:1/0,D=performance.now(),j=D-E.current;(P>16||j>16)&&(w.points.push(p),E.current=D);}N();}function I(){if(!y.current)return;y.current=false,r?.(false);let m=x.current;if(x.current=null,!!m){if(m.kind==="arrow"||m.kind==="rect"){let p=m.to.x-m.from.x,w=m.to.y-m.from.y;if(p*p+w*w<16){let k=s.current;k&&le(k,b,null);return}}else if(m.points.length<2){let p=s.current;p&&le(p,b,null);return}v(p=>[...p,m].slice(-50));}}return jsxRuntime.jsxs("div",{ref:u,className:"lumen-annotate-frame",children:[jsxRuntime.jsx("canvas",{ref:i}),jsxRuntime.jsx("canvas",{ref:s,className:"lumen-annotate-overlay",onPointerDown:M,onPointerMove:S,onPointerUp:I,onPointerCancel:I})]})}function le(e,t,n){let o=e.getContext("2d");if(o){o.clearRect(0,0,e.width,e.height);for(let r of t)xe(o,r);n&&xe(o,n);}}function xe(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),o=Math.min(t.from.y,t.to.y),r=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,o,r,a);}else if(t.kind==="freehand")pn(e,t.points);else {let{from:n,to:o,width:r}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(o.x,o.y),e.stroke();let a=Math.atan2(o.y-n.y,o.x-n.x),i=Math.max(12,r*4);e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(o.x-i*Math.cos(a-Math.PI/7),o.y-i*Math.sin(a-Math.PI/7)),e.lineTo(o.x-i*Math.cos(a+Math.PI/7),o.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function pn(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 r=t[1];e.lineTo(r.x,r.y),e.stroke();return}for(let r=1;r<t.length-1;r++){let a=t[r],i=t[r+1],s=(a.x+i.x)/2,u=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,s,u);}let o=t[t.length-1];e.lineTo(o.x,o.y),e.stroke();}var Ee=60,gn=60,at=[{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)"}],it=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],st=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],bn=[{value:"shot",label:"Screenshot",hint:"This page, instantly"},{value:"screen",label:"Screen",hint:"Pick a window or tab"},{value:"video",label:"Video",hint:"Record up to 60s"}];function ke(){let{client:e,isOpen:t,closeCapture:n,user:o,capture:r}=Z(),[a,i]=react.useState(1),[s,u]=react.useState(null),[c,f]=react.useState({kind:"idle"}),[b,v]=react.useState(false),[x,y]=react.useState(0),[E,C]=react.useState(null),[R,N]=react.useState(false),[M,S]=react.useState("arrow"),[I,m]=react.useState(at[0].value),[p,w]=react.useState(it[1].value),[k,P]=react.useState(""),[D,j]=react.useState("bug"),[_,Q]=react.useState(o?.email??""),[O,de]=react.useState(null),[B,Y]=react.useState(null),[Pt,me]=react.useState(0),[K,ee]=react.useState(null),[W,pe]=react.useState(null),[It,Dt]=react.useState(false),te=react.useRef(null),Ne=react.useRef(null),Se=react.useRef(null),X=react.useRef(false);if(react.useEffect(()=>{if(t)return X.current=false,i(1),u(null),P(""),Y(null),me(0),pe(null),v(false),y(0),C(null),N(false),ee(l=>(l?.cancel(),null)),f(r?.mode==="manual"?{kind:"manual"}:{kind:"idle"}),()=>{X.current=true;}},[t,r]),react.useEffect(()=>{if(!t)return;Se.current=document.activeElement??null;let l=document.documentElement,h=l.style.overflow,A=l.style.paddingRight,H=window.innerWidth-l.clientWidth;l.style.overflow="hidden",H>0&&(l.style.paddingRight=`${H}px`);let F=false,V=()=>{if(!F){F=true,l.style.overflow=h,l.style.paddingRight=A;try{Se.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",V),()=>{window.removeEventListener("pagehide",V),V();}},[t]),react.useEffect(()=>{if(!t)return;function l(h){if(h.key==="Escape"){h.preventDefault(),n();return}if(h.key!=="Tab")return;let A=Ne.current;if(!A)return;let H=kn(A);if(H.length===0)return;let F=H[0],V=H[H.length-1],be=document.activeElement;h.shiftKey&&(be===F||!A.contains(be))?(h.preventDefault(),V.focus()):!h.shiftKey&&be===V&&(h.preventDefault(),F.focus());}return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t,n]),react.useEffect(()=>{if(!t||c.kind!=="manual")return;function l(h){let F=Array.from(h.clipboardData?.items??[]).find(V=>V.type.startsWith("image/"))?.getAsFile();F&&(h.preventDefault(),Pe(F));}return window.addEventListener("paste",l),()=>window.removeEventListener("paste",l)},[t,c.kind]),react.useEffect(()=>{if(!O)return;let l=Date.now(),h=window.setInterval(()=>{let A=Math.floor((Date.now()-l)/1e3);me(A),A>=Ee&&De();},250);return ()=>window.clearInterval(h)},[O]),!t)return null;async function fe(l){X.current=false,f({kind:"capturing"});try{let h=await qe({...r,mode:l,target:r?.target??document.documentElement});return X.current?!1:(Ot(h),f({kind:"ready",capture:h}),!0)}catch(h){return X.current||f({kind:"manual",error:h instanceof Error?h.message:"Automatic screenshot capture was unavailable."}),false}}async function Ae(l){u(l),C(null),l!=="video"&&He(),l==="shot"?await fe(r?.mode??"auto"):l==="screen"?await fe("true-screen"):await fe(r?.mode??"auto")&&await Oe();}function Pe(l){if(!l.type.startsWith("image/")){sonner.toast.error("Choose a PNG, JPEG, or WebP screenshot.");return}let h=Ke(l,["Manual screenshot upload used."]);f({kind:"ready",capture:h});}function Ot(l){l.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function Ie(){try{let l=await et(Ee);de(l);}catch(l){sonner.toast.error(l instanceof Error?l.message:"Microphone unavailable");}}async function De(){if(O)try{let l=await O.stop();Y({blob:l.blob,durationMs:l.durationMs});}catch(l){sonner.toast.error(l instanceof Error?l.message:"Could not stop recording");}finally{de(null);}}function Ht(){O?.cancel(),de(null),Y(null),me(0);}async function Oe(){try{let l=await tt(gn);ee(l),l.stream.getVideoTracks()[0]?.addEventListener("ended",()=>{ne();});}catch(l){sonner.toast.error(l instanceof Error?l.message:"Screen capture unavailable");}}async function ne(){if(!K)return;let l=K;ee(null);try{let h=await l.stop();pe({blob:h.blob,durationMs:h.durationMs});}catch(h){sonner.toast.error(h instanceof Error?h.message:"Could not stop recording");}}function He(){K?.cancel(),ee(null),pe(null);}let Ft=c.kind==="ready";async function Bt(){if(a===1){if(K&&await ne(),c.kind==="ready"){let l=await te.current?.flatten();C(l??c.capture.blob),N(l!=null&&l!==c.capture.blob);}i(2);}else a===2?i(3):await Vt();}function _t(){a>1&&i(l=>l-1);}async function Vt(){if(c.kind!=="ready")return;let l=k.trim(),{capture:h}=c;v(true),y(0);try{let A=E??h.blob,H=await e.submit({rawText:l.length>0?l:void 0,category:D,submitterEmail:_.trim()||void 0,screenshot:A,audio:B?.blob,audioDurationMs:B?.durationMs,video:W?.blob,videoDurationMs:W?.durationMs,context:Qe(h)},{onUploadProgress:F=>y(Math.min(.95,F))});y(1),sonner.toast.success("Feedback sent \u2014 thank you."),H.id,n();}catch(A){sonner.toast.error(A instanceof Error?A.message:"Could not submit feedback"),v(false);}}function zt(l){l.target===l.currentTarget&&!b&&n();}let oe=Math.round(x*100),ge=s==="video",Ut=a===1&&!Ft||b,Wt=a<3?"Next":b?oe<95?`Uploading ${oe}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",onMouseDown:zt,children:jsxRuntime.jsxs("div",{ref:Ne,className:"lumen-modal","data-lumen-drawing":It?"true":void 0,children:[jsxRuntime.jsx(wn,{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(hn,{step:a}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[a===1?jsxRuntime.jsxs("div",{className:"lumen-pane",children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:bn.map(l=>jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn","aria-pressed":s===l.value,onClick:()=>Ae(l.value),disabled:c.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:l.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:l.hint})]},l.value))}),c.kind==="idle"?jsxRuntime.jsxs("div",{className:"lumen-cap-empty",children:[jsxRuntime.jsx("p",{children:"Pick a capture method above \u2014 nothing is captured until you choose, so take your time positioning the screen."}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>f({kind:"manual"}),children:"Or upload a screenshot"})]}):null,c.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,c.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:c.error?"Automatic capture was unavailable. Upload or paste a screenshot to continue.":"Upload or paste a screenshot to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:"Choose or paste a screenshot"}),jsxRuntime.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",onChange:l=>{let h=l.currentTarget.files?.[0];h&&Pe(h),l.currentTarget.value="";}})]})]}):null,c.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[ge?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(Ce,{label:"Arrow",active:M==="arrow",onClick:()=>S("arrow")}),jsxRuntime.jsx(Ce,{label:"Box",active:M==="rect",onClick:()=>S("rect")}),jsxRuntime.jsx(Ce,{label:"Draw",active:M==="freehand",onClick:()=>S("freehand")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:at.map(l=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:l.value},"aria-label":l.label,"aria-pressed":I===l.value,onClick:()=>m(l.value)},l.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:it.map(l=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":l.label,"aria-pressed":p===l.value,onClick:()=>w(l.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:l.dot,height:l.dot}})},l.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>te.current?.undo(),children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>te.current?.reset(),children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(rt,{ref:te,screenshot:c.capture.blob,tool:M,color:I,strokeWidth:p,onDrawingChange:Dt})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>s&&Ae(s),children:ge?"\u21BB Re-record":"\u21BB Recapture"}),ge?K?jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-time",children:"Recording\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:ne,children:"Stop"})]}):W?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round(W.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:[lt(s)," captured \xB7 switch method above anytime"]})]})]}):null]}):null,a===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:k,onChange:l=>P(l.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!O&&!B?jsxRuntime.jsx("button",{type:"button",onClick:Ie,className:"lumen-btn-ghost",children:"Record voice note"}):null,O?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(vn,{stream:O.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[Pt,"s / ",Ee,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:De,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:Ht,className:"lumen-btn-ghost",children:"Cancel"})]}):null,B&&!O?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(xn,{blob:B.blob,durationMs:B.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Y(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]})]}),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:st.map(l=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":D===l.value,onClick:()=>j(l.value),children:l.label},l.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:_,onChange:l=>Q(l.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,a===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[lt(s),R?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>i(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:st.find(l=>l.value===D)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>i(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[k.trim()?k.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>i(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[B?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(B.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>Y(null),children:"\xD7"})]}):null,W?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round(W.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:He,children:"\xD7"})]}):null,_.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",_.trim()]}):null,!B&&!O?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{i(2),Ie();},children:"+ Voice note"}):null,K?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-attach",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),"Recording\u2026"]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:ne,children:"Stop"})]}):W?null:jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:Oe,children:"+ Screen recording"})]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[b?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":oe,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${oe}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:a===1?n:_t,className:"lumen-btn-ghost",disabled:b,children:a===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:Bt,className:"lumen-btn-primary",disabled:Ut,children:Wt})]})]})]})})}function lt(e){return e==="video"?"Screen recording":e==="screen"?"Screen capture":"Screenshot"}function hn({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,o)=>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}),o<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function Ce({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function wn({onDismiss:e}){let t=react.useRef(null),n=react.useRef(0),o=react.useRef(null);function r(s){s.currentTarget.setPointerCapture(s.pointerId),t.current=s.clientY,n.current=performance.now(),o.current=s.currentTarget.parentElement;}function a(s){if(t.current==null||!o.current)return;let u=Math.max(0,s.clientY-t.current);o.current.style.transform=`translateY(${u}px)`;}function i(s){if(t.current==null||!o.current)return;let u=Math.max(0,s.clientY-t.current),c=Math.max(1,performance.now()-n.current),f=u/c;o.current.style.transform="",o.current.style.transition="",t.current=null,(u>80||f>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:r,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function vn({stream:e}){let t=react.useRef(null);return react.useEffect(()=>{let n=t.current;if(!n)return;let o=Math.min(window.devicePixelRatio||1,2),r=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(r*o),n.height=Math.round(a*o);let i=n.getContext("2d");if(!i)return;i.scale(o,o);let s=window.AudioContext??window.webkitAudioContext;if(!s)return;let u=new s,c=u.createMediaStreamSource(e),f=u.createAnalyser();f.fftSize=1024,f.smoothingTimeConstant=.6,c.connect(f);let b=new Uint8Array(f.fftSize),v=18,x=3,y=3,E=Math.max(2,(r-x*(v-1))/v),C=Math.min(E/2,3),R=new Array(v).fill(0),N=0,M=false;function S(){if(M)return;f.getByteTimeDomainData(b);let I=Math.floor(b.length/v);i.clearRect(0,0,r,a),i.fillStyle=En("--lumen-danger")||"rgb(239,68,68)";for(let m=0;m<v;m++){let p=0;for(let _=0;_<I;_++){let Q=Math.abs((b[m*I+_]??128)-128);Q>p&&(p=Q);}let w=Math.min(1,p/128*1.8),k=R[m]??0;R[m]=w>k?w:k+(w-k)*.35;let P=Math.max(y,R[m]*a),D=m*(E+x),j=(a-P)/2;yn(i,D,j,E,P,C),i.fill();}N=requestAnimationFrame(S);}return N=requestAnimationFrame(S),()=>{M=true,cancelAnimationFrame(N);try{c.disconnect();}catch{}u.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function yn(e,t,n,o,r,a){let i=Math.min(a,o/2,r/2);e.beginPath();let s=e;if(typeof s.roundRect=="function"){s.roundRect(t,n,o,r,i);return}e.moveTo(t+i,n),e.arcTo(t+o,n,t+o,n+r,i),e.arcTo(t+o,n+r,t,n+r,i),e.arcTo(t,n+r,t,n,i),e.arcTo(t,n,t+o,n,i),e.closePath();}function xn({blob:e,durationMs:t}){let[n,o]=react.useState("");return react.useEffect(()=>{let r=URL.createObjectURL(e);return o(r),()=>{URL.revokeObjectURL(r);}},[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 En(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var Cn='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function kn(e){return Array.from(e.querySelectorAll(Cn)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}function ut(){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,o=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],r=new Set,a=0;for(let i of o){let s=document.elementsFromPoint(i,n);for(let u of s){if(r.has(u))continue;r.add(u);let c=window.getComputedStyle(u);if(c.position!=="fixed"&&c.position!=="sticky")continue;let f=u.getBoundingClientRect();f.bottom<t-8||f.bottom>t+8||f.width<e*.6||f.height>a&&(a=f.height);}}return a}function Le(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,o=window.innerHeight,r=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let s of Array.from(i)){let u=s.getBoundingClientRect();if(u.height===0||u.width===0)continue;let c=0;switch(t){case "bottom":if(u.bottom<o-8)break;c=Math.max(0,o-u.top);break;case "top":if(u.top>8)break;c=Math.max(0,u.bottom);break;case "left":if(u.left>8)break;c=Math.max(0,u.right);break;case "right":if(u.right<n-8)break;c=Math.max(0,n-u.left);break}c>r&&(r=c);}}return r}function ct(e){let[t,n]=react.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),o=react.useRef(t),r=Mn(e.avoid),a=e.placement,i=e.offset.x,s=e.offset.y;return react.useEffect(()=>{if(typeof window>"u")return;let u=0,c=false,f=()=>{if(u=0,c)return;let E=a[0]==="b"?"bottom":"top",C=a[1]==="r"?"right":"left",R=0,N=0;e.avoid==="auto"&&E==="bottom"?R=ut():Array.isArray(e.avoid)&&(R=Le(e.avoid,E),N=Le(e.avoid,C));let M={bottom:E==="bottom"?s+R:0,top:E==="top"?s+R:0,right:C==="right"?i+N:0,left:C==="left"?i+N:0},S=o.current;(M.bottom!==S.bottom||M.top!==S.top||M.right!==S.right||M.left!==S.left)&&(o.current=M,n(M));},b=()=>{u||(u=window.requestAnimationFrame(f));};b();let v=typeof ResizeObserver<"u"?new ResizeObserver(b):null;v?.observe(document.documentElement);let x=typeof MutationObserver<"u"?new MutationObserver(b):null;x?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",b);let y=window.visualViewport;return y?.addEventListener("resize",b),y?.addEventListener("scroll",b),()=>{c=true,u&&window.cancelAnimationFrame(u),v?.disconnect(),x?.disconnect(),window.removeEventListener("resize",b),y?.removeEventListener("resize",b),y?.removeEventListener("scroll",b);}},[a,i,s,r]),t}function Mn(e){return e===false?"false":e==="auto"?"auto":e.join("|")}function dt(e){let[t,n]=react.useState(false);return react.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;let o=window.visualViewport;if(!o||typeof window.matchMedia!="function"||!window.matchMedia("(pointer: coarse)").matches)return;let r=100,a=0,i=()=>{a=0;let u=window.innerHeight-o.height;n(u>r);},s=()=>{a||(a=window.requestAnimationFrame(i));};return s(),o.addEventListener("resize",s),o.addEventListener("scroll",s),()=>{a&&window.cancelAnimationFrame(a),o.removeEventListener("resize",s),o.removeEventListener("scroll",s);}},[e]),t}function gt({config:e,portalTarget:t,hidden:n,onClick:o}){let[r,a]=react.useState(null),i=react.useRef(null),s=ct(e),u=dt(e.hideOnKeyboard);if(react.useEffect(()=>{typeof document>"u"||a(t??document.body);},[t]),In(i,!n&&!u),!r)return null;let c=e.placement,f=c[0]==="b"?"bottom":"top",b=c[1]==="r"?"right":"left",v=f==="bottom"?s.bottom:s.top,x=b==="right"?s.right:s.left,y={position:"fixed",[f]:e.safeArea?`calc(${v}px + env(safe-area-inset-${f}, 0px))`:`${v}px`,[b]:e.safeArea?`calc(${x}px + env(safe-area-inset-${b}, 0px))`:`${x}px`,zIndex:e.zIndex,opacity:n||u?0:1,pointerEvents:n||u?"none":"auto",transition:"opacity 160ms ease"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:i,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:y,"aria-label":e.label,"aria-hidden":n||u?true:void 0,tabIndex:n||u?-1:0,onClick:o,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),r)}function In(e,t){let n=react.useRef(false);react.useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let o=window.setTimeout(()=>{let r=e.current;if(!r)return;let a=r.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,s=a.top+a.height/2,u=document.elementsFromPoint(i,s),c=mt(window.getComputedStyle(r).zIndex);for(let f of u){if(f===r||r.contains(f))continue;if(mt(window.getComputedStyle(f).zIndex)>c){n.current=true,console.warn("[lumen] trigger is occluded by",f);break}}},250);return ()=>window.clearTimeout(o)},[t,e]);}function mt(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function bt({mount:e,label:t,icon:n,onClick:o}){let[r,a]=react.useState(null);return react.useEffect(()=>{if(typeof document>"u")return;let i=e instanceof HTMLElement?e:e.current??null;a(i);},[e]),r?reactDom.createPortal(jsxRuntime.jsxs("button",{type:"button",className:"lumen-btn lumen-btn-primary",onClick:o,"aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),r):null}function vt({config:e,portalTarget:t,hidden:n,onClick:o}){let[r,a]=react.useState(null),[i,s]=react.useState(false),u=react.useRef(null);if(react.useEffect(()=>{typeof document>"u"||a(t??document.body);},[t]),!r)return null;let c=`lumen-notch lumen-notch-${e.edge}${i?" lumen-notch-expanded":""}`;function f(y){u.current={x:y.clientX,y:y.clientY},s(true),y.currentTarget.setPointerCapture(y.pointerId);}function b(y){let E=u.current;if(!E)return;let C=y.clientX-E.x,R=y.clientY-E.y;(e.edge==="top"&&R>16||e.edge==="bottom"&&R<-16||e.edge==="right"&&C<-16||e.edge==="left"&&C>16)&&(u.current=null,o());}function v(){u.current=null,s(false);}function x(){u.current=null,s(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{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,onClick:o,onPointerDown:f,onPointerMove:b,onPointerUp:v,onPointerCancel:x,onMouseEnter:()=>s(true),onMouseLeave:()=>s(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]})]}),r)}function yt(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function xt(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],hideOnKeyboard:e.hideOnKeyboard??true,zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var jn={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-primary":"accent","--lumen-radius":"radius"};function Et(e){let t=react.useId();react.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,o=`data-lumen-theme-${Yn(t)}`,r={};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")r["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else for(let[a,i]of Object.entries(jn)){let s=e[i];typeof s=="string"&&s.length>0&&(r[a]=n.style.getPropertyValue(a)||null,n.style.setProperty(a,s));}return n.setAttribute(o,""),()=>{n.removeAttribute(o);for(let[a,i]of Object.entries(r))a.startsWith("--")?i?n.style.setProperty(a,i):n.style.removeProperty(a):i==null?n.removeAttribute(a):n.setAttribute(a,i);}},[e,t]);}function Yn(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Ct=Symbol.for("lumen.history.patched"),Re="lumen:locationchange";function Jn(){if(typeof window>"u")return;let e=window;if(e[Ct])return;e[Ct]=true;let t=()=>window.dispatchEvent(new Event(Re)),n=history.pushState;history.pushState=function(...r){let a=n.apply(this,r);return t(),a};let o=history.replaceState;history.replaceState=function(...r){let a=o.apply(this,r);return t(),a},window.addEventListener("popstate",t);}function kt(e){let[t,n]=react.useState(false);return react.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;Jn();let o=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return o(),window.addEventListener(Re,o),window.addEventListener("popstate",o),()=>{window.removeEventListener(Re,o),window.removeEventListener("popstate",o);}},[e]),t}var eo=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function Lt(){let[e,t]=react.useState(false);return react.useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let o=n.webkit;if(o&&o.messageHandlers){t(true);return}let r=navigator.userAgent||"";eo.some(a=>r.includes(a))&&t(true);},[]),e}var Tt="lumen.config.v1.",oo=3600*1e3;function Mt(e,t){let[n,o]=react.useState(()=>({trigger:null,enabled:true,loading:true}));return react.useEffect(()=>{if(typeof window>"u")return;let r=io(e);r&&o({trigger:r.trigger,enabled:Rt(r.trigger),loading:false});let a=new AbortController,i=window.setTimeout(()=>a.abort(),5e3),s=`${t.replace(/\/$/,"")}/api/v1/sdk/config?apiKey=${encodeURIComponent(e)}`;return fetch(s,{method:"GET",mode:"cors",credentials:"omit",signal:a.signal}).then(async u=>{if(!u.ok)throw new Error(`HTTP ${u.status}`);let c=await u.json(),f=Nt(c.trigger);if(!f)throw new Error("Malformed config response");so(e,f),o({trigger:f,enabled:Rt(f),loading:false});}).catch(()=>{o(u=>u.loading?{trigger:null,enabled:true,loading:false}:u);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Rt(e){return e.kind!=="headless"}var ro=["br","bl","tr","tl"],ao=["top","right","bottom","left"];function Nt(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:ro.find(r=>r===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:ao.find(r=>r===t.edge)??"top",label:n}:null}function io(e){try{let t=window.localStorage.getItem(Tt+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>oo)return null;let o=Nt(n.trigger);return o?{fetchedAt:n.fetchedAt,trigger:o}:null}catch{return null}}function so(e,t){try{window.localStorage.setItem(Tt+e,JSON.stringify({fetchedAt:Date.now(),trigger:t}));}catch{}}var At="https://shakebugs.vercel.app";function uo({apiKey:e,apiUrl:t,user:n,amplitude:o,floatingButton:r=true,trigger:a,hideOn:i,theme:s,portalTarget:u,capture:c,children:f}){let[b,v]=react.useState(false),[x]=react.useState(false),[y]=react.useState(null),E=react.useMemo(()=>new $e({apiKey:e,apiUrl:t,user:n,amplitude:o}),[e,t,n?.id,n?.email,n?.name,o?.userId,o?.deviceId,o?.sessionId]);react.useEffect(()=>{Je({ignoreUrlPrefix:(t??At).replace(/\/$/,"")});},[t]);let C=react.useCallback(()=>v(true),[]),R=react.useCallback(()=>v(false),[]),N=react.useCallback(E.submit.bind(E),[E]),M=Lt(),S=kt(i);Et(s);let I=Mt(a?"":e,t??At),m=react.useMemo(()=>({client:E,user:n,isOpen:b,isSubmitting:x,error:y,open:C,close:R,openCapture:C,closeCapture:R,submit:N,isNativeShell:M,capture:c}),[E,n,b,x,y,C,R,N,M,c]),p=co({explicit:a,remote:I.trigger,remoteLoading:I.loading,floatingButton:r});return jsxRuntime.jsxs(ve.Provider,{value:m,children:[f,p?.kind==="floating"?jsxRuntime.jsx(gt,{config:xt(p),portalTarget:u,hidden:S,onClick:C}):null,p?.kind==="notch"?jsxRuntime.jsx(vt,{config:yt(p),portalTarget:u,hidden:S,onClick:C}):null,p?.kind==="inline"?jsxRuntime.jsx(bt,{mount:p.mount,label:p.label??"Feedback",icon:p.icon,onClick:C}):null,jsxRuntime.jsx(ke,{})]})}function co(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function po({variant:e="default",floating:t=false,className:n,children:o="Feedback",onClick:r,...a}){let{openCapture:i}=Z(),s=["lumen-btn",e==="default"?"lumen-btn-primary":null,e==="ghost"?"lumen-btn-ghost":null,e==="outline"?"lumen-btn-outline":null,t?"lumen-btn-floating":null,n].filter(Boolean).join(" ");return jsxRuntime.jsx("button",{type:"button",className:s,onClick:u=>{r?.(u),u.defaultPrevented||i();},...a,children:o})}
|
|
4
|
-
exports.CaptureModal=ke;exports.FeedbackButton=
|
|
2
|
+
'use strict';var at=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 at__namespace=/*#__PURE__*/_interopNamespace(at);var L=class extends Error{constructor(e,t,n){super(e),this.code=t,this.status=n,this.name="LumenError";}code;status},Be=class extends L{constructor(){super("Origin not allowed. Add this origin in your Lumen project settings.","ORIGIN_NOT_ALLOWED",403),this.name="LumenOriginError";}},_e=class extends L{constructor(e){super(`Rate limited \u2014 retry after ${e}s.`,"RATE_LIMITED",429),this.retryAfter=e,this.name="LumenRateLimitError";}retryAfter},re=class extends L{constructor(e){super(e,"NETWORK_ERROR"),this.name="LumenNetworkError";}},jt="https://shakebugs.vercel.app",Yt="/api/v1/sdk/submit",Xt=new Set([502,503,504]),qe=class{apiKey;apiUrl;user;amplitude;constructor(e){if(!e.apiKey||!e.apiKey.startsWith("lk_pub_"))throw new L("Invalid Lumen apiKey \u2014 expected a key starting with `lk_pub_`.","INVALID_API_KEY");this.apiKey=e.apiKey,this.apiUrl=(e.apiUrl??jt).replace(/\/$/,""),this.user=e.user,this.amplitude=e.amplitude;}async submit(e,t={}){let n=`${this.apiUrl}${Yt}`,o=this.#e(e),r=null;for(let a=0;a<3;a++){a>0&&await Jt(2**a*250);try{return await this.#t(n,o,t)}catch(i){if(r=i,i instanceof Be||i instanceof _e||i instanceof L&&typeof i.status=="number"&&!Xt.has(i.status))throw i}}throw r instanceof Error?r:new re("Submit failed after 3 attempts.")}#e(e){let t=new FormData;e.rawText&&t.append("rawText",e.rawText),e.category&&t.append("category",e.category),e.submitterEmail&&t.append("submitterEmail",e.submitterEmail),e.submitterFingerprint&&t.append("submitterFingerprint",e.submitterFingerprint);let n=e.context.amplitude??this.amplitude,o=n?{...e.context,amplitude:n}:e.context;return t.append("context",JSON.stringify(o)),e.screenshot&&t.append("screenshot",e.screenshot,Gt(e.screenshot)),e.audio&&t.append("audio",e.audio,"audio"),e.audioDurationMs!=null&&t.append("audioDurationMs",String(e.audioDurationMs)),e.video&&t.append("video",e.video,"video"),e.videoDurationMs!=null&&t.append("videoDurationMs",String(e.videoDurationMs)),t}#t(e,t,n){return new Promise((o,r)=>{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",d=>{d.lengthComputable&&d.total>0&&i(Math.min(1,d.loaded/d.total));});let s=()=>{a.abort(),r(new re("Submit aborted."));};if(u){if(u.aborted){r(new re("Submit aborted."));return}u.addEventListener("abort",s,{once:true});}a.addEventListener("load",()=>{if(u&&u.removeEventListener("abort",s),a.status===403){r(new Be);return}if(a.status===429){let d=Number(a.getResponseHeader("Retry-After"))||60;r(new _e(d));return}if(a.status<200||a.status>=300){r(new L(Zt(a.responseText)??`HTTP ${a.status}`,"HTTP_ERROR",a.status));return}try{let d=JSON.parse(a.responseText);o(d);}catch{r(new L("Malformed response from server.","BAD_RESPONSE"));}}),a.addEventListener("error",()=>{u&&u.removeEventListener("abort",s),r(new re("Network error during submit."));}),a.send(t);})}};function Gt(e){return `screenshot.${e.type==="image/jpeg"?"jpg":e.type==="image/webp"?"webp":"png"}`}function Jt(e){return new Promise(t=>setTimeout(t,e))}function Zt(e){try{let t=JSON.parse(e);return t.error??t.message??null}catch{return e||null}}var Qt=2,G=8*1024*1024;async function Ke(e={}){Ge();let t=e.mode??"auto";if(e.provider&&(t==="auto"||t==="custom"))try{return tn(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 L("Manual screenshot upload is required for this capture mode.","MANUAL_CAPTURE_REQUIRED");if(t==="true-screen")return ze(e);if(t==="dom")return Ve(e);if(t==="custom")throw new L("`capture.provider` is required when capture mode is `custom`.","CAPTURE_PROVIDER_REQUIRED");try{return await Ve(e)}catch(n){if(Xe()){let o=await ze(e);return o.warnings=J(["DOM screenshot failed; used browser screen permission fallback.",...o.warnings]),e.onWarning?.(o.warnings),o}throw n}}function je(e,t=[]){Ge();let n=se();return {blob:e,method:"manual-upload",platform:"web",viewport:n,pixelRatio:window.devicePixelRatio??1,warnings:J(t)}}async function Ve(e){let t=await en(),n=e.target??document.documentElement,o=se(),r=Math.max(1,Math.min(window.devicePixelRatio??1,e.maxScale??Qt)),a=nn(n),i=await t(n,{backgroundColor:null,logging:false,useCORS:true,allowTaint:false,width:o.width,height:o.height,windowWidth:o.width,windowHeight:o.height,scrollX:window.scrollX,scrollY:window.scrollY,x:window.scrollX,y:window.scrollY,scale:r,ignoreElements:s=>s instanceof HTMLElement&&(s.dataset.lumenCaptureIgnore==="true"||!!s.closest("[data-lumen-capture-ignore='true']"))}),u={blob:await Ye(i,a),method:"web-dom",platform:"web",viewport:o,pixelRatio:r,warnings:J(a)};return u.warnings.length>0&&e.onWarning?.(u.warnings),u}async function en(){let{default:e}=await import('html2canvas-pro');return e}async function ze(e){if(!Xe())throw new L("Browser screen capture is unavailable in this environment.","DISPLAY_MEDIA_UNAVAILABLE");let t=await navigator.mediaDevices.getDisplayMedia({video:true,audio:false});try{let n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=t,await on(n);let o=document.createElement("canvas");o.width=n.videoWidth,o.height=n.videoHeight;let r=o.getContext("2d");if(!r)throw new L("Could not create a drawing context for screen capture.","CANVAS_CONTEXT_UNAVAILABLE");r.drawImage(n,0,0,o.width,o.height);let a=se(),i=["Browser screen capture uses the window or tab selected by the user."],u={blob:await Ye(o,i),method:"web-display-media",platform:"web",viewport:a,pixelRatio:a.width>0?o.width/a.width:void 0,warnings:J(i)};return e.onWarning?.(u.warnings),u}finally{for(let n of t.getTracks())n.stop();}}function tn(e,t){let n=se(),o={...e,method:e.method??"custom",platform:e.platform??"custom",viewport:e.viewport??n,pixelRatio:e.pixelRatio??window.devicePixelRatio??1,warnings:J(e.warnings??[])};return o.warnings.length>0&&t.onWarning?.(o.warnings),o}function nn(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 o of Array.from(e.querySelectorAll("img"))){let r=o.currentSrc||o.src;if(r)try{new URL(r,window.location.href).origin!==window.location.origin&&!o.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 Ye(e,t){let n=await Ue(e,"image/png",.92);if(n.size<=G)return n;t.push("Screenshot exceeded the upload cap and was compressed.");let o=e,r=0;for(;n.size>G&&r<6;){let a=Math.max(.35,Math.min(.95,Math.sqrt(G/n.size)*.9)),i=document.createElement("canvas");i.width=Math.max(1,Math.round(o.width*a)),i.height=Math.max(1,Math.round(o.height*a));let u=i.getContext("2d");if(!u)return n;u.drawImage(o,0,0,i.width,i.height),o=i;for(let s of [.86,.74,.62,.5])if(n=await Ue(o,"image/jpeg",s),n.size<=G)return n;if(r+=1,i.width<480||i.height<320)break}return n.size>G&&t.push("Screenshot remained large after compression; upload may be rejected."),n}function Ue(e,t,n){return new Promise((o,r)=>{e.toBlob(a=>{if(!a){r(new L("Could not encode screenshot.","ENCODE_FAILED"));return}o(a);},t,n);})}function se(){let e=window.visualViewport;return {width:Math.round(e?.width??window.innerWidth),height:Math.round(e?.height??window.innerHeight)}}function Xe(){return !!navigator.mediaDevices?.getDisplayMedia}async function on(e){await new Promise((o,r)=>{let a=()=>o(),i=()=>r(new L("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 L("Screen capture did not produce a frame in time.","VIDEO_TIMEOUT");await new Promise(o=>requestAnimationFrame(()=>o()));}}function Ge(){if(typeof window>"u"||typeof document>"u")throw new L("Screenshot capture can only run in the browser.","INVALID_ENV")}function J(e){return Array.from(new Set(e.filter(Boolean)))}var Je=[],ae=[],We=false,he=null;function Ze(e={}){We||typeof window>"u"||(We=true,he=e.ignoreUrlPrefix??null,ln(),un(),cn());}function rn(){return {consoleLog:Je.slice(),networkLog:ae.slice()}}function ie(e,t){e.push(t),e.length>200&&e.splice(0,e.length-200);}function an(e){let t=[];for(let o of e){if(typeof o=="string"){t.push(o);continue}if(o instanceof Error){t.push(`${o.name}: ${o.message}${o.stack?`
|
|
3
|
+
${o.stack}`:""}`);continue}try{t.push(JSON.stringify(o,sn));}catch{t.push(String(o));}}let n=t.join(" ");return n.length>4096?n.slice(0,4096)+"\u2026[truncated]":n}function sn(e,t){return t instanceof Element?`[Element ${t.tagName}]`:typeof t=="function"?"[Function]":t}function ln(){let e=window.console;if(!e)return;let t=["log","info","warn","error","debug"];for(let n of t){let o=e[n]?.bind(e);o&&(e[n]=(...r)=>{try{ie(Je,{level:n,ts:Date.now(),message:an(r)});}catch{}o(...r);});}}function Qe(e){return he?e.startsWith(he):false}function un(){let e=window.fetch;typeof e=="function"&&(window.fetch=async function(t,n){let o=typeof t=="string"?t:t instanceof URL?t.toString():t.url,r=(n?.method??(t instanceof Request?t.method:"GET")).toUpperCase();if(Qe(o))return e.call(window,t,n);let a=performance.now();try{let i=await e.call(window,t,n);return ie(ae,{type:"fetch",method:r,url:we(o),status:i.status,ok:i.ok,durationMs:Math.round(performance.now()-a),ts:Date.now()}),i}catch(i){throw ie(ae,{type:"fetch",method:r,url:we(o),status:0,ok:false,durationMs:Math.round(performance.now()-a),ts:Date.now(),error:i instanceof Error?i.message:"fetch error"}),i}});}function cn(){let e=window.XMLHttpRequest;if(!e)return;let t=e.prototype.open,n=e.prototype.send;e.prototype.open=function(o,r,...a){return this.__lumen={method:String(o).toUpperCase(),url:typeof r=="string"?r:r.toString(),t:0},t.call(this,o,r,...a)},e.prototype.send=function(o){let r=this.__lumen;if(r&&!Qe(r.url)){r.t=performance.now();let a=()=>{try{ie(ae,{type:"xhr",method:r.method,url:we(r.url),status:this.status,ok:this.status>=200&&this.status<400,durationMs:Math.round(performance.now()-r.t),ts:Date.now()});}catch{}this.removeEventListener("loadend",a);};this.addEventListener("loadend",a);}return n.call(this,o??null)};}function we(e){return e.length>512?e.slice(0,512)+"\u2026":e}function et(e){if(typeof window>"u")return {url:"",userAgent:"",viewport:{width:0,height:0},capture:$e(e),consoleLog:[],networkLog:[]};let t=rn();return {url:window.location.href,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},capture:$e(e),device:dn(),consoleLog:t.consoleLog,networkLog:t.networkLog}}function dn(){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||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 $e(e){if(e)return {method:e.method,platform:e.platform,viewport:e.viewport,pixelRatio:e.pixelRatio,warnings:e.warnings}}async function tt(e=60){if(typeof window>"u"||!navigator.mediaDevices)throw new L("Audio recording requires a browser with MediaDevices.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getUserMedia({audio:!0});}catch{throw new L("Microphone access denied or unavailable.","MIC_DENIED")}let n=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(s=>MediaRecorder.isTypeSupported(s))??"",o=new MediaRecorder(t,n?{mimeType:n}:void 0),r=[],a=performance.now(),i=null;o.addEventListener("dataavailable",s=>{s.data&&s.data.size>0&&r.push(s.data);}),o.start(),i=window.setTimeout(()=>{o.state!=="inactive"&&o.stop();},e*1e3);function u(){i!==null&&window.clearTimeout(i),i=null;for(let s of t.getTracks())s.stop();}return {stream:t,cancel(){try{o.state!=="inactive"&&o.stop();}catch{}u();},stop(){return new Promise((s,d)=>{if(o.state==="inactive"){u(),d(new L("Recorder already stopped.","RECORDER_STOPPED"));return}o.addEventListener("stop",()=>{let m=performance.now()-a,w=o.mimeType||n||"audio/webm",b=new Blob(r,{type:w});u(),s({blob:b,durationMs:m,mimeType:w});},{once:true}),o.stop();})}}}async function nt(e=60){if(typeof window>"u"||!navigator.mediaDevices||typeof navigator.mediaDevices.getDisplayMedia!="function")throw new L("Screen recording requires a browser with getDisplayMedia.","INVALID_ENV");let t;try{t=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0});}catch{throw new L("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(d=>MediaRecorder.isTypeSupported(d))??"",o=new MediaRecorder(t,n?{mimeType:n}:void 0),r=[],a=performance.now(),i=null;o.addEventListener("dataavailable",d=>{d.data&&d.data.size>0&&r.push(d.data);}),o.start(),i=window.setTimeout(()=>{o.state!=="inactive"&&o.stop();},e*1e3);let u=t.getVideoTracks()[0];u&&u.addEventListener("ended",()=>{o.state!=="inactive"&&o.stop();});function s(){i!==null&&window.clearTimeout(i),i=null;for(let d of t.getTracks())d.stop();}return {stream:t,cancel(){try{o.state!=="inactive"&&o.stop();}catch{}s();},stop(){return new Promise((d,m)=>{if(o.state==="inactive"){s(),m(new L("Recorder already stopped.","RECORDER_STOPPED"));return}o.addEventListener("stop",()=>{let w=performance.now()-a,b=o.mimeType||n||"video/webm",R=new Blob(r,{type:b});s(),d({blob:R,durationMs:w,mimeType:b});},{once:true}),o.stop();})}}}var ve=at.createContext(null);function Z(){let e=at.useContext(ve);if(!e)throw new Error("useLumen() must be used inside <LumenProvider>.");return e}var it=at__namespace.forwardRef(function({screenshot:t,tool:n,color:o="rgb(239, 68, 68)",strokeWidth:r=4,onDrawingChange:a},i){let u=at.useRef(null),s=at.useRef(null),d=at.useRef(null),[m,w]=at.useState(null),[b,R]=at.useState([]),v=at.useRef(null),C=at.useRef(false),k=at.useRef(0),T=at.useRef(false);at.useEffect(()=>{let p=false,g=null;return (async()=>{try{let h=await createImageBitmap(t);if(p){h.close?.();return}g=h,w(h);}catch{}})(),()=>{p=true,g?.close?.();}},[t]),at.useEffect(()=>{if(!m)return;let p=u.current,g=s.current;if(!p||!g)return;p.width=m.width,p.height=m.height,g.width=m.width,g.height=m.height;let h=p.getContext("2d");h&&(h.imageSmoothingEnabled=false,h.drawImage(m,0,0));},[m]),at.useEffect(()=>{let p=s.current;p&&le(p,b,v.current);},[b]),at.useImperativeHandle(i,()=>({hasAnnotations:()=>b.length>0,reset:()=>R([]),undo:()=>R(p=>p.length===0?p:p.slice(0,-1)),async flatten(){let p=v.current,g=p?[...b,p]:b;if(g.length===0||!m)return t;let h=document.createElement("canvas");h.width=m.width,h.height=m.height;let x=h.getContext("2d");if(!x)return t;x.imageSmoothingEnabled=false,x.drawImage(m,0,0);for(let P of g)xe(x,P);return await new Promise(P=>{h.toBlob(V=>{P(V??t);},"image/jpeg",.85);})}}),[b,m,t]);function N(p){let g=s.current;if(!g)return {x:0,y:0};let h=g.getBoundingClientRect(),x=g.width/Math.max(h.width,1),P=g.height/Math.max(h.height,1);return {x:(p.clientX-h.left)*x,y:(p.clientY-h.top)*P}}function E(){T.current||(T.current=true,requestAnimationFrame(()=>{T.current=false;let p=s.current;p&&le(p,b,v.current);}));}function A(p){if(p.button!==void 0&&p.button!==0)return;try{p.currentTarget.setPointerCapture(p.pointerId);}catch{}C.current=true,a?.(true);let g=N(p);n==="arrow"?v.current={kind:"arrow",from:g,to:g,color:o,width:r}:n==="rect"?v.current={kind:"rect",from:g,to:g,color:o,width:r}:v.current={kind:"freehand",points:[g],color:o,width:r},k.current=performance.now(),E();}function D(p){if(!C.current||!v.current)return;let g=N(p),h=v.current;if(h.kind==="arrow"||h.kind==="rect")h.to=g;else {let x=h.points[h.points.length-1],P=x?(x.x-g.x)**2+(x.y-g.y)**2:1/0,V=performance.now(),O=V-k.current;(P>16||O>16)&&(h.points.push(g),k.current=V);}E();}function S(){if(!C.current)return;C.current=false,a?.(false);let p=v.current;if(v.current=null,!!p){if(p.kind==="arrow"||p.kind==="rect"){let g=p.to.x-p.from.x,h=p.to.y-p.from.y;if(g*g+h*h<16){let x=s.current;x&&le(x,b,null);return}}else if(p.points.length<2){let g=s.current;g&&le(g,b,null);return}R(g=>[...g,p].slice(-50));}}return jsxRuntime.jsxs("div",{ref:d,className:"lumen-annotate-frame",children:[jsxRuntime.jsx("canvas",{ref:u}),jsxRuntime.jsx("canvas",{ref:s,className:"lumen-annotate-overlay",onPointerDown:A,onPointerMove:D,onPointerUp:S,onPointerCancel:S})]})});function le(e,t,n){let o=e.getContext("2d");if(o){o.clearRect(0,0,e.width,e.height);for(let r of t)xe(o,r);n&&xe(o,n);}}function xe(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),o=Math.min(t.from.y,t.to.y),r=Math.abs(t.to.x-t.from.x),a=Math.abs(t.to.y-t.from.y);e.strokeRect(n,o,r,a);}else if(t.kind==="freehand")bn(e,t.points);else {let{from:n,to:o,width:r}=t;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(o.x,o.y),e.stroke();let a=Math.atan2(o.y-n.y,o.x-n.x),i=Math.max(12,r*4);e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(o.x-i*Math.cos(a-Math.PI/7),o.y-i*Math.sin(a-Math.PI/7)),e.lineTo(o.x-i*Math.cos(a+Math.PI/7),o.y-i*Math.sin(a+Math.PI/7)),e.closePath(),e.fill();}e.restore();}function bn(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 r=t[1];e.lineTo(r.x,r.y),e.stroke();return}for(let r=1;r<t.length-1;r++){let a=t[r],i=t[r+1],u=(a.x+i.x)/2,s=(a.y+i.y)/2;e.quadraticCurveTo(a.x,a.y,u,s);}let o=t[t.length-1];e.lineTo(o.x,o.y),e.stroke();}var Ee=60,wn=60,st=[{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)"}],lt=[{label:"Small",value:2,dot:6},{label:"Medium",value:4,dot:9},{label:"Large",value:6,dot:12}],ut=[{value:"bug",label:"Bug"},{value:"feature",label:"Idea"},{value:"other",label:"Other"}],vn=[{value:"shot",label:"Screenshot",hint:"This page, instantly"},{value:"screen",label:"Screen",hint:"Pick a window or tab"},{value:"video",label:"Video",hint:"Record up to 60s"}];function ke(){let{client:e,isOpen:t,closeCapture:n,user:o,capture:r}=Z(),[a,i]=at.useState(1),[u,s]=at.useState(null),[d,m]=at.useState({kind:"idle"}),[w,b]=at.useState(false),[R,v]=at.useState(0),[C,k]=at.useState(null),[T,N]=at.useState(false),[E,A]=at.useState("arrow"),[D,S]=at.useState(st[0].value),[p,g]=at.useState(lt[1].value),[h,x]=at.useState(""),[P,V]=at.useState("bug"),[O,Q]=at.useState(o?.email??""),[H,de]=at.useState(null),[_,Y]=at.useState(null),[Ot,me]=at.useState(0),[j,ee]=at.useState(null),[$,pe]=at.useState(null),[Ht,Ft]=at.useState(false),te=at.useRef(null),Ae=at.useRef(null),Se=at.useRef(null),X=at.useRef(false);if(at.useEffect(()=>{if(t)return X.current=false,i(1),s(null),x(""),Y(null),me(0),pe(null),b(false),v(0),k(null),N(false),ee(l=>(l?.cancel(),null)),m(r?.mode==="manual"?{kind:"manual"}:{kind:"idle"}),()=>{X.current=true;}},[t,r]),at.useEffect(()=>{if(!t)return;Se.current=document.activeElement??null;let l=document.documentElement,y=l.style.overflow,I=l.style.paddingRight,F=window.innerWidth-l.clientWidth;l.style.overflow="hidden",F>0&&(l.style.paddingRight=`${F}px`);let B=false,z=()=>{if(!B){B=true,l.style.overflow=y,l.style.paddingRight=I;try{Se.current?.focus?.();}catch{}}};return window.addEventListener("pagehide",z),()=>{window.removeEventListener("pagehide",z),z();}},[t]),at.useEffect(()=>{if(!t)return;function l(y){if(y.key==="Escape"){y.preventDefault(),n();return}if(y.key!=="Tab")return;let I=Ae.current;if(!I)return;let F=Tn(I);if(F.length===0)return;let B=F[0],z=F[F.length-1],be=document.activeElement;y.shiftKey&&(be===B||!I.contains(be))?(y.preventDefault(),z.focus()):!y.shiftKey&&be===z&&(y.preventDefault(),B.focus());}return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t,n]),at.useEffect(()=>{if(!t||d.kind!=="manual")return;function l(y){let B=Array.from(y.clipboardData?.items??[]).find(z=>z.type.startsWith("image/"))?.getAsFile();B&&(y.preventDefault(),Ie(B));}return window.addEventListener("paste",l),()=>window.removeEventListener("paste",l)},[t,d.kind]),at.useEffect(()=>{if(!H)return;let l=Date.now(),y=window.setInterval(()=>{let I=Math.floor((Date.now()-l)/1e3);me(I),I>=Ee&&Oe();},250);return ()=>window.clearInterval(y)},[H]),!t)return null;async function fe(l){X.current=false,m({kind:"capturing"});try{let y=await Ke({...r,mode:l,target:r?.target??document.documentElement});return X.current?!1:(Bt(y),m({kind:"ready",capture:y}),!0)}catch(y){return X.current||m({kind:"manual",error:y instanceof Error?y.message:"Automatic screenshot capture was unavailable."}),false}}async function Pe(l){s(l),k(null),l!=="video"&&Fe(),l==="shot"?await fe(r?.mode??"auto"):l==="screen"?await fe("true-screen"):await fe(r?.mode??"auto")&&await He();}function Ie(l){if(!l.type.startsWith("image/")){sonner.toast.error("Choose a PNG, JPEG, or WebP screenshot.");return}let y=je(l,["Manual screenshot upload used."]);m({kind:"ready",capture:y});}function Bt(l){l.warnings.length!==0&&sonner.toast.warning("Screenshot captured, but iframe, video, canvas, or cross-origin content may be incomplete.");}async function De(){try{let l=await tt(Ee);de(l);}catch(l){sonner.toast.error(l instanceof Error?l.message:"Microphone unavailable");}}async function Oe(){if(H)try{let l=await H.stop();Y({blob:l.blob,durationMs:l.durationMs});}catch(l){sonner.toast.error(l instanceof Error?l.message:"Could not stop recording");}finally{de(null);}}function _t(){H?.cancel(),de(null),Y(null),me(0);}async function He(){try{let l=await nt(wn);ee(l),l.stream.getVideoTracks()[0]?.addEventListener("ended",()=>{ne();});}catch(l){sonner.toast.error(l instanceof Error?l.message:"Screen capture unavailable");}}async function ne(){if(!j)return;let l=j;ee(null);try{let y=await l.stop();pe({blob:y.blob,durationMs:y.durationMs});}catch(y){sonner.toast.error(y instanceof Error?y.message:"Could not stop recording");}}function Fe(){j?.cancel(),ee(null),pe(null);}let Vt=d.kind==="ready";async function zt(){if(a===1){if(j&&await ne(),d.kind==="ready"){let l=await te.current?.flatten();k(l??d.capture.blob),N(l!=null&&l!==d.capture.blob);}i(2);}else a===2?i(3):await Wt();}function Ut(){a>1&&i(l=>l-1);}async function Wt(){if(d.kind!=="ready")return;let l=h.trim(),{capture:y}=d;b(true),v(0);try{let I=C??y.blob,F=await e.submit({rawText:l.length>0?l:void 0,category:P,submitterEmail:O.trim()||void 0,screenshot:I,audio:_?.blob,audioDurationMs:_?.durationMs,video:$?.blob,videoDurationMs:$?.durationMs,context:et(y)},{onUploadProgress:B=>v(Math.min(.95,B))});v(1),sonner.toast.success("Feedback sent \u2014 thank you."),F.id,n();}catch(I){sonner.toast.error(I instanceof Error?I.message:"Could not submit feedback"),b(false);}}function $t(l){l.target===l.currentTarget&&!w&&n();}let oe=Math.round(R*100),ge=u==="video",qt=a===1&&!Vt||w,Kt=a<3?"Next":w?oe<95?`Uploading ${oe}%\u2026`:"Almost done\u2026":"Send feedback";return jsxRuntime.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:"lumen-modal-backdrop","data-lumen-capture-ignore":"true",onMouseDown:$t,children:jsxRuntime.jsxs("div",{ref:Ae,className:"lumen-modal","data-lumen-drawing":Ht?"true":void 0,children:[jsxRuntime.jsx(xn,{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(yn,{step:a}),jsxRuntime.jsxs("div",{className:"lumen-modal-body",children:[a===1?jsxRuntime.jsxs("div",{className:"lumen-pane",children:[jsxRuntime.jsx("div",{className:"lumen-method",role:"group","aria-label":"Capture method",children:vn.map(l=>jsxRuntime.jsxs("button",{type:"button",className:"lumen-method-btn","aria-pressed":u===l.value,onClick:()=>Pe(l.value),disabled:d.kind==="capturing",children:[jsxRuntime.jsx("span",{className:"lumen-method-label",children:l.label}),jsxRuntime.jsx("span",{className:"lumen-method-hint",children:l.hint})]},l.value))}),d.kind==="idle"?jsxRuntime.jsxs("div",{className:"lumen-cap-empty",children:[jsxRuntime.jsx("p",{children:"Pick a capture method above \u2014 nothing is captured until you choose, so take your time positioning the screen."}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>m({kind:"manual"}),children:"Or upload a screenshot"})]}):null,d.kind==="capturing"?jsxRuntime.jsxs("p",{className:"lumen-status",children:[jsxRuntime.jsx("span",{className:"lumen-spinner","aria-hidden":"true"}),"Capturing\u2026"]}):null,d.kind==="manual"?jsxRuntime.jsxs("div",{className:"lumen-manual-capture",children:[jsxRuntime.jsx("p",{className:"lumen-status",children:d.error?"Automatic capture was unavailable. Upload or paste a screenshot to continue.":"Upload or paste a screenshot to continue."}),jsxRuntime.jsxs("label",{className:"lumen-manual-drop",children:[jsxRuntime.jsx("span",{children:"Choose or paste a screenshot"}),jsxRuntime.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",onChange:l=>{let y=l.currentTarget.files?.[0];y&&Ie(y),l.currentTarget.value="";}})]})]}):null,d.kind==="ready"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[ge?null:jsxRuntime.jsxs("div",{className:"lumen-toolbar",children:[jsxRuntime.jsxs("div",{className:"lumen-segmented",role:"group","aria-label":"Annotation tool",children:[jsxRuntime.jsx(Ce,{label:"Arrow",active:E==="arrow",onClick:()=>A("arrow")}),jsxRuntime.jsx(Ce,{label:"Box",active:E==="rect",onClick:()=>A("rect")}),jsxRuntime.jsx(Ce,{label:"Draw",active:E==="freehand",onClick:()=>A("freehand")})]}),jsxRuntime.jsx("span",{className:"lumen-toolbar-sep"}),jsxRuntime.jsx("div",{className:"lumen-swatches",role:"group","aria-label":"Color",children:st.map(l=>jsxRuntime.jsx("button",{type:"button",className:"lumen-swatch",style:{background:l.value},"aria-label":l.label,"aria-pressed":D===l.value,onClick:()=>S(l.value)},l.value))}),jsxRuntime.jsx("div",{className:"lumen-stroke-sizes",role:"group","aria-label":"Stroke width",children:lt.map(l=>jsxRuntime.jsx("button",{type:"button",className:"lumen-stroke-size","aria-label":l.label,"aria-pressed":p===l.value,onClick:()=>g(l.value),children:jsxRuntime.jsx("span",{className:"lumen-stroke-size-dot",style:{width:l.dot,height:l.dot}})},l.value))}),jsxRuntime.jsx("span",{className:"lumen-toolbar-spacer"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>te.current?.undo(),children:"Undo"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>te.current?.reset(),children:"Clear"})]}),jsxRuntime.jsx("div",{className:"lumen-annotate",children:jsxRuntime.jsx(it,{ref:te,screenshot:d.capture.blob,tool:E,color:D,strokeWidth:p,onDrawingChange:Ft})}),jsxRuntime.jsxs("div",{className:"lumen-cap-actions",children:[jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:()=>u&&Pe(u),children:ge?"\u21BB Re-record":"\u21BB Recapture"}),ge?j?jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx("span",{className:"lumen-rec-time",children:"Recording\u2026"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost",onClick:ne,children:"Stop"})]}):$?jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:["\u2713 ",Math.round($.durationMs/1e3),"s recorded"]}):null:jsxRuntime.jsxs("span",{className:"lumen-cap-note",children:[ct(u)," captured \xB7 switch method above anytime"]})]})]}):null]}):null,a===2?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-form",children:[jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"What happened?"}),jsxRuntime.jsx("textarea",{value:h,onChange:l=>x(l.target.value),rows:3,placeholder:"Describe the issue or idea\u2026",className:"lumen-input",autoFocus:true})]}),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Add a voice note (optional)"}),jsxRuntime.jsxs("div",{className:"lumen-audio-row",children:[!H&&!_?jsxRuntime.jsx("button",{type:"button",onClick:De,className:"lumen-btn-ghost",children:"Record voice note"}):null,H?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-recording",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),jsxRuntime.jsx(En,{stream:H.stream}),jsxRuntime.jsxs("span",{className:"lumen-rec-time",children:[Ot,"s / ",Ee,"s"]})]}),jsxRuntime.jsx("button",{type:"button",onClick:Oe,className:"lumen-btn-ghost",children:"Stop"}),jsxRuntime.jsx("button",{type:"button",onClick:_t,className:"lumen-btn-ghost",children:"Cancel"})]}):null,_&&!H?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(kn,{blob:_.blob,durationMs:_.durationMs}),jsxRuntime.jsx("button",{type:"button",onClick:()=>Y(null),className:"lumen-btn-ghost",children:"Remove"})]}):null]})]}),jsxRuntime.jsxs("div",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Category"}),jsxRuntime.jsx("div",{className:"lumen-category",role:"group","aria-label":"Feedback category",children:ut.map(l=>jsxRuntime.jsx("button",{type:"button",className:"lumen-category-opt","aria-pressed":P===l.value,onClick:()=>V(l.value),children:l.label},l.value))})]}),jsxRuntime.jsxs("label",{className:"lumen-label",children:[jsxRuntime.jsx("span",{children:"Your email (optional)"}),jsxRuntime.jsx("input",{type:"email",value:O,onChange:l=>Q(l.target.value),placeholder:"you@example.com",className:"lumen-input"})]})]}):null,a===3?jsxRuntime.jsxs("div",{className:"lumen-pane lumen-review",children:[jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Capture"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[ct(u),T?" \xB7 annotated":"",jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>i(1),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Category"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[jsxRuntime.jsx("span",{className:"lumen-chip",children:ut.find(l=>l.value===P)?.label}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>i(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Description"}),jsxRuntime.jsxs("span",{className:"lumen-review-v",children:[h.trim()?h.trim():jsxRuntime.jsx("span",{className:"lumen-muted-empty",children:"\u2014"}),jsxRuntime.jsx("button",{type:"button",className:"lumen-edit",onClick:()=>i(2),children:"edit"})]})]}),jsxRuntime.jsxs("div",{className:"lumen-review-row",children:[jsxRuntime.jsx("span",{className:"lumen-review-k",children:"Material"}),jsxRuntime.jsxs("span",{className:"lumen-review-v lumen-attach-row",children:[_?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u{1F399} Voice ",Math.round(_.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove voice note",onClick:()=>Y(null),children:"\xD7"})]}):null,$?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u25B6 Video ",Math.round($.durationMs/1e3),"s",jsxRuntime.jsx("button",{type:"button",className:"lumen-att-x","aria-label":"Remove video",onClick:Fe,children:"\xD7"})]}):null,O.trim()?jsxRuntime.jsxs("span",{className:"lumen-attach",children:["\u2709 ",O.trim()]}):null,!_&&!H?jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:()=>{i(2),De();},children:"+ Voice note"}):null,j?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"lumen-attach",children:[jsxRuntime.jsx("span",{className:"lumen-rec-dot","aria-hidden":"true"}),"Recording\u2026"]}),jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:ne,children:"Stop"})]}):$?null:jsxRuntime.jsx("button",{type:"button",className:"lumen-btn-ghost lumen-add-btn",onClick:He,children:"+ Screen recording"})]})]})]}):null]}),jsxRuntime.jsxs("footer",{className:"lumen-modal-footer",children:[w?jsxRuntime.jsx("div",{className:"lumen-progress",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":oe,children:jsxRuntime.jsx("div",{className:"lumen-progress-fill",style:{width:`${oe}%`}})}):null,jsxRuntime.jsxs("div",{className:"lumen-modal-actions",children:[jsxRuntime.jsx("button",{type:"button",onClick:a===1?n:Ut,className:"lumen-btn-ghost",disabled:w,children:a===1?"Cancel":"Back"}),jsxRuntime.jsx("button",{type:"button",onClick:zt,className:"lumen-btn-primary",disabled:qt,children:Kt})]})]})]})})}function ct(e){return e==="video"?"Screen recording":e==="screen"?"Screen capture":"Screenshot"}function yn({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,o)=>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}),o<t.length-1?jsxRuntime.jsx("span",{className:"lumen-step-bar"}):null]},n.n))})}function Ce({label:e,active:t,onClick:n}){return jsxRuntime.jsx("button",{type:"button",onClick:n,className:"lumen-tool","aria-pressed":t,children:e})}function xn({onDismiss:e}){let t=at.useRef(null),n=at.useRef(0),o=at.useRef(null);function r(u){u.currentTarget.setPointerCapture(u.pointerId),t.current=u.clientY,n.current=performance.now(),o.current=u.currentTarget.parentElement;}function a(u){if(t.current==null||!o.current)return;let s=Math.max(0,u.clientY-t.current);o.current.style.transform=`translateY(${s}px)`;}function i(u){if(t.current==null||!o.current)return;let s=Math.max(0,u.clientY-t.current),d=Math.max(1,performance.now()-n.current),m=s/d;o.current.style.transform="",o.current.style.transition="",t.current=null,(s>80||m>.6)&&e();}return jsxRuntime.jsx("div",{className:"lumen-modal-grabber","aria-hidden":"true",onPointerDown:r,onPointerMove:a,onPointerUp:i,onPointerCancel:i})}function En({stream:e}){let t=at.useRef(null);return at.useEffect(()=>{let n=t.current;if(!n)return;let o=Math.min(window.devicePixelRatio||1,2),r=n.clientWidth||88,a=n.clientHeight||22;n.width=Math.round(r*o),n.height=Math.round(a*o);let i=n.getContext("2d");if(!i)return;i.scale(o,o);let u=window.AudioContext??window.webkitAudioContext;if(!u)return;let s=new u,d=s.createMediaStreamSource(e),m=s.createAnalyser();m.fftSize=1024,m.smoothingTimeConstant=.6,d.connect(m);let w=new Uint8Array(m.fftSize),b=18,R=3,v=3,C=Math.max(2,(r-R*(b-1))/b),k=Math.min(C/2,3),T=new Array(b).fill(0),N=0,E=false;function A(){if(E)return;m.getByteTimeDomainData(w);let D=Math.floor(w.length/b);i.clearRect(0,0,r,a),i.fillStyle=Rn("--lumen-danger")||"rgb(239,68,68)";for(let S=0;S<b;S++){let p=0;for(let O=0;O<D;O++){let Q=Math.abs((w[S*D+O]??128)-128);Q>p&&(p=Q);}let g=Math.min(1,p/128*1.8),h=T[S]??0;T[S]=g>h?g:h+(g-h)*.35;let x=Math.max(v,T[S]*a),P=S*(C+R),V=(a-x)/2;Cn(i,P,V,C,x,k),i.fill();}N=requestAnimationFrame(A);}return N=requestAnimationFrame(A),()=>{E=true,cancelAnimationFrame(N);try{d.disconnect();}catch{}s.close();}},[e]),jsxRuntime.jsx("canvas",{ref:t,className:"lumen-waveform","aria-hidden":"true"})}function Cn(e,t,n,o,r,a){let i=Math.min(a,o/2,r/2);e.beginPath();let u=e;if(typeof u.roundRect=="function"){u.roundRect(t,n,o,r,i);return}e.moveTo(t+i,n),e.arcTo(t+o,n,t+o,n+r,i),e.arcTo(t+o,n+r,t,n+r,i),e.arcTo(t,n+r,t,n,i),e.arcTo(t,n,t+o,n,i),e.closePath();}function kn({blob:e,durationMs:t}){let[n,o]=at.useState("");return at.useEffect(()=>{let r=URL.createObjectURL(e);return o(r),()=>{URL.revokeObjectURL(r);}},[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 Rn(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()}var Ln='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Tn(e){return Array.from(e.querySelectorAll(Ln)).filter(t=>!t.hasAttribute("disabled")&&t.offsetParent!==null)}function dt(){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,o=[Math.round(e*.1),Math.round(e*.5),Math.round(e*.9)],r=new Set,a=0;for(let i of o){let u=document.elementsFromPoint(i,n);for(let s of u){if(r.has(s))continue;r.add(s);let d=window.getComputedStyle(s);if(d.position!=="fixed"&&d.position!=="sticky")continue;let m=s.getBoundingClientRect();m.bottom<t-8||m.bottom>t+8||m.width<e*.6||m.height>a&&(a=m.height);}}return a}function Re(e,t){if(typeof document>"u"||typeof window>"u")return 0;let n=window.innerWidth,o=window.innerHeight,r=0;for(let a of e){let i;try{i=document.querySelectorAll(a);}catch{continue}for(let u of Array.from(i)){let s=u.getBoundingClientRect();if(s.height===0||s.width===0)continue;let d=0;switch(t){case "bottom":if(s.bottom<o-8)break;d=Math.max(0,o-s.top);break;case "top":if(s.top>8)break;d=Math.max(0,s.bottom);break;case "left":if(s.left>8)break;d=Math.max(0,s.right);break;case "right":if(s.right<n-8)break;d=Math.max(0,n-s.left);break}d>r&&(r=d);}}return r}function mt(e){let[t,n]=at.useState(()=>({bottom:e.offset.y,right:e.offset.x,left:e.offset.x,top:e.offset.y})),o=at.useRef(t),r=Sn(e.avoid),a=e.placement,i=e.offset.x,u=e.offset.y;return at.useEffect(()=>{if(typeof window>"u")return;let s=0,d=false,m=()=>{if(s=0,d)return;let C=a[0]==="b"?"bottom":"top",k=a[1]==="r"?"right":"left",T=0,N=0;e.avoid==="auto"&&C==="bottom"?T=dt():Array.isArray(e.avoid)&&(T=Re(e.avoid,C),N=Re(e.avoid,k));let E={bottom:C==="bottom"?u+T:0,top:C==="top"?u+T:0,right:k==="right"?i+N:0,left:k==="left"?i+N:0},A=o.current;(E.bottom!==A.bottom||E.top!==A.top||E.right!==A.right||E.left!==A.left)&&(o.current=E,n(E));},w=()=>{s||(s=window.requestAnimationFrame(m));};w();let b=typeof ResizeObserver<"u"?new ResizeObserver(w):null;b?.observe(document.documentElement);let R=typeof MutationObserver<"u"?new MutationObserver(w):null;R?.observe(document.body,{childList:true,subtree:true,attributes:true,attributeFilter:["class","style","hidden"]}),window.addEventListener("resize",w);let v=window.visualViewport;return v?.addEventListener("resize",w),v?.addEventListener("scroll",w),()=>{d=true,s&&window.cancelAnimationFrame(s),b?.disconnect(),R?.disconnect(),window.removeEventListener("resize",w),v?.removeEventListener("resize",w),v?.removeEventListener("scroll",w);}},[a,i,u,r]),t}function Sn(e){return e===false?"false":e==="auto"?"auto":e.join("|")}function pt(e){let[t,n]=at.useState(false);return at.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;let o=window.visualViewport;if(!o||typeof window.matchMedia!="function"||!window.matchMedia("(pointer: coarse)").matches)return;let r=100,a=0,i=()=>{a=0;let s=window.innerHeight-o.height;n(s>r);},u=()=>{a||(a=window.requestAnimationFrame(i));};return u(),o.addEventListener("resize",u),o.addEventListener("scroll",u),()=>{a&&window.cancelAnimationFrame(a),o.removeEventListener("resize",u),o.removeEventListener("scroll",u);}},[e]),t}function ht({config:e,portalTarget:t,hidden:n,onClick:o}){let[r,a]=at.useState(null),i=at.useRef(null),u=mt(e),s=pt(e.hideOnKeyboard);if(at.useEffect(()=>{typeof document>"u"||a(t??document.body);},[t]),Hn(i,!n&&!s),!r)return null;let d=e.placement,m=d[0]==="b"?"bottom":"top",w=d[1]==="r"?"right":"left",b=m==="bottom"?u.bottom:u.top,R=w==="right"?u.right:u.left,v={position:"fixed",[m]:e.safeArea?`calc(${b}px + env(safe-area-inset-${m}, 0px))`:`${b}px`,[w]:e.safeArea?`calc(${R}px + env(safe-area-inset-${w}, 0px))`:`${R}px`,zIndex:e.zIndex,opacity:n||s?0:1,pointerEvents:n||s?"none":"auto",transition:"opacity 160ms ease"};return reactDom.createPortal(jsxRuntime.jsxs("button",{ref:i,type:"button",className:"lumen-btn lumen-btn-primary lumen-btn-floating",style:v,"aria-label":e.label,"aria-hidden":n||s?true:void 0,tabIndex:n||s?-1:0,onClick:o,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[e.icon,jsxRuntime.jsx("span",{children:e.label})]}),r)}function Hn(e,t){let n=at.useRef(false);at.useEffect(()=>{if(process.env.NODE_ENV==="production"||!t||n.current||typeof window>"u")return;let o=window.setTimeout(()=>{let r=e.current;if(!r)return;let a=r.getBoundingClientRect();if(a.width===0||a.height===0)return;let i=a.left+a.width/2,u=a.top+a.height/2,s=document.elementsFromPoint(i,u),d=ft(window.getComputedStyle(r).zIndex);for(let m of s){if(m===r||r.contains(m))continue;if(ft(window.getComputedStyle(m).zIndex)>d){n.current=true,console.warn("[lumen] trigger is occluded by",m);break}}},250);return ()=>window.clearTimeout(o)},[t,e]);}function ft(e){let t=parseInt(e,10);return Number.isNaN(t)?0:t}function wt({mount:e,label:t,icon:n,onClick:o}){let[r,a]=at.useState(null);return at.useEffect(()=>{if(typeof document>"u")return;let i=e instanceof HTMLElement?e:e.current??null;a(i);},[e]),r?reactDom.createPortal(jsxRuntime.jsxs("button",{type:"button",className:"lumen-btn lumen-btn-primary",onClick:o,"aria-label":t,"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[n,jsxRuntime.jsx("span",{children:t})]}),r):null}function xt({config:e,portalTarget:t,hidden:n,onClick:o}){let[r,a]=at.useState(null),[i,u]=at.useState(false),s=at.useRef(null);if(at.useEffect(()=>{typeof document>"u"||a(t??document.body);},[t]),!r)return null;let d=`lumen-notch lumen-notch-${e.edge}${i?" lumen-notch-expanded":""}`;function m(v){s.current={x:v.clientX,y:v.clientY},u(true),v.currentTarget.setPointerCapture(v.pointerId);}function w(v){let C=s.current;if(!C)return;let k=v.clientX-C.x,T=v.clientY-C.y;(e.edge==="top"&&T>16||e.edge==="bottom"&&T<-16||e.edge==="right"&&k<-16||e.edge==="left"&&k>16)&&(s.current=null,o());}function b(){s.current=null,u(false);}function R(){s.current=null,u(false);}return reactDom.createPortal(jsxRuntime.jsxs("button",{type:"button",className:d,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,onClick:o,onPointerDown:m,onPointerMove:w,onPointerUp:b,onPointerCancel:R,onMouseEnter:()=>u(true),onMouseLeave:()=>u(false),"data-lumen-trigger":"","data-lumen-capture-ignore":"true",children:[jsxRuntime.jsx("span",{className:"lumen-notch-handle","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"lumen-notch-label",children:[e.icon,e.label]})]}),r)}function Et(e){return {kind:"notch",edge:e.edge??"top",label:e.label??"Feedback",icon:e.icon,zIndex:e.zIndex??2147483600}}function Ct(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],hideOnKeyboard:e.hideOnKeyboard??true,zIndex:e.zIndex??2147483600,label:e.label??"Feedback",icon:e.icon}}var Gn={"--lumen-bg":"background","--lumen-fg":"foreground","--lumen-primary":"accent","--lumen-radius":"radius"};function kt(e){let t=at.useId();at.useEffect(()=>{if(typeof document>"u")return;let n=document.documentElement,o=`data-lumen-theme-${Jn(t)}`,r={};if(e==="auto"||e==null)n.removeAttribute("data-lumen-theme");else if(e==="light"||e==="dark")r["data-lumen-theme"]=n.getAttribute("data-lumen-theme"),n.setAttribute("data-lumen-theme",e);else for(let[a,i]of Object.entries(Gn)){let u=e[i];typeof u=="string"&&u.length>0&&(r[a]=n.style.getPropertyValue(a)||null,n.style.setProperty(a,u));}return n.setAttribute(o,""),()=>{n.removeAttribute(o);for(let[a,i]of Object.entries(r))a.startsWith("--")?i?n.style.setProperty(a,i):n.style.removeProperty(a):i==null?n.removeAttribute(a):n.setAttribute(a,i);}},[e,t]);}function Jn(e){return e.replace(/[^a-zA-Z0-9]/g,"")}var Rt=Symbol.for("lumen.history.patched"),Le="lumen:locationchange";function eo(){if(typeof window>"u")return;let e=window;if(e[Rt])return;e[Rt]=true;let t=()=>window.dispatchEvent(new Event(Le)),n=history.pushState;history.pushState=function(...r){let a=n.apply(this,r);return t(),a};let o=history.replaceState;history.replaceState=function(...r){let a=o.apply(this,r);return t(),a},window.addEventListener("popstate",t);}function Lt(e){let[t,n]=at.useState(false);return at.useEffect(()=>{if(!e){n(false);return}if(typeof window>"u")return;eo();let o=()=>{try{n(!!e({pathname:window.location.pathname}));}catch{n(false);}};return o(),window.addEventListener(Le,o),window.addEventListener("popstate",o),()=>{window.removeEventListener(Le,o),window.removeEventListener("popstate",o);}},[e]),t}var oo=["wv","Capacitor","Cordova","Expo","FBAN","FBAV","Instagram","Line/","Twitter"];function Tt(){let[e,t]=at.useState(false);return at.useEffect(()=>{if(typeof window>"u")return;let n=window;if(n.ReactNativeWebView){t(true);return}let o=n.webkit;if(o&&o.messageHandlers){t(true);return}let r=navigator.userAgent||"";oo.some(a=>r.includes(a))&&t(true);},[]),e}var Nt="lumen.config.v1.",io=3600*1e3;function At(e,t){let[n,o]=at.useState(()=>({trigger:null,enabled:true,loading:true}));return at.useEffect(()=>{if(typeof window>"u")return;let r=uo(e);r&&o({trigger:r.trigger,enabled:Mt(r.trigger),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 s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);let d=await s.json(),m=St(d.trigger);if(!m)throw new Error("Malformed config response");co(e,m),o({trigger:m,enabled:Mt(m),loading:false});}).catch(()=>{o(s=>s.loading?{trigger:null,enabled:true,loading:false}:s);}).finally(()=>window.clearTimeout(i)),()=>{window.clearTimeout(i),a.abort();}},[e,t]),n}function Mt(e){return e.kind!=="headless"}var so=["br","bl","tr","tl"],lo=["top","right","bottom","left"];function St(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:so.find(r=>r===t.placement)??"br",label:n}:t.kind==="notch"?{kind:"notch",edge:lo.find(r=>r===t.edge)??"top",label:n}:null}function uo(e){try{let t=window.localStorage.getItem(Nt+e);if(!t)return null;let n=JSON.parse(t);if(typeof n?.fetchedAt!="number"||Date.now()-n.fetchedAt>io)return null;let o=St(n.trigger);return o?{fetchedAt:n.fetchedAt,trigger:o}:null}catch{return null}}function co(e,t){try{window.localStorage.setItem(Nt+e,JSON.stringify({fetchedAt:Date.now(),trigger:t}));}catch{}}var Dt="https://shakebugs.vercel.app";function mo({apiKey:e,apiUrl:t,user:n,amplitude:o,floatingButton:r=true,trigger:a,hideOn:i,theme:u,portalTarget:s,capture:d,onOpenChange:m,children:w}){let[b,R]=at.useState(false),[v]=at.useState(false),[C]=at.useState(null),k=at.useMemo(()=>new qe({apiKey:e,apiUrl:t,user:n,amplitude:o}),[e,t,n?.id,n?.email,n?.name,o?.userId,o?.deviceId,o?.sessionId]);at.useEffect(()=>{Ze({ignoreUrlPrefix:(t??Dt).replace(/\/$/,"")});},[t]);let T=at.useRef(m);T.current=m,at.useEffect(()=>{if(!(typeof document>"u"))return b?document.body.setAttribute("data-lumen-open","true"):document.body.removeAttribute("data-lumen-open"),()=>{document.body.removeAttribute("data-lumen-open");}},[b]);let N=at.useRef(null);at.useEffect(()=>{if(N.current===b)return;let P=N.current;N.current=b,P!==null&&T.current?.(b);},[b]);let E=at.useCallback(()=>R(true),[]),A=at.useCallback(()=>R(false),[]),D=at.useCallback(k.submit.bind(k),[k]),S=Tt(),p=Lt(i);kt(u);let g=At(a?"":e,t??Dt),h=at.useMemo(()=>({client:k,user:n,isOpen:b,isSubmitting:v,error:C,open:E,close:A,openCapture:E,closeCapture:A,submit:D,isNativeShell:S,capture:d}),[k,n,b,v,C,E,A,D,S,d]),x=po({explicit:a,remote:g.trigger,remoteLoading:g.loading,floatingButton:r});return jsxRuntime.jsxs(ve.Provider,{value:h,children:[w,x?.kind==="floating"?jsxRuntime.jsx(ht,{config:Ct(x),portalTarget:s,hidden:p,onClick:E}):null,x?.kind==="notch"?jsxRuntime.jsx(xt,{config:Et(x),portalTarget:s,hidden:p,onClick:E}):null,x?.kind==="inline"?jsxRuntime.jsx(wt,{mount:x.mount,label:x.label??"Feedback",icon:x.icon,onClick:E}):null,jsxRuntime.jsx(ke,{})]})}function po(e){return e.explicit?e.explicit:e.floatingButton===false?{kind:"headless"}:e.remote?e.remote:e.remoteLoading?null:{kind:"floating"}}function go({variant:e="default",floating:t=false,className:n,children:o="Feedback",onClick:r,...a}){let{openCapture:i}=Z(),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,onClick:s=>{r?.(s),s.defaultPrevented||i();},...a,children:o})}
|
|
4
|
+
exports.CaptureModal=ke;exports.FeedbackButton=go;exports.LumenProvider=mo;exports.useLumen=Z;//# sourceMappingURL=index.cjs.map
|
|
5
5
|
//# sourceMappingURL=index.cjs.map
|