bug-widget-library 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("html2canvas");l=s(l,1);let u=require("lucide-react"),d=require("react/jsx-runtime"),f=require("react-konva");function p(e){try{return new URL(e).hostname}catch{return`project`}}var m=({projectUrl:e,isOpen:t,onClose:n,uiSettings:r={},screenshots:i,onTriggerScreenshot:a,onEditScreenshot:o,onDeleteScreenshot:s,onSubmitReport:l})=>{let{position:f=`bottom-right`,primaryColor:m=`#2563eb`,title:h=`Report a Bug`,subtitle:g=`Found an issue? Let us know with details and screenshots.`,placeholderTitle:_=`e.g. Broken checkout button on cart page`,placeholderDescription:v=`Describe what happened, steps to reproduce, and expected result...`}=r,y=(e=>e===`bottom-left`||e===`top-left`||e===`left`)(f),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(``),[w,T]=(0,c.useState)(!1),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(null),[A,j]=(0,c.useState)({}),[M,N]=(0,c.useState)(null),P=p(e),F=()=>{let e={};return b.trim()||(e.title=`Title / bug name is required.`),S.trim()||(e.description=`Description is required.`),j(e),Object.keys(e).length===0};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{"data-bugdrop-widget":`true`,onClick:n,className:`fixed inset-0 z-[99990] bg-slate-900/40 backdrop-blur-sm transition-opacity duration-300 ${t?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`}),(0,d.jsxs)(`aside`,{"data-bugdrop-widget":`true`,className:`fixed top-0 z-[99995] flex h-full w-full max-w-md flex-col bg-white shadow-2xl transition-all duration-300 ease-out sm:max-w-lg ${y?`left-0 border-r border-slate-200`:`right-0 border-l border-slate-200`} ${y?t?`translate-x-0 opacity-100 pointer-events-auto`:`-translate-x-full opacity-0 pointer-events-none`:t?`translate-x-0 opacity-100 pointer-events-auto`:`translate-x-full opacity-0 pointer-events-none`}`,role:`dialog`,"aria-modal":`true`,"aria-label":h,children:[(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-slate-100 px-6 py-5`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl text-white shadow-md font-bold`,style:{backgroundColor:m},children:(0,d.jsx)(u.Sparkles,{className:`h-5 w-5`})}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`h2`,{className:`text-lg font-bold text-slate-800`,children:h}),(0,d.jsx)(`span`,{className:`rounded-md bg-slate-100 px-2 py-0.5 text-[11px] font-semibold tracking-wider text-slate-500`,title:e,children:P})]}),(0,d.jsx)(`p`,{className:`mt-0.5 text-xs text-slate-500`,children:g})]})]}),(0,d.jsx)(`button`,{type:`button`,onClick:n,className:`flex h-8 w-8 items-center justify-center rounded-lg text-slate-400 transition hover:bg-slate-100 hover:text-slate-600`,children:(0,d.jsx)(u.X,{className:`h-5 w-5`})})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5`,children:E?(0,d.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center py-10 animate-fadeIn`,children:[(0,d.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-full text-white shadow-lg mb-4`,style:{backgroundColor:m},children:(0,d.jsx)(u.CheckCircle2,{className:`h-9 w-9`})}),(0,d.jsx)(`h3`,{className:`text-xl font-bold text-slate-800`,children:`Bug Report Submitted!`}),(0,d.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500 max-w-xs`,children:[`Thank you! Your bug report with `,i.length,` screenshot`,i.length===1?``:`s`,` has been captured and logged.`]}),(0,d.jsxs)(`div`,{className:`mt-8 flex flex-col sm:flex-row gap-3 w-full`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>{x(``),C(``),j({}),k(null),D(!1)},className:`flex-1 rounded-xl border border-slate-200 bg-white py-2.5 text-sm font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50`,children:`Report Another Bug`}),(0,d.jsx)(`button`,{type:`button`,onClick:n,style:{backgroundColor:m},className:`flex-1 rounded-xl py-2.5 text-sm font-semibold text-white shadow-md transition hover:brightness-110`,children:`Close`})]})]}):(0,d.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),F()){T(!0),k(null);try{await l({projectUrl:e,title:b.trim(),description:S.trim(),screenshots:i,timestamp:new Date().toISOString(),meta:{url:window.location.href,userAgent:navigator.userAgent,timestamp:new Date().toISOString(),screenSize:{width:window.innerWidth,height:window.innerHeight}}}),D(!0)}catch(e){console.error(`Failed to submit bug report:`,e),k(e instanceof Error?e.message:`Failed to submit bug report. Please try again.`)}finally{T(!1)}}},className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`label`,{className:`block text-xs font-bold tracking-wide uppercase text-slate-700`,children:[`Bug Title / Name `,(0,d.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,d.jsx)(`input`,{type:`text`,value:b,onChange:e=>{x(e.target.value),A.title&&j(e=>({...e,title:void 0}))},placeholder:_,className:`mt-1.5 w-full rounded-xl border px-3.5 py-2.5 text-sm transition focus:outline-none focus:ring-2 ${A.title?`border-red-300 bg-red-50/50 text-red-900 focus:ring-red-400`:`border-slate-200 bg-white text-slate-800 focus:border-transparent focus:ring-blue-500`}`}),A.title&&(0,d.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1 text-xs text-red-600`,children:[(0,d.jsx)(u.AlertCircle,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:A.title})]})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`label`,{className:`block text-xs font-bold tracking-wide uppercase text-slate-700`,children:[`Description `,(0,d.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,d.jsx)(`textarea`,{rows:4,value:S,onChange:e=>{C(e.target.value),A.description&&j(e=>({...e,description:void 0}))},placeholder:v,className:`mt-1.5 w-full rounded-xl border px-3.5 py-2.5 text-sm transition focus:outline-none focus:ring-2 ${A.description?`border-red-300 bg-red-50/50 text-red-900 focus:ring-red-400`:`border-slate-200 bg-white text-slate-800 focus:border-transparent focus:ring-blue-500`}`}),A.description&&(0,d.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1 text-xs text-red-600`,children:[(0,d.jsx)(u.AlertCircle,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:A.description})]})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`label`,{className:`block text-xs font-bold tracking-wide uppercase text-slate-700`,children:[`Screenshots `,(0,d.jsx)(`span`,{className:`text-slate-400 font-normal lowercase`,children:`(optional)`})]}),(0,d.jsxs)(`span`,{className:`rounded-full bg-slate-100 px-2 py-0.5 text-xs font-semibold text-slate-600`,children:[i.length,` / 3`]})]}),(0,d.jsx)(`p`,{className:`mt-1 text-xs text-slate-500`,children:`Capture your screen and annotate with pencil, shapes, or arrows.`}),i.length>0&&(0,d.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-2.5`,children:i.map((e,t)=>(0,d.jsxs)(`div`,{className:`group relative aspect-video overflow-hidden rounded-lg border border-slate-200 bg-slate-100 shadow-sm`,children:[(0,d.jsx)(`img`,{src:e.dataUrl,alt:`Screenshot ${t+1}`,className:`h-full w-full object-cover transition duration-200 group-hover:scale-105`}),(0,d.jsxs)(`span`,{className:`absolute top-1 left-1 rounded bg-black/60 px-1 py-0.2 text-[10px] font-semibold text-white`,children:[`#`,t+1]}),(0,d.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-1.5 bg-black/50 opacity-0 backdrop-blur-[1px] transition-opacity duration-200 group-hover:opacity-100`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>N(e.dataUrl),title:`Preview screenshot`,className:`flex h-7 w-7 items-center justify-center rounded-md bg-white/90 text-slate-700 shadow transition hover:bg-white hover:text-blue-600`,children:(0,d.jsx)(u.Eye,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>o(e),title:`Re-edit / annotate`,className:`flex h-7 w-7 items-center justify-center rounded-md bg-white/90 text-slate-700 shadow transition hover:bg-white hover:text-blue-600`,children:(0,d.jsx)(u.Edit3,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),title:`Delete screenshot`,className:`flex h-7 w-7 items-center justify-center rounded-md bg-red-600 text-white shadow transition hover:bg-red-700`,children:(0,d.jsx)(u.Trash2,{className:`h-3.5 w-3.5`})})]})]},e.id))}),(0,d.jsx)(`div`,{className:`mt-3`,children:i.length<3?(0,d.jsxs)(`button`,{type:`button`,onClick:a,className:`flex w-full items-center justify-center gap-2 rounded-xl border-2 border-dashed border-slate-300 bg-slate-50/70 py-3 text-xs font-semibold text-slate-600 transition hover:border-blue-400 hover:bg-blue-50/50 hover:text-blue-600`,children:[(0,d.jsx)(u.Camera,{className:`h-4 w-4 text-slate-500`}),(0,d.jsx)(`span`,{children:i.length===0?`Capture Screen & Annotate`:`Capture Another Screenshot (${3-i.length} left)`})]}):(0,d.jsx)(`div`,{className:`rounded-lg bg-amber-50 p-2.5 text-center text-xs text-amber-700 border border-amber-200`,children:`Maximum 3 screenshots attached. Delete one to take a new one.`})})]}),O&&(0,d.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 px-3.5 py-2.5 text-xs text-red-700 flex items-start gap-2`,children:[(0,d.jsx)(u.AlertCircle,{className:`h-4 w-4 shrink-0 mt-0.5`}),(0,d.jsx)(`span`,{children:O})]}),(0,d.jsxs)(`div`,{className:`pt-4 border-t border-slate-100 flex items-center justify-end gap-3`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-xl border border-slate-200 bg-white px-4 py-2.5 text-sm font-semibold text-slate-600 transition hover:bg-slate-50`,children:`Cancel`}),(0,d.jsx)(`button`,{type:`submit`,disabled:w,style:{backgroundColor:m},className:`flex items-center gap-2 rounded-xl px-5 py-2.5 text-sm font-semibold text-white shadow-md transition hover:brightness-110 active:scale-95 disabled:opacity-60`,children:w?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(u.Loader2,{className:`h-4 w-4 animate-spin`}),(0,d.jsx)(`span`,{children:`Submitting...`})]}):(0,d.jsx)(`span`,{children:`Submit Bug Report`})})]})]})})]}),M&&(0,d.jsx)(`div`,{"data-bugdrop-widget":`true`,onClick:()=>N(null),className:`fixed inset-0 z-[100001] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm animate-fadeIn`,children:(0,d.jsxs)(`div`,{className:`relative max-h-[90vh] max-w-[90vw] overflow-hidden rounded-xl bg-slate-900 shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,d.jsx)(`img`,{src:M,alt:`Screenshot Preview`,className:`max-h-[85vh] w-auto rounded-xl object-contain`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>N(null),className:`absolute top-3 right-3 flex h-8 w-8 items-center justify-center rounded-full bg-black/60 text-white shadow hover:bg-black/90`,children:(0,d.jsx)(u.X,{className:`h-4 w-4`})})]})})]})},h=[`#ef4444`,`#f97316`,`#eab308`,`#10b981`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#000000`,`#ffffff`],g=[{label:`S`,value:3},{label:`M`,value:6},{label:`L`,value:10},{label:`XL`,value:16}],_=({imageSrc:e,onSave:t,onCancel:n,primaryColor:r=`#2563eb`})=>{let i=(0,c.useRef)(null),a=(0,c.useRef)(null),o=(0,c.useRef)(null),[s,l]=(0,c.useState)(null),[p,m]=(0,c.useState)(1),[_,v]=(0,c.useState)({width:800,height:600}),[y,b]=(0,c.useState)(`pencil`),[x,S]=(0,c.useState)(`#ef4444`),[C,w]=(0,c.useState)(6),[T,E]=(0,c.useState)(null),[D,O]=(0,c.useState)([]),[k,A]=(0,c.useState)(null),[j,M]=(0,c.useState)(!1),[N,P]=(0,c.useState)(null),[F,I]=(0,c.useState)([[]]),[L,R]=(0,c.useState)(0);(0,c.useEffect)(()=>{let t=new window.Image;t.crossOrigin=`anonymous`,t.src=e,t.onload=()=>{l(t)}},[e]);let z=(0,c.useCallback)(()=>{if(!i.current||!s)return;let e=Math.max(300,i.current.clientWidth-48),t=Math.max(300,i.current.clientHeight-120),n=Math.min(e/s.naturalWidth,t/s.naturalHeight,1);m(n),v({width:Math.round(s.naturalWidth*n),height:Math.round(s.naturalHeight*n)})},[s]);(0,c.useEffect)(()=>(z(),window.addEventListener(`resize`,z),()=>window.removeEventListener(`resize`,z)),[z]),(0,c.useEffect)(()=>{if(o.current&&a.current){if(T){let e=a.current.findOne(`#`+T);if(e){o.current.nodes([e]),o.current.getLayer()?.batchDraw();return}}o.current.nodes([]),o.current.getLayer()?.batchDraw()}},[T,D]);let B=(0,c.useCallback)(e=>{I(t=>{let n=t.slice(0,L+1);return n.push(e),n}),R(e=>e+1)},[L]),V=(0,c.useCallback)(()=>{if(L>0){let e=L-1;R(e),O(F[e]),E(null)}},[L,F]),H=(0,c.useCallback)(()=>{if(L<F.length-1){let e=L+1;R(e),O(F[e]),E(null)}},[L,F]),U=()=>{if(D.length===0)return;let e=[];O(e),B(e),E(null)},W=(0,c.useCallback)(()=>{if(!T)return;let e=D.filter(e=>e.id!==T);O(e),B(e),E(null)},[T,D,B]);(0,c.useEffect)(()=>{let e=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||((e.ctrlKey||e.metaKey)&&e.key===`z`?(e.shiftKey?H():V(),e.preventDefault()):(e.ctrlKey||e.metaKey)&&e.key===`y`?(H(),e.preventDefault()):e.key===`Delete`||e.key===`Backspace`?T&&(W(),e.preventDefault()):e.key===`Escape`&&(E(null),e.preventDefault()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[W,H,V,T]);let G=e=>{let t=a.current;if(!t||!s)return;let n=t.getPointerPosition();if(!n)return;let r=n.x/p,i=n.y/p;if(y===`select`){(e.target===t||e.target.hasName(`bg-image`))&&E(null);return}if(y===`eraser`){let n=e.target;if(n!==t&&!n.hasName(`bg-image`)){let e=n.id();if(e){let t=D.filter(t=>t.id!==e);O(t),B(t),E(null);return}}}E(null),M(!0),P({x:r,y:i});let o=`shape_${Date.now()}_${Math.random().toString(36).substring(2,7)}`;if(y===`pencil`||y===`eraser`){let e={id:o,type:`line`,tool:y,points:[r,i],stroke:y===`eraser`?`#ffffff`:x,strokeWidth:y===`eraser`?C*2.5:C};A(e)}else y===`rectangle`?A({id:o,type:`rectangle`,x:r,y:i,width:0,height:0,stroke:x,strokeWidth:C}):y===`circle`?A({id:o,type:`circle`,x:r,y:i,radius:0,stroke:x,strokeWidth:C}):y===`arrow`&&A({id:o,type:`arrow`,points:[r,i,r,i],stroke:x,fill:x,strokeWidth:C})},K=()=>{if(!j||!k||!N||!a.current)return;let e=a.current.getPointerPosition();if(!e)return;let t=e.x/p,n=e.y/p;if(k.type===`line`)A({...k,points:[...k.points,t,n]});else if(k.type===`rectangle`){let e=Math.min(N.x,t),r=Math.min(N.y,n),i=Math.abs(t-N.x),a=Math.abs(n-N.y);A({...k,x:e,y:r,width:i,height:a})}else if(k.type===`circle`){let e=Math.hypot(t-N.x,n-N.y);A({...k,radius:e})}else k.type===`arrow`&&A({...k,points:[N.x,N.y,t,n]})},q=()=>{if(!j||(M(!1),!k))return;let e=!1;if(k.type===`line`&&k.points.length>=2)e=!0;else if(k.type===`rectangle`&&k.width>6&&k.height>6)e=!0;else if(k.type===`circle`&&k.radius>5)e=!0;else if(k.type===`arrow`){let[t,n,r,i]=k.points;Math.hypot(r-t,i-n)>10&&(e=!0)}if(e){let e=[...D,k];O(e),B(e),(k.type===`rectangle`||k.type===`circle`||k.type===`arrow`)&&(E(k.id),b(`select`))}A(null),P(null)},J=(e,t)=>{let n=e.target,r=D.find(e=>e.id===t);if(r){if(r.type===`rectangle`){let e=n.scaleX(),i=n.scaleY();n.scaleX(1),n.scaleY(1);let a={...r,x:n.x(),y:n.y(),width:Math.max(10,n.width()*e),height:Math.max(10,n.height()*i),rotation:n.rotation()},o=D.map(e=>e.id===t?a:e);O(o),B(o)}else if(r.type===`circle`){let e=n.scaleX();n.scaleX(1),n.scaleY(1);let i={...r,x:n.x(),y:n.y(),radius:Math.max(6,r.radius*e),rotation:n.rotation()},a=D.map(e=>e.id===t?i:e);O(a),B(a)}else if(r.type===`arrow`){let e=n.scaleX(),i=n.scaleY();n.scaleX(1),n.scaleY(1);let[a,o,s,c]=r.points,l={...r,x:n.x(),y:n.y(),points:[a,o,a+(s-a)*e,o+(c-o)*i],rotation:n.rotation()},u=D.map(e=>e.id===t?l:e);O(u),B(u)}}},Y=(e,t)=>{let n=e.target;if(!D.find(e=>e.id===t))return;let r=D.map(e=>e.id===t?{...e,x:n.x(),y:n.y()}:e);O(r),B(r)};return(0,d.jsxs)(`div`,{ref:i,className:`fixed inset-0 z-[100000] flex flex-col bg-slate-950/90 backdrop-blur-md select-none text-white overflow-hidden animate-fadeIn`,style:{touchAction:`none`},children:[(0,d.jsxs)(`div`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-slate-800 bg-slate-900/90 px-4 sm:px-6`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg text-white font-bold text-sm shadow`,style:{backgroundColor:r},children:`BD`}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h1`,{className:`text-sm sm:text-base font-semibold leading-tight text-slate-100`,children:`Screenshot Editor`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-400 hidden sm:block`,children:`Highlight issues with pencil, arrows, circles, and boxes`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:V,disabled:L<=0,title:`Undo (Ctrl+Z)`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-slate-700 bg-slate-800 text-slate-200 transition hover:bg-slate-700 hover:text-white disabled:opacity-40 disabled:pointer-events-none`,children:(0,d.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,d.jsx)(`button`,{type:`button`,onClick:H,disabled:L>=F.length-1,title:`Redo (Ctrl+Y)`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-slate-700 bg-slate-800 text-slate-200 transition hover:bg-slate-700 hover:text-white disabled:opacity-40 disabled:pointer-events-none`,children:(0,d.jsx)(u.Redo2,{className:`h-4 w-4`})}),(0,d.jsxs)(`button`,{type:`button`,onClick:U,disabled:D.length===0,title:`Clear all annotations`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-slate-700 bg-slate-800 px-2.5 text-xs font-medium text-slate-300 transition hover:bg-slate-700 hover:text-white disabled:opacity-40 disabled:pointer-events-none`,children:[(0,d.jsx)(u.Trash2,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{className:`hidden md:inline`,children:`Clear All`})]}),(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700 mx-1`}),(0,d.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-9 items-center gap-1.5 rounded-lg border border-slate-700 bg-slate-800 px-3 text-xs sm:text-sm font-medium text-slate-200 transition hover:bg-slate-700 hover:text-white`,children:[(0,d.jsx)(u.X,{className:`h-4 w-4`}),(0,d.jsx)(`span`,{children:`Cancel`})]}),(0,d.jsxs)(`button`,{type:`button`,onClick:()=>{a.current&&(E(null),setTimeout(()=>{a.current&&t(a.current.toDataURL({pixelRatio:1/p,mimeType:`image/png`}))},60))},style:{backgroundColor:r},className:`flex h-9 items-center gap-1.5 rounded-lg px-4 text-xs sm:text-sm font-semibold text-white shadow-md transition hover:brightness-110 active:scale-95`,children:[(0,d.jsx)(u.Check,{className:`h-4 w-4`}),(0,d.jsx)(`span`,{children:`Add to Report`})]})]})]}),(0,d.jsxs)(`div`,{className:`absolute top-20 left-1/2 -translate-x-1/2 z-20 flex flex-wrap items-center justify-center gap-2 rounded-2xl border border-slate-700/80 bg-slate-900/95 p-2 shadow-2xl backdrop-blur-md`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>b(`select`),title:`Select & Move / Resize`,className:`flex h-9 w-9 items-center justify-center rounded-xl transition ${y===`select`?`bg-blue-600 text-white shadow-inner`:`text-slate-300 hover:bg-slate-800 hover:text-white`}`,children:(0,d.jsx)(u.MousePointer,{className:`h-4 w-4`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>{b(`pencil`),E(null)},title:`Pencil / Draw`,className:`flex h-9 w-9 items-center justify-center rounded-xl transition ${y===`pencil`?`bg-blue-600 text-white shadow-inner`:`text-slate-300 hover:bg-slate-800 hover:text-white`}`,children:(0,d.jsx)(u.Pencil,{className:`h-4 w-4`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>{b(`eraser`),E(null)},title:`Eraser (click or drag to erase)`,className:`flex h-9 w-9 items-center justify-center rounded-xl transition ${y===`eraser`?`bg-blue-600 text-white shadow-inner`:`text-slate-300 hover:bg-slate-800 hover:text-white`}`,children:(0,d.jsx)(u.Eraser,{className:`h-4 w-4`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>{b(`rectangle`),E(null)},title:`Rectangle (Resizable)`,className:`flex h-9 w-9 items-center justify-center rounded-xl transition ${y===`rectangle`?`bg-blue-600 text-white shadow-inner`:`text-slate-300 hover:bg-slate-800 hover:text-white`}`,children:(0,d.jsx)(u.Square,{className:`h-4 w-4`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>{b(`circle`),E(null)},title:`Circle (Resizable)`,className:`flex h-9 w-9 items-center justify-center rounded-xl transition ${y===`circle`?`bg-blue-600 text-white shadow-inner`:`text-slate-300 hover:bg-slate-800 hover:text-white`}`,children:(0,d.jsx)(u.Circle,{className:`h-4 w-4`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>{b(`arrow`),E(null)},title:`Arrow (Resizable)`,className:`flex h-9 w-9 items-center justify-center rounded-xl transition ${y===`arrow`?`bg-blue-600 text-white shadow-inner`:`text-slate-300 hover:bg-slate-800 hover:text-white`}`,children:(0,d.jsx)(u.ArrowUpRight,{className:`h-4 w-4`})})]}),(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1`,children:[h.map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>S(e),title:e,style:{backgroundColor:e},className:`h-5 w-5 rounded-full border border-slate-700 transition-transform ${x===e?`scale-125 ring-2 ring-white ring-offset-1 ring-offset-slate-900`:`hover:scale-110`}`},e)),(0,d.jsxs)(`label`,{title:`Custom Color`,className:`relative flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-slate-600 bg-slate-800 text-slate-300 hover:text-white transition`,children:[(0,d.jsx)(u.Palette,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`input`,{type:`color`,value:x,onChange:e=>S(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer`})]})]}),(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700`}),(0,d.jsx)(`div`,{className:`flex items-center gap-1`,children:g.map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>w(e.value),className:`flex h-7 w-7 items-center justify-center rounded-lg text-xs font-semibold transition ${C===e.value?`bg-slate-700 text-white ring-1 ring-slate-400`:`text-slate-400 hover:bg-slate-800 hover:text-white`}`,children:e.label},e.value))}),T&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700`}),(0,d.jsxs)(`button`,{type:`button`,onClick:W,title:`Delete Selected Shape (Del / Backspace)`,className:`flex h-8 items-center gap-1.5 rounded-xl bg-red-600/90 px-3 text-xs font-semibold text-white shadow hover:bg-red-600`,children:[(0,d.jsx)(u.Trash2,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Delete`})]})]})]}),(0,d.jsx)(`div`,{className:`relative flex flex-1 items-center justify-center p-4 overflow-hidden`,children:s?(0,d.jsx)(`div`,{className:`relative shadow-2xl rounded-md overflow-hidden border border-slate-700 bg-slate-900`,style:{width:_.width,height:_.height,cursor:y===`select`?`default`:y===`eraser`?`cell`:`crosshair`},children:(0,d.jsxs)(f.Stage,{ref:a,width:_.width,height:_.height,scaleX:p,scaleY:p,onMouseDown:G,onMouseMove:K,onMouseUp:q,onTouchStart:G,onTouchMove:K,onTouchEnd:q,children:[(0,d.jsx)(f.Layer,{listening:!1,children:(0,d.jsx)(f.Image,{name:`bg-image`,image:s,width:s.naturalWidth,height:s.naturalHeight})}),(0,d.jsxs)(f.Layer,{children:[D.map(e=>{let t=y===`select`;return e.type===`line`?(0,d.jsx)(f.Line,{id:e.id,points:e.points,stroke:e.stroke,strokeWidth:e.strokeWidth,tension:.5,lineCap:`round`,lineJoin:`round`,globalCompositeOperation:e.tool===`eraser`?`destination-out`:`source-over`,draggable:t&&e.tool!==`eraser`,onClick:()=>{if(t&&E(e.id),y===`eraser`){let t=D.filter(t=>t.id!==e.id);O(t),B(t)}},onTap:()=>{t&&E(e.id)},onDragEnd:t=>Y(t,e.id)},e.id):e.type===`rectangle`?(0,d.jsx)(f.Rect,{id:e.id,x:e.x,y:e.y,width:e.width,height:e.height,stroke:e.stroke,strokeWidth:e.strokeWidth,rotation:e.rotation||0,draggable:t,onClick:()=>{if(t&&E(e.id),y===`eraser`){let t=D.filter(t=>t.id!==e.id);O(t),B(t)}},onTap:()=>{t&&E(e.id)},onTransformEnd:t=>J(t,e.id),onDragEnd:t=>Y(t,e.id)},e.id):e.type===`circle`?(0,d.jsx)(f.Circle,{id:e.id,x:e.x,y:e.y,radius:e.radius,stroke:e.stroke,strokeWidth:e.strokeWidth,rotation:e.rotation||0,draggable:t,onClick:()=>{if(t&&E(e.id),y===`eraser`){let t=D.filter(t=>t.id!==e.id);O(t),B(t)}},onTap:()=>{t&&E(e.id)},onTransformEnd:t=>J(t,e.id),onDragEnd:t=>Y(t,e.id)},e.id):e.type===`arrow`?(0,d.jsx)(f.Arrow,{id:e.id,points:e.points,pointerLength:14,pointerWidth:14,stroke:e.stroke,fill:e.fill,strokeWidth:e.strokeWidth,rotation:e.rotation||0,draggable:t,onClick:()=>{if(t&&E(e.id),y===`eraser`){let t=D.filter(t=>t.id!==e.id);O(t),B(t)}},onTap:()=>{t&&E(e.id)},onTransformEnd:t=>J(t,e.id),onDragEnd:t=>Y(t,e.id)},e.id):null}),k&&(0,d.jsxs)(d.Fragment,{children:[k.type===`line`&&(0,d.jsx)(f.Line,{points:k.points,stroke:k.stroke,strokeWidth:k.strokeWidth,tension:.5,lineCap:`round`,lineJoin:`round`,globalCompositeOperation:k.tool===`eraser`?`destination-out`:`source-over`}),k.type===`rectangle`&&(0,d.jsx)(f.Rect,{x:k.x,y:k.y,width:k.width,height:k.height,stroke:k.stroke,strokeWidth:k.strokeWidth,dash:[6,4]}),k.type===`circle`&&(0,d.jsx)(f.Circle,{x:k.x,y:k.y,radius:k.radius,stroke:k.stroke,strokeWidth:k.strokeWidth,dash:[6,4]}),k.type===`arrow`&&(0,d.jsx)(f.Arrow,{points:k.points,pointerLength:14,pointerWidth:14,stroke:k.stroke,fill:k.fill,strokeWidth:k.strokeWidth,dash:[6,4]})]}),(0,d.jsx)(f.Transformer,{ref:o,rotateEnabled:!0,enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`,`middle-left`,`middle-right`,`top-center`,`bottom-center`],borderStroke:`#3b82f6`,borderDash:[4,4],anchorFill:`#ffffff`,anchorStroke:`#3b82f6`,anchorSize:9,anchorCornerRadius:2,boundBoxFunc:(e,t)=>t.width<10||t.height<10?e:t})]})]})}):(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-slate-400`,children:[(0,d.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-blue-500 border-t-transparent`}),(0,d.jsx)(`p`,{className:`text-sm`,children:`Loading screenshot...`})]})}),(0,d.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between border-t border-slate-800 bg-slate-900/80 px-4 text-xs text-slate-400`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,d.jsxs)(`span`,{children:[`Active tool: `,(0,d.jsx)(`strong`,{className:`text-slate-200 capitalize`,children:y})]}),(0,d.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Use `,(0,d.jsx)(`kbd`,{className:`rounded bg-slate-800 px-1 py-0.5 text-slate-300`,children:`Ctrl+Z`}),` to undo, `,(0,d.jsx)(`kbd`,{className:`rounded bg-slate-800 px-1 py-0.5 text-slate-300`,children:`Del`}),` to remove selected shape`]})]}),(0,d.jsx)(`div`,{children:s&&(0,d.jsxs)(`span`,{children:[`Original Resolution: `,s.naturalWidth,` x `,s.naturalHeight,`px`]})})]})]})},v=({projectUrl:e,onSubmit:t,uiSettings:n={},onSuccess:r,onError:i,isOpen:a,onToggle:o,className:s=``})=>{let{position:f=`bottom-right`,primaryColor:p=`#2563eb`,buttonSize:h=`md`,buttonText:g,buttonIcon:v,zIndex:y=99990}=n,[b,x]=(0,c.useState)(!1),S=a===void 0?b:a,C=e=>{a===void 0&&x(e),o?.(e)},[w,T]=(0,c.useState)([]),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1),[A,j]=(0,c.useState)(null),M=e=>{switch(e){case`bottom-left`:return`bottom-6 left-6`;case`top-left`:return`top-6 left-6`;case`top-right`:return`top-6 right-6`;case`left`:return`top-1/2 -translate-y-1/2 left-4`;case`right`:return`top-1/2 -translate-y-1/2 right-4`;default:return`bottom-6 right-6`}},N=(e=>{switch(e){case`sm`:return{button:`h-10 px-3.5 gap-2 text-xs font-semibold rounded-full shadow-md`,icon:`h-4 w-4`};case`lg`:return{button:`h-14 px-5 gap-3 text-base font-bold rounded-full shadow-xl`,icon:`h-6 w-6`};default:return{button:`h-12 px-4 gap-2.5 text-sm font-semibold rounded-full shadow-lg`,icon:`h-5 w-5`}}})(h);return E?null:(0,d.jsxs)(d.Fragment,{children:[!O&&(0,d.jsx)(`div`,{"data-bugdrop-widget":`true`,className:`fixed ${M(f)} ${s}`,style:{zIndex:y},children:(0,d.jsxs)(`button`,{type:`button`,onClick:()=>C(!S),style:{backgroundColor:p},className:`group flex items-center justify-center text-white transition-all duration-200 hover:brightness-110 active:scale-95 ${N.button}`,"aria-label":S?`Close bug report form`:`Open bug report form`,title:S?`Close Bug Report`:`Report a Bug`,children:[S?(0,d.jsx)(u.X,{className:N.icon}):v||(0,d.jsx)(u.Bug,{className:N.icon}),g&&(0,d.jsx)(`span`,{children:g}),w.length>0&&!S&&(0,d.jsx)(`span`,{className:`flex h-5 w-5 items-center justify-center rounded-full bg-white text-[11px] font-bold text-slate-900 shadow`,children:w.length})]})}),!O&&(0,d.jsx)(m,{projectUrl:e,isOpen:S,onClose:()=>C(!1),uiSettings:n,screenshots:w,onTriggerScreenshot:async()=>{D(!0);try{await new Promise(e=>setTimeout(e,180));let e=(await(0,l.default)(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scrollX:0,scrollY:-window.scrollY,windowWidth:document.documentElement.offsetWidth,windowHeight:document.documentElement.offsetHeight,ignoreElements:e=>e.getAttribute(`data-bugdrop-widget`)===`true`||e.classList.contains(`bugdrop-ignore`)})).toDataURL(`image/png`);j({dataUrl:e,isNew:!0}),k(!0)}catch(e){console.error(`Error taking screenshot:`,e),alert(`Could not capture screenshot. Please try again.`)}finally{D(!1)}},onEditScreenshot:e=>{j({id:e.id,dataUrl:e.dataUrl,isNew:!1}),k(!0)},onDeleteScreenshot:e=>{T(t=>t.filter(t=>t.id!==e))},onSubmitReport:async e=>{try{await t(e),r?.(e)}catch(e){let t=e instanceof Error?e:Error(`Failed to submit bug report`);throw i?.(t),t}}}),O&&A&&(0,d.jsx)(_,{imageSrc:A.dataUrl,onSave:e=>{if(A?.isNew){if(w.length<3){let t={id:`ss_${Date.now()}_${Math.random().toString(36).substring(2,6)}`,dataUrl:e,createdAt:Date.now()};T(e=>[...e,t])}}else A?.id&&T(t=>t.map(t=>t.id===A.id?{...t,dataUrl:e}:t));k(!1),j(null),C(!0)},onCancel:()=>{k(!1),j(null),C(!0)},primaryColor:p})]})};exports.Widget=v;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("html2canvas");l=s(l,1);let u=require("lucide-react"),d=require("react/jsx-runtime");function f(e){try{return new URL(e).hostname}catch{return`project`}}var p=({projectUrl:e,isOpen:t,onClose:n,uiSettings:r={},screenshots:i,onTriggerScreenshot:a,onEditScreenshot:o,onDeleteScreenshot:s,onSubmitReport:l})=>{let{position:p=`bottom-right`,primaryColor:m=`#2563eb`,title:h=`Report a Bug`,subtitle:g=`Found an issue? Let us know with details and screenshots.`,placeholderTitle:_=`e.g. Broken checkout button on cart page`,placeholderDescription:v=`Describe what happened, steps to reproduce, and expected result...`}=r,y=(e=>e===`bottom-left`||e===`top-left`||e===`left`)(p),[b,x]=(0,c.useState)(``),[S,C]=(0,c.useState)(``),[w,T]=(0,c.useState)(!1),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(null),[A,j]=(0,c.useState)({}),[M,N]=(0,c.useState)(null),P=f(e),F=()=>{let e={};return b.trim()||(e.title=`Title / bug name is required.`),S.trim()||(e.description=`Description is required.`),j(e),Object.keys(e).length===0};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{"data-bugdrop-widget":`true`,onClick:n,className:`fixed inset-0 z-[99990] bg-slate-900/40 backdrop-blur-sm transition-opacity duration-300 ${t?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`}),(0,d.jsxs)(`aside`,{"data-bugdrop-widget":`true`,className:`fixed top-0 z-[99995] flex h-full w-full max-w-md flex-col bg-white shadow-2xl transition-all duration-300 ease-out sm:max-w-lg ${y?`left-0 border-r border-slate-200`:`right-0 border-l border-slate-200`} ${y?t?`translate-x-0 opacity-100 pointer-events-auto`:`-translate-x-full opacity-0 pointer-events-none`:t?`translate-x-0 opacity-100 pointer-events-auto`:`translate-x-full opacity-0 pointer-events-none`}`,role:`dialog`,"aria-modal":`true`,"aria-label":h,children:[(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-slate-100 px-6 py-5`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl text-white shadow-md font-bold`,style:{backgroundColor:m},children:(0,d.jsx)(u.Sparkles,{className:`h-5 w-5`})}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`h2`,{className:`text-lg font-bold text-slate-800`,children:h}),(0,d.jsx)(`span`,{className:`rounded-md bg-slate-100 px-2 py-0.5 text-[11px] font-semibold tracking-wider text-slate-500`,title:e,children:P})]}),(0,d.jsx)(`p`,{className:`mt-0.5 text-xs text-slate-500`,children:g})]})]}),(0,d.jsx)(`button`,{type:`button`,onClick:n,className:`flex h-8 w-8 items-center justify-center rounded-lg text-slate-400 transition hover:bg-slate-100 hover:text-slate-600`,children:(0,d.jsx)(u.X,{className:`h-5 w-5`})})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5`,children:E?(0,d.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center text-center py-10 animate-fadeIn`,children:[(0,d.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-full text-white shadow-lg mb-4`,style:{backgroundColor:m},children:(0,d.jsx)(u.CheckCircle2,{className:`h-9 w-9`})}),(0,d.jsx)(`h3`,{className:`text-xl font-bold text-slate-800`,children:`Bug Report Submitted!`}),(0,d.jsxs)(`p`,{className:`mt-2 text-sm text-slate-500 max-w-xs`,children:[`Thank you! Your bug report with `,i.length,` screenshot`,i.length===1?``:`s`,` has been captured and logged.`]}),(0,d.jsxs)(`div`,{className:`mt-8 flex flex-col sm:flex-row gap-3 w-full`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>{x(``),C(``),j({}),k(null),D(!1)},className:`flex-1 rounded-xl border border-slate-200 bg-white py-2.5 text-sm font-semibold text-slate-700 shadow-sm transition hover:bg-slate-50`,children:`Report Another Bug`}),(0,d.jsx)(`button`,{type:`button`,onClick:n,style:{backgroundColor:m},className:`flex-1 rounded-xl py-2.5 text-sm font-semibold text-white shadow-md transition hover:brightness-110`,children:`Close`})]})]}):(0,d.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),F()){T(!0),k(null);try{await l({projectUrl:e,title:b.trim(),description:S.trim(),screenshots:i,timestamp:new Date().toISOString(),meta:{url:window.location.href,userAgent:navigator.userAgent,timestamp:new Date().toISOString(),screenSize:{width:window.innerWidth,height:window.innerHeight}}}),D(!0)}catch(e){console.error(`Failed to submit bug report:`,e),k(e instanceof Error?e.message:`Failed to submit bug report. Please try again.`)}finally{T(!1)}}},className:`space-y-5`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`label`,{className:`block text-xs font-bold tracking-wide uppercase text-slate-700`,children:[`Bug Title / Name `,(0,d.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,d.jsx)(`input`,{type:`text`,value:b,onChange:e=>{x(e.target.value),A.title&&j(e=>({...e,title:void 0}))},placeholder:_,className:`mt-1.5 w-full rounded-xl border px-3.5 py-2.5 text-sm transition focus:outline-none focus:ring-2 ${A.title?`border-red-300 bg-red-50/50 text-red-900 focus:ring-red-400`:`border-slate-200 bg-white text-slate-800 focus:border-transparent focus:ring-blue-500`}`}),A.title&&(0,d.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1 text-xs text-red-600`,children:[(0,d.jsx)(u.AlertCircle,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:A.title})]})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`label`,{className:`block text-xs font-bold tracking-wide uppercase text-slate-700`,children:[`Description `,(0,d.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,d.jsx)(`textarea`,{rows:4,value:S,onChange:e=>{C(e.target.value),A.description&&j(e=>({...e,description:void 0}))},placeholder:v,className:`mt-1.5 w-full rounded-xl border px-3.5 py-2.5 text-sm transition focus:outline-none focus:ring-2 ${A.description?`border-red-300 bg-red-50/50 text-red-900 focus:ring-red-400`:`border-slate-200 bg-white text-slate-800 focus:border-transparent focus:ring-blue-500`}`}),A.description&&(0,d.jsxs)(`p`,{className:`mt-1.5 flex items-center gap-1 text-xs text-red-600`,children:[(0,d.jsx)(u.AlertCircle,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:A.description})]})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`label`,{className:`block text-xs font-bold tracking-wide uppercase text-slate-700`,children:[`Screenshots `,(0,d.jsx)(`span`,{className:`text-slate-400 font-normal lowercase`,children:`(optional)`})]}),(0,d.jsxs)(`span`,{className:`rounded-full bg-slate-100 px-2 py-0.5 text-xs font-semibold text-slate-600`,children:[i.length,` / 3`]})]}),(0,d.jsx)(`p`,{className:`mt-1 text-xs text-slate-500`,children:`Capture your screen and annotate with pencil, shapes, or arrows.`}),i.length>0&&(0,d.jsx)(`div`,{className:`mt-3 grid grid-cols-3 gap-2.5`,children:i.map((e,t)=>(0,d.jsxs)(`div`,{className:`group relative aspect-video overflow-hidden rounded-lg border border-slate-200 bg-slate-100 shadow-sm`,children:[(0,d.jsx)(`img`,{src:e.dataUrl,alt:`Screenshot ${t+1}`,className:`h-full w-full object-cover transition duration-200 group-hover:scale-105`}),(0,d.jsxs)(`span`,{className:`absolute top-1 left-1 rounded bg-black/60 px-1 py-0.2 text-[10px] font-semibold text-white`,children:[`#`,t+1]}),(0,d.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-1.5 bg-black/50 opacity-0 backdrop-blur-[1px] transition-opacity duration-200 group-hover:opacity-100`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:()=>N(e.dataUrl),title:`Preview screenshot`,className:`flex h-7 w-7 items-center justify-center rounded-md bg-white/90 text-slate-700 shadow transition hover:bg-white hover:text-blue-600`,children:(0,d.jsx)(u.Eye,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>o(e),title:`Re-edit / annotate`,className:`flex h-7 w-7 items-center justify-center rounded-md bg-white/90 text-slate-700 shadow transition hover:bg-white hover:text-blue-600`,children:(0,d.jsx)(u.Edit3,{className:`h-3.5 w-3.5`})}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),title:`Delete screenshot`,className:`flex h-7 w-7 items-center justify-center rounded-md bg-red-600 text-white shadow transition hover:bg-red-700`,children:(0,d.jsx)(u.Trash2,{className:`h-3.5 w-3.5`})})]})]},e.id))}),(0,d.jsx)(`div`,{className:`mt-3`,children:i.length<3?(0,d.jsxs)(`button`,{type:`button`,onClick:a,className:`flex w-full items-center justify-center gap-2 rounded-xl border-2 border-dashed border-slate-300 bg-slate-50/70 py-3 text-xs font-semibold text-slate-600 transition hover:border-blue-400 hover:bg-blue-50/50 hover:text-blue-600`,children:[(0,d.jsx)(u.Camera,{className:`h-4 w-4 text-slate-500`}),(0,d.jsx)(`span`,{children:i.length===0?`Capture Screen & Annotate`:`Capture Another Screenshot (${3-i.length} left)`})]}):(0,d.jsx)(`div`,{className:`rounded-lg bg-amber-50 p-2.5 text-center text-xs text-amber-700 border border-amber-200`,children:`Maximum 3 screenshots attached. Delete one to take a new one.`})})]}),O&&(0,d.jsxs)(`div`,{className:`rounded-xl border border-red-200 bg-red-50 px-3.5 py-2.5 text-xs text-red-700 flex items-start gap-2`,children:[(0,d.jsx)(u.AlertCircle,{className:`h-4 w-4 shrink-0 mt-0.5`}),(0,d.jsx)(`span`,{children:O})]}),(0,d.jsxs)(`div`,{className:`pt-4 border-t border-slate-100 flex items-center justify-end gap-3`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-xl border border-slate-200 bg-white px-4 py-2.5 text-sm font-semibold text-slate-600 transition hover:bg-slate-50`,children:`Cancel`}),(0,d.jsx)(`button`,{type:`submit`,disabled:w,style:{backgroundColor:m},className:`flex items-center gap-2 rounded-xl px-5 py-2.5 text-sm font-semibold text-white shadow-md transition hover:brightness-110 active:scale-95 disabled:opacity-60`,children:w?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(u.Loader2,{className:`h-4 w-4 animate-spin`}),(0,d.jsx)(`span`,{children:`Submitting...`})]}):(0,d.jsx)(`span`,{children:`Submit Bug Report`})})]})]})})]}),M&&(0,d.jsx)(`div`,{"data-bugdrop-widget":`true`,onClick:()=>N(null),className:`fixed inset-0 z-[100001] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm animate-fadeIn`,children:(0,d.jsxs)(`div`,{className:`relative max-h-[90vh] max-w-[90vw] overflow-hidden rounded-xl bg-slate-900 shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,d.jsx)(`img`,{src:M,alt:`Screenshot Preview`,className:`max-h-[85vh] w-auto rounded-xl object-contain`}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>N(null),className:`absolute top-3 right-3 flex h-8 w-8 items-center justify-center rounded-full bg-black/60 text-white shadow hover:bg-black/90`,children:(0,d.jsx)(u.X,{className:`h-4 w-4`})})]})})]})},m=null;function h(){return m||=import(`konva`).then(e=>{let t=e;return t.default??t}).catch(e=>{throw m=null,e}),m}var g=typeof window<`u`?c.useLayoutEffect:c.useEffect;function _(e){let t=e,n={stroke:e.stroke,strokeWidth:e.strokeWidth,rotation:t.rotation??0};switch(e.type){case`line`:return{...n,x:t.x??0,y:t.y??0,points:e.points,tension:.5,lineCap:`round`,lineJoin:`round`,globalCompositeOperation:e.tool===`eraser`?`destination-out`:`source-over`};case`rectangle`:return{...n,x:e.x,y:e.y,width:e.width,height:e.height};case`circle`:return{...n,x:e.x,y:e.y,radius:e.radius};case`arrow`:return{...n,x:t.x??0,y:t.y??0,points:e.points,fill:e.fill,pointerLength:14,pointerWidth:14};default:return n}}function v(e,t,n){let r={..._(t),...n};switch(t.type){case`line`:return new e.Line(r);case`rectangle`:return new e.Rect(r);case`circle`:return new e.Circle(r);case`arrow`:return new e.Arrow(r);default:return null}}var y=[`#ef4444`,`#f97316`,`#eab308`,`#10b981`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#000000`,`#ffffff`],b=[{label:`S`,value:3},{label:`M`,value:6},{label:`L`,value:10},{label:`XL`,value:16}],x=[{id:`select`,title:`Select & Move / Resize`,Icon:u.MousePointer},{id:`pencil`,title:`Pencil / Draw`,Icon:u.Pencil},{id:`eraser`,title:`Eraser (click or drag to erase)`,Icon:u.Eraser},{id:`rectangle`,title:`Rectangle (Resizable)`,Icon:u.Square},{id:`circle`,title:`Circle (Resizable)`,Icon:u.Circle},{id:`arrow`,title:`Arrow (Resizable)`,Icon:u.ArrowUpRight}],S=[`top-left`,`top-right`,`bottom-left`,`bottom-right`,`middle-left`,`middle-right`,`top-center`,`bottom-center`],C=({imageSrc:e,onSave:t,onCancel:n,primaryColor:r=`#2563eb`})=>{let i=(0,c.useRef)(null),a=(0,c.useRef)(null),o=(0,c.useRef)(null),s=(0,c.useRef)(null),l=(0,c.useRef)(null),f=(0,c.useRef)(null),p=(0,c.useRef)(null),m=(0,c.useRef)(null),[C,w]=(0,c.useState)(null),[T,E]=(0,c.useState)(null),[D,O]=(0,c.useState)(null),[k,A]=(0,c.useState)(1),[j,M]=(0,c.useState)({width:800,height:600}),[N,P]=(0,c.useState)(`pencil`),[F,I]=(0,c.useState)(`#ef4444`),[L,R]=(0,c.useState)(6),[z,B]=(0,c.useState)(null),[V,H]=(0,c.useState)([]),[U,W]=(0,c.useState)([[]]),[G,K]=(0,c.useState)(0);(0,c.useEffect)(()=>{let e=!1;return h().then(t=>{e||w(()=>t)}).catch(()=>{e||E(`The annotation editor could not load. Check your connection and try again.`)}),()=>{e=!0}},[]),(0,c.useEffect)(()=>{let t=new window.Image;return t.crossOrigin=`anonymous`,t.onload=()=>O(t),t.src=e,()=>{t.onload=null}},[e]);let q=(0,c.useCallback)(()=>{if(!i.current||!D)return;let e=Math.max(300,i.current.clientWidth-48),t=Math.max(300,i.current.clientHeight-120),n=Math.min(e/D.naturalWidth,t/D.naturalHeight,1);A(n),M({width:Math.round(D.naturalWidth*n),height:Math.round(D.naturalHeight*n)})},[D]);(0,c.useEffect)(()=>(q(),window.addEventListener(`resize`,q),()=>window.removeEventListener(`resize`,q)),[q]),(0,c.useEffect)(()=>{let e=a.current;if(!C||!D||!e)return;let t=C,n=new t.Stage({container:e,width:1,height:1}),r=new t.Layer({listening:!1});r.add(new t.Image({name:`bg-image`,image:D,width:D.naturalWidth,height:D.naturalHeight}));let i=new t.Layer,c=new t.Transformer({rotateEnabled:!0,enabledAnchors:S,borderStroke:`#3b82f6`,borderDash:[4,4],anchorFill:`#ffffff`,anchorStroke:`#3b82f6`,anchorSize:9,anchorCornerRadius:2,boundBoxFunc:(e,t)=>Math.abs(t.width)<10||Math.abs(t.height)<10?e:t});i.add(c),n.add(r),n.add(i),n.on(`pointerdown`,e=>m.current?.pointerDown(e)),n.on(`pointermove`,()=>m.current?.pointerMove()),n.on(`pointerup`,()=>m.current?.pointerUp());let u=()=>m.current?.pointerUp();return window.addEventListener(`pointerup`,u),window.addEventListener(`pointercancel`,u),o.current=n,s.current=i,l.current=c,()=>{window.removeEventListener(`pointerup`,u),window.removeEventListener(`pointercancel`,u),p.current=null,f.current=null,n.destroy(),o.current=null,s.current=null,l.current=null}},[C,D]),(0,c.useEffect)(()=>{let e=o.current;e&&(e.size(j),e.scale({x:k,y:k}))},[C,D,k,j]),(0,c.useEffect)(()=>{let e=C,t=s.current,n=l.current;if(!e||!t||!n)return;n.nodes([]),t.find(`.annotation`).forEach(e=>e.destroy());let r=N===`select`;V.forEach(n=>{let i=n.type===`line`&&n.tool===`eraser`,a=v(e,n,{id:n.id,name:`annotation`,draggable:r&&!i,hitStrokeWidth:Math.max(n.strokeWidth,12)});a&&(a.on(`dragend`,()=>m.current?.dragEnd(a,n.id)),a.on(`transformend`,()=>m.current?.transformEnd(a,n.id)),t.add(a))}),n.moveToTop()},[C,D,V,N]),(0,c.useEffect)(()=>{let e=s.current,t=l.current;if(!e||!t)return;let n=z?e.findOne(`#`+z):void 0;if(!n){t.nodes([]);return}let r=n.getClassName()===`Line`;t.resizeEnabled(!r),t.rotateEnabled(!r),t.nodes([n])},[C,D,V,N,z]);let J=e=>{H(e),W([...U.slice(0,G+1),e]),K(G+1)},Y=()=>{if(G<=0)return;let e=G-1;K(e),H(U[e]),B(null)},X=()=>{if(G>=U.length-1)return;let e=G+1;K(e),H(U[e]),B(null)},ee=()=>{V.length!==0&&(J([]),B(null))},Z=()=>{z&&(J(V.filter(e=>e.id!==z)),B(null))},Q=()=>{let e=o.current?.getPointerPosition();return e?{x:e.x/k,y:e.y/k}:null},te=e=>{let t=o.current,n=s.current,r=C;if(!t||!n||!r||p.current)return;let i=Q();if(!i)return;let{x:a,y:c}=i,l=e.target,u=l===t?``:l.id(),d=u?V.find(e=>e.id===u):void 0;if(N===`select`){d?(d.type!==`line`||d.tool!==`eraser`)&&B(d.id):(l===t||l.hasName(`bg-image`))&&B(null);return}if(N===`eraser`&&d){J(V.filter(e=>e.id!==d.id)),B(null);return}B(null);let m=`shape_${Date.now()}_${Math.random().toString(36).substring(2,7)}`,h;h=N===`pencil`||N===`eraser`?{id:m,type:`line`,tool:N,points:[a,c],stroke:N===`eraser`?`#ffffff`:F,strokeWidth:N===`eraser`?L*2.5:L}:N===`rectangle`?{id:m,type:`rectangle`,x:a,y:c,width:0,height:0,stroke:F,strokeWidth:L}:N===`circle`?{id:m,type:`circle`,x:a,y:c,radius:0,stroke:F,strokeWidth:L}:{id:m,type:`arrow`,points:[a,c,a,c],stroke:F,fill:F,strokeWidth:L};let g=v(r,h,{listening:!1,dash:h.type===`line`?void 0:[6,4]});g&&(n.add(g),f.current=g,p.current={start:{x:a,y:c},data:h})},ne=()=>{let e=p.current;if(!e)return;let t=Q();if(!t)return;let{x:n,y:r}=t,{start:i,data:a}=e,o=a;a.type===`line`?o={...a,points:[...a.points,n,r]}:a.type===`rectangle`?o={...a,x:Math.min(i.x,n),y:Math.min(i.y,r),width:Math.abs(n-i.x),height:Math.abs(r-i.y)}:a.type===`circle`?o={...a,radius:Math.hypot(n-i.x,r-i.y)}:a.type===`arrow`&&(o={...a,points:[i.x,i.y,n,r]}),e.data=o,f.current?.setAttrs(_(o))},re=()=>{let e=p.current;if(!e)return;p.current=null,f.current?.destroy(),f.current=null;let t=e.data,n=!1;if(t.type===`line`)n=t.points.length>=2;else if(t.type===`rectangle`)n=t.width>6&&t.height>6;else if(t.type===`circle`)n=t.radius>5;else if(t.type===`arrow`){let[e,r,i,a]=t.points;n=Math.hypot(i-e,a-r)>10}n&&(J([...V,t]),(t.type===`rectangle`||t.type===`circle`||t.type===`arrow`)&&(B(t.id),P(`select`)))},ie=(e,t)=>{V.some(e=>e.id===t)&&J(V.map(n=>n.id===t?{...n,x:e.x(),y:e.y()}:n))},ae=(e,t)=>{let n=V.find(e=>e.id===t);if(!n)return;let r=e.scaleX(),i=e.scaleY();e.scaleX(1),e.scaleY(1);let a=null;if(n.type===`rectangle`)a={...n,x:e.x(),y:e.y(),width:Math.max(10,e.width()*r),height:Math.max(10,e.height()*i),rotation:e.rotation()};else if(n.type===`circle`)a={...n,x:e.x(),y:e.y(),radius:Math.max(6,n.radius*r),rotation:e.rotation()};else if(n.type===`arrow`){let[t,o,s,c]=n.points;a={...n,x:e.x(),y:e.y(),points:[t,o,t+(s-t)*r,o+(c-o)*i],rotation:e.rotation()}}if(!a)return;let o=a;J(V.map(e=>e.id===t?o:e))};g(()=>{m.current={pointerDown:te,pointerMove:ne,pointerUp:re,dragEnd:ie,transformEnd:ae,undo:Y,redo:X,deleteSelected:Z,hasSelection:()=>z!==null,clearSelection:()=>B(null)}}),(0,c.useEffect)(()=>{let e=e=>{let t=m.current;if(!t||e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)return;let n=e.ctrlKey||e.metaKey,r=e.key.toLowerCase();n&&r===`z`?(e.shiftKey?t.redo():t.undo(),e.preventDefault()):n&&r===`y`?(t.redo(),e.preventDefault()):(e.key===`Delete`||e.key===`Backspace`)&&t.hasSelection()?(t.deleteSelected(),e.preventDefault()):e.key===`Escape`&&(t.clearSelection(),e.preventDefault())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let oe=()=>{let e=o.current;e&&(l.current?.nodes([]),B(null),t(e.toDataURL({pixelRatio:1/k,mimeType:`image/png`})))},se=e=>{P(e),e!==`select`&&B(null)},$=!!(D&&C);return(0,d.jsxs)(`div`,{ref:i,className:`fixed inset-0 z-[100000] flex flex-col bg-slate-950/90 backdrop-blur-md select-none text-white overflow-hidden animate-fadeIn`,style:{touchAction:`none`},children:[(0,d.jsxs)(`div`,{className:`flex h-16 shrink-0 items-center justify-between border-b border-slate-800 bg-slate-900/90 px-4 sm:px-6`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg text-white font-bold text-sm shadow`,style:{backgroundColor:r},children:`BD`}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h1`,{className:`text-sm sm:text-base font-semibold leading-tight text-slate-100`,children:`Screenshot Editor`}),(0,d.jsx)(`p`,{className:`text-xs text-slate-400 hidden sm:block`,children:`Highlight issues with pencil, arrows, circles, and boxes`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[(0,d.jsx)(`button`,{type:`button`,onClick:Y,disabled:G<=0,title:`Undo (Ctrl+Z)`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-slate-700 bg-slate-800 text-slate-200 transition hover:bg-slate-700 hover:text-white disabled:opacity-40 disabled:pointer-events-none`,children:(0,d.jsx)(u.Undo2,{className:`h-4 w-4`})}),(0,d.jsx)(`button`,{type:`button`,onClick:X,disabled:G>=U.length-1,title:`Redo (Ctrl+Y)`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-slate-700 bg-slate-800 text-slate-200 transition hover:bg-slate-700 hover:text-white disabled:opacity-40 disabled:pointer-events-none`,children:(0,d.jsx)(u.Redo2,{className:`h-4 w-4`})}),(0,d.jsxs)(`button`,{type:`button`,onClick:ee,disabled:V.length===0,title:`Clear all annotations`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-slate-700 bg-slate-800 px-2.5 text-xs font-medium text-slate-300 transition hover:bg-slate-700 hover:text-white disabled:opacity-40 disabled:pointer-events-none`,children:[(0,d.jsx)(u.Trash2,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{className:`hidden md:inline`,children:`Clear All`})]}),(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700 mx-1`}),(0,d.jsxs)(`button`,{type:`button`,onClick:n,className:`flex h-9 items-center gap-1.5 rounded-lg border border-slate-700 bg-slate-800 px-3 text-xs sm:text-sm font-medium text-slate-200 transition hover:bg-slate-700 hover:text-white`,children:[(0,d.jsx)(u.X,{className:`h-4 w-4`}),(0,d.jsx)(`span`,{children:`Cancel`})]}),(0,d.jsxs)(`button`,{type:`button`,onClick:oe,disabled:!$,style:{backgroundColor:r},className:`flex h-9 items-center gap-1.5 rounded-lg px-4 text-xs sm:text-sm font-semibold text-white shadow-md transition hover:brightness-110 active:scale-95 disabled:opacity-50 disabled:pointer-events-none`,children:[(0,d.jsx)(u.Check,{className:`h-4 w-4`}),(0,d.jsx)(`span`,{children:`Add to Report`})]})]})]}),(0,d.jsxs)(`div`,{className:`absolute top-20 left-1/2 -translate-x-1/2 z-20 flex flex-wrap items-center justify-center gap-2 rounded-2xl border border-slate-700/80 bg-slate-900/95 p-2 shadow-2xl backdrop-blur-md`,children:[(0,d.jsx)(`div`,{className:`flex items-center gap-1`,children:x.map(({id:e,title:t,Icon:n})=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>se(e),title:t,"aria-pressed":N===e,className:`flex h-9 w-9 items-center justify-center rounded-xl transition ${N===e?`bg-blue-600 text-white shadow-inner`:`text-slate-300 hover:bg-slate-800 hover:text-white`}`,children:(0,d.jsx)(n,{className:`h-4 w-4`})},e))}),(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1`,children:[y.map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>I(e),title:e,"aria-label":`Color ${e}`,style:{backgroundColor:e},className:`h-5 w-5 rounded-full border border-slate-700 transition-transform ${F===e?`scale-125 ring-2 ring-white ring-offset-1 ring-offset-slate-900`:`hover:scale-110`}`},e)),(0,d.jsxs)(`label`,{title:`Custom Color`,className:`relative flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-slate-600 bg-slate-800 text-slate-300 hover:text-white transition`,children:[(0,d.jsx)(u.Palette,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`input`,{type:`color`,value:F,onChange:e=>I(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer`})]})]}),(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700`}),(0,d.jsx)(`div`,{className:`flex items-center gap-1`,children:b.map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>R(e.value),className:`flex h-7 w-7 items-center justify-center rounded-lg text-xs font-semibold transition ${L===e.value?`bg-slate-700 text-white ring-1 ring-slate-400`:`text-slate-400 hover:bg-slate-800 hover:text-white`}`,children:e.label},e.value))}),z&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`h-5 w-px bg-slate-700`}),(0,d.jsxs)(`button`,{type:`button`,onClick:Z,title:`Delete Selected Shape (Del / Backspace)`,className:`flex h-8 items-center gap-1.5 rounded-xl bg-red-600/90 px-3 text-xs font-semibold text-white shadow hover:bg-red-600`,children:[(0,d.jsx)(u.Trash2,{className:`h-3.5 w-3.5`}),(0,d.jsx)(`span`,{children:`Delete`})]})]})]}),(0,d.jsx)(`div`,{className:`relative flex flex-1 items-center justify-center p-4 overflow-hidden`,children:T?(0,d.jsx)(`p`,{className:`text-sm text-red-300`,children:T}):$?(0,d.jsx)(`div`,{className:`relative shadow-2xl rounded-md overflow-hidden border border-slate-700 bg-slate-900`,style:{width:j.width,height:j.height,cursor:N===`select`?`default`:N===`eraser`?`cell`:`crosshair`},children:(0,d.jsx)(`div`,{ref:a})}):(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-slate-400`,children:[(0,d.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-blue-500 border-t-transparent`}),(0,d.jsx)(`p`,{className:`text-sm`,children:`Loading screenshot...`})]})}),(0,d.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between border-t border-slate-800 bg-slate-900/80 px-4 text-xs text-slate-400`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,d.jsxs)(`span`,{children:[`Active tool: `,(0,d.jsx)(`strong`,{className:`text-slate-200 capitalize`,children:N})]}),(0,d.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Use `,(0,d.jsx)(`kbd`,{className:`rounded bg-slate-800 px-1 py-0.5 text-slate-300`,children:`Ctrl+Z`}),` to undo,`,` `,(0,d.jsx)(`kbd`,{className:`rounded bg-slate-800 px-1 py-0.5 text-slate-300`,children:`Del`}),` to remove selected shape`]})]}),(0,d.jsx)(`div`,{children:D&&(0,d.jsxs)(`span`,{children:[`Original Resolution: `,D.naturalWidth,` x `,D.naturalHeight,`px`]})})]})]})},w=({projectUrl:e,onSubmit:t,uiSettings:n={},onSuccess:r,onError:i,isOpen:a,onToggle:o,className:s=``})=>{let{position:f=`bottom-right`,primaryColor:m=`#2563eb`,buttonSize:h=`md`,buttonText:g,buttonIcon:_,zIndex:v=99990}=n,[y,b]=(0,c.useState)(!1),x=a===void 0?y:a,S=e=>{a===void 0&&b(e),o?.(e)},[w,T]=(0,c.useState)([]),[E,D]=(0,c.useState)(!1),[O,k]=(0,c.useState)(!1),[A,j]=(0,c.useState)(null),M=e=>{switch(e){case`bottom-left`:return`bottom-6 left-6`;case`top-left`:return`top-6 left-6`;case`top-right`:return`top-6 right-6`;case`left`:return`top-1/2 -translate-y-1/2 left-4`;case`right`:return`top-1/2 -translate-y-1/2 right-4`;default:return`bottom-6 right-6`}},N=(e=>{switch(e){case`sm`:return{button:`h-10 px-3.5 gap-2 text-xs font-semibold rounded-full shadow-md`,icon:`h-4 w-4`};case`lg`:return{button:`h-14 px-5 gap-3 text-base font-bold rounded-full shadow-xl`,icon:`h-6 w-6`};default:return{button:`h-12 px-4 gap-2.5 text-sm font-semibold rounded-full shadow-lg`,icon:`h-5 w-5`}}})(h);return E?null:(0,d.jsxs)(d.Fragment,{children:[!O&&(0,d.jsx)(`div`,{"data-bugdrop-widget":`true`,className:`fixed ${M(f)} ${s}`,style:{zIndex:v},children:(0,d.jsxs)(`button`,{type:`button`,onClick:()=>S(!x),style:{backgroundColor:m},className:`group flex items-center justify-center text-white transition-all duration-200 hover:brightness-110 active:scale-95 ${N.button}`,"aria-label":x?`Close bug report form`:`Open bug report form`,title:x?`Close Bug Report`:`Report a Bug`,children:[x?(0,d.jsx)(u.X,{className:N.icon}):_||(0,d.jsx)(u.Bug,{className:N.icon}),g&&(0,d.jsx)(`span`,{children:g}),w.length>0&&!x&&(0,d.jsx)(`span`,{className:`flex h-5 w-5 items-center justify-center rounded-full bg-white text-[11px] font-bold text-slate-900 shadow`,children:w.length})]})}),!O&&(0,d.jsx)(p,{projectUrl:e,isOpen:x,onClose:()=>S(!1),uiSettings:n,screenshots:w,onTriggerScreenshot:async()=>{D(!0);try{await new Promise(e=>setTimeout(e,180));let e=(await(0,l.default)(document.documentElement,{useCORS:!0,allowTaint:!0,logging:!1,scrollX:0,scrollY:-window.scrollY,windowWidth:document.documentElement.offsetWidth,windowHeight:document.documentElement.offsetHeight,ignoreElements:e=>e.getAttribute(`data-bugdrop-widget`)===`true`||e.classList.contains(`bugdrop-ignore`)})).toDataURL(`image/png`);j({dataUrl:e,isNew:!0}),k(!0)}catch(e){console.error(`Error taking screenshot:`,e),alert(`Could not capture screenshot. Please try again.`)}finally{D(!1)}},onEditScreenshot:e=>{j({id:e.id,dataUrl:e.dataUrl,isNew:!1}),k(!0)},onDeleteScreenshot:e=>{T(t=>t.filter(t=>t.id!==e))},onSubmitReport:async e=>{try{await t(e),r?.(e)}catch(e){let t=e instanceof Error?e:Error(`Failed to submit bug report`);throw i?.(t),t}}}),O&&A&&(0,d.jsx)(C,{imageSrc:A.dataUrl,onSave:e=>{if(A?.isNew){if(w.length<3){let t={id:`ss_${Date.now()}_${Math.random().toString(36).substring(2,6)}`,dataUrl:e,createdAt:Date.now()};T(e=>[...e,t])}}else A?.id&&T(t=>t.map(t=>t.id===A.id?{...t,dataUrl:e}:t));k(!1),j(null),S(!0)},onCancel:()=>{k(!1),j(null),S(!0)},primaryColor:m})]})};exports.Widget=w;
|
|
2
2
|
//# sourceMappingURL=bug-widget-library.cjs.map
|