(()=>{var t={d:(a,r)=>{for(var e in r)t.o(r,e)&&!t.o(a,e)&&Object.defineProperty(a,e,{enumerable:!0,get:r[e]})},o:(t,a)=>Object.prototype.hasOwnProperty.call(t,a),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},a={};(()=>{"use strict";t.r(a),t.d(a,{Hovercards:()=>v});var r,e={top:"paddingBottom",bottom:"paddingTop",left:"paddingRight",right:"paddingLeft"};function n(t,a,r){var n=void 0===r?{}:r,o=n.placement,i=void 0===o?"right-start":o,c=n.offset,s=void 0===c?0:c,d=n.autoFlip,l=void 0===d||d,v=n.autoShift,h=void 0===v||v;a.style.padding="0";var _=t.getBoundingClientRect(),u=a.getBoundingClientRect(),g=_.top+scrollY,f=_.bottom+scrollY,p=_.right+scrollX,m=_.left+scrollX,w=_.top,y=innerHeight-_.bottom,b=_.left,H=innerWidth-_.right,S=0,k=0,L=i.split("-"),C=L[0],E=L[1];if(s=Math.max(0,s),l){var P=u.height+s,T=u.width+s;"top"===C&&w
w?C="bottom":"bottom"===C&&y
y?C="top":"left"===C&&bb?C="right":"right"===C&&HH&&(C="left")}if(h){var I=u.height-_.height,M=u.width-_.width,R=I/2,j=M/2;"top"!==C&&"bottom"!==C||("start"===E&&Hb?"start":"end")),"right"!==C&&"left"!==C||("start"===E&&yw?"start":"end"))}"top"===C||"bottom"===C?(S=m+_.width/2-u.width/2,k="top"===C?g-u.height-s:f,"start"===E&&(S=m),"end"===E&&(S=p-u.width)):(S="right"===C?p:m-u.width-s,k=g+_.height/2-u.height/2,"start"===E&&(k=g),"end"===E&&(k=f-u.height)),a.style.position="absolute",a.style.left=S+"px",a.style.top=k+"px",a.style[e[C]]=s+"px"}function o(t){var a={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return t.replace(/&(amp|lt|gt|quot|#39|x60);|[\&<>"'`]/g,(function(t){return"&"===t[0]?t:a[t]}))}function i(t){return encodeURI(t)}function c(t,a,r){var e=t.split("?"),n=e[0],o=e[1],i=new URLSearchParams(o||"");return i.set(a,r),n+"?"+i.toString()}function s(t,a){return t[a]||a}function d(){return d=Object.assign?Object.assign.bind():function(t){for(var a=1;a1?s[1]:""}else if("IMG"===t.tagName){var d=t.src.split("/").pop().split("?");r=d[0],n=d.length>1?d[1]:""}if(!r)return null;var l=new URLSearchParams(n),v=l.get("d")||l.get("default"),h=l.get("f")||l.get("forcedefault"),_=l.get("r")||l.get("rating"),u=l.get("initials"),g=l.get("name"),f=l.get("txt_color"),p=l.get("bg_color");return{id:"gravatar-hovercard-"+r+"-"+a,hash:r,params:(n=[v&&"d="+v,h&&"f="+h,_&&"r="+_,u&&"initials="+u,g&&"name="+g,f&&"txt_color="+f,p&&"bg_color="+p].filter(Boolean).join("&"))?"?"+n:"",ref:e._onQueryHovercardRef(t)||t}})).filter(Boolean).map((function(t){return d({},t,{onEnter:function(a){return e._handleMouseEnter(a,t)},onLeave:function(a){return e._handleMouseLeave(a,t)}})})),this._hovercardRefs},t._createDrawer=function(t,a,r){return'\n\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t'+r+"\n\t\t\t\t\t \n\t\t\t\t
\n\t\t\t
\n\t\t"},t._openDrawer=function(t,a){var r=a.querySelector('.gravatar-hovercard__drawer[data-drawer-name="'+t.dataset.targetDrawer+'"]');r&&r.classList.add("gravatar-hovercard__drawer--open")},t._closeDrawer=function(t,a){var r=a.querySelector('.gravatar-hovercard__drawer[data-drawer-name="'+t.dataset.targetDrawer+'"]');r&&(r.classList.add("gravatar-hovercard__drawer--closing"),r.classList.remove("gravatar-hovercard__drawer--open"),setTimeout((function(){r.classList.remove("gravatar-hovercard__drawer--closing")}),300))},t._createContactDrawerContent=function(t){var a={email:"icons/mail.svg",home_phone:"icons/home-phone.svg",work_phone:"icons/work-phone.svg",cell_phone:"icons/mobile-phone.svg",contact_form:"icons/envelope.svg",calendar:"icons/calendar.svg",calendly:"icons/calendly.svg"};return t.map((function(t){var r=t[0],e=t[1],n=function(t,a){switch(t){case"email":return"mailto:"+a;case"contact_form":case"calendar":case"calendly":return a.startsWith("http")?a:"https://"+a;default:return null}}(r,e),o=e.replace(/^(https?:\/\/)?(www\.)?/,"");return o=o.endsWith("/")?o.slice(0,-1):o,n&&(o=''+o+" "),'\n\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t\t\t'+r.replace("_"," ")+' \n\t\t\t\t\t\t'+o+" \n\t\t\t\t\t
\n\t\t\t\t \n\t\t\t"})).join("")},t._createSendMoneyDrawerContent=function(t){var a,r,e=[];return null==(a=t.links)||a.forEach((function(t){e.push('\n\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t \n\t\t\t")})),null==(r=t.crypto_wallets)||r.forEach((function(t){e.push('\n\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t\t\t'+t.label+' \n\t\t\t\t\t\t'+t.address+" \n\t\t\t\t\t
\n\t\t\t\t \n\t\t\t")})),e.join("")},a._showHovercard=function(a){var r=this,e=a.id,o=a.hash,i=a.params,v=a.ref,h=setTimeout((function(){if(!l.getElementById(e)&&r._canShowHovercard(o)){var a,h=new URLSearchParams(i);h.delete("size"),h.set("s","256"),i="?"+h.toString();var _={placement:r._placement,offset:r._offset,autoFlip:r._autoFlip,autoShift:r._autoShift};if(r._cachedProfiles.has(o)){var u=r._cachedProfiles.get(o);a=t.createHovercard(d({},u,{avatarUrl:u.avatarUrl+i}),{additionalClass:r._additionalClass,myHash:r._myHash,i18n:r._i18n}),r._onHovercardShown(o,a)}else a=t.createHovercardSkeleton({additionalClass:r._additionalClass}),r._onFetchProfileStart(o),fetch(c("https://api.gravatar.com/v3/profiles/"+o,"source","hovercard")).then((function(t){if(200!==t.status)throw t.status;return t.json()})).then((function(e){var c;r._cachedProfiles.set(o,{hash:e.hash,avatarUrl:e.avatar_url,profileUrl:e.profile_url,displayName:e.display_name,location:e.location,description:e.description,jobTitle:e.job_title,company:e.company,headerImage:e.header_image,backgroundColor:e.background_color,verifiedAccounts:null==(c=e.verified_accounts)?void 0:c.map((function(t){return{type:t.service_type,label:t.service_label,icon:t.service_icon,url:t.url,isHidden:t.is_hidden}})),contactInfo:e.contact_info,payments:e.payments});var s=r._cachedProfiles.get(o),l=t.createHovercard(d({},s,{avatarUrl:s.avatarUrl+i}),{additionalClass:r._additionalClass,myHash:r._myHash,i18n:r._i18n}).firstElementChild;a.classList.remove("gravatar-hovercard--skeleton"),a.replaceChildren(l),n(v,a,_),r._onFetchProfileSuccess(o,r._cachedProfiles.get(o)),r._onHovercardShown(o,a)})).catch((function(e){var n=s(r._i18n,"Sorry, we are unable to load this Gravatar profile.");switch(e){case 404:n=s(r._i18n,"Profile not found.");break;case 429:n=s(r._i18n,"Too Many Requests.");break;case 500:n=s(r._i18n,"Internal Server Error.")}var c=t.createHovercardError("https://0.gravatar.com/avatar/"+o+i,n,{additionalClass:r._additionalClass}).firstElementChild;a.classList.add("gravatar-hovercard--error"),a.classList.remove("gravatar-hovercard--skeleton"),a.replaceChildren(c),r._onFetchProfileFailure(o,{code:e,message:n})}));a.id=e,a.addEventListener("mouseenter",(function(){return clearInterval(r._hideHovercardTimeoutIds.get(e))})),a.addEventListener("mouseleave",(function(){return r._hideHovercard(e)})),l.body.appendChild(a),n(v,a,_)}}),this._delayToShow);this._showHovercardTimeoutIds.set(e,h)},a._hideHovercard=function(t){var a=this,r=setTimeout((function(){var r=l.getElementById(t);r&&(r.remove(),a._onHovercardHidden(t,r))}),this._delayToHide);this._hideHovercardTimeoutIds.set(t,r)},a._handleMouseEnter=function(t,a){"ontouchstart"in l||(t.stopImmediatePropagation(),clearInterval(this._hideHovercardTimeoutIds.get(a.id)),this._showHovercard(a))},a._handleMouseLeave=function(t,a){var r=a.id;"ontouchstart"in l||(t.stopImmediatePropagation(),clearInterval(this._showHovercardTimeoutIds.get(r)),this._hideHovercard(r))},t}();r=v,v.createHovercard=function(t,a){var e,n,d=void 0===a?{}:a,v=d.additionalClass,h=d.myHash,_=d.i18n,u=void 0===_?{}:_,g=t.hash,f=t.avatarUrl,p=t.profileUrl,m=t.displayName,w=t.location,y=t.description,b=t.jobTitle,H=t.company,S=t.headerImage,k=t.verifiedAccounts,L=void 0===k?[]:k,C=t.payments,E=t.contactInfo,P=t.backgroundColor,T=l.createElement("div");T.className="gravatar-hovercard"+(v?" "+v:"");var I=L.find((function(t){return"calendly"===t.type&&!t.isHidden}));E&&I&&(E.calendly=I.url);var M=i(c(p,"utm_source","hovercard")),R=o(m),j=!y&&h===g,F=[b,H].filter(Boolean).join(", "),q=(null==C||null==(e=C.links)?void 0:e.length)||(null==C||null==(n=C.crypto_wallets)?void 0:n.length),A=Object.entries(E||{}).filter((function(t){t[0];return!!t[1]})),D=L.slice(0,3).reduce((function(t,a){var r=a.label,e=a.icon,n=a.url,c=a.type;return a.isHidden||t.push('\n\t\t\t\t\t\n\t\t\t\t\t\t \n\t\t\t\t\t \n\t\t\t\t'),t}),[]).join(""),x="",U="",O="";(A.length||q)&&(A.length&&(x+='\n\t\t\t\t\t'+s(u,"Contact")+" \n\t\t\t\t",U=r._createDrawer("contact",s(u,"Contact"),r._createContactDrawerContent(A))),q&&(x+='\n\t\t\t\t\t'+s(u,"Send money")+" \n\t\t\t\t",O=r._createDrawer("send-money",s(u,"Send money"),r._createSendMoneyDrawerContent(C))),x='\n\t\t\t\t'+x+"
\n\t\t\t"),T.innerHTML='\n\t\t\t\n\t\t\t\t'+(S?'':"")+'\n\t\t\t\t\n\t\t\t\t"+(y?'
\n\t\t\t\t\t\t\t\t
'+o(y)+"
\n\t\t\t\t\t\t\t
":"")+'\n\t\t\t\t
\n\t\t\t\t"+x+'\n\t\t\t\t\n\t\t\t\t"+U+"\n\t\t\t\t"+O+"\n\t\t\t\t"+(P?'
':"")+"\n\t\t\t
\n\t\t";var B=T.querySelector(".gravatar-hovercard__inner"),N=B.querySelector(".gravatar-hovercard__header-image"),G=B.querySelector(".gravatar-hovercard__profile-color");return S&&N&&(N.style.background=S),P&&G&&(G.style.background=P),B.querySelectorAll(".gravatar-hovercard__button").forEach((function(t){t.addEventListener("click",(function(){return r._openDrawer(t,B)}))})),B.querySelectorAll(".gravatar-hovercard__drawer-close").forEach((function(t){t.addEventListener("click",(function(){return r._closeDrawer(t,B)}))})),B.querySelectorAll(".gravatar-hovercard__drawer-backdrop").forEach((function(t){t.addEventListener("click",(function(){return r._closeDrawer(t,B)}))})),T},v.createHovercardSkeleton=function(t){var a=(void 0===t?{}:t).additionalClass,r=l.createElement("div");return r.className="gravatar-hovercard gravatar-hovercard--skeleton"+(a?" "+a:""),r.innerHTML='\n\t\t\t\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\n\t\t\t
\n\t\t',r},v.createHovercardError=function(t,a,r){var e=void 0===r?{}:r,n=e.avatarAlt,o=void 0===n?"Avatar":n,i=e.additionalClass,c=l.createElement("div");return c.className="gravatar-hovercard gravatar-hovercard--error"+(i?" "+i:""),c.innerHTML='\n\t\t\t\n\t\t\t\t
\n\t\t\t\t
'+a+" \n\t\t\t
\n\t\t",c}})();var r=Gravatar="undefined"==typeof Gravatar?{}:Gravatar;for(var e in a)r[e]=a[e];a.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
//# sourceMappingURL=index.umd.js.map