-
Notifications
You must be signed in to change notification settings - Fork 0
/
411.render-page.js.map
1 lines (1 loc) · 138 KB
/
411.render-page.js.map
1
{"version":3,"file":"411.render-page.js","mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA,KAAK;AACL,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP,KAAK;AACL;AACA,CAAC;;AAEM;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,GAAG;AACH;;AAEO;AACP;AACA;;;AC9SqC;AACW;AAC0C;AAC7B;AAChC;;AAE7B,IAAI,cAAI;AACR;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C;AAC9C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC,0GAA0G,WAAW;AACrH;AACA;AACA,kDAAkD,cAAc,4BAA4B,cAAc,cAAc,GAAG,eAAe;AAC1I;AACA;AACA;AACA,wBAAwB,wCAAY;AACpC;AACA;AACA,6BAA6B,yCAAa;AAC1C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E,kCAAkC;AAC5G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,mCAAa,KAAK,4BAAM;AAC7E;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,GAAG;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+BAA+B,8BAAQ,iDAAiD,qBAAqB;AAC7G;AACA;AACA;AACA;AACA,oBAAoB,QAAQ;AAC5B;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA,8BAA8B,oBAAoB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,MAAM;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E,kCAAkC;AAC5G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,8BAAQ,CAAC,8BAAQ,GAAG,eAAe,aAAa,sCAAsC;AACzG;AACA;AACA,KAAK;AACL;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,8BAAQ,CAAC,8BAAQ,GAAG,wBAAwB,sBAAsB;AACjH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,8BAAQ,CAAC,8BAAQ,GAAG,wBAAwB,aAAa,sCAAsC;AAC9I;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,8BAAQ,CAAC,8BAAQ,GAAG,eAAe,gCAAgC;AAC9E;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E,kCAAkC;AAC5G;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,8BAAQ,oDAAoD,sBAAsB;AAClH;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,QAAQ;AAC5B;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,gCAAS;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,6BAA6B;AAC9D;AACA;AACA,aAAa;AACb,kCAAkC,0CAA0C;AAC5E;AACA;AACA;AACA;AACA;AACA,KAAK;AACL,6BAA6B,cAAI;AACjC;AACA,sBAAsB,wBAAQ;;AAEG;AACjC;;;;;ACjzCyD;AACpB;AACJ;AACS;AACmI;AAC7H;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mFAAmF,OAAO;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,kCAAkC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,8BAA8B;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,8BAAQ,CAAC,8BAAQ,GAAG,kBAAkB,0BAA0B;AAC7F;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA,oDAAoD,2BAA2B;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA,oDAAoD,eAAe;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA,+DAA+D,gBAAgB;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,oCAAM;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gFAAgF,gDAAgD;AAChI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wFAAwF,2CAA2C;AACnI;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gEAAgE,4BAA4B;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+EAA+E;AAC/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,+BAAS;AACxB;AACA,mBAAmB,iCAAW;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,uBAAuB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,gBAAgB;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,WAAE;AACN,cAAc,WAAE,KAAK;AACrB,IAAI,WAAE,yFAAyF,KAAK;AACpG;AACA;AACA,IAAI,WAAE;AACN;AACA;AACA,IAAI,WAAE,oIAAoI,QAAQ;AAClJ,IAAI,WAAE;AACN;AACA,0EAA0E,WAAW;AACrF,IAAI,WAAE;AACN;AACA,0EAA0E,WAAW;AACrF,IAAI,WAAE;AACN,8EAA8E,uBAAuB;AACrG,IAAI,WAAE,oFAAoF,YAAY,GAAG,iBAAiB;AAC1H,IAAI,WAAE;AACN;AACA,IAAI,WAAE;AACN;AACA,IAAI,WAAE;AACN,IAAI,uBAAa,OAAO,wCAAY;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C;AAC3C,yCAAyC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,SAAS,oBAAU;AACnB;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA,iCAAiC,oBAAU;AAC3C;AACA,0DAA0D,OAAO;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,uBAAa;AAC3C;AACA;AACA,iBAAiB;AACjB;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC,WAAW,+BAAS;AACpB;AACA;AACA,eAAe,iCAAW;AAC1B;AACA;AACA,sBAAsB,uBAAa;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB;AACzB;AACA,sBAAsB,uBAAa;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,OAAO,+BAAS;AACrD,uBAAuB,iCAAW;AAClC;AACA;AACA;AACA,iBAAiB;AACjB,aAAa,IAAI;AACjB,uEAAuE,4DAA4D;AACnI,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,4CAA4C;AAC5F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,4CAA4C;AAChG;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,sDAAsB;AAChD,0BAA0B,sDAAsB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,uBAAa;AAChC;AACA,aAAa;AACb,SAAS;AACT,KAAK;AACL;AACA;AACA,wBAAwB,aAAa;AACrC;AACA;AACA,uBAAuB,yCAAa;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,oBAAoB;AACzE;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA,0BAA0B,oDAAoB;AAC9C,gCAAgC,uBAAa;AAC7C;AACA,qBAAqB;AACrB;AACA;AACA;AACA,yCAAyC,yDAAyB;AAClE;AACA;AACA;AACA;AACA;AACA,gCAAgC,uBAAa;AAC7C;AACA,qBAAqB;AACrB;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA;AACA,eAAe,iCAAW;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB,8CAA8C,yBAAyB;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC;AACxC,mDAAmD;AACnD,yCAAyC;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,uBAAa;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,kDAAkB;AAC1B;AACA;AACA,SAAS,iDAAiB;AAC1B;AACA;AACA;AACA;AACA,6CAA6C,4CAA4C;AACzF;AACA,kBAAkB,uBAAa;AAC/B;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,uBAAa;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAa;AAC/B;AACA;AACA;AACA,cAAc,uBAAa;AAC3B;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kIAAkI,yBAAyB;AAC3J,SAAS;AACT;AACA,8HAA8H,yBAAyB;AACvJ,SAAS;AACT;AACA,+GAA+G,yBAAyB;AACxI,SAAS;AACT;AACA,+HAA+H,yBAAyB;AACxJ,SAAS;AACT;AACA,0GAA0G,yBAAyB;AACnI,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAI,mBAAI;AACR,IAAI,iBAAO;;AAEX;AACA;AACA;AACA;AACA;AACA,4CAA4C,gCAAS;AACrD;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA,KAAK;AACL,4CAA4C,gCAAS;AACrD,6BAA6B,mBAAI,EAAE,iBAAO;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAa;AAC/B;AACA,aAAa;AACb;AACA;AACA;AACA,kBAAkB,wBAAQ;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,+BAAS;AACpB;AACA,eAAe,iCAAW;AAC1B;AACA;AACA,wBAAwB,kDAAkB;AAC1C;AACA;AACA,yBAAyB,iDAAiB;AAC1C;AACA;AACA,yBAAyB,oDAAoB;AAC7C;AACA;AACA;AACA;AACA;AACA,yCAAyC,yDAAyB;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT,KAAK;AACL;;AAEgF;AAChF;;;AC1sC6B;AAC7B","sources":["webpack://lubycon-home/./node_modules/idb/lib/idb.mjs","webpack://lubycon-home/./node_modules/@lubycon/logger/node_modules/@firebase/installations/dist/index.esm.js","webpack://lubycon-home/./node_modules/@lubycon/logger/node_modules/@firebase/analytics/dist/index.esm.js","webpack://lubycon-home/./node_modules/@lubycon/logger/node_modules/firebase/analytics/dist/index.esm.js"],"sourcesContent":["function toArray(arr) {\n return Array.prototype.slice.call(arr);\n}\n\nfunction promisifyRequest(request) {\n return new Promise(function(resolve, reject) {\n request.onsuccess = function() {\n resolve(request.result);\n };\n\n request.onerror = function() {\n reject(request.error);\n };\n });\n}\n\nfunction promisifyRequestCall(obj, method, args) {\n var request;\n var p = new Promise(function(resolve, reject) {\n request = obj[method].apply(obj, args);\n promisifyRequest(request).then(resolve, reject);\n });\n\n p.request = request;\n return p;\n}\n\nfunction promisifyCursorRequestCall(obj, method, args) {\n var p = promisifyRequestCall(obj, method, args);\n return p.then(function(value) {\n if (!value) return;\n return new Cursor(value, p.request);\n });\n}\n\nfunction proxyProperties(ProxyClass, targetProp, properties) {\n properties.forEach(function(prop) {\n Object.defineProperty(ProxyClass.prototype, prop, {\n get: function() {\n return this[targetProp][prop];\n },\n set: function(val) {\n this[targetProp][prop] = val;\n }\n });\n });\n}\n\nfunction proxyRequestMethods(ProxyClass, targetProp, Constructor, properties) {\n properties.forEach(function(prop) {\n if (!(prop in Constructor.prototype)) return;\n ProxyClass.prototype[prop] = function() {\n return promisifyRequestCall(this[targetProp], prop, arguments);\n };\n });\n}\n\nfunction proxyMethods(ProxyClass, targetProp, Constructor, properties) {\n properties.forEach(function(prop) {\n if (!(prop in Constructor.prototype)) return;\n ProxyClass.prototype[prop] = function() {\n return this[targetProp][prop].apply(this[targetProp], arguments);\n };\n });\n}\n\nfunction proxyCursorRequestMethods(ProxyClass, targetProp, Constructor, properties) {\n properties.forEach(function(prop) {\n if (!(prop in Constructor.prototype)) return;\n ProxyClass.prototype[prop] = function() {\n return promisifyCursorRequestCall(this[targetProp], prop, arguments);\n };\n });\n}\n\nfunction Index(index) {\n this._index = index;\n}\n\nproxyProperties(Index, '_index', [\n 'name',\n 'keyPath',\n 'multiEntry',\n 'unique'\n]);\n\nproxyRequestMethods(Index, '_index', IDBIndex, [\n 'get',\n 'getKey',\n 'getAll',\n 'getAllKeys',\n 'count'\n]);\n\nproxyCursorRequestMethods(Index, '_index', IDBIndex, [\n 'openCursor',\n 'openKeyCursor'\n]);\n\nfunction Cursor(cursor, request) {\n this._cursor = cursor;\n this._request = request;\n}\n\nproxyProperties(Cursor, '_cursor', [\n 'direction',\n 'key',\n 'primaryKey',\n 'value'\n]);\n\nproxyRequestMethods(Cursor, '_cursor', IDBCursor, [\n 'update',\n 'delete'\n]);\n\n// proxy 'next' methods\n['advance', 'continue', 'continuePrimaryKey'].forEach(function(methodName) {\n if (!(methodName in IDBCursor.prototype)) return;\n Cursor.prototype[methodName] = function() {\n var cursor = this;\n var args = arguments;\n return Promise.resolve().then(function() {\n cursor._cursor[methodName].apply(cursor._cursor, args);\n return promisifyRequest(cursor._request).then(function(value) {\n if (!value) return;\n return new Cursor(value, cursor._request);\n });\n });\n };\n});\n\nfunction ObjectStore(store) {\n this._store = store;\n}\n\nObjectStore.prototype.createIndex = function() {\n return new Index(this._store.createIndex.apply(this._store, arguments));\n};\n\nObjectStore.prototype.index = function() {\n return new Index(this._store.index.apply(this._store, arguments));\n};\n\nproxyProperties(ObjectStore, '_store', [\n 'name',\n 'keyPath',\n 'indexNames',\n 'autoIncrement'\n]);\n\nproxyRequestMethods(ObjectStore, '_store', IDBObjectStore, [\n 'put',\n 'add',\n 'delete',\n 'clear',\n 'get',\n 'getAll',\n 'getKey',\n 'getAllKeys',\n 'count'\n]);\n\nproxyCursorRequestMethods(ObjectStore, '_store', IDBObjectStore, [\n 'openCursor',\n 'openKeyCursor'\n]);\n\nproxyMethods(ObjectStore, '_store', IDBObjectStore, [\n 'deleteIndex'\n]);\n\nfunction Transaction(idbTransaction) {\n this._tx = idbTransaction;\n this.complete = new Promise(function(resolve, reject) {\n idbTransaction.oncomplete = function() {\n resolve();\n };\n idbTransaction.onerror = function() {\n reject(idbTransaction.error);\n };\n idbTransaction.onabort = function() {\n reject(idbTransaction.error);\n };\n });\n}\n\nTransaction.prototype.objectStore = function() {\n return new ObjectStore(this._tx.objectStore.apply(this._tx, arguments));\n};\n\nproxyProperties(Transaction, '_tx', [\n 'objectStoreNames',\n 'mode'\n]);\n\nproxyMethods(Transaction, '_tx', IDBTransaction, [\n 'abort'\n]);\n\nfunction UpgradeDB(db, oldVersion, transaction) {\n this._db = db;\n this.oldVersion = oldVersion;\n this.transaction = new Transaction(transaction);\n}\n\nUpgradeDB.prototype.createObjectStore = function() {\n return new ObjectStore(this._db.createObjectStore.apply(this._db, arguments));\n};\n\nproxyProperties(UpgradeDB, '_db', [\n 'name',\n 'version',\n 'objectStoreNames'\n]);\n\nproxyMethods(UpgradeDB, '_db', IDBDatabase, [\n 'deleteObjectStore',\n 'close'\n]);\n\nfunction DB(db) {\n this._db = db;\n}\n\nDB.prototype.transaction = function() {\n return new Transaction(this._db.transaction.apply(this._db, arguments));\n};\n\nproxyProperties(DB, '_db', [\n 'name',\n 'version',\n 'objectStoreNames'\n]);\n\nproxyMethods(DB, '_db', IDBDatabase, [\n 'close'\n]);\n\n// Add cursor iterators\n// TODO: remove this once browsers do the right thing with promises\n['openCursor', 'openKeyCursor'].forEach(function(funcName) {\n [ObjectStore, Index].forEach(function(Constructor) {\n // Don't create iterateKeyCursor if openKeyCursor doesn't exist.\n if (!(funcName in Constructor.prototype)) return;\n\n Constructor.prototype[funcName.replace('open', 'iterate')] = function() {\n var args = toArray(arguments);\n var callback = args[args.length - 1];\n var nativeObject = this._store || this._index;\n var request = nativeObject[funcName].apply(nativeObject, args.slice(0, -1));\n request.onsuccess = function() {\n callback(request.result);\n };\n };\n });\n});\n\n// polyfill getAll\n[Index, ObjectStore].forEach(function(Constructor) {\n if (Constructor.prototype.getAll) return;\n Constructor.prototype.getAll = function(query, count) {\n var instance = this;\n var items = [];\n\n return new Promise(function(resolve) {\n instance.iterateCursor(query, function(cursor) {\n if (!cursor) {\n resolve(items);\n return;\n }\n items.push(cursor.value);\n\n if (count !== undefined && items.length == count) {\n resolve(items);\n return;\n }\n cursor.continue();\n });\n });\n };\n});\n\nexport function openDb(name, version, upgradeCallback) {\n var p = promisifyRequestCall(indexedDB, 'open', [name, version]);\n var request = p.request;\n\n if (request) {\n request.onupgradeneeded = function(event) {\n if (upgradeCallback) {\n upgradeCallback(new UpgradeDB(request.result, event.oldVersion, request.transaction));\n }\n };\n }\n\n return p.then(function(db) {\n return new DB(db);\n });\n}\n\nexport function deleteDb(name) {\n return promisifyRequestCall(indexedDB, 'deleteDatabase', [name]);\n}\n","import firebase from '@firebase/app';\nimport { Component } from '@firebase/component';\nimport { __awaiter, __generator, __spreadArray, __read, __values, __assign } from 'tslib';\nimport { ErrorFactory, FirebaseError } from '@firebase/util';\nimport { openDb } from 'idb';\n\nvar name = \"@firebase/installations\";\nvar version = \"0.4.32\";\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar PENDING_TIMEOUT_MS = 10000;\r\nvar PACKAGE_VERSION = \"w:\" + version;\r\nvar INTERNAL_AUTH_VERSION = 'FIS_v2';\r\nvar INSTALLATIONS_API_URL = 'https://firebaseinstallations.googleapis.com/v1';\r\nvar TOKEN_EXPIRATION_BUFFER = 60 * 60 * 1000; // One hour\r\nvar SERVICE = 'installations';\r\nvar SERVICE_NAME = 'Installations';\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar _a;\r\nvar ERROR_DESCRIPTION_MAP = (_a = {},\r\n _a[\"missing-app-config-values\" /* MISSING_APP_CONFIG_VALUES */] = 'Missing App configuration value: \"{$valueName}\"',\r\n _a[\"not-registered\" /* NOT_REGISTERED */] = 'Firebase Installation is not registered.',\r\n _a[\"installation-not-found\" /* INSTALLATION_NOT_FOUND */] = 'Firebase Installation not found.',\r\n _a[\"request-failed\" /* REQUEST_FAILED */] = '{$requestName} request failed with error \"{$serverCode} {$serverStatus}: {$serverMessage}\"',\r\n _a[\"app-offline\" /* APP_OFFLINE */] = 'Could not process request. Application offline.',\r\n _a[\"delete-pending-registration\" /* DELETE_PENDING_REGISTRATION */] = \"Can't delete installation while there is a pending registration request.\",\r\n _a);\r\nvar ERROR_FACTORY = new ErrorFactory(SERVICE, SERVICE_NAME, ERROR_DESCRIPTION_MAP);\r\n/** Returns true if error is a FirebaseError that is based on an error from the server. */\r\nfunction isServerError(error) {\r\n return (error instanceof FirebaseError &&\r\n error.code.includes(\"request-failed\" /* REQUEST_FAILED */));\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction getInstallationsEndpoint(_a) {\r\n var projectId = _a.projectId;\r\n return INSTALLATIONS_API_URL + \"/projects/\" + projectId + \"/installations\";\r\n}\r\nfunction extractAuthTokenInfoFromResponse(response) {\r\n return {\r\n token: response.token,\r\n requestStatus: 2 /* COMPLETED */,\r\n expiresIn: getExpiresInFromResponseExpiresIn(response.expiresIn),\r\n creationTime: Date.now()\r\n };\r\n}\r\nfunction getErrorFromResponse(requestName, response) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var responseJson, errorData;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, response.json()];\r\n case 1:\r\n responseJson = _a.sent();\r\n errorData = responseJson.error;\r\n return [2 /*return*/, ERROR_FACTORY.create(\"request-failed\" /* REQUEST_FAILED */, {\r\n requestName: requestName,\r\n serverCode: errorData.code,\r\n serverMessage: errorData.message,\r\n serverStatus: errorData.status\r\n })];\r\n }\r\n });\r\n });\r\n}\r\nfunction getHeaders(_a) {\r\n var apiKey = _a.apiKey;\r\n return new Headers({\r\n 'Content-Type': 'application/json',\r\n Accept: 'application/json',\r\n 'x-goog-api-key': apiKey\r\n });\r\n}\r\nfunction getHeadersWithAuth(appConfig, _a) {\r\n var refreshToken = _a.refreshToken;\r\n var headers = getHeaders(appConfig);\r\n headers.append('Authorization', getAuthorizationHeader(refreshToken));\r\n return headers;\r\n}\r\n/**\r\n * Calls the passed in fetch wrapper and returns the response.\r\n * If the returned response has a status of 5xx, re-runs the function once and\r\n * returns the response.\r\n */\r\nfunction retryIfServerError(fn) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var result;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, fn()];\r\n case 1:\r\n result = _a.sent();\r\n if (result.status >= 500 && result.status < 600) {\r\n // Internal Server Error. Retry request.\r\n return [2 /*return*/, fn()];\r\n }\r\n return [2 /*return*/, result];\r\n }\r\n });\r\n });\r\n}\r\nfunction getExpiresInFromResponseExpiresIn(responseExpiresIn) {\r\n // This works because the server will never respond with fractions of a second.\r\n return Number(responseExpiresIn.replace('s', '000'));\r\n}\r\nfunction getAuthorizationHeader(refreshToken) {\r\n return INTERNAL_AUTH_VERSION + \" \" + refreshToken;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction createInstallationRequest(appConfig, _a) {\r\n var fid = _a.fid;\r\n return __awaiter(this, void 0, void 0, function () {\r\n var endpoint, headers, body, request, response, responseValue, registeredInstallationEntry;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n endpoint = getInstallationsEndpoint(appConfig);\r\n headers = getHeaders(appConfig);\r\n body = {\r\n fid: fid,\r\n authVersion: INTERNAL_AUTH_VERSION,\r\n appId: appConfig.appId,\r\n sdkVersion: PACKAGE_VERSION\r\n };\r\n request = {\r\n method: 'POST',\r\n headers: headers,\r\n body: JSON.stringify(body)\r\n };\r\n return [4 /*yield*/, retryIfServerError(function () { return fetch(endpoint, request); })];\r\n case 1:\r\n response = _b.sent();\r\n if (!response.ok) return [3 /*break*/, 3];\r\n return [4 /*yield*/, response.json()];\r\n case 2:\r\n responseValue = _b.sent();\r\n registeredInstallationEntry = {\r\n fid: responseValue.fid || fid,\r\n registrationStatus: 2 /* COMPLETED */,\r\n refreshToken: responseValue.refreshToken,\r\n authToken: extractAuthTokenInfoFromResponse(responseValue.authToken)\r\n };\r\n return [2 /*return*/, registeredInstallationEntry];\r\n case 3: return [4 /*yield*/, getErrorFromResponse('Create Installation', response)];\r\n case 4: throw _b.sent();\r\n }\r\n });\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2020 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/** Returns a promise that resolves after given time passes. */\r\nfunction sleep(ms) {\r\n return new Promise(function (resolve) {\r\n setTimeout(resolve, ms);\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction bufferToBase64UrlSafe(array) {\r\n var b64 = btoa(String.fromCharCode.apply(String, __spreadArray([], __read(array))));\r\n return b64.replace(/\\+/g, '-').replace(/\\//g, '_');\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar VALID_FID_PATTERN = /^[cdef][\\w-]{21}$/;\r\nvar INVALID_FID = '';\r\n/**\r\n * Generates a new FID using random values from Web Crypto API.\r\n * Returns an empty string if FID generation fails for any reason.\r\n */\r\nfunction generateFid() {\r\n try {\r\n // A valid FID has exactly 22 base64 characters, which is 132 bits, or 16.5\r\n // bytes. our implementation generates a 17 byte array instead.\r\n var fidByteArray = new Uint8Array(17);\r\n var crypto_1 = self.crypto || self.msCrypto;\r\n crypto_1.getRandomValues(fidByteArray);\r\n // Replace the first 4 random bits with the constant FID header of 0b0111.\r\n fidByteArray[0] = 112 + (fidByteArray[0] % 16);\r\n var fid = encode(fidByteArray);\r\n return VALID_FID_PATTERN.test(fid) ? fid : INVALID_FID;\r\n }\r\n catch (_a) {\r\n // FID generation errored\r\n return INVALID_FID;\r\n }\r\n}\r\n/** Converts a FID Uint8Array to a base64 string representation. */\r\nfunction encode(fidByteArray) {\r\n var b64String = bufferToBase64UrlSafe(fidByteArray);\r\n // Remove the 23rd character that was added because of the extra 4 bits at the\r\n // end of our 17 byte array, and the '=' padding.\r\n return b64String.substr(0, 22);\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/** Returns a string key that can be used to identify the app. */\r\nfunction getKey(appConfig) {\r\n return appConfig.appName + \"!\" + appConfig.appId;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar fidChangeCallbacks = new Map();\r\n/**\r\n * Calls the onIdChange callbacks with the new FID value, and broadcasts the\r\n * change to other tabs.\r\n */\r\nfunction fidChanged(appConfig, fid) {\r\n var key = getKey(appConfig);\r\n callFidChangeCallbacks(key, fid);\r\n broadcastFidChange(key, fid);\r\n}\r\nfunction addCallback(appConfig, callback) {\r\n // Open the broadcast channel if it's not already open,\r\n // to be able to listen to change events from other tabs.\r\n getBroadcastChannel();\r\n var key = getKey(appConfig);\r\n var callbackSet = fidChangeCallbacks.get(key);\r\n if (!callbackSet) {\r\n callbackSet = new Set();\r\n fidChangeCallbacks.set(key, callbackSet);\r\n }\r\n callbackSet.add(callback);\r\n}\r\nfunction removeCallback(appConfig, callback) {\r\n var key = getKey(appConfig);\r\n var callbackSet = fidChangeCallbacks.get(key);\r\n if (!callbackSet) {\r\n return;\r\n }\r\n callbackSet.delete(callback);\r\n if (callbackSet.size === 0) {\r\n fidChangeCallbacks.delete(key);\r\n }\r\n // Close broadcast channel if there are no more callbacks.\r\n closeBroadcastChannel();\r\n}\r\nfunction callFidChangeCallbacks(key, fid) {\r\n var e_1, _a;\r\n var callbacks = fidChangeCallbacks.get(key);\r\n if (!callbacks) {\r\n return;\r\n }\r\n try {\r\n for (var callbacks_1 = __values(callbacks), callbacks_1_1 = callbacks_1.next(); !callbacks_1_1.done; callbacks_1_1 = callbacks_1.next()) {\r\n var callback = callbacks_1_1.value;\r\n callback(fid);\r\n }\r\n }\r\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\r\n finally {\r\n try {\r\n if (callbacks_1_1 && !callbacks_1_1.done && (_a = callbacks_1.return)) _a.call(callbacks_1);\r\n }\r\n finally { if (e_1) throw e_1.error; }\r\n }\r\n}\r\nfunction broadcastFidChange(key, fid) {\r\n var channel = getBroadcastChannel();\r\n if (channel) {\r\n channel.postMessage({ key: key, fid: fid });\r\n }\r\n closeBroadcastChannel();\r\n}\r\nvar broadcastChannel = null;\r\n/** Opens and returns a BroadcastChannel if it is supported by the browser. */\r\nfunction getBroadcastChannel() {\r\n if (!broadcastChannel && 'BroadcastChannel' in self) {\r\n broadcastChannel = new BroadcastChannel('[Firebase] FID Change');\r\n broadcastChannel.onmessage = function (e) {\r\n callFidChangeCallbacks(e.data.key, e.data.fid);\r\n };\r\n }\r\n return broadcastChannel;\r\n}\r\nfunction closeBroadcastChannel() {\r\n if (fidChangeCallbacks.size === 0 && broadcastChannel) {\r\n broadcastChannel.close();\r\n broadcastChannel = null;\r\n }\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar DATABASE_NAME = 'firebase-installations-database';\r\nvar DATABASE_VERSION = 1;\r\nvar OBJECT_STORE_NAME = 'firebase-installations-store';\r\nvar dbPromise = null;\r\nfunction getDbPromise() {\r\n if (!dbPromise) {\r\n dbPromise = openDb(DATABASE_NAME, DATABASE_VERSION, function (upgradeDB) {\r\n // We don't use 'break' in this switch statement, the fall-through\r\n // behavior is what we want, because if there are multiple versions between\r\n // the old version and the current version, we want ALL the migrations\r\n // that correspond to those versions to run, not only the last one.\r\n // eslint-disable-next-line default-case\r\n switch (upgradeDB.oldVersion) {\r\n case 0:\r\n upgradeDB.createObjectStore(OBJECT_STORE_NAME);\r\n }\r\n });\r\n }\r\n return dbPromise;\r\n}\r\n/** Assigns or overwrites the record for the given key with the given value. */\r\nfunction set(appConfig, value) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var key, db, tx, objectStore, oldValue;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n key = getKey(appConfig);\r\n return [4 /*yield*/, getDbPromise()];\r\n case 1:\r\n db = _a.sent();\r\n tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\r\n objectStore = tx.objectStore(OBJECT_STORE_NAME);\r\n return [4 /*yield*/, objectStore.get(key)];\r\n case 2:\r\n oldValue = _a.sent();\r\n return [4 /*yield*/, objectStore.put(value, key)];\r\n case 3:\r\n _a.sent();\r\n return [4 /*yield*/, tx.complete];\r\n case 4:\r\n _a.sent();\r\n if (!oldValue || oldValue.fid !== value.fid) {\r\n fidChanged(appConfig, value.fid);\r\n }\r\n return [2 /*return*/, value];\r\n }\r\n });\r\n });\r\n}\r\n/** Removes record(s) from the objectStore that match the given key. */\r\nfunction remove(appConfig) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var key, db, tx;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n key = getKey(appConfig);\r\n return [4 /*yield*/, getDbPromise()];\r\n case 1:\r\n db = _a.sent();\r\n tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\r\n return [4 /*yield*/, tx.objectStore(OBJECT_STORE_NAME).delete(key)];\r\n case 2:\r\n _a.sent();\r\n return [4 /*yield*/, tx.complete];\r\n case 3:\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Atomically updates a record with the result of updateFn, which gets\r\n * called with the current value. If newValue is undefined, the record is\r\n * deleted instead.\r\n * @return Updated value\r\n */\r\nfunction update(appConfig, updateFn) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var key, db, tx, store, oldValue, newValue;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n key = getKey(appConfig);\r\n return [4 /*yield*/, getDbPromise()];\r\n case 1:\r\n db = _a.sent();\r\n tx = db.transaction(OBJECT_STORE_NAME, 'readwrite');\r\n store = tx.objectStore(OBJECT_STORE_NAME);\r\n return [4 /*yield*/, store.get(key)];\r\n case 2:\r\n oldValue = _a.sent();\r\n newValue = updateFn(oldValue);\r\n if (!(newValue === undefined)) return [3 /*break*/, 4];\r\n return [4 /*yield*/, store.delete(key)];\r\n case 3:\r\n _a.sent();\r\n return [3 /*break*/, 6];\r\n case 4: return [4 /*yield*/, store.put(newValue, key)];\r\n case 5:\r\n _a.sent();\r\n _a.label = 6;\r\n case 6: return [4 /*yield*/, tx.complete];\r\n case 7:\r\n _a.sent();\r\n if (newValue && (!oldValue || oldValue.fid !== newValue.fid)) {\r\n fidChanged(appConfig, newValue.fid);\r\n }\r\n return [2 /*return*/, newValue];\r\n }\r\n });\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Updates and returns the InstallationEntry from the database.\r\n * Also triggers a registration request if it is necessary and possible.\r\n */\r\nfunction getInstallationEntry(appConfig) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var registrationPromise, installationEntry;\r\n var _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, update(appConfig, function (oldEntry) {\r\n var installationEntry = updateOrCreateInstallationEntry(oldEntry);\r\n var entryWithPromise = triggerRegistrationIfNecessary(appConfig, installationEntry);\r\n registrationPromise = entryWithPromise.registrationPromise;\r\n return entryWithPromise.installationEntry;\r\n })];\r\n case 1:\r\n installationEntry = _b.sent();\r\n if (!(installationEntry.fid === INVALID_FID)) return [3 /*break*/, 3];\r\n _a = {};\r\n return [4 /*yield*/, registrationPromise];\r\n case 2: \r\n // FID generation failed. Waiting for the FID from the server.\r\n return [2 /*return*/, (_a.installationEntry = _b.sent(), _a)];\r\n case 3: return [2 /*return*/, {\r\n installationEntry: installationEntry,\r\n registrationPromise: registrationPromise\r\n }];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Creates a new Installation Entry if one does not exist.\r\n * Also clears timed out pending requests.\r\n */\r\nfunction updateOrCreateInstallationEntry(oldEntry) {\r\n var entry = oldEntry || {\r\n fid: generateFid(),\r\n registrationStatus: 0 /* NOT_STARTED */\r\n };\r\n return clearTimedOutRequest(entry);\r\n}\r\n/**\r\n * If the Firebase Installation is not registered yet, this will trigger the\r\n * registration and return an InProgressInstallationEntry.\r\n *\r\n * If registrationPromise does not exist, the installationEntry is guaranteed\r\n * to be registered.\r\n */\r\nfunction triggerRegistrationIfNecessary(appConfig, installationEntry) {\r\n if (installationEntry.registrationStatus === 0 /* NOT_STARTED */) {\r\n if (!navigator.onLine) {\r\n // Registration required but app is offline.\r\n var registrationPromiseWithError = Promise.reject(ERROR_FACTORY.create(\"app-offline\" /* APP_OFFLINE */));\r\n return {\r\n installationEntry: installationEntry,\r\n registrationPromise: registrationPromiseWithError\r\n };\r\n }\r\n // Try registering. Change status to IN_PROGRESS.\r\n var inProgressEntry = {\r\n fid: installationEntry.fid,\r\n registrationStatus: 1 /* IN_PROGRESS */,\r\n registrationTime: Date.now()\r\n };\r\n var registrationPromise = registerInstallation(appConfig, inProgressEntry);\r\n return { installationEntry: inProgressEntry, registrationPromise: registrationPromise };\r\n }\r\n else if (installationEntry.registrationStatus === 1 /* IN_PROGRESS */) {\r\n return {\r\n installationEntry: installationEntry,\r\n registrationPromise: waitUntilFidRegistration(appConfig)\r\n };\r\n }\r\n else {\r\n return { installationEntry: installationEntry };\r\n }\r\n}\r\n/** This will be executed only once for each new Firebase Installation. */\r\nfunction registerInstallation(appConfig, installationEntry) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var registeredInstallationEntry, e_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 2, , 7]);\r\n return [4 /*yield*/, createInstallationRequest(appConfig, installationEntry)];\r\n case 1:\r\n registeredInstallationEntry = _a.sent();\r\n return [2 /*return*/, set(appConfig, registeredInstallationEntry)];\r\n case 2:\r\n e_1 = _a.sent();\r\n if (!(isServerError(e_1) && e_1.customData.serverCode === 409)) return [3 /*break*/, 4];\r\n // Server returned a \"FID can not be used\" error.\r\n // Generate a new ID next time.\r\n return [4 /*yield*/, remove(appConfig)];\r\n case 3:\r\n // Server returned a \"FID can not be used\" error.\r\n // Generate a new ID next time.\r\n _a.sent();\r\n return [3 /*break*/, 6];\r\n case 4: \r\n // Registration failed. Set FID as not registered.\r\n return [4 /*yield*/, set(appConfig, {\r\n fid: installationEntry.fid,\r\n registrationStatus: 0 /* NOT_STARTED */\r\n })];\r\n case 5:\r\n // Registration failed. Set FID as not registered.\r\n _a.sent();\r\n _a.label = 6;\r\n case 6: throw e_1;\r\n case 7: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/** Call if FID registration is pending in another request. */\r\nfunction waitUntilFidRegistration(appConfig) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var entry, _a, installationEntry, registrationPromise;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, updateInstallationRequest(appConfig)];\r\n case 1:\r\n entry = _b.sent();\r\n _b.label = 2;\r\n case 2:\r\n if (!(entry.registrationStatus === 1 /* IN_PROGRESS */)) return [3 /*break*/, 5];\r\n // createInstallation request still in progress.\r\n return [4 /*yield*/, sleep(100)];\r\n case 3:\r\n // createInstallation request still in progress.\r\n _b.sent();\r\n return [4 /*yield*/, updateInstallationRequest(appConfig)];\r\n case 4:\r\n entry = _b.sent();\r\n return [3 /*break*/, 2];\r\n case 5:\r\n if (!(entry.registrationStatus === 0 /* NOT_STARTED */)) return [3 /*break*/, 7];\r\n return [4 /*yield*/, getInstallationEntry(appConfig)];\r\n case 6:\r\n _a = _b.sent(), installationEntry = _a.installationEntry, registrationPromise = _a.registrationPromise;\r\n if (registrationPromise) {\r\n return [2 /*return*/, registrationPromise];\r\n }\r\n else {\r\n // if there is no registrationPromise, entry is registered.\r\n return [2 /*return*/, installationEntry];\r\n }\r\n case 7: return [2 /*return*/, entry];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Called only if there is a CreateInstallation request in progress.\r\n *\r\n * Updates the InstallationEntry in the DB based on the status of the\r\n * CreateInstallation request.\r\n *\r\n * Returns the updated InstallationEntry.\r\n */\r\nfunction updateInstallationRequest(appConfig) {\r\n return update(appConfig, function (oldEntry) {\r\n if (!oldEntry) {\r\n throw ERROR_FACTORY.create(\"installation-not-found\" /* INSTALLATION_NOT_FOUND */);\r\n }\r\n return clearTimedOutRequest(oldEntry);\r\n });\r\n}\r\nfunction clearTimedOutRequest(entry) {\r\n if (hasInstallationRequestTimedOut(entry)) {\r\n return {\r\n fid: entry.fid,\r\n registrationStatus: 0 /* NOT_STARTED */\r\n };\r\n }\r\n return entry;\r\n}\r\nfunction hasInstallationRequestTimedOut(installationEntry) {\r\n return (installationEntry.registrationStatus === 1 /* IN_PROGRESS */ &&\r\n installationEntry.registrationTime + PENDING_TIMEOUT_MS < Date.now());\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction generateAuthTokenRequest(_a, installationEntry) {\r\n var appConfig = _a.appConfig, platformLoggerProvider = _a.platformLoggerProvider;\r\n return __awaiter(this, void 0, void 0, function () {\r\n var endpoint, headers, platformLogger, body, request, response, responseValue, completedAuthToken;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n endpoint = getGenerateAuthTokenEndpoint(appConfig, installationEntry);\r\n headers = getHeadersWithAuth(appConfig, installationEntry);\r\n platformLogger = platformLoggerProvider.getImmediate({\r\n optional: true\r\n });\r\n if (platformLogger) {\r\n headers.append('x-firebase-client', platformLogger.getPlatformInfoString());\r\n }\r\n body = {\r\n installation: {\r\n sdkVersion: PACKAGE_VERSION\r\n }\r\n };\r\n request = {\r\n method: 'POST',\r\n headers: headers,\r\n body: JSON.stringify(body)\r\n };\r\n return [4 /*yield*/, retryIfServerError(function () { return fetch(endpoint, request); })];\r\n case 1:\r\n response = _b.sent();\r\n if (!response.ok) return [3 /*break*/, 3];\r\n return [4 /*yield*/, response.json()];\r\n case 2:\r\n responseValue = _b.sent();\r\n completedAuthToken = extractAuthTokenInfoFromResponse(responseValue);\r\n return [2 /*return*/, completedAuthToken];\r\n case 3: return [4 /*yield*/, getErrorFromResponse('Generate Auth Token', response)];\r\n case 4: throw _b.sent();\r\n }\r\n });\r\n });\r\n}\r\nfunction getGenerateAuthTokenEndpoint(appConfig, _a) {\r\n var fid = _a.fid;\r\n return getInstallationsEndpoint(appConfig) + \"/\" + fid + \"/authTokens:generate\";\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Returns a valid authentication token for the installation. Generates a new\r\n * token if one doesn't exist, is expired or about to expire.\r\n *\r\n * Should only be called if the Firebase Installation is registered.\r\n */\r\nfunction refreshAuthToken(dependencies, forceRefresh) {\r\n if (forceRefresh === void 0) { forceRefresh = false; }\r\n return __awaiter(this, void 0, void 0, function () {\r\n var tokenPromise, entry, authToken, _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, update(dependencies.appConfig, function (oldEntry) {\r\n if (!isEntryRegistered(oldEntry)) {\r\n throw ERROR_FACTORY.create(\"not-registered\" /* NOT_REGISTERED */);\r\n }\r\n var oldAuthToken = oldEntry.authToken;\r\n if (!forceRefresh && isAuthTokenValid(oldAuthToken)) {\r\n // There is a valid token in the DB.\r\n return oldEntry;\r\n }\r\n else if (oldAuthToken.requestStatus === 1 /* IN_PROGRESS */) {\r\n // There already is a token request in progress.\r\n tokenPromise = waitUntilAuthTokenRequest(dependencies, forceRefresh);\r\n return oldEntry;\r\n }\r\n else {\r\n // No token or token expired.\r\n if (!navigator.onLine) {\r\n throw ERROR_FACTORY.create(\"app-offline\" /* APP_OFFLINE */);\r\n }\r\n var inProgressEntry = makeAuthTokenRequestInProgressEntry(oldEntry);\r\n tokenPromise = fetchAuthTokenFromServer(dependencies, inProgressEntry);\r\n return inProgressEntry;\r\n }\r\n })];\r\n case 1:\r\n entry = _b.sent();\r\n if (!tokenPromise) return [3 /*break*/, 3];\r\n return [4 /*yield*/, tokenPromise];\r\n case 2:\r\n _a = _b.sent();\r\n return [3 /*break*/, 4];\r\n case 3:\r\n _a = entry.authToken;\r\n _b.label = 4;\r\n case 4:\r\n authToken = _a;\r\n return [2 /*return*/, authToken];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Call only if FID is registered and Auth Token request is in progress.\r\n *\r\n * Waits until the current pending request finishes. If the request times out,\r\n * tries once in this thread as well.\r\n */\r\nfunction waitUntilAuthTokenRequest(dependencies, forceRefresh) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var entry, authToken;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, updateAuthTokenRequest(dependencies.appConfig)];\r\n case 1:\r\n entry = _a.sent();\r\n _a.label = 2;\r\n case 2:\r\n if (!(entry.authToken.requestStatus === 1 /* IN_PROGRESS */)) return [3 /*break*/, 5];\r\n // generateAuthToken still in progress.\r\n return [4 /*yield*/, sleep(100)];\r\n case 3:\r\n // generateAuthToken still in progress.\r\n _a.sent();\r\n return [4 /*yield*/, updateAuthTokenRequest(dependencies.appConfig)];\r\n case 4:\r\n entry = _a.sent();\r\n return [3 /*break*/, 2];\r\n case 5:\r\n authToken = entry.authToken;\r\n if (authToken.requestStatus === 0 /* NOT_STARTED */) {\r\n // The request timed out or failed in a different call. Try again.\r\n return [2 /*return*/, refreshAuthToken(dependencies, forceRefresh)];\r\n }\r\n else {\r\n return [2 /*return*/, authToken];\r\n }\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Called only if there is a GenerateAuthToken request in progress.\r\n *\r\n * Updates the InstallationEntry in the DB based on the status of the\r\n * GenerateAuthToken request.\r\n *\r\n * Returns the updated InstallationEntry.\r\n */\r\nfunction updateAuthTokenRequest(appConfig) {\r\n return update(appConfig, function (oldEntry) {\r\n if (!isEntryRegistered(oldEntry)) {\r\n throw ERROR_FACTORY.create(\"not-registered\" /* NOT_REGISTERED */);\r\n }\r\n var oldAuthToken = oldEntry.authToken;\r\n if (hasAuthTokenRequestTimedOut(oldAuthToken)) {\r\n return __assign(__assign({}, oldEntry), { authToken: { requestStatus: 0 /* NOT_STARTED */ } });\r\n }\r\n return oldEntry;\r\n });\r\n}\r\nfunction fetchAuthTokenFromServer(dependencies, installationEntry) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var authToken, updatedInstallationEntry, e_1, updatedInstallationEntry;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 3, , 8]);\r\n return [4 /*yield*/, generateAuthTokenRequest(dependencies, installationEntry)];\r\n case 1:\r\n authToken = _a.sent();\r\n updatedInstallationEntry = __assign(__assign({}, installationEntry), { authToken: authToken });\r\n return [4 /*yield*/, set(dependencies.appConfig, updatedInstallationEntry)];\r\n case 2:\r\n _a.sent();\r\n return [2 /*return*/, authToken];\r\n case 3:\r\n e_1 = _a.sent();\r\n if (!(isServerError(e_1) &&\r\n (e_1.customData.serverCode === 401 || e_1.customData.serverCode === 404))) return [3 /*break*/, 5];\r\n // Server returned a \"FID not found\" or a \"Invalid authentication\" error.\r\n // Generate a new ID next time.\r\n return [4 /*yield*/, remove(dependencies.appConfig)];\r\n case 4:\r\n // Server returned a \"FID not found\" or a \"Invalid authentication\" error.\r\n // Generate a new ID next time.\r\n _a.sent();\r\n return [3 /*break*/, 7];\r\n case 5:\r\n updatedInstallationEntry = __assign(__assign({}, installationEntry), { authToken: { requestStatus: 0 /* NOT_STARTED */ } });\r\n return [4 /*yield*/, set(dependencies.appConfig, updatedInstallationEntry)];\r\n case 6:\r\n _a.sent();\r\n _a.label = 7;\r\n case 7: throw e_1;\r\n case 8: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\nfunction isEntryRegistered(installationEntry) {\r\n return (installationEntry !== undefined &&\r\n installationEntry.registrationStatus === 2 /* COMPLETED */);\r\n}\r\nfunction isAuthTokenValid(authToken) {\r\n return (authToken.requestStatus === 2 /* COMPLETED */ &&\r\n !isAuthTokenExpired(authToken));\r\n}\r\nfunction isAuthTokenExpired(authToken) {\r\n var now = Date.now();\r\n return (now < authToken.creationTime ||\r\n authToken.creationTime + authToken.expiresIn < now + TOKEN_EXPIRATION_BUFFER);\r\n}\r\n/** Returns an updated InstallationEntry with an InProgressAuthToken. */\r\nfunction makeAuthTokenRequestInProgressEntry(oldEntry) {\r\n var inProgressAuthToken = {\r\n requestStatus: 1 /* IN_PROGRESS */,\r\n requestTime: Date.now()\r\n };\r\n return __assign(__assign({}, oldEntry), { authToken: inProgressAuthToken });\r\n}\r\nfunction hasAuthTokenRequestTimedOut(authToken) {\r\n return (authToken.requestStatus === 1 /* IN_PROGRESS */ &&\r\n authToken.requestTime + PENDING_TIMEOUT_MS < Date.now());\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction getId(dependencies) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var _a, installationEntry, registrationPromise;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0: return [4 /*yield*/, getInstallationEntry(dependencies.appConfig)];\r\n case 1:\r\n _a = _b.sent(), installationEntry = _a.installationEntry, registrationPromise = _a.registrationPromise;\r\n if (registrationPromise) {\r\n registrationPromise.catch(console.error);\r\n }\r\n else {\r\n // If the installation is already registered, update the authentication\r\n // token if needed.\r\n refreshAuthToken(dependencies).catch(console.error);\r\n }\r\n return [2 /*return*/, installationEntry.fid];\r\n }\r\n });\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction getToken(dependencies, forceRefresh) {\r\n if (forceRefresh === void 0) { forceRefresh = false; }\r\n return __awaiter(this, void 0, void 0, function () {\r\n var authToken;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, completeInstallationRegistration(dependencies.appConfig)];\r\n case 1:\r\n _a.sent();\r\n return [4 /*yield*/, refreshAuthToken(dependencies, forceRefresh)];\r\n case 2:\r\n authToken = _a.sent();\r\n return [2 /*return*/, authToken.token];\r\n }\r\n });\r\n });\r\n}\r\nfunction completeInstallationRegistration(appConfig) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var registrationPromise;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, getInstallationEntry(appConfig)];\r\n case 1:\r\n registrationPromise = (_a.sent()).registrationPromise;\r\n if (!registrationPromise) return [3 /*break*/, 3];\r\n // A createInstallation request is in progress. Wait until it finishes.\r\n return [4 /*yield*/, registrationPromise];\r\n case 2:\r\n // A createInstallation request is in progress. Wait until it finishes.\r\n _a.sent();\r\n _a.label = 3;\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction deleteInstallationRequest(appConfig, installationEntry) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var endpoint, headers, request, response;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n endpoint = getDeleteEndpoint(appConfig, installationEntry);\r\n headers = getHeadersWithAuth(appConfig, installationEntry);\r\n request = {\r\n method: 'DELETE',\r\n headers: headers\r\n };\r\n return [4 /*yield*/, retryIfServerError(function () { return fetch(endpoint, request); })];\r\n case 1:\r\n response = _a.sent();\r\n if (!!response.ok) return [3 /*break*/, 3];\r\n return [4 /*yield*/, getErrorFromResponse('Delete Installation', response)];\r\n case 2: throw _a.sent();\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\nfunction getDeleteEndpoint(appConfig, _a) {\r\n var fid = _a.fid;\r\n return getInstallationsEndpoint(appConfig) + \"/\" + fid;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction deleteInstallation(dependencies) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var appConfig, entry;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n appConfig = dependencies.appConfig;\r\n return [4 /*yield*/, update(appConfig, function (oldEntry) {\r\n if (oldEntry && oldEntry.registrationStatus === 0 /* NOT_STARTED */) {\r\n // Delete the unregistered entry without sending a deleteInstallation request.\r\n return undefined;\r\n }\r\n return oldEntry;\r\n })];\r\n case 1:\r\n entry = _a.sent();\r\n if (!entry) return [3 /*break*/, 6];\r\n if (!(entry.registrationStatus === 1 /* IN_PROGRESS */)) return [3 /*break*/, 2];\r\n // Can't delete while trying to register.\r\n throw ERROR_FACTORY.create(\"delete-pending-registration\" /* DELETE_PENDING_REGISTRATION */);\r\n case 2:\r\n if (!(entry.registrationStatus === 2 /* COMPLETED */)) return [3 /*break*/, 6];\r\n if (!!navigator.onLine) return [3 /*break*/, 3];\r\n throw ERROR_FACTORY.create(\"app-offline\" /* APP_OFFLINE */);\r\n case 3: return [4 /*yield*/, deleteInstallationRequest(appConfig, entry)];\r\n case 4:\r\n _a.sent();\r\n return [4 /*yield*/, remove(appConfig)];\r\n case 5:\r\n _a.sent();\r\n _a.label = 6;\r\n case 6: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Sets a new callback that will get called when Installation ID changes.\r\n * Returns an unsubscribe function that will remove the callback when called.\r\n */\r\nfunction onIdChange(_a, callback) {\r\n var appConfig = _a.appConfig;\r\n addCallback(appConfig, callback);\r\n return function () {\r\n removeCallback(appConfig, callback);\r\n };\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction extractAppConfig(app) {\r\n var e_1, _a;\r\n if (!app || !app.options) {\r\n throw getMissingValueError('App Configuration');\r\n }\r\n if (!app.name) {\r\n throw getMissingValueError('App Name');\r\n }\r\n // Required app config keys\r\n var configKeys = [\r\n 'projectId',\r\n 'apiKey',\r\n 'appId'\r\n ];\r\n try {\r\n for (var configKeys_1 = __values(configKeys), configKeys_1_1 = configKeys_1.next(); !configKeys_1_1.done; configKeys_1_1 = configKeys_1.next()) {\r\n var keyName = configKeys_1_1.value;\r\n if (!app.options[keyName]) {\r\n throw getMissingValueError(keyName);\r\n }\r\n }\r\n }\r\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\r\n finally {\r\n try {\r\n if (configKeys_1_1 && !configKeys_1_1.done && (_a = configKeys_1.return)) _a.call(configKeys_1);\r\n }\r\n finally { if (e_1) throw e_1.error; }\r\n }\r\n return {\r\n appName: app.name,\r\n projectId: app.options.projectId,\r\n apiKey: app.options.apiKey,\r\n appId: app.options.appId\r\n };\r\n}\r\nfunction getMissingValueError(valueName) {\r\n return ERROR_FACTORY.create(\"missing-app-config-values\" /* MISSING_APP_CONFIG_VALUES */, {\r\n valueName: valueName\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction registerInstallations(instance) {\r\n var installationsName = 'installations';\r\n instance.INTERNAL.registerComponent(new Component(installationsName, function (container) {\r\n var app = container.getProvider('app').getImmediate();\r\n // Throws if app isn't configured properly.\r\n var appConfig = extractAppConfig(app);\r\n var platformLoggerProvider = container.getProvider('platform-logger');\r\n var dependencies = {\r\n appConfig: appConfig,\r\n platformLoggerProvider: platformLoggerProvider\r\n };\r\n var installations = {\r\n app: app,\r\n getId: function () { return getId(dependencies); },\r\n getToken: function (forceRefresh) {\r\n return getToken(dependencies, forceRefresh);\r\n },\r\n delete: function () { return deleteInstallation(dependencies); },\r\n onIdChange: function (callback) {\r\n return onIdChange(dependencies, callback);\r\n }\r\n };\r\n return installations;\r\n }, \"PUBLIC\" /* PUBLIC */));\r\n instance.registerVersion(name, version);\r\n}\r\nregisterInstallations(firebase);\n\nexport { registerInstallations };\n//# sourceMappingURL=index.esm.js.map\n","import { __awaiter, __generator, __assign } from 'tslib';\nimport firebase from '@firebase/app';\nimport '@firebase/installations';\nimport { Logger } from '@firebase/logger';\nimport { ErrorFactory, calculateBackoffMillis, FirebaseError, validateIndexedDBOpenable, isIndexedDBAvailable, isBrowserExtension, areCookiesEnabled } from '@firebase/util';\nimport { Component } from '@firebase/component';\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n// Key to attach FID to in gtag params.\r\nvar GA_FID_KEY = 'firebase_id';\r\nvar ORIGIN_KEY = 'origin';\r\nvar FETCH_TIMEOUT_MILLIS = 60 * 1000;\r\nvar DYNAMIC_CONFIG_URL = 'https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig';\r\nvar GTAG_URL = 'https://www.googletagmanager.com/gtag/js';\r\nvar GtagCommand;\r\n(function (GtagCommand) {\r\n GtagCommand[\"EVENT\"] = \"event\";\r\n GtagCommand[\"SET\"] = \"set\";\r\n GtagCommand[\"CONFIG\"] = \"config\";\r\n})(GtagCommand || (GtagCommand = {}));\r\n/**\r\n * Officially recommended event names for gtag.js\r\n * Any other string is also allowed.\r\n *\r\n * @public\r\n */\r\nvar EventName;\r\n(function (EventName) {\r\n EventName[\"ADD_SHIPPING_INFO\"] = \"add_shipping_info\";\r\n EventName[\"ADD_PAYMENT_INFO\"] = \"add_payment_info\";\r\n EventName[\"ADD_TO_CART\"] = \"add_to_cart\";\r\n EventName[\"ADD_TO_WISHLIST\"] = \"add_to_wishlist\";\r\n EventName[\"BEGIN_CHECKOUT\"] = \"begin_checkout\";\r\n /**\r\n * @deprecated\r\n * This event name is deprecated and is unsupported in updated\r\n * Enhanced Ecommerce reports.\r\n */\r\n EventName[\"CHECKOUT_PROGRESS\"] = \"checkout_progress\";\r\n EventName[\"EXCEPTION\"] = \"exception\";\r\n EventName[\"GENERATE_LEAD\"] = \"generate_lead\";\r\n EventName[\"LOGIN\"] = \"login\";\r\n EventName[\"PAGE_VIEW\"] = \"page_view\";\r\n EventName[\"PURCHASE\"] = \"purchase\";\r\n EventName[\"REFUND\"] = \"refund\";\r\n EventName[\"REMOVE_FROM_CART\"] = \"remove_from_cart\";\r\n EventName[\"SCREEN_VIEW\"] = \"screen_view\";\r\n EventName[\"SEARCH\"] = \"search\";\r\n EventName[\"SELECT_CONTENT\"] = \"select_content\";\r\n EventName[\"SELECT_ITEM\"] = \"select_item\";\r\n EventName[\"SELECT_PROMOTION\"] = \"select_promotion\";\r\n /** @deprecated */\r\n EventName[\"SET_CHECKOUT_OPTION\"] = \"set_checkout_option\";\r\n EventName[\"SHARE\"] = \"share\";\r\n EventName[\"SIGN_UP\"] = \"sign_up\";\r\n EventName[\"TIMING_COMPLETE\"] = \"timing_complete\";\r\n EventName[\"VIEW_CART\"] = \"view_cart\";\r\n EventName[\"VIEW_ITEM\"] = \"view_item\";\r\n EventName[\"VIEW_ITEM_LIST\"] = \"view_item_list\";\r\n EventName[\"VIEW_PROMOTION\"] = \"view_promotion\";\r\n EventName[\"VIEW_SEARCH_RESULTS\"] = \"view_search_results\";\r\n})(EventName || (EventName = {}));\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Logs an analytics event through the Firebase SDK.\r\n *\r\n * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event\r\n * @param eventName Google Analytics event name, choose from standard list or use a custom string.\r\n * @param eventParams Analytics event parameters.\r\n */\r\nfunction logEvent(gtagFunction, initializationPromise, eventName, eventParams, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var measurementId, params;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!(options && options.global)) return [3 /*break*/, 1];\r\n gtagFunction(GtagCommand.EVENT, eventName, eventParams);\r\n return [2 /*return*/];\r\n case 1: return [4 /*yield*/, initializationPromise];\r\n case 2:\r\n measurementId = _a.sent();\r\n params = __assign(__assign({}, eventParams), { 'send_to': measurementId });\r\n gtagFunction(GtagCommand.EVENT, eventName, params);\r\n _a.label = 3;\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Set screen_name parameter for this Google Analytics ID.\r\n *\r\n * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event\r\n * @param screenName Screen name string to set.\r\n */\r\nfunction setCurrentScreen(gtagFunction, initializationPromise, screenName, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var measurementId;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!(options && options.global)) return [3 /*break*/, 1];\r\n gtagFunction(GtagCommand.SET, { 'screen_name': screenName });\r\n return [2 /*return*/, Promise.resolve()];\r\n case 1: return [4 /*yield*/, initializationPromise];\r\n case 2:\r\n measurementId = _a.sent();\r\n gtagFunction(GtagCommand.CONFIG, measurementId, {\r\n update: true,\r\n 'screen_name': screenName\r\n });\r\n _a.label = 3;\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Set user_id parameter for this Google Analytics ID.\r\n *\r\n * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event\r\n * @param id User ID string to set\r\n */\r\nfunction setUserId(gtagFunction, initializationPromise, id, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var measurementId;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!(options && options.global)) return [3 /*break*/, 1];\r\n gtagFunction(GtagCommand.SET, { 'user_id': id });\r\n return [2 /*return*/, Promise.resolve()];\r\n case 1: return [4 /*yield*/, initializationPromise];\r\n case 2:\r\n measurementId = _a.sent();\r\n gtagFunction(GtagCommand.CONFIG, measurementId, {\r\n update: true,\r\n 'user_id': id\r\n });\r\n _a.label = 3;\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Set all other user properties other than user_id and screen_name.\r\n *\r\n * @param gtagFunction Wrapped gtag function that waits for fid to be set before sending an event\r\n * @param properties Map of user properties to set\r\n */\r\nfunction setUserProperties(gtagFunction, initializationPromise, properties, options) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var flatProperties, _i, _a, key, measurementId;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n if (!(options && options.global)) return [3 /*break*/, 1];\r\n flatProperties = {};\r\n for (_i = 0, _a = Object.keys(properties); _i < _a.length; _i++) {\r\n key = _a[_i];\r\n // use dot notation for merge behavior in gtag.js\r\n flatProperties[\"user_properties.\" + key] = properties[key];\r\n }\r\n gtagFunction(GtagCommand.SET, flatProperties);\r\n return [2 /*return*/, Promise.resolve()];\r\n case 1: return [4 /*yield*/, initializationPromise];\r\n case 2:\r\n measurementId = _b.sent();\r\n gtagFunction(GtagCommand.CONFIG, measurementId, {\r\n update: true,\r\n 'user_properties': properties\r\n });\r\n _b.label = 3;\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Set whether collection is enabled for this ID.\r\n *\r\n * @param enabled If true, collection is enabled for this ID.\r\n */\r\nfunction setAnalyticsCollectionEnabled(initializationPromise, enabled) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var measurementId;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, initializationPromise];\r\n case 1:\r\n measurementId = _a.sent();\r\n window[\"ga-disable-\" + measurementId] = !enabled;\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar logger = new Logger('@firebase/analytics');\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Inserts gtag script tag into the page to asynchronously download gtag.\r\n * @param dataLayerName Name of datalayer (most often the default, \"_dataLayer\").\r\n */\r\nfunction insertScriptTag(dataLayerName, measurementId) {\r\n var script = document.createElement('script');\r\n script.src = GTAG_URL + \"?l=\" + dataLayerName + \"&id=\" + measurementId;\r\n script.async = true;\r\n document.head.appendChild(script);\r\n}\r\n/**\r\n * Get reference to, or create, global datalayer.\r\n * @param dataLayerName Name of datalayer (most often the default, \"_dataLayer\").\r\n */\r\nfunction getOrCreateDataLayer(dataLayerName) {\r\n // Check for existing dataLayer and create if needed.\r\n var dataLayer = [];\r\n if (Array.isArray(window[dataLayerName])) {\r\n dataLayer = window[dataLayerName];\r\n }\r\n else {\r\n window[dataLayerName] = dataLayer;\r\n }\r\n return dataLayer;\r\n}\r\n/**\r\n * Wrapped gtag logic when gtag is called with 'config' command.\r\n *\r\n * @param gtagCore Basic gtag function that just appends to dataLayer.\r\n * @param initializationPromisesMap Map of appIds to their initialization promises.\r\n * @param dynamicConfigPromisesList Array of dynamic config fetch promises.\r\n * @param measurementIdToAppId Map of GA measurementIDs to corresponding Firebase appId.\r\n * @param measurementId GA Measurement ID to set config for.\r\n * @param gtagParams Gtag config params to set.\r\n */\r\nfunction gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId, measurementId, gtagParams) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var correspondingAppId, dynamicConfigResults, foundConfig, e_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n correspondingAppId = measurementIdToAppId[measurementId];\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 7, , 8]);\r\n if (!correspondingAppId) return [3 /*break*/, 3];\r\n return [4 /*yield*/, initializationPromisesMap[correspondingAppId]];\r\n case 2:\r\n _a.sent();\r\n return [3 /*break*/, 6];\r\n case 3: return [4 /*yield*/, Promise.all(dynamicConfigPromisesList)];\r\n case 4:\r\n dynamicConfigResults = _a.sent();\r\n foundConfig = dynamicConfigResults.find(function (config) { return config.measurementId === measurementId; });\r\n if (!foundConfig) return [3 /*break*/, 6];\r\n return [4 /*yield*/, initializationPromisesMap[foundConfig.appId]];\r\n case 5:\r\n _a.sent();\r\n _a.label = 6;\r\n case 6: return [3 /*break*/, 8];\r\n case 7:\r\n e_1 = _a.sent();\r\n logger.error(e_1);\r\n return [3 /*break*/, 8];\r\n case 8:\r\n gtagCore(GtagCommand.CONFIG, measurementId, gtagParams);\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Wrapped gtag logic when gtag is called with 'event' command.\r\n *\r\n * @param gtagCore Basic gtag function that just appends to dataLayer.\r\n * @param initializationPromisesMap Map of appIds to their initialization promises.\r\n * @param dynamicConfigPromisesList Array of dynamic config fetch promises.\r\n * @param measurementId GA Measurement ID to log event to.\r\n * @param gtagParams Params to log with this event.\r\n */\r\nfunction gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementId, gtagParams) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var initializationPromisesToWaitFor, gaSendToList, dynamicConfigResults, _loop_1, _i, gaSendToList_1, sendToId, state_1, e_2;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 4, , 5]);\r\n initializationPromisesToWaitFor = [];\r\n if (!(gtagParams && gtagParams['send_to'])) return [3 /*break*/, 2];\r\n gaSendToList = gtagParams['send_to'];\r\n // Make it an array if is isn't, so it can be dealt with the same way.\r\n if (!Array.isArray(gaSendToList)) {\r\n gaSendToList = [gaSendToList];\r\n }\r\n return [4 /*yield*/, Promise.all(dynamicConfigPromisesList)];\r\n case 1:\r\n dynamicConfigResults = _a.sent();\r\n _loop_1 = function (sendToId) {\r\n // Any fetched dynamic measurement ID that matches this 'send_to' ID\r\n var foundConfig = dynamicConfigResults.find(function (config) { return config.measurementId === sendToId; });\r\n var initializationPromise = foundConfig && initializationPromisesMap[foundConfig.appId];\r\n if (initializationPromise) {\r\n initializationPromisesToWaitFor.push(initializationPromise);\r\n }\r\n else {\r\n // Found an item in 'send_to' that is not associated\r\n // directly with an FID, possibly a group. Empty this array,\r\n // exit the loop early, and let it get populated below.\r\n initializationPromisesToWaitFor = [];\r\n return \"break\";\r\n }\r\n };\r\n for (_i = 0, gaSendToList_1 = gaSendToList; _i < gaSendToList_1.length; _i++) {\r\n sendToId = gaSendToList_1[_i];\r\n state_1 = _loop_1(sendToId);\r\n if (state_1 === \"break\")\r\n break;\r\n }\r\n _a.label = 2;\r\n case 2:\r\n // This will be unpopulated if there was no 'send_to' field , or\r\n // if not all entries in the 'send_to' field could be mapped to\r\n // a FID. In these cases, wait on all pending initialization promises.\r\n if (initializationPromisesToWaitFor.length === 0) {\r\n initializationPromisesToWaitFor = Object.values(initializationPromisesMap);\r\n }\r\n // Run core gtag function with args after all relevant initialization\r\n // promises have been resolved.\r\n return [4 /*yield*/, Promise.all(initializationPromisesToWaitFor)];\r\n case 3:\r\n // Run core gtag function with args after all relevant initialization\r\n // promises have been resolved.\r\n _a.sent();\r\n // Workaround for http://b/141370449 - third argument cannot be undefined.\r\n gtagCore(GtagCommand.EVENT, measurementId, gtagParams || {});\r\n return [3 /*break*/, 5];\r\n case 4:\r\n e_2 = _a.sent();\r\n logger.error(e_2);\r\n return [3 /*break*/, 5];\r\n case 5: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Wraps a standard gtag function with extra code to wait for completion of\r\n * relevant initialization promises before sending requests.\r\n *\r\n * @param gtagCore Basic gtag function that just appends to dataLayer.\r\n * @param initializationPromisesMap Map of appIds to their initialization promises.\r\n * @param dynamicConfigPromisesList Array of dynamic config fetch promises.\r\n * @param measurementIdToAppId Map of GA measurementIDs to corresponding Firebase appId.\r\n */\r\nfunction wrapGtag(gtagCore, \r\n/**\r\n * Allows wrapped gtag calls to wait on whichever intialization promises are required,\r\n * depending on the contents of the gtag params' `send_to` field, if any.\r\n */\r\ninitializationPromisesMap, \r\n/**\r\n * Wrapped gtag calls sometimes require all dynamic config fetches to have returned\r\n * before determining what initialization promises (which include FIDs) to wait for.\r\n */\r\ndynamicConfigPromisesList, \r\n/**\r\n * Wrapped gtag config calls can narrow down which initialization promise (with FID)\r\n * to wait for if the measurementId is already fetched, by getting the corresponding appId,\r\n * which is the key for the initialization promises map.\r\n */\r\nmeasurementIdToAppId) {\r\n /**\r\n * Wrapper around gtag that ensures FID is sent with gtag calls.\r\n * @param command Gtag command type.\r\n * @param idOrNameOrParams Measurement ID if command is EVENT/CONFIG, params if command is SET.\r\n * @param gtagParams Params if event is EVENT/CONFIG.\r\n */\r\n function gtagWrapper(command, idOrNameOrParams, gtagParams) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var e_3;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 6, , 7]);\r\n if (!(command === GtagCommand.EVENT)) return [3 /*break*/, 2];\r\n // If EVENT, second arg must be measurementId.\r\n return [4 /*yield*/, gtagOnEvent(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, idOrNameOrParams, gtagParams)];\r\n case 1:\r\n // If EVENT, second arg must be measurementId.\r\n _a.sent();\r\n return [3 /*break*/, 5];\r\n case 2:\r\n if (!(command === GtagCommand.CONFIG)) return [3 /*break*/, 4];\r\n // If CONFIG, second arg must be measurementId.\r\n return [4 /*yield*/, gtagOnConfig(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId, idOrNameOrParams, gtagParams)];\r\n case 3:\r\n // If CONFIG, second arg must be measurementId.\r\n _a.sent();\r\n return [3 /*break*/, 5];\r\n case 4:\r\n // If SET, second arg must be params.\r\n gtagCore(GtagCommand.SET, idOrNameOrParams);\r\n _a.label = 5;\r\n case 5: return [3 /*break*/, 7];\r\n case 6:\r\n e_3 = _a.sent();\r\n logger.error(e_3);\r\n return [3 /*break*/, 7];\r\n case 7: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n }\r\n return gtagWrapper;\r\n}\r\n/**\r\n * Creates global gtag function or wraps existing one if found.\r\n * This wrapped function attaches Firebase instance ID (FID) to gtag 'config' and\r\n * 'event' calls that belong to the GAID associated with this Firebase instance.\r\n *\r\n * @param initializationPromisesMap Map of appIds to their initialization promises.\r\n * @param dynamicConfigPromisesList Array of dynamic config fetch promises.\r\n * @param measurementIdToAppId Map of GA measurementIDs to corresponding Firebase appId.\r\n * @param dataLayerName Name of global GA datalayer array.\r\n * @param gtagFunctionName Name of global gtag function (\"gtag\" if not user-specified).\r\n */\r\nfunction wrapOrCreateGtag(initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId, dataLayerName, gtagFunctionName) {\r\n // Create a basic core gtag function\r\n var gtagCore = function () {\r\n var _args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n _args[_i] = arguments[_i];\r\n }\r\n // Must push IArguments object, not an array.\r\n window[dataLayerName].push(arguments);\r\n };\r\n // Replace it with existing one if found\r\n if (window[gtagFunctionName] &&\r\n typeof window[gtagFunctionName] === 'function') {\r\n // @ts-ignore\r\n gtagCore = window[gtagFunctionName];\r\n }\r\n window[gtagFunctionName] = wrapGtag(gtagCore, initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId);\r\n return {\r\n gtagCore: gtagCore,\r\n wrappedGtag: window[gtagFunctionName]\r\n };\r\n}\r\n/**\r\n * Returns first script tag in DOM matching our gtag url pattern.\r\n */\r\nfunction findGtagScriptOnPage() {\r\n var scriptTags = window.document.getElementsByTagName('script');\r\n for (var _i = 0, _a = Object.values(scriptTags); _i < _a.length; _i++) {\r\n var tag = _a[_i];\r\n if (tag.src && tag.src.includes(GTAG_URL)) {\r\n return tag;\r\n }\r\n }\r\n return null;\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nvar _a;\r\nvar ERRORS = (_a = {},\r\n _a[\"already-exists\" /* ALREADY_EXISTS */] = 'A Firebase Analytics instance with the appId {$id} ' +\r\n ' already exists. ' +\r\n 'Only one Firebase Analytics instance can be created for each appId.',\r\n _a[\"already-initialized\" /* ALREADY_INITIALIZED */] = 'Firebase Analytics has already been initialized.' +\r\n 'settings() must be called before initializing any Analytics instance' +\r\n 'or it will have no effect.',\r\n _a[\"interop-component-reg-failed\" /* INTEROP_COMPONENT_REG_FAILED */] = 'Firebase Analytics Interop Component failed to instantiate: {$reason}',\r\n _a[\"invalid-analytics-context\" /* INVALID_ANALYTICS_CONTEXT */] = 'Firebase Analytics is not supported in this environment. ' +\r\n 'Wrap initialization of analytics in analytics.isSupported() ' +\r\n 'to prevent initialization in unsupported environments. Details: {$errorInfo}',\r\n _a[\"indexeddb-unavailable\" /* INDEXEDDB_UNAVAILABLE */] = 'IndexedDB unavailable or restricted in this environment. ' +\r\n 'Wrap initialization of analytics in analytics.isSupported() ' +\r\n 'to prevent initialization in unsupported environments. Details: {$errorInfo}',\r\n _a[\"fetch-throttle\" /* FETCH_THROTTLE */] = 'The config fetch request timed out while in an exponential backoff state.' +\r\n ' Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',\r\n _a[\"config-fetch-failed\" /* CONFIG_FETCH_FAILED */] = 'Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}',\r\n _a[\"no-api-key\" /* NO_API_KEY */] = 'The \"apiKey\" field is empty in the local Firebase config. Firebase Analytics requires this field to' +\r\n 'contain a valid API key.',\r\n _a[\"no-app-id\" /* NO_APP_ID */] = 'The \"appId\" field is empty in the local Firebase config. Firebase Analytics requires this field to' +\r\n 'contain a valid app ID.',\r\n _a);\r\nvar ERROR_FACTORY = new ErrorFactory('analytics', 'Analytics', ERRORS);\n\n/**\r\n * @license\r\n * Copyright 2020 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Backoff factor for 503 errors, which we want to be conservative about\r\n * to avoid overloading servers. Each retry interval will be\r\n * BASE_INTERVAL_MILLIS * LONG_RETRY_FACTOR ^ retryCount, so the second one\r\n * will be ~30 seconds (with fuzzing).\r\n */\r\nvar LONG_RETRY_FACTOR = 30;\r\n/**\r\n * Base wait interval to multiplied by backoffFactor^backoffCount.\r\n */\r\nvar BASE_INTERVAL_MILLIS = 1000;\r\n/**\r\n * Stubbable retry data storage class.\r\n */\r\nvar RetryData = /** @class */ (function () {\r\n function RetryData(throttleMetadata, intervalMillis) {\r\n if (throttleMetadata === void 0) { throttleMetadata = {}; }\r\n if (intervalMillis === void 0) { intervalMillis = BASE_INTERVAL_MILLIS; }\r\n this.throttleMetadata = throttleMetadata;\r\n this.intervalMillis = intervalMillis;\r\n }\r\n RetryData.prototype.getThrottleMetadata = function (appId) {\r\n return this.throttleMetadata[appId];\r\n };\r\n RetryData.prototype.setThrottleMetadata = function (appId, metadata) {\r\n this.throttleMetadata[appId] = metadata;\r\n };\r\n RetryData.prototype.deleteThrottleMetadata = function (appId) {\r\n delete this.throttleMetadata[appId];\r\n };\r\n return RetryData;\r\n}());\r\nvar defaultRetryData = new RetryData();\r\n/**\r\n * Set GET request headers.\r\n * @param apiKey App API key.\r\n */\r\nfunction getHeaders(apiKey) {\r\n return new Headers({\r\n Accept: 'application/json',\r\n 'x-goog-api-key': apiKey\r\n });\r\n}\r\n/**\r\n * Fetches dynamic config from backend.\r\n * @param app Firebase app to fetch config for.\r\n */\r\nfunction fetchDynamicConfig(appFields) {\r\n var _a;\r\n return __awaiter(this, void 0, void 0, function () {\r\n var appId, apiKey, request, appUrl, response, errorMessage, jsonResponse;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n appId = appFields.appId, apiKey = appFields.apiKey;\r\n request = {\r\n method: 'GET',\r\n headers: getHeaders(apiKey)\r\n };\r\n appUrl = DYNAMIC_CONFIG_URL.replace('{app-id}', appId);\r\n return [4 /*yield*/, fetch(appUrl, request)];\r\n case 1:\r\n response = _b.sent();\r\n if (!(response.status !== 200 && response.status !== 304)) return [3 /*break*/, 6];\r\n errorMessage = '';\r\n _b.label = 2;\r\n case 2:\r\n _b.trys.push([2, 4, , 5]);\r\n return [4 /*yield*/, response.json()];\r\n case 3:\r\n jsonResponse = (_b.sent());\r\n if ((_a = jsonResponse.error) === null || _a === void 0 ? void 0 : _a.message) {\r\n errorMessage = jsonResponse.error.message;\r\n }\r\n return [3 /*break*/, 5];\r\n case 4:\r\n _b.sent();\r\n return [3 /*break*/, 5];\r\n case 5: throw ERROR_FACTORY.create(\"config-fetch-failed\" /* CONFIG_FETCH_FAILED */, {\r\n httpStatus: response.status,\r\n responseMessage: errorMessage\r\n });\r\n case 6: return [2 /*return*/, response.json()];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Fetches dynamic config from backend, retrying if failed.\r\n * @param app Firebase app to fetch config for.\r\n */\r\nfunction fetchDynamicConfigWithRetry(app, \r\n// retryData and timeoutMillis are parameterized to allow passing a different value for testing.\r\nretryData, timeoutMillis) {\r\n if (retryData === void 0) { retryData = defaultRetryData; }\r\n return __awaiter(this, void 0, void 0, function () {\r\n var _a, appId, apiKey, measurementId, throttleMetadata, signal;\r\n var _this = this;\r\n return __generator(this, function (_b) {\r\n _a = app.options, appId = _a.appId, apiKey = _a.apiKey, measurementId = _a.measurementId;\r\n if (!appId) {\r\n throw ERROR_FACTORY.create(\"no-app-id\" /* NO_APP_ID */);\r\n }\r\n if (!apiKey) {\r\n if (measurementId) {\r\n return [2 /*return*/, {\r\n measurementId: measurementId,\r\n appId: appId\r\n }];\r\n }\r\n throw ERROR_FACTORY.create(\"no-api-key\" /* NO_API_KEY */);\r\n }\r\n throttleMetadata = retryData.getThrottleMetadata(appId) || {\r\n backoffCount: 0,\r\n throttleEndTimeMillis: Date.now()\r\n };\r\n signal = new AnalyticsAbortSignal();\r\n setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n // Note a very low delay, eg < 10ms, can elapse before listeners are initialized.\r\n signal.abort();\r\n return [2 /*return*/];\r\n });\r\n }); }, timeoutMillis !== undefined ? timeoutMillis : FETCH_TIMEOUT_MILLIS);\r\n return [2 /*return*/, attemptFetchDynamicConfigWithRetry({ appId: appId, apiKey: apiKey, measurementId: measurementId }, throttleMetadata, signal, retryData)];\r\n });\r\n });\r\n}\r\n/**\r\n * Runs one retry attempt.\r\n * @param appFields Necessary app config fields.\r\n * @param throttleMetadata Ongoing metadata to determine throttling times.\r\n * @param signal Abort signal.\r\n */\r\nfunction attemptFetchDynamicConfigWithRetry(appFields, _a, signal, retryData // for testing\r\n) {\r\n var throttleEndTimeMillis = _a.throttleEndTimeMillis, backoffCount = _a.backoffCount;\r\n if (retryData === void 0) { retryData = defaultRetryData; }\r\n return __awaiter(this, void 0, void 0, function () {\r\n var appId, measurementId, e_1, response, e_2, backoffMillis, throttleMetadata;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n appId = appFields.appId, measurementId = appFields.measurementId;\r\n _b.label = 1;\r\n case 1:\r\n _b.trys.push([1, 3, , 4]);\r\n return [4 /*yield*/, setAbortableTimeout(signal, throttleEndTimeMillis)];\r\n case 2:\r\n _b.sent();\r\n return [3 /*break*/, 4];\r\n case 3:\r\n e_1 = _b.sent();\r\n if (measurementId) {\r\n logger.warn(\"Timed out fetching this Firebase app's measurement ID from the server.\" +\r\n (\" Falling back to the measurement ID \" + measurementId) +\r\n (\" provided in the \\\"measurementId\\\" field in the local Firebase config. [\" + e_1.message + \"]\"));\r\n return [2 /*return*/, { appId: appId, measurementId: measurementId }];\r\n }\r\n throw e_1;\r\n case 4:\r\n _b.trys.push([4, 6, , 7]);\r\n return [4 /*yield*/, fetchDynamicConfig(appFields)];\r\n case 5:\r\n response = _b.sent();\r\n // Note the SDK only clears throttle state if response is success or non-retriable.\r\n retryData.deleteThrottleMetadata(appId);\r\n return [2 /*return*/, response];\r\n case 6:\r\n e_2 = _b.sent();\r\n if (!isRetriableError(e_2)) {\r\n retryData.deleteThrottleMetadata(appId);\r\n if (measurementId) {\r\n logger.warn(\"Failed to fetch this Firebase app's measurement ID from the server.\" +\r\n (\" Falling back to the measurement ID \" + measurementId) +\r\n (\" provided in the \\\"measurementId\\\" field in the local Firebase config. [\" + e_2.message + \"]\"));\r\n return [2 /*return*/, { appId: appId, measurementId: measurementId }];\r\n }\r\n else {\r\n throw e_2;\r\n }\r\n }\r\n backoffMillis = Number(e_2.customData.httpStatus) === 503\r\n ? calculateBackoffMillis(backoffCount, retryData.intervalMillis, LONG_RETRY_FACTOR)\r\n : calculateBackoffMillis(backoffCount, retryData.intervalMillis);\r\n throttleMetadata = {\r\n throttleEndTimeMillis: Date.now() + backoffMillis,\r\n backoffCount: backoffCount + 1\r\n };\r\n // Persists state.\r\n retryData.setThrottleMetadata(appId, throttleMetadata);\r\n logger.debug(\"Calling attemptFetch again in \" + backoffMillis + \" millis\");\r\n return [2 /*return*/, attemptFetchDynamicConfigWithRetry(appFields, throttleMetadata, signal, retryData)];\r\n case 7: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Supports waiting on a backoff by:\r\n *\r\n * <ul>\r\n * <li>Promisifying setTimeout, so we can set a timeout in our Promise chain</li>\r\n * <li>Listening on a signal bus for abort events, just like the Fetch API</li>\r\n * <li>Failing in the same way the Fetch API fails, so timing out a live request and a throttled\r\n * request appear the same.</li>\r\n * </ul>\r\n *\r\n * <p>Visible for testing.\r\n */\r\nfunction setAbortableTimeout(signal, throttleEndTimeMillis) {\r\n return new Promise(function (resolve, reject) {\r\n // Derives backoff from given end time, normalizing negative numbers to zero.\r\n var backoffMillis = Math.max(throttleEndTimeMillis - Date.now(), 0);\r\n var timeout = setTimeout(resolve, backoffMillis);\r\n // Adds listener, rather than sets onabort, because signal is a shared object.\r\n signal.addEventListener(function () {\r\n clearTimeout(timeout);\r\n // If the request completes before this timeout, the rejection has no effect.\r\n reject(ERROR_FACTORY.create(\"fetch-throttle\" /* FETCH_THROTTLE */, {\r\n throttleEndTimeMillis: throttleEndTimeMillis\r\n }));\r\n });\r\n });\r\n}\r\n/**\r\n * Returns true if the {@link Error} indicates a fetch request may succeed later.\r\n */\r\nfunction isRetriableError(e) {\r\n if (!(e instanceof FirebaseError) || !e.customData) {\r\n return false;\r\n }\r\n // Uses string index defined by ErrorData, which FirebaseError implements.\r\n var httpStatus = Number(e.customData['httpStatus']);\r\n return (httpStatus === 429 ||\r\n httpStatus === 500 ||\r\n httpStatus === 503 ||\r\n httpStatus === 504);\r\n}\r\n/**\r\n * Shims a minimal AbortSignal (copied from Remote Config).\r\n *\r\n * <p>AbortController's AbortSignal conveniently decouples fetch timeout logic from other aspects\r\n * of networking, such as retries. Firebase doesn't use AbortController enough to justify a\r\n * polyfill recommendation, like we do with the Fetch API, but this minimal shim can easily be\r\n * swapped out if/when we do.\r\n */\r\nvar AnalyticsAbortSignal = /** @class */ (function () {\r\n function AnalyticsAbortSignal() {\r\n this.listeners = [];\r\n }\r\n AnalyticsAbortSignal.prototype.addEventListener = function (listener) {\r\n this.listeners.push(listener);\r\n };\r\n AnalyticsAbortSignal.prototype.abort = function () {\r\n this.listeners.forEach(function (listener) { return listener(); });\r\n };\r\n return AnalyticsAbortSignal;\r\n}());\n\n/**\r\n * @license\r\n * Copyright 2020 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\nfunction validateIndexedDB() {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var e_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (!!isIndexedDBAvailable()) return [3 /*break*/, 1];\r\n logger.warn(ERROR_FACTORY.create(\"indexeddb-unavailable\" /* INDEXEDDB_UNAVAILABLE */, {\r\n errorInfo: 'IndexedDB is not available in this environment.'\r\n }).message);\r\n return [2 /*return*/, false];\r\n case 1:\r\n _a.trys.push([1, 3, , 4]);\r\n return [4 /*yield*/, validateIndexedDBOpenable()];\r\n case 2:\r\n _a.sent();\r\n return [3 /*break*/, 4];\r\n case 3:\r\n e_1 = _a.sent();\r\n logger.warn(ERROR_FACTORY.create(\"indexeddb-unavailable\" /* INDEXEDDB_UNAVAILABLE */, {\r\n errorInfo: e_1\r\n }).message);\r\n return [2 /*return*/, false];\r\n case 4: return [2 /*return*/, true];\r\n }\r\n });\r\n });\r\n}\r\n/**\r\n * Initialize the analytics instance in gtag.js by calling config command with fid.\r\n *\r\n * NOTE: We combine analytics initialization and setting fid together because we want fid to be\r\n * part of the `page_view` event that's sent during the initialization\r\n * @param app Firebase app\r\n * @param gtagCore The gtag function that's not wrapped.\r\n * @param dynamicConfigPromisesList Array of all dynamic config promises.\r\n * @param measurementIdToAppId Maps measurementID to appID.\r\n * @param installations FirebaseInstallations instance.\r\n *\r\n * @returns Measurement ID.\r\n */\r\nfunction initializeIds(app, dynamicConfigPromisesList, measurementIdToAppId, installations, gtagCore, dataLayerName) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var dynamicConfigPromise, fidPromise, _a, dynamicConfig, fid, configProperties;\r\n var _b;\r\n return __generator(this, function (_c) {\r\n switch (_c.label) {\r\n case 0:\r\n dynamicConfigPromise = fetchDynamicConfigWithRetry(app);\r\n // Once fetched, map measurementIds to appId, for ease of lookup in wrapped gtag function.\r\n dynamicConfigPromise\r\n .then(function (config) {\r\n measurementIdToAppId[config.measurementId] = config.appId;\r\n if (app.options.measurementId &&\r\n config.measurementId !== app.options.measurementId) {\r\n logger.warn(\"The measurement ID in the local Firebase config (\" + app.options.measurementId + \")\" +\r\n (\" does not match the measurement ID fetched from the server (\" + config.measurementId + \").\") +\r\n \" To ensure analytics events are always sent to the correct Analytics property,\" +\r\n \" update the\" +\r\n \" measurement ID field in the local config or remove it from the local config.\");\r\n }\r\n })\r\n .catch(function (e) { return logger.error(e); });\r\n // Add to list to track state of all dynamic config promises.\r\n dynamicConfigPromisesList.push(dynamicConfigPromise);\r\n fidPromise = validateIndexedDB().then(function (envIsValid) {\r\n if (envIsValid) {\r\n return installations.getId();\r\n }\r\n else {\r\n return undefined;\r\n }\r\n });\r\n return [4 /*yield*/, Promise.all([\r\n dynamicConfigPromise,\r\n fidPromise\r\n ])];\r\n case 1:\r\n _a = _c.sent(), dynamicConfig = _a[0], fid = _a[1];\r\n // Detect if user has already put the gtag <script> tag on this page.\r\n if (!findGtagScriptOnPage()) {\r\n insertScriptTag(dataLayerName, dynamicConfig.measurementId);\r\n }\r\n // This command initializes gtag.js and only needs to be called once for the entire web app,\r\n // but since it is idempotent, we can call it multiple times.\r\n // We keep it together with other initialization logic for better code structure.\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n gtagCore('js', new Date());\r\n configProperties = (_b = {},\r\n // guard against developers accidentally setting properties with prefix `firebase_`\r\n _b[ORIGIN_KEY] = 'firebase',\r\n _b.update = true,\r\n _b);\r\n if (fid != null) {\r\n configProperties[GA_FID_KEY] = fid;\r\n }\r\n // It should be the first config command called on this GA-ID\r\n // Initialize this GA-ID and set FID on it using the gtag config API.\r\n // Note: This will trigger a page_view event unless 'send_page_view' is set to false in\r\n // `configProperties`.\r\n gtagCore(GtagCommand.CONFIG, dynamicConfig.measurementId, configProperties);\r\n return [2 /*return*/, dynamicConfig.measurementId];\r\n }\r\n });\r\n });\r\n}\n\n/**\r\n * @license\r\n * Copyright 2019 Google LLC\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n/**\r\n * Maps appId to full initialization promise. Wrapped gtag calls must wait on\r\n * all or some of these, depending on the call's `send_to` param and the status\r\n * of the dynamic config fetches (see below).\r\n */\r\nvar initializationPromisesMap = {};\r\n/**\r\n * List of dynamic config fetch promises. In certain cases, wrapped gtag calls\r\n * wait on all these to be complete in order to determine if it can selectively\r\n * wait for only certain initialization (FID) promises or if it must wait for all.\r\n */\r\nvar dynamicConfigPromisesList = [];\r\n/**\r\n * Maps fetched measurementIds to appId. Populated when the app's dynamic config\r\n * fetch completes. If already populated, gtag config calls can use this to\r\n * selectively wait for only this app's initialization promise (FID) instead of all\r\n * initialization promises.\r\n */\r\nvar measurementIdToAppId = {};\r\n/**\r\n * Name for window global data layer array used by GA: defaults to 'dataLayer'.\r\n */\r\nvar dataLayerName = 'dataLayer';\r\n/**\r\n * Name for window global gtag function used by GA: defaults to 'gtag'.\r\n */\r\nvar gtagName = 'gtag';\r\n/**\r\n * Reproduction of standard gtag function or reference to existing\r\n * gtag function on window object.\r\n */\r\nvar gtagCoreFunction;\r\n/**\r\n * Wrapper around gtag function that ensures FID is sent with all\r\n * relevant event and config calls.\r\n */\r\nvar wrappedGtagFunction;\r\n/**\r\n * Flag to ensure page initialization steps (creation or wrapping of\r\n * dataLayer and gtag script) are only run once per page load.\r\n */\r\nvar globalInitDone = false;\r\n/**\r\n * For testing\r\n */\r\nfunction resetGlobalVars(newGlobalInitDone, newInitializationPromisesMap, newDynamicPromises) {\r\n if (newGlobalInitDone === void 0) { newGlobalInitDone = false; }\r\n if (newInitializationPromisesMap === void 0) { newInitializationPromisesMap = {}; }\r\n if (newDynamicPromises === void 0) { newDynamicPromises = []; }\r\n globalInitDone = newGlobalInitDone;\r\n initializationPromisesMap = newInitializationPromisesMap;\r\n dynamicConfigPromisesList = newDynamicPromises;\r\n dataLayerName = 'dataLayer';\r\n gtagName = 'gtag';\r\n}\r\n/**\r\n * For testing\r\n */\r\nfunction getGlobalVars() {\r\n return {\r\n initializationPromisesMap: initializationPromisesMap,\r\n dynamicConfigPromisesList: dynamicConfigPromisesList\r\n };\r\n}\r\n/**\r\n * This must be run before calling firebase.analytics() or it won't\r\n * have any effect.\r\n * @param options Custom gtag and dataLayer names.\r\n */\r\nfunction settings(options) {\r\n if (globalInitDone) {\r\n throw ERROR_FACTORY.create(\"already-initialized\" /* ALREADY_INITIALIZED */);\r\n }\r\n if (options.dataLayerName) {\r\n dataLayerName = options.dataLayerName;\r\n }\r\n if (options.gtagName) {\r\n gtagName = options.gtagName;\r\n }\r\n}\r\n/**\r\n * Returns true if no environment mismatch is found.\r\n * If environment mismatches are found, throws an INVALID_ANALYTICS_CONTEXT\r\n * error that also lists details for each mismatch found.\r\n */\r\nfunction warnOnBrowserContextMismatch() {\r\n var mismatchedEnvMessages = [];\r\n if (isBrowserExtension()) {\r\n mismatchedEnvMessages.push('This is a browser extension environment.');\r\n }\r\n if (!areCookiesEnabled()) {\r\n mismatchedEnvMessages.push('Cookies are not available.');\r\n }\r\n if (mismatchedEnvMessages.length > 0) {\r\n var details = mismatchedEnvMessages\r\n .map(function (message, index) { return \"(\" + (index + 1) + \") \" + message; })\r\n .join(' ');\r\n var err = ERROR_FACTORY.create(\"invalid-analytics-context\" /* INVALID_ANALYTICS_CONTEXT */, {\r\n errorInfo: details\r\n });\r\n logger.warn(err.message);\r\n }\r\n}\r\nfunction factory(app, installations) {\r\n warnOnBrowserContextMismatch();\r\n var appId = app.options.appId;\r\n if (!appId) {\r\n throw ERROR_FACTORY.create(\"no-app-id\" /* NO_APP_ID */);\r\n }\r\n if (!app.options.apiKey) {\r\n if (app.options.measurementId) {\r\n logger.warn(\"The \\\"apiKey\\\" field is empty in the local Firebase config. This is needed to fetch the latest\" +\r\n (\" measurement ID for this Firebase app. Falling back to the measurement ID \" + app.options.measurementId) +\r\n \" provided in the \\\"measurementId\\\" field in the local Firebase config.\");\r\n }\r\n else {\r\n throw ERROR_FACTORY.create(\"no-api-key\" /* NO_API_KEY */);\r\n }\r\n }\r\n if (initializationPromisesMap[appId] != null) {\r\n throw ERROR_FACTORY.create(\"already-exists\" /* ALREADY_EXISTS */, {\r\n id: appId\r\n });\r\n }\r\n if (!globalInitDone) {\r\n // Steps here should only be done once per page: creation or wrapping\r\n // of dataLayer and global gtag function.\r\n getOrCreateDataLayer(dataLayerName);\r\n var _a = wrapOrCreateGtag(initializationPromisesMap, dynamicConfigPromisesList, measurementIdToAppId, dataLayerName, gtagName), wrappedGtag = _a.wrappedGtag, gtagCore = _a.gtagCore;\r\n wrappedGtagFunction = wrappedGtag;\r\n gtagCoreFunction = gtagCore;\r\n globalInitDone = true;\r\n }\r\n // Async but non-blocking.\r\n // This map reflects the completion state of all promises for each appId.\r\n initializationPromisesMap[appId] = initializeIds(app, dynamicConfigPromisesList, measurementIdToAppId, installations, gtagCoreFunction, dataLayerName);\r\n var analyticsInstance = {\r\n app: app,\r\n // Public methods return void for API simplicity and to better match gtag,\r\n // while internal implementations return promises.\r\n logEvent: function (eventName, eventParams, options) {\r\n logEvent(wrappedGtagFunction, initializationPromisesMap[appId], eventName, eventParams, options).catch(function (e) { return logger.error(e); });\r\n },\r\n setCurrentScreen: function (screenName, options) {\r\n setCurrentScreen(wrappedGtagFunction, initializationPromisesMap[appId], screenName, options).catch(function (e) { return logger.error(e); });\r\n },\r\n setUserId: function (id, options) {\r\n setUserId(wrappedGtagFunction, initializationPromisesMap[appId], id, options).catch(function (e) { return logger.error(e); });\r\n },\r\n setUserProperties: function (properties, options) {\r\n setUserProperties(wrappedGtagFunction, initializationPromisesMap[appId], properties, options).catch(function (e) { return logger.error(e); });\r\n },\r\n setAnalyticsCollectionEnabled: function (enabled) {\r\n setAnalyticsCollectionEnabled(initializationPromisesMap[appId], enabled).catch(function (e) { return logger.error(e); });\r\n },\r\n INTERNAL: {\r\n delete: function () {\r\n delete initializationPromisesMap[appId];\r\n return Promise.resolve();\r\n }\r\n }\r\n };\r\n return analyticsInstance;\r\n}\n\nvar name = \"@firebase/analytics\";\nvar version = \"0.6.18\";\n\n/**\r\n * Type constant for Firebase Analytics.\r\n */\r\nvar ANALYTICS_TYPE = 'analytics';\r\nfunction registerAnalytics(instance) {\r\n instance.INTERNAL.registerComponent(new Component(ANALYTICS_TYPE, function (container) {\r\n // getImmediate for FirebaseApp will always succeed\r\n var app = container.getProvider('app').getImmediate();\r\n var installations = container\r\n .getProvider('installations')\r\n .getImmediate();\r\n return factory(app, installations);\r\n }, \"PUBLIC\" /* PUBLIC */).setServiceProps({\r\n settings: settings,\r\n EventName: EventName,\r\n isSupported: isSupported\r\n }));\r\n instance.INTERNAL.registerComponent(new Component('analytics-internal', internalFactory, \"PRIVATE\" /* PRIVATE */));\r\n instance.registerVersion(name, version);\r\n function internalFactory(container) {\r\n try {\r\n var analytics = container.getProvider(ANALYTICS_TYPE).getImmediate();\r\n return {\r\n logEvent: analytics.logEvent\r\n };\r\n }\r\n catch (e) {\r\n throw ERROR_FACTORY.create(\"interop-component-reg-failed\" /* INTEROP_COMPONENT_REG_FAILED */, {\r\n reason: e\r\n });\r\n }\r\n }\r\n}\r\nregisterAnalytics(firebase);\r\n/**\r\n * this is a public static method provided to users that wraps four different checks:\r\n *\r\n * 1. check if it's not a browser extension environment.\r\n * 1. check if cookie is enabled in current browser.\r\n * 3. check if IndexedDB is supported by the browser environment.\r\n * 4. check if the current browser context is valid for using IndexedDB.\r\n *\r\n */\r\nfunction isSupported() {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var isDBOpenable;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (isBrowserExtension()) {\r\n return [2 /*return*/, false];\r\n }\r\n if (!areCookiesEnabled()) {\r\n return [2 /*return*/, false];\r\n }\r\n if (!isIndexedDBAvailable()) {\r\n return [2 /*return*/, false];\r\n }\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 3, , 4]);\r\n return [4 /*yield*/, validateIndexedDBOpenable()];\r\n case 2:\r\n isDBOpenable = _a.sent();\r\n return [2 /*return*/, isDBOpenable];\r\n case 3:\r\n _a.sent();\r\n return [2 /*return*/, false];\r\n case 4: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n}\n\nexport { factory, getGlobalVars, registerAnalytics, resetGlobalVars, settings };\n//# sourceMappingURL=index.esm.js.map\n","import '@firebase/analytics';\n//# sourceMappingURL=index.esm.js.map\n"],"names":[],"sourceRoot":""}