Loading
function(r,e,t){t.r(e),t.d(e,{default:()=>E});var a,o=t(477900);t(582128);var n=t(284009),i=t.n(n),l=t(492462),c=((a={}).OAUTH_REDIRECT="oauth_redirect",a),u=t(333748),s=t(13202),h=t(231723),d=t(77468),A=t(269815),w=t(114716),p=t(370480),T=t(626584),_=t(123677),y=t(610056),I=t(321987),k=t(998218),L=t(652215);let f=new T.A("LinkAuthorize");function m(r){let{platformType:e}=r;(0,A.A)();let t=(0,_._)(window.location.search),{code:a,token_redirect_uri:n}=l.qg(window.location.search);return(0,o.jsx)(I.$,{removeChildWrapper:!0,children:(0,o.jsx)(y.OAuth2AuthorizeModal,{transitionState:h.ip.ENTERED,...t,showLogout:!0,callback:async function(r){let{location:t}=r;if(null==t)return;let{error:o}=l.qg(t),u=null;if(null==o&&null!=a)try{u=await async function(r,e,t,a){let o=null;try{let{body:r}=await d.A.authorize(a,{twoWayLinkType:s.I.WEB});o=r.url}catch(r){throw Error(`error at authorize with code ${r?.body?.code??0}`)}let n=null;try{i()(null!=o,"No URL in authorize response");let{state:r}=(0,p.vA)(o);i()(null!=r,"Authorize URL state query parameter must be present"),n=r}catch(r){throw Error("error at authorize parsing callback params")}try{let o=await d.A.completeTwoWayLink(a,r,e,n,t);return o?.body?.redirect}catch(r){throw Error(`error at callback with code ${r?.body?.code??0}`)}}(t,a,n,e)}catch(e){f.error("Error Creating Discord link",e?.message);let r=k.A.toURLSafe(t);if(null==r)return;r.searchParams.delete("code"),r.searchParams.set("error","two_way_link_error"),r.searchParams.set("error_description",e?.message??"unknown_error"),t=r.toString()}window.location=null==u||u===c.OAUTH_REDIRECT?t:u}})})}let E=(0,w.C)(function(r){let{match:e}=r,t=e.params.type,{client_id:a=""}=l.qg(window.location.search),n=t===L.fg2.PLAYSTATION&&a===u.i.PLAYSTATION_APPLICATION_ID,i=t===L.fg2.PLAYSTATION_STAGING&&a===u.i.PLAYSTATION_STAGING_APPLICATION_ID;return n||i?(0,o.jsx)(m,{platformType:t}):null})}