UNPKG

radh-ui

Version:

Stencil Component Starter

17 lines 8.03 kB
import{r as t,c as s,h as r}from"./p-1a9f3501.js";function i(t){return"function"==typeof t}let e=!1;const n={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){if(t){const t=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+t.stack)}else e&&console.log("RxJS: Back to a better error behavior. Thank you. <3");e=t},get useDeprecatedSynchronousErrorHandling(){return e}};function o(t){setTimeout(()=>{throw t},0)}const h={closed:!0,next(t){},error(t){if(n.useDeprecatedSynchronousErrorHandling)throw t;o(t)},complete(){}},c=Array.isArray||(t=>t&&"number"==typeof t.length),u=(()=>{function t(t){return Error.call(this),this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map((t,s)=>`${s+1}) ${t.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t})();class a{constructor(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._unsubscribe=t)}unsubscribe(){let t;if(this.closed)return;let{_parentOrParents:s,_unsubscribe:r,_subscriptions:e}=this;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,s instanceof a)s.remove(this);else if(null!==s)for(let i=0;i<s.length;++i)s[i].remove(this);if(i(r))try{r.call(this)}catch(o){t=o instanceof u?l(o.errors):[o]}if(c(e)){let s=-1,r=e.length;for(;++s<r;){const r=e[s];if(null!==(n=r)&&"object"==typeof n)try{r.unsubscribe()}catch(o){t=t||[],o instanceof u?t=t.concat(l(o.errors)):t.push(o)}}}var n;if(t)throw new u(t)}add(t){let s=t;if(!t)return a.EMPTY;switch(typeof t){case"function":s=new a(t);case"object":if(s===this||s.closed||"function"!=typeof s.unsubscribe)return s;if(this.closed)return s.unsubscribe(),s;if(!(s instanceof a)){const t=s;s=new a,s._subscriptions=[t]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}let{_parentOrParents:r}=s;if(null===r)s._parentOrParents=this;else if(r instanceof a){if(r===this)return s;s._parentOrParents=[r,this]}else{if(-1!==r.indexOf(this))return s;r.push(this)}const i=this._subscriptions;return null===i?this._subscriptions=[s]:i.push(s),s}remove(t){const s=this._subscriptions;if(s){const r=s.indexOf(t);-1!==r&&s.splice(r,1)}}}function l(t){return t.reduce((t,s)=>t.concat(s instanceof u?s.errors:s),[])}a.EMPTY=function(t){return t.closed=!0,t}(new a);const f="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random();class b extends a{constructor(t,s,r){switch(super(),this.syncErrorValue=null,this.syncErrorThrown=!1,this.syncErrorThrowable=!1,this.isStopped=!1,arguments.length){case 0:this.destination=h;break;case 1:if(!t){this.destination=h;break}if("object"==typeof t){t instanceof b?(this.syncErrorThrowable=t.syncErrorThrowable,this.destination=t,t.add(this)):(this.syncErrorThrowable=!0,this.destination=new p(this,t));break}default:this.syncErrorThrowable=!0,this.destination=new p(this,t,s,r)}}[f](){return this}static create(t,s,r){const i=new b(t,s,r);return i.syncErrorThrowable=!1,i}next(t){this.isStopped||this._next(t)}error(t){this.isStopped||(this.isStopped=!0,this._error(t))}complete(){this.isStopped||(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}_next(t){this.destination.next(t)}_error(t){this.destination.error(t),this.unsubscribe()}_complete(){this.destination.complete(),this.unsubscribe()}_unsubscribeAndRecycle(){const{_parentOrParents:t}=this;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this}}class p extends b{constructor(t,s,r,e){let n;super(),this._parentSubscriber=t;let o=this;i(s)?n=s:s&&(n=s.next,r=s.error,e=s.complete,s!==h&&(o=Object.create(s),i(o.unsubscribe)&&this.add(o.unsubscribe.bind(o)),o.unsubscribe=this.unsubscribe.bind(this))),this._context=o,this._next=n,this._error=r,this._complete=e}next(t){if(!this.isStopped&&this._next){const{_parentSubscriber:s}=this;n.useDeprecatedSynchronousErrorHandling&&s.syncErrorThrowable?this.__tryOrSetError(s,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}}error(t){if(!this.isStopped){const{_parentSubscriber:s}=this,{useDeprecatedSynchronousErrorHandling:r}=n;if(this._error)r&&s.syncErrorThrowable?(this.__tryOrSetError(s,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(s.syncErrorThrowable)r?(s.syncErrorValue=t,s.syncErrorThrown=!0):o(t),this.unsubscribe();else{if(this.unsubscribe(),r)throw t;o(t)}}}complete(){if(!this.isStopped){const{_parentSubscriber:t}=this;if(this._complete){const s=()=>this._complete.call(this._context);n.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,s),this.unsubscribe()):(this.__tryOrUnsub(s),this.unsubscribe())}else this.unsubscribe()}}__tryOrUnsub(t,s){try{t.call(this._context,s)}catch(r){if(this.unsubscribe(),n.useDeprecatedSynchronousErrorHandling)throw r;o(r)}}__tryOrSetError(t,s,r){if(!n.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{s.call(this._context,r)}catch(i){return n.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=i,t.syncErrorThrown=!0,!0):(o(i),!0)}return!1}_unsubscribe(){const{_parentSubscriber:t}=this;this._context=null,this._parentSubscriber=null,t.unsubscribe()}}const d="function"==typeof Symbol&&Symbol.observable||"@@observable";function w(t){return t}class y{constructor(t){this._isScalar=!1,t&&(this._subscribe=t)}lift(t){const s=new y;return s.source=this,s.operator=t,s}subscribe(t,s,r){const{operator:i}=this,e=function(t,s,r){if(t){if(t instanceof b)return t;if(t[f])return t[f]()}return t||s||r?new b(t,s,r):new b(h)}(t,s,r);if(e.add(i?i.call(e,this.source):this.source||n.useDeprecatedSynchronousErrorHandling&&!e.syncErrorThrowable?this._subscribe(e):this._trySubscribe(e)),n.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable&&(e.syncErrorThrowable=!1,e.syncErrorThrown))throw e.syncErrorValue;return e}_trySubscribe(t){try{return this._subscribe(t)}catch(s){n.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=s),function(t){for(;t;){const{closed:s,destination:r,isStopped:i}=t;if(s||i)return!1;t=r&&r instanceof b?r:null}return!0}(t)?t.error(s):console.warn(s)}}forEach(t,s){return new(s=_(s))((s,r)=>{let i;i=this.subscribe(s=>{try{t(s)}catch(e){r(e),i&&i.unsubscribe()}},r,s)})}_subscribe(t){const{source:s}=this;return s&&s.subscribe(t)}[d](){return this}pipe(...t){return 0===t.length?this:(0===(s=t).length?w:1===s.length?s[0]:function(t){return s.reduce((t,s)=>s(t),t)})(this);var s}toPromise(t){return new(t=_(t))((t,s)=>{let r;this.subscribe(t=>r=t,t=>s(t),()=>t(r))})}}function _(t){if(t||(t=Promise),!t)throw new Error("no Promise impl found");return t} /** * @license * Copyright 2018 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */y.create=t=>new y(t);class m{constructor(r){t(this,r),this.userInfo=s(this,"userInfo",7)}componentWillLoad(){var t;(t=firebase.auth(),new y((function(s){return{unsubscribe:t.onAuthStateChanged(s)}}))).subscribe(t=>{this.user=t,this.userInfo.emit(t)})}login(){const t=new firebase.auth.GoogleAuthProvider;firebase.auth().signInWithPopup(t)}logout(){firebase.auth().signOut()}render(){return this.user?r("div",null,"You are logged is as ",this.user.displayName,r("button",{onClick:this.logout},"Logout")):r("div",null,r("radh-button",{onClick:this.login},"Login with Google"))}}m.style="radh-auth{}";export{m as radh_auth}