1import{na as r,ra as c}from"./chat-page-evUfHQgD.js";c();var l=class extends r{constructor(){super()}loadScript(){if(typeof document>"u")return;const t="gapi";if(document?.getElementById(t))return;const n=document.getElementsByTagName("head")[0],e=document.createElement("script");e.type="text/javascript",e.defer=!0,e.async=!0,e.id=t,e.onload=this.platformJsLoaded.bind(this),e.src="https://apis.google.com/js/platform.js",n.appendChild(e)}initialize(t={clientId:"",scopes:[],grantOfflineAccess:!1}){var n,e;if(typeof window>"u")return;const s=(n=document.getElementsByName("google-signin-client_id")[0])===null||n===void 0?void 0:n.content,i=t.clientId||s||"";return i||console.warn("GoogleAuthPlugin - clientId is empty"),this.options={clientId:i,grantOfflineAccess:(e=t.grantOfflineAccess)!==null&&e!==void 0?e:!1,scopes:t.scopes||[]},this.gapiLoaded=new Promise(a=>{window.gapiResolve=a,this.loadScript()}),this.addUserChangeListener(),this.gapiLoaded}platformJsLoaded(){gapi.load("auth2",()=>{const t={client_id:this.options.clientId,plugin_name:"CodetrixStudioCapacitorGoogleAuth"};this.options.scopes.length&&(t.scope=this.options.scopes.join(" ")),gapi.auth2.init(t),window.gapiResolve()})}async signIn(){return new Promise(async(t,n)=>{var e;try{let s;const i=(e=this.options.grantOfflineAccess)!==null&&e!==void 0?e:!1;i?s=(await gapi.auth2.getAuthInstance().grantOfflineAccess()).code:await gapi.auth2.getAuthInstance().sign
1In();const a=gapi.auth2.getAuthInstance().currentUser.get();i&&await a.reloadAuthResponse();const o=this.getUserFrom(a);o.serverAuthCode=s,t(o)}catch(s){n(s)}})}async refresh(){const t=await gapi.auth2.getAuthInstance().currentUser.get().reloadAuthResponse();return{accessToken:t.access_token,idToken:t.id_token,refreshToken:""}}async signOut(){return gapi.auth2.getAuthInstance().signOut()}async addUserChangeListener(){await this.gapiLoaded,gapi.auth2.getAuthInstance().currentUser.listen(t=>{this.notifyListeners("userChange",t.isSignedIn()?this.getUserFrom(t):null)})}getUserFrom(t){const n={},e=t.getBasicProfile();n.email=e.getEmail(),n.familyName=e.getFamilyName(),n.givenName=e.getGivenName(),n.id=e.getId(),n.imageUrl=e.getImageUrl(),n.name=e.getName();const s=t.getAuthResponse(!0);return n.authentication={accessToken:s.access_token,idToken:s.id_token,refreshToken:""},n}};export{l as GoogleAuthWeb};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.