gotcha-feedback 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,11 +1,12 @@
1
- import {createContext,useState,useMemo,useEffect,useCallback,useRef,useContext}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var Qe="https://gotcha.cx/api/v1";var Re={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!"},be={MAX_RETRIES:2,BASE_DELAY_MS:500,MAX_DELAY_MS:5e3};function Xe(){if(typeof window>"u")return `anon_${crypto.randomUUID()}`;try{let e=localStorage.getItem(Re.ANONYMOUS_ID);if(e)return e;let r=`anon_${crypto.randomUUID()}`;return localStorage.setItem(Re.ANONYMOUS_ID,r),r}catch{return `anon_${crypto.randomUUID()}`}}var q={maxRetries:be.MAX_RETRIES,baseDelayMs:be.BASE_DELAY_MS,maxDelayMs:be.MAX_DELAY_MS};async function se(e,r,t=q,o=false){let s=null;for(let h=0;h<=t.maxRetries;h++){try{o&&h>0&&console.log(`[Gotcha] Retry attempt ${h}/${t.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,o&&console.log(`[Gotcha] Network error: ${s.message}`);}if(h<t.maxRetries){let n=Math.min(t.baseDelayMs*Math.pow(2,h),t.maxDelayMs);await new Promise(g=>setTimeout(g,n));}}throw s}function Je(e){let{apiKey:r,baseUrl:t=Qe,debug:o=false}=e,s={"Content-Type":"application/json",Authorization:`Bearer ${r}`};async function h(n,g,d){let a=`${t}${g}`,u=crypto.randomUUID();o&&console.log(`[Gotcha] ${n} ${g}`,d);let b=await se(a,{method:n,headers:{...s,"Idempotency-Key":u},body:d?JSON.stringify(d):void 0},q,o),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 o&&console.error(`[Gotcha] Error: ${i.code} - ${i.message}`),i}return o&&console.log("[Gotcha] Response:",l),l}return {async submitResponse(n){let g=n.user||{};g.id||(g.id=Xe());let d={...n,user:g,context:{url:typeof window<"u"?window.location.href: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=`${t}/responses/check?elementId=${encodeURIComponent(n)}&userId=${encodeURIComponent(g)}`;o&&console.log("[Gotcha] GET /responses/check");let a=await se(d,{method:"GET",headers:s},q,o),u=await a.json();if(!a.ok){let b=u.error;throw o&&console.error(`[Gotcha] Error: ${b.code} - ${b.message}`),b}return u.exists?(o&&console.log("[Gotcha] Found existing response:",u.response),u.response):null},async updateResponse(n,g,d){let a=`${t}/responses/${n}${d?`?userId=${encodeURIComponent(d)}`:""}`;o&&console.log(`[Gotcha] PATCH /responses/${n}`,g);let u=await se(a,{method:"PATCH",headers:s,body:JSON.stringify(g)},q,o),b=await u.json();if(!u.ok){let l=b.error;throw o&&console.error(`[Gotcha] Error: ${l.code} - ${l.message}`),l}return o&&console.log("[Gotcha] Response updated:",b),b},async getScore(n){let g=`${t}/scores/${encodeURIComponent(n)}`;o&&console.log(`[Gotcha] GET /scores/${n}`);let d=await se(g,{method:"GET",headers:s},q,o),a=await d.json();if(!d.ok){let u=a.error;throw o&&console.error(`[Gotcha] Error: ${u.code} - ${u.message}`),u}return o&&console.log("[Gotcha] Score:",a),a},async flagAsBug(n){let g=`${t}/responses/${encodeURIComponent(n)}/bug`;o&&console.log(`[Gotcha] POST /responses/${n}/bug`);let d=await se(g,{method:"POST",headers:s},q,o),a=await d.json();if(!d.ok){let u=a.error;throw o&&console.error(`[Gotcha] Error: ${u.code} - ${u.message}`),u}return o&&console.log("[Gotcha] Bug flagged:",a),a},getBaseUrl(){return t}}}var Bo=new Set(["__proto__","constructor","prototype"]);function X(e,r){let t={...e};for(let o of Object.keys(r)){if(Bo.has(o))continue;let s=r[o];s!=null&&typeof s=="object"&&!Array.isArray(s)?t[o]=X(e[o]??{},s):s!==void 0&&(t[o]=s);}return t}var qe=["#ef4444","#f05540","#f1663c","#f27738","#f38834","#f59e0b","#d4a30e","#b3a812","#79b841","#45c870","#10b981"],Be={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:qe,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)"}}},Ae={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:qe,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 Ao(e,r){return X(e==="dark"?Ae:Be,r)}function K(e,r,t){let s=(e==="auto"||e==="custom"?r:e)==="dark"?X({},Ae):X({},Be);return t&&(s=X(s,t)),s}var Ze="gotcha-styles",eo="gotcha-dm-sans",oo="gotcha-carter-one",Go=`
1
+ import {createContext,useState,useMemo,useEffect,useCallback,useRef,useContext}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var Xe="https://gotcha.cx/api/v1";var Re={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!"},be={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(Re.ANONYMOUS_ID);if(e)return e;let r=`anon_${crypto.randomUUID()}`;return localStorage.setItem(Re.ANONYMOUS_ID,r),r}catch{return `anon_${crypto.randomUUID()}`}}var q={maxRetries:be.MAX_RETRIES,baseDelayMs:be.BASE_DELAY_MS,maxDelayMs:be.MAX_DELAY_MS};async function se(e,r,o=q,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 Je(e){let{apiKey:r,baseUrl:o=Xe,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 se(a,{method:n,headers:{...s,"Idempotency-Key":u},body:d?JSON.stringify(d):void 0},q,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 se(d,{method:"GET",headers:s},q,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 se(a,{method:"PATCH",headers:s,body:JSON.stringify(g)},q,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 se(g,{method:"GET",headers:s},q,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 se(g,{method:"POST",headers:s},q,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 Eo=new Set(["__proto__","constructor","prototype"]);function Q(e,r){let o={...e};for(let t of Object.keys(r)){if(Eo.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 qe=["#ef4444","#f05540","#f1663c","#f27738","#f38834","#f59e0b","#d4a30e","#b3a812","#79b841","#45c870","#10b981"],Be={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:qe,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)"}}},Ae={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:qe,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 Ro(e,r){return Q(e==="dark"?Ae:Be,r)}function K(e,r,o){let s=(e==="auto"||e==="custom"?r:e)==="dark"?Q({},Ae):Q({},Be);return o&&(s=Q(s,o)),s}var Ze="gotcha-styles",eo="gotcha-dm-sans",oo="gotcha-carter-one",Bo=`
2
2
  @font-face {
3
3
  font-family: 'Carter One';
4
4
  font-style: normal;
5
5
  font-weight: 400;
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
- }`.trim();function to(){if(typeof document>"u"||document.getElementById(oo))return;let e=document.createElement("style");e.id=oo,e.textContent=Go,document.head.appendChild(e);}to();function ie(e){return e.replace(/[{}<>;@\\]/g,"")}function Mo(e){let r={default:ie(e.animation.easing.default),spring:ie(e.animation.easing.spring)},t={normal:ie(e.animation.duration.normal)},o=ie(e.typography.fontFamily),s=ie(e.colors.textDisabled);return `
8
+ unicode-range: U+0047;
9
+ }`.trim();function Ao(){if(typeof document>"u"||document.getElementById(oo))return;let e=document.createElement("style");e.id=oo,e.textContent=Bo,document.head.appendChild(e);}Ao();function ie(e){return e.replace(/[{}<>;@\\]/g,"")}function Go(e){let r={default:ie(e.animation.easing.default),spring:ie(e.animation.easing.spring)},o={normal:ie(e.animation.duration.normal)},t=ie(e.typography.fontFamily),s=ie(e.colors.textDisabled);return `
9
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 */
10
11
 
11
12
  @keyframes gotcha-modal-in {
@@ -56,8 +57,8 @@ import {createContext,useState,useMemo,useEffect,useCallback,useRef,useContext}f
56
57
  }
57
58
 
58
59
  @keyframes gotcha-fade-up {
59
- from { opacity: 0; transform: translateY(8px); }
60
- to { opacity: 1; transform: translateY(0); }
60
+ from { opacity: 0; }
61
+ to { opacity: 1; }
61
62
  }
62
63
 
63
64
  @keyframes gotcha-overlay-in {
@@ -102,7 +103,7 @@ import {createContext,useState,useMemo,useEffect,useCallback,useRef,useContext}f
102
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 */
103
104
 
104
105
  [data-gotcha] {
105
- font-family: ${o};
106
+ font-family: ${t};
106
107
  -webkit-font-smoothing: antialiased;
107
108
  -moz-osx-font-smoothing: grayscale;
108
109
  }
@@ -118,7 +119,7 @@ import {createContext,useState,useMemo,useEffect,useCallback,useRef,useContext}f
118
119
  /* \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 */
119
120
 
120
121
  .gotcha-fade-up {
121
- animation: gotcha-fade-up ${t.normal} ${r.default} both;
122
+ animation: gotcha-fade-up ${o.normal} ${r.default} both;
122
123
  }
123
124
 
124
125
  .gotcha-modal-enter {
@@ -146,6 +147,6 @@ import {createContext,useState,useMemo,useEffect,useCallback,useRef,useContext}f
146
147
  transition-duration: 0.01ms !important;
147
148
  }
148
149
  }
149
- `.trim()}function ye(e){if(typeof document>"u")return;if(to(),!document.getElementById(eo)){let t=document.createElement("link");t.rel="preconnect",t.href="https://fonts.googleapis.com",document.head.appendChild(t);let o=document.createElement("link");o.rel="preconnect",o.href="https://fonts.gstatic.com",o.crossOrigin="anonymous",document.head.appendChild(o);let s=document.createElement("link");s.id=eo,s.rel="stylesheet",s.href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap",document.head.appendChild(s);}let r=document.getElementById(Ze);r||(r=document.createElement("style"),r.id=Ze,document.head.appendChild(r)),r.textContent=Mo(e);}var no=createContext(null),Do={};function Lo({apiKey:e,children:r,baseUrl:t,debug:o=false,disabled:s=false,defaultUser:h,themeConfig:n}){let[g,d]=useState(null),a=useMemo(()=>Je({apiKey:e,baseUrl:t,debug:o}),[e,t,o]),u=useMemo(()=>h??Do,[JSON.stringify(h)]);useEffect(()=>{let c=K("light","light",n);ye(c);},[n]);let b=useCallback(c=>{d(c);},[]),l=useCallback(()=>{d(null);},[]),i=useMemo(()=>({client:a,disabled:s,defaultUser:u,debug:o,activeModalId:g,openModal:b,closeModal:l,themeConfig:n}),[a,s,u,o,g,b,l,n]);return jsx(no.Provider,{value:i,children:r})}function I(){let e=useContext(no);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function ao(e){let{client:r,defaultUser:t}=I(),[o,s]=useState(false),[h,n]=useState(false),[g,d]=useState(null),[a,u]=useState(null);return useEffect(()=>{let l=e.user?.id||t?.id;if(!l){u(null);return}let i=false;return (async()=>{n(true);try{let p=await r.checkExistingResponse(e.elementId,l);i||u(p);}catch{i||u(null);}finally{i||n(false);}})(),()=>{i=true;}},[r,e.elementId,e.user?.id,t?.id]),{submit:useCallback(async l=>{s(true),d(null);try{let i=e.user?.id||t?.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:{...t,...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,t,e,a]),isLoading:o,isCheckingExisting:h,error:g,existingResponse:a,isEditing:!!a,clearError:()=>d(null)}}function xe(...e){return e.filter(Boolean).join(" ")}var $=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,so=(e,r)=>{let t={sm:{desktop:24,mobile:28},md:{desktop:32,mobile:34},lg:{desktop:40,mobile:40}};return r?t[e].mobile:t[e].desktop};function _o(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function io({size:e,theme:r,customStyles:t,showOnHover:o,touchBehavior:s,onClick:h,isOpen:n,isParentHovered:g=false,animated:d=true}){let[a,u]=useState(false),[b,l]=useState(false),[i,c]=useState(_o),[p,y]=useState(false),[E,v]=useState(false),[w,R]=useState(false),{themeConfig:P}=I();useEffect(()=>{if(u($()),typeof window>"u")return;let U=window.matchMedia("(prefers-color-scheme: dark)"),W=A=>c(A.matches?"dark":"light");return U.addEventListener("change",W),()=>U.removeEventListener("change",W)},[]);let S=n?true:!a&&o?g:a&&s==="tap-to-reveal"?b:true;useEffect(()=>{if(S&&!w){let U=setTimeout(()=>R(true),600);return ()=>clearTimeout(U)}},[S,w]);let T=()=>{if(a&&s==="tap-to-reveal"&&!b){l(true);return}h();},m=so(e,a),k=useMemo(()=>K(r,i,P),[r,i,P]),x=()=>S?E?"scale(0.95)":p?"scale(1.08)":"scale(1)":"scale(0.6)",F={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:p?k.colors.glassHoverShadow:k.colors.glassShadow,transition:w?`all 0.3s ${k.animation.easing.spring}`:"none",opacity:S?1:0,transform:x(),filter:E?"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"}:{},...t?.button};return 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:F,className:xe("gotcha-button",n&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":n,"aria-haspopup":"dialog",children:jsx(Wo,{size:m*.65,animated:d})})}function Wo({size:e,animated:r=true}){let[t,o]=useState(false);return useEffect(()=>{o(true);},[]),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:t?1:0,...r&&t?{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 jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{animation:"gotcha-spin 0.8s linear infinite"},children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:r,strokeWidth:"2",strokeOpacity:"0.12"}),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 co({resolvedTheme:e,placeholder:r,submitText:t,isLoading:o,onSubmit:s,customStyles:h,initialValues:n,isEditing:g=false,showText:d=true,showRating:a=true,enableBugFlag:u=false,bugFlagLabel:b}){let[l,i]=useState(n?.content||""),[c,p]=useState(n?.rating??null),[y,E]=useState(false),[v,w]=useState(false);useEffect(()=>{w($());},[]),useEffect(()=>{n?.content!==void 0&&i(n.content||""),n?.rating!==void 0&&p(n.rating??null);},[n?.content,n?.rating]);let R=d&&a?l.trim().length>0||c!==null:d?l.trim().length>0:a?c!==null:false,P=m=>{m.preventDefault(),R&&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:"vertical",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:o?"not-allowed":"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,letterSpacing:"0.01em",...h?.submitButton};return jsxs("form",{onSubmit:P,children:[a&&jsx("div",{style:{marginBottom:d?v?16:12:0,...d?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsx(Ko,{value:c,onChange:p,theme:e,isTouch:v,large:!d})}),d&&jsx("textarea",{value:l,onChange:m=>i(m.target.value),placeholder:r||"Share your thoughts...",style:S,disabled:o,"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&&jsxs("button",{type:"button",role:"switch","aria-checked":y,onClick:()=>E(!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:[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: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"})}),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"}),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: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)"}})})]}),jsxs("button",{type:"submit",disabled:o||!R,style:{...T,marginTop:12,opacity:o?.8:1,backgroundColor:R?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:R?e.colors.buttonColor:e.colors.buttonColorDisabled,display:"flex",alignItems:"center",justifyContent:"center",gap:8,...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"}:{}},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:[o&&jsx(H,{size:v?18:16,color:e.colors.buttonColor}),o?g?"Updating...":"Submitting...":g?"Update":t]})]})}function Ko({value:e,onChange:r,theme:t,isTouch:o,large:s=false}){let[h,n]=useState(null),[g,d]=useState(null),a=useRef(),u=s?o?36:28:o?28:18,b=s?o?8:5:o?8:3;useEffect(()=>()=>{clearTimeout(a.current);},[]);let l=i=>{d(i),r(i),clearTimeout(a.current),a.current=setTimeout(()=>d(null),300);};return jsx("div",{style:{display:"flex",gap:s?o?8:6:o?6:2},role:"group","aria-label":"Rating",children:[1,2,3,4,5].map(i=>{let c=(h??e??0)>=i;return 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?t.colors.starFilled:t.colors.starEmpty,transition:`color 0.15s ${t.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 ${t.animation.easing.spring}`:"none",filter:c?`drop-shadow(0 0 3px ${t.colors.starFilled}40)`:"none",transitionDelay:`${(i-1)*30}ms`},children:jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"currentColor",children: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 uo({resolvedTheme:e,isLoading:r,onSubmit:t,initialVote:o,isEditing:s=false,labels:h}){let[n,g]=useState(false),[d,a]=useState(o||null),[u,b]=useState(o||null);useEffect(()=>{g($());},[]),useEffect(()=>{o!==void 0&&(b(o),a(o));},[o]),useEffect(()=>{!r&&!s&&a(null);},[r,s]);let l=p=>{a(p),t({vote:p});},i=p=>{let y=u===p,E=p==="up"?e.colors.voteUp:e.colors.voteDown,v=p==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,w=p==="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?E: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 jsxs("div",{style:{display:"flex",gap:n?12:10},role:"group","aria-label":"Vote",children:[jsx("button",{type:"button",onClick:()=>l("up"),disabled:r,style:i("up"),"aria-label":"Vote up - I like this","aria-pressed":u==="up",onMouseEnter:p=>{r||(p.currentTarget.style.transform="translateY(-2px) scale(1.02)",p.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:p=>{p.currentTarget.style.transform="translateY(0) scale(1)",p.currentTarget.style.boxShadow="none";},children:r&&d==="up"?jsxs(Fragment,{children:[jsx(H,{size:c,color:e.colors.text}),jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxs(Fragment,{children:[jsx(Vo,{size:c}),jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:h?.up||(u==="up"?"Liked":"Like")})]})}),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:p=>{r||(p.currentTarget.style.transform="translateY(-2px) scale(1.02)",p.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:p=>{p.currentTarget.style.transform="translateY(0) scale(1)",p.currentTarget.style.boxShadow="none";},children:r&&d==="down"?jsxs(Fragment,{children:[jsx(H,{size:c,color:e.colors.text}),jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxs(Fragment,{children:[jsx(jo,{size:c}),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 jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children: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 jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children: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 fo({resolvedTheme:e,options:r,allowMultiple:t,isLoading:o,onSubmit:s,initialSelected:h,isEditing:n=false}){let[g,d]=useState(h||[]),[a,u]=useState(false);useEffect(()=>{u($());},[]),useEffect(()=>{h&&d(h);},[h]);let b=c=>{d(t?p=>p.includes(c)?p.filter(y=>y!==c):[...p,c]:p=>p.includes(c)?[]:[c]);},l=()=>{g.length!==0&&s({pollSelected:g});},i=(c,p)=>{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:o?"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:`${p*.05}s`}};return jsxs("div",{children:[jsx("div",{style:{display:"flex",flexDirection:"column",gap:a?8:6},role:"group","aria-label":t?"Select one or more options":"Select an option",children:r.map((c,p)=>{let y=g.includes(c);return jsxs("button",{type:"button",onClick:()=>b(c),disabled:o,style:i(c,p),"aria-pressed":y,onMouseEnter:E=>{o||(E.currentTarget.style.transform="translateX(2px)");},onMouseLeave:E=>{E.currentTarget.style.transform="translateX(0)";},children:[jsx("span",{style:{width:16,height:16,borderRadius:t?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&&jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),c]},c)})}),jsxs("button",{type:"button",onClick:l,disabled:o||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:o||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:o?.8:1,...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"}:{}},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:[o&&jsx(H,{size:a?18:16,color:e.colors.buttonColor}),o?n?"Updating...":"Submitting...":n?"Update":"Submit"]})]})}function ho({resolvedTheme:e,submitText:r,isLoading:t,onSubmit:o,customStyles:s,showFollowUp:h=true,followUpPlaceholder:n,lowLabel:g="Not likely",highLabel:d="Very likely",initialValues:a,isEditing:u=false}){let[b,l]=useState(a?.rating??null),[i,c]=useState(a?.content||""),[p,y]=useState(false),[E,v]=useState(null);useEffect(()=>{y($());},[]),useEffect(()=>{a?.rating!==void 0&&l(a.rating??null),a?.content!==void 0&&c(a.content||"");},[a?.rating,a?.content]);let w=b!==null,R=e.colors.npsColors;return jsxs("form",{onSubmit:S=>{S.preventDefault(),w&&o({rating:b??void 0,content:h&&i.trim()?i.trim():void 0});},children:[jsxs("div",{children:[jsx("div",{style:{display:"flex",gap:p?4:6,justifyContent:"center"},role:"group","aria-label":"NPS Score",children:Array.from({length:11},(S,T)=>{let m=b===T,k=E===T,x=R[T];return 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:p?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)})}),jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6,padding:"0 2px",...s?.npsLabels},children:[jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:g}),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&&jsx("textarea",{value:i,onChange:S=>c(S.target.value),placeholder:n||"What's the main reason for your score?",style:{width:"100%",padding:p?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:p?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"vertical",minHeight:p?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:t,"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;}}),jsxs("button",{type:"submit",disabled:t||!w,style:{width:"100%",padding:p?"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:p?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",opacity:t?.8:1,display:"flex",alignItems:"center",justifyContent:"center",gap:8,marginTop:12,...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"}:{},...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:[t&&jsx(H,{size:p?18:16,color:e.colors.buttonColor}),t?u?"Updating...":"Submitting...":u?"Update":r]})]})}function Oe({mode:e,theme:r,customStyles:t,promptText:o,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:p,allowMultiple:y=false,npsQuestion:E,npsFollowUp:v=true,npsFollowUpPlaceholder:w,npsLowLabel:R,npsHighLabel:P,enableBugFlag:S=false,bugFlagLabel:T,onSubmit:m,onClose:k,anchorRect:x}){let F=useRef(null),U=useRef(null),W=useRef(k);W.current=k;let[A,Te]=useState(false),[pe,fe]=useState("light"),{themeConfig:oe}=I();useEffect(()=>{Te(window.innerWidth<640);let B=window.matchMedia("(prefers-color-scheme: dark)");fe(B.matches?"dark":"light");let j=D=>fe(D.matches?"dark":"light");return B.addEventListener("change",j),()=>B.removeEventListener("change",j)},[]);let f=useMemo(()=>K(r,pe,oe),[r,pe,oe]);useEffect(()=>{ye(f);},[f]);let me=typeof window>"u"||!x?false:window.innerHeight-x.bottom<300;useEffect(()=>{let B=F.current;if(!B)return;U.current?.focus();let j=D=>{if(D.key==="Escape"){W.current();return}if(D.key==="Tab"){let Q=B.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),O=Q[0],ne=Q[Q.length-1];D.shiftKey&&document.activeElement===O?(D.preventDefault(),ne?.focus()):!D.shiftKey&&document.activeElement===ne&&(D.preventDefault(),O?.focus());}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);let te=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":e==="nps"?E||"How likely are you to recommend us?":"What do you think of this feature?",he=A?24:20,re=e==="nps"?420:340,Ce=A?"gotcha-modal-enter-center":me?"gotcha-modal-enter-above":"gotcha-modal-enter",Ee=A?{position:"fixed",left:"50%",top:"50%",width:"calc(100vw - 32px)",maxWidth:re,padding:he,borderRadius:f.borders.radius.lg+2,background:f.colors.backgroundGradient,color:f.colors.text,boxShadow:f.shadows.modal,border:`${f.borders.width}px solid ${f.colors.border}`,zIndex:9999,fontFamily:f.typography.fontFamily,...t?.modal,textAlign:"left"}:{position:"fixed",left:x?x.left+x.width/2:"50%",width:re,padding:he,borderRadius:f.borders.radius.lg,background:f.colors.backgroundGradient,color:f.colors.text,boxShadow:f.shadows.modal,border:`${f.borders.width}px solid ${f.colors.border}`,zIndex:99999,fontFamily:f.typography.fontFamily,...me?{top:x?x.top-8:void 0,transform:"translate(-50%, -100%)"}:{top:x?x.bottom+8:void 0,transform:"translate(-50%, 0)"},...t?.modal,textAlign:"left"},N=B=>({animation:`gotcha-fade-up ${f.animation.duration.normal} ${f.animation.easing.default} both`,animationDelay:`${B*.05}s`}),V=n==="Gotcha!"||n==="Thanks for your feedback!";return jsxs("div",{ref:F,role:"dialog","aria-modal":"true","aria-label":d?"Feedback submitted":void 0,"aria-labelledby":d?void 0:"gotcha-modal-title","data-gotcha":true,style:Ee,className:xe("gotcha-modal",Ce),children:[jsx("button",{ref:U,type:"button",onClick:k,"aria-label":"Close feedback form",style:{position:"absolute",top:A?10:6,right:A?10:6,width:A?40:36,height:A?40:36,border:"none",background:"transparent",cursor:"pointer",color:f.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:f.borders.radius.sm,transition:`all ${f.animation.duration.fast} ${f.animation.easing.default}`,...t?.closeButton},onMouseEnter:B=>{B.currentTarget.style.backgroundColor=f.colors.closeButtonBg,B.currentTarget.style.color=f.colors.closeButtonHover;},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="transparent",B.currentTarget.style.color=f.colors.closeButton;},children:jsx("svg",{width:A?16:14,height:A?16:14,viewBox:"0 0 14 14",fill:"none",children:jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!d&&jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:A?f.typography.fontSize.lg:f.typography.fontSize.md,fontWeight:f.typography.fontWeight.semibold,paddingRight:A?44:38,letterSpacing:"-0.02em",lineHeight:1.4,textAlign:"left",fontFamily:f.typography.fontFamily,...N(0),...t?.title},children:o||te}),d&&jsxs("div",{style:{textAlign:"center",padding:"28px 0 20px"},children:[jsx("div",{style:{width:52,height:52,borderRadius:"50%",backgroundColor:f.colors.successSurface,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",animation:`gotcha-success-pop 0.4s ${f.animation.easing.spring} both, gotcha-glow-pulse 0.8s ease 0.4s`,...t?.successIcon},children:jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M20 6L9 17L4 12",stroke:f.colors.success,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:24,strokeDashoffset:0,animation:"gotcha-check-draw 0.4s ease 0.2s both"}})})}),jsx("p",{style:{margin:0,fontSize:V?22:f.typography.fontSize.md,fontWeight:V?f.typography.fontWeight.bold:f.typography.fontWeight.medium,color:f.colors.text,fontFamily:V?"'Carter One', cursive":f.typography.fontFamily,animation:"gotcha-success-text 0.3s ease 0.3s both",...t?.successMessage},children:V?"Gotcha!":n}),V&&jsx("p",{style:{margin:"6px 0 0",fontSize:f.typography.fontSize.sm,fontWeight:f.typography.fontWeight.normal,color:f.colors.textSecondary,animation:"gotcha-success-text 0.3s ease 0.45s both"},children:"Thanks for your feedback!"})]}),a&&!d&&jsxs("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:f.borders.radius.sm,backgroundColor:f.colors.errorSurface,border:`1px solid ${f.colors.errorBorder}`,color:f.colors.error,fontSize:f.typography.fontSize.sm,lineHeight:1.4,display:"flex",alignItems:"center",gap:8,...N(1),...t?.errorMessage},children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children: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&&jsxs("div",{style:N(1),children:[e==="feedback"&&jsx(co,{resolvedTheme:f,placeholder:s,submitText:h,isLoading:g,onSubmit:m,customStyles:t,initialValues:u?{content:u.content,rating:u.rating}:void 0,isEditing:b,showText:l,showRating:i,enableBugFlag:S,bugFlagLabel:T}),e==="vote"&&jsx(uo,{resolvedTheme:f,isLoading:g,onSubmit:m,initialVote:u?.vote||void 0,isEditing:b,labels:c}),e==="nps"&&jsx(ho,{resolvedTheme:f,submitText:h,isLoading:g,onSubmit:m,showFollowUp:v,followUpPlaceholder:w,lowLabel:R,highLabel:P,customStyles:t,initialValues:u?{rating:u.rating,content:u.content}:void 0,isEditing:b}),e==="poll"&&p&&p.length>0&&jsx(fo,{resolvedTheme:f,options:p,allowMultiple:y,isLoading:g,onSubmit:m,initialSelected:u?.pollSelected||void 0,isEditing:b})]}),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 Xo({elementId:e,user:r,mode:t="feedback",showText:o=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:p=false,animated:y=true,position:E=Y.POSITION,size:v=Y.SIZE,theme:w=Y.THEME,customStyles:R,visible:P=true,showOnHover:S=Y.SHOW_ON_HOVER,touchBehavior:T=Y.TOUCH_BEHAVIOR,promptText:m,placeholder:k,submitText:x=Y.SUBMIT_TEXT,thankYouMessage:F=Y.THANK_YOU_MESSAGE,onSubmit:U,onOpen:W,onClose:A,onError:Te}){let{disabled:pe,activeModalId:fe,openModal:oe,closeModal:f}=I(),[me,te]=useState(false),[he,re]=useState(false),[Ce,Ee]=useState(null),[N,V]=useState(false),[B,j]=useState(false),D=useRef(null),Q=useRef();useEffect(()=>(j(true),V(window.innerWidth<640),()=>{clearTimeout(Q.current);}),[]);let O=fe===e;useEffect(()=>{if(!O||!N)return;let G=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=G;}},[O,N]),useEffect(()=>{if(!S)return;let G=D.current;if(!G)return;let ae=G.parentElement;if(!ae)return;let Ve=()=>re(true),je=()=>re(false);return ae.addEventListener("mouseenter",Ve),ae.addEventListener("mouseleave",je),()=>{ae.removeEventListener("mouseenter",Ve),ae.removeEventListener("mouseleave",je);}},[S]);let{submit:ne,isLoading:vo,error:ko,existingResponse:wo,isEditing:Ne}=ao({elementId:e,mode:t,pollOptions:n,user:r,onSuccess:G=>{te(true),U?.(G),Q.current=setTimeout(()=>{f(),te(false);},3e3);},onError:G=>{console.warn("[Gotcha] Submission failed:",G instanceof Error?G.message:G),Te?.(G);}}),To=useCallback(()=>{D.current&&Ee(D.current.getBoundingClientRect()),oe(e),W?.();},[e,oe,W]),Ye=useCallback(()=>{clearTimeout(Q.current),f(),te(false),A?.();},[f,A]),Co=useCallback(G=>{ne(G);},[ne]),Eo=Ne?"Update":x;if(pe||!P)return null;let Ro={"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"}},Ke={mode:t,theme:w,customStyles:R,promptText:m,placeholder:k,submitText:Eo,thankYouMessage:F,isLoading:vo,isSubmitted:me,error:ko,existingResponse:wo,isEditing:Ne,showText:o,showRating:s,voteLabels:h,options:n,allowMultiple:g,npsQuestion:d,npsFollowUp:a,npsFollowUpPlaceholder:u,npsLowLabel:b,npsHighLabel:l,enableBugFlag:i,bugFlagLabel:c,onSubmit:Co,onClose:Ye,anchorRect:Ce||void 0};return jsxs("div",{ref:D,style:{...Ro[E],zIndex:O?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsx(io,{size:v,theme:w,customStyles:R,showOnHover:S,touchBehavior:T,onClick:To,isOpen:O,isParentHovered:he,animated:y}),O&&!N&&B&&createPortal(jsx(Oe,{...Ke}),document.body),O&&N&&B&&createPortal(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:Ye,children:jsx("div",{onClick:G=>G.stopPropagation(),children:jsx(Oe,{...Ke})})}),document.body)]})}function xo({elementId:e,refreshInterval:r}){let{client:t}=I(),[o,s]=useState(null),[h,n]=useState(true),[g,d]=useState(null);return useEffect(()=>{let a=false,u=async()=>{try{let l=await t.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);}},[t,e,r]),{score:o,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:t,emptyColor:o}){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(jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",style:{display:"block"},children:[jsx("defs",{children:jsx("clipPath",{id:d,children:jsx("rect",{x:"0",y:"0",width:24*g,height:"24"})})}),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}),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,clipPath:`url(#${d})`})]},n));}return jsx("span",{style:{display:"inline-flex",gap:Math.max(1,r*.08),alignItems:"center"},children:h})}function nt({rate:e,height:r,filledColor:t,trackColor:o}){return jsx("span",{style:{display:"inline-block",width:48,height:r,borderRadius:r,backgroundColor:o,overflow:"hidden",verticalAlign:"middle"},children:jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:r,background:t,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function at({size:e,color:r}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:r,style:{display:"block"},children: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:t=true,size:o="md",theme:s="auto",refreshInterval:h,style:n}){let{score:g,isLoading:d}=xo({elementId:e,refreshInterval:h}),[a,u]=useState("light");useEffect(()=>{if(typeof window>"u")return;let k=window.matchMedia("(prefers-color-scheme: dark)");u(k.matches?"dark":"light");let x=F=>u(F.matches?"dark":"light");return k.addEventListener("change",x),()=>k.removeEventListener("change",x)},[]);let{themeConfig:b}=I(),l=useMemo(()=>K(s,a,b),[s,a,b]);if(d||!g)return null;let i=tt[o],c=l.colors.text,p=l.colors.textDisabled,y=l.colors.starFilled,E=l.colors.starEmpty,v=l.colors.voteUp,w=l.colors.starEmpty,R={display:"inline-flex",alignItems:"center",gap:i.gap,fontFamily:l.typography.fontFamily,lineHeight:1,letterSpacing:"-0.01em",WebkitFontSmoothing:"antialiased",...n},P=(k,x)=>{let F=k===1?x:`${x}s`;return `${k.toLocaleString()} ${F}`};if(r==="votes"){let{voteCount:k,positiveRate:x}=g,F=k.up+k.down;return F===0?null:jsxs("span",{style:R,children:[jsx(at,{size:i.iconSize,color:v}),jsxs("span",{style:{fontSize:i.ratingFontSize,fontWeight:600,color:v,fontVariantNumeric:"tabular-nums"},children:[x,"%"]}),jsx(nt,{rate:x??0,height:i.barHeight,filledColor:v,trackColor:w}),t&&jsx("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:P(F,"vote")})]})}let{averageRating:S,totalResponses:T}=g;if(S===null||T===0)return null;let m=S.toFixed(1);return r==="compact"?jsxs("span",{style:R,children:[jsx("svg",{width:i.starSize,height:i.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children: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})}),jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),t&&jsxs("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:["(",T.toLocaleString(),")"]})]}):r==="number"?jsxs("span",{style:R,children:[jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),jsx("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:"/ 5"}),t&&jsxs("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400,marginLeft:2},children:["(",P(T,"response"),")"]})]}):jsxs("span",{style:R,children:[jsx(rt,{rating:S,size:i.starSize,filledColor:y,emptyColor:E}),jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),t&&jsxs("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:["(",P(T,"response"),")"]})]})}function it(){let{client:e,disabled:r,defaultUser:t,debug:o}=I();return {client:e,disabled:r,defaultUser:t,debug:o,submitFeedback:e.submitResponse.bind(e)}}
150
- export{Xo as Gotcha,Lo as GotchaProvider,st as GotchaScore,Ao as createTheme,it as useGotcha};//# sourceMappingURL=index.mjs.map
150
+ `.trim()}function ye(e){if(typeof document>"u")return;if(!document.getElementById(eo)){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=eo,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(Ze);r||(r=document.createElement("style"),r.id=Ze,document.head.appendChild(r)),r.textContent=Go(e);}var ro=createContext(null),Fo={};function Do({apiKey:e,children:r,baseUrl:o,debug:t=false,disabled:s=false,defaultUser:h,themeConfig:n}){let[g,d]=useState(null);o&&!o.startsWith("https://")&&!o.startsWith("/")&&!o.includes("localhost")&&console.warn("[Gotcha] baseUrl should use HTTPS in production:",o);let a=useMemo(()=>Je({apiKey:e,baseUrl:o,debug:t}),[e,o,t]),u=useMemo(()=>h??Fo,[JSON.stringify(h)]);useEffect(()=>{let c=K("light","light",n);ye(c);},[n]);let b=useCallback(c=>{d(c);},[]),l=useCallback(()=>{d(null);},[]),i=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 jsx(ro.Provider,{value:i,children:r})}function I(){let e=useContext(ro);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function no(e){let{client:r,defaultUser:o}=I(),[t,s]=useState(false),[h,n]=useState(false),[g,d]=useState(null),[a,u]=useState(null);return useEffect(()=>{let l=e.user?.id||o?.id;if(!l){u(null);return}let i=false;return (async()=>{n(true);try{let p=await r.checkExistingResponse(e.elementId,l);i||u(p);}catch{i||u(null);}finally{i||n(false);}})(),()=>{i=true;}},[r,e.elementId,e.user?.id,o?.id]),{submit: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 xe(...e){return e.filter(Boolean).join(" ")}var $=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,ao=(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 Ho(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function so({size:e,theme:r,customStyles:o,showOnHover:t,touchBehavior:s,onClick:h,isOpen:n,isParentHovered:g=false,animated:d=true}){let[a,u]=useState(false),[b,l]=useState(false),[i,c]=useState(Ho),[p,y]=useState(false),[E,x]=useState(false),[w,R]=useState(false),{themeConfig:P}=I();useEffect(()=>{if(u($()),typeof window>"u")return;let U=window.matchMedia("(prefers-color-scheme: dark)"),W=B=>c(B.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;useEffect(()=>{if(S&&!w){let U=setTimeout(()=>R(true),600);return ()=>clearTimeout(U)}},[S,w]);let T=()=>{if(a&&s==="tap-to-reveal"&&!b){l(true);return}h();},m=ao(e,a),v=useMemo(()=>K(r,i,P),[r,i,P]),k=()=>S?E?"scale(0.95)":p?"scale(1.08)":"scale(1)":"scale(0.6)",F={width:m,height:m,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:p?v.colors.glassHoverShadow:v.colors.glassShadow,transition:w?`all 0.3s ${v.animation.easing.spring}`:"none",opacity:S?1:0,transform:k(),filter:E?"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 jsx("button",{type:"button",onClick:T,onMouseEnter:()=>y(true),onMouseLeave:()=>{y(false),x(false);},onMouseDown:()=>x(true),onMouseUp:()=>x(false),onTouchStart:()=>x(true),onTouchEnd:()=>x(false),style:F,className:xe("gotcha-button",n&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":n,"aria-haspopup":"dialog",children:jsx(_o,{size:m*.65,animated:d})})}function _o({size:e,animated:r=true}){let[o,t]=useState(false);return useEffect(()=>{t(true);},[]),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 jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",style:{animation:"gotcha-spin 0.8s linear infinite"},children:[jsx("circle",{cx:"12",cy:"12",r:"10",stroke:r,strokeWidth:"2",strokeOpacity:"0.12"}),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 lo({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]=useState(n?.content||""),[c,p]=useState(n?.rating??null),[y,E]=useState(false),[x,w]=useState(false);useEffect(()=>{w($());},[]),useEffect(()=>{n?.content!==void 0&&i(n.content||""),n?.rating!==void 0&&p(n.rating??null);},[n?.content,n?.rating]);let R=d&&a?l.trim().length>0||c!==null:d?l.trim().length>0:a?c!==null:false,P=m=>{m.preventDefault(),R&&s({content:d&&l.trim()?l.trim():void 0,rating:a&&c!==null?c:void 0,isBug:y||void 0});},S={width:"100%",padding:x?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:x?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:x?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:x?"14px 16px":"10px 16px",border:e.colors.buttonBorder,borderRadius:e.borders.radius.md,backgroundColor:e.colors.buttonBackground,color:e.colors.buttonColor,fontSize:x?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 jsxs("form",{onSubmit:P,children:[a&&jsx("div",{style:{marginBottom:d?x?16:12:0,...d?{}:{display:"flex",justifyContent:"center",padding:"8px 0"}},children:jsx(Yo,{value:c,onChange:p,theme:e,isTouch:x,large:!d})}),d&&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&&jsxs("button",{type:"button",role:"switch","aria-checked":y,onClick:()=>E(!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:[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: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"})}),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"}),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: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)"}})})]}),jsxs("button",{type:"submit",disabled:t||!R,style:{...T,marginTop:12,opacity:t?.8:1,backgroundColor:R?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:R?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&&jsx(H,{size:x?18:16,color:e.colors.buttonColor}),t?g?"Updating...":"Submitting...":g?"Update":o]})]})}function Yo({value:e,onChange:r,theme:o,isTouch:t,large:s=false}){let[h,n]=useState(null),[g,d]=useState(null),a=useRef(),u=s?t?36:28:t?28:18,b=s?t?8:5:t?8:3;useEffect(()=>()=>{clearTimeout(a.current);},[]);let l=i=>{d(i),r(i),clearTimeout(a.current),a.current=setTimeout(()=>d(null),300);};return 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 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:jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"currentColor",children: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 co({resolvedTheme:e,isLoading:r,onSubmit:o,initialVote:t,isEditing:s=false,labels:h}){let[n,g]=useState(false),[d,a]=useState(t||null),[u,b]=useState(t||null);useEffect(()=>{g($());},[]),useEffect(()=>{t!==void 0&&(b(t),a(t));},[t]),useEffect(()=>{!r&&!s&&a(null);},[r,s]);let l=p=>{a(p),o({vote:p});},i=p=>{let y=u===p,E=p==="up"?e.colors.voteUp:e.colors.voteDown,x=p==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,w=p==="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, ${x}, ${x})`:e.colors.surface,color:y?E: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 jsxs("div",{style:{display:"flex",gap:n?12:10},role:"group","aria-label":"Vote",children:[jsx("button",{type:"button",onClick:()=>l("up"),disabled:r,style:i("up"),"aria-label":"Vote up - I like this","aria-pressed":u==="up",onMouseEnter:p=>{r||(p.currentTarget.style.transform="translateY(-2px) scale(1.02)",p.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:p=>{p.currentTarget.style.transform="translateY(0) scale(1)",p.currentTarget.style.boxShadow="none";},children:r&&d==="up"?jsxs(Fragment,{children:[jsx(H,{size:c,color:e.colors.text}),jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxs(Fragment,{children:[jsx(Ko,{size:c}),jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:h?.up||(u==="up"?"Liked":"Like")})]})}),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:p=>{r||(p.currentTarget.style.transform="translateY(-2px) scale(1.02)",p.currentTarget.style.boxShadow=e.shadows.button);},onMouseLeave:p=>{p.currentTarget.style.transform="translateY(0) scale(1)",p.currentTarget.style.boxShadow="none";},children:r&&d==="down"?jsxs(Fragment,{children:[jsx(H,{size:c,color:e.colors.text}),jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:s?"Updating...":"Sending..."})]}):jsxs(Fragment,{children:[jsx(Vo,{size:c}),jsx("span",{style:{fontSize:n?15:13,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.01em"},children:h?.down||(u==="down"?"Disliked":"Dislike")})]})})]})}function Ko({size:e=24}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children: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 Vo({size:e=24}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children: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 po({resolvedTheme:e,options:r,allowMultiple:o,isLoading:t,onSubmit:s,initialSelected:h,isEditing:n=false}){let[g,d]=useState(h||[]),[a,u]=useState(false);useEffect(()=>{u($());},[]),useEffect(()=>{h&&d(h);},[h]);let b=c=>{d(o?p=>p.includes(c)?p.filter(y=>y!==c):[...p,c]:p=>p.includes(c)?[]:[c]);},l=()=>{g.length!==0&&s({pollSelected:g});},i=(c,p)=>{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:`${p*.05}s`}};return jsxs("div",{children:[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,p)=>{let y=g.includes(c);return jsxs("button",{type:"button",onClick:()=>b(c),disabled:t,style:i(c,p),"aria-pressed":y,onMouseEnter:E=>{t||(E.currentTarget.style.transform="translateX(2px)");},onMouseLeave:E=>{E.currentTarget.style.transform="translateX(0)";},children:[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&&jsx("svg",{width:10,height:10,viewBox:"0 0 12 12",fill:"none",children:jsx("path",{d:"M2 6l3 3 5-5",stroke:"#fff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),c]},c)})}),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&&jsx(H,{size:a?18:16,color:e.colors.buttonColor}),t?n?"Updating...":"Submitting...":n?"Update":"Submit"]})]})}function mo({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]=useState(a?.rating??null),[i,c]=useState(a?.content||""),[p,y]=useState(false),[E,x]=useState(null);useEffect(()=>{y($());},[]),useEffect(()=>{a?.rating!==void 0&&l(a.rating??null),a?.content!==void 0&&c(a.content||"");},[a?.rating,a?.content]);let w=b!==null,R=e.colors.npsColors;return jsxs("form",{onSubmit:S=>{S.preventDefault(),w&&t({rating:b??void 0,content:h&&i.trim()?i.trim():void 0});},children:[jsxs("div",{children:[jsx("div",{style:{display:"flex",gap:p?4:6,justifyContent:"center"},role:"group","aria-label":"NPS Score",children:Array.from({length:11},(S,T)=>{let m=b===T,v=E===T,k=R[T];return jsx("button",{type:"button",onClick:()=>l(T),onMouseEnter:()=>x(T),onMouseLeave:()=>x(null),"aria-label":`Score ${T} out of 10`,"aria-pressed":m,style:{flex:1,minWidth:0,height:p?34:32,borderRadius:e.borders.radius.sm,border:m?`2px solid ${k}`:`1.5px solid ${k}25`,backgroundColor:m?k:v?`${k}25`:`${k}0c`,color:m?"#fff":v?k:`${k}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)":v?"scale(1.04)":"scale(1)",boxShadow:m?`0 0 12px ${k}40`:"none",...s?.npsButton,...m?s?.npsButtonSelected:{}},children:T},T)})}),jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6,padding:"0 2px",...s?.npsLabels},children:[jsx("span",{style:{fontSize:e.typography.fontSize.xs,color:e.colors.textDisabled,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.02em"},children:g}),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&&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:p?"12px 14px":"10px 12px",border:`1px solid ${e.colors.inputBorder}`,borderRadius:e.borders.radius.md,backgroundColor:e.colors.inputBackground,color:e.colors.text,fontSize:p?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"vertical",minHeight:p?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;}}),jsxs("button",{type:"submit",disabled:o||!w,style:{width:"100%",padding:p?"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:p?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&&jsx(H,{size:p?18:16,color:e.colors.buttonColor}),o?u?"Updating...":"Submitting...":u?"Update":r]})]})}function Oe({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:p,allowMultiple:y=false,npsQuestion:E,npsFollowUp:x=true,npsFollowUpPlaceholder:w,npsLowLabel:R,npsHighLabel:P,enableBugFlag:S=false,bugFlagLabel:T,onSubmit:m,onClose:v,anchorRect:k}){let F=useRef(null),U=useRef(null),W=useRef(v);W.current=v;let[B,Te]=useState(false),[pe,fe]=useState("light"),{themeConfig:oe}=I();useEffect(()=>{Te(window.innerWidth<640);let A=window.matchMedia("(prefers-color-scheme: dark)");fe(A.matches?"dark":"light");let j=D=>fe(D.matches?"dark":"light");return A.addEventListener("change",j),()=>A.removeEventListener("change",j)},[]);let f=useMemo(()=>K(r,pe,oe),[r,pe,oe]);useEffect(()=>{ye(f);},[f]);let me=typeof window>"u"||!k?false:window.innerHeight-k.bottom<300;useEffect(()=>{let A=F.current;if(!A)return;U.current?.focus();let j=D=>{if(D.key==="Escape"){W.current();return}if(D.key==="Tab"){let X=A.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),O=X[0],ne=X[X.length-1];D.shiftKey&&document.activeElement===O?(D.preventDefault(),ne?.focus()):!D.shiftKey&&document.activeElement===ne&&(D.preventDefault(),O?.focus());}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[]);let te=e==="vote"?"What do you think?":e==="poll"?"Cast your vote":e==="nps"?E||"How likely are you to recommend us?":"What do you think of this feature?",he=B?24:20,re=e==="nps"?420:340,Ce=B?"gotcha-modal-enter-center":me?"gotcha-modal-enter-above":"gotcha-modal-enter",Ee=B?{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"calc(100vw - 32px)",maxWidth:re,padding:he,borderRadius:f.borders.radius.lg+2,background:f.colors.backgroundGradient,color:f.colors.text,boxShadow:f.shadows.modal,border:`${f.borders.width}px solid ${f.colors.border}`,zIndex:9999,fontFamily:f.typography.fontFamily,...o?.modal,textAlign:"left"}:{position:"absolute",left:"50%",width:re,padding:he,borderRadius:f.borders.radius.lg,background:f.colors.backgroundGradient,color:f.colors.text,boxShadow:f.shadows.modal,border:`${f.borders.width}px solid ${f.colors.border}`,zIndex:9999,fontFamily:f.typography.fontFamily,...me?{bottom:"100%",marginBottom:8,transform:"translateX(-50%)"}:{top:"100%",marginTop:8,transform:"translateX(-50%)"},...o?.modal,textAlign:"left"},N=A=>B?{}:{animation:`gotcha-fade-up ${f.animation.duration.normal} ${f.animation.easing.default} both`,animationDelay:`${A*.05}s`},V=n==="Gotcha!"||n==="Thanks for your feedback!";return jsxs("div",{ref:F,role:"dialog","aria-modal":"true","aria-label":d?"Feedback submitted":void 0,"aria-labelledby":d?void 0:"gotcha-modal-title","data-gotcha":true,style:Ee,className:xe("gotcha-modal",Ce),children:[jsx("button",{ref:U,type:"button",onClick:v,"aria-label":"Close feedback form",style:{position:"absolute",top:B?10:6,right:B?10:6,width:B?40:36,height:B?40:36,border:"none",background:"transparent",outline:"none",cursor:"pointer",zIndex:10,color:f.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:f.borders.radius.sm,transition:`all ${f.animation.duration.fast} ${f.animation.easing.default}`,...o?.closeButton},onMouseEnter:A=>{A.currentTarget.style.backgroundColor=f.colors.closeButtonBg,A.currentTarget.style.color=f.colors.closeButtonHover;},onMouseLeave:A=>{A.currentTarget.style.backgroundColor="transparent",A.currentTarget.style.color=f.colors.closeButton;},children:jsx("svg",{width:B?16:14,height:B?16:14,viewBox:"0 0 14 14",fill:"none",children:jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!d&&jsx("h2",{id:"gotcha-modal-title",style:{margin:"0 0 16px 0",fontSize:B?f.typography.fontSize.lg:f.typography.fontSize.md,fontWeight:f.typography.fontWeight.semibold,paddingRight:B?44:38,letterSpacing:"-0.02em",lineHeight:1.4,textAlign:"left",fontFamily:f.typography.fontFamily,...N(0),...o?.title},children:t||te}),d&&jsxs("div",{style:{textAlign:"center",padding:"28px 0 20px"},children:[jsx("div",{style:{width:52,height:52,borderRadius:"50%",backgroundColor:f.colors.successSurface,display:"flex",alignItems:"center",justifyContent:"center",margin:"0 auto 16px",animation:`gotcha-success-pop 0.4s ${f.animation.easing.spring} both, gotcha-glow-pulse 0.8s ease 0.4s`,...o?.successIcon},children:jsx("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M20 6L9 17L4 12",stroke:f.colors.success,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:24,strokeDashoffset:0,animation:"gotcha-check-draw 0.4s ease 0.2s both"}})})}),jsx("p",{style:{margin:0,fontSize:V?22:f.typography.fontSize.md,fontWeight:V?f.typography.fontWeight.bold:f.typography.fontWeight.medium,color:f.colors.text,fontFamily:V?"'Carter One', cursive":f.typography.fontFamily,animation:"gotcha-success-text 0.3s ease 0.3s both",...o?.successMessage},children:V?"Gotcha!":n}),V&&jsx("p",{style:{margin:"6px 0 0",fontSize:f.typography.fontSize.sm,fontWeight:f.typography.fontWeight.normal,color:f.colors.textSecondary,animation:"gotcha-success-text 0.3s ease 0.45s both"},children:"Thanks for your feedback!"})]}),a&&!d&&jsxs("div",{style:{padding:"8px 10px",marginBottom:12,borderRadius:f.borders.radius.sm,backgroundColor:f.colors.errorSurface,border:`1px solid ${f.colors.errorBorder}`,color:f.colors.error,fontSize:f.typography.fontSize.sm,lineHeight:1.4,display:"flex",alignItems:"center",gap:8,...N(1),...o?.errorMessage},children:[jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",style:{flexShrink:0},children: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&&jsxs("div",{style:N(1),children:[e==="feedback"&&jsx(lo,{resolvedTheme:f,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"&&jsx(co,{resolvedTheme:f,isLoading:g,onSubmit:m,initialVote:u?.vote||void 0,isEditing:b,labels:c}),e==="nps"&&jsx(mo,{resolvedTheme:f,submitText:h,isLoading:g,onSubmit:m,showFollowUp:x,followUpPlaceholder:w,lowLabel:R,highLabel:P,customStyles:o,initialValues:u?{rating:u.rating,content:u.content}:void 0,isEditing:b}),e==="poll"&&p&&p.length>0&&jsx(po,{resolvedTheme:f,options:p,allowMultiple:y,isLoading:g,onSubmit:m,initialSelected:u?.pollSelected||void 0,isEditing:b})]}),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:p=false,animated:y=true,position:E=Y.POSITION,size:x=Y.SIZE,theme:w=Y.THEME,customStyles:R,visible:P=true,showOnHover:S=Y.SHOW_ON_HOVER,touchBehavior:T=Y.TOUCH_BEHAVIOR,promptText:m,placeholder:v,submitText:k=Y.SUBMIT_TEXT,thankYouMessage:F=Y.THANK_YOU_MESSAGE,onSubmit:U,onOpen:W,onClose:B,onError:Te}){let{disabled:pe,activeModalId:fe,openModal:oe,closeModal:f}=I(),[me,te]=useState(false),[he,re]=useState(false),[Ce,Ee]=useState(null),[N,V]=useState(false),[A,j]=useState(false),D=useRef(null),X=useRef();useEffect(()=>(j(true),V(window.innerWidth<640),()=>{clearTimeout(X.current);}),[]);let O=fe===e;useEffect(()=>{if(!O||!N)return;let G=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=G;}},[O,N]),useEffect(()=>{if(!S)return;let G=D.current;if(!G)return;let ae=G.parentElement;if(!ae)return;let Ve=()=>re(true),je=()=>re(false);return ae.addEventListener("mouseenter",Ve),ae.addEventListener("mouseleave",je),()=>{ae.removeEventListener("mouseenter",Ve),ae.removeEventListener("mouseleave",je);}},[S]);let{submit:ne,isLoading:So,error:xo,existingResponse:vo,isEditing:Ne}=no({elementId:e,mode:o,pollOptions:n,user:r,onSuccess:G=>{te(true),U?.(G),X.current=setTimeout(()=>{f(),te(false);},3e3);},onError:G=>{console.warn("[Gotcha] Submission failed:",G instanceof Error?G.message:G),Te?.(G);}}),ko=useCallback(()=>{D.current&&Ee(D.current.getBoundingClientRect()),oe(e),W?.();},[e,oe,W]),Ye=useCallback(()=>{clearTimeout(X.current),f(),te(false),B?.();},[f,B]),wo=useCallback(G=>{ne(G);},[ne]),To=Ne?"Update":k;if(pe||!P)return null;let Co={"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"}},Ke={mode:o,theme:w,customStyles:R,promptText:m,placeholder:v,submitText:To,thankYouMessage:F,isLoading:So,isSubmitted:me,error:xo,existingResponse:vo,isEditing:Ne,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:wo,onClose:Ye,anchorRect:Ce||void 0};return jsxs("div",{ref:D,style:{...Co[E],zIndex:O?1e4:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsx(so,{size:x,theme:w,customStyles:R,showOnHover:S,touchBehavior:T,onClick:ko,isOpen:O,isParentHovered:he,animated:y}),O&&!N&&jsx(Oe,{...Ke}),O&&N&&A&&createPortal(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:Ye,children:jsx("div",{onClick:G=>G.stopPropagation(),children:jsx(Oe,{...Ke})})}),document.body)]})}function yo({elementId:e,refreshInterval:r}){let{client:o}=I(),[t,s]=useState(null),[h,n]=useState(true),[g,d]=useState(null);return 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(jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",style:{display:"block"},children:[jsx("defs",{children:jsx("clipPath",{id:d,children:jsx("rect",{x:"0",y:"0",width:24*g,height:"24"})})}),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}),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 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 jsx("span",{style:{display:"inline-block",width:48,height:r,borderRadius:r,backgroundColor:t,overflow:"hidden",verticalAlign:"middle"},children: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 jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:r,style:{display:"block"},children: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}=yo({elementId:e,refreshInterval:h}),[a,u]=useState("light");useEffect(()=>{if(typeof window>"u")return;let v=window.matchMedia("(prefers-color-scheme: dark)");u(v.matches?"dark":"light");let k=F=>u(F.matches?"dark":"light");return v.addEventListener("change",k),()=>v.removeEventListener("change",k)},[]);let{themeConfig:b}=I(),l=useMemo(()=>K(s,a,b),[s,a,b]);if(d||!g)return null;let i=tt[t],c=l.colors.text,p=l.colors.textDisabled,y=l.colors.starFilled,E=l.colors.starEmpty,x=l.colors.voteUp,w=l.colors.starEmpty,R={display:"inline-flex",alignItems:"center",gap:i.gap,fontFamily:l.typography.fontFamily,lineHeight:1,letterSpacing:"-0.01em",WebkitFontSmoothing:"antialiased",...n},P=(v,k)=>{let F=v===1?k:`${k}s`;return `${v.toLocaleString()} ${F}`};if(r==="votes"){let{voteCount:v,positiveRate:k}=g,F=v.up+v.down;return F===0?null:jsxs("span",{style:R,children:[jsx(at,{size:i.iconSize,color:x}),jsxs("span",{style:{fontSize:i.ratingFontSize,fontWeight:600,color:x,fontVariantNumeric:"tabular-nums"},children:[k,"%"]}),jsx(nt,{rate:k??0,height:i.barHeight,filledColor:x,trackColor:w}),o&&jsx("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:P(F,"vote")})]})}let{averageRating:S,totalResponses:T}=g;if(S===null||T===0)return null;let m=S.toFixed(1);return r==="compact"?jsxs("span",{style:R,children:[jsx("svg",{width:i.starSize,height:i.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children: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})}),jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),o&&jsxs("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:["(",T.toLocaleString(),")"]})]}):r==="number"?jsxs("span",{style:R,children:[jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),jsx("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:"/ 5"}),o&&jsxs("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400,marginLeft:2},children:["(",P(T,"response"),")"]})]}):jsxs("span",{style:R,children:[jsx(rt,{rating:S,size:i.starSize,filledColor:y,emptyColor:E}),jsx("span",{style:{fontSize:i.ratingFontSize,fontWeight:700,color:c,fontVariantNumeric:"tabular-nums"},children:m}),o&&jsxs("span",{style:{fontSize:i.fontSize,color:p,fontWeight:400},children:["(",P(T,"response"),")"]})]})}function it(){let{client:e,disabled:r,defaultUser:o,debug:t}=I();return {client:e,disabled:r,defaultUser:o,debug:t,submitFeedback:e.submitResponse.bind(e)}}
151
+ export{Qo as Gotcha,Do as GotchaProvider,st as GotchaScore,Ro as createTheme,it as useGotcha};//# sourceMappingURL=index.mjs.map
151
152
  //# sourceMappingURL=index.mjs.map