Module 548118

3,868 characters · in no known chunk
Dependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{s:()=>v,iu:()=>C,DN:()=>y,Ay:()=>D});var i=n(627968),r=n(64700),s=n(503698),a=n.n(s),o=n(936504),l=n(17928),u=n(661531),c=n(990078),d=n(939249);n(321073);var _=n(113144),f=n.n(_),h=n(776231);let p=/url\(['"](.*)['"]\)/,E=e=>{if(null==e||""===e||"none"===e)return null;let t=e.match(p);return null!=t?t[1]:e};var m=n(624793),g=n(714991),A=n(260509),I=n(531685),T=n(515718),S=n(821589),N=n(645206);let y={SMOL:"Smol",MINI:"Mini",SMALLER:"Smaller",SMALL:"Small",MEDIUM:"Medium",LARGE:"Large",LARGER:"Larger",XLARGE:"XLarge"},C={[y.SMOL]:16,[y.MINI]:20,[y.SMALLER]:24,[y.SMALL]:30,[y.MEDIUM]:40,[y.LARGE]:50,[y.LARGER]:64,[y.XLARGE]:100},v={[y.SMOL]:[10,10,8,6,6,4],[y.MINI]:[12,12,10,10,8,6,4],[y.SMALLER]:[13,13,11,11,9,7,5],[y.SMALL]:[14,14,12,12,10,8,6],[y.MEDIUM]:[16,16,14,14,12,10,8],[y.LARGE]:[18,18,16,16,14,12,10],[y.LARGER]:[19,19,17,17,15,13,11],[y.XLARGE]:[20,20,18,18,16,14,12]};class O extends r.PureComponent{renderAcronym(){let{guild:e,iconSrc:t}=this.props;return null!=e.icon||null!=t?null:(0,i.jsx)("div",{className:N.acronym,children:(0,A.Rb)(e)})}renderBadge(){let{showBadge:e,guild:t,badgeStrokeColor:n,badgeTooltipColor:r,badgeTooltipDelay:s}=this.props;return e?(0,i.jsx)(g.A,{className:N.guildIconBadge,guild:t,badgeStrokeColor:n,tooltipColor:r,tooltipDelay:s}):null}renderIcon(){let{guild:e,className:t,showBadge:n,active:r,size:s,style:o={},textScale:l,showTooltip:u,tooltipPosition:c,onClick:_,to:f,badgeStrokeColor:h,animate:p,tabIndex:E,iconSrc:m,"aria-hidden":g,lossless:I,iconSize:T,...y}=this.props,C=v[s],O=null!=_?d.D:"div",R=(0,A.Rb)(e);return(0,i.jsxs)(O,{className:a()(N.icon,t,(0,S.t)(N,"iconSize",s),{[(0,S.t)(N,"iconActive",s)??""]:r,[N.iconInactive]:!r,[N.noIcon]:null==e.icon}),"aria-hidden":g,style:null==e.icon?{fontSize:(C[R.length]??C[C.length-1])*l,...o}:o,onClick:null!=f||null==_?void 0:_,tabIndex:E,...y,children:[this.renderAcronym(),this.renderBadge()]})}renderTooltip(){let{guild:e,showTooltip:t,tooltipPosition:n}=this.props;return t?(0,i.jsx)(c.m,{text:e.name,position:n,"aria-label":!1,children:this.renderIcon()}):this.renderIcon()}render(){let{to:e,guild:t,source:n,tabIndex:r,"aria-hidden":s}=this.props;return null!=e?(0,i.jsx)(o.N_,{"aria-hidden":s,to:{pathname:e,state:null!=n?{analyticsSource:n}:null},"aria-label":t.name,tabIndex:r,children:this.renderTooltip()}):this.renderTooltip()}}let R=l.Ay.connectStores([I.A],e=>{let{guild:t,animate:n,iconSrc:i,style:r,size:s,iconSize:a,lossless:o}=e;return null==i&&(i=t instanceof m.GO?t.getIconURL(a??C[s],n&&I.A.isFocused()):(0,A.Iv)(t,a??C[s],n&&I.A.isFocused(),o)),{style:{...r,backgroundImage:(0,T.wU)(i)}}})(function(e){class t extends r.Component{cachedURLs=[];canceller=null;constructor(e){super(e);const{style:t}=e,n=null!=t?E(t.backgroundImage):null;this.cachedURLs=[n],this.state={cached:n,loaded:!0}}componentDidUpdate(e,t){if(t===this.state)return;let{cached:n,loaded:i}=this.state,{style:r}=this.props,s=null!=r?E(r.backgroundImage):null;null==s&&s!==n||this.cachedURLs.indexOf(s)>=0?this.setState({loaded:!0,cached:s}):null!=s&&s!==n&&!0===i&&this.setState({loaded:!1},()=>this.preloadURL(s))}preloadURL(e){this.canceller?.(),this.canceller=(0,h.yt)(e,t=>{this.canceller=null,t||(this.cachedURLs.push(e),this.setState({cached:e,loaded:!0}))})}componentWillUnmount(){this.canceller?.(),this.cachedURLs.length=0}render(){let{style:t,...n}=this.props,{loaded:r,cached:s}=this.state;return r||null==t||(t={...t,backgroundImage:null==s||""===s||"none"===s?"none":`url(${s})`}),(0,i.jsx)(e,{style:t,...n})}}return f()(t,e),t}(e=>(0,i.jsx)(O,{...e})));class b extends r.PureComponent{static Sizes=y;static defaultProps={size:y.LARGE,textScale:1,showBadge:!1,showTooltip:!1,active:!1,tooltipPosition:"top",badgeStrokeColor:u.A.unsafe_rawColors.WHITE.css,animate:!1};render(){return(0,i.jsx)(R,{...this.props})}}let D=b}