gotcha-feedback 1.2.1 → 1.2.2

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.js CHANGED
@@ -144,6 +144,6 @@ ${co}
144
144
  opacity: 1 !important;
145
145
  }
146
146
  }
147
- `.trim()}function rt(e){if(typeof document>"u")return;let o=document.getElementById(uo);o||(o=document.createElement("style"),o.id=uo,document.head.appendChild(o)),o.textContent=Ur(e);}var fo=react.createContext(null),Wr={};function Yr({apiKey:e,children:o,baseUrl:t,debug:r=false,disabled:a=false,defaultUser:s,defaultUserEmail:i,themeConfig:n}){let[p,c]=react.useState(null);t&&!t.startsWith("https://")&&!t.startsWith("/")&&!t.includes("localhost")&&console.warn("[Gotcha] baseUrl should use HTTPS in production:",t);let l=react.useMemo(()=>ao({apiKey:e,baseUrl:t,debug:r}),[e,t,r]),d=react.useMemo(()=>s??Wr,[JSON.stringify(s)]);react.useEffect(()=>{let g=ue("light","light",n);rt(g);},[n]),react.useEffect(()=>(_t(),()=>Jt()),[]),react.useEffect(()=>{l.flushQueue();let g=()=>l.flushQueue();return window.addEventListener("online",g),()=>window.removeEventListener("online",g)},[l]);let u=react.useCallback(g=>{c(g);},[]),f=react.useCallback(()=>{c(null);},[]),b=react.useMemo(()=>({client:l,disabled:a,defaultUser:d,defaultUserEmail:i,debug:r,activeModalId:p,openModal:u,closeModal:f,themeConfig:n}),[l,a,d,i,r,p,u,f,n]);return jsxRuntime.jsx(fo.Provider,{value:b,children:o})}function G(){let e=react.useContext(fo);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function jr(e,o){let t=new Date(e).getTime();if(isNaN(t))return true;let r=Date.now()-t,a=o*24*60*60*1e3;return r>=a}function go(e){let{client:o,defaultUser:t}=G(),[r,a]=react.useState(false),[s,i]=react.useState(false),[n,p]=react.useState(null),[c,l]=react.useState(null);return react.useEffect(()=>{process.env.NODE_ENV!=="production"&&e.cooldownDays&&!e.onePerUser&&console.warn("[Gotcha] cooldownDays has no effect without onePerUser=true");let u=e.user?.id||t?.id;if(!u||!e.onePerUser){l(null);return}let f=false;return (async()=>{i(true);try{let g=await o.checkExistingResponse(e.elementId,u);f||(g&&e.cooldownDays&&e.cooldownDays>0&&jr(g.createdAt,e.cooldownDays)?l(null):l(g));}catch{f||l(null);}finally{f||i(false);}})(),()=>{f=true;}},[o,e.elementId,e.user?.id,t?.id,e.onePerUser,e.cooldownDays]),{submit:react.useCallback(async u=>{a(true),p(null);try{let f=e.user?.id||t?.id,b;return e.onePerUser&&c&&f?b=await o.updateResponse(c.id,{content:u.content,title:u.title,rating:u.rating,vote:u.vote,pollSelected:u.pollSelected},f):b=await o.submitResponse({elementId:e.elementId,mode:e.mode,content:u.content,title:u.title,rating:u.rating,vote:u.vote,pollOptions:e.pollOptions,pollSelected:u.pollSelected,isBug:u.isBug,screenshot:u.screenshot,user:{...t,...e.user},userEmail:e.userEmail}),e.onePerUser&&l({id:b.id,mode:e.mode,content:u.content??null,title:u.title??null,rating:u.rating??null,vote:u.vote??null,pollSelected:u.pollSelected??null,createdAt:b.createdAt}),e.onSuccess?.(b),b}catch(f){let b=f instanceof Error?f.message:"Something went wrong";throw p(b),e.onError?.(f instanceof Error?f:new Error(b)),f}finally{a(false);}},[o,t,e,c]),isLoading:r,isCheckingExisting:s,error:n,existingResponse:c,isEditing:!!c,clearError:()=>p(null)}}function ho(e,o){return `${Z.HIDDEN_UNTIL}_${e}_${o}`}function mo(e,o,t){if(!t||t<=0)return false;let r=ho(e,o),a=ie(r);return a?new Date(a).getTime()>Date.now():false}function bo(e){let{elementId:o,userId:t,hideAfterSubmitDays:r}=e,a=react.useMemo(()=>t||et(),[t]),[s,i]=react.useState(()=>mo(o,a,r));react.useEffect(()=>{i(mo(o,a,r));},[o,a,r]);let n=react.useCallback(()=>{if(!r||r<=0)return;let p=ho(o,a),c=new Date(Date.now()+r*24*60*60*1e3);le(p,c.toISOString()),i(true);},[o,a,r]);return {isHidden:s,markHidden:n}}function _r(e){return `${Z.VISIT_COUNT}_${e}`}function wo(e){let{elementId:o,showAfterSeconds:t,showAfterScrollPercent:r,showAfterVisits:a}=e,s=t!=null||r!=null||a!=null,[i,n]=react.useState(!t),[p,c]=react.useState(!r),[l]=react.useState(()=>{if(!a)return true;let d=_r(o),f=parseInt(ie(d)||"0",10)+1;return le(d,String(f)),f>=a});return react.useEffect(()=>{if(!t||t<=0)return;let d=Date.now(),u=t*1e3,f=()=>{Date.now()-d>=u?n(true):b=setTimeout(f,Math.min(1e3,u-(Date.now()-d)));},b=setTimeout(f,Math.min(1e3,u));return ()=>clearTimeout(b)},[t]),react.useEffect(()=>{if(!r||r<=0)return;let d=()=>{let u=document.documentElement.scrollHeight,f=window.innerHeight;if(u<=f){c(true);return}(window.scrollY+f)/u*100>=r&&c(true);};if(d(),!p)return window.addEventListener("scroll",d,{passive:true}),()=>window.removeEventListener("scroll",d)},[r,p]),{conditionsMet:!s||i&&p&&l}}function st(...e){return e.filter(Boolean).join(" ")}var W=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,So=(e,o)=>{let t={sm:{desktop:24,mobile:28},md:{desktop:32,mobile:34},lg:{desktop:40,mobile:40}};return o?t[e].mobile:t[e].desktop};function en(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function vo({size:e,theme:o,customStyles:t,showOnHover:r,touchBehavior:a,onClick:s,isOpen:i,isParentHovered:n=false,animated:p=true,queuedCount:c=0}){let[l,d]=react.useState(false),[u,f]=react.useState(false),[b,g]=react.useState(en),[m,h]=react.useState(false),[w,y]=react.useState(false),[C,v]=react.useState(false),{themeConfig:E}=G();react.useEffect(()=>{if(d(W()),typeof window>"u")return;let j=window.matchMedia("(prefers-color-scheme: dark)"),ge=xe=>g(xe.matches?"dark":"light");return j.addEventListener("change",ge),()=>j.removeEventListener("change",ge)},[]);let k=i?true:!l&&r?n:l&&a==="tap-to-reveal"?u:true;react.useEffect(()=>{if(k&&!C){let j=setTimeout(()=>v(true),320);return ()=>clearTimeout(j)}},[k,C]);let P=()=>{if(l&&a==="tap-to-reveal"&&!u){f(true);return}s();},z=So(e,l),A=react.useMemo(()=>ue(o,b,E),[o,b,E]),F=i?A.colors.warning:A.colors.border,D=i?A.colors.warning:A.colors.glassColor,O=()=>k?w?"scale(0.97)":"scale(1)":"scale(0.96)",q=w?"80ms":"160ms",T=A.animation.easing.default,H=m&&!i?A.colors.surfaceHover:A.colors.glassBackground,Me={position:"relative",width:z,height:z,borderRadius:A.borders.radius.full,border:`1px solid ${F}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:H,color:D,boxShadow:m?A.colors.glassHoverShadow:A.colors.glassShadow,transition:C?`transform ${q} ${T}, background-color 180ms ${T}, box-shadow 180ms ${T}, border-color 240ms ${T}, color 240ms ${T}`:`opacity 320ms ${T}, transform 320ms ${T}`,opacity:k?1:0,transform:O(),pointerEvents:k?"auto":"none",...t?.button};return jsxRuntime.jsxs("button",{type:"button",onClick:P,onMouseEnter:()=>h(true),onMouseLeave:()=>{h(false),y(false);},onMouseDown:()=>y(true),onMouseUp:()=>y(false),onTouchStart:()=>y(true),onTouchEnd:()=>y(false),style:Me,className:st("gotcha-button",i&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":i,"aria-haspopup":"dialog",children:[jsxRuntime.jsx(tn,{size:z*.62,color:D,fontFamilyDisplay:A.typography.fontFamilyDisplay,animated:p&&!C}),c>0&&jsxRuntime.jsx("span",{"aria-label":`${c} queued`,style:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",backgroundColor:A.colors.warning,border:`1.5px solid ${A.colors.background}`}})]})}function tn({size:e,color:o,fontFamilyDisplay:t,animated:r}){let[a,s]=react.useState(false);return react.useEffect(()=>{s(true);},[]),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{fontFamily:t,fontWeight:400,fontSize:e,fontStyle:"normal",lineHeight:1,color:o,transform:"translateY(1px) translateZ(0)",willChange:"transform",letterSpacing:"normal",userSelect:"none",display:"inline-block",opacity:r?a?1:0:1,transition:r?"opacity 240ms cubic-bezier(0.22, 0.61, 0.36, 1) 120ms":"none"},children:"G"})}function Eo({src:e,onRemove:o,resolvedTheme:t}){let[r,a]=react.useState(false),[s,i]=react.useState(false);react.useEffect(()=>{a(W());},[]);let n=(()=>{if(!e.startsWith("data:"))return null;let p=e.indexOf(",");if(p<0)return null;let c=e.slice(p+1);return Math.round(c.length*3/4/1024)})();return jsxRuntime.jsxs("div",{style:{marginTop:12},children:[jsxRuntime.jsxs("div",{style:{position:"relative",borderRadius:t.borders.radius.sm,overflow:"hidden",border:`1px solid ${t.colors.border}`,padding:4,background:t.colors.background},children:[jsxRuntime.jsx("img",{src:e,alt:"Screenshot attached to the feedback",style:{display:"block",width:"100%",maxHeight:140,objectFit:"cover",borderRadius:Math.max(0,t.borders.radius.sm-2)}}),jsxRuntime.jsx("button",{type:"button",onClick:o,onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),"aria-label":"Remove screenshot",style:{position:"absolute",top:8,right:8,width:r?32:24,height:r?32:24,borderRadius:"50%",border:`1px solid ${s?t.colors.error:t.colors.border}`,backgroundColor:s?t.colors.error:t.colors.background,color:s?t.colors.primaryText:t.colors.textSecondary,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:`all ${t.animation.duration.fast} ${t.animation.easing.default}`},children:jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),jsxRuntime.jsxs("p",{style:{margin:"6px 0 0",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",fontSize:10,letterSpacing:"0.08em",textTransform:"uppercase",color:t.colors.textSecondary},children:["screenshot.png",n!=null?` \xB7 ${n} KB`:""]})]})}function _o({resolvedTheme:e,placeholder:o,submitText:t,isLoading:r,onSubmit:a,customStyles:s,initialValues:i,isEditing:n=false,showText:p=true,showRating:c=true,enableBugFlag:l=false,bugFlagLabel:d,enableScreenshot:u=false}){let[f,b]=react.useState(i?.content||""),[g,m]=react.useState(i?.rating??null),[h,w]=react.useState(false),[y,C]=react.useState(false),[v,E]=react.useState(null),[k,P]=react.useState(false),[z,A]=react.useState(false);react.useEffect(()=>{C(W());},[]),react.useEffect(()=>{i?.content!==void 0&&b(i.content||""),i?.rating!==void 0&&m(i.rating??null);},[i?.content,i?.rating]);let F=p&&c?f.trim().length>0||g!==null:p?f.trim().length>0:c?g!==null:false,D=async()=>{P(true),A(false);try{let{captureScreenshot:T}=await Promise.resolve().then(()=>(Zo(),Ko)),H=await T();H?E(H):A(!0);}catch{A(true);}finally{P(false);}},O=T=>{T.preventDefault(),!(!F||r)&&a({content:p&&f.trim()?f.trim():void 0,rating:c&&g!==null?g:void 0,isBug:h||void 0,screenshot:v||void 0});},q={width:"100%",padding:y?"12px 0":"10px 0",border:"none",borderBottom:`1px solid ${e.colors.inputBorder}`,borderRadius:0,backgroundColor:"transparent",color:e.colors.text,fontSize:y?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:y?96:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.55,...s?.input};return jsxRuntime.jsxs("form",{onSubmit:O,children:[c&&jsxRuntime.jsx("div",{style:{marginBottom:p?y?18:16:0,...p?{}:{display:"flex",justifyContent:"center",padding:"6px 0"}},children:jsxRuntime.jsx(Cs,{value:g,onChange:m,theme:e,isTouch:y,large:!p})}),p&&jsxRuntime.jsx("textarea",{value:f,onChange:T=>b(T.target.value),placeholder:o||"Share your thoughts\u2026",maxLength:5e3,style:q,disabled:r,"aria-label":"Your feedback",onFocus:T=>{T.currentTarget.style.borderBottomColor=e.colors.inputBorderFocus;},onBlur:T=>{T.currentTarget.style.borderBottomColor=e.colors.inputBorder;}}),l&&jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":h,onClick:()=>w(!h),style:{display:"flex",alignItems:"center",gap:10,width:"100%",marginTop:16,padding:y?"12px 12px":"10px 12px",border:`1px solid ${h?e.colors.warningBorder:e.colors.border}`,borderRadius:e.borders.radius.sm,backgroundColor:h?e.colors.warningSurface:"transparent",cursor:"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,fontFamily:e.typography.fontFamily,...s?.bugFlag},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:3,border:`1px solid ${h?e.colors.warningActive:e.colors.border}`,backgroundColor:h?e.colors.warning:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},children:h&&jsxRuntime.jsx("svg",{width:8,height:8,viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M2 5L4 7L8 3",stroke:e.colors.primaryText,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.normal,color:h?e.colors.text:e.colors.textSecondary,letterSpacing:"0",textAlign:"left",flex:1},children:h?"Reported as an issue":d||"Report an issue"})]}),l&&u&&h&&!v&&jsxRuntime.jsxs("button",{type:"button",onClick:D,disabled:k,style:{display:"flex",alignItems:"center",gap:8,width:"100%",marginTop:8,padding:"9px 12px",border:`1px solid ${e.colors.border}`,borderRadius:e.borders.radius.sm,backgroundColor:"transparent",cursor:k?"progress":"pointer",fontFamily:e.typography.fontFamily,fontSize:e.typography.fontSize.xs,letterSpacing:"0.06em",textTransform:"uppercase",color:e.colors.textSecondary,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},onMouseEnter:T=>{T.currentTarget.style.borderColor=e.colors.inputBorderFocus,T.currentTarget.style.color=e.colors.text;},onMouseLeave:T=>{T.currentTarget.style.borderColor=e.colors.border,T.currentTarget.style.color=e.colors.textSecondary;},children:[jsxRuntime.jsxs("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"10",r:"3"}),jsxRuntime.jsx("path",{d:"M2 17l4-4 3 3 4-4 9 9"})]}),k?"Capturing\u2026":"Attach screenshot"]}),z&&jsxRuntime.jsxs("div",{role:"alert",style:{marginTop:8,padding:"6px 0 6px 10px",borderLeft:`2px solid ${e.colors.error}`,fontSize:e.typography.fontSize.xs,color:e.colors.text,fontFamily:e.typography.fontFamily,display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[jsxRuntime.jsx("span",{children:"Screenshot capture unavailable."}),jsxRuntime.jsx("button",{type:"button",onClick:D,style:{background:"none",border:"none",padding:0,color:e.colors.text,fontFamily:e.typography.fontFamily,fontSize:e.typography.fontSize.xs,textDecoration:"underline",textDecorationColor:e.colors.border,textUnderlineOffset:3,cursor:"pointer"},children:"Try again"})]}),l&&u&&h&&v&&jsxRuntime.jsx(Eo,{src:v,onRemove:()=>E(null),resolvedTheme:e}),jsxRuntime.jsx("button",{type:"submit",disabled:r||!F,style:{width:"100%",padding:y?"14px 16px":"11px 16px",marginTop:18,border:"none",borderRadius:e.borders.radius.sm,backgroundColor:F?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:F?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||!F?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:r?"italic":"normal",...s?.submitButton},onMouseEnter:T=>{T.currentTarget.disabled||(T.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:T=>{T.currentTarget.disabled||(T.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:r?n?"Updating\u2026":"Sending\u2026":n?"Update":t})]})}function Cs({value:e,onChange:o,theme:t,isTouch:r,large:a=false}){let[s,i]=react.useState(null),n=a?r?34:28:r?26:20,p=a?8:6,c=a?r?6:4:r?6:2,l=d=>s!==null&&s>=d?`${(d-1)*30}ms`:"0ms";return jsxRuntime.jsx("div",{style:{display:"flex",gap:p},role:"group","aria-label":"Rating",onMouseLeave:()=>i(null),children:[1,2,3,4,5].map(d=>{let u=(s??e??0)>=d;return jsxRuntime.jsx("button",{type:"button",onClick:()=>o(d),onMouseEnter:()=>i(d),"aria-label":`Rate ${d} out of 5`,"aria-pressed":e===d,style:{background:"none",border:"none",cursor:"pointer",padding:c,color:u?t.colors.starFilled:t.colors.starEmpty,transition:`color 180ms ${t.animation.easing.default}`,transitionDelay:l(d),outline:"none",WebkitTapHighlightColor:"transparent"},children:jsxRuntime.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:u?"currentColor":"none",stroke:"currentColor",strokeWidth:u?0:1.5,strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M12 3.5L14.472 8.506L20 9.308L16 13.205L16.944 18.706L12 16.107L7.056 18.706L8 13.205L4 9.308L9.528 8.506L12 3.5Z"})})},d)})})}function Jo({resolvedTheme:e,isLoading:o,onSubmit:t,initialVote:r,isEditing:a=false,labels:s}){let[i,n]=react.useState(false),[p,c]=react.useState(r||null),[l,d]=react.useState(r||null);react.useEffect(()=>{n(W());},[]),react.useEffect(()=>{r!==void 0&&(d(r),c(r));},[r]),react.useEffect(()=>{!o&&!a&&c(null);},[o,a]);let u=m=>{c(m),t({vote:m});},f=i?24:20,b=m=>{let h=l===m,w=m==="up"?e.colors.voteUp:e.colors.voteDown,y=m==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,C=m==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return {flex:1,minWidth:0,padding:i?"14px 18px":"11px 16px",border:`1px solid ${h?w:C}`,borderRadius:e.borders.radius.full,background:h?w:y,color:h?e.colors.primaryText:e.colors.text,fontSize:i?15:13,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:o?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}, border-color ${e.animation.duration.fast} ${e.animation.easing.default}, color ${e.animation.duration.fast} ${e.animation.easing.default}`,display:"flex",alignItems:"center",justifyContent:"center",gap:i?10:8,outline:"none"}},g=(m,h)=>s?.[m]?s[m]:m==="up"?h?"Liked":"Like":h?"Disliked":"Dislike";return jsxRuntime.jsx("div",{style:{display:"flex",gap:i?12:10},role:"group","aria-label":"Vote",children:["up","down"].map(m=>{let h=l===m,w=o&&p===m,y=g(m,h),C=w?`${y}, submitting`:y,v=m==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>u(m),disabled:o,style:b(m),"aria-label":C,"aria-pressed":h,onMouseEnter:E=>{o||h||(E.currentTarget.style.borderColor=e.colors.inputBorderFocus);},onMouseLeave:E=>{h||(E.currentTarget.style.borderColor=v);},children:[m==="up"?jsxRuntime.jsx(ks,{size:f}):jsxRuntime.jsx(As,{size:f}),jsxRuntime.jsx("span",{style:{fontStyle:w?"italic":"normal"},children:w?a?"Updating\u2026":"Sending\u2026":y})]},m)})})}function ks({size:e=20}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function As({size:e=20}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function tr({resolvedTheme:e,options:o,allowMultiple:t,isLoading:r,onSubmit:a,initialSelected:s,isEditing:i=false}){let[n,p]=react.useState(s||[]),[c,l]=react.useState(false),[d,u]=react.useState(null);react.useEffect(()=>{l(W());},[]),react.useEffect(()=>{s&&p(s);},[s]);let f=m=>{r||p(t?h=>h.includes(m)?h.filter(w=>w!==m):[...h,m]:h=>h.includes(m)?[]:[m]);},b=()=>{n.length===0||r||a({pollSelected:n});},g=c?"14px 14px":"12px 14px";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("ul",{role:"group","aria-label":t?"Select one or more options":"Select an option",style:{listStyle:"none",margin:0,padding:0,borderTop:`1px solid ${e.colors.border}`},children:o.map((m,h)=>{let w=n.includes(m),y=d===h;return jsxRuntime.jsxs("li",{style:{borderBottom:`1px solid ${e.colors.border}`,position:"relative",animation:`gotcha-fade-up ${e.animation.duration.normal} ${e.animation.easing.default} both`,animationDelay:`${h*.04}s`},children:[w&&jsxRuntime.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:8,bottom:8,width:2,backgroundColor:e.colors.pollSelectedBorder}}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>f(m),onMouseEnter:()=>u(h),onMouseLeave:()=>u(null),disabled:r,"aria-pressed":w,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:g,paddingLeft:w?16:14,border:"none",background:y&&!w?e.colors.surfaceHover:"transparent",color:e.colors.text,fontSize:c?15:e.typography.fontSize.md,fontWeight:w?e.typography.fontWeight.medium:e.typography.fontWeight.normal,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,textAlign:"left",letterSpacing:"0",outline:"none"},children:[jsxRuntime.jsx("span",{style:{flex:1},children:m}),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:t?3:"50%",border:`1px solid ${w?e.colors.pollCheckSelectedBorder:e.colors.pollCheckBorder}`,backgroundColor:w?e.colors.pollCheckSelectedBg:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},children:w&&jsxRuntime.jsx("svg",{width:8,height:8,viewBox:"0 0 10 10",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 5L4 7L8 3",stroke:e.colors.primaryText,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]},m)})}),jsxRuntime.jsx("button",{type:"button",onClick:b,disabled:r||n.length===0,style:{width:"100%",marginTop:18,padding:c?"14px 16px":"11px 16px",border:"none",borderRadius:e.borders.radius.sm,backgroundColor:n.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,color:n.length===0?e.colors.buttonColorDisabled:e.colors.buttonColor,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||n.length===0?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:r?"italic":"normal"},onMouseEnter:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:r?i?"Updating\u2026":"Sending\u2026":i?"Update":"Submit"})]})}function rr({size:e=16,color:o="currentColor"}){let r=2*Math.PI*9,a=r*.25;return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Loading",style:{animation:"gotcha-spin 1.1s linear infinite",transformOrigin:"center"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:9,stroke:o,strokeOpacity:"0.18",strokeWidth:"1.25",fill:"none"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:9,stroke:o,strokeWidth:"1.25",strokeLinecap:"round",fill:"none",strokeDasharray:`${a} ${r}`,strokeDashoffset:"0"})]})}function sr({resolvedTheme:e,submitText:o,isLoading:t,onSubmit:r,customStyles:a,showFollowUp:s=true,followUpPlaceholder:i,lowLabel:n="Not likely",highLabel:p="Very likely",initialValues:c,isEditing:l=false}){let[d,u]=react.useState(c?.rating??null),[f,b]=react.useState(c?.content||""),[g,m]=react.useState(false),[h,w]=react.useState(null);react.useEffect(()=>{m(W());},[]),react.useEffect(()=>{c?.rating!==void 0&&u(c.rating??null),c?.content!==void 0&&b(c.content||"");},[c?.rating,c?.content]);let y=d!==null;return jsxRuntime.jsxs("form",{onSubmit:v=>{v.preventDefault(),!(!y||t)&&r({rating:d??void 0,content:s&&f.trim()?f.trim():void 0});},children:[jsxRuntime.jsx("div",{style:{position:"relative",display:"flex",gap:g?4:5,justifyContent:"center"},role:"group","aria-label":"NPS Score",onMouseLeave:()=>w(null),children:Array.from({length:11},(v,E)=>{let k=d===E,P=h===E;return jsxRuntime.jsx("button",{type:"button",onClick:()=>u(E),onMouseEnter:()=>w(E),"aria-label":`Score ${E} out of 10`,"aria-pressed":k,style:{flex:1,minWidth:0,aspectRatio:"1",borderRadius:e.borders.radius.sm,border:`1px solid ${k?e.colors.buttonBackground:P?e.colors.inputBorderFocus:e.colors.border}`,backgroundColor:k?e.colors.buttonBackground:"transparent",color:k?e.colors.buttonColor:e.colors.text,fontSize:15,fontWeight:k?e.typography.fontWeight.medium:e.typography.fontWeight.normal,fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}, border-color ${e.animation.duration.fast} ${e.animation.easing.default}, color ${e.animation.duration.fast} ${e.animation.easing.default}`,outline:"none",...a?.npsButton,...k?a?.npsButtonSelected:{}},children:E},E)})}),jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:12,padding:"0 2px",...a?.npsLabels},children:[n,p].map(v=>jsxRuntime.jsx("span",{style:{fontFamily:e.typography.fontFamily,fontSize:11,color:e.colors.text,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.14em",textTransform:"uppercase"},children:v},v))}),s&&d!==null&&jsxRuntime.jsx("textarea",{value:f,onChange:v=>b(v.target.value),placeholder:i||"What's the main reason for your score?",maxLength:5e3,style:{width:"100%",padding:g?"12px 0":"10px 0",marginTop:18,border:"none",borderBottom:`1px solid ${e.colors.inputBorder}`,borderRadius:0,backgroundColor:"transparent",color:e.colors.text,fontSize:g?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:g?72:56,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.55,animation:`gotcha-expand-in ${e.animation.duration.normal} ${e.animation.easing.default} both`,overflow:"hidden",...a?.input},disabled:t,"aria-label":"Follow-up feedback",onFocus:v=>{v.currentTarget.style.borderBottomColor=e.colors.inputBorderFocus;},onBlur:v=>{v.currentTarget.style.borderBottomColor=e.colors.inputBorder;}}),jsxRuntime.jsx("button",{type:"submit",disabled:t||!y,style:{width:"100%",marginTop:18,padding:g?"14px 16px":"11px 16px",border:"none",borderRadius:e.borders.radius.sm,backgroundColor:y?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:y?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:t||!y?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:t?"italic":"normal",...a?.submitButton},onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:v=>{v.currentTarget.disabled||(v.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:t?l?"Updating\u2026":"Sending\u2026":l?"Update":o})]})}function ir({resolvedTheme:e,promptText:o,placeholder:t,isLoading:r,onSubmit:a}){let[s,i]=react.useState(""),[n,p]=react.useState(false);return react.useEffect(()=>{p(W());},[]),jsxRuntime.jsxs("form",{onSubmit:l=>{l.preventDefault(),!(!s.trim()||r)&&a(s.trim());},children:[jsxRuntime.jsx("p",{style:{margin:"0 0 14px 0",fontFamily:e.typography.fontFamilyDisplay,fontSize:n?17:16,fontStyle:"italic",color:e.colors.text,lineHeight:1.45,letterSpacing:"-0.01em"},children:o}),jsxRuntime.jsx("textarea",{value:s,onChange:l=>i(l.target.value),placeholder:t||"Tell us more\u2026",maxLength:5e3,disabled:r,"aria-label":"Follow-up feedback",style:{width:"100%",padding:n?"12px 0":"10px 0",border:"none",borderBottom:`1px solid ${e.colors.inputBorder}`,borderRadius:0,backgroundColor:"transparent",color:e.colors.text,fontSize:n?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:n?96:72,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.55},onFocus:l=>{l.currentTarget.style.borderBottomColor=e.colors.inputBorderFocus;},onBlur:l=>{l.currentTarget.style.borderBottomColor=e.colors.inputBorder;}}),jsxRuntime.jsx("button",{type:"submit",disabled:r||!s.trim(),style:{width:"100%",marginTop:16,padding:n?"14px 16px":"11px 16px",border:"none",borderRadius:e.borders.radius.sm,backgroundColor:s.trim()?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:s.trim()?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||!s.trim()?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:r?"italic":"normal"},onMouseEnter:l=>{l.currentTarget.disabled||(l.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:l=>{l.currentTarget.disabled||(l.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:r?"Sending\u2026":"Submit"})]})}var Ls={feedback:"Feedback",vote:"Vote",poll:"Poll",nps:"Rate"};function Ps(e,o){switch(e){case "vote":return "What do you think?";case "poll":return "Cast your vote.";case "nps":return o||"How likely are you to recommend us?";default:return "What do you think of this feature?"}}var Ns=4e3;function cr({mode:e,theme:o,customStyles:t,promptText:r,placeholder:a,submitText:s,thankYouMessage:i,isLoading:n,isCheckingExisting:p=false,isSubmitted:c,phase:l="form",followUpConfig:d,followUpLoading:u=false,onFollowUpSubmit:f,error:b,existingResponse:g,isEditing:m=false,showText:h=true,showRating:w=true,voteLabels:y,options:C,allowMultiple:v=false,npsQuestion:E,npsFollowUp:k=true,npsFollowUpPlaceholder:P,npsLowLabel:z,npsHighLabel:A,enableBugFlag:F=false,bugFlagLabel:D,enableScreenshot:O=false,onSubmit:q,onClose:T,anchorRect:H,useFixedPosition:Me=false,isMobile:j}){let ge=react.useRef(null),xe=react.useRef(null),Ie=react.useRef(T);Ie.current=T;let[Ve,gt]=react.useState(false),U=j??Ve,[je,Qe]=react.useState("light"),{themeConfig:_}=G();react.useEffect(()=>{if(typeof window>"u")return;let I=window.matchMedia("(prefers-color-scheme: dark)"),Q=N=>Qe(N.matches?"dark":"light");Q(I);let Y=N=>Q(N);I.addEventListener("change",Y);let K=[()=>I.removeEventListener("change",Y)];if(j===void 0){let N=window.matchMedia("(max-width: 1023px)"),re=()=>gt(N.matches);re(),N.addEventListener("change",re),K.push(()=>N.removeEventListener("change",re));}return ()=>{for(let N of K)N();}},[j]);let S=react.useMemo(()=>ue(o,je,_),[o,je,_]);react.useEffect(()=>{rt(S);},[S]);let Le=typeof window>"u"||!H?false:window.innerHeight-H.bottom<340;react.useEffect(()=>{let I=ge.current;if(!I)return;xe.current?.focus();let Q=Y=>{if(Y.key==="Escape"){Ie.current();return}if(Y.key==="Tab"){let K=I.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),N=K[0],re=K[K.length-1];Y.shiftKey&&document.activeElement===N?(Y.preventDefault(),re?.focus()):!Y.shiftKey&&document.activeElement===re&&(Y.preventDefault(),N?.focus());}};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[]);let me=r||Ps(e,E),Ke=Ls[e],he=e==="nps"?420:e==="poll"?400:360,Ze=U?"gotcha-modal-enter-center":Le?"gotcha-modal-enter-above":"gotcha-modal-enter",Pe=typeof window<"u"?window.innerHeight:0,V={padding:0,borderRadius:S.borders.radius.lg,background:S.colors.background,color:S.colors.text,boxShadow:S.shadows.modal,border:`${S.borders.width}px solid ${S.colors.border}`,fontFamily:S.typography.fontFamily,textAlign:"left",overflow:"hidden"},Ne=U?{...V,position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"calc(100vw - 32px)",maxWidth:he,zIndex:9999,...t?.modal}:Me&&H&&Pe?(()=>{let I=window.innerWidth,Q=24,K=H.left+H.width/2-he/2,N=Math.max(Q,Math.min(K,I-he-Q));return {...V,position:"fixed",left:N,width:he,zIndex:99999,...Le?{bottom:Pe-H.top+10}:{top:H.bottom+10},...t?.modal}})():{...V,position:"absolute",left:"50%",width:he,zIndex:9999,...Le?{bottom:"100%",marginBottom:10,transform:"translateX(-50%)"}:{top:"100%",marginTop:10,transform:"translateX(-50%)"},...t?.modal},oe=I=>U?{}:{animation:`gotcha-fade-up ${S.animation.duration.normal} ${S.animation.easing.default} both`,animationDelay:`${I*.04}s`},mt=U?"20px 24px 24px":"20px 28px 24px";return jsxRuntime.jsxs("div",{ref:ge,role:"dialog","aria-modal":"true","aria-label":c?"Feedback submitted":void 0,"aria-labelledby":c?void 0:"gotcha-modal-title","data-gotcha":true,style:Ne,className:st("gotcha-modal","gotcha-root",Ze),children:[!c&&jsxRuntime.jsxs("header",{style:{padding:U?"20px 24px 16px":"22px 28px 16px",borderBottom:`${S.borders.width}px solid ${S.colors.border}`,position:"relative"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,...oe(0)},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:16,height:1,backgroundColor:S.colors.warning}}),jsxRuntime.jsx("span",{style:{fontFamily:S.typography.fontFamily,fontSize:10,fontWeight:S.typography.fontWeight.medium,letterSpacing:"0.16em",textTransform:"uppercase",color:S.colors.textSecondary},children:Ke})]}),jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:0,paddingRight:U?52:44,fontFamily:S.typography.fontFamilyDisplay,fontSize:U?22:20,fontWeight:S.typography.fontWeight.normal,letterSpacing:"-0.01em",lineHeight:1.25,color:S.colors.text,...oe(1),...t?.title},children:me}),jsxRuntime.jsx("button",{ref:xe,type:"button",onClick:T,"aria-label":"Close feedback form",style:{position:"absolute",top:U?14:16,right:U?14:18,width:U?44:32,height:U?44:32,border:"none",background:"transparent",outline:"none",cursor:"pointer",color:S.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:S.borders.radius.sm,transition:`color ${S.animation.duration.fast} ${S.animation.easing.default}`,...t?.closeButton},onMouseEnter:I=>{I.currentTarget.style.color=S.colors.closeButtonHover;},onMouseLeave:I=>{I.currentTarget.style.color=S.colors.closeButton;},children:jsxRuntime.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L11 11M1 11L11 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),jsxRuntime.jsxs("div",{style:{padding:c?0:mt,position:"relative"},children:[b&&!c&&jsxRuntime.jsxs("div",{role:"alert",style:{padding:"2px 0 2px 14px",marginBottom:16,borderLeft:`2px solid ${S.colors.error}`,color:S.colors.text,fontSize:S.typography.fontSize.sm,lineHeight:1.55,...oe(2),...t?.errorMessage},children:[b,jsxRuntime.jsx("span",{style:{color:S.colors.textSecondary},children:" \u2014 try again?"})]}),c&&jsxRuntime.jsxs("div",{style:{padding:U?"32px 24px 28px":"36px 28px 28px",textAlign:"center",position:"relative"},children:[jsxRuntime.jsx("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",style:{display:"block",margin:"0 auto 14px",...t?.successIcon},children:jsxRuntime.jsx("path",{d:"M10 20.5L17 27.5L31 13.5",stroke:S.colors.success,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:30,strokeDashoffset:30,animation:`gotcha-check-draw 320ms ${S.animation.easing.default} forwards`}})}),jsxRuntime.jsx("p",{style:{margin:0,fontFamily:S.typography.fontFamilyDisplay,fontSize:22,fontWeight:S.typography.fontWeight.normal,letterSpacing:"-0.01em",color:S.colors.text,...t?.successMessage},children:i}),jsxRuntime.jsx("p",{style:{margin:"8px 0 0",fontFamily:S.typography.fontFamily,fontSize:S.typography.fontSize.sm,color:S.colors.textSecondary,fontStyle:"italic"},children:"We\u2019ll close this in a moment."}),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:1,right:1,bottom:1,height:1,backgroundColor:S.colors.success,transformOrigin:"left center",animation:`gotcha-progress ${Ns}ms linear forwards`}})]}),l==="followUp"&&d&&f&&!c&&jsxRuntime.jsx("div",{style:oe(2),children:jsxRuntime.jsx(ir,{resolvedTheme:S,promptText:d.promptText,placeholder:d.placeholder,isLoading:u,onSubmit:f})}),l==="form"&&p&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"24px 0",...oe(2)},children:jsxRuntime.jsx(rr,{size:20,color:S.colors.textSecondary})}),l==="form"&&!p&&!c&&jsxRuntime.jsxs("div",{style:oe(2),children:[e==="feedback"&&jsxRuntime.jsx(_o,{resolvedTheme:S,placeholder:a,submitText:s,isLoading:n,onSubmit:q,customStyles:t,initialValues:g?{content:g.content,rating:g.rating}:void 0,isEditing:m,showText:h,showRating:w,enableBugFlag:F,bugFlagLabel:D,enableScreenshot:O}),e==="vote"&&jsxRuntime.jsx(Jo,{resolvedTheme:S,isLoading:n,onSubmit:q,initialVote:g?.vote||void 0,isEditing:m,labels:y}),e==="nps"&&jsxRuntime.jsx(sr,{resolvedTheme:S,submitText:s,isLoading:n,onSubmit:q,showFollowUp:k,followUpPlaceholder:P,lowLabel:z,highLabel:A,customStyles:t,initialValues:g?{rating:g.rating,content:g.content}:void 0,isEditing:m}),e==="poll"&&C&&C.length>0&&jsxRuntime.jsx(tr,{resolvedTheme:S,options:C,allowMultiple:v,isLoading:n,onSubmit:q,initialSelected:g?.pollSelected||void 0,isEditing:m})]})]}),jsxRuntime.jsx("div",{"aria-live":"polite",className:"sr-only",style:{position:"absolute",left:-9999},children:c?"Thank you. Your feedback has been submitted.":b?`Error: ${b}`:""})]})}function Gs({elementId:e,user:o,userEmail:t,mode:r="feedback",showText:a=true,showRating:s=true,voteLabels:i,options:n,allowMultiple:p=false,npsQuestion:c,npsFollowUp:l=true,npsFollowUpPlaceholder:d,npsLowLabel:u,npsHighLabel:f,enableBugFlag:b=false,bugFlagLabel:g,enableScreenshot:m=false,onePerUser:h=false,cooldownDays:w,hideAfterSubmitDays:y,showAfterSeconds:C,showAfterScrollPercent:v,showAfterVisits:E,followUp:k,animated:P=true,position:z=ae.POSITION,size:A=ae.SIZE,theme:F=ae.THEME,customStyles:D,visible:O=true,showOnHover:q=ae.SHOW_ON_HOVER,touchBehavior:T=ae.TOUCH_BEHAVIOR,promptText:H,placeholder:Me,submitText:j=ae.SUBMIT_TEXT,thankYouMessage:ge=ae.THANK_YOU_MESSAGE,onSubmit:xe,onOpen:Ie,onClose:Ve,onError:gt}){let{disabled:U,activeModalId:je,openModal:Qe,closeModal:_,defaultUser:S,defaultUserEmail:Le,client:me,debug:Ke}=G(),{conditionsMet:Wt}=wo({elementId:e,showAfterSeconds:C,showAfterScrollPercent:v,showAfterVisits:E}),{isHidden:he,markHidden:Ze}=bo({elementId:e,userId:o?.id||S?.id,hideAfterSubmitDays:y}),[Pe,V]=react.useState("form"),[Ne,oe]=react.useState(null),[mt,I]=react.useState(false),[Q,Y]=react.useState(0),[K,N]=react.useState(false),[re,Yt]=react.useState(null),[X,fr]=react.useState(false),[qt,gr]=react.useState(false),Ee=react.useRef(null),Ge=react.useRef(),mr=react.useRef(null),Ue=react.useRef(null),[be,$e]=react.useState(null);react.useEffect(()=>{if(gr(true),typeof window>"u")return;let x=window.matchMedia("(max-width: 1023px)"),M=()=>fr(x.matches);return M(),x.addEventListener("change",M),()=>{x.removeEventListener("change",M),clearTimeout(Ge.current);}},[]),react.useEffect(()=>{Y(me.getQueueLength());let x=()=>{setTimeout(()=>Y(me.getQueueLength()),2e3);};return window.addEventListener("online",x),()=>window.removeEventListener("online",x)},[me]);let ne=je===e;react.useEffect(()=>{if(!ne||X)return;let x=0,M=()=>{x||(x=requestAnimationFrame(()=>{x=0;let se=Ee.current;if(!se)return;let Te=se.querySelector("button");Yt((Te??se).getBoundingClientRect());}));};return window.addEventListener("resize",M),window.addEventListener("scroll",M,{passive:true}),()=>{x&&cancelAnimationFrame(x),window.removeEventListener("resize",M),window.removeEventListener("scroll",M);}},[ne,X]),react.useEffect(()=>{ne||(V("form"),clearTimeout(Ge.current));},[ne]),react.useEffect(()=>{if(!ne||!X)return;let x=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=x;}},[ne,X]),react.useEffect(()=>{if(!q)return;let x=Ee.current;if(!x)return;let M=x.parentElement;if(!M)return;let se=()=>N(true),Te=()=>N(false);return M.addEventListener("mouseenter",se),M.addEventListener("mouseleave",Te),()=>{M.removeEventListener("mouseenter",se),M.removeEventListener("mouseleave",Te);}},[q]);let{submit:_e,isLoading:hr,isCheckingExisting:br,error:yr,existingResponse:wr,isEditing:Xt}=go({elementId:e,mode:r,pollOptions:n,user:o,userEmail:t??Le,onePerUser:h,cooldownDays:w,onSuccess:x=>{oe(x.id),xe?.(x),$e(null),Ue.current=null;},onError:x=>{console.warn("[Gotcha] Submission failed:",x instanceof Error?x.message:x),gt?.(x),Ue.current&&$e({message:x instanceof Error?x.message:"Something went wrong",retrying:false});}}),Sr=react.useCallback(()=>{if(Ee.current){let x=Ee.current.querySelector("button");Yt((x??Ee.current).getBoundingClientRect());}Qe(e),Ie?.();},[e,Qe,Ie]),Vt=react.useCallback(()=>{clearTimeout(Ge.current),_(),V("form"),Ve?.();},[_,Ve]),vr=react.useCallback(x=>{mr.current={rating:x.rating,vote:x.vote},Ue.current=x,k&&(k.ratingThreshold!=null&&x.rating!=null&&x.rating<=k.ratingThreshold||k.onNegativeVote&&x.vote==="down")&&r!=="poll"?V("followUp"):(V("success"),Ge.current=setTimeout(()=>{_(),V("form");},4e3)),y&&Ze();let se=typeof performance<"u"?performance.now():Date.now();_e(x).catch(()=>{}).finally(()=>{if(Ke){let Te=(typeof performance<"u"?performance.now():Date.now())-se;console.log(`[Gotcha] Server ack in ${Te.toFixed(0)}ms`);}});},[_e,k,r,y,Ze,_,Ke]),xr=react.useCallback(()=>{let x=Ue.current;!x||!be||be.retrying||($e({...be,retrying:true}),_e(x).catch(()=>{}));},[be,_e]),Er=react.useCallback(()=>{$e(null),Ue.current=null;},[]),Tr=react.useCallback(async x=>{if(Ne){I(true);try{await me.updateResponse(Ne,{content:x});}catch(M){console.warn("[Gotcha] Follow-up submission failed:",M instanceof Error?M.message:M);}finally{I(false),V("success"),Ge.current=setTimeout(()=>{_(),V("form");},4e3);}}},[Ne,_,me]),Cr=h&&Xt?"Update":j;if(U||!O||he||!Wt)return null;let kr={"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"}},Ar={mode:r,theme:F,customStyles:D,promptText:H,placeholder:Me,submitText:Cr,thankYouMessage:ge,isLoading:hr,isCheckingExisting:h&&br,isSubmitted:Pe==="success",phase:Pe,followUpConfig:k,followUpLoading:mt,onFollowUpSubmit:Tr,error:yr,existingResponse:h?wr:null,isEditing:h&&Xt,showText:a,showRating:s,voteLabels:i,options:n,allowMultiple:p,npsQuestion:c,npsFollowUp:l,npsFollowUpPlaceholder:d,npsLowLabel:u,npsHighLabel:f,enableBugFlag:b,bugFlagLabel:g,enableScreenshot:m,onSubmit:vr,onClose:Vt,anchorRect:re||void 0,useFixedPosition:!X,isMobile:X};return jsxRuntime.jsxs("div",{ref:Ee,style:{...kr[z],zIndex:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(vo,{size:A,theme:F,customStyles:D,showOnHover:q,touchBehavior:T,onClick:Sr,isOpen:ne,isParentHovered:K,animated:P,queuedCount:Q}),be&&qt&&reactDom.createPortal(jsxRuntime.jsx(Us,{message:be.message,retrying:be.retrying,onRetry:xr,onDismiss:Er}),document.body),ne&&qt&&reactDom.createPortal(jsxRuntime.jsx("div",{role:"presentation",onClick:X?Vt:void 0,style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:X?"rgba(26,23,20,0.32)":"transparent",backdropFilter:X?"blur(8px)":"none",WebkitBackdropFilter:X?"blur(8px)":"none",pointerEvents:X?"auto":"none",transition:"background-color 180ms cubic-bezier(0.22, 0.61, 0.36, 1)"},children:jsxRuntime.jsx("div",{onClick:X?x=>x.stopPropagation():void 0,style:{pointerEvents:"auto"},children:jsxRuntime.jsx(cr,{...Ar})})}),document.body)]})}function Us({message:e,retrying:o,onRetry:t,onDismiss:r}){return jsxRuntime.jsxs("div",{role:"status","aria-live":"polite",className:"editorial",style:{position:"fixed",bottom:16,right:16,zIndex:99998,maxWidth:360,borderRadius:6,border:"1px solid rgba(155, 58, 46, 0.35)",backgroundColor:"#FAF8F4",boxShadow:"0 4px 16px rgba(26, 23, 20, 0.12)",padding:"14px 16px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif",color:"#1A1714",animation:"gotcha-fade-up 240ms cubic-bezier(0.22, 0.61, 0.36, 1)"},children:[jsxRuntime.jsx("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, 'Courier New', monospace",fontSize:10,textTransform:"uppercase",letterSpacing:"0.18em",color:"#9B3A2E",marginBottom:6},children:"Couldn\u2019t save"}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:13,lineHeight:1.55,color:"#1A1714"},children:e||"Your feedback didn\u2019t reach us. Retry?"}),jsxRuntime.jsxs("div",{style:{marginTop:12,display:"flex",gap:8},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:o,style:{backgroundColor:"#1A1714",color:"#FAF8F4",border:"none",borderRadius:4,padding:"6px 14px",fontSize:12,fontWeight:500,cursor:o?"default":"pointer",opacity:o?.6:1,transition:"opacity 180ms"},children:o?"Retrying\u2026":"Retry"}),jsxRuntime.jsx("button",{type:"button",onClick:r,style:{backgroundColor:"transparent",color:"#6B655D",border:"1px solid #E8E2D9",borderRadius:4,padding:"6px 14px",fontSize:12,cursor:"pointer",transition:"color 180ms"},children:"Dismiss"})]})]})}function dr({elementId:e,refreshInterval:o}){let{client:t}=G(),[r,a]=react.useState(null),[s,i]=react.useState(true),[n,p]=react.useState(null);return react.useEffect(()=>{let c=false,l=async()=>{try{let u=await t.getScore(e);c||(a(u),p(null));}catch(u){c||p(u instanceof Error?u.message:"Failed to load score");}finally{c||i(false);}};l();let d;return o&&o>0&&(d=setInterval(l,o)),()=>{c=true,d&&clearInterval(d);}},[t,e,o]),{score:r,isLoading:s,error:n}}var Ys={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 qs({rating:e,size:o,filledColor:t,emptyColor:r}){let a=`gotcha-star-clip-${Math.random().toString(36).slice(2,8)}`,s=[];for(let i=1;i<=5;i++){let n=Math.min(1,Math.max(0,e-(i-1))),p=`${a}-${i}`;s.push(jsxRuntime.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",style:{display:"block"},children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:p,children:jsxRuntime.jsx("rect",{x:"0",y:"0",width:24*n,height:"24"})})}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:r}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:t,clipPath:`url(#${p})`})]},i));}return jsxRuntime.jsx("span",{style:{display:"inline-flex",gap:Math.max(1,o*.08),alignItems:"center"},children:s})}function Xs({rate:e,height:o,filledColor:t,trackColor:r}){return jsxRuntime.jsx("span",{style:{display:"inline-block",width:48,height:o,borderRadius:o,backgroundColor:r,overflow:"hidden",verticalAlign:"middle"},children:jsxRuntime.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:o,background:t,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function Vs({size:e,color:o}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function js({elementId:e,variant:o="stars",showCount:t=true,size:r="md",theme:a="auto",refreshInterval:s,style:i}){let{score:n,isLoading:p}=dr({elementId:e,refreshInterval:s}),[c,l]=react.useState("light");react.useEffect(()=>{if(typeof window>"u")return;let F=window.matchMedia("(prefers-color-scheme: dark)");l(F.matches?"dark":"light");let D=O=>l(O.matches?"dark":"light");return F.addEventListener("change",D),()=>F.removeEventListener("change",D)},[]);let{themeConfig:d}=G(),u=react.useMemo(()=>ue(a,c,d),[a,c,d]);if(p||!n)return null;let f=Ys[r],b=u.colors.text,g=u.colors.textDisabled,m=u.colors.starFilled,h=u.colors.starEmpty,w=u.colors.voteUp,y=u.colors.starEmpty,C={display:"inline-flex",alignItems:"center",gap:f.gap,fontFamily:u.typography.fontFamily,lineHeight:1,WebkitFontSmoothing:"antialiased",...i},v={fontFamily:u.typography.fontFamily,fontSize:f.ratingFontSize,fontWeight:700,color:b,fontVariantNumeric:"tabular-nums",letterSpacing:"-0.01em",lineHeight:1},E={fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",fontSize:Math.max(9,f.fontSize-1),color:g,fontWeight:400,letterSpacing:"0.1em",textTransform:"uppercase"},k=(F,D)=>{let O=F===1?D:`${D}s`;return `${F.toLocaleString()} ${O}`};if(o==="votes"){let{voteCount:F,positiveRate:D}=n,O=F.up+F.down;return O===0?null:jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx(Vs,{size:f.iconSize,color:w}),jsxRuntime.jsxs("span",{style:{...v,color:w},children:[D,"%"]}),jsxRuntime.jsx(Xs,{rate:D??0,height:f.barHeight,filledColor:w,trackColor:y}),t&&jsxRuntime.jsx("span",{style:E,children:k(O,"vote")})]})}let{averageRating:P,totalResponses:z}=n;if(P===null||z===0)return null;let A=P.toFixed(1);return o==="compact"?jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx("svg",{width:f.starSize,height:f.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:m})}),jsxRuntime.jsx("span",{style:v,children:A}),t&&jsxRuntime.jsxs("span",{style:E,children:["(",z.toLocaleString(),")"]})]}):o==="number"?jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx("span",{style:v,children:A}),jsxRuntime.jsx("span",{style:{...E,marginLeft:2},children:"/ 5"}),t&&jsxRuntime.jsxs("span",{style:{...E,marginLeft:2},children:["(",k(z,"response"),")"]})]}):jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx(qs,{rating:P,size:f.starSize,filledColor:m,emptyColor:h}),jsxRuntime.jsx("span",{style:v,children:A}),t&&jsxRuntime.jsxs("span",{style:E,children:["(",k(z,"response"),")"]})]})}function Qs(){let{client:e,disabled:o,defaultUser:t,debug:r,openModal:a,closeModal:s,activeModalId:i}=G();return {client:e,disabled:o,defaultUser:t,debug:r,submitFeedback:e.submitResponse.bind(e),openModal:a,closeModal:s,activeModalId:i}}function Ks(e){let{activeModalId:o,openModal:t,closeModal:r}=G(),a=react.useCallback(()=>t(e),[t,e]),s=react.useCallback(()=>r(),[r]);return {open:a,close:s,isOpen:o===e}}
147
+ `.trim()}function rt(e){if(typeof document>"u")return;let o=document.getElementById(uo);o||(o=document.createElement("style"),o.id=uo,document.head.appendChild(o)),o.textContent=Ur(e);}var fo=react.createContext(null),Wr={};function Yr({apiKey:e,children:o,baseUrl:t,debug:r=false,disabled:a=false,defaultUser:s,defaultUserEmail:i,themeConfig:n}){let[p,c]=react.useState(null);t&&!t.startsWith("https://")&&!t.startsWith("/")&&!t.includes("localhost")&&console.warn("[Gotcha] baseUrl should use HTTPS in production:",t);let l=react.useMemo(()=>ao({apiKey:e,baseUrl:t,debug:r}),[e,t,r]),d=react.useMemo(()=>s??Wr,[JSON.stringify(s)]);react.useEffect(()=>{let g=ue("light","light",n);rt(g);},[n]),react.useEffect(()=>(_t(),()=>Jt()),[]),react.useEffect(()=>{l.flushQueue();let g=()=>l.flushQueue();return window.addEventListener("online",g),()=>window.removeEventListener("online",g)},[l]);let u=react.useCallback(g=>{c(g);},[]),f=react.useCallback(()=>{c(null);},[]),b=react.useMemo(()=>({client:l,disabled:a,defaultUser:d,defaultUserEmail:i,debug:r,activeModalId:p,openModal:u,closeModal:f,themeConfig:n}),[l,a,d,i,r,p,u,f,n]);return jsxRuntime.jsx(fo.Provider,{value:b,children:o})}function G(){let e=react.useContext(fo);if(!e)throw new Error("useGotchaContext must be used within a GotchaProvider");return e}function jr(e,o){let t=new Date(e).getTime();if(isNaN(t))return true;let r=Date.now()-t,a=o*24*60*60*1e3;return r>=a}function go(e){let{client:o,defaultUser:t}=G(),[r,a]=react.useState(false),[s,i]=react.useState(false),[n,p]=react.useState(null),[c,l]=react.useState(null);return react.useEffect(()=>{process.env.NODE_ENV!=="production"&&e.cooldownDays&&!e.onePerUser&&console.warn("[Gotcha] cooldownDays has no effect without onePerUser=true");let u=e.user?.id||t?.id;if(!u||!e.onePerUser){l(null);return}let f=false;return (async()=>{i(true);try{let g=await o.checkExistingResponse(e.elementId,u);f||(g&&e.cooldownDays&&e.cooldownDays>0&&jr(g.createdAt,e.cooldownDays)?l(null):l(g));}catch{f||l(null);}finally{f||i(false);}})(),()=>{f=true;}},[o,e.elementId,e.user?.id,t?.id,e.onePerUser,e.cooldownDays]),{submit:react.useCallback(async u=>{a(true),p(null);try{let f=e.user?.id||t?.id,b;return e.onePerUser&&c&&f?b=await o.updateResponse(c.id,{content:u.content,title:u.title,rating:u.rating,vote:u.vote,pollSelected:u.pollSelected},f):b=await o.submitResponse({elementId:e.elementId,mode:e.mode,content:u.content,title:u.title,rating:u.rating,vote:u.vote,pollOptions:e.pollOptions,pollSelected:u.pollSelected,isBug:u.isBug,screenshot:u.screenshot,user:{...t,...e.user},userEmail:e.userEmail}),e.onePerUser&&l({id:b.id,mode:e.mode,content:u.content??null,title:u.title??null,rating:u.rating??null,vote:u.vote??null,pollSelected:u.pollSelected??null,createdAt:b.createdAt}),e.onSuccess?.(b),b}catch(f){let b=f instanceof Error?f.message:"Something went wrong";throw p(b),e.onError?.(f instanceof Error?f:new Error(b)),f}finally{a(false);}},[o,t,e,c]),isLoading:r,isCheckingExisting:s,error:n,existingResponse:c,isEditing:!!c,clearError:()=>p(null)}}function ho(e,o){return `${Z.HIDDEN_UNTIL}_${e}_${o}`}function mo(e,o,t){if(!t||t<=0)return false;let r=ho(e,o),a=ie(r);return a?new Date(a).getTime()>Date.now():false}function bo(e){let{elementId:o,userId:t,hideAfterSubmitDays:r}=e,a=react.useMemo(()=>t||et(),[t]),[s,i]=react.useState(()=>mo(o,a,r));react.useEffect(()=>{i(mo(o,a,r));},[o,a,r]);let n=react.useCallback(()=>{if(!r||r<=0)return;let p=ho(o,a),c=new Date(Date.now()+r*24*60*60*1e3);le(p,c.toISOString()),i(true);},[o,a,r]);return {isHidden:s,markHidden:n}}function _r(e){return `${Z.VISIT_COUNT}_${e}`}function wo(e){let{elementId:o,showAfterSeconds:t,showAfterScrollPercent:r,showAfterVisits:a}=e,s=t!=null||r!=null||a!=null,[i,n]=react.useState(!t),[p,c]=react.useState(!r),[l]=react.useState(()=>{if(!a)return true;let d=_r(o),f=parseInt(ie(d)||"0",10)+1;return le(d,String(f)),f>=a});return react.useEffect(()=>{if(!t||t<=0)return;let d=Date.now(),u=t*1e3,f=()=>{Date.now()-d>=u?n(true):b=setTimeout(f,Math.min(1e3,u-(Date.now()-d)));},b=setTimeout(f,Math.min(1e3,u));return ()=>clearTimeout(b)},[t]),react.useEffect(()=>{if(!r||r<=0)return;let d=()=>{let u=document.documentElement.scrollHeight,f=window.innerHeight;if(u<=f){c(true);return}(window.scrollY+f)/u*100>=r&&c(true);};if(d(),!p)return window.addEventListener("scroll",d,{passive:true}),()=>window.removeEventListener("scroll",d)},[r,p]),{conditionsMet:!s||i&&p&&l}}function st(...e){return e.filter(Boolean).join(" ")}var W=()=>typeof window>"u"?false:"ontouchstart"in window||navigator.maxTouchPoints>0,So=(e,o)=>{let t={sm:{desktop:24,mobile:28},md:{desktop:32,mobile:34},lg:{desktop:40,mobile:40}};return o?t[e].mobile:t[e].desktop};function en(){return typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function vo({size:e,theme:o,customStyles:t,showOnHover:r,touchBehavior:a,onClick:s,isOpen:i,isParentHovered:n=false,animated:p=true,queuedCount:c=0}){let[l,d]=react.useState(false),[u,f]=react.useState(false),[b,g]=react.useState(en),[m,h]=react.useState(false),[w,y]=react.useState(false),[C,v]=react.useState(false),{themeConfig:E}=G();react.useEffect(()=>{if(d(W()),typeof window>"u")return;let j=window.matchMedia("(prefers-color-scheme: dark)"),ge=xe=>g(xe.matches?"dark":"light");return j.addEventListener("change",ge),()=>j.removeEventListener("change",ge)},[]);let k=i?true:!l&&r?n:l&&a==="tap-to-reveal"?u:true;react.useEffect(()=>{if(k&&!C){let j=setTimeout(()=>v(true),320);return ()=>clearTimeout(j)}},[k,C]);let P=()=>{if(l&&a==="tap-to-reveal"&&!u){f(true);return}s();},z=So(e,l),A=react.useMemo(()=>ue(o,b,E),[o,b,E]),F=i?A.colors.warning:A.colors.border,D=i?A.colors.warning:A.colors.glassColor,O=()=>k?w?"scale(0.97)":"scale(1)":"scale(0.96)",q=w?"80ms":"160ms",T=A.animation.easing.default,H=m&&!i?A.colors.surfaceHover:A.colors.glassBackground,Me={position:"relative",width:z,height:z,borderRadius:A.borders.radius.full,border:`1px solid ${F}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",background:H,color:D,boxShadow:m?A.colors.glassHoverShadow:A.colors.glassShadow,transition:C?`transform ${q} ${T}, background-color 180ms ${T}, box-shadow 180ms ${T}, border-color 240ms ${T}, color 240ms ${T}`:`opacity 320ms ${T}, transform 320ms ${T}`,opacity:k?1:0,transform:O(),pointerEvents:k?"auto":"none",...t?.button};return jsxRuntime.jsxs("button",{type:"button",onClick:P,onMouseEnter:()=>h(true),onMouseLeave:()=>{h(false),y(false);},onMouseDown:()=>y(true),onMouseUp:()=>y(false),onTouchStart:()=>y(true),onTouchEnd:()=>y(false),style:Me,className:st("gotcha-button",i&&"gotcha-button--open"),"aria-label":"Give feedback on this feature","aria-expanded":i,"aria-haspopup":"dialog",children:[jsxRuntime.jsx(tn,{size:z*.62,color:D,fontFamilyDisplay:A.typography.fontFamilyDisplay,animated:p&&!C}),c>0&&jsxRuntime.jsx("span",{"aria-label":`${c} queued`,style:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",backgroundColor:A.colors.warning,border:`1.5px solid ${A.colors.background}`}})]})}function tn({size:e,color:o,fontFamilyDisplay:t,animated:r}){let[a,s]=react.useState(false);return react.useEffect(()=>{s(true);},[]),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{fontFamily:t,fontWeight:400,fontSize:e,fontStyle:"normal",lineHeight:1,color:o,transform:"translateY(1px) translateZ(0)",willChange:"transform",letterSpacing:"normal",userSelect:"none",display:"inline-block",opacity:r?a?1:0:1,transition:r?"opacity 240ms cubic-bezier(0.22, 0.61, 0.36, 1) 120ms":"none"},children:"G"})}function Eo({src:e,onRemove:o,resolvedTheme:t}){let[r,a]=react.useState(false),[s,i]=react.useState(false);react.useEffect(()=>{a(W());},[]);let n=(()=>{if(!e.startsWith("data:"))return null;let p=e.indexOf(",");if(p<0)return null;let c=e.slice(p+1);return Math.round(c.length*3/4/1024)})();return jsxRuntime.jsxs("div",{style:{marginTop:12},children:[jsxRuntime.jsxs("div",{style:{position:"relative",borderRadius:t.borders.radius.sm,overflow:"hidden",border:`1px solid ${t.colors.border}`,padding:4,background:t.colors.background},children:[jsxRuntime.jsx("img",{src:e,alt:"Screenshot attached to the feedback",style:{display:"block",width:"100%",maxHeight:140,objectFit:"cover",borderRadius:Math.max(0,t.borders.radius.sm-2)}}),jsxRuntime.jsx("button",{type:"button",onClick:o,onMouseEnter:()=>i(true),onMouseLeave:()=>i(false),"aria-label":"Remove screenshot",style:{position:"absolute",top:8,right:8,width:r?32:24,height:r?32:24,borderRadius:"50%",border:`1px solid ${s?t.colors.error:t.colors.border}`,backgroundColor:s?t.colors.error:t.colors.background,color:s?t.colors.primaryText:t.colors.textSecondary,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:`all ${t.animation.duration.fast} ${t.animation.easing.default}`},children:jsxRuntime.jsx("svg",{width:10,height:10,viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 1L13 13M1 13L13 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),jsxRuntime.jsxs("p",{style:{margin:"6px 0 0",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",fontSize:10,letterSpacing:"0.08em",textTransform:"uppercase",color:t.colors.textSecondary},children:["screenshot.png",n!=null?` \xB7 ${n} KB`:""]})]})}function _o({resolvedTheme:e,placeholder:o,submitText:t,isLoading:r,onSubmit:a,customStyles:s,initialValues:i,isEditing:n=false,showText:p=true,showRating:c=true,enableBugFlag:l=false,bugFlagLabel:d,enableScreenshot:u=false}){let[f,b]=react.useState(i?.content||""),[g,m]=react.useState(i?.rating??null),[h,w]=react.useState(false),[y,C]=react.useState(false),[v,E]=react.useState(null),[k,P]=react.useState(false),[z,A]=react.useState(false);react.useEffect(()=>{C(W());},[]),react.useEffect(()=>{i?.content!==void 0&&b(i.content||""),i?.rating!==void 0&&m(i.rating??null);},[i?.content,i?.rating]);let F=p&&c?f.trim().length>0||g!==null:p?f.trim().length>0:c?g!==null:false,D=async()=>{P(true),A(false);try{let{captureScreenshot:T}=await Promise.resolve().then(()=>(Zo(),Ko)),H=await T();H?E(H):A(!0);}catch{A(true);}finally{P(false);}},O=T=>{T.preventDefault(),!(!F||r)&&a({content:p&&f.trim()?f.trim():void 0,rating:c&&g!==null?g:void 0,isBug:h||void 0,screenshot:v||void 0});},q={width:"100%",padding:y?"12px 0":"10px 0",border:"none",borderBottom:`1px solid ${e.colors.inputBorder}`,borderRadius:0,backgroundColor:"transparent",color:e.colors.text,fontSize:y?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:y?96:80,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.55,...s?.input};return jsxRuntime.jsxs("form",{onSubmit:O,children:[c&&jsxRuntime.jsx("div",{style:{marginBottom:p?y?18:16:0,...p?{}:{display:"flex",justifyContent:"center",padding:"6px 0"}},children:jsxRuntime.jsx(Cs,{value:g,onChange:m,theme:e,isTouch:y,large:!p})}),p&&jsxRuntime.jsx("textarea",{value:f,onChange:T=>b(T.target.value),placeholder:o||"Share your thoughts\u2026",maxLength:5e3,style:q,disabled:r,"aria-label":"Your feedback",onFocus:T=>{T.currentTarget.style.borderBottomColor=e.colors.inputBorderFocus;},onBlur:T=>{T.currentTarget.style.borderBottomColor=e.colors.inputBorder;}}),l&&jsxRuntime.jsxs("button",{type:"button",role:"switch","aria-checked":h,onClick:()=>w(!h),style:{display:"flex",alignItems:"center",gap:10,width:"100%",marginTop:16,padding:y?"12px 12px":"10px 12px",border:`1px solid ${h?e.colors.warningBorder:e.colors.border}`,borderRadius:e.borders.radius.sm,backgroundColor:h?e.colors.warningSurface:"transparent",cursor:"pointer",transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`,fontFamily:e.typography.fontFamily,...s?.bugFlag},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:3,border:`1px solid ${h?e.colors.warningActive:e.colors.border}`,backgroundColor:h?e.colors.warning:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},children:h&&jsxRuntime.jsx("svg",{width:8,height:8,viewBox:"0 0 10 10",fill:"none","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M2 5L4 7L8 3",stroke:e.colors.primaryText,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxRuntime.jsx("span",{style:{fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.normal,color:h?e.colors.text:e.colors.textSecondary,letterSpacing:"0",textAlign:"left",flex:1},children:h?"Reported as an issue":d||"Report an issue"})]}),l&&u&&h&&!v&&jsxRuntime.jsxs("button",{type:"button",onClick:D,disabled:k,style:{display:"flex",alignItems:"center",gap:8,width:"100%",marginTop:8,padding:"9px 12px",border:`1px solid ${e.colors.border}`,borderRadius:e.borders.radius.sm,backgroundColor:"transparent",cursor:k?"progress":"pointer",fontFamily:e.typography.fontFamily,fontSize:e.typography.fontSize.xs,letterSpacing:"0.06em",textTransform:"uppercase",color:e.colors.textSecondary,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},onMouseEnter:T=>{T.currentTarget.style.borderColor=e.colors.inputBorderFocus,T.currentTarget.style.color=e.colors.text;},onMouseLeave:T=>{T.currentTarget.style.borderColor=e.colors.border,T.currentTarget.style.color=e.colors.textSecondary;},children:[jsxRuntime.jsxs("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),jsxRuntime.jsx("circle",{cx:"12",cy:"10",r:"3"}),jsxRuntime.jsx("path",{d:"M2 17l4-4 3 3 4-4 9 9"})]}),k?"Capturing\u2026":"Attach screenshot"]}),z&&jsxRuntime.jsxs("div",{role:"alert",style:{marginTop:8,padding:"6px 0 6px 10px",borderLeft:`2px solid ${e.colors.error}`,fontSize:e.typography.fontSize.xs,color:e.colors.text,fontFamily:e.typography.fontFamily,display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[jsxRuntime.jsx("span",{children:"Screenshot capture unavailable."}),jsxRuntime.jsx("button",{type:"button",onClick:D,style:{background:"none",border:"none",padding:0,color:e.colors.text,fontFamily:e.typography.fontFamily,fontSize:e.typography.fontSize.xs,textDecoration:"underline",textDecorationColor:e.colors.border,textUnderlineOffset:3,cursor:"pointer"},children:"Try again"})]}),l&&u&&h&&v&&jsxRuntime.jsx(Eo,{src:v,onRemove:()=>E(null),resolvedTheme:e}),jsxRuntime.jsx("button",{type:"submit",disabled:r||!F,style:{width:"100%",padding:y?"14px 16px":"11px 16px",marginTop:18,border:"none",borderRadius:e.borders.radius.sm,backgroundColor:F?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:F?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||!F?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:r?"italic":"normal",...s?.submitButton},onMouseEnter:T=>{T.currentTarget.disabled||(T.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:T=>{T.currentTarget.disabled||(T.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:r?n?"Updating\u2026":"Sending\u2026":n?"Update":t})]})}function Cs({value:e,onChange:o,theme:t,isTouch:r,large:a=false}){let[s,i]=react.useState(null),n=a?r?34:28:r?26:20,p=a?8:6,c=a?r?6:4:r?6:2,l=d=>s!==null&&s>=d?`${(d-1)*30}ms`:"0ms";return jsxRuntime.jsx("div",{style:{display:"flex",gap:p},role:"group","aria-label":"Rating",onMouseLeave:()=>i(null),children:[1,2,3,4,5].map(d=>{let u=(s??e??0)>=d;return jsxRuntime.jsx("button",{type:"button",onClick:()=>o(d),onMouseEnter:()=>i(d),"aria-label":`Rate ${d} out of 5`,"aria-pressed":e===d,style:{background:"none",border:"none",cursor:"pointer",padding:c,color:u?t.colors.starFilled:t.colors.starEmpty,transition:`color 180ms ${t.animation.easing.default}`,transitionDelay:l(d),outline:"none",WebkitTapHighlightColor:"transparent"},children:jsxRuntime.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:u?"currentColor":"none",stroke:"currentColor",strokeWidth:u?0:1.5,strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M12 3.5L14.472 8.506L20 9.308L16 13.205L16.944 18.706L12 16.107L7.056 18.706L8 13.205L4 9.308L9.528 8.506L12 3.5Z"})})},d)})})}function Jo({resolvedTheme:e,isLoading:o,onSubmit:t,initialVote:r,isEditing:a=false,labels:s}){let[i,n]=react.useState(false),[p,c]=react.useState(r||null),[l,d]=react.useState(r||null);react.useEffect(()=>{n(W());},[]),react.useEffect(()=>{r!==void 0&&(d(r),c(r));},[r]),react.useEffect(()=>{!o&&!a&&c(null);},[o,a]);let u=m=>{c(m),t({vote:m});},f=i?24:20,b=m=>{let h=l===m,w=m==="up"?e.colors.voteUp:e.colors.voteDown,y=m==="up"?e.colors.voteUpSurface:e.colors.voteDownSurface,C=m==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return {flex:1,minWidth:0,padding:i?"14px 18px":"11px 16px",border:`1px solid ${h?w:C}`,borderRadius:e.borders.radius.full,background:h?w:y,color:h?e.colors.primaryText:e.colors.text,fontSize:i?15:13,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:o?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}, border-color ${e.animation.duration.fast} ${e.animation.easing.default}, color ${e.animation.duration.fast} ${e.animation.easing.default}`,display:"flex",alignItems:"center",justifyContent:"center",gap:i?10:8,outline:"none"}},g=(m,h)=>s?.[m]?s[m]:m==="up"?h?"Liked":"Like":h?"Disliked":"Dislike";return jsxRuntime.jsx("div",{style:{display:"flex",gap:i?12:10},role:"group","aria-label":"Vote",children:["up","down"].map(m=>{let h=l===m,w=o&&p===m,y=g(m,h),C=w?`${y}, submitting`:y,v=m==="up"?e.colors.voteUpBorder:e.colors.voteDownBorder;return jsxRuntime.jsxs("button",{type:"button",onClick:()=>u(m),disabled:o,style:b(m),"aria-label":C,"aria-pressed":h,onMouseEnter:E=>{o||h||(E.currentTarget.style.borderColor=e.colors.inputBorderFocus);},onMouseLeave:E=>{h||(E.currentTarget.style.borderColor=v);},children:[m==="up"?jsxRuntime.jsx(ks,{size:f}):jsxRuntime.jsx(As,{size:f}),jsxRuntime.jsx("span",{style:{fontStyle:w?"italic":"normal"},children:w?a?"Updating\u2026":"Sending\u2026":y})]},m)})})}function ks({size:e=20}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function As({size:e=20}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17"})})}function tr({resolvedTheme:e,options:o,allowMultiple:t,isLoading:r,onSubmit:a,initialSelected:s,isEditing:i=false}){let[n,p]=react.useState(s||[]),[c,l]=react.useState(false),[d,u]=react.useState(null);react.useEffect(()=>{l(W());},[]),react.useEffect(()=>{s&&p(s);},[s]);let f=m=>{r||p(t?h=>h.includes(m)?h.filter(w=>w!==m):[...h,m]:h=>h.includes(m)?[]:[m]);},b=()=>{n.length===0||r||a({pollSelected:n});},g=c?"14px 14px":"12px 14px";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("ul",{role:"group","aria-label":t?"Select one or more options":"Select an option",style:{listStyle:"none",margin:0,padding:0,borderTop:`1px solid ${e.colors.border}`},children:o.map((m,h)=>{let w=n.includes(m),y=d===h;return jsxRuntime.jsxs("li",{style:{borderBottom:`1px solid ${e.colors.border}`,position:"relative",animation:`gotcha-fade-up ${e.animation.duration.normal} ${e.animation.easing.default} both`,animationDelay:`${h*.04}s`},children:[w&&jsxRuntime.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:0,top:8,bottom:8,width:2,backgroundColor:e.colors.pollSelectedBorder}}),jsxRuntime.jsxs("button",{type:"button",onClick:()=>f(m),onMouseEnter:()=>u(h),onMouseLeave:()=>u(null),disabled:r,"aria-pressed":w,style:{display:"flex",alignItems:"center",gap:12,width:"100%",padding:g,paddingLeft:w?16:14,border:"none",background:y&&!w?e.colors.surfaceHover:"transparent",color:e.colors.text,fontSize:c?15:e.typography.fontSize.md,fontWeight:w?e.typography.fontWeight.medium:e.typography.fontWeight.normal,fontFamily:e.typography.fontFamily,cursor:r?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,textAlign:"left",letterSpacing:"0",outline:"none"},children:[jsxRuntime.jsx("span",{style:{flex:1},children:m}),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:t?3:"50%",border:`1px solid ${w?e.colors.pollCheckSelectedBorder:e.colors.pollCheckBorder}`,backgroundColor:w?e.colors.pollCheckSelectedBg:"transparent",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:`all ${e.animation.duration.fast} ${e.animation.easing.default}`},children:w&&jsxRuntime.jsx("svg",{width:8,height:8,viewBox:"0 0 10 10",fill:"none",children:jsxRuntime.jsx("path",{d:"M2 5L4 7L8 3",stroke:e.colors.primaryText,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]},m)})}),jsxRuntime.jsx("button",{type:"button",onClick:b,disabled:r||n.length===0,style:{width:"100%",marginTop:18,padding:c?"14px 16px":"11px 16px",border:"none",borderRadius:e.borders.radius.sm,backgroundColor:n.length===0?e.colors.buttonBackgroundDisabled:e.colors.buttonBackground,color:n.length===0?e.colors.buttonColorDisabled:e.colors.buttonColor,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||n.length===0?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:r?"italic":"normal"},onMouseEnter:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:m=>{m.currentTarget.disabled||(m.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:r?i?"Updating\u2026":"Sending\u2026":i?"Update":"Submit"})]})}function rr({size:e=16,color:o="currentColor"}){let r=2*Math.PI*9,a=r*.25;return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Loading",style:{animation:"gotcha-spin 1.1s linear infinite",transformOrigin:"center"},children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:9,stroke:o,strokeOpacity:"0.18",strokeWidth:"1.25",fill:"none"}),jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:9,stroke:o,strokeWidth:"1.25",strokeLinecap:"round",fill:"none",strokeDasharray:`${a} ${r}`,strokeDashoffset:"0"})]})}function sr({resolvedTheme:e,submitText:o,isLoading:t,onSubmit:r,customStyles:a,showFollowUp:s=true,followUpPlaceholder:i,lowLabel:n="Not likely",highLabel:p="Very likely",initialValues:c,isEditing:l=false}){let[d,u]=react.useState(c?.rating??null),[f,b]=react.useState(c?.content||""),[g,m]=react.useState(false),[h,w]=react.useState(null);react.useEffect(()=>{m(W());},[]),react.useEffect(()=>{c?.rating!==void 0&&u(c.rating??null),c?.content!==void 0&&b(c.content||"");},[c?.rating,c?.content]);let y=d!==null;return jsxRuntime.jsxs("form",{onSubmit:v=>{v.preventDefault(),!(!y||t)&&r({rating:d??void 0,content:s&&f.trim()?f.trim():void 0});},children:[jsxRuntime.jsx("div",{style:{position:"relative",display:"flex",gap:g?4:5,justifyContent:"center"},role:"group","aria-label":"NPS Score",onMouseLeave:()=>w(null),children:Array.from({length:11},(v,E)=>{let k=d===E,P=h===E;return jsxRuntime.jsx("button",{type:"button",onClick:()=>u(E),onMouseEnter:()=>w(E),"aria-label":`Score ${E} out of 10`,"aria-pressed":k,style:{flex:1,minWidth:0,aspectRatio:"1",borderRadius:e.borders.radius.sm,border:`1px solid ${k?e.colors.buttonBackground:P?e.colors.inputBorderFocus:e.colors.border}`,backgroundColor:k?e.colors.buttonBackground:"transparent",color:k?e.colors.buttonColor:e.colors.text,fontSize:15,fontWeight:k?e.typography.fontWeight.medium:e.typography.fontWeight.normal,fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:0,display:"flex",alignItems:"center",justifyContent:"center",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}, border-color ${e.animation.duration.fast} ${e.animation.easing.default}, color ${e.animation.duration.fast} ${e.animation.easing.default}`,outline:"none",...a?.npsButton,...k?a?.npsButtonSelected:{}},children:E},E)})}),jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:12,padding:"0 2px",...a?.npsLabels},children:[n,p].map(v=>jsxRuntime.jsx("span",{style:{fontFamily:e.typography.fontFamily,fontSize:11,color:e.colors.text,fontWeight:e.typography.fontWeight.medium,letterSpacing:"0.14em",textTransform:"uppercase"},children:v},v))}),s&&d!==null&&jsxRuntime.jsx("textarea",{value:f,onChange:v=>b(v.target.value),placeholder:i||"What's the main reason for your score?",maxLength:5e3,style:{width:"100%",padding:g?"12px 0":"10px 0",marginTop:18,border:"none",borderBottom:`1px solid ${e.colors.inputBorder}`,borderRadius:0,backgroundColor:"transparent",color:e.colors.text,fontSize:g?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:g?72:56,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.55,animation:`gotcha-expand-in ${e.animation.duration.normal} ${e.animation.easing.default} both`,overflow:"hidden",...a?.input},disabled:t,"aria-label":"Follow-up feedback",onFocus:v=>{v.currentTarget.style.borderBottomColor=e.colors.inputBorderFocus;},onBlur:v=>{v.currentTarget.style.borderBottomColor=e.colors.inputBorder;}}),jsxRuntime.jsx("button",{type:"submit",disabled:t||!y,style:{width:"100%",marginTop:18,padding:g?"14px 16px":"11px 16px",border:"none",borderRadius:e.borders.radius.sm,backgroundColor:y?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:y?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:t||!y?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:t?"italic":"normal",...a?.submitButton},onMouseEnter:v=>{v.currentTarget.disabled||(v.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:v=>{v.currentTarget.disabled||(v.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:t?l?"Updating\u2026":"Sending\u2026":l?"Update":o})]})}function ir({resolvedTheme:e,promptText:o,placeholder:t,isLoading:r,onSubmit:a}){let[s,i]=react.useState(""),[n,p]=react.useState(false);return react.useEffect(()=>{p(W());},[]),jsxRuntime.jsxs("form",{onSubmit:l=>{l.preventDefault(),!(!s.trim()||r)&&a(s.trim());},children:[jsxRuntime.jsx("p",{style:{margin:"0 0 14px 0",fontFamily:e.typography.fontFamilyDisplay,fontSize:n?17:16,fontStyle:"italic",color:e.colors.text,lineHeight:1.45,letterSpacing:"-0.01em"},children:o}),jsxRuntime.jsx("textarea",{value:s,onChange:l=>i(l.target.value),placeholder:t||"Tell us more\u2026",maxLength:5e3,disabled:r,"aria-label":"Follow-up feedback",style:{width:"100%",padding:n?"12px 0":"10px 0",border:"none",borderBottom:`1px solid ${e.colors.inputBorder}`,borderRadius:0,backgroundColor:"transparent",color:e.colors.text,fontSize:n?e.typography.fontSize.lg:e.typography.fontSize.md,resize:"none",minHeight:n?96:72,fontFamily:e.typography.fontFamily,outline:"none",transition:`border-color ${e.animation.duration.fast} ${e.animation.easing.default}`,lineHeight:1.55},onFocus:l=>{l.currentTarget.style.borderBottomColor=e.colors.inputBorderFocus;},onBlur:l=>{l.currentTarget.style.borderBottomColor=e.colors.inputBorder;}}),jsxRuntime.jsx("button",{type:"submit",disabled:r||!s.trim(),style:{width:"100%",marginTop:16,padding:n?"14px 16px":"11px 16px",border:"none",borderRadius:e.borders.radius.sm,backgroundColor:s.trim()?e.colors.buttonBackground:e.colors.buttonBackgroundDisabled,color:s.trim()?e.colors.buttonColor:e.colors.buttonColorDisabled,fontSize:e.typography.fontSize.sm,fontWeight:e.typography.fontWeight.medium,fontFamily:e.typography.fontFamily,cursor:r||!s.trim()?"not-allowed":"pointer",transition:`background-color ${e.animation.duration.fast} ${e.animation.easing.default}`,fontStyle:r?"italic":"normal"},onMouseEnter:l=>{l.currentTarget.disabled||(l.currentTarget.style.backgroundColor=e.colors.buttonBackgroundHover);},onMouseLeave:l=>{l.currentTarget.disabled||(l.currentTarget.style.backgroundColor=e.colors.buttonBackground);},children:r?"Sending\u2026":"Submit"})]})}var Ls={feedback:"Feedback",vote:"Vote",poll:"Poll",nps:"Rate"};function Ps(e,o){switch(e){case "vote":return "What do you think?";case "poll":return "Cast your vote.";case "nps":return o||"How likely are you to recommend us?";default:return "What do you think of this feature?"}}var Ns=4e3;function cr({mode:e,theme:o,customStyles:t,promptText:r,placeholder:a,submitText:s,thankYouMessage:i,isLoading:n,isCheckingExisting:p=false,isSubmitted:c,phase:l="form",followUpConfig:d,followUpLoading:u=false,onFollowUpSubmit:f,error:b,existingResponse:g,isEditing:m=false,showText:h=true,showRating:w=true,voteLabels:y,options:C,allowMultiple:v=false,npsQuestion:E,npsFollowUp:k=true,npsFollowUpPlaceholder:P,npsLowLabel:z,npsHighLabel:A,enableBugFlag:F=false,bugFlagLabel:D,enableScreenshot:O=false,onSubmit:q,onClose:T,anchorRect:H,useFixedPosition:Me=false,isMobile:j}){let ge=react.useRef(null),xe=react.useRef(null),Ie=react.useRef(T);Ie.current=T;let[Ve,gt]=react.useState(false),U=j??Ve,[je,Qe]=react.useState("light"),{themeConfig:_}=G();react.useEffect(()=>{if(typeof window>"u")return;let I=window.matchMedia("(prefers-color-scheme: dark)"),Q=N=>Qe(N.matches?"dark":"light");Q(I);let Y=N=>Q(N);I.addEventListener("change",Y);let K=[()=>I.removeEventListener("change",Y)];if(j===void 0){let N=window.matchMedia("(max-width: 1023px)"),re=()=>gt(N.matches);re(),N.addEventListener("change",re),K.push(()=>N.removeEventListener("change",re));}return ()=>{for(let N of K)N();}},[j]);let S=react.useMemo(()=>ue(o,je,_),[o,je,_]);react.useEffect(()=>{rt(S);},[S]);let Le=typeof window>"u"||!H?false:window.innerHeight-H.bottom<340;react.useEffect(()=>{let I=ge.current;if(!I)return;xe.current?.focus();let Q=Y=>{if(Y.key==="Escape"){Ie.current();return}if(Y.key==="Tab"){let K=I.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),N=K[0],re=K[K.length-1];Y.shiftKey&&document.activeElement===N?(Y.preventDefault(),re?.focus()):!Y.shiftKey&&document.activeElement===re&&(Y.preventDefault(),N?.focus());}};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[]);let me=r||Ps(e,E),Ke=Ls[e],he=e==="nps"?420:e==="poll"?400:360,Ze=U?"gotcha-modal-enter-center":Le?"gotcha-modal-enter-above":"gotcha-modal-enter",Pe=typeof window<"u"?window.innerHeight:0,V={padding:0,borderRadius:S.borders.radius.lg,background:S.colors.background,color:S.colors.text,boxShadow:S.shadows.modal,border:`${S.borders.width}px solid ${S.colors.border}`,fontFamily:S.typography.fontFamily,textAlign:"left",overflow:"hidden"},Ne=U?{...V,position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"calc(100vw - 32px)",maxWidth:he,zIndex:9999,...t?.modal}:Me&&H&&Pe?(()=>{let I=window.innerWidth,Q=24,K=H.left+H.width/2-he/2,N=Math.max(Q,Math.min(K,I-he-Q));return {...V,position:"fixed",left:N,width:he,zIndex:99999,...Le?{bottom:Pe-H.top+10}:{top:H.bottom+10},...t?.modal}})():{...V,position:"absolute",left:"50%",width:he,zIndex:9999,...Le?{bottom:"100%",marginBottom:10,transform:"translateX(-50%)"}:{top:"100%",marginTop:10,transform:"translateX(-50%)"},...t?.modal},oe=I=>U?{}:{animation:`gotcha-fade-up ${S.animation.duration.normal} ${S.animation.easing.default} both`,animationDelay:`${I*.04}s`},mt=U?"20px 24px 24px":"20px 28px 24px";return jsxRuntime.jsxs("div",{ref:ge,role:"dialog","aria-modal":"true","aria-label":c?"Feedback submitted":void 0,"aria-labelledby":c?void 0:"gotcha-modal-title","data-gotcha":true,style:Ne,className:st("gotcha-modal","gotcha-root",Ze),children:[!c&&jsxRuntime.jsxs("header",{style:{padding:U?"20px 24px 16px":"22px 28px 16px",borderBottom:`${S.borders.width}px solid ${S.colors.border}`,position:"relative"},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,...oe(0)},children:[jsxRuntime.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:16,height:1,backgroundColor:S.colors.warning}}),jsxRuntime.jsx("span",{style:{fontFamily:S.typography.fontFamily,fontSize:10,fontWeight:S.typography.fontWeight.medium,letterSpacing:"0.16em",textTransform:"uppercase",color:S.colors.textSecondary},children:Ke})]}),jsxRuntime.jsx("h2",{id:"gotcha-modal-title",style:{margin:0,paddingRight:U?52:44,fontFamily:S.typography.fontFamilyDisplay,fontSize:U?22:20,fontWeight:S.typography.fontWeight.normal,letterSpacing:"-0.01em",lineHeight:1.25,color:S.colors.text,...oe(1),...t?.title},children:me}),jsxRuntime.jsx("button",{ref:xe,type:"button",onClick:T,"aria-label":"Close feedback form",style:{position:"absolute",top:U?14:16,right:U?14:18,width:U?44:32,height:U?44:32,border:"none",background:"transparent",outline:"none",cursor:"pointer",color:S.colors.closeButton,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:S.borders.radius.sm,transition:`color ${S.animation.duration.fast} ${S.animation.easing.default}`,...t?.closeButton},onMouseEnter:I=>{I.currentTarget.style.color=S.colors.closeButtonHover;},onMouseLeave:I=>{I.currentTarget.style.color=S.colors.closeButton;},children:jsxRuntime.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",children:jsxRuntime.jsx("path",{d:"M1 1L11 11M1 11L11 1",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),jsxRuntime.jsxs("div",{style:{padding:c?0:mt,position:"relative"},children:[b&&!c&&jsxRuntime.jsxs("div",{role:"alert",style:{padding:"2px 0 2px 14px",marginBottom:16,borderLeft:`2px solid ${S.colors.error}`,color:S.colors.text,fontSize:S.typography.fontSize.sm,lineHeight:1.55,...oe(2),...t?.errorMessage},children:[b,jsxRuntime.jsx("span",{style:{color:S.colors.textSecondary},children:" \u2014 try again?"})]}),c&&jsxRuntime.jsxs("div",{style:{padding:U?"32px 24px 28px":"36px 28px 28px",textAlign:"center",position:"relative"},children:[jsxRuntime.jsx("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",style:{display:"block",margin:"0 auto 14px",...t?.successIcon},children:jsxRuntime.jsx("path",{d:"M10 20.5L17 27.5L31 13.5",stroke:S.colors.success,strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",style:{strokeDasharray:30,strokeDashoffset:30,animation:`gotcha-check-draw 320ms ${S.animation.easing.default} forwards`}})}),jsxRuntime.jsx("p",{style:{margin:0,fontFamily:S.typography.fontFamilyDisplay,fontSize:22,fontWeight:S.typography.fontWeight.normal,letterSpacing:"-0.01em",color:S.colors.text,...t?.successMessage},children:i}),jsxRuntime.jsx("p",{style:{margin:"8px 0 0",fontFamily:S.typography.fontFamily,fontSize:S.typography.fontSize.sm,color:S.colors.textSecondary,fontStyle:"italic"},children:"We\u2019ll close this in a moment."}),jsxRuntime.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:1,right:1,bottom:1,height:1,backgroundColor:S.colors.success,transformOrigin:"left center",animation:`gotcha-progress ${Ns}ms linear forwards`}})]}),l==="followUp"&&d&&f&&!c&&jsxRuntime.jsx("div",{style:oe(2),children:jsxRuntime.jsx(ir,{resolvedTheme:S,promptText:d.promptText,placeholder:d.placeholder,isLoading:u,onSubmit:f})}),l==="form"&&p&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"24px 0",...oe(2)},children:jsxRuntime.jsx(rr,{size:20,color:S.colors.textSecondary})}),l==="form"&&!p&&!c&&jsxRuntime.jsxs("div",{style:oe(2),children:[e==="feedback"&&jsxRuntime.jsx(_o,{resolvedTheme:S,placeholder:a,submitText:s,isLoading:n,onSubmit:q,customStyles:t,initialValues:g?{content:g.content,rating:g.rating}:void 0,isEditing:m,showText:h,showRating:w,enableBugFlag:F,bugFlagLabel:D,enableScreenshot:O}),e==="vote"&&jsxRuntime.jsx(Jo,{resolvedTheme:S,isLoading:n,onSubmit:q,initialVote:g?.vote||void 0,isEditing:m,labels:y}),e==="nps"&&jsxRuntime.jsx(sr,{resolvedTheme:S,submitText:s,isLoading:n,onSubmit:q,showFollowUp:k,followUpPlaceholder:P,lowLabel:z,highLabel:A,customStyles:t,initialValues:g?{rating:g.rating,content:g.content}:void 0,isEditing:m}),e==="poll"&&C&&C.length>0&&jsxRuntime.jsx(tr,{resolvedTheme:S,options:C,allowMultiple:v,isLoading:n,onSubmit:q,initialSelected:g?.pollSelected||void 0,isEditing:m})]})]}),jsxRuntime.jsx("div",{"aria-live":"polite",className:"sr-only",children:c?"Thank you. Your feedback has been submitted.":b?`Error: ${b}`:""})]})}function Gs({elementId:e,user:o,userEmail:t,mode:r="feedback",showText:a=true,showRating:s=true,voteLabels:i,options:n,allowMultiple:p=false,npsQuestion:c,npsFollowUp:l=true,npsFollowUpPlaceholder:d,npsLowLabel:u,npsHighLabel:f,enableBugFlag:b=false,bugFlagLabel:g,enableScreenshot:m=false,onePerUser:h=false,cooldownDays:w,hideAfterSubmitDays:y,showAfterSeconds:C,showAfterScrollPercent:v,showAfterVisits:E,followUp:k,animated:P=true,position:z=ae.POSITION,size:A=ae.SIZE,theme:F=ae.THEME,customStyles:D,visible:O=true,showOnHover:q=ae.SHOW_ON_HOVER,touchBehavior:T=ae.TOUCH_BEHAVIOR,promptText:H,placeholder:Me,submitText:j=ae.SUBMIT_TEXT,thankYouMessage:ge=ae.THANK_YOU_MESSAGE,onSubmit:xe,onOpen:Ie,onClose:Ve,onError:gt}){let{disabled:U,activeModalId:je,openModal:Qe,closeModal:_,defaultUser:S,defaultUserEmail:Le,client:me,debug:Ke}=G(),{conditionsMet:Wt}=wo({elementId:e,showAfterSeconds:C,showAfterScrollPercent:v,showAfterVisits:E}),{isHidden:he,markHidden:Ze}=bo({elementId:e,userId:o?.id||S?.id,hideAfterSubmitDays:y}),[Pe,V]=react.useState("form"),[Ne,oe]=react.useState(null),[mt,I]=react.useState(false),[Q,Y]=react.useState(0),[K,N]=react.useState(false),[re,Yt]=react.useState(null),[X,fr]=react.useState(false),[qt,gr]=react.useState(false),Ee=react.useRef(null),Ge=react.useRef(),mr=react.useRef(null),Ue=react.useRef(null),[be,$e]=react.useState(null);react.useEffect(()=>{if(gr(true),typeof window>"u")return;let x=window.matchMedia("(max-width: 1023px)"),M=()=>fr(x.matches);return M(),x.addEventListener("change",M),()=>{x.removeEventListener("change",M),clearTimeout(Ge.current);}},[]),react.useEffect(()=>{Y(me.getQueueLength());let x=()=>{setTimeout(()=>Y(me.getQueueLength()),2e3);};return window.addEventListener("online",x),()=>window.removeEventListener("online",x)},[me]);let ne=je===e;react.useEffect(()=>{if(!ne||X)return;let x=0,M=()=>{x||(x=requestAnimationFrame(()=>{x=0;let se=Ee.current;if(!se)return;let Te=se.querySelector("button");Yt((Te??se).getBoundingClientRect());}));};return window.addEventListener("resize",M),window.addEventListener("scroll",M,{passive:true}),()=>{x&&cancelAnimationFrame(x),window.removeEventListener("resize",M),window.removeEventListener("scroll",M);}},[ne,X]),react.useEffect(()=>{ne||(V("form"),clearTimeout(Ge.current));},[ne]),react.useEffect(()=>{if(!ne||!X)return;let x=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=x;}},[ne,X]),react.useEffect(()=>{if(!q)return;let x=Ee.current;if(!x)return;let M=x.parentElement;if(!M)return;let se=()=>N(true),Te=()=>N(false);return M.addEventListener("mouseenter",se),M.addEventListener("mouseleave",Te),()=>{M.removeEventListener("mouseenter",se),M.removeEventListener("mouseleave",Te);}},[q]);let{submit:_e,isLoading:hr,isCheckingExisting:br,error:yr,existingResponse:wr,isEditing:Xt}=go({elementId:e,mode:r,pollOptions:n,user:o,userEmail:t??Le,onePerUser:h,cooldownDays:w,onSuccess:x=>{oe(x.id),xe?.(x),$e(null),Ue.current=null;},onError:x=>{console.warn("[Gotcha] Submission failed:",x instanceof Error?x.message:x),gt?.(x),Ue.current&&$e({message:x instanceof Error?x.message:"Something went wrong",retrying:false});}}),Sr=react.useCallback(()=>{if(Ee.current){let x=Ee.current.querySelector("button");Yt((x??Ee.current).getBoundingClientRect());}Qe(e),Ie?.();},[e,Qe,Ie]),Vt=react.useCallback(()=>{clearTimeout(Ge.current),_(),V("form"),Ve?.();},[_,Ve]),vr=react.useCallback(x=>{mr.current={rating:x.rating,vote:x.vote},Ue.current=x,k&&(k.ratingThreshold!=null&&x.rating!=null&&x.rating<=k.ratingThreshold||k.onNegativeVote&&x.vote==="down")&&r!=="poll"?V("followUp"):(V("success"),Ge.current=setTimeout(()=>{_(),V("form");},4e3)),y&&Ze();let se=typeof performance<"u"?performance.now():Date.now();_e(x).catch(()=>{}).finally(()=>{if(Ke){let Te=(typeof performance<"u"?performance.now():Date.now())-se;console.log(`[Gotcha] Server ack in ${Te.toFixed(0)}ms`);}});},[_e,k,r,y,Ze,_,Ke]),xr=react.useCallback(()=>{let x=Ue.current;!x||!be||be.retrying||($e({...be,retrying:true}),_e(x).catch(()=>{}));},[be,_e]),Er=react.useCallback(()=>{$e(null),Ue.current=null;},[]),Tr=react.useCallback(async x=>{if(Ne){I(true);try{await me.updateResponse(Ne,{content:x});}catch(M){console.warn("[Gotcha] Follow-up submission failed:",M instanceof Error?M.message:M);}finally{I(false),V("success"),Ge.current=setTimeout(()=>{_(),V("form");},4e3);}}},[Ne,_,me]),Cr=h&&Xt?"Update":j;if(U||!O||he||!Wt)return null;let kr={"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"}},Ar={mode:r,theme:F,customStyles:D,promptText:H,placeholder:Me,submitText:Cr,thankYouMessage:ge,isLoading:hr,isCheckingExisting:h&&br,isSubmitted:Pe==="success",phase:Pe,followUpConfig:k,followUpLoading:mt,onFollowUpSubmit:Tr,error:yr,existingResponse:h?wr:null,isEditing:h&&Xt,showText:a,showRating:s,voteLabels:i,options:n,allowMultiple:p,npsQuestion:c,npsFollowUp:l,npsFollowUpPlaceholder:d,npsLowLabel:u,npsHighLabel:f,enableBugFlag:b,bugFlagLabel:g,enableScreenshot:m,onSubmit:vr,onClose:Vt,anchorRect:re||void 0,useFixedPosition:!X,isMobile:X};return jsxRuntime.jsxs("div",{ref:Ee,style:{...kr[z],zIndex:"auto"},className:"gotcha-container","data-gotcha-element":e,children:[jsxRuntime.jsx(vo,{size:A,theme:F,customStyles:D,showOnHover:q,touchBehavior:T,onClick:Sr,isOpen:ne,isParentHovered:K,animated:P,queuedCount:Q}),be&&qt&&reactDom.createPortal(jsxRuntime.jsx(Us,{message:be.message,retrying:be.retrying,onRetry:xr,onDismiss:Er}),document.body),ne&&qt&&reactDom.createPortal(jsxRuntime.jsx("div",{role:"presentation",onClick:X?Vt:void 0,style:{position:"fixed",inset:0,zIndex:99999,backgroundColor:X?"rgba(26,23,20,0.32)":"transparent",backdropFilter:X?"blur(8px)":"none",WebkitBackdropFilter:X?"blur(8px)":"none",pointerEvents:X?"auto":"none",transition:"background-color 180ms cubic-bezier(0.22, 0.61, 0.36, 1)"},children:jsxRuntime.jsx("div",{onClick:X?x=>x.stopPropagation():void 0,style:{pointerEvents:"auto"},children:jsxRuntime.jsx(cr,{...Ar})})}),document.body)]})}function Us({message:e,retrying:o,onRetry:t,onDismiss:r}){return jsxRuntime.jsxs("div",{role:"status","aria-live":"polite",className:"editorial",style:{position:"fixed",bottom:16,right:16,zIndex:99998,maxWidth:360,borderRadius:6,border:"1px solid rgba(155, 58, 46, 0.35)",backgroundColor:"#FAF8F4",boxShadow:"0 4px 16px rgba(26, 23, 20, 0.12)",padding:"14px 16px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif",color:"#1A1714",animation:"gotcha-fade-up 240ms cubic-bezier(0.22, 0.61, 0.36, 1)"},children:[jsxRuntime.jsx("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, 'Courier New', monospace",fontSize:10,textTransform:"uppercase",letterSpacing:"0.18em",color:"#9B3A2E",marginBottom:6},children:"Couldn\u2019t save"}),jsxRuntime.jsx("p",{style:{margin:0,fontSize:13,lineHeight:1.55,color:"#1A1714"},children:e||"Your feedback didn\u2019t reach us. Retry?"}),jsxRuntime.jsxs("div",{style:{marginTop:12,display:"flex",gap:8},children:[jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:o,style:{backgroundColor:"#1A1714",color:"#FAF8F4",border:"none",borderRadius:4,padding:"6px 14px",fontSize:12,fontWeight:500,cursor:o?"default":"pointer",opacity:o?.6:1,transition:"opacity 180ms"},children:o?"Retrying\u2026":"Retry"}),jsxRuntime.jsx("button",{type:"button",onClick:r,style:{backgroundColor:"transparent",color:"#6B655D",border:"1px solid #E8E2D9",borderRadius:4,padding:"6px 14px",fontSize:12,cursor:"pointer",transition:"color 180ms"},children:"Dismiss"})]})]})}function dr({elementId:e,refreshInterval:o}){let{client:t}=G(),[r,a]=react.useState(null),[s,i]=react.useState(true),[n,p]=react.useState(null);return react.useEffect(()=>{let c=false,l=async()=>{try{let u=await t.getScore(e);c||(a(u),p(null));}catch(u){c||p(u instanceof Error?u.message:"Failed to load score");}finally{c||i(false);}};l();let d;return o&&o>0&&(d=setInterval(l,o)),()=>{c=true,d&&clearInterval(d);}},[t,e,o]),{score:r,isLoading:s,error:n}}var Ys={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 qs({rating:e,size:o,filledColor:t,emptyColor:r}){let a=`gotcha-star-clip-${Math.random().toString(36).slice(2,8)}`,s=[];for(let i=1;i<=5;i++){let n=Math.min(1,Math.max(0,e-(i-1))),p=`${a}-${i}`;s.push(jsxRuntime.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",style:{display:"block"},children:[jsxRuntime.jsx("defs",{children:jsxRuntime.jsx("clipPath",{id:p,children:jsxRuntime.jsx("rect",{x:"0",y:"0",width:24*n,height:"24"})})}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:r}),jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:t,clipPath:`url(#${p})`})]},i));}return jsxRuntime.jsx("span",{style:{display:"inline-flex",gap:Math.max(1,o*.08),alignItems:"center"},children:s})}function Xs({rate:e,height:o,filledColor:t,trackColor:r}){return jsxRuntime.jsx("span",{style:{display:"inline-block",width:48,height:o,borderRadius:o,backgroundColor:r,overflow:"hidden",verticalAlign:"middle"},children:jsxRuntime.jsx("span",{style:{display:"block",width:`${e}%`,height:"100%",borderRadius:o,background:t,transition:"width 0.6s cubic-bezier(0.4, 0, 0.2, 1)"}})})}function Vs({size:e,color:o}){return jsxRuntime.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:jsxRuntime.jsx("path",{d:"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3"})})}function js({elementId:e,variant:o="stars",showCount:t=true,size:r="md",theme:a="auto",refreshInterval:s,style:i}){let{score:n,isLoading:p}=dr({elementId:e,refreshInterval:s}),[c,l]=react.useState("light");react.useEffect(()=>{if(typeof window>"u")return;let F=window.matchMedia("(prefers-color-scheme: dark)");l(F.matches?"dark":"light");let D=O=>l(O.matches?"dark":"light");return F.addEventListener("change",D),()=>F.removeEventListener("change",D)},[]);let{themeConfig:d}=G(),u=react.useMemo(()=>ue(a,c,d),[a,c,d]);if(p||!n)return null;let f=Ys[r],b=u.colors.text,g=u.colors.textDisabled,m=u.colors.starFilled,h=u.colors.starEmpty,w=u.colors.voteUp,y=u.colors.starEmpty,C={display:"inline-flex",alignItems:"center",gap:f.gap,fontFamily:u.typography.fontFamily,lineHeight:1,WebkitFontSmoothing:"antialiased",...i},v={fontFamily:u.typography.fontFamily,fontSize:f.ratingFontSize,fontWeight:700,color:b,fontVariantNumeric:"tabular-nums",letterSpacing:"-0.01em",lineHeight:1},E={fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace",fontSize:Math.max(9,f.fontSize-1),color:g,fontWeight:400,letterSpacing:"0.1em",textTransform:"uppercase"},k=(F,D)=>{let O=F===1?D:`${D}s`;return `${F.toLocaleString()} ${O}`};if(o==="votes"){let{voteCount:F,positiveRate:D}=n,O=F.up+F.down;return O===0?null:jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx(Vs,{size:f.iconSize,color:w}),jsxRuntime.jsxs("span",{style:{...v,color:w},children:[D,"%"]}),jsxRuntime.jsx(Xs,{rate:D??0,height:f.barHeight,filledColor:w,trackColor:y}),t&&jsxRuntime.jsx("span",{style:E,children:k(O,"vote")})]})}let{averageRating:P,totalResponses:z}=n;if(P===null||z===0)return null;let A=P.toFixed(1);return o==="compact"?jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx("svg",{width:f.starSize,height:f.starSize,viewBox:"0 0 24 24",style:{display:"block",flexShrink:0},children:jsxRuntime.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",fill:m})}),jsxRuntime.jsx("span",{style:v,children:A}),t&&jsxRuntime.jsxs("span",{style:E,children:["(",z.toLocaleString(),")"]})]}):o==="number"?jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx("span",{style:v,children:A}),jsxRuntime.jsx("span",{style:{...E,marginLeft:2},children:"/ 5"}),t&&jsxRuntime.jsxs("span",{style:{...E,marginLeft:2},children:["(",k(z,"response"),")"]})]}):jsxRuntime.jsxs("span",{style:C,children:[jsxRuntime.jsx(qs,{rating:P,size:f.starSize,filledColor:m,emptyColor:h}),jsxRuntime.jsx("span",{style:v,children:A}),t&&jsxRuntime.jsxs("span",{style:E,children:["(",k(z,"response"),")"]})]})}function Qs(){let{client:e,disabled:o,defaultUser:t,debug:r,openModal:a,closeModal:s,activeModalId:i}=G();return {client:e,disabled:o,defaultUser:t,debug:r,submitFeedback:e.submitResponse.bind(e),openModal:a,closeModal:s,activeModalId:i}}function Ks(e){let{activeModalId:o,openModal:t,closeModal:r}=G(),a=react.useCallback(()=>t(e),[t,e]),s=react.useCallback(()=>r(),[r]);return {open:a,close:s,isOpen:o===e}}
148
148
  exports.Gotcha=Gs;exports.GotchaProvider=Yr;exports.GotchaScore=js;exports.createTheme=Pr;exports.useGotcha=Qs;exports.useGotchaTrigger=Ks;//# sourceMappingURL=index.js.map
149
149
  //# sourceMappingURL=index.js.map