gotcha-feedback 1.1.5 → 1.1.7
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/README.md +144 -3
- package/dist/index.d.mts +68 -7
- package/dist/index.d.ts +68 -7
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/dist/screenshot-CTLYS27H.mjs +2 -0
- package/dist/screenshot-CTLYS27H.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var Je="https://gotcha.cx/api/v1";var Ae={ANONYMOUS_ID:"gotcha_anonymous_id",OFFLINE_QUEUE:"gotcha_offline_queue"},Y={POSITION:"top-right",SIZE:"md",THEME:"light",SHOW_ON_HOVER:true,TOUCH_BEHAVIOR:"always-visible",SUBMIT_TEXT:"Submit",THANK_YOU_MESSAGE:"Gotcha!"},ye={MAX_RETRIES:2,BASE_DELAY_MS:500,MAX_DELAY_MS:5e3};function qe(){if(typeof window>"u")return `anon_${crypto.randomUUID()}`;try{let e=localStorage.getItem(Ae.ANONYMOUS_ID);if(e)return e;let r=`anon_${crypto.randomUUID()}`;return localStorage.setItem(Ae.ANONYMOUS_ID,r),r}catch{return `anon_${crypto.randomUUID()}`}}var te={maxRetries:ye.MAX_RETRIES,baseDelayMs:ye.BASE_DELAY_MS,maxDelayMs:ye.MAX_DELAY_MS};async function ce(e,r,o=te,t=false){let s=null;for(let h=0;h<=o.maxRetries;h++){try{t&&h>0&&console.log(`[Gotcha] Retry attempt ${h}/${o.maxRetries}`);let n=await fetch(e,r);if(n.status>=400&&n.status<500&&n.status!==429||n.ok)return n;s=new Error(`HTTP ${n.status}`);}catch(n){s=n,t&&console.log(`[Gotcha] Network error: ${s.message}`);}if(h<o.maxRetries){let n=Math.min(o.baseDelayMs*Math.pow(2,h),o.maxDelayMs);await new Promise(g=>setTimeout(g,n));}}throw s}function Ze(e){let{apiKey:r,baseUrl:o=Je,debug:t=false}=e,s={"Content-Type":"application/json",Authorization:`Bearer ${r}`};async function h(n,g,d){let a=`${o}${g}`,u=crypto.randomUUID();t&&console.log(`[Gotcha] ${n} ${g}`,d);let b=await ce(a,{method:n,headers:{...s,"Idempotency-Key":u},body:d?JSON.stringify(d):void 0},te,t),l;try{l=await b.json();}catch{throw {code:"PARSE_ERROR",message:"Invalid response from server",status:b.status}}if(!b.ok){let i=l.error;throw t&&console.error(`[Gotcha] Error: ${i.code} - ${i.message}`),i}return t&&console.log("[Gotcha] Response:",l),l}return {async submitResponse(n){let g=n.user||{};g.id||(g.id=qe());let d={...n,user:g,context:{url:typeof window<"u"?window.location.origin+window.location.pathname:void 0,userAgent:typeof navigator<"u"?navigator.userAgent:void 0},...n.isBug?{isBug:true}:{}};return h("POST","/responses",d)},async checkExistingResponse(n,g){let d=`${o}/responses/check?elementId=${encodeURIComponent(n)}&userId=${encodeURIComponent(g)}`;t&&console.log("[Gotcha] GET /responses/check");let a=await ce(d,{method:"GET",headers:s},te,t),u=await a.json();if(!a.ok){let b=u.error;throw t&&console.error(`[Gotcha] Error: ${b.code} - ${b.message}`),b}return u.exists?(t&&console.log("[Gotcha] Found existing response:",u.response),u.response):null},async updateResponse(n,g,d){let a=`${o}/responses/${n}${d?`?userId=${encodeURIComponent(d)}`:""}`;t&&console.log(`[Gotcha] PATCH /responses/${n}`,g);let u=await ce(a,{method:"PATCH",headers:s,body:JSON.stringify(g)},te,t),b=await u.json();if(!u.ok){let l=b.error;throw t&&console.error(`[Gotcha] Error: ${l.code} - ${l.message}`),l}return t&&console.log("[Gotcha] Response updated:",b),b},async getScore(n){let g=`${o}/scores/${encodeURIComponent(n)}`;t&&console.log(`[Gotcha] GET /scores/${n}`);let d=await ce(g,{method:"GET",headers:s},te,t),a=await d.json();if(!d.ok){let u=a.error;throw t&&console.error(`[Gotcha] Error: ${u.code} - ${u.message}`),u}return t&&console.log("[Gotcha] Score:",a),a},async flagAsBug(n){let g=`${o}/responses/${encodeURIComponent(n)}/bug`;t&&console.log(`[Gotcha] POST /responses/${n}/bug`);let d=await ce(g,{method:"POST",headers:s},te,t),a=await d.json();if(!d.ok){let u=a.error;throw t&&console.error(`[Gotcha] Error: ${u.code} - ${u.message}`),u}return t&&console.log("[Gotcha] Bug flagged:",a),a},getBaseUrl(){return o}}}var Ro=new Set(["__proto__","constructor","prototype"]);function Q(e,r){let o={...e};for(let t of Object.keys(r)){if(Ro.has(t))continue;let s=r[t];s!=null&&typeof s=="object"&&!Array.isArray(s)?o[t]=Q(e[t]??{},s):s!==void 0&&(o[t]=s);}return o}var eo=["#ef4444","#f05540","#f1663c","#f27738","#f38834","#f59e0b","#d4a30e","#b3a812","#79b841","#45c870","#10b981"],Ge={colors:{primary:"#1e293b",primaryHover:"#334155",primaryText:"#ffffff",background:"#ffffff",backgroundGradient:"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)",surface:"#fafbfc",surfaceHover:"#ffffff",text:"#111827",textSecondary:"#374151",textDisabled:"#94a3b8",border:"#e2e8f0",borderFocus:"#1e293b",success:"#059669",successSurface:"rgba(5,150,105,0.08)",error:"#dc2626",errorSurface:"#fef2f2",errorBorder:"rgba(220,38,38,0.1)",warning:"#d97706",warningActive:"#b45309",warningSurface:"rgba(251,191,36,0.08)",warningBorder:"rgba(217,119,6,0.25)",starFilled:"#f59e0b",starEmpty:"#e2e8f0",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.06)",voteUpBorder:"rgba(16,185,129,0.25)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.06)",voteDownBorder:"rgba(239,68,68,0.25)",npsColors:eo,buttonBackground:"#1e293b",buttonBackgroundHover:"#334155",buttonBackgroundDisabled:"#e2e8f0",buttonColor:"#ffffff",buttonColorDisabled:"#94a3b8",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.4)",closeButton:"#9ca3af",closeButtonHover:"#6b7280",closeButtonBg:"rgba(0,0,0,0.04)",glassBackground:"linear-gradient(160deg, rgba(255,255,255,0.7) 0%, rgba(200,210,230,0.4) 40%, rgba(180,192,220,0.5) 100%)",glassBorder:"none",glassColor:"rgba(0,0,0,0.75)",glassShadow:"0 3px 12px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.2)",glassHoverShadow:"0 6px 20px rgba(0,0,0,0.18), 0 0 1px rgba(0,0,0,0.25)",inputBackground:"#fafbfc",inputBackgroundFocus:"#ffffff",inputBorder:"#e2e8f0",inputBorderFocus:"#1e293b",inputFocusRing:"rgba(30,41,59,0.15)",pollBorder:"#e2e8f0",pollSelectedBorder:"rgba(30,41,59,0.25)",pollBackground:"#fafbfc",pollSelectedBackground:"rgba(30,41,59,0.05)",pollColor:"#374151",pollSelectedColor:"#1e293b",pollCheckBorder:"#cbd5e1",pollCheckSelectedBorder:"#1e293b",pollCheckSelectedBg:"#1e293b"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.04)",md:"0 4px 12px rgba(0,0,0,0.06)",lg:"0 12px 32px rgba(0,0,0,0.06)",modal:"0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.06), 0 24px 48px rgba(0,0,0,0.04)",button:"0 2px 8px rgba(0,0,0,0.06)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}},Me={colors:{primary:"#e2e8f0",primaryHover:"#cbd5e1",primaryText:"#1e293b",background:"#1a1f2e",backgroundGradient:"linear-gradient(180deg, #1a1f2e 0%, #151925 100%)",surface:"rgba(55,65,81,0.5)",surfaceHover:"rgba(55,65,81,0.7)",text:"#f9fafb",textSecondary:"#d1d5db",textDisabled:"#6b7280",border:"rgba(255,255,255,0.08)",borderFocus:"rgba(255,255,255,0.2)",success:"#10b981",successSurface:"rgba(16,185,129,0.1)",error:"#fecaca",errorSurface:"rgba(127,29,29,0.3)",errorBorder:"rgba(254,202,202,0.1)",warning:"#fbbf24",warningActive:"#fbbf24",warningSurface:"rgba(245,158,11,0.08)",warningBorder:"rgba(245,158,11,0.3)",starFilled:"#f59e0b",starEmpty:"rgba(255,255,255,0.12)",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.08)",voteUpBorder:"rgba(16,185,129,0.3)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.08)",voteDownBorder:"rgba(239,68,68,0.3)",npsColors:eo,buttonBackground:"#e2e8f0",buttonBackgroundHover:"#cbd5e1",buttonBackgroundDisabled:"#374151",buttonColor:"#1e293b",buttonColorDisabled:"#6b7280",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.5)",closeButton:"#6b7280",closeButtonHover:"#9ca3af",closeButtonBg:"rgba(255,255,255,0.06)",glassBackground:"linear-gradient(180deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 60%, rgba(0,0,0,0.05) 100%)",glassBorder:"1px solid rgba(255,255,255,0.15)",glassColor:"rgba(255,255,255,0.88)",glassShadow:"0 4px 14px rgba(0,0,0,0.45), 0 1px 3px rgba(0,0,0,0.35)",glassHoverShadow:"0 8px 24px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.4)",inputBackground:"rgba(55,65,81,0.5)",inputBackgroundFocus:"rgba(55,65,81,0.7)",inputBorder:"rgba(255,255,255,0.08)",inputBorderFocus:"rgba(255,255,255,0.2)",inputFocusRing:"rgba(255,255,255,0.06)",pollBorder:"rgba(255,255,255,0.08)",pollSelectedBorder:"rgba(226,232,240,0.25)",pollBackground:"rgba(55,65,81,0.5)",pollSelectedBackground:"rgba(226,232,240,0.08)",pollColor:"#d1d5db",pollSelectedColor:"#e2e8f0",pollCheckBorder:"rgba(255,255,255,0.2)",pollCheckSelectedBorder:"#e2e8f0",pollCheckSelectedBg:"#e2e8f0"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.2)",md:"0 4px 12px rgba(0,0,0,0.3)",lg:"0 12px 32px rgba(0,0,0,0.2)",modal:"0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.2), 0 24px 48px rgba(0,0,0,0.15)",button:"0 2px 8px rgba(0,0,0,0.15)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}};function Bo(e,r){return Q(e==="dark"?Me:Ge,r)}function K(e,r,o){let s=(e==="auto"||e==="custom"?r:e)==="dark"?Q({},Me):Q({},Ge);return o&&(s=Q(s,o)),s}var oo="gotcha-styles",to="gotcha-dm-sans",ro="gotcha-carter-one",Ao=`
|
|
1
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');var At=Object.defineProperty;var Mt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Gt=(e,t)=>{for(var o in t)At(e,o,{get:t[o],enumerable:true});};var ot={};Gt(ot,{captureScreenshot:()=>sr});async function sr(){try{let e=(await new Function('return import("html2canvas")')()).default,t=await e(document.body,{logging:!1,useCORS:!0,scale:1,width:window.innerWidth,height:window.innerHeight,windowWidth:window.innerWidth,windowHeight:window.innerHeight});return et(t)}catch{}try{if(!navigator.mediaDevices?.getDisplayMedia||typeof ImageCapture>"u")return null;let t=(await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"}})).getVideoTracks()[0],r=await new ImageCapture(t).grabFrame();t.stop();let n=document.createElement("canvas");n.width=r.width,n.height=r.height;let p=n.getContext("2d");return p?(p.drawImage(r,0,0),et(n)):null}catch{return null}}function et(e){let t=e.toDataURL("image/jpeg",.7);if(t.length>2097152&&(t=e.toDataURL("image/jpeg",.4)),t.length>2097152){let r=document.createElement("canvas");r.width=e.width*.5,r.height=e.height*.5;let n=r.getContext("2d");n&&(n.drawImage(e,0,0,r.width,r.height),t=r.toDataURL("image/jpeg",.5));}return t}var tt=Mt(()=>{});var Co="https://gotcha.cx/api/v1";var W={ANONYMOUS_ID:"gotcha_anonymous_id",OFFLINE_QUEUE:"gotcha_offline_queue",HIDDEN_UNTIL:"gotcha_hidden",VISIT_COUNT:"gotcha_visits"},q={POSITION:"top-right",SIZE:"md",THEME:"light",SHOW_ON_HOVER:true,TOUCH_BEHAVIOR:"always-visible",SUBMIT_TEXT:"Submit",THANK_YOU_MESSAGE:"Gotcha!"},Pe={MAX_RETRIES:2,BASE_DELAY_MS:500,MAX_DELAY_MS:5e3};function J(e){if(typeof window>"u")return null;try{return localStorage.getItem(e)}catch{return null}}function Z(e,t){if(!(typeof window>"u"))try{localStorage.setItem(e,t);}catch{}}function ee(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return (e==="x"?t:t&3|8).toString(16)})}function Ue(){let e=J(W.ANONYMOUS_ID);if(e)return e;let t=`anon_${ee()}`;return Z(W.ANONYMOUS_ID,t),t}var $e=[],Oe=false;function Eo(e,t){let o={message:e.slice(0,200),source:t?.slice(0,200),timestamp:Date.now()};$e.push(o),$e.length>10&&$e.shift();}function Ro(e){Eo(e.message,e.filename);}function Bo(e){let t=e.reason instanceof Error?e.reason.message:String(e.reason);Eo(t);}function Io(){typeof window>"u"||Oe||(window.addEventListener("error",Ro),window.addEventListener("unhandledrejection",Bo),Oe=true);}function Ao(){typeof window>"u"||!Oe||(window.removeEventListener("error",Ro),window.removeEventListener("unhandledrejection",Bo),Oe=false);}function Mo(){return [...$e].reverse()}function Go(){return typeof window>"u"?{}:{url:window.location.origin+window.location.pathname,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenResolution:{width:screen.width,height:screen.height},recentErrors:Mo()}}var Dt=50,Ft=10080*60*1e3;function ke(){let e=J(W.OFFLINE_QUEUE);if(!e)return [];try{let t=JSON.parse(e),o=Date.now();return t.filter(r=>o-r.queuedAt<Ft)}catch{return []}}function Je(e){Z(W.OFFLINE_QUEUE,JSON.stringify(e));}function Ze(e,t="create"){let o=ke();o.length>=Dt||(o.push({id:ee(),payload:e,type:t,queuedAt:Date.now(),retries:0}),Je(o));}function Do(e){let t=ke().filter(o=>o.id!==e);Je(t);}function Fo(){return ke()}function zo(){return ke().length}function Lo(e){let t=ke().map(o=>o.id===e?{...o,retries:o.retries+1}:o);Je(t.filter(o=>o.retries<=5));}var de={maxRetries:Pe.MAX_RETRIES,baseDelayMs:Pe.BASE_DELAY_MS,maxDelayMs:Pe.MAX_DELAY_MS};async function Te(e,t,o=de,r=false){let n=null;for(let p=0;p<=o.maxRetries;p++){try{r&&p>0&&console.log(`[Gotcha] Retry attempt ${p}/${o.maxRetries}`);let l=await fetch(e,t);if(l.status>=400&&l.status<500&&l.status!==429||l.ok)return l;n=new Error(`HTTP ${l.status}`);}catch(l){n=l,r&&console.log(`[Gotcha] Network error: ${n.message}`);}if(p<o.maxRetries){let l=Math.min(o.baseDelayMs*Math.pow(2,p),o.maxDelayMs);await new Promise(u=>setTimeout(u,l));}}throw n}function Po(e){let{apiKey:t,baseUrl:o=Co,debug:r=false}=e,n=false,p={"Content-Type":"application/json",Authorization:`Bearer ${t}`};async function l(u,g,a){let s=`${o}${g}`,h=ee();r&&console.log(`[Gotcha] ${u} ${g}`,a);let d=await Te(s,{method:u,headers:{...p,"Idempotency-Key":h},body:a?JSON.stringify(a):void 0},de,r),i;try{i=await d.json();}catch{throw {code:"PARSE_ERROR",message:"Invalid response from server",status:d.status}}if(!d.ok){let c=i.error;throw r&&console.error(`[Gotcha] Error: ${c.code} - ${c.message}`),c}return r&&console.log("[Gotcha] Response:",i),i}return {async submitResponse(u){let g=u.user||{};g.id||(g.id=Ue());let a={...u,user:g,context:Go(),...u.isBug?{isBug:true}:{}};if(typeof navigator<"u"&&!navigator.onLine)return Ze(a,"create"),{id:ee(),status:"queued",createdAt:new Date().toISOString()};try{return await l("POST","/responses",a)}catch(s){if(s instanceof TypeError&&typeof navigator<"u"&&!navigator.onLine)return Ze(a,"create"),{id:ee(),status:"queued",createdAt:new Date().toISOString()};throw s}},async checkExistingResponse(u,g){let a=`${o}/responses/check?elementId=${encodeURIComponent(u)}&userId=${encodeURIComponent(g)}`;r&&console.log("[Gotcha] GET /responses/check");let s=await Te(a,{method:"GET",headers:p},de,r),h=await s.json();if(!s.ok){let d=h.error;throw r&&console.error(`[Gotcha] Error: ${d.code} - ${d.message}`),d}return h.exists?(r&&console.log("[Gotcha] Found existing response:",h.response),h.response):null},async updateResponse(u,g,a){let s=`${o}/responses/${u}${a?`?userId=${encodeURIComponent(a)}`:""}`;r&&console.log(`[Gotcha] PATCH /responses/${u}`,g);let h=await Te(s,{method:"PATCH",headers:p,body:JSON.stringify(g)},de,r),d=await h.json();if(!h.ok){let i=d.error;throw r&&console.error(`[Gotcha] Error: ${i.code} - ${i.message}`),i}return r&&console.log("[Gotcha] Response updated:",d),d},async getScore(u){let g=`${o}/scores/${encodeURIComponent(u)}`;r&&console.log(`[Gotcha] GET /scores/${u}`);let a=await Te(g,{method:"GET",headers:p},de,r),s=await a.json();if(!a.ok){let h=s.error;throw r&&console.error(`[Gotcha] Error: ${h.code} - ${h.message}`),h}return r&&console.log("[Gotcha] Score:",s),s},async flagAsBug(u){let g=`${o}/responses/${encodeURIComponent(u)}/bug`;r&&console.log(`[Gotcha] POST /responses/${u}/bug`);let a=await Te(g,{method:"POST",headers:p},de,r),s=await a.json();if(!a.ok){let h=s.error;throw r&&console.error(`[Gotcha] Error: ${h.code} - ${h.message}`),h}return r&&console.log("[Gotcha] Bug flagged:",s),s},async flushQueue(){if(!n){n=true;try{let u=Fo();for(let g of u)try{if(g.type==="update"&&g.payload.responseId){let{responseId:a,...s}=g.payload;await l("PATCH",`/responses/${a}`,s);}else await l("POST","/responses",g.payload);Do(g.id);}catch{Lo(g.id);}}finally{n=false;}}},getQueueLength:zo,getBaseUrl(){return o}}}var zt=new Set(["__proto__","constructor","prototype"]);function ie(e,t){let o={...e};for(let r of Object.keys(t)){if(zt.has(r))continue;let n=t[r];n!=null&&typeof n=="object"&&!Array.isArray(n)?o[r]=ie(e[r]??{},n):n!==void 0&&(o[r]=n);}return o}var Uo=["#ef4444","#f05540","#f1663c","#f27738","#f38834","#f59e0b","#d4a30e","#b3a812","#79b841","#45c870","#10b981"],eo={colors:{primary:"#1e293b",primaryHover:"#334155",primaryText:"#ffffff",background:"#ffffff",backgroundGradient:"linear-gradient(180deg, #ffffff 0%, #f8fafc 100%)",surface:"#fafbfc",surfaceHover:"#ffffff",text:"#111827",textSecondary:"#374151",textDisabled:"#94a3b8",border:"#e2e8f0",borderFocus:"#1e293b",success:"#059669",successSurface:"rgba(5,150,105,0.08)",error:"#dc2626",errorSurface:"#fef2f2",errorBorder:"rgba(220,38,38,0.1)",warning:"#d97706",warningActive:"#b45309",warningSurface:"rgba(251,191,36,0.08)",warningBorder:"rgba(217,119,6,0.25)",starFilled:"#f59e0b",starEmpty:"#e2e8f0",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.06)",voteUpBorder:"rgba(16,185,129,0.25)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.06)",voteDownBorder:"rgba(239,68,68,0.25)",npsColors:Uo,buttonBackground:"#1e293b",buttonBackgroundHover:"#334155",buttonBackgroundDisabled:"#e2e8f0",buttonColor:"#ffffff",buttonColorDisabled:"#94a3b8",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.4)",closeButton:"#9ca3af",closeButtonHover:"#6b7280",closeButtonBg:"rgba(0,0,0,0.04)",glassBackground:"linear-gradient(160deg, rgba(255,255,255,0.7) 0%, rgba(200,210,230,0.4) 40%, rgba(180,192,220,0.5) 100%)",glassBorder:"none",glassColor:"rgba(0,0,0,0.75)",glassShadow:"0 3px 12px rgba(0,0,0,0.12), 0 0 1px rgba(0,0,0,0.2)",glassHoverShadow:"0 6px 20px rgba(0,0,0,0.18), 0 0 1px rgba(0,0,0,0.25)",inputBackground:"#fafbfc",inputBackgroundFocus:"#ffffff",inputBorder:"#e2e8f0",inputBorderFocus:"#1e293b",inputFocusRing:"rgba(30,41,59,0.15)",pollBorder:"#e2e8f0",pollSelectedBorder:"rgba(30,41,59,0.25)",pollBackground:"#fafbfc",pollSelectedBackground:"rgba(30,41,59,0.05)",pollColor:"#374151",pollSelectedColor:"#1e293b",pollCheckBorder:"#cbd5e1",pollCheckSelectedBorder:"#1e293b",pollCheckSelectedBg:"#1e293b"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.04)",md:"0 4px 12px rgba(0,0,0,0.06)",lg:"0 12px 32px rgba(0,0,0,0.06)",modal:"0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.06), 0 24px 48px rgba(0,0,0,0.04)",button:"0 2px 8px rgba(0,0,0,0.06)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}},oo={colors:{primary:"#e2e8f0",primaryHover:"#cbd5e1",primaryText:"#1e293b",background:"#1a1f2e",backgroundGradient:"linear-gradient(180deg, #1a1f2e 0%, #151925 100%)",surface:"rgba(55,65,81,0.5)",surfaceHover:"rgba(55,65,81,0.7)",text:"#f9fafb",textSecondary:"#d1d5db",textDisabled:"#6b7280",border:"rgba(255,255,255,0.08)",borderFocus:"rgba(255,255,255,0.2)",success:"#10b981",successSurface:"rgba(16,185,129,0.1)",error:"#fecaca",errorSurface:"rgba(127,29,29,0.3)",errorBorder:"rgba(254,202,202,0.1)",warning:"#fbbf24",warningActive:"#fbbf24",warningSurface:"rgba(245,158,11,0.08)",warningBorder:"rgba(245,158,11,0.3)",starFilled:"#f59e0b",starEmpty:"rgba(255,255,255,0.12)",voteUp:"#10b981",voteUpSurface:"rgba(16,185,129,0.08)",voteUpBorder:"rgba(16,185,129,0.3)",voteDown:"#ef4444",voteDownSurface:"rgba(239,68,68,0.08)",voteDownBorder:"rgba(239,68,68,0.3)",npsColors:Uo,buttonBackground:"#e2e8f0",buttonBackgroundHover:"#cbd5e1",buttonBackgroundDisabled:"#374151",buttonColor:"#1e293b",buttonColorDisabled:"#6b7280",buttonBorder:"none",buttonShadow:"none",backdropColor:"rgba(0,0,0,0.5)",closeButton:"#6b7280",closeButtonHover:"#9ca3af",closeButtonBg:"rgba(255,255,255,0.06)",glassBackground:"linear-gradient(180deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.04) 60%, rgba(0,0,0,0.05) 100%)",glassBorder:"1px solid rgba(255,255,255,0.15)",glassColor:"rgba(255,255,255,0.88)",glassShadow:"0 4px 14px rgba(0,0,0,0.45), 0 1px 3px rgba(0,0,0,0.35)",glassHoverShadow:"0 8px 24px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.4)",inputBackground:"rgba(55,65,81,0.5)",inputBackgroundFocus:"rgba(55,65,81,0.7)",inputBorder:"rgba(255,255,255,0.08)",inputBorderFocus:"rgba(255,255,255,0.2)",inputFocusRing:"rgba(255,255,255,0.06)",pollBorder:"rgba(255,255,255,0.08)",pollSelectedBorder:"rgba(226,232,240,0.25)",pollBackground:"rgba(55,65,81,0.5)",pollSelectedBackground:"rgba(226,232,240,0.08)",pollColor:"#d1d5db",pollSelectedColor:"#e2e8f0",pollCheckBorder:"rgba(255,255,255,0.2)",pollCheckSelectedBorder:"#e2e8f0",pollCheckSelectedBg:"#e2e8f0"},typography:{fontFamily:"'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",fontSize:{xs:11,sm:13,md:14,lg:16},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},borders:{radius:{sm:8,md:10,lg:14,full:"50%"},width:1},shadows:{sm:"0 1px 2px rgba(0,0,0,0.2)",md:"0 4px 12px rgba(0,0,0,0.3)",lg:"0 12px 32px rgba(0,0,0,0.2)",modal:"0 1px 2px rgba(0,0,0,0.2), 0 4px 12px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.2), 0 24px 48px rgba(0,0,0,0.15)",button:"0 2px 8px rgba(0,0,0,0.15)"},animation:{duration:{fast:"0.15s",normal:"0.25s",slow:"0.4s"},easing:{default:"cubic-bezier(0.4, 0, 0.2, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"}}};function Lt(e,t){return ie(e==="dark"?oo:eo,t)}function oe(e,t,o){let n=(e==="auto"||e==="custom"?t:e)==="dark"?ie({},oo):ie({},eo);return o&&(n=ie(n,o)),n}var $o="gotcha-styles",Oo="gotcha-dm-sans",Ho="gotcha-carter-one",Pt=`
|
|
2
2
|
@font-face {
|
|
3
3
|
font-family: 'Carter One';
|
|
4
4
|
font-style: normal;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
font-display: block;
|
|
7
7
|
src: url(data:font/woff2;base64,d09GMgABAAAAAAK4AA4AAAAABOwAAAJlAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGhQbXhwaBmAANBEICoFUgW8BNgIkAwgLBgAEIAWCUgcgGwoEUVQMHgC+OLCNaQVfBAoIrXGAIhjLIIM0CxavPfqMrzmLh6/9fufu20XEQyQzNNPOUEmimUZJpKLdIu3RKOU3O1hXc5D3YTdAbu+mRHU5AAIwC231R25qGGbpnwecyr34QQKM3gHMKMzOM4ogDSwQSreJE9bjISamQdCMwAAgeI0+S7qoy5j8TCDK8Ff4Fwm5+ecJhCwh9EgmsJiTo6S+/WkCPCU8DpCqr+hWKM/FBMRyfLPqV2LSlzBEIhqLxeGhIADg+rwoHxx58Oipm4301FUpgID4K8fAChoJFSYwAhNYKyDLAjudDimd9wA18hGDDvNkBE6AByBJiLpXVM2jgyht94hWK9yPQD+5lb948fAQKnfCK1PjBQWRayfW+hltCzAs9B8eX54Xd5g7vrzpiTswCeXB/VG5PNObmFr711KPrLKC6/mxys5avigCA+uFj8HGq+ErmaRDt/31k1XtfRtcI0pNluOCFEOOmVEOTg5eYn77Hq9Y0SJxu+bSBW5skqWS0VLXOvNJxgyRhVECycL7u2cb2pmOGdolPK+ORsLma1IHQCAY6I5NjWKsNzQVPeDnvzc7Pth+aTYMKHpqoEcCwSM4A6sVYPt/AIoeTckToLx4hELyieAj16Z4TKDbKYzIJOAW2JNhIptMhjyRlbXedjaymDv75i5jb1xkyVYiV4okyfIhmnG0EGNDIyMkVgmkUIJcmbJkQmLEi5Ehjz7iJF06pJeel1ETYiCBP/+OePouYuTKlyAX4iVTAl8JkhRIFyN3UpqAdTHa1nfVAy3Kk3LL2Ejf0Gch0McAqJNIAwAA) format('woff2');
|
|
8
8
|
unicode-range: U+0047;
|
|
9
|
-
}`.trim();function
|
|
9
|
+
}`.trim();function Ut(){if(typeof document>"u"||document.getElementById(Ho))return;let e=document.createElement("style");e.id=Ho,e.textContent=Pt,document.head.appendChild(e);}Ut();function ue(e){return e.replace(/[{}<>;@\\]/g,"")}function $t(e){let t={default:ue(e.animation.easing.default),spring:ue(e.animation.easing.spring)},o={normal:ue(e.animation.duration.normal)},r=ue(e.typography.fontFamily),n=ue(e.colors.textDisabled),p=ue(e.colors.border);return `
|
|
10
10
|
/* \u2500\u2500 Gotcha Keyframe Animations \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
11
11
|
|
|
12
12
|
@keyframes gotcha-modal-in {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
/* \u2500\u2500 Base Styles \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
104
104
|
|
|
105
105
|
[data-gotcha] {
|
|
106
|
-
font-family: ${
|
|
106
|
+
font-family: ${r};
|
|
107
107
|
-webkit-font-smoothing: antialiased;
|
|
108
108
|
-moz-osx-font-smoothing: grayscale;
|
|
109
109
|
}
|
|
@@ -118,33 +118,33 @@
|
|
|
118
118
|
|
|
119
119
|
[data-gotcha] button:focus-visible {
|
|
120
120
|
outline: none;
|
|
121
|
-
box-shadow: 0 0 0 2px ${
|
|
121
|
+
box-shadow: 0 0 0 2px ${p};
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
.gotcha-root textarea::placeholder {
|
|
125
|
-
color: ${
|
|
125
|
+
color: ${n};
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/* \u2500\u2500 Animation Utilities \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
129
129
|
|
|
130
130
|
.gotcha-fade-up {
|
|
131
|
-
animation: gotcha-fade-up ${o.normal} ${
|
|
131
|
+
animation: gotcha-fade-up ${o.normal} ${t.default} both;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
.gotcha-modal-enter {
|
|
135
|
-
animation: gotcha-modal-in 0.3s ${
|
|
135
|
+
animation: gotcha-modal-in 0.3s ${t.spring} both;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
.gotcha-modal-enter-above {
|
|
139
|
-
animation: gotcha-modal-in-above 0.3s ${
|
|
139
|
+
animation: gotcha-modal-in-above 0.3s ${t.spring} both;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
.gotcha-modal-enter-center {
|
|
143
|
-
animation: gotcha-modal-in-center 0.3s ${
|
|
143
|
+
animation: gotcha-modal-in-center 0.3s ${t.spring} both;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
.gotcha-overlay-enter {
|
|
147
|
-
animation: gotcha-overlay-in 0.2s ${
|
|
147
|
+
animation: gotcha-overlay-in 0.2s ${t.default} both;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/* \u2500\u2500 Reduced Motion \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
@@ -156,6 +156,6 @@
|
|
|
156
156
|
transition-duration: 0.01ms !important;
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
`.trim()}function Se(e){if(typeof document>"u")return;if(!document.getElementById(to)){let o=document.createElement("link");o.rel="preconnect",o.href="https://fonts.googleapis.com",document.head.appendChild(o);let t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.gstatic.com",t.crossOrigin="anonymous",document.head.appendChild(t);let s=document.createElement("link");s.id=to,s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=Carter+One&family=DM+Sans:wght@400;500;600;700&display=swap",document.head.appendChild(s);}let r=document.getElementById(oo);r||(r=document.createElement("style"),r.id=oo,document.head.appendChild(r)),r.textContent=Mo(e);}var ao=react.createContext(null),Do={};function Lo({apiKey:e,children:r,baseUrl:o,debug:t=false,disabled:s=false,defaultUser:h,themeConfig:n}){let[g,d]=react.useState(null);o&&!o.startsWith("https://")&&!o.startsWith("/")&&!o.includes("localhost")&&console.warn("[Gotcha] baseUrl should use HTTPS in production:",o);let a=react.useMemo(()=>Ze({apiKey:e,baseUrl:o,debug:t}),[e,o,t]),u=react.useMemo(()=>h??Do,[JSON.stringify(h)]);react.useEffect(()=>{let c=K("light","light",n);Se(c);},[n]);let b=react.useCallback(c=>{d(c);},[]),l=react.useCallback(()=>{d(null);},[]),i=react.useMemo(()=>({client:a,disabled:s,defaultUser:u,debug:t,activeModalId:g,openModal:b,closeModal:l,themeConfig:n}),[a,s,u,t,g,b,l,n]);return jsxRuntime.jsx(ao.Provider,{value:i,children:r})}function z(){let e=react.useContext(ao);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function so(e){let{client:r,defaultUser:o}=z(),[t,s]=react.useState(false),[h,n]=react.useState(false),[g,d]=react.useState(null),[a,u]=react.useState(null);return react.useEffect(()=>{let l=e.user?.id||o?.id;if(!l){u(null);return}let i=false;return (async()=>{n(true);try{let f=await r.checkExistingResponse(e.elementId,l);i||u(f);}catch{i||u(null);}finally{i||n(false);}})(),()=>{i=true;}},[r,e.elementId,e.user?.id,o?.id]),{submit:react.useCallback(async l=>{s(true),d(null);try{let i=e.user?.id||o?.id,c;return a&&i?c=await r.updateResponse(a.id,{content:l.content,title:l.title,rating:l.rating,vote:l.vote,pollSelected:l.pollSelected},i):c=await r.submitResponse({elementId:e.elementId,mode:e.mode,content:l.content,title:l.title,rating:l.rating,vote:l.vote,pollOptions:e.pollOptions,pollSelected:l.pollSelected,isBug:l.isBug,user:{...o,...e.user}}),u({id:c.id,mode:e.mode,content:l.content??null,title:l.title??null,rating:l.rating??null,vote:l.vote??null,pollSelected:l.pollSelected??null,createdAt:c.createdAt}),e.onSuccess?.(c),c}catch(i){let c=i instanceof Error?i.message:"Something went wrong";throw d(c),e.onError?.(i instanceof Error?i:new Error(c)),i}finally{s(false);}},[r,o,e,a]),isLoading:t,isCheckingExisting:h,error:g,existingResponse:a,isEditing:!!a,clearError:()=>d(null)}}function ve(...e){return e.filter(Boolean).join(" ")}var $=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,io=(e,r)=>{let o={sm:{desktop:24,mobile:28},md:{desktop:32,mobile:34},lg:{desktop:40,mobile:40}};return r?o[e].mobile:o[e].desktop};function _o(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function lo({size:e,theme:r,customStyles:o,showOnHover:t,touchBehavior:s,onClick:h,isOpen:n,isParentHovered:g=false,animated:d=true}){let[a,u]=react.useState(false),[b,l]=react.useState(false),[i,c]=react.useState(_o),[f,y]=react.useState(false),[R,v]=react.useState(false),[w,B]=react.useState(false),{themeConfig:P}=z();react.useEffect(()=>{if(u($()),typeof window>"u")return;let U=window.matchMedia("(prefers-color-scheme: dark)"),W=V=>c(V.matches?"dark":"light");return U.addEventListener("change",W),()=>U.removeEventListener("change",W)},[]);let S=n?true:!a&&t?g:a&&s==="tap-to-reveal"?b:true;react.useEffect(()=>{if(S&&!w){let U=setTimeout(()=>B(true),600);return ()=>clearTimeout(U)}},[S,w]);let T=()=>{if(a&&s==="tap-to-reveal"&&!b){l(true);return}h();},m=io(e,a),k=react.useMemo(()=>K(r,i,P),[r,i,P]),x=()=>S?R?"scale(0.95)":f?"scale(1.08)":"scale(1)":"scale(0.6)",L={width:m,height:m,borderRadius:"50%",border:k.colors.glassBorder,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:k.colors.glassBackground,backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",color:k.colors.glassColor,boxShadow:f?k.colors.glassHoverShadow:k.colors.glassShadow,transition:w?`all 0.3s ${k.animation.easing.spring}`:"none",opacity:S?1:0,transform:x(),filter:R?"brightness(0.95)":"brightness(1)",pointerEvents:S?"auto":"none",...d&&S&&!w?{animation:"gotcha-bubble-pop 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275) both, gotcha-arrive-glow 1200ms ease-in-out 600ms both"}:{},...o?.button};return jsxRuntime.jsx("button",{type:"button",onClick:T,onMouseEnter:()=>y(true),onMouseLeave:()=>{y(false),v(false);},onMouseDown:()=>v(true),onMouseUp:()=>v(false),onTouchStart:()=>v(true),onTouchEnd:()=>v(false),style:L,className:ve("gotcha-button",n&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":n,"aria-haspopup":"dialog",children:jsxRuntime.jsx(Wo,{size:m*.65,animated:d})})}function Wo({size:e,animated:r=true}){let[o,t]=react.useState(false);return react.useEffect(()=>{t(true);},[]),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{fontFamily:"'Carter One', cursive",fontSize:e,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",marginTop:e*.05,marginRight:e*.05,userSelect:"none",opacity:r?0:o?1:0,...r&&o?{animation:"gotcha-letter-in 350ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 200ms both"}:{}},children:"G"})}function H({size:e=16,color:r="currentColor"}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{animation:"gotcha-spin 0.8s linear infinite"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:r,strokeWidth:"2",strokeOpacity:"0.12"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:r,strokeWidth:"2",strokeLinecap:"round",style:{animation:"gotcha-dash 1.2s ease-in-out infinite"}})]})}function uo({resolvedTheme:e,placeholder:r,submitText:o,isLoading:t,onSubmit:s,customStyles:h,initialValues:n,isEditing:g=false,showText:d=true,showRating:a=true,enableBugFlag:u=false,bugFlagLabel:b}){let[l,i]=react.useState(n?.content||""),[c,f]=react.useState(n?.rating??null),[y,R]=react.useState(false),[v,w]=react.useState(false);react.useEffect(()=>{w($());},[]),react.useEffect(()=>{n?.content!==void 0&&i(n.content||""),n?.rating!==void 0&&f(n.rating??null);},[n?.content,n?.rating]);let B=d&&a?l.trim().length>0||c!==null:d?l.trim().length>0:a?c!==null:false,P=m=>{m.preventDefault(),B&&s({content:d&&l.trim()?l.trim():void 0,rating:a&&c!==null?c:void 0,isBug:y||void 0});},S={width:"100%",padding:v?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:v?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:v?100:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)",...h?.input},T={width:"100%",padding:v?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:e.colors.buttonBackground,color:e.colors.buttonColor,fontSize:v?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:t?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",...h?.submitButton};return jsxRuntime.jsxs("form",{onSubmit:P,children:[a&&jsxRuntime.jsx("div",{style:{marginBottom:d?v?16:12:0,...d?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsxRuntime.jsx(Ko,{value:c,onChange:f,theme:e,isTouch:v,large:!d})}),d&&jsxRuntime.jsx("textarea",{value:l,onChange:m=>i(m.target.value),placeholder:r||"Share your thoughts...",maxLength:5e3,style:S,disabled:t,"aria-label":"Your feedback",onFocus:m=>{m.currentTarget.style.borderColor=e.colors.inputBorderFocus,m.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,m.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:m=>{m.currentTarget.style.borderColor=e.colors.inputBorder,m.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.04)",m.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),u&&jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":y,onClick:()=>R(!y),style:{display:"flex",alignItems:"center",gap:7,width:"100%",marginTop:10,padding:"7px 10px",border:`1px solid ${y?e.colors.warningBorder:e.colors.border}`,borderRadius:7,backgroundColor:y?e.colors.warningSurface:"transparent",cursor:"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,fontFamily:e.typography.fontFamily,...h?.bugFlag},onMouseEnter:m=>{y||(m.currentTarget.style.backgroundColor=e.colors.surfaceHover===e.colors.inputBackgroundFocus?"rgba(0,0,0,0.02)":e.colors.surfaceHover);},onMouseLeave:m=>{y||(m.currentTarget.style.backgroundColor="transparent");},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:y?e.colors.warningActive:e.colors.textDisabled,strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:`stroke ${e.animation.duration.fast}`},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:y?e.typography.fontWeight.medium:e.typography.fontWeight.normal,color:y?e.colors.warningActive:e.colors.textDisabled,transition:`color ${e.animation.duration.fast}`,letterSpacing:"0.01em"},children:y?"Issue reported":b||"Report an issue"}),jsxRuntime.jsx("div",{style:{marginLeft:"auto",width:28,height:16,borderRadius:8,backgroundColor:y?e.colors.warning:e.colors.border,position:"relative",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,flexShrink:0},children:jsxRuntime.jsx("div",{style:{position:"absolute",top:2,left:y?14:2,width:12,height:12,borderRadius:"50%",backgroundColor:y?"#ffffff":e.colors.textDisabled,transition:`left ${e.animation.duration.fast} ${e.animation.easing.default}, background-color ${e.animation.duration.fast}`,boxShadow:"0 1px 2px rgba(0,0,0,0.15)"}})})]}),jsxRuntime.jsxs("button",{type:"submit",disabled:t||!B,style:{...T,marginTop:12,opacity:t?.8:1,backgroundColor:B?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:B?e.colors.buttonColor:e.colors.buttonColorDisabled,display:"flex",alignItems:"center",justifyContent:"center",gap:8,...t?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,m.currentTarget.style.transform="translateY(-1px)",m.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=e.colors.buttonBackground,m.currentTarget.style.transform="translateY(0)",m.currentTarget.style.boxShadow="none");},children:[t&&jsxRuntime.jsx(H,{size:v?18:16,color:e.colors.buttonColor}),t?g?"Updating...":"Submitting...":g?"Update":o]})]})}function Ko({value:e,onChange:r,theme:o,isTouch:t,large:s=false}){let[h,n]=react.useState(null),[g,d]=react.useState(null),a=react.useRef(),u=s?t?36:28:t?28:18,b=s?t?8:5:t?8:3;react.useEffect(()=>()=>{clearTimeout(a.current);},[]);let l=i=>{d(i),r(i),clearTimeout(a.current),a.current=setTimeout(()=>d(null),300);};return jsxRuntime.jsx("div",{style:{display:"flex",gap:s?t?8:6:t?6:2},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(i=>{let c=(h??e??0)>=i;return jsxRuntime.jsx("button",{type:"button",onClick:()=>l(i),onMouseEnter:()=>n(i),onMouseLeave:()=>n(null),"aria-label":`Rate ${i} out of 5`,"aria-pressed":e===i,style:{background:"none",border:"none",cursor:"pointer",padding:b,color:c?o.colors.starFilled:o.colors.starEmpty,transition:`color 0.15s ${o.animation.easing.default}`,transform:g===i?"scale(1)":h!==null&&h>=i?"scale(1.1)":"scale(1)",animation:g===i?`gotcha-star-pulse 0.3s ${o.animation.easing.spring}`:"none",filter:c?`drop-shadow(0 0 3px ${o.colors.starFilled}40)`:"none",transitionDelay:`${(i-1)*30}ms`},children:jsxRuntime.jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})},i)})})}function go({resolvedTheme:e,isLoading:r,onSubmit:o,initialVote:t,isEditing:s=false,labels:h}){let[n,g]=react.useState(false),[d,a]=react.useState(t||null),[u,b]=react.useState(t||null);react.useEffect(()=>{g($());},[]),react.useEffect(()=>{t!==void 0&&(b(t),a(t));},[t]),react.useEffect(()=>{!r&&!s&&a(null);},[r,s]);let l=f=>{a(f),o({vote:f});},i=f=>{let y=u===f,R=f==="up"?e.colors.voteUp:e.colors.voteDown,v=f==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,w=f==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return {flex:1,minWidth:0,overflow:"hidden",padding:n?"14px 18px":"10px 14px",border:y?`2px solid ${w}`:`1px solid ${e.colors.border}`,borderRadius:e.borders.radius.lg-2,background:y?`linear-gradient(135deg, ${v}, ${v})`:e.colors.surface,color:y?R:e.colors.textSecondary,fontSize:n?28:24,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,display:"flex",alignItems:"center",justifyContent:"center",gap:n?10:8}},c=n?24:20;return jsxRuntime.jsxs("div",{style:{display:"flex",gap:n?12:10},role:"group","aria-label":"Vote",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>l("up"),disabled:r,style:i("up"),"aria-label":"Vote up - I like this","aria-pressed":u==="up",onMouseEnter:f=>{r||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:r&&d==="up"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(H,{size:c,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Vo,{size:c}),jsxRuntime.jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:h?.up||(u==="up"?"Liked":"Like")})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>l("down"),disabled:r,style:i("down"),"aria-label":"Vote down - I don't like this","aria-pressed":u==="down",onMouseEnter:f=>{r||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:r&&d==="down"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(H,{size:c,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(jo,{size:c}),jsxRuntime.jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:h?.down||(u==="down"?"Disliked":"Dislike")})]})})]})}function Vo({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function jo({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function mo({resolvedTheme:e,options:r,allowMultiple:o,isLoading:t,onSubmit:s,initialSelected:h,isEditing:n=false}){let[g,d]=react.useState(h||[]),[a,u]=react.useState(false);react.useEffect(()=>{u($());},[]),react.useEffect(()=>{h&&d(h);},[h]);let b=c=>{d(o?f=>f.includes(c)?f.filter(y=>y!==c):[...f,c]:f=>f.includes(c)?[]:[c]);},l=()=>{g.length!==0&&s({pollSelected:g});},i=(c,f)=>{let y=g.includes(c);return {width:"100%",padding:a?"12px 14px":"9px 12px",border:`1px solid ${y?e.colors.pollSelectedBorder:e.colors.pollBorder}`,borderRadius:e.borders.radius.lg-2,backgroundColor:y?e.colors.pollSelectedBackground:e.colors.pollBackground,color:y?e.colors.pollSelectedColor:e.colors.pollColor,fontSize:a?15:e.typography.fontSize.sm,fontWeight:y?e.typography.fontWeight.semibold:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:t?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,textAlign:"left",letterSpacing:"0.01em",display:"flex",alignItems:"center",gap:8,animation:`gotcha-fade-up ${e.animation.duration.normal} ${e.animation.easing.default} both`,animationDelay:`${f*.05}s`}};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:a?8:6},role:"group","aria-label":o?"Select one or more options":"Select an option",children:r.map((c,f)=>{let y=g.includes(c);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>b(c),disabled:t,style:i(c,f),"aria-pressed":y,onMouseEnter:R=>{t||(R.currentTarget.style.transform="translateX(2px)");},onMouseLeave:R=>{R.currentTarget.style.transform="translateX(0)";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:o?4:"50%",border:`2px solid ${y?e.colors.pollCheckSelectedBorder:e.colors.pollCheckBorder}`,backgroundColor:y?e.colors.pollCheckSelectedBg:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast}`},children:y&&jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),c]},c)})}),jsxRuntime.jsxs("button",{type:"button",onClick:l,disabled:t||g.length===0,style:{width:"100%",marginTop:12,padding:a?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:g.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,color:g.length===0?e.colors.buttonColorDisabled:e.colors.buttonColor,fontSize:a?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:t||g.length===0?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:t?.8:1,...t?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:c=>{c.currentTarget.disabled||(c.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:c=>{c.currentTarget.disabled||(c.currentTarget.style.backgroundColor=g.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,c.currentTarget.style.transform="translateY(0)",c.currentTarget.style.boxShadow="none");},children:[t&&jsxRuntime.jsx(H,{size:a?18:16,color:e.colors.buttonColor}),t?n?"Updating...":"Submitting...":n?"Update":"Submit"]})]})}function bo({resolvedTheme:e,submitText:r,isLoading:o,onSubmit:t,customStyles:s,showFollowUp:h=true,followUpPlaceholder:n,lowLabel:g="Not likely",highLabel:d="Very likely",initialValues:a,isEditing:u=false}){let[b,l]=react.useState(a?.rating??null),[i,c]=react.useState(a?.content||""),[f,y]=react.useState(false),[R,v]=react.useState(null);react.useEffect(()=>{y($());},[]),react.useEffect(()=>{a?.rating!==void 0&&l(a.rating??null),a?.content!==void 0&&c(a.content||"");},[a?.rating,a?.content]);let w=b!==null,B=e.colors.npsColors;return jsxRuntime.jsxs("form",{onSubmit:S=>{S.preventDefault(),w&&t({rating:b??void 0,content:h&&i.trim()?i.trim():void 0});},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:f?4:6,justifyContent:"center"},role:"group","aria-label":"NPS Score",children:Array.from({length:11},(S,T)=>{let m=b===T,k=R===T,x=B[T];return jsxRuntime.jsx("button",{type:"button",onClick:()=>l(T),onMouseEnter:()=>v(T),onMouseLeave:()=>v(null),"aria-label":`Score ${T} out of 10`,"aria-pressed":m,style:{flex:1,minWidth:0,height:f?34:32,borderRadius:e.borders.radius.sm,border:m?`2px solid ${x}`:`1.5px solid ${x}25`,backgroundColor:m?x:k?`${x}25`:`${x}0c`,color:m?"#fff":k?x:`${x}bb`,fontSize:12,fontWeight:m?e.typography.fontWeight.bold:e.typography.fontWeight.semibold,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:`all 0.2s ${e.animation.easing.spring}`,transform:m?"scale(1.08)":k?"scale(1.04)":"scale(1)",boxShadow:m?`0 0 12px ${x}40`:"none",...s?.npsButton,...m?s?.npsButtonSelected:{}},children:T},T)})}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6,padding:"0 2px",...s?.npsLabels},children:[jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:g}),jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:d})]})]}),h&&b!==null&&jsxRuntime.jsx("textarea",{value:i,onChange:S=>c(S.target.value),placeholder:n||"What's the main reason for your score?",maxLength:5e3,style:{width:"100%",padding:f?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"vertical",minHeight:f?80:60,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,animation:`gotcha-expand-in 0.3s ${e.animation.easing.default} both`,overflow:"hidden",...s?.input},disabled:o,"aria-label":"Follow-up feedback",onFocus:S=>{S.currentTarget.style.borderColor=e.colors.inputBorderFocus,S.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,S.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:S=>{S.currentTarget.style.borderColor=e.colors.inputBorder,S.currentTarget.style.boxShadow="none",S.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),jsxRuntime.jsxs("button",{type:"submit",disabled:o||!w,style:{width:"100%",padding:f?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:w?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:w?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:o?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",opacity:o?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginTop:12,...o?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{},...s?.submitButton},onMouseEnter:S=>{S.currentTarget.disabled||(S.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,S.currentTarget.style.transform="translateY(-1px)",S.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:S=>{S.currentTarget.disabled||(S.currentTarget.style.backgroundColor=w?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,S.currentTarget.style.transform="translateY(0)",S.currentTarget.style.boxShadow="none");},children:[o&&jsxRuntime.jsx(H,{size:f?18:16,color:e.colors.buttonColor}),o?u?"Updating...":"Submitting...":u?"Update":r]})]})}function _e({mode:e,theme:r,customStyles:o,promptText:t,placeholder:s,submitText:h,thankYouMessage:n,isLoading:g,isSubmitted:d,error:a,existingResponse:u,isEditing:b=false,showText:l=true,showRating:i=true,voteLabels:c,options:f,allowMultiple:y=false,npsQuestion:R,npsFollowUp:v=true,npsFollowUpPlaceholder:w,npsLowLabel:B,npsHighLabel:P,enableBugFlag:S=false,bugFlagLabel:T,onSubmit:m,onClose:k,anchorRect:x,useFixedPosition:L=false}){let U=react.useRef(null),W=react.useRef(null),V=react.useRef(k);V.current=k;let[I,Ce]=react.useState(false),[me,se]=react.useState("light"),{themeConfig:q}=z();react.useEffect(()=>{Ce(window.innerWidth<640);let C=window.matchMedia("(prefers-color-scheme: dark)");se(C.matches?"dark":"light");let O=A=>se(A.matches?"dark":"light");return C.addEventListener("change",O),()=>C.removeEventListener("change",O)},[]);let p=react.useMemo(()=>K(r,me,q),[r,me,q]);react.useEffect(()=>{Se(p);},[p]);let j=typeof window>"u"||!x?false:window.innerHeight-x.bottom<300;react.useEffect(()=>{let C=U.current;if(!C)return;W.current?.focus();let O=A=>{if(A.key==="Escape"){V.current();return}if(A.key==="Tab"){let oe=C.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),he=oe[0],be=oe[oe.length-1];A.shiftKey&&document.activeElement===he?(A.preventDefault(),be?.focus()):!A.shiftKey&&document.activeElement===be&&(A.preventDefault(),he?.focus());}};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[]);let Ee=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":e==="nps"?R||"How likely are you to recommend us?":"What do you think of this feature?",Z=I?24:20,ie=e==="nps"?420:340,Re=I?"gotcha-modal-enter-center":j?"gotcha-modal-enter-above":"gotcha-modal-enter",N=typeof window<"u"?window.innerHeight:0,Be=I?{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"calc(100vw - 32px)",maxWidth:ie,padding:Z,borderRadius:p.borders.radius.lg+2,background:p.colors.backgroundGradient,color:p.colors.text,boxShadow:p.shadows.modal,border:`${p.borders.width}px solid ${p.colors.border}`,zIndex:9999,fontFamily:p.typography.fontFamily,...o?.modal,textAlign:"left"}:L&&x&&N?{position:"fixed",left:x.left+x.width/2,width:ie,padding:Z,borderRadius:p.borders.radius.lg,background:p.colors.backgroundGradient,color:p.colors.text,boxShadow:p.shadows.modal,border:`${p.borders.width}px solid ${p.colors.border}`,zIndex:99999,fontFamily:p.typography.fontFamily,...j?{bottom:N-x.top+8,transform:"translateX(-50%)"}:{top:x.bottom+8,transform:"translateX(-50%)"},...o?.modal,textAlign:"left"}:{position:"absolute",left:"50%",width:ie,padding:Z,borderRadius:p.borders.radius.lg,background:p.colors.backgroundGradient,color:p.colors.text,boxShadow:p.shadows.modal,border:`${p.borders.width}px solid ${p.colors.border}`,zIndex:9999,fontFamily:p.typography.fontFamily,...j?{bottom:"100%",marginBottom:8,transform:"translateX(-50%)"}:{top:"100%",marginTop:8,transform:"translateX(-50%)"},...o?.modal,textAlign:"left"},ee=C=>I?{}:{animation:`gotcha-fade-up ${p.animation.duration.normal} ${p.animation.easing.default} both`,animationDelay:`${C*.05}s`},X=n==="Gotcha!"||n==="Thanks for your feedback!";return jsxRuntime.jsxs("div",{ref:U,role:"dialog","aria-modal":"true","aria-label":d?"Feedback submitted":void 0,"aria-labelledby":d?void 0:"gotcha-modal-title","data-gotcha":true,style:Be,className:ve("gotcha-modal",Re),children:[jsxRuntime.jsx("button",{ref:W,type:"button",onClick:k,"aria-label":"Close feedback form",style:{position:"absolute",top:I?10:6,right:I?10:6,width:I?40:36,height:I?40:36,border:"none",background:"transparent",outline:"none",cursor:"pointer",zIndex:10,color:p.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:p.borders.radius.sm,transition:`all ${p.animation.duration.fast} ${p.animation.easing.default}`,...o?.closeButton},onMouseEnter:C=>{C.currentTarget.style.backgroundColor=p.colors.closeButtonBg,C.currentTarget.style.color=p.colors.closeButtonHover;},onMouseLeave:C=>{C.currentTarget.style.backgroundColor="transparent",C.currentTarget.style.color=p.colors.closeButton;},children:jsxRuntime.jsx("svg",{width:I?16:14,height:I?16:14,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!d&&jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:I?p.typography.fontSize.lg:p.typography.fontSize.md,fontWeight:p.typography.fontWeight.semibold,paddingRight:I?44:38,letterSpacing:"-0.02em",lineHeight:1.4,textAlign:"left",fontFamily:p.typography.fontFamily,...ee(0),...o?.title},children:t||Ee}),d&&jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"28px 0 20px"},children:[jsxRuntime.jsx("div",{style:{width:52,height:52,borderRadius:"50%",backgroundColor:p.colors.successSurface,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",animation:`gotcha-success-pop 0.4s ${p.animation.easing.spring} both, gotcha-glow-pulse 0.8s ease 0.4s`,...o?.successIcon},children:jsxRuntime.jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M20 6L9 17L4 12",stroke:p.colors.success,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:24,strokeDashoffset:0,animation:"gotcha-check-draw 0.4s ease 0.2s both"}})})}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:X?22:p.typography.fontSize.md,fontWeight:X?p.typography.fontWeight.bold:p.typography.fontWeight.medium,color:p.colors.text,fontFamily:X?"'Carter One', cursive":p.typography.fontFamily,animation:"gotcha-success-text 0.3s ease 0.3s both",...o?.successMessage},children:X?"Gotcha!":n}),X&&jsxRuntime.jsx("p",{style:{margin:"6px 0 0",fontSize:p.typography.fontSize.sm,fontWeight:p.typography.fontWeight.normal,color:p.colors.textSecondary,animation:"gotcha-success-text 0.3s ease 0.45s both"},children:"Thanks for your feedback!"})]}),a&&!d&&jsxRuntime.jsxs("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:p.borders.radius.sm,backgroundColor:p.colors.errorSurface,border:`1px solid ${p.colors.errorBorder}`,color:p.colors.error,fontSize:p.typography.fontSize.sm,lineHeight:1.4,display:"flex",alignItems:"center",gap:8,...ee(1),...o?.errorMessage},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),a]}),!d&&jsxRuntime.jsxs("div",{style:ee(1),children:[e==="feedback"&&jsxRuntime.jsx(uo,{resolvedTheme:p,placeholder:s,submitText:h,isLoading:g,onSubmit:m,customStyles:o,initialValues:u?{content:u.content,rating:u.rating}:void 0,isEditing:b,showText:l,showRating:i,enableBugFlag:S,bugFlagLabel:T}),e==="vote"&&jsxRuntime.jsx(go,{resolvedTheme:p,isLoading:g,onSubmit:m,initialVote:u?.vote||void 0,isEditing:b,labels:c}),e==="nps"&&jsxRuntime.jsx(bo,{resolvedTheme:p,submitText:h,isLoading:g,onSubmit:m,showFollowUp:v,followUpPlaceholder:w,lowLabel:B,highLabel:P,customStyles:o,initialValues:u?{rating:u.rating,content:u.content}:void 0,isEditing:b}),e==="poll"&&f&&f.length>0&&jsxRuntime.jsx(mo,{resolvedTheme:p,options:f,allowMultiple:y,isLoading:g,onSubmit:m,initialSelected:u?.pollSelected||void 0,isEditing:b})]}),jsxRuntime.jsxs("div",{"aria-live":"polite",className:"sr-only",style:{position:"absolute",left:-9999},children:[d&&"Thank you! Your feedback has been submitted.",a&&`Error: ${a}`]})]})}function Qo({elementId:e,user:r,mode:o="feedback",showText:t=true,showRating:s=true,voteLabels:h,options:n,allowMultiple:g=false,npsQuestion:d,npsFollowUp:a=true,npsFollowUpPlaceholder:u,npsLowLabel:b,npsHighLabel:l,enableBugFlag:i=false,bugFlagLabel:c,onePerUser:f=false,animated:y=true,position:R=Y.POSITION,size:v=Y.SIZE,theme:w=Y.THEME,customStyles:B,visible:P=true,showOnHover:S=Y.SHOW_ON_HOVER,touchBehavior:T=Y.TOUCH_BEHAVIOR,promptText:m,placeholder:k,submitText:x=Y.SUBMIT_TEXT,thankYouMessage:L=Y.THANK_YOU_MESSAGE,onSubmit:U,onOpen:W,onClose:V,onError:I}){let{disabled:Ce,activeModalId:me,openModal:se,closeModal:q}=z(),[p,j]=react.useState(false),[Ee,Z]=react.useState(false),[ie,Re]=react.useState(null),[N,Be]=react.useState(false),[ee,X]=react.useState(false),C=react.useRef(null),O=react.useRef();react.useEffect(()=>(X(true),Be(window.innerWidth<640),()=>{clearTimeout(O.current);}),[]);let A=me===e;react.useEffect(()=>{if(!A||!N)return;let G=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=G;}},[A,N]),react.useEffect(()=>{if(!S)return;let G=C.current;if(!G)return;let le=G.parentElement;if(!le)return;let Xe=()=>Z(true),Qe=()=>Z(false);return le.addEventListener("mouseenter",Xe),le.addEventListener("mouseleave",Qe),()=>{le.removeEventListener("mouseenter",Xe),le.removeEventListener("mouseleave",Qe);}},[S]);let{submit:oe,isLoading:he,error:be,existingResponse:ko,isEditing:Ke}=so({elementId:e,mode:o,pollOptions:n,user:r,onSuccess:G=>{j(true),U?.(G),O.current=setTimeout(()=>{q(),j(false);},3e3);},onError:G=>{console.warn("[Gotcha] Submission failed:",G instanceof Error?G.message:G),I?.(G);}}),wo=react.useCallback(()=>{C.current&&Re(C.current.getBoundingClientRect()),se(e),W?.();},[e,se,W]),Ve=react.useCallback(()=>{clearTimeout(O.current),q(),j(false),V?.();},[q,V]),To=react.useCallback(G=>{oe(G);},[oe]),Co=Ke?"Update":x;if(Ce||!P)return null;let Eo={"top-right":{position:"absolute",top:0,right:0,transform:"translate(50%, -50%)"},"top-left":{position:"absolute",top:0,left:0,transform:"translate(-50%, -50%)"},"bottom-right":{position:"absolute",bottom:0,right:0,transform:"translate(50%, 50%)"},"bottom-left":{position:"absolute",bottom:0,left:0,transform:"translate(-50%, 50%)"},inline:{position:"relative",display:"inline-flex"}},je={mode:o,theme:w,customStyles:B,promptText:m,placeholder:k,submitText:Co,thankYouMessage:L,isLoading:he,isSubmitted:p,error:be,existingResponse:ko,isEditing:Ke,showText:t,showRating:s,voteLabels:h,options:n,allowMultiple:g,npsQuestion:d,npsFollowUp:a,npsFollowUpPlaceholder:u,npsLowLabel:b,npsHighLabel:l,enableBugFlag:i,bugFlagLabel:c,onSubmit:To,onClose:Ve,anchorRect:ie||void 0,useFixedPosition:!N};return jsxRuntime.jsxs("div",{ref:C,style:{...Eo[R],zIndex:A?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(lo,{size:v,theme:w,customStyles:B,showOnHover:S,touchBehavior:T,onClick:wo,isOpen:A,isParentHovered:Ee,animated:y}),A&&!N&&ee&&reactDom.createPortal(jsxRuntime.jsx(_e,{...je}),document.body),A&&N&&ee&&reactDom.createPortal(jsxRuntime.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:"rgba(0,0,0,0.4)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},className:"gotcha-overlay-enter",onClick:Ve,children:jsxRuntime.jsx("div",{onClick:G=>G.stopPropagation(),children:jsxRuntime.jsx(_e,{...je})})}),document.body)]})}function vo({elementId:e,refreshInterval:r}){let{client:o}=z(),[t,s]=react.useState(null),[h,n]=react.useState(true),[g,d]=react.useState(null);return react.useEffect(()=>{let a=false,u=async()=>{try{let l=await o.getScore(e);a||(s(l),d(null));}catch(l){a||d(l instanceof Error?l.message:"Failed to load score");}finally{a||n(false);}};u();let b;return r&&r>0&&(b=setInterval(u,r)),()=>{a=true,b&&clearInterval(b);}},[o,e,r]),{score:t,isLoading:h,error:g}}var tt={sm:{fontSize:11,ratingFontSize:13,starSize:13,gap:5,pillPx:8,pillPy:4,barHeight:3,iconSize:12},md:{fontSize:12.5,ratingFontSize:15,starSize:15,gap:6,pillPx:10,pillPy:5,barHeight:4,iconSize:14},lg:{fontSize:14,ratingFontSize:18,starSize:18,gap:8,pillPx:12,pillPy:6,barHeight:5,iconSize:16}};function rt({rating:e,size:r,filledColor:o,emptyColor:t}){let s=`gotcha-star-clip-${Math.random().toString(36).slice(2,8)}`,h=[];for(let n=1;n<=5;n++){let g=Math.min(1,Math.max(0,e-(n-1))),d=`${s}-${n}`;h.push(jsxRuntime.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",style:{display:"block"},children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:d,children:jsxRuntime.jsx("rect",{x:"0",y:"0",width:24*g,height:"24"})})}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:t}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:o,clipPath:`url(#${d})`})]},n));}return jsxRuntime.jsx("span",{style:{display:"inline-flex",gap:Math.max(1,r*.08),alignItems:"center"},children:h})}function nt({rate:e,height:r,filledColor:o,trackColor:t}){return jsxRuntime.jsx("span",{style:{display:"inline-block",width:48,height:r,borderRadius:r,backgroundColor:t,overflow:"hidden",verticalAlign:"middle"},children:jsxRuntime.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:r,background:o,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function at({size:e,color:r}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:r,style:{display:"block"},children:jsxRuntime.jsx("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66a4.8 4.8 0 00-.88-1.12L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})})}function st({elementId:e,variant:r="stars",showCount:o=true,size:t="md",theme:s="auto",refreshInterval:h,style:n}){let{score:g,isLoading:d}=vo({elementId:e,refreshInterval:h}),[a,u]=react.useState("light");react.useEffect(()=>{if(typeof window>"u")return;let k=window.matchMedia("(prefers-color-scheme: dark)");u(k.matches?"dark":"light");let x=L=>u(L.matches?"dark":"light");return k.addEventListener("change",x),()=>k.removeEventListener("change",x)},[]);let{themeConfig:b}=z(),l=react.useMemo(()=>K(s,a,b),[s,a,b]);if(d||!g)return null;let i=tt[t],c=l.colors.text,f=l.colors.textDisabled,y=l.colors.starFilled,R=l.colors.starEmpty,v=l.colors.voteUp,w=l.colors.starEmpty,B={display:"inline-flex",alignItems:"center",gap:i.gap,fontFamily:l.typography.fontFamily,lineHeight:1,letterSpacing:"-0.01em",WebkitFontSmoothing:"antialiased",...n},P=(k,x)=>{let L=k===1?x:`${x}s`;return `${k.toLocaleString()} ${L}`};if(r==="votes"){let{voteCount:k,positiveRate:x}=g,L=k.up+k.down;return L===0?null:jsxRuntime.jsxs("span",{style:B,children:[jsxRuntime.jsx(at,{size:i.iconSize,color:v}),jsxRuntime.jsxs("span",{style:{fontSize:i.ratingFontSize,fontWeight:600,color:v,fontVariantNumeric:"tabular-nums"},children:[x,"%"]}),jsxRuntime.jsx(nt,{rate:x??0,height:i.barHeight,filledColor:v,trackColor:w}),o&&jsxRuntime.jsx("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:P(L,"vote")})]})}let{averageRating:S,totalResponses:T}=g;if(S===null||T===0)return null;let m=S.toFixed(1);return r==="compact"?jsxRuntime.jsxs("span",{style:B,children:[jsxRuntime.jsx("svg",{width:i.starSize,height:i.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:y})}),jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:["(",T.toLocaleString(),")"]})]}):r==="number"?jsxRuntime.jsxs("span",{style:B,children:[jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),jsxRuntime.jsx("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:"/ 5"}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400,marginLeft:2},children:["(",P(T,"response"),")"]})]}):jsxRuntime.jsxs("span",{style:B,children:[jsxRuntime.jsx(rt,{rating:S,size:i.starSize,filledColor:y,emptyColor:R}),jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:["(",P(T,"response"),")"]})]})}function it(){let{client:e,disabled:r,defaultUser:o,debug:t}=z();return {client:e,disabled:r,defaultUser:o,debug:t,submitFeedback:e.submitResponse.bind(e)}}
|
|
160
|
-
exports.Gotcha=
|
|
159
|
+
`.trim()}function He(e){if(typeof document>"u")return;if(!document.getElementById(Oo)){let o=document.createElement("link");o.rel="preconnect",o.href="https://fonts.googleapis.com",document.head.appendChild(o);let r=document.createElement("link");r.rel="preconnect",r.href="https://fonts.gstatic.com",r.crossOrigin="anonymous",document.head.appendChild(r);let n=document.createElement("link");n.id=Oo,n.rel="stylesheet",n.href="https://fonts.googleapis.com/css2?family=Carter+One&family=DM+Sans:wght@400;500;600;700&display=swap",document.head.appendChild(n);}let t=document.getElementById($o);t||(t=document.createElement("style"),t.id=$o,document.head.appendChild(t)),t.textContent=$t(e);}var No=react.createContext(null),Nt={};function Wt({apiKey:e,children:t,baseUrl:o,debug:r=false,disabled:n=false,defaultUser:p,themeConfig:l}){let[u,g]=react.useState(null);o&&!o.startsWith("https://")&&!o.startsWith("/")&&!o.includes("localhost")&&console.warn("[Gotcha] baseUrl should use HTTPS in production:",o);let a=react.useMemo(()=>Po({apiKey:e,baseUrl:o,debug:r}),[e,o,r]),s=react.useMemo(()=>p??Nt,[JSON.stringify(p)]);react.useEffect(()=>{let c=oe("light","light",l);He(c);},[l]),react.useEffect(()=>(Io(),()=>Ao()),[]),react.useEffect(()=>{a.flushQueue();let c=()=>a.flushQueue();return window.addEventListener("online",c),()=>window.removeEventListener("online",c)},[a]);let h=react.useCallback(c=>{g(c);},[]),d=react.useCallback(()=>{g(null);},[]),i=react.useMemo(()=>({client:a,disabled:n,defaultUser:s,debug:r,activeModalId:u,openModal:h,closeModal:d,themeConfig:l}),[a,n,s,r,u,h,d,l]);return jsxRuntime.jsx(No.Provider,{value:i,children:t})}function D(){let e=react.useContext(No);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function Qt(e,t){let o=new Date(e).getTime();if(isNaN(o))return true;let r=Date.now()-o,n=t*24*60*60*1e3;return r>=n}function Wo(e){let{client:t,defaultUser:o}=D(),[r,n]=react.useState(false),[p,l]=react.useState(false),[u,g]=react.useState(null),[a,s]=react.useState(null);return react.useEffect(()=>{process.env.NODE_ENV!=="production"&&e.cooldownDays&&!e.onePerUser&&console.warn("[Gotcha] cooldownDays has no effect without onePerUser=true");let d=e.user?.id||o?.id;if(!d||!e.onePerUser){s(null);return}let i=false;return (async()=>{l(true);try{let f=await t.checkExistingResponse(e.elementId,d);i||(f&&e.cooldownDays&&e.cooldownDays>0&&Qt(f.createdAt,e.cooldownDays)?s(null):s(f));}catch{i||s(null);}finally{i||l(false);}})(),()=>{i=true;}},[t,e.elementId,e.user?.id,o?.id,e.onePerUser,e.cooldownDays]),{submit:react.useCallback(async d=>{n(true),g(null);try{let i=e.user?.id||o?.id,c;return e.onePerUser&&a&&i?c=await t.updateResponse(a.id,{content:d.content,title:d.title,rating:d.rating,vote:d.vote,pollSelected:d.pollSelected},i):c=await t.submitResponse({elementId:e.elementId,mode:e.mode,content:d.content,title:d.title,rating:d.rating,vote:d.vote,pollOptions:e.pollOptions,pollSelected:d.pollSelected,isBug:d.isBug,screenshot:d.screenshot,user:{...o,...e.user}}),e.onePerUser&&s({id:c.id,mode:e.mode,content:d.content??null,title:d.title??null,rating:d.rating??null,vote:d.vote??null,pollSelected:d.pollSelected??null,createdAt:c.createdAt}),e.onSuccess?.(c),c}catch(i){let c=i instanceof Error?i.message:"Something went wrong";throw g(c),e.onError?.(i instanceof Error?i:new Error(c)),i}finally{n(false);}},[t,o,e,a]),isLoading:r,isCheckingExisting:p,error:u,existingResponse:a,isEditing:!!a,clearError:()=>g(null)}}function Vo(e,t){return `${W.HIDDEN_UNTIL}_${e}_${t}`}function Yo(e,t,o){if(!o||o<=0)return false;let r=Vo(e,t),n=J(r);return n?new Date(n).getTime()>Date.now():false}function Ko(e){let{elementId:t,userId:o,hideAfterSubmitDays:r}=e,n=react.useMemo(()=>o||Ue(),[o]),[p,l]=react.useState(()=>Yo(t,n,r));react.useEffect(()=>{l(Yo(t,n,r));},[t,n,r]);let u=react.useCallback(()=>{if(!r||r<=0)return;let g=Vo(t,n),a=new Date(Date.now()+r*24*60*60*1e3);Z(g,a.toISOString()),l(true);},[t,n,r]);return {isHidden:p,markHidden:u}}function Zt(e){return `${W.VISIT_COUNT}_${e}`}function jo(e){let{elementId:t,showAfterSeconds:o,showAfterScrollPercent:r,showAfterVisits:n}=e,p=o!=null||r!=null||n!=null,[l,u]=react.useState(!o),[g,a]=react.useState(!r),[s]=react.useState(()=>{if(!n)return true;let h=Zt(t),i=parseInt(J(h)||"0",10)+1;return Z(h,String(i)),i>=n});return react.useEffect(()=>{if(!o||o<=0)return;let h=Date.now(),d=o*1e3,i=()=>{Date.now()-h>=d?u(true):c=setTimeout(i,Math.min(1e3,d-(Date.now()-h)));},c=setTimeout(i,Math.min(1e3,d));return ()=>clearTimeout(c)},[o]),react.useEffect(()=>{if(!r||r<=0)return;let h=()=>{let d=document.documentElement.scrollHeight,i=window.innerHeight;if(d<=i){a(true);return}(window.scrollY+i)/d*100>=r&&a(true);};if(h(),!g)return window.addEventListener("scroll",h,{passive:true}),()=>window.removeEventListener("scroll",h)},[r,g]),{conditionsMet:!p||l&&g&&s}}function Ne(...e){return e.filter(Boolean).join(" ")}var O=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,Xo=(e,t)=>{let o={sm:{desktop:24,mobile:28},md:{desktop:32,mobile:34},lg:{desktop:40,mobile:40}};return t?o[e].mobile:o[e].desktop};function or(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function qo({size:e,theme:t,customStyles:o,showOnHover:r,touchBehavior:n,onClick:p,isOpen:l,isParentHovered:u=false,animated:g=true,queuedCount:a=0}){let[s,h]=react.useState(false),[d,i]=react.useState(false),[c,f]=react.useState(or),[S,x]=react.useState(false),[B,k]=react.useState(false),[I,F]=react.useState(false),{themeConfig:y}=D();react.useEffect(()=>{if(h(O()),typeof window>"u")return;let $=window.matchMedia("(prefers-color-scheme: dark)"),b=H=>f(H.matches?"dark":"light");return $.addEventListener("change",b),()=>$.removeEventListener("change",b)},[]);let w=l?true:!s&&r?u:s&&n==="tap-to-reveal"?d:true;react.useEffect(()=>{if(w&&!I){let $=setTimeout(()=>F(true),600);return ()=>clearTimeout($)}},[w,I]);let E=()=>{if(s&&n==="tap-to-reveal"&&!d){i(true);return}p();},T=Xo(e,s),v=react.useMemo(()=>oe(t,c,y),[t,c,y]),z=()=>w?B?"scale(0.95)":S?"scale(1.08)":"scale(1)":"scale(0.6)",ne={width:T,height:T,borderRadius:"50%",border:v.colors.glassBorder,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:v.colors.glassBackground,backdropFilter:"blur(20px) saturate(180%)",WebkitBackdropFilter:"blur(20px) saturate(180%)",color:v.colors.glassColor,boxShadow:S?v.colors.glassHoverShadow:v.colors.glassShadow,transition:I?`all 0.3s ${v.animation.easing.spring}`:"none",opacity:w?1:0,transform:z(),filter:B?"brightness(0.95)":"brightness(1)",pointerEvents:w?"auto":"none",...g&&w&&!I?{animation:"gotcha-bubble-pop 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275) both, gotcha-arrive-glow 1200ms ease-in-out 600ms both"}:{},...o?.button};return jsxRuntime.jsxs("button",{type:"button",onClick:E,onMouseEnter:()=>x(true),onMouseLeave:()=>{x(false),k(false);},onMouseDown:()=>k(true),onMouseUp:()=>k(false),onTouchStart:()=>k(true),onTouchEnd:()=>k(false),style:ne,className:Ne("gotcha-button",l&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":l,"aria-haspopup":"dialog",children:[jsxRuntime.jsx(tr,{size:T*.65,animated:g}),a>0&&jsxRuntime.jsx("div",{"aria-label":`${a} queued`,style:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",backgroundColor:v.colors.warning,border:"1.5px solid rgba(255,255,255,0.9)"}})]})}function tr({size:e,animated:t=true}){let[o,r]=react.useState(false);return react.useEffect(()=>{r(true);},[]),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{fontFamily:"'Carter One', cursive",fontSize:e,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",marginTop:e*.05,marginRight:e*.05,userSelect:"none",opacity:t?0:o?1:0,...t&&o?{animation:"gotcha-letter-in 350ms cubic-bezier(0.25, 0.46, 0.45, 0.94) 200ms both"}:{}},children:"G"})}function P({size:e=16,color:t="currentColor"}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{animation:"gotcha-spin 0.8s linear infinite"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"2",strokeOpacity:"0.12"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"2",strokeLinecap:"round",style:{animation:"gotcha-dash 1.2s ease-in-out infinite"}})]})}function Zo({src:e,onRemove:t,resolvedTheme:o}){return jsxRuntime.jsxs("div",{style:{position:"relative",marginTop:10,borderRadius:o.borders.radius.md,overflow:"hidden",border:`1px solid ${o.colors.border}`},children:[jsxRuntime.jsx("img",{src:e,alt:"Screenshot",style:{display:"block",width:"100%",maxHeight:120,objectFit:"cover"}}),jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":"Remove screenshot",style:{position:"absolute",top:4,right:4,width:22,height:22,borderRadius:"50%",border:"none",backgroundColor:"rgba(0,0,0,0.6)",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,lineHeight:1},children:jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]})}function rt({resolvedTheme:e,placeholder:t,submitText:o,isLoading:r,onSubmit:n,customStyles:p,initialValues:l,isEditing:u=false,showText:g=true,showRating:a=true,enableBugFlag:s=false,bugFlagLabel:h,enableScreenshot:d=false}){let[i,c]=react.useState(l?.content||""),[f,S]=react.useState(l?.rating??null),[x,B]=react.useState(false),[k,I]=react.useState(false),[F,y]=react.useState(null),[w,E]=react.useState(false);react.useEffect(()=>{I(O());},[]),react.useEffect(()=>{l?.content!==void 0&&c(l.content||""),l?.rating!==void 0&&S(l.rating??null);},[l?.content,l?.rating]);let T=g&&a?i.trim().length>0||f!==null:g?i.trim().length>0:a?f!==null:false,v=async()=>{E(true);try{let{captureScreenshot:b}=await Promise.resolve().then(()=>(tt(),ot)),H=await b();H&&y(H);}catch{}finally{E(false);}},z=b=>{b.preventDefault(),T&&n({content:g&&i.trim()?i.trim():void 0,rating:a&&f!==null?f:void 0,isBug:x||void 0,screenshot:F||void 0});},ne={width:"100%",padding:k?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:k?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:k?100:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)",...p?.input},$={width:"100%",padding:k?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:e.colors.buttonBackground,color:e.colors.buttonColor,fontSize:k?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",...p?.submitButton};return jsxRuntime.jsxs("form",{onSubmit:z,children:[a&&jsxRuntime.jsx("div",{style:{marginBottom:g?k?16:12:0,...g?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsxRuntime.jsx(lr,{value:f,onChange:S,theme:e,isTouch:k,large:!g})}),g&&jsxRuntime.jsx("textarea",{value:i,onChange:b=>c(b.target.value),placeholder:t||"Share your thoughts...",maxLength:5e3,style:ne,disabled:r,"aria-label":"Your feedback",onFocus:b=>{b.currentTarget.style.borderColor=e.colors.inputBorderFocus,b.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,b.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:b=>{b.currentTarget.style.borderColor=e.colors.inputBorder,b.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.04)",b.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),s&&jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":x,onClick:()=>B(!x),style:{display:"flex",alignItems:"center",gap:7,width:"100%",marginTop:10,padding:"7px 10px",border:`1px solid ${x?e.colors.warningBorder:e.colors.border}`,borderRadius:7,backgroundColor:x?e.colors.warningSurface:"transparent",cursor:"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,fontFamily:e.typography.fontFamily,...p?.bugFlag},onMouseEnter:b=>{x||(b.currentTarget.style.backgroundColor=e.colors.surfaceHover===e.colors.inputBackgroundFocus?"rgba(0,0,0,0.02)":e.colors.surfaceHover);},onMouseLeave:b=>{x||(b.currentTarget.style.backgroundColor="transparent");},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:x?e.colors.warningActive:e.colors.textDisabled,strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,transition:`stroke ${e.animation.duration.fast}`},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"})}),jsxRuntime.jsx("span",{style:{fontSize:12,fontWeight:x?e.typography.fontWeight.medium:e.typography.fontWeight.normal,color:x?e.colors.warningActive:e.colors.textDisabled,transition:`color ${e.animation.duration.fast}`,letterSpacing:"0.01em"},children:x?"Issue reported":h||"Report an issue"}),jsxRuntime.jsx("div",{style:{marginLeft:"auto",width:28,height:16,borderRadius:8,backgroundColor:x?e.colors.warning:e.colors.border,position:"relative",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,flexShrink:0},children:jsxRuntime.jsx("div",{style:{position:"absolute",top:2,left:x?14:2,width:12,height:12,borderRadius:"50%",backgroundColor:x?"#ffffff":e.colors.textDisabled,transition:`left ${e.animation.duration.fast} ${e.animation.easing.default}, background-color ${e.animation.duration.fast}`,boxShadow:"0 1px 2px rgba(0,0,0,0.15)"}})})]}),s&&d&&x&&!F&&jsxRuntime.jsxs("button",{type:"button",onClick:v,disabled:w,style:{display:"flex",alignItems:"center",gap:6,width:"100%",marginTop:8,padding:"7px 10px",border:`1px solid ${e.colors.border}`,borderRadius:7,backgroundColor:"transparent",cursor:w?"not-allowed":"pointer",fontFamily:e.typography.fontFamily,fontSize:12,color:e.colors.textSecondary,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},onMouseEnter:b=>{b.currentTarget.style.backgroundColor=e.colors.surfaceHover;},onMouseLeave:b=>{b.currentTarget.style.backgroundColor="transparent";},children:[w?jsxRuntime.jsx(P,{size:14,color:e.colors.textSecondary}):jsxRuntime.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"10",r:"3"}),jsxRuntime.jsx("path",{d:"M2 17l4-4 3 3 4-4 9 9"})]}),w?"Capturing...":"Capture screenshot"]}),s&&d&&x&&F&&jsxRuntime.jsx(Zo,{src:F,onRemove:()=>y(null),resolvedTheme:e}),jsxRuntime.jsxs("button",{type:"submit",disabled:r||!T,style:{...$,marginTop:12,opacity:r?.8:1,backgroundColor:T?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:T?e.colors.buttonColor:e.colors.buttonColorDisabled,display:"flex",alignItems:"center",justifyContent:"center",gap:8,...r?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:b=>{b.currentTarget.disabled||(b.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,b.currentTarget.style.transform="translateY(-1px)",b.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:b=>{b.currentTarget.disabled||(b.currentTarget.style.backgroundColor=e.colors.buttonBackground,b.currentTarget.style.transform="translateY(0)",b.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(P,{size:k?18:16,color:e.colors.buttonColor}),r?u?"Updating...":"Submitting...":u?"Update":o]})]})}function lr({value:e,onChange:t,theme:o,isTouch:r,large:n=false}){let[p,l]=react.useState(null),[u,g]=react.useState(null),a=react.useRef(),s=n?r?36:28:r?28:18,h=n?r?8:5:r?8:3;react.useEffect(()=>()=>{clearTimeout(a.current);},[]);let d=i=>{g(i),t(i),clearTimeout(a.current),a.current=setTimeout(()=>g(null),300);};return jsxRuntime.jsx("div",{style:{display:"flex",gap:n?r?8:6:r?6:2},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(i=>{let c=(p??e??0)>=i;return jsxRuntime.jsx("button",{type:"button",onClick:()=>d(i),onMouseEnter:()=>l(i),onMouseLeave:()=>l(null),"aria-label":`Rate ${i} out of 5`,"aria-pressed":e===i,style:{background:"none",border:"none",cursor:"pointer",padding:h,color:c?o.colors.starFilled:o.colors.starEmpty,transition:`color 0.15s ${o.animation.easing.default}`,transform:u===i?"scale(1)":p!==null&&p>=i?"scale(1.1)":"scale(1)",animation:u===i?`gotcha-star-pulse 0.3s ${o.animation.easing.spring}`:"none",filter:c?`drop-shadow(0 0 3px ${o.colors.starFilled}40)`:"none",transitionDelay:`${(i-1)*30}ms`},children:jsxRuntime.jsx("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"currentColor",children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})},i)})})}function nt({resolvedTheme:e,isLoading:t,onSubmit:o,initialVote:r,isEditing:n=false,labels:p}){let[l,u]=react.useState(false),[g,a]=react.useState(r||null),[s,h]=react.useState(r||null);react.useEffect(()=>{u(O());},[]),react.useEffect(()=>{r!==void 0&&(h(r),a(r));},[r]),react.useEffect(()=>{!t&&!n&&a(null);},[t,n]);let d=f=>{a(f),o({vote:f});},i=f=>{let S=s===f,x=f==="up"?e.colors.voteUp:e.colors.voteDown,B=f==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,k=f==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return {flex:1,minWidth:0,overflow:"hidden",padding:l?"14px 18px":"10px 14px",border:S?`2px solid ${k}`:`1px solid ${e.colors.border}`,borderRadius:e.borders.radius.lg-2,background:S?`linear-gradient(135deg, ${B}, ${B})`:e.colors.surface,color:S?x:e.colors.textSecondary,fontSize:l?28:24,fontFamily:e.typography.fontFamily,cursor:t?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,display:"flex",alignItems:"center",justifyContent:"center",gap:l?10:8}},c=l?24:20;return jsxRuntime.jsxs("div",{style:{display:"flex",gap:l?12:10},role:"group","aria-label":"Vote",children:[jsxRuntime.jsx("button",{type:"button",onClick:()=>d("up"),disabled:t,style:i("up"),"aria-label":"Vote up - I like this","aria-pressed":s==="up",onMouseEnter:f=>{t||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:t&&g==="up"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P,{size:c,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:n?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(cr,{size:c}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:p?.up||(s==="up"?"Liked":"Like")})]})}),jsxRuntime.jsx("button",{type:"button",onClick:()=>d("down"),disabled:t,style:i("down"),"aria-label":"Vote down - I don't like this","aria-pressed":s==="down",onMouseEnter:f=>{t||(f.currentTarget.style.transform="translateY(-2px) scale(1.02)",f.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:f=>{f.currentTarget.style.transform="translateY(0) scale(1)",f.currentTarget.style.boxShadow="none";},children:t&&g==="down"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P,{size:c,color:e.colors.text}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:n?"Updating...":"Sending..."})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(dr,{size:c}),jsxRuntime.jsx("span",{style:{fontSize:l?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:p?.down||(s==="down"?"Disliked":"Dislike")})]})})]})}function cr({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function dr({size:e=24}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function it({resolvedTheme:e,options:t,allowMultiple:o,isLoading:r,onSubmit:n,initialSelected:p,isEditing:l=false}){let[u,g]=react.useState(p||[]),[a,s]=react.useState(false);react.useEffect(()=>{s(O());},[]),react.useEffect(()=>{p&&g(p);},[p]);let h=c=>{g(o?f=>f.includes(c)?f.filter(S=>S!==c):[...f,c]:f=>f.includes(c)?[]:[c]);},d=()=>{u.length!==0&&n({pollSelected:u});},i=(c,f)=>{let S=u.includes(c);return {width:"100%",padding:a?"12px 14px":"9px 12px",border:`1px solid ${S?e.colors.pollSelectedBorder:e.colors.pollBorder}`,borderRadius:e.borders.radius.lg-2,backgroundColor:S?e.colors.pollSelectedBackground:e.colors.pollBackground,color:S?e.colors.pollSelectedColor:e.colors.pollColor,fontSize:a?15:e.typography.fontSize.sm,fontWeight:S?e.typography.fontWeight.semibold:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all 0.2s ${e.animation.easing.default}`,textAlign:"left",letterSpacing:"0.01em",display:"flex",alignItems:"center",gap:8,animation:`gotcha-fade-up ${e.animation.duration.normal} ${e.animation.easing.default} both`,animationDelay:`${f*.05}s`}};return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:a?8:6},role:"group","aria-label":o?"Select one or more options":"Select an option",children:t.map((c,f)=>{let S=u.includes(c);return jsxRuntime.jsxs("button",{type:"button",onClick:()=>h(c),disabled:r,style:i(c,f),"aria-pressed":S,onMouseEnter:x=>{r||(x.currentTarget.style.transform="translateX(2px)");},onMouseLeave:x=>{x.currentTarget.style.transform="translateX(0)";},children:[jsxRuntime.jsx("span",{style:{width:16,height:16,borderRadius:o?4:"50%",border:`2px solid ${S?e.colors.pollCheckSelectedBorder:e.colors.pollCheckBorder}`,backgroundColor:S?e.colors.pollCheckSelectedBg:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast}`},children:S&&jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),c]},c)})}),jsxRuntime.jsxs("button",{type:"button",onClick:d,disabled:r||u.length===0,style:{width:"100%",marginTop:12,padding:a?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:u.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,color:u.length===0?e.colors.buttonColorDisabled:e.colors.buttonColor,fontSize:a?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||u.length===0?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:r?.8:1,...r?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{}},onMouseEnter:c=>{c.currentTarget.disabled||(c.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:c=>{c.currentTarget.disabled||(c.currentTarget.style.backgroundColor=u.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,c.currentTarget.style.transform="translateY(0)",c.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(P,{size:a?18:16,color:e.colors.buttonColor}),r?l?"Updating...":"Submitting...":l?"Update":"Submit"]})]})}function ct({resolvedTheme:e,submitText:t,isLoading:o,onSubmit:r,customStyles:n,showFollowUp:p=true,followUpPlaceholder:l,lowLabel:u="Not likely",highLabel:g="Very likely",initialValues:a,isEditing:s=false}){let[h,d]=react.useState(a?.rating??null),[i,c]=react.useState(a?.content||""),[f,S]=react.useState(false),[x,B]=react.useState(null);react.useEffect(()=>{S(O());},[]),react.useEffect(()=>{a?.rating!==void 0&&d(a.rating??null),a?.content!==void 0&&c(a.content||"");},[a?.rating,a?.content]);let k=h!==null,I=e.colors.npsColors;return jsxRuntime.jsxs("form",{onSubmit:y=>{y.preventDefault(),k&&r({rating:h??void 0,content:p&&i.trim()?i.trim():void 0});},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{style:{display:"flex",gap:f?4:6,justifyContent:"center"},role:"group","aria-label":"NPS Score",children:Array.from({length:11},(y,w)=>{let E=h===w,T=x===w,v=I[w];return jsxRuntime.jsx("button",{type:"button",onClick:()=>d(w),onMouseEnter:()=>B(w),onMouseLeave:()=>B(null),"aria-label":`Score ${w} out of 10`,"aria-pressed":E,style:{flex:1,minWidth:0,height:f?34:32,borderRadius:e.borders.radius.sm,border:E?`2px solid ${v}`:`1.5px solid ${v}25`,backgroundColor:E?v:T?`${v}25`:`${v}0c`,color:E?"#fff":T?v:`${v}bb`,fontSize:12,fontWeight:E?e.typography.fontWeight.bold:e.typography.fontWeight.semibold,fontFamily:e.typography.fontFamily,fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:`all 0.2s ${e.animation.easing.spring}`,transform:E?"scale(1.08)":T?"scale(1.04)":"scale(1)",boxShadow:E?`0 0 12px ${v}40`:"none",...n?.npsButton,...E?n?.npsButtonSelected:{}},children:w},w)})}),jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6,padding:"0 2px",...n?.npsLabels},children:[jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:u}),jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:g})]})]}),p&&h!==null&&jsxRuntime.jsx("textarea",{value:i,onChange:y=>c(y.target.value),placeholder:l||"What's the main reason for your score?",maxLength:5e3,style:{width:"100%",padding:f?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"vertical",minHeight:f?80:60,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,animation:`gotcha-expand-in 0.3s ${e.animation.easing.default} both`,overflow:"hidden",...n?.input},disabled:o,"aria-label":"Follow-up feedback",onFocus:y=>{y.currentTarget.style.borderColor=e.colors.inputBorderFocus,y.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,y.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:y=>{y.currentTarget.style.borderColor=e.colors.inputBorder,y.currentTarget.style.boxShadow="none",y.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),jsxRuntime.jsxs("button",{type:"submit",disabled:o||!k,style:{width:"100%",padding:f?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:k?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:k?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:f?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:o?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",opacity:o?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginTop:12,...o?{backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"gotcha-shimmer 1.5s ease infinite"}:{},...n?.submitButton},onMouseEnter:y=>{y.currentTarget.disabled||(y.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,y.currentTarget.style.transform="translateY(-1px)",y.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:y=>{y.currentTarget.disabled||(y.currentTarget.style.backgroundColor=k?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,y.currentTarget.style.transform="translateY(0)",y.currentTarget.style.boxShadow="none");},children:[o&&jsxRuntime.jsx(P,{size:f?18:16,color:e.colors.buttonColor}),o?s?"Updating...":"Submitting...":s?"Update":t]})]})}function gt({resolvedTheme:e,promptText:t,placeholder:o,isLoading:r,onSubmit:n}){let[p,l]=react.useState(""),[u,g]=react.useState(false);return react.useEffect(()=>{g(O());},[]),jsxRuntime.jsxs("form",{onSubmit:s=>{s.preventDefault(),p.trim()&&n(p.trim());},children:[jsxRuntime.jsx("p",{style:{margin:"0 0 12px 0",fontSize:e.typography.fontSize.sm,color:e.colors.textSecondary,lineHeight:1.4,fontFamily:e.typography.fontFamily},children:t}),jsxRuntime.jsx("textarea",{value:p,onChange:s=>l(s.target.value),placeholder:o||"Tell us more...",maxLength:5e3,disabled:r,"aria-label":"Follow-up feedback",style:{width:"100%",padding:u?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:u?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:u?100:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}, box-shadow ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.5,boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)"},onFocus:s=>{s.currentTarget.style.borderColor=e.colors.inputBorderFocus,s.currentTarget.style.boxShadow=`0 0 0 3px ${e.colors.inputFocusRing}`,s.currentTarget.style.backgroundColor=e.colors.inputBackgroundFocus;},onBlur:s=>{s.currentTarget.style.borderColor=e.colors.inputBorder,s.currentTarget.style.boxShadow="inset 0 1px 2px rgba(0,0,0,0.04)",s.currentTarget.style.backgroundColor=e.colors.inputBackground;}}),jsxRuntime.jsxs("button",{type:"submit",disabled:r||!p.trim(),style:{width:"100%",marginTop:12,padding:u?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:p.trim()?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:p.trim()?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:u?e.typography.fontSize.lg:e.typography.fontSize.md,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:r?.8:1},onMouseEnter:s=>{s.currentTarget.disabled||(s.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover,s.currentTarget.style.transform="translateY(-1px)",s.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:s=>{s.currentTarget.disabled||(s.currentTarget.style.backgroundColor=e.colors.buttonBackground,s.currentTarget.style.transform="translateY(0)",s.currentTarget.style.boxShadow="none");},children:[r&&jsxRuntime.jsx(P,{size:u?18:16,color:e.colors.buttonColor}),r?"Sending...":"Submit"]})]})}function mo({mode:e,theme:t,customStyles:o,promptText:r,placeholder:n,submitText:p,thankYouMessage:l,isLoading:u,isCheckingExisting:g=false,isSubmitted:a,phase:s="form",followUpConfig:h,followUpLoading:d=false,onFollowUpSubmit:i,error:c,existingResponse:f,isEditing:S=false,showText:x=true,showRating:B=true,voteLabels:k,options:I,allowMultiple:F=false,npsQuestion:y,npsFollowUp:w=true,npsFollowUpPlaceholder:E,npsLowLabel:T,npsHighLabel:v,enableBugFlag:z=false,bugFlagLabel:ne,enableScreenshot:$=false,onSubmit:b,onClose:H,anchorRect:Y,useFixedPosition:je=false}){let Me=react.useRef(null),Ge=react.useRef(null),pe=react.useRef(H);pe.current=H;let[L,Xe]=react.useState(false),[De,Fe]=react.useState("light"),{themeConfig:fe}=D();react.useEffect(()=>{Xe(window.innerWidth<640);let G=window.matchMedia("(prefers-color-scheme: dark)");Fe(G.matches?"dark":"light");let j=_=>Fe(_.matches?"dark":"light");return G.addEventListener("change",j),()=>G.removeEventListener("change",j)},[]);let m=react.useMemo(()=>oe(t,De,fe),[t,De,fe]);react.useEffect(()=>{He(m);},[m]);let me=typeof window>"u"||!Y?false:window.innerHeight-Y.bottom<300;react.useEffect(()=>{let G=Me.current;if(!G)return;Ge.current?.focus();let j=_=>{if(_.key==="Escape"){pe.current();return}if(_.key==="Tab"){let ce=G.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),ze=ce[0],Se=ce[ce.length-1];_.shiftKey&&document.activeElement===ze?(_.preventDefault(),Se?.focus()):!_.shiftKey&&document.activeElement===Se&&(_.preventDefault(),ze?.focus());}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);let ae=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":e==="nps"?y||"How likely are you to recommend us?":"What do you think of this feature?",he=L?24:20,be=e==="nps"?420:340,qe=L?"gotcha-modal-enter-center":me?"gotcha-modal-enter-above":"gotcha-modal-enter",ye=typeof window<"u"?window.innerHeight:0,V=L?{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"calc(100vw - 32px)",maxWidth:be,padding:he,borderRadius:m.borders.radius.lg+2,background:m.colors.backgroundGradient,color:m.colors.text,boxShadow:m.shadows.modal,border:`${m.borders.width}px solid ${m.colors.border}`,zIndex:9999,fontFamily:m.typography.fontFamily,...o?.modal,textAlign:"left"}:je&&Y&&ye?{position:"fixed",left:Y.left+Y.width/2,width:be,padding:he,borderRadius:m.borders.radius.lg,background:m.colors.backgroundGradient,color:m.colors.text,boxShadow:m.shadows.modal,border:`${m.borders.width}px solid ${m.colors.border}`,zIndex:99999,fontFamily:m.typography.fontFamily,...me?{bottom:ye-Y.top+8,transform:"translateX(-50%)"}:{top:Y.bottom+8,transform:"translateX(-50%)"},...o?.modal,textAlign:"left"}:{position:"absolute",left:"50%",width:be,padding:he,borderRadius:m.borders.radius.lg,background:m.colors.backgroundGradient,color:m.colors.text,boxShadow:m.shadows.modal,border:`${m.borders.width}px solid ${m.colors.border}`,zIndex:9999,fontFamily:m.typography.fontFamily,...me?{bottom:"100%",marginBottom:8,transform:"translateX(-50%)"}:{top:"100%",marginTop:8,transform:"translateX(-50%)"},...o?.modal,textAlign:"left"},K=G=>L?{}:{animation:`gotcha-fade-up ${m.animation.duration.normal} ${m.animation.easing.default} both`,animationDelay:`${G*.05}s`},se=l==="Gotcha!"||l==="Thanks for your feedback!";return jsxRuntime.jsxs("div",{ref:Me,role:"dialog","aria-modal":"true","aria-label":a?"Feedback submitted":void 0,"aria-labelledby":a?void 0:"gotcha-modal-title","data-gotcha":true,style:V,className:Ne("gotcha-modal",qe),children:[jsxRuntime.jsx("button",{ref:Ge,type:"button",onClick:H,"aria-label":"Close feedback form",style:{position:"absolute",top:L?10:6,right:L?10:6,width:L?40:36,height:L?40:36,border:"none",background:"transparent",outline:"none",cursor:"pointer",zIndex:10,color:m.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:m.borders.radius.sm,transition:`all ${m.animation.duration.fast} ${m.animation.easing.default}`,...o?.closeButton},onMouseEnter:G=>{G.currentTarget.style.backgroundColor=m.colors.closeButtonBg,G.currentTarget.style.color=m.colors.closeButtonHover;},onMouseLeave:G=>{G.currentTarget.style.backgroundColor="transparent",G.currentTarget.style.color=m.colors.closeButton;},children:jsxRuntime.jsx("svg",{width:L?16:14,height:L?16:14,viewBox:"0 0 14 14",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!a&&jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:L?m.typography.fontSize.lg:m.typography.fontSize.md,fontWeight:m.typography.fontWeight.semibold,paddingRight:L?44:38,letterSpacing:"-0.02em",lineHeight:1.4,textAlign:"left",fontFamily:m.typography.fontFamily,...K(0),...o?.title},children:r||ae}),a&&jsxRuntime.jsxs("div",{style:{textAlign:"center",padding:"28px 0 20px"},children:[jsxRuntime.jsx("div",{style:{width:52,height:52,borderRadius:"50%",backgroundColor:m.colors.successSurface,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",animation:`gotcha-success-pop 0.4s ${m.animation.easing.spring} both, gotcha-glow-pulse 0.8s ease 0.4s`,...o?.successIcon},children:jsxRuntime.jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx("path",{d:"M20 6L9 17L4 12",stroke:m.colors.success,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:24,strokeDashoffset:0,animation:"gotcha-check-draw 0.4s ease 0.2s both"}})})}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:se?22:m.typography.fontSize.md,fontWeight:se?m.typography.fontWeight.bold:m.typography.fontWeight.medium,color:m.colors.text,fontFamily:se?"'Carter One', cursive":m.typography.fontFamily,animation:"gotcha-success-text 0.3s ease 0.3s both",...o?.successMessage},children:se?"Gotcha!":l}),se&&jsxRuntime.jsx("p",{style:{margin:"6px 0 0",fontSize:m.typography.fontSize.sm,fontWeight:m.typography.fontWeight.normal,color:m.colors.textSecondary,animation:"gotcha-success-text 0.3s ease 0.45s both"},children:"Thanks for your feedback!"})]}),c&&!a&&jsxRuntime.jsxs("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:m.borders.radius.sm,backgroundColor:m.colors.errorSurface,border:`1px solid ${m.colors.errorBorder}`,color:m.colors.error,fontSize:m.typography.fontSize.sm,lineHeight:1.4,display:"flex",alignItems:"center",gap:8,...K(1),...o?.errorMessage},children:[jsxRuntime.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),c]}),s==="followUp"&&h&&i&&jsxRuntime.jsx("div",{style:K(1),children:jsxRuntime.jsx(gt,{resolvedTheme:m,promptText:h.promptText,placeholder:h.placeholder,isLoading:d,onSubmit:i})}),s==="form"&&g&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"24px 0",...K(1)},children:jsxRuntime.jsx(P,{size:24,color:m.colors.textSecondary})}),s==="form"&&!g&&jsxRuntime.jsxs("div",{style:K(1),children:[e==="feedback"&&jsxRuntime.jsx(rt,{resolvedTheme:m,placeholder:n,submitText:p,isLoading:u,onSubmit:b,customStyles:o,initialValues:f?{content:f.content,rating:f.rating}:void 0,isEditing:S,showText:x,showRating:B,enableBugFlag:z,bugFlagLabel:ne,enableScreenshot:$}),e==="vote"&&jsxRuntime.jsx(nt,{resolvedTheme:m,isLoading:u,onSubmit:b,initialVote:f?.vote||void 0,isEditing:S,labels:k}),e==="nps"&&jsxRuntime.jsx(ct,{resolvedTheme:m,submitText:p,isLoading:u,onSubmit:b,showFollowUp:w,followUpPlaceholder:E,lowLabel:T,highLabel:v,customStyles:o,initialValues:f?{rating:f.rating,content:f.content}:void 0,isEditing:S}),e==="poll"&&I&&I.length>0&&jsxRuntime.jsx(it,{resolvedTheme:m,options:I,allowMultiple:F,isLoading:u,onSubmit:b,initialSelected:f?.pollSelected||void 0,isEditing:S})]}),jsxRuntime.jsxs("div",{"aria-live":"polite",className:"sr-only",style:{position:"absolute",left:-9999},children:[a&&"Thank you! Your feedback has been submitted.",c&&`Error: ${c}`]})]})}function pr({elementId:e,user:t,mode:o="feedback",showText:r=true,showRating:n=true,voteLabels:p,options:l,allowMultiple:u=false,npsQuestion:g,npsFollowUp:a=true,npsFollowUpPlaceholder:s,npsLowLabel:h,npsHighLabel:d,enableBugFlag:i=false,bugFlagLabel:c,enableScreenshot:f=false,onePerUser:S=false,cooldownDays:x,hideAfterSubmitDays:B,showAfterSeconds:k,showAfterScrollPercent:I,showAfterVisits:F,followUp:y,animated:w=true,position:E=q.POSITION,size:T=q.SIZE,theme:v=q.THEME,customStyles:z,visible:ne=true,showOnHover:$=q.SHOW_ON_HOVER,touchBehavior:b=q.TOUCH_BEHAVIOR,promptText:H,placeholder:Y,submitText:je=q.SUBMIT_TEXT,thankYouMessage:Me=q.THANK_YOU_MESSAGE,onSubmit:Ge,onOpen:pe,onClose:L,onError:Xe}){let{disabled:De,activeModalId:Fe,openModal:fe,closeModal:m,defaultUser:me,client:ae}=D(),{conditionsMet:he}=jo({elementId:e,showAfterSeconds:k,showAfterScrollPercent:I,showAfterVisits:F}),{isHidden:be,markHidden:qe}=Ko({elementId:e,userId:t?.id||me?.id,hideAfterSubmitDays:B}),[ye,V]=react.useState("form"),[K,se]=react.useState(null),[G,j]=react.useState(false),[_,ce]=react.useState(0),[ze,Se]=react.useState(false),[bt,yt]=react.useState(null),[xe,St]=react.useState(false),[yo,xt]=react.useState(false),Le=react.useRef(null),ve=react.useRef(),we=react.useRef(null);react.useEffect(()=>(xt(true),St(window.innerWidth<640),()=>{clearTimeout(ve.current);}),[]),react.useEffect(()=>{ce(ae.getQueueLength());let C=()=>{setTimeout(()=>ce(ae.getQueueLength()),2e3);};return window.addEventListener("online",C),()=>window.removeEventListener("online",C)},[ae]);let X=Fe===e;react.useEffect(()=>{X||(V("form"),clearTimeout(ve.current));},[X]),react.useEffect(()=>{if(!X||!xe)return;let C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=C;}},[X,xe]),react.useEffect(()=>{if(!$)return;let C=Le.current;if(!C)return;let N=C.parentElement;if(!N)return;let ko=()=>Se(true),To=()=>Se(false);return N.addEventListener("mouseenter",ko),N.addEventListener("mouseleave",To),()=>{N.removeEventListener("mouseenter",ko),N.removeEventListener("mouseleave",To);}},[$]);let{submit:So,isLoading:vt,isCheckingExisting:wt,error:kt,existingResponse:Tt,isEditing:xo}=Wo({elementId:e,mode:o,pollOptions:l,user:t,onePerUser:S,cooldownDays:x,onSuccess:C=>{se(C.id),B&&qe(),Ge?.(C),y&&we.current&&(y.ratingThreshold!=null&&we.current.rating!=null&&we.current.rating<=y.ratingThreshold||y.onNegativeVote&&we.current.vote==="down")&&o!=="poll"?V("followUp"):(V("success"),ve.current=setTimeout(()=>{m(),V("form");},3e3));},onError:C=>{console.warn("[Gotcha] Submission failed:",C instanceof Error?C.message:C),Xe?.(C);}}),Ct=react.useCallback(()=>{Le.current&&yt(Le.current.getBoundingClientRect()),fe(e),pe?.();},[e,fe,pe]),vo=react.useCallback(()=>{clearTimeout(ve.current),m(),V("form"),L?.();},[m,L]),Et=react.useCallback(C=>{we.current={rating:C.rating,vote:C.vote},So(C);},[So]),Rt=react.useCallback(async C=>{if(K){j(true);try{await ae.updateResponse(K,{content:C});}catch(N){console.warn("[Gotcha] Follow-up submission failed:",N instanceof Error?N.message:N);}finally{j(false),V("success"),ve.current=setTimeout(()=>{m(),V("form");},3e3);}}},[K,m,ae]),Bt=S&&xo?"Update":je;if(De||!ne||be||!he)return null;let It={"top-right":{position:"absolute",top:0,right:0,transform:"translate(50%, -50%)"},"top-left":{position:"absolute",top:0,left:0,transform:"translate(-50%, -50%)"},"bottom-right":{position:"absolute",bottom:0,right:0,transform:"translate(50%, 50%)"},"bottom-left":{position:"absolute",bottom:0,left:0,transform:"translate(-50%, 50%)"},inline:{position:"relative",display:"inline-flex"}},wo={mode:o,theme:v,customStyles:z,promptText:H,placeholder:Y,submitText:Bt,thankYouMessage:Me,isLoading:vt,isCheckingExisting:S&&wt,isSubmitted:ye==="success",phase:ye,followUpConfig:y,followUpLoading:G,onFollowUpSubmit:Rt,error:kt,existingResponse:S?Tt:null,isEditing:S&&xo,showText:r,showRating:n,voteLabels:p,options:l,allowMultiple:u,npsQuestion:g,npsFollowUp:a,npsFollowUpPlaceholder:s,npsLowLabel:h,npsHighLabel:d,enableBugFlag:i,bugFlagLabel:c,enableScreenshot:f,onSubmit:Et,onClose:vo,anchorRect:bt||void 0,useFixedPosition:!xe};return jsxRuntime.jsxs("div",{ref:Le,style:{...It[E],zIndex:X?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(qo,{size:T,theme:v,customStyles:z,showOnHover:$,touchBehavior:b,onClick:Ct,isOpen:X,isParentHovered:ze,animated:w,queuedCount:_}),X&&!xe&&yo&&reactDom.createPortal(jsxRuntime.jsx(mo,{...wo}),document.body),X&&xe&&yo&&reactDom.createPortal(jsxRuntime.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:"rgba(0,0,0,0.4)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},className:"gotcha-overlay-enter",onClick:vo,children:jsxRuntime.jsx("div",{onClick:C=>C.stopPropagation(),children:jsxRuntime.jsx(mo,{...wo})})}),document.body)]})}function mt({elementId:e,refreshInterval:t}){let{client:o}=D(),[r,n]=react.useState(null),[p,l]=react.useState(true),[u,g]=react.useState(null);return react.useEffect(()=>{let a=false,s=async()=>{try{let d=await o.getScore(e);a||(n(d),g(null));}catch(d){a||g(d instanceof Error?d.message:"Failed to load score");}finally{a||l(false);}};s();let h;return t&&t>0&&(h=setInterval(s,t)),()=>{a=true,h&&clearInterval(h);}},[o,e,t]),{score:r,isLoading:p,error:u}}var Sr={sm:{fontSize:11,ratingFontSize:13,starSize:13,gap:5,pillPx:8,pillPy:4,barHeight:3,iconSize:12},md:{fontSize:12.5,ratingFontSize:15,starSize:15,gap:6,pillPx:10,pillPy:5,barHeight:4,iconSize:14},lg:{fontSize:14,ratingFontSize:18,starSize:18,gap:8,pillPx:12,pillPy:6,barHeight:5,iconSize:16}};function xr({rating:e,size:t,filledColor:o,emptyColor:r}){let n=`gotcha-star-clip-${Math.random().toString(36).slice(2,8)}`,p=[];for(let l=1;l<=5;l++){let u=Math.min(1,Math.max(0,e-(l-1))),g=`${n}-${l}`;p.push(jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",style:{display:"block"},children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:g,children:jsxRuntime.jsx("rect",{x:"0",y:"0",width:24*u,height:"24"})})}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:r}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:o,clipPath:`url(#${g})`})]},l));}return jsxRuntime.jsx("span",{style:{display:"inline-flex",gap:Math.max(1,t*.08),alignItems:"center"},children:p})}function vr({rate:e,height:t,filledColor:o,trackColor:r}){return jsxRuntime.jsx("span",{style:{display:"inline-block",width:48,height:t,borderRadius:t,backgroundColor:r,overflow:"hidden",verticalAlign:"middle"},children:jsxRuntime.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:t,background:o,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function wr({size:e,color:t}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:t,style:{display:"block"},children:jsxRuntime.jsx("path",{d:"M2 20h2c.55 0 1-.45 1-1v-9c0-.55-.45-1-1-1H2v11zm19.83-7.12c.11-.25.17-.52.17-.8V11c0-1.1-.9-2-2-2h-5.5l.92-4.65c.05-.22.02-.46-.08-.66a4.8 4.8 0 00-.88-1.12L14 2 7.59 8.41C7.21 8.79 7 9.3 7 9.83v7.84C7 18.95 8.05 20 9.34 20h8.11c.7 0 1.36-.37 1.72-.97l2.66-6.15z"})})}function kr({elementId:e,variant:t="stars",showCount:o=true,size:r="md",theme:n="auto",refreshInterval:p,style:l}){let{score:u,isLoading:g}=mt({elementId:e,refreshInterval:p}),[a,s]=react.useState("light");react.useEffect(()=>{if(typeof window>"u")return;let T=window.matchMedia("(prefers-color-scheme: dark)");s(T.matches?"dark":"light");let v=z=>s(z.matches?"dark":"light");return T.addEventListener("change",v),()=>T.removeEventListener("change",v)},[]);let{themeConfig:h}=D(),d=react.useMemo(()=>oe(n,a,h),[n,a,h]);if(g||!u)return null;let i=Sr[r],c=d.colors.text,f=d.colors.textDisabled,S=d.colors.starFilled,x=d.colors.starEmpty,B=d.colors.voteUp,k=d.colors.starEmpty,I={display:"inline-flex",alignItems:"center",gap:i.gap,fontFamily:d.typography.fontFamily,lineHeight:1,letterSpacing:"-0.01em",WebkitFontSmoothing:"antialiased",...l},F=(T,v)=>{let z=T===1?v:`${v}s`;return `${T.toLocaleString()} ${z}`};if(t==="votes"){let{voteCount:T,positiveRate:v}=u,z=T.up+T.down;return z===0?null:jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx(wr,{size:i.iconSize,color:B}),jsxRuntime.jsxs("span",{style:{fontSize:i.ratingFontSize,fontWeight:600,color:B,fontVariantNumeric:"tabular-nums"},children:[v,"%"]}),jsxRuntime.jsx(vr,{rate:v??0,height:i.barHeight,filledColor:B,trackColor:k}),o&&jsxRuntime.jsx("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:F(z,"vote")})]})}let{averageRating:y,totalResponses:w}=u;if(y===null||w===0)return null;let E=y.toFixed(1);return t==="compact"?jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx("svg",{width:i.starSize,height:i.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:S})}),jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:E}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:["(",w.toLocaleString(),")"]})]}):t==="number"?jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:E}),jsxRuntime.jsx("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:"/ 5"}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400,marginLeft:2},children:["(",F(w,"response"),")"]})]}):jsxRuntime.jsxs("span",{style:I,children:[jsxRuntime.jsx(xr,{rating:y,size:i.starSize,filledColor:S,emptyColor:x}),jsxRuntime.jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:E}),o&&jsxRuntime.jsxs("span",{style:{fontSize:i.fontSize,color:f,fontWeight:400},children:["(",F(w,"response"),")"]})]})}function Tr(){let{client:e,disabled:t,defaultUser:o,debug:r,openModal:n,closeModal:p,activeModalId:l}=D();return {client:e,disabled:t,defaultUser:o,debug:r,submitFeedback:e.submitResponse.bind(e),openModal:n,closeModal:p,activeModalId:l}}function Cr(e){let{activeModalId:t,openModal:o,closeModal:r}=D(),n=react.useCallback(()=>o(e),[o,e]),p=react.useCallback(()=>r(),[r]);return {open:n,close:p,isOpen:t===e}}
|
|
160
|
+
exports.Gotcha=pr;exports.GotchaProvider=Wt;exports.GotchaScore=kr;exports.createTheme=Lt;exports.useGotcha=Tr;exports.useGotchaTrigger=Cr;//# sourceMappingURL=index.js.map
|
|
161
161
|
//# sourceMappingURL=index.js.map
|