/*! Built with http://stenciljs.com */
const{h:t}=window.webcomponents;import{a as s,b as e,c as a,d as n,e as i,f as o,g as r,h as c,i as h,j as u,k as d,l,m as f,n as p,o as g,p as m,q as b,r as y,s as w,t as O,u as j,v,w as S,x as _,y as L,z as D,A as E,B as U,C as x,D as A,E as G,F as I,G as N,H as k}from"./chunk-c1dbd7c7.js";import{a as C}from"./chunk-25ecf4a4.js";var F=function(){function t(t,s,e){void 0===e&&(e=!1),this.accumulator=t,this.seed=s,this.hasSeed=e}return t.prototype.call=function(t,s){return s.subscribe(new H(t,this.accumulator,this.seed,this.hasSeed))},t}(),H=function(t){function e(s,e,a,n){var i=t.call(this,s)||this;return i.accumulator=e,i._seed=a,i.hasSeed=n,i.index=0,i}return s(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var s,e=this.index++;try{s=this.accumulator(this.seed,t,e)}catch(t){this.destination.error(t)}this.seed=s,this.destination.next(s)},e}(r);console.log.bind(console);const J=new L,M=(t,s={timestamp:C.getTimeStamp(),id:C.getUUID()})=>J.pipe(f(t=>(t=>t instanceof g)(t)?t:d([t])),function(){for(var t=[],s=0;s<arguments.length;s++)t[s]=arguments[s];return function(s){var e=t[t.length-1];c(e)?t.pop():e=null;var a=t.length;return l(1!==a||e?a>0?j(t,e):O(e):v(t[0]),s)}}(s),function(t,s){var e=!1;return arguments.length>=2&&(e=!0),function(a){return a.lift(new F(t,s,e))}}(t));function T(t,s){switch(s.type){case"CONFIG_LOADING":return Object.assign({},t,{isLoading:!0});case"CONFIG_LOADED":let e=Object.assign({},t,{isLoading:!1});return Object.keys(s.payload).forEach(t=>{e[t]=s.payload[t]}),e;case"SET_CONFIG":let a=Object.assign({},t);return Object.keys(s.payload).forEach(t=>{a[t]=s.payload[t]}),a;default:return t}}function $(t,s){switch(s.type){case"GITHUB_FOLLOWERS_LOADING":return Object.assign({},t,{isLoading:!0});case"GITHUB_FOLLOWERS_LOADED":return Object.assign({},t,{isLoading:!1,users:s.payload});case"NAME_CHANGED":return Object.assign({},t,{isLoading:!1,name:s.payload});default:return t}}var B=function(t,s,e,a){return new(e||(e=Promise))(function(n,i){function o(t){try{c(a.next(t))}catch(t){i(t)}}function r(t){try{c(a.throw(t))}catch(t){i(t)}}function c(t){t.done?n(t.value):new e(function(s){s(t.value)}).then(o,r)}c((a=a.apply(t,s||[])).next())})};const P=Symbol(),R=Symbol();class q{constructor(t){if(this.baseUrl="",this.loading=!0,this.authenticated=!1,this.errorMessage="",t!==R)throw new Error("Cannot construct singleton");this.initStores(),this.base=k.instance,this.config=this.base.config}init(t,s=""){return B(this,void 0,void 0,function*(){return""!==s&&(this.baseUrl=s),this.appRoot=t,yield this.base.initApp(this.baseUrl+"/assets/config.json",!0,"_emaApp"),this.baseUrl=s,this.base.translation.use(this.config.get("language")),this.data={},this.data.manifest=yield C.fetchJson(this.baseUrl+"/assets/collection-manifest.json"),this.data.mockData=yield C.fetchJson(this.baseUrl+"/assets/data/mock-data.json"),this.data.dwpData=yield C.fetchJson(this.baseUrl+"/assets/data/mock-dwp.json"),this.data.swaggerData=yield C.fetchJson(this.baseUrl+"/assets/data/apiSwagger.json"),this.collectionManifest=this.data.manifest,this.parseComponents(),this.initHistory(),window.document.location.hostname.match("localhost")&&this.config.set("dev",!0),this.data})}initStores(){return B(this,void 0,void 0,function*(){this.store$=M($),this.config$=M(T),this.store$.pipe().subscribe(t=>{}),this.config$.pipe().subscribe(t=>{})})}initHistory(){"undefined"!=typeof window&&window.history}parseComponents(){let t=[];C.copy(this.data.manifest.components).map(s=>{let e=s.tag,a=!1;this.config.get("componentsIgnorePatterns").forEach(t=>{e.match(t)&&(a=!0)}),a||t.push(s)}),this.components=t}showFlashMessage(t,s,e=2e3){document.querySelector("ema-flash-message").show(t,s,e)}static get instance(){return this[P]||(this[P]=new q(R)),this[P]}}export{q as a};