"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4428],{28273:function(e,r,n){var t=n(85893),i=n(67294),l=n(86896),o=n(22715),s=n(23776),a=n(12102),c=n(43530),d=n(87357);r.Z=e=>{let{countries:r,countryCode:n,onChange:u,sx:h}=e,g=(0,l.Z)(),m=i.useMemo(()=>r?a.hW.filter(e=>r.includes(e.code)):a.hW,[r]),[f,x]=i.useState(a.hW.find(e=>e.code===n)||null);return i.useEffect(()=>{(null===f||n!==f.code)&&x(a.hW.find(e=>e.code===n)||null)},[n]),(0,t.jsx)(s.Z,{sx:h,options:m,autoHighlight:!0,getOptionLabel:e=>e.name,renderOption:(e,r)=>(0,t.jsx)(d.Z,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...e,children:(0,t.jsx)(c.Z,{country:r},r.code)}),value:f,renderInput:e=>(0,t.jsx)(o.Z,{...e,placeholder:g.formatMessage({id:"ChooseCountry"}),inputProps:{...e.inputProps,autoComplete:"new-password"}}),onChange:(e,r,n,t)=>{x(r),u(r)}})}},45023:function(e,r,n){var t=n(85893),i=n(67294),l=n(22715),o=n(23776),s=n(87357),a=n(86896),c=n(73359),d=n(23497),u=n(80005);r.Z=e=>{let{games:r,onChange:n,onError:h,initialValue:g=null,sx:m}=e,f=(0,a.Z)(),[x,p]=i.useState(g),[v,{data:y,loading:j,error:Z}]=(0,c.t)(d.m7);i.useEffect(()=>{r.length>0&&v({variables:{gameIds:r.map(e=>e.slice(1))}})},[r]),i.useEffect(()=>{Z&&h(Z)},[Z]),i.useEffect(()=>{},[y]);let S=null==y?void 0:y.getIGDBGames;return(0,t.jsx)(o.Z,{sx:m,options:S||[],autoHighlight:!0,getOptionLabel:e=>e.name,renderOption:(e,r)=>(0,i.createElement)(s.Z,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...e,key:r.id,style:{userSelect:"none",cursor:"pointer"}},(0,t.jsx)(u.Z,{game:"i"+r.id,activeLinks:!1},r.id)),value:x,renderInput:e=>(0,t.jsx)(l.Z,{...e,placeholder:f.formatMessage({id:"ChooseGame"}),inputProps:{...e.inputProps,autoComplete:"new-password"}}),onChange:(e,r,t,i)=>{p(r),n(r)}})}},66361:function(e,r,n){n.d(r,{Z:function(){return LanguageSelect}});var t=n(85893),i=n(67294),l=n(86896),o=n(23776),s=n(22715),a=n(87357),c=n(26452);function LanguageSelect(e){let{languages:r,locale:n,onChange:a}=e,d=(0,l.Z)(),u=i.useMemo(()=>r?c.mT.filter(e=>r.includes(e.locale)):c.mT,[r]),[h,g]=i.useState(c.mT.find(e=>e.locale===n)||null);return(0,t.jsx)(o.Z,{id:"country-select-demo",sx:{width:"100%",maxWidth:"15rem"},options:u,autoHighlight:!0,getOptionLabel:e=>e.name,renderOption:(e,r)=>(0,t.jsx)(LanguageBox,{option:r,props:e},r.locale),value:h,renderInput:e=>(0,t.jsx)(s.Z,{...e,placeholder:d.formatMessage({id:"ChooseLanguage"}),inputProps:{...e.inputProps,autoComplete:"new-password"}}),onChange:(e,r,n,t)=>{g(r),a(r)}})}let LanguageBox=e=>{let{option:r,props:n}=e;return(0,t.jsx)(a.Z,{component:"li",sx:{"& > img":{mr:2,flexShrink:0}},...n,children:r.name})}},54428:function(e,r,n){n.d(r,{Z:function(){return Search}});var t=n(85893),i=n(67294),l=n(23972),o=n(44012),s=n(2734),a=n(66489),c=n(26447),d=n(21987),u=n(58988),h=n(43530),g=n(26452),m=n(59582);function SearchProfile(e){let{profile:r,onClick:n}=e,[o,s]=i.useState(!1);if(!r)return null;let a=(0,u.Sy)(r);return(0,u.oY)(r),(0,t.jsxs)(m.k,{elevation:4,style:{padding:"1rem",width:"13rem",minWidth:"13rem",height:"25rem",overflow:"hidden",cursor:"pointer",display:"flex",flexDirection:"column"},onClick:n,children:[(0,t.jsxs)(c.Z,{gap:"0.75rem",style:{width:"13rem",overflow:"hidden"},children:[(0,t.jsx)("div",{style:{height:"13rem",width:"13rem",borderRadius:"0.5rem",overflow:"hidden"},children:(0,t.jsx)("div",{style:{backgroundImage:"url(".concat((0,u.wX)(r),")"),backgroundPosition:"center",backgroundSize:"cover",transform:o?"scale(1.1)":"scale(1.0)",transition:"1s",width:"100%",height:"100%"},onMouseEnter:()=>{s(!0)},onMouseLeave:()=>{s(!1)}})}),(0,t.jsx)(l.Z,{variant:"subtitle1",style:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},component:"div",children:a}),(null==r?void 0:r.summary)?(0,t.jsx)(l.Z,{variant:"body1",component:"p",style:{display:"-webkit-box",WebkitLineClamp:4,WebkitBoxOrient:"vertical"},children:r.summary}):null]}),(0,t.jsxs)(c.Z,{style:{marginTop:"auto"},children:[(null==r?void 0:r.country_of_residence)?(0,t.jsx)(h.Z,{country:r.country_of_residence,oneliner:!0}):null,(null==r?void 0:r.languages)?(0,t.jsx)(l.Z,{variant:"body1",style:{whiteSpace:"nowrap",textOverflow:"ellipsis",overflow:"hidden"},component:"div",children:r.languages.map(e=>g.b9[e]).join(", ")}):null]})]})}var f=n(73359),x=n(82729),p=n(31230);function _templateObject(){let e=(0,x._)(["\n query searchPublicProfiles(\n $games: [String!]\n $country_of_residence: String\n $languages: [String!]\n $customized_id: String\n ) {\n searchPublicProfiles(\n games: $games\n country_of_residence: $country_of_residence\n languages: $languages\n customized_id: $customized_id\n ) @client {\n profiles {\n friend_id\n customized_id\n languages\n country_of_residence\n avatar\n background\n summary\n real_name\n gamer_names\n games\n }\n hasMore\n }\n }\n"]);return _templateObject=function(){return e},e}let v=(0,p.Ps)(_templateObject());var y=n(39518),j=n(13594),Z=n(9103);function SearchResult(e){let{openProfile:r}=e,n=(0,s.Z)(),{loading:u,profiles:h,hasMore:g,error:m}=function(){let[e,{data:r,loading:n,error:t}]=(0,f.t)(v,{fetchPolicy:"network-only"}),{gameFilter:l,countryFilter:o,localesFilter:s,customizedIdFilter:a}=(0,Z.C)(e=>e.search),{profiles:c,hasMore:d}=i.useMemo(()=>{var e,n;return{profiles:null==r?void 0:null===(e=r.searchPublicProfiles)||void 0===e?void 0:e.profiles,hasMore:null==r?void 0:null===(n=r.searchPublicProfiles)||void 0===n?void 0:n.hasMore}},[r]),[u,h]=i.useState(void 0);return i.useEffect(()=>{t&&(j.ZP.error("ProfileSearch(): Fetching public profiles failed. (error: ".concat(JSON.stringify(t),")")),h("FetchingPublicProfilesFailed"))},[t]),i.useEffect(()=>{(0,y.f)("event","skelly_profile_search",{skelly_event_action:JSON.stringify(null==l?void 0:l.id),skelly_event_source:JSON.stringify(o),skelly_event_label:JSON.stringify(s)}),j.ZP.log("ProfileSearch(): Selection changed (games: ".concat(JSON.stringify(l),", country: ").concat(JSON.stringify(o),", locales: ").concat(JSON.stringify(s),", customizedIdFilter: ").concat(JSON.stringify(a),")"));let r={games:l?["i"+l.id]:void 0,country_of_residence:o,languages:s&&(Array.isArray(s)?s:[s]),customized_id:a};j.ZP.log("ProfileSearch(): Selection changed (variables: ".concat(JSON.stringify(r),")")),e({variables:r})},[l,o,s,a]),{loading:n,profiles:c,hasMore:d,error:u}}();return m?(0,t.jsxs)(l.Z,{variant:"body1",children:[(0,t.jsx)(o.Z,{id:"ErrorSorryMessage"})," ",(0,t.jsx)(o.Z,{id:"NetworkRequestFailed"})]}):u?(0,t.jsx)("div",{style:{height:"16rem",width:"100%",maxWidth:"41rem",display:"flex"},children:(0,t.jsx)(a.Z,{size:"6rem",style:{margin:"auto"}})}):h?0===h.length?(0,t.jsx)(l.Z,{variant:"body1",children:(0,t.jsx)(o.Z,{id:"NoProfileFound"})}):(0,t.jsxs)(c.Z,{direction:"row",gap:"1rem",flexWrap:"wrap",style:{overflow:"auto"},children:[h.map(e=>(0,t.jsx)(SearchProfile,{profile:e,onClick:()=>{let n=e.customized_id||e.friend_id;r(n)}},e.friend_id)),g?(0,t.jsx)(d.Z,{elevation:4,style:{padding:"1rem",width:"13rem",minWidth:"13rem",height:"25rem",overflow:"hidden",display:"flex",flexDirection:"column"},children:(0,t.jsx)(l.Z,{variant:"body1",style:{padding:"1rem",height:"11rem",width:"11rem",borderRadius:"0.5rem",backgroundColor:n.palette.surfaceVariant.default,color:n.palette.surfaceVariant.contrastText,textAlign:"center",display:"flex"},component:"div",children:(0,t.jsx)("div",{style:{marginTop:"auto",marginBottom:"auto",display:"flex"},children:(0,t.jsx)(o.Z,{id:"HasMoreProfiles"})})})}):null]}):null}var S=n(86725),w=n(53265),_=n(21879),b=n(69072),P=n(22715),k=n(28273),C=n(66361),O=n(45023),F=n(6154),N=n(30490);let E=i.createContext(null);function SearchContextProvider(e){let{children:r}=e,{loading:n,games:l,countries:o,languages:s,error:a,retry:c}=function(){let[e,r]=i.useState([]),[n,t]=i.useState([]),[l,o]=i.useState([]),[s,a]=i.useState(!0),[c,d]=i.useState(void 0),[u,h]=i.useState(1);return i.useEffect(()=>{let e="web"===N.N||"ios"===N.N?"https://server.skelly.gg:3001/searchFields":"http://server.skelly.gg:3000/searchFields";j.ZP.log("useSearchFields(): Fetching search fields"),F.Z.get(e).then(e=>{if(200===e.status){let n=e.data;r(n.games),t(n.countries),o(n.languages),d(void 0)}else j.ZP.error("useSearchFields(): Fetching search fields (".concat(e.status," | ").concat(e.statusText,"): "),e.statusText),d("SkellyServerReturnedError")}).catch(e=>{j.ZP.error("useSearchFields(): error: ",e),d("CouldNotAccessSkellyServer")}).finally(()=>{a(!1)})},[u]),{loading:s,games:e,countries:n,languages:l,error:c,retry:()=>{!1===s&&(a(!0),h(e=>e+1))}}}();return(0,t.jsx)(E.Provider,{value:{loading:n,games:l,countries:o,languages:s,error:a,retry:c},children:r})}var W=n(62858),I=n(9473);function SearchFiltering(){let e=(0,I.I0)(),[r,n]=i.useState(void 0),{games:s,languages:a,countries:d}=i.useContext(E),{gameFilter:u,localesFilter:h,countryFilter:g,customizedIdFilter:m}=(0,Z.C)(e=>e.search);return(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)(c.Z,{direction:"row",gap:"1rem",flexWrap:"wrap",alignContent:"center",children:[(0,t.jsxs)(c.Z,{direction:"column",gap:"0.5rem",style:{width:"13rem"},children:[(0,t.jsxs)(c.Z,{direction:"row",gap:"0.5rem",alignItems:"center",children:[(0,t.jsx)(S.Z,{}),(0,t.jsx)(l.Z,{variant:"subtitle2",children:(0,t.jsx)(o.Z,{id:"Game"})})]}),(0,t.jsx)(O.Z,{games:s,onChange:r=>{e((0,W.PU)(r))},onError:e=>{n(e)},initialValue:u,sx:{width:"100%",maxWidth:"15rem"}})]}),(0,t.jsxs)(c.Z,{direction:"column",gap:"0.5rem",style:{width:"13rem"},children:[(0,t.jsxs)(c.Z,{direction:"row",gap:"0.5rem",alignItems:"center",children:[(0,t.jsx)(w.Z,{}),(0,t.jsx)(l.Z,{variant:"subtitle2",children:(0,t.jsx)(o.Z,{id:"Language"})})]}),(0,t.jsx)(C.Z,{languages:a,locale:(null==h?void 0:h.length)>0?h[0]:void 0,onChange:r=>{e((0,W.Te)(r?[r.locale]:void 0))}})]}),(0,t.jsxs)(c.Z,{direction:"column",gap:"0.5rem",style:{width:"13rem"},children:[(0,t.jsxs)(c.Z,{direction:"row",gap:"0.5rem",alignItems:"center",children:[(0,t.jsx)(_.Z,{}),(0,t.jsx)(l.Z,{variant:"subtitle2",children:(0,t.jsx)(o.Z,{id:"Country"})})]}),(0,t.jsx)(k.Z,{countries:d,countryCode:g,onChange:r=>{e((0,W._8)(r?r.code:void 0))},sx:{width:"100%",maxWidth:"15rem"}})]}),(0,t.jsxs)(c.Z,{direction:"column",gap:"0.5rem",style:{width:"13rem"},children:[(0,t.jsxs)(c.Z,{direction:"row",gap:"0.5rem",alignItems:"center",children:[(0,t.jsx)(b.Z,{}),(0,t.jsx)(l.Z,{variant:"subtitle2",children:(0,t.jsx)(o.Z,{id:"Username"})})]}),(0,t.jsx)(P.Z,{sx:{width:"100%",maxWidth:"15rem"},placeholder:"Search",defaultValue:m,onChange:r=>{let n=r.target.value,t=n&&""!==n?n:void 0;console.log("++: val ",t),t!==m&&e((0,W.cp)(t))}})]})]})})}function Search(e){let{openProfile:r}=e;return(0,t.jsx)(SearchContextProvider,{children:(0,t.jsx)(Internal,{openProfile:r})})}function Internal(e){let{openProfile:r}=e,{error:n}=i.useContext(E);return n?(0,t.jsxs)(l.Z,{variant:"body1",children:[(0,t.jsx)(o.Z,{id:"ErrorSorryMessage"})," ",(0,t.jsx)(o.Z,{id:"NetworkRequestFailed"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(SearchFiltering,{}),(0,t.jsx)(SearchResult,{openProfile:r})]})}}}]);