"use strict";const m=require("./Env-a6f11491.js"),c=require("./useRoutes-df841412.js"),e=require("react"),k=require("@accelbyte/sdk-iam"),p=require("./Alert-e121f45b.js"),E=require("./CommonError-3e91e7d2.js"),d=require("./Alert-dec85153.js"),g=require("./ProfileImage-52ff6047.js"),y=require("@accelbyte/sdk"),s=require("react-i18next"),u=require("./index-dae188cc.js"),A=({children:o})=>{const{state:{user:r,userFetchStatus:t}}=m.useUserInfo(),{state:a}=c.useHistory(),[n]=m.useSdk();return e.useEffect(()=>{if(n&&!r&&t!==m.FetchStatus.FETCHING){const l=new k.IamUserAuthorizationClient(n).createLoginURL(a.location.pathname);window.location.replace(l)}},[n]),e.createElement(e.Fragment,null,o)},N=o=>{const{error:r,accountConflictInformation:t,onDismiss:a}=o;if((t==null?void 0:t.errorCode)===y.ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT&&(t!=null&&t.previousLinkedPlatformAccount)){const{platformID:n,platformUserID:l,platformDisplayName:i}=t.previousLinkedPlatformAccount,f=g.UserHelper.getPlatformName(n);return e.createElement(p.Alert,{className:"mb-6",type:d.AlertType.danger,onDismiss:a},e.createElement(s.Trans,{i18nKey:"LinkedAccountpage.cannotLinkWithAnotherAccount"},"Unable to link this ",{platformName:f}," account. Please link the ",{platformName:f}," account previously linked to this account :"," ",{platformDisplayName:i}," ( ",{platformUserID:l}," )."))}if(t){const n=g.UserHelper.getPlatformName(t.platformId);return e.createElement(p.Alert,{className:"mb-6",type:d.AlertType.danger,onDismiss:a},e.createElement(s.Trans,{i18nKey:"LinkedAccountPage.linkConflictError"},"That ",{platformName:n}," account has already been linked with another account.",e.createElement("br",null)," Please contact support for assistance linking it with a different account."))}return r?e.createElement(p.Alert,{type:d.AlertType.danger,className:"alert",onDismiss:a},e.createElement(E.CommonError,{error:r})):null};const h=({onCancel:o,onConfirm:r,platformId:t})=>{var i;const{state:a}=u.useDiscoveryConfigs(),n=g.UserHelper.getPlatformName(t),l=((i=a.discoveryConfigData)==null?void 0:i.brandName.data.value)||"";return e.createElement(u.Dialog,{className:"purchaseDialog",title:c.t("LinkedAccountPage.confirmUnlinkDialog.title"),isOpen:!0},e.createElement(u.DialogBody,null,e.createElement("p",{className:"dialogPlatformBodyText"},e.createElement(s.Trans,{i18nKey:"LinkedAccountPage.confirmUnlinkDialog.unlinkConfirm"},"Do you want to unlink your ",e.createElement("span",{className:"capitalize"},{platformName:n})," account from",{publisherName:l},"?"))),e.createElement(u.DialogFooter,null,e.createElement("div",{className:"flex justify-end"},e.createElement(c.Button,{className:"btn btn-ghost mr-2 uppercase",buttonType:c.ButtonType.TEXT,buttonStyle:c.ButtonStyle.NONE,onClick:()=>{o&&o()}},e.createElement(s.Trans,{i18nKey:"LinkAccountPage.cancel"},"Cancel")),e.createElement(c.Button,{className:"btn btn-primary uppercase",onClick:()=>{r&&r()}},e.createElement(s.Trans,{i18nKey:"LinkAccountPage.unlink"},"Unlink")))))};exports.LinkedAccountsErrorAlert=N;exports.PrivateWidget=A;exports.UnlinkAccountConfirmDialog=h;
