@thefittingroom/shop-ui 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * thefittingroom v1.5.2 (2024-09-02T22:33:59.821Z)
2
+ * thefittingroom v1.5.3 (2024-09-03T15:46:41.127Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  function t(e,n){let r=function(){0!==n.length&&t(n.slice(-1),n.slice(0,-1))};var i=new Image;i.onload=r,i.onerror=r,i.src=e}function e(e){t(e.slice(-1),e.slice(0,-1))}const n=(t,n)=>{const r=document.getElementById(t);if(!r)throw new Error(`Slider with id ${t} not found`);return{Load(t){if(!Array.isArray(t)||!t.length)return console.debug("slider has no images to load"),new Error("slider has no images to load");e(t);const i=(null==t?void 0:t.length)-2;r.value=i.toString(),r.max=(t.length-1).toString();const s=()=>{const e=parseInt(r.value);n(r,t[e])};return n(r,t[i]),r.removeEventListener("input",s),r.addEventListener("input",s),()=>{r.removeEventListener("input",s)}}}},r=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=63&i|128):55296==(64512&i)&&r+1<t.length&&56320==(64512&t.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&t.charCodeAt(++r)),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=63&i|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=63&i|128)}return e},i={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let e=0;e<t.length;e+=3){const i=t[e],s=e+1<t.length,o=s?t[e+1]:0,a=e+2<t.length,c=a?t[e+2]:0,l=i>>2,u=(3&i)<<4|o>>4;let h=(15&o)<<2|c>>6,d=63&c;a||(d=64,s||(h=64)),r.push(n[l],n[u],n[h],n[d])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(r(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=t[n++];e[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){const s=((7&i)<<18|(63&t[n++])<<12|(63&t[n++])<<6|63&t[n++])-65536;e[r++]=String.fromCharCode(55296+(s>>10)),e[r++]=String.fromCharCode(56320+(1023&s))}else{const s=t[n++],o=t[n++];e[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let e=0;e<t.length;){const i=n[t.charAt(e++)],o=e<t.length?n[t.charAt(e)]:0;++e;const a=e<t.length?n[t.charAt(e)]:64;++e;const c=e<t.length?n[t.charAt(e)]:64;if(++e,null==i||null==o||null==a||null==c)throw new s;const l=i<<2|o>>4;if(r.push(l),64!==a){const t=o<<4&240|a>>2;if(r.push(t),64!==c){const t=a<<6&192|c;r.push(t)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};
6
6
  /*!
7
- * thefittingroom v1.5.1 (2024-09-02T22:33:26.212Z)
7
+ * thefittingroom v1.5.2 (2024-09-03T15:43:56.403Z)
8
8
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
9
9
  */
10
10
  /**
@@ -121,7 +121,7 @@ class d{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Pr
121
121
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
122
  * See the License for the specific language governing permissions and
123
123
  * limitations under the License.
124
- */function w(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach((t=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(t))})):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function S(t){const e={};return t.replace(/^\?/,"").split("&").forEach((t=>{if(t){const[n,r]=t.split("=");e[decodeURIComponent(n)]=decodeURIComponent(r)}})),e}function b(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}class _{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then((()=>{t(this)})).catch((t=>{this.error(t)}))}next(t){this.forEachObserver((e=>{e.next(t)}))}error(t){this.forEachObserver((e=>{e.error(t)})),this.close(t)}complete(){this.forEachObserver((t=>{t.complete()})),this.close()}subscribe(t,e,n){let r;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");r=function(t,e){if("object"!=typeof t||null===t)return!1;for(const n of e)if(n in t&&"function"==typeof t[n])return!0;return!1}(t,["next","error","complete"])?t:{next:t,error:e,complete:n},void 0===r.next&&(r.next=E),void 0===r.error&&(r.error=E),void 0===r.complete&&(r.complete=E);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(t){}})),this.observers.push(r),i}unsubscribeOne(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then((()=>{if(void 0!==this.observers&&void 0!==this.observers[t])try{e(this.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}}))}close(t){this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function E(){}
124
+ */function w(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach((t=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(t))})):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function b(t){const e={};return t.replace(/^\?/,"").split("&").forEach((t=>{if(t){const[n,r]=t.split("=");e[decodeURIComponent(n)]=decodeURIComponent(r)}})),e}function S(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}class _{constructor(t,e){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=e,this.task.then((()=>{t(this)})).catch((t=>{this.error(t)}))}next(t){this.forEachObserver((e=>{e.next(t)}))}error(t){this.forEachObserver((e=>{e.error(t)})),this.close(t)}complete(){this.forEachObserver((t=>{t.complete()})),this.close()}subscribe(t,e,n){let r;if(void 0===t&&void 0===e&&void 0===n)throw new Error("Missing Observer.");r=function(t,e){if("object"!=typeof t||null===t)return!1;for(const n of e)if(n in t&&"function"==typeof t[n])return!0;return!1}(t,["next","error","complete"])?t:{next:t,error:e,complete:n},void 0===r.next&&(r.next=E),void 0===r.error&&(r.error=E),void 0===r.complete&&(r.complete=E);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then((()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(t){}})),this.observers.push(r),i}unsubscribeOne(t){void 0!==this.observers&&void 0!==this.observers[t]&&(delete this.observers[t],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(t){if(!this.finalized)for(let e=0;e<this.observers.length;e++)this.sendOne(e,t)}sendOne(t,e){this.task.then((()=>{if(void 0!==this.observers&&void 0!==this.observers[t])try{e(this.observers[t])}catch(t){"undefined"!=typeof console&&console.error&&console.error(t)}}))}close(t){this.finalized||(this.finalized=!0,void 0!==t&&(this.finalError=t),this.task.then((()=>{this.observers=void 0,this.onNoObservers=void 0})))}}function E(){}
125
125
  /**
126
126
  * @license
127
127
  * Copyright 2021 Google LLC
@@ -218,7 +218,7 @@ class d{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Pr
218
218
  * See the License for the specific language governing permissions and
219
219
  * limitations under the License.
220
220
  */
221
- class X{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const Z="@firebase/app",tt="0.10.9",et=new P("@firebase/app"),nt="@firebase/app-compat",rt="@firebase/analytics-compat",it="@firebase/analytics",st="@firebase/app-check-compat",ot="@firebase/app-check",at="@firebase/auth",ct="@firebase/auth-compat",lt="@firebase/database",ut="@firebase/database-compat",ht="@firebase/functions",dt="@firebase/functions-compat",ft="@firebase/installations",pt="@firebase/installations-compat",gt="@firebase/messaging",mt="@firebase/messaging-compat",yt="@firebase/performance",vt="@firebase/performance-compat",wt="@firebase/remote-config",St="@firebase/remote-config-compat",bt="@firebase/storage",_t="@firebase/storage-compat",Et="@firebase/firestore",Tt="@firebase/vertexai-preview",It="@firebase/firestore-compat",kt="firebase",Ct="[DEFAULT]",At={[Z]:"fire-core",[nt]:"fire-core-compat",[it]:"fire-analytics",[rt]:"fire-analytics-compat",[ot]:"fire-app-check",[st]:"fire-app-check-compat",[at]:"fire-auth",[ct]:"fire-auth-compat",[lt]:"fire-rtdb",[ut]:"fire-rtdb-compat",[ht]:"fire-fn",[dt]:"fire-fn-compat",[ft]:"fire-iid",[pt]:"fire-iid-compat",[gt]:"fire-fcm",[mt]:"fire-fcm-compat",[yt]:"fire-perf",[vt]:"fire-perf-compat",[wt]:"fire-rc",[St]:"fire-rc-compat",[bt]:"fire-gcs",[_t]:"fire-gcs-compat",[Et]:"fire-fst",[It]:"fire-fst-compat",[Tt]:"fire-vertex","fire-js":"fire-js",[kt]:"fire-js-all"},Rt=new Map,Nt=new Map,Lt=new Map;function Ot(t,e){try{t.container.addComponent(e)}catch(n){et.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function Dt(t){const e=t.name;if(Lt.has(e))return et.debug(`There were multiple attempts to register component ${e}.`),!1;Lt.set(e,t);for(const e of Rt.values())Ot(e,t);for(const e of Nt.values())Ot(e,t);return!0}function Pt(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function xt(t){return void 0!==t.settings}
221
+ class X{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const Z="@firebase/app",tt="0.10.9",et=new P("@firebase/app"),nt="@firebase/app-compat",rt="@firebase/analytics-compat",it="@firebase/analytics",st="@firebase/app-check-compat",ot="@firebase/app-check",at="@firebase/auth",ct="@firebase/auth-compat",lt="@firebase/database",ut="@firebase/database-compat",ht="@firebase/functions",dt="@firebase/functions-compat",ft="@firebase/installations",pt="@firebase/installations-compat",gt="@firebase/messaging",mt="@firebase/messaging-compat",yt="@firebase/performance",vt="@firebase/performance-compat",wt="@firebase/remote-config",bt="@firebase/remote-config-compat",St="@firebase/storage",_t="@firebase/storage-compat",Et="@firebase/firestore",Tt="@firebase/vertexai-preview",It="@firebase/firestore-compat",kt="firebase",Ct="[DEFAULT]",At={[Z]:"fire-core",[nt]:"fire-core-compat",[it]:"fire-analytics",[rt]:"fire-analytics-compat",[ot]:"fire-app-check",[st]:"fire-app-check-compat",[at]:"fire-auth",[ct]:"fire-auth-compat",[lt]:"fire-rtdb",[ut]:"fire-rtdb-compat",[ht]:"fire-fn",[dt]:"fire-fn-compat",[ft]:"fire-iid",[pt]:"fire-iid-compat",[gt]:"fire-fcm",[mt]:"fire-fcm-compat",[yt]:"fire-perf",[vt]:"fire-perf-compat",[wt]:"fire-rc",[bt]:"fire-rc-compat",[St]:"fire-gcs",[_t]:"fire-gcs-compat",[Et]:"fire-fst",[It]:"fire-fst-compat",[Tt]:"fire-vertex","fire-js":"fire-js",[kt]:"fire-js-all"},Rt=new Map,Nt=new Map,Lt=new Map;function Ot(t,e){try{t.container.addComponent(e)}catch(n){et.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function Dt(t){const e=t.name;if(Lt.has(e))return et.debug(`There were multiple attempts to register component ${e}.`),!1;Lt.set(e,t);for(const e of Rt.values())Ot(e,t);for(const e of Nt.values())Ot(e,t);return!0}function Pt(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function xt(t){return void 0!==t.settings}
222
222
  /**
223
223
  * @license
224
224
  * Copyright 2019 Google LLC
@@ -397,7 +397,7 @@ const re=()=>function(){if("undefined"!=typeof self)return self;if("undefined"!=
397
397
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
398
398
  * See the License for the specific language governing permissions and
399
399
  * limitations under the License.
400
- */var de;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(de||(de={}));const fe={debug:de.DEBUG,verbose:de.VERBOSE,info:de.INFO,warn:de.WARN,error:de.ERROR,silent:de.SILENT},pe=de.INFO,ge={[de.DEBUG]:"log",[de.VERBOSE]:"log",[de.INFO]:"info",[de.WARN]:"warn",[de.ERROR]:"error"},me=(t,e,...n)=>{if(e<t.logLevel)return;const r=(new Date).toISOString(),i=ge[e];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[i](`[${r}] ${t.name}:`,...n)};var ye=function(t,e){return ye=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},ye(t,e)};function ve(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function we(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,s=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}var Se,be="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},_e=_e||{},Ee=be||self;function Te(){}function Ie(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function ke(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var Ce="closure_uid_"+(1e9*Math.random()>>>0),Ae=0;function Re(t,e,n){return t.call.apply(t.bind,arguments)}function Ne(t,e,n){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function Le(t,e,n){return(Le=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?Re:Ne).apply(null,arguments)}function Oe(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function De(t,e){function n(){}n.prototype=e.prototype,t.X=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Wb=function(t,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return e.prototype[n].apply(t,i)}}function Pe(){this.s=this.s,this.o=this.o}Pe.prototype.s=!1,Pe.prototype.na=function(){var t;!this.s&&(this.s=!0,this.M(),0)&&(t=this,Object.prototype.hasOwnProperty.call(t,Ce)&&t[Ce]||(t[Ce]=++Ae))},Pe.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};var xe=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1};function Me(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function Ue(t,e){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(Ie(r)){var i=t.length||0,s=r.length||0;t.length=i+s;for(var o=0;o<s;o++)t[i+o]=r[o]}else t.push(r)}}function Fe(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}Fe.prototype.h=function(){this.defaultPrevented=!0};var ze=function(){if(!Ee.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{Ee.addEventListener("test",Te,e),Ee.removeEventListener("test",Te,e)}catch(t){}return t}();function Be(t){return/^[\s\xa0]*$/.test(t)}var Ve=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function He(t,e){return t<e?-1:t>e?1:0}function je(){var t=Ee.navigator;return t&&(t=t.userAgent)?t:""}function $e(t){return-1!=je().indexOf(t)}function qe(t){return qe[" "](t),t}qe[" "]=Te;var We,Ke,Ge=$e("Opera"),Qe=$e("Trident")||$e("MSIE"),Ye=$e("Edge"),Je=Ye||Qe,Xe=$e("Gecko")&&!(-1!=je().toLowerCase().indexOf("webkit")&&!$e("Edge"))&&!($e("Trident")||$e("MSIE"))&&!$e("Edge"),Ze=-1!=je().toLowerCase().indexOf("webkit")&&!$e("Edge");function tn(){var t=Ee.document;return t?t.documentMode:void 0}t:{var en="",nn=(Ke=je(),Xe?/rv:([^\);]+)(\)|;)/.exec(Ke):Ye?/Edge\/([\d\.]+)/.exec(Ke):Qe?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Ke):Ze?/WebKit\/(\S+)/.exec(Ke):Ge?/(?:Version)[ \/]?(\S+)/.exec(Ke):void 0);if(nn&&(en=nn?nn[1]:""),Qe){var rn=tn();if(null!=rn&&rn>parseFloat(en)){We=String(rn);break t}}We=en}var sn,on={};function an(){return function(t){var e=on;return Object.prototype.hasOwnProperty.call(e,9)?e[9]:e[9]=t(9)}((function(){for(var t=0,e=Ve(String(We)).split("."),n=Ve("9").split("."),r=Math.max(e.length,n.length),i=0;0==t&&i<r;i++){var s=e[i]||"",o=n[i]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],0==s[0].length&&0==o[0].length)break;t=He(0==s[1].length?0:parseInt(s[1],10),0==o[1].length?0:parseInt(o[1],10))||He(0==s[2].length,0==o[2].length)||He(s[2],o[2]),s=s[3],o=o[3]}while(0==t)}return 0<=t}))}if(Ee.document&&Qe){var cn=tn();sn=cn||(parseInt(We,10)||void 0)}else sn=void 0;var ln=sn;function un(t,e){if(Fe.call(this,t?t.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(Xe){t:{try{qe(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:hn[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&un.X.h.call(this)}}De(un,Fe);var hn={2:"touch",3:"pen",4:"mouse"};un.prototype.h=function(){un.X.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var dn="closure_listenable_"+(1e6*Math.random()|0),fn=0;function pn(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.ha=i,this.key=++fn,this.ba=this.ea=!1}function gn(t){t.ba=!0,t.listener=null,t.proxy=null,t.src=null,t.ha=null}function mn(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function yn(t){var e={};for(var n in t)e[n]=t[n];return e}var vn="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function wn(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var s=0;s<vn.length;s++)n=vn[s],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function Sn(t){this.src=t,this.g={},this.h=0}function bn(t,e){var n=e.type;if(n in t.g){var r,i=t.g[n],s=xe(i,e);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(gn(e),0==t.g[n].length&&(delete t.g[n],t.h--))}}function _n(t,e,n,r){for(var i=0;i<t.length;++i){var s=t[i];if(!s.ba&&s.listener==e&&s.capture==!!n&&s.ha==r)return i}return-1}Sn.prototype.add=function(t,e,n,r,i){var s=t.toString();(t=this.g[s])||(t=this.g[s]=[],this.h++);var o=_n(t,e,r,i);return-1<o?(e=t[o],n||(e.ea=!1)):((e=new pn(e,this.src,s,!!r,i)).ea=n,t.push(e)),e};var En="closure_lm_"+(1e6*Math.random()|0),Tn={};function In(t,e,n,r,i){if(r&&r.once)return Cn(t,e,n,r,i);if(Array.isArray(e)){for(var s=0;s<e.length;s++)In(t,e[s],n,r,i);return null}return n=Pn(n),t&&t[dn]?t.N(e,n,ke(r)?!!r.capture:!!r,i):kn(t,e,n,!1,r,i)}function kn(t,e,n,r,i,s){if(!e)throw Error("Invalid event type");var o=ke(i)?!!i.capture:!!i,a=On(t);if(a||(t[En]=a=new Sn(t)),(n=a.add(e,n,r,o,s)).proxy)return n;if(r=function(){function t(n){return e.call(t.src,t.listener,n)}var e=Ln;return t}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)ze||(i=o),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Nn(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function Cn(t,e,n,r,i){if(Array.isArray(e)){for(var s=0;s<e.length;s++)Cn(t,e[s],n,r,i);return null}return n=Pn(n),t&&t[dn]?t.O(e,n,ke(r)?!!r.capture:!!r,i):kn(t,e,n,!0,r,i)}function An(t,e,n,r,i){if(Array.isArray(e))for(var s=0;s<e.length;s++)An(t,e[s],n,r,i);else r=ke(r)?!!r.capture:!!r,n=Pn(n),t&&t[dn]?(t=t.i,(e=String(e).toString())in t.g&&(-1<(n=_n(s=t.g[e],n,r,i))&&(gn(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete t.g[e],t.h--)))):t&&(t=On(t))&&(e=t.g[e.toString()],t=-1,e&&(t=_n(e,n,r,i)),(n=-1<t?e[t]:null)&&Rn(n))}function Rn(t){if("number"!=typeof t&&t&&!t.ba){var e=t.src;if(e&&e[dn])bn(e.i,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Nn(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=On(e))?(bn(n,t),0==n.h&&(n.src=null,e[En]=null)):gn(t)}}}function Nn(t){return t in Tn?Tn[t]:Tn[t]="on"+t}function Ln(t,e){if(t.ba)t=!0;else{e=new un(e,this);var n=t.listener,r=t.ha||t.src;t.ea&&Rn(t),t=n.call(r,e)}return t}function On(t){return(t=t[En])instanceof Sn?t:null}var Dn="__closure_events_fn_"+(1e9*Math.random()>>>0);function Pn(t){return"function"==typeof t?t:(t[Dn]||(t[Dn]=function(e){return t.handleEvent(e)}),t[Dn])}function xn(){Pe.call(this),this.i=new Sn(this),this.P=this,this.I=null}function Mn(t,e){var n,r=t.I;if(r)for(n=[];r;r=r.I)n.push(r);if(t=t.P,r=e.type||e,"string"==typeof e)e=new Fe(e,t);else if(e instanceof Fe)e.target=e.target||t;else{var i=e;wn(e=new Fe(r,t),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=e.g=n[s];i=Un(o,r,!0,e)&&i}if(i=Un(o=e.g=t,r,!0,e)&&i,i=Un(o,r,!1,e)&&i,n)for(s=0;s<n.length;s++)i=Un(o=e.g=n[s],r,!1,e)&&i}function Un(t,e,n,r){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var i=!0,s=0;s<e.length;++s){var o=e[s];if(o&&!o.ba&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.ea&&bn(t.i,o),i=!1!==a.call(c,r)&&i}}return i&&!r.defaultPrevented}De(xn,Pe),xn.prototype[dn]=!0,xn.prototype.removeEventListener=function(t,e,n,r){An(this,t,e,n,r)},xn.prototype.M=function(){if(xn.X.M.call(this),this.i){var t,e=this.i;for(t in e.g){for(var n=e.g[t],r=0;r<n.length;r++)gn(n[r]);delete e.g[t],e.h--}}this.I=null},xn.prototype.N=function(t,e,n,r){return this.i.add(String(t),e,!1,n,r)},xn.prototype.O=function(t,e,n,r){return this.i.add(String(t),e,!0,n,r)};var Fn=Ee.JSON.stringify;function zn(){var t=Kn,e=null;return t.g&&(e=t.g,t.g=t.g.next,t.g||(t.h=null),e.next=null),e}var Bn,Vn=function(){function t(){this.h=this.g=null}return t.prototype.add=function(t,e){var n=Hn.get();n.set(t,e),this.h?this.h.next=n:this.g=n,this.h=n},t}(),Hn=new(function(){function t(t,e){this.i=t,this.j=e,this.h=0,this.g=null}return t.prototype.get=function(){var t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t},t}())((function(){return new jn}),(function(t){return t.reset()})),jn=function(){function t(){this.next=this.g=this.h=null}return t.prototype.set=function(t,e){this.h=t,this.g=e,this.next=null},t.prototype.reset=function(){this.next=this.g=this.h=null},t}();function $n(t){Ee.setTimeout((function(){throw t}),0)}function qn(t,e){Bn||function(){var t=Ee.Promise.resolve(void 0);Bn=function(){t.then(Gn)}}(),Wn||(Bn(),Wn=!0),Kn.add(t,e)}var Wn=!1,Kn=new Vn;function Gn(){for(var t;t=zn();){try{t.h.call(t.g)}catch(t){$n(t)}var e=Hn;e.j(t),100>e.h&&(e.h++,t.next=e.g,e.g=t)}Wn=!1}function Qn(t,e){xn.call(this),this.h=t||1,this.g=e||Ee,this.j=Le(this.lb,this),this.l=Date.now()}function Yn(t){t.ca=!1,t.R&&(t.g.clearTimeout(t.R),t.R=null)}function Jn(t,e,n){if("function"==typeof t)n&&(t=Le(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=Le(t.handleEvent,t)}return 2147483647<Number(e)?-1:Ee.setTimeout(t,e||0)}function Xn(t){t.g=Jn((function(){t.g=null,t.i&&(t.i=!1,Xn(t))}),t.j);var e=t.h;t.h=null,t.m.apply(null,e)}De(Qn,xn),(Se=Qn.prototype).ca=!1,Se.R=null,Se.lb=function(){if(this.ca){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.R=this.g.setTimeout(this.j,this.h-t):(this.R&&(this.g.clearTimeout(this.R),this.R=null),Mn(this,"tick"),this.ca&&(Yn(this),this.start()))}},Se.start=function(){this.ca=!0,this.R||(this.R=this.g.setTimeout(this.j,this.h),this.l=Date.now())},Se.M=function(){Qn.X.M.call(this),Yn(this),delete this.g};var Zn=function(t){function e(e,n){var r=t.call(this)||this;return r.m=e,r.j=n,r.h=null,r.i=!1,r.g=null,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}ye(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.l=function(t){this.h=arguments,this.g?this.i=!0:Xn(this)},e.prototype.M=function(){t.prototype.M.call(this),this.g&&(Ee.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)},e}(Pe);function tr(t){Pe.call(this),this.h=t,this.g={}}De(tr,Pe);var er=[];function nr(t,e,n,r){Array.isArray(n)||(n&&(er[0]=n.toString()),n=er);for(var i=0;i<n.length;i++){var s=In(e,n[i],r||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}}function rr(t){mn(t.g,(function(t,e){this.g.hasOwnProperty(e)&&Rn(t)}),t),t.g={}}function ir(){this.g=!0}function sr(t,e,n,r){t.info((function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.g)return e;if(!e)return null;try{var n=JSON.parse(e);if(n)for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var r=n[t];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return Fn(n)}catch(t){return e}}(t,n)+(r?" "+r:"")}))}tr.prototype.M=function(){tr.X.M.call(this),rr(this)},tr.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},ir.prototype.Aa=function(){this.g=!1},ir.prototype.info=function(){};var or={},ar=null;function cr(){return ar=ar||new xn}function lr(t){Fe.call(this,or.Pa,t)}function ur(t){var e=cr();Mn(e,new lr(e))}function hr(t,e){Fe.call(this,or.STAT_EVENT,t),this.stat=e}function dr(t){var e=cr();Mn(e,new hr(e,t))}function fr(t,e){Fe.call(this,or.Qa,t),this.size=e}function pr(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return Ee.setTimeout((function(){t()}),e)}or.Pa="serverreachability",De(lr,Fe),or.STAT_EVENT="statevent",De(hr,Fe),or.Qa="timingevent",De(fr,Fe);var gr={NO_ERROR:0,mb:1,zb:2,yb:3,tb:4,xb:5,Ab:6,Ma:7,TIMEOUT:8,Db:9},mr={rb:"complete",Nb:"success",Na:"error",Ma:"abort",Fb:"ready",Gb:"readystatechange",TIMEOUT:"timeout",Bb:"incrementaldata",Eb:"progress",ub:"downloadprogress",Vb:"uploadprogress"};function yr(){}function vr(t){return t.h||(t.h=t.i())}function wr(){}yr.prototype.h=null;var Sr,br={OPEN:"a",qb:"b",Na:"c",Cb:"d"};function _r(){Fe.call(this,"d")}function Er(){Fe.call(this,"c")}function Tr(){}function Ir(t,e,n,r){this.l=t,this.j=e,this.m=n,this.U=r||1,this.S=new tr(this),this.O=Cr,t=Je?125:void 0,this.T=new Qn(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.V=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.Y=-1,this.I=!1,this.N=0,this.L=null,this.$=this.J=this.Z=this.P=!1,this.h=new kr}function kr(){this.i=null,this.g="",this.h=!1}De(_r,Fe),De(Er,Fe),De(Tr,yr),Tr.prototype.g=function(){return new XMLHttpRequest},Tr.prototype.i=function(){return{}},Sr=new Tr;var Cr=45e3,Ar={},Rr={};function Nr(t,e,n){t.K=1,t.v=Qr($r(e)),t.s=n,t.P=!0,Lr(t,null)}function Lr(t,e){t.F=Date.now(),xr(t),t.A=$r(t.v);var n=t.A,r=t.U;Array.isArray(r)||(r=[String(r)]),ci(n.i,"t",r),t.C=0,n=t.l.H,t.h=new kr,t.g=cs(t.l,n?e:null,!t.s),0<t.N&&(t.L=new Zn(Le(t.La,t,t.g),t.N)),nr(t.S,t.g,"readystatechange",t.ib),e=t.H?yn(t.H):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.da(t.A,t.u,t.s,e)):(t.u="GET",t.g.da(t.A,t.u,null,e)),ur(),function(t,e,n,r,i,s){t.info((function(){if(t.g)if(s)for(var o="",a=s.split("&"),c=0;c<a.length;c++){var l=a[c].split("=");if(1<l.length){var u=l[0];l=l[1];var h=u.split("_");o=2<=h.length&&"type"==h[1]?o+(u+"=")+l+"&":o+(u+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+e+"\n"+n+"\n"+o}))}(t.j,t.u,t.A,t.m,t.U,t.s)}function Or(t){return!!t.g&&("GET"==t.u&&2!=t.K&&t.l.Da)}function Dr(t,e,n){for(var r,i=!0;!t.I&&t.C<n.length;){if((r=Pr(t,n))==Rr){4==e&&(t.o=4,dr(14),i=!1),sr(t.j,t.m,null,"[Incomplete Response]");break}if(r==Ar){t.o=4,dr(15),sr(t.j,t.m,n,"[Invalid Chunk]"),i=!1;break}sr(t.j,t.m,r,null),Br(t,r)}Or(t)&&r!=Rr&&r!=Ar&&(t.h.g="",t.C=0),4!=e||0!=n.length||t.h.h||(t.o=1,dr(16),i=!1),t.i=t.i&&i,i?0<n.length&&!t.$&&(t.$=!0,(e=t.l).g==t&&e.$&&!e.K&&(e.j.info("Great, no buffering proxy detected. Bytes received: "+n.length),ts(e),e.K=!0,dr(11))):(sr(t.j,t.m,n,"[Invalid Chunked Response]"),zr(t),Fr(t))}function Pr(t,e){var n=t.C,r=e.indexOf("\n",n);return-1==r?Rr:(n=Number(e.substring(n,r)),isNaN(n)?Ar:(r+=1)+n>e.length?Rr:(e=e.substr(r,n),t.C=r+n,e))}function xr(t){t.V=Date.now()+t.O,Mr(t,t.O)}function Mr(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=pr(Le(t.gb,t),e)}function Ur(t){t.B&&(Ee.clearTimeout(t.B),t.B=null)}function Fr(t){0==t.l.G||t.I||rs(t.l,t)}function zr(t){Ur(t);var e=t.L;e&&"function"==typeof e.na&&e.na(),t.L=null,Yn(t.T),rr(t.S),t.g&&(e=t.g,t.g=null,e.abort(),e.na())}function Br(t,e){try{var n=t.l;if(0!=n.G&&(n.g==t||gi(n.h,t)))if(!t.J&&gi(n.h,t)&&3==n.G){try{var r=n.Fa.g.parse(e)}catch(s){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){t:if(!n.u){if(n.g){if(!(n.g.F+3e3<t.F))break t;ns(n),Wi(n)}Zi(n),dr(18)}}else n.Ba=i[1],0<n.Ba-n.T&&37500>i[2]&&n.L&&0==n.A&&!n.v&&(n.v=pr(Le(n.cb,n),6e3));if(1>=pi(n.h)&&n.ja){try{n.ja()}catch(s){}n.ja=void 0}}else ss(n,11)}else if((t.J||n.g==t)&&ns(n),!Be(e))for(i=n.Fa.g.parse(e),e=0;e<i.length;e++){var s=i[e];if(n.T=s[0],s=s[1],2==n.G)if("c"==s[0]){n.I=s[1],n.ka=s[2];var o=s[3];null!=o&&(n.ma=o,n.j.info("VER="+n.ma));var a=s[4];null!=a&&(n.Ca=a,n.j.info("SVER="+n.Ca));var c=s[5];null!=c&&"number"==typeof c&&0<c&&(r=1.5*c,n.J=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;var l=t.g;if(l){var u=l.g?l.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(u){var h=r.h;h.g||-1==u.indexOf("spdy")&&-1==u.indexOf("quic")&&-1==u.indexOf("h2")||(h.j=h.l,h.g=new Set,h.h&&(mi(h,h.h),h.h=null))}if(r.D){var d=l.g?l.g.getResponseHeader("X-HTTP-Session-Id"):null;d&&(r.za=d,Gr(r.F,r.D,d))}}n.G=3,n.l&&n.l.xa(),n.$&&(n.P=Date.now()-t.F,n.j.info("Handshake RTT: "+n.P+"ms"));var f=t;if((r=n).sa=as(r,r.H?r.ka:null,r.V),f.J){yi(r.h,f);var p=f,g=r.J;g&&p.setTimeout(g),p.B&&(Ur(p),xr(p)),r.g=f}else Xi(r);0<n.i.length&&Gi(n)}else"stop"!=s[0]&&"close"!=s[0]||ss(n,7);else 3==n.G&&("stop"==s[0]||"close"==s[0]?"stop"==s[0]?ss(n,7):qi(n):"noop"!=s[0]&&n.l&&n.l.wa(s),n.A=0)}ur()}catch(s){}}function Vr(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(Ie(t)||"string"==typeof t)Array.prototype.forEach.call(t,e,void 0);else for(var n=function(t){if(t.oa&&"function"==typeof t.oa)return t.oa();if(!t.W||"function"!=typeof t.W){if("undefined"!=typeof Map&&t instanceof Map)return Array.from(t.keys());if(!("undefined"!=typeof Set&&t instanceof Set)){if(Ie(t)||"string"==typeof t){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(var r in e=[],n=0,t)e[n++]=r;return e}}}(t),r=function(t){if(t.W&&"function"==typeof t.W)return t.W();if("undefined"!=typeof Map&&t instanceof Map||"undefined"!=typeof Set&&t instanceof Set)return Array.from(t.values());if("string"==typeof t)return t.split("");if(Ie(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t),i=r.length,s=0;s<i;s++)e.call(void 0,r[s],n&&n[s],t)}(Se=Ir.prototype).setTimeout=function(t){this.O=t},Se.ib=function(t){t=t.target;var e=this.L;e&&3==zi(t)?e.l():this.La(t)},Se.La=function(t){try{if(t==this.g)t:{var e=zi(this.g),n=this.g.Ea();this.g.aa();if(!(3>e)&&(3!=e||Je||this.g&&(this.h.h||this.g.fa()||Bi(this.g)))){this.I||4!=e||7==n||ur(),Ur(this);var r=this.g.aa();this.Y=r;e:if(Or(this)){var i=Bi(this.g);t="";var s=i.length,o=4==zi(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){zr(this),Fr(this);var a="";break e}this.h.i=new Ee.TextDecoder}for(n=0;n<s;n++)this.h.h=!0,t+=this.h.i.decode(i[n],{stream:o&&n==s-1});i.splice(0,s),this.h.g+=t,this.C=0,a=this.h.g}else a=this.g.fa();if(this.i=200==r,function(t,e,n,r,i,s,o){t.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+e+"\n"+n+"\n"+s+" "+o}))}(this.j,this.u,this.A,this.m,this.U,e,r),this.i){if(this.Z&&!this.J){e:{if(this.g){var c,l=this.g;if((c=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!Be(c)){var u=c;break e}}u=null}if(!(r=u)){this.i=!1,this.o=3,dr(12),zr(this),Fr(this);break t}sr(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,Br(this,r)}this.P?(Dr(this,e,a),Je&&this.i&&3==e&&(nr(this.S,this.T,"tick",this.hb),this.T.start())):(sr(this.j,this.m,a,null),Br(this,a)),4==e&&zr(this),this.i&&!this.I&&(4==e?rs(this.l,this):(this.i=!1,xr(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,dr(12)):(this.o=0,dr(13)),zr(this),Fr(this)}}}catch(e){}},Se.hb=function(){if(this.g){var t=zi(this.g),e=this.g.fa();this.C<e.length&&(Ur(this),Dr(this,t,e),this.i&&4!=t&&xr(this))}},Se.cancel=function(){this.I=!0,zr(this)},Se.gb=function(){this.B=null;var t=Date.now();0<=t-this.V?(function(t,e){t.info((function(){return"TIMEOUT: "+e}))}(this.j,this.A),2!=this.K&&(ur(),dr(17)),zr(this),this.o=2,Fr(this)):Mr(this,this.V-t)};var Hr=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function jr(t,e){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,t instanceof jr){this.h=void 0!==e?e:t.h,qr(this,t.j),this.s=t.s,this.g=t.g,Wr(this,t.m),this.l=t.l,e=t.i;var n=new ii;n.i=e.i,e.g&&(n.g=new Map(e.g),n.h=e.h),Kr(this,n),this.o=t.o}else t&&(n=String(t).match(Hr))?(this.h=!!e,qr(this,n[1]||"",!0),this.s=Yr(n[2]||""),this.g=Yr(n[3]||"",!0),Wr(this,n[4]),this.l=Yr(n[5]||"",!0),Kr(this,n[6]||"",!0),this.o=Yr(n[7]||"")):(this.h=!!e,this.i=new ii(null,this.h))}function $r(t){return new jr(t)}function qr(t,e,n){t.j=n?Yr(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function Wr(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.m=e}else t.m=null}function Kr(t,e,n){e instanceof ii?(t.i=e,function(t,e){e&&!t.j&&(si(t),t.i=null,t.g.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(oi(this,e),ci(this,n,t))}),t)),t.j=e}(t.i,t.h)):(n||(e=Jr(e,ni)),t.i=new ii(e,t.h))}function Gr(t,e,n){t.i.set(e,n)}function Qr(t){return Gr(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function Yr(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Jr(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,Xr),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Xr(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}jr.prototype.toString=function(){var t=[],e=this.j;e&&t.push(Jr(e,Zr,!0),":");var n=this.g;return(n||"file"==e)&&(t.push("//"),(e=this.s)&&t.push(Jr(e,Zr,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&t.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&t.push("/"),t.push(Jr(n,"/"==n.charAt(0)?ei:ti,!0))),(n=this.i.toString())&&t.push("?",n),(n=this.o)&&t.push("#",Jr(n,ri)),t.join("")};var Zr=/[#\/\?@]/g,ti=/[#\?:]/g,ei=/[#\?]/g,ni=/[#\?@]/g,ri=/#/g;function ii(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function si(t){t.g||(t.g=new Map,t.h=0,t.i&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var s=t[n].substring(0,r);i=t[n].substring(r+1)}else s=t[n];e(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(t.i,(function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)})))}function oi(t,e){si(t),e=li(t,e),t.g.has(e)&&(t.i=null,t.h-=t.g.get(e).length,t.g.delete(e))}function ai(t,e){return si(t),e=li(t,e),t.g.has(e)}function ci(t,e,n){oi(t,e),0<n.length&&(t.i=null,t.g.set(li(t,e),Me(n)),t.h+=n.length)}function li(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}(Se=ii.prototype).add=function(t,e){si(this),this.i=null,t=li(this,t);var n=this.g.get(t);return n||this.g.set(t,n=[]),n.push(e),this.h+=1,this},Se.forEach=function(t,e){si(this),this.g.forEach((function(n,r){n.forEach((function(n){t.call(e,n,r,this)}),this)}),this)},Se.oa=function(){si(this);for(var t=Array.from(this.g.values()),e=Array.from(this.g.keys()),n=[],r=0;r<e.length;r++)for(var i=t[r],s=0;s<i.length;s++)n.push(e[r]);return n},Se.W=function(t){si(this);var e=[];if("string"==typeof t)ai(this,t)&&(e=e.concat(this.g.get(li(this,t))));else{t=Array.from(this.g.values());for(var n=0;n<t.length;n++)e=e.concat(t[n])}return e},Se.set=function(t,e){return si(this),this.i=null,ai(this,t=li(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},Se.get=function(t,e){return t&&0<(t=this.W(t)).length?String(t[0]):e},Se.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var t=[],e=Array.from(this.g.keys()),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r)),s=this.W(r);for(r=0;r<s.length;r++){var o=i;""!==s[r]&&(o+="="+encodeURIComponent(String(s[r]))),t.push(o)}}return this.i=t.join("&")};var ui=function(t,e){this.h=t,this.g=e};function hi(t){this.l=t||di,Ee.PerformanceNavigationTiming?t=0<(t=Ee.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(Ee.g&&Ee.g.Ga&&Ee.g.Ga()&&Ee.g.Ga().$b),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var di=10;function fi(t){return!!t.h||!!t.g&&t.g.size>=t.j}function pi(t){return t.h?1:t.g?t.g.size:0}function gi(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function mi(t,e){t.g?t.g.add(e):t.h=e}function yi(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function vi(t){var e,n;if(null!=t.h)return t.i.concat(t.h.D);if(null!=t.g&&0!==t.g.size){var r=t.i;try{for(var i=ve(t.g.values()),s=i.next();!s.done;s=i.next()){var o=s.value;r=r.concat(o.D)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}return Me(t.i)}function wi(){}function Si(){this.g=new wi}function bi(t,e,n){var r=n||"";try{Vr(t,(function(t,n){var i=t;ke(t)&&(i=Fn(t)),e.push(r+n+"="+encodeURIComponent(i))}))}catch(t){throw e.push(r+"type="+encodeURIComponent("_badmap")),t}}function _i(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}function Ei(t){this.l=t.ac||null,this.j=t.jb||!1}function Ti(t,e){xn.call(this),this.D=t,this.u=e,this.m=void 0,this.readyState=Ii,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}hi.prototype.cancel=function(){var t,e;if(this.i=vi(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){try{for(var n=ve(this.g.values()),r=n.next();!r.done;r=n.next()){r.value.cancel()}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}this.g.clear()}},wi.prototype.stringify=function(t){return Ee.JSON.stringify(t,void 0)},wi.prototype.parse=function(t){return Ee.JSON.parse(t,void 0)},De(Ei,yr),Ei.prototype.g=function(){return new Ti(this.l,this.j)},Ei.prototype.i=function(t){return function(){return t}}({}),De(Ti,xn);var Ii=0;function ki(t){t.j.read().then(t.Ta.bind(t)).catch(t.ga.bind(t))}function Ci(t){t.readyState=4,t.l=null,t.j=null,t.A=null,Ai(t)}function Ai(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(Se=Ti.prototype).open=function(t,e){if(this.readyState!=Ii)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=e,this.readyState=1,Ai(this)},Se.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;var e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(e.body=t),(this.D||Ee).fetch(new Request(this.B,e)).then(this.Wa.bind(this),this.ga.bind(this))},Se.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch((function(){})),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Ci(this)),this.readyState=Ii},Se.Wa=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,Ai(this)),this.g&&(this.readyState=3,Ai(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ua.bind(this),this.ga.bind(this));else if(void 0!==Ee.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;ki(this)}else t.text().then(this.Va.bind(this),this.ga.bind(this))},Se.Ta=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var e=t.value?t.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?Ci(this):Ai(this),3==this.readyState&&ki(this)}},Se.Va=function(t){this.g&&(this.response=this.responseText=t,Ci(this))},Se.Ua=function(t){this.g&&(this.response=t,Ci(this))},Se.ga=function(){this.g&&Ci(this)},Se.setRequestHeader=function(t,e){this.v.append(t,e)},Se.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},Se.getAllResponseHeaders=function(){if(!this.h)return"";for(var t=[],e=this.h.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},Object.defineProperty(Ti.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var Ri=Ee.JSON.parse;function Ni(t){xn.call(this),this.headers=new Map,this.u=t||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=Li,this.K=this.L=!1}De(Ni,xn);var Li="",Oi=/^https?$/i,Di=["POST","PUT"];function Pi(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,xi(t),Ui(t)}function xi(t){t.D||(t.D=!0,Mn(t,"complete"),Mn(t,"error"))}function Mi(t){if(t.h&&void 0!==_e&&(!t.C[1]||4!=zi(t)||2!=t.aa()))if(t.v&&4==zi(t))Jn(t.Ha,0,t);else if(Mn(t,"readystatechange"),4==zi(t)){t.h=!1;try{var e,n=t.aa();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var s=String(t.H).match(Hr)[1]||null;if(!s&&Ee.self&&Ee.self.location){var o=Ee.self.location.protocol;s=o.substr(0,o.length-1)}i=!Oi.test(s?s.toLowerCase():"")}e=i}if(e)Mn(t,"complete"),Mn(t,"success");else{t.m=6;try{var a=2<zi(t)?t.g.statusText:""}catch(t){a=""}t.j=a+" ["+t.aa()+"]",xi(t)}}finally{Ui(t)}}}function Ui(t,e){if(t.g){Fi(t);var n=t.g,r=t.C[0]?Te:null;t.g=null,t.C=null,e||Mn(t,"ready");try{n.onreadystatechange=r}catch(t){}}}function Fi(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(Ee.clearTimeout(t.A),t.A=null)}function zi(t){return t.g?t.g.readyState:0}function Bi(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case Li:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(t){return null}}function Vi(t){var e="";return mn(t,(function(t,n){e+=n,e+=":",e+=t,e+="\r\n"})),e}function Hi(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}r||(n=Vi(n),"string"==typeof t?null!=n&&encodeURIComponent(String(n)):Gr(t,e,n))}function ji(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function $i(t){this.Ca=0,this.i=[],this.j=new ir,this.ka=this.sa=this.F=this.V=this.g=this.za=this.D=this.ia=this.o=this.S=this.s=null,this.ab=this.U=0,this.Za=ji("failFast",!1,t),this.L=this.v=this.u=this.m=this.l=null,this.Y=!0,this.pa=this.Ba=this.T=-1,this.Z=this.A=this.C=0,this.Xa=ji("baseRetryDelayMs",5e3,t),this.bb=ji("retryDelaySeedMs",1e4,t),this.$a=ji("forwardChannelMaxRetries",2,t),this.ta=ji("forwardChannelRequestTimeoutMs",2e4,t),this.ra=t&&t.xmlHttpFactory||void 0,this.Da=t&&t.Zb||!1,this.J=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.I="",this.h=new hi(t&&t.concurrentRequestLimit),this.Fa=new Si,this.O=t&&t.fastHandshake||!1,this.N=t&&t.encodeInitMessageHeaders||!1,this.O&&this.N&&(this.N=!1),this.Ya=t&&t.Xb||!1,t&&t.Aa&&this.j.Aa(),t&&t.forceLongPolling&&(this.Y=!1),this.$=!this.O&&this.Y&&t&&t.detectBufferingProxy||!1,this.ja=void 0,this.P=0,this.K=!1,this.la=this.B=null}function qi(t){if(Ki(t),3==t.G){var e=t.U++,n=$r(t.F);Gr(n,"SID",t.I),Gr(n,"RID",e),Gr(n,"TYPE","terminate"),Yi(t,n),(e=new Ir(t,t.j,e,void 0)).K=2,e.v=Qr($r(n)),n=!1,Ee.navigator&&Ee.navigator.sendBeacon&&(n=Ee.navigator.sendBeacon(e.v.toString(),"")),!n&&Ee.Image&&((new Image).src=e.v,n=!0),n||(e.g=cs(e.l,null),e.g.da(e.v)),e.F=Date.now(),xr(e)}os(t)}function Wi(t){t.g&&(ts(t),t.g.cancel(),t.g=null)}function Ki(t){Wi(t),t.u&&(Ee.clearTimeout(t.u),t.u=null),ns(t),t.h.cancel(),t.m&&("number"==typeof t.m&&Ee.clearTimeout(t.m),t.m=null)}function Gi(t){fi(t.h)||t.m||(t.m=!0,qn(t.Ja,t),t.C=0)}function Qi(t,e){var n;n=e?e.m:t.U++;var r=$r(t.F);Gr(r,"SID",t.I),Gr(r,"RID",n),Gr(r,"AID",t.T),Yi(t,r),t.o&&t.s&&Hi(r,t.o,t.s),n=new Ir(t,t.j,n,t.C+1),null===t.o&&(n.H=t.s),e&&(t.i=e.D.concat(t.i)),e=Ji(t,n,1e3),n.setTimeout(Math.round(.5*t.ta)+Math.round(.5*t.ta*Math.random())),mi(t.h,n),Nr(n,r,e)}function Yi(t,e){t.ia&&mn(t.ia,(function(t,n){Gr(e,n,t)})),t.l&&Vr({},(function(t,n){Gr(e,n,t)}))}function Ji(t,e,n){n=Math.min(t.i.length,n);var r=t.l?Le(t.l.Ra,t.l,t):null;t:for(var i=t.i,s=-1;;){var o=["count="+n];-1==s?0<n?(s=i[0].h,o.push("ofs="+s)):s=0:o.push("ofs="+s);for(var a=!0,c=0;c<n;c++){var l=i[c].h,u=i[c].g;if(0>(l-=s))s=Math.max(0,i[c].h-100),a=!1;else try{bi(u,o,"req"+l+"_")}catch(t){r&&r(u)}}if(a){r=o.join("&");break t}}return t=t.i.splice(0,n),e.D=t,r}function Xi(t){t.g||t.u||(t.Z=1,qn(t.Ia,t),t.A=0)}function Zi(t){return!(t.g||t.u||3<=t.A)&&(t.Z++,t.u=pr(Le(t.Ia,t),is(t,t.A)),t.A++,!0)}function ts(t){null!=t.B&&(Ee.clearTimeout(t.B),t.B=null)}function es(t){t.g=new Ir(t,t.j,"rpc",t.Z),null===t.o&&(t.g.H=t.s),t.g.N=0;var e=$r(t.sa);Gr(e,"RID","rpc"),Gr(e,"SID",t.I),Gr(e,"CI",t.L?"0":"1"),Gr(e,"AID",t.T),Gr(e,"TYPE","xmlhttp"),Yi(t,e),t.o&&t.s&&Hi(e,t.o,t.s),t.J&&t.g.setTimeout(t.J);var n=t.g;t=t.ka,n.K=1,n.v=Qr($r(e)),n.s=null,n.P=!0,Lr(n,t)}function ns(t){null!=t.v&&(Ee.clearTimeout(t.v),t.v=null)}function rs(t,e){var n=null;if(t.g==e){ns(t),ts(t),t.g=null;var r=2}else{if(!gi(t.h,e))return;n=e.D,yi(t.h,e),r=1}if(0!=t.G)if(t.pa=e.Y,e.i)if(1==r){n=e.s?e.s.length:0,e=Date.now()-e.F;var i=t.C;Mn(r=cr(),new fr(r,n)),Gi(t)}else Xi(t);else if(3==(i=e.o)||0==i&&0<t.pa||!(1==r&&function(t,e){return!(pi(t.h)>=t.h.j-(t.m?1:0)||(t.m?(t.i=e.D.concat(t.i),0):1==t.G||2==t.G||t.C>=(t.Za?0:t.$a)||(t.m=pr(Le(t.Ja,t,e),is(t,t.C)),t.C++,0)))}(t,e)||2==r&&Zi(t)))switch(n&&0<n.length&&(e=t.h,e.i=e.i.concat(n)),i){case 1:ss(t,5);break;case 4:ss(t,10);break;case 3:ss(t,6);break;default:ss(t,2)}}function is(t,e){var n=t.Xa+Math.floor(Math.random()*t.bb);return t.l||(n*=2),n*e}function ss(t,e){if(t.j.info("Error code "+e),2==e){var n=null;t.l&&(n=null);var r=Le(t.kb,t);n||(n=new jr("//www.google.com/images/cleardot.gif"),Ee.location&&"http"==Ee.location.protocol||qr(n,"https"),Qr(n)),function(t,e){var n=new ir;if(Ee.Image){var r=new Image;r.onload=Oe(_i,n,r,"TestLoadImage: loaded",!0,e),r.onerror=Oe(_i,n,r,"TestLoadImage: error",!1,e),r.onabort=Oe(_i,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=Oe(_i,n,r,"TestLoadImage: timeout",!1,e),Ee.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=t}else e(!1)}(n.toString(),r)}else dr(2);t.G=0,t.l&&t.l.va(e),os(t),Ki(t)}function os(t){if(t.G=0,t.la=[],t.l){var e=vi(t.h);0==e.length&&0==t.i.length||(Ue(t.la,e),Ue(t.la,t.i),t.h.i.length=0,Me(t.i),t.i.length=0),t.l.ua()}}function as(t,e,n){var r=n instanceof jr?$r(n):new jr(n,void 0);if(""!=r.g)e&&(r.g=e+"."+r.g),Wr(r,r.m);else{var i=Ee.location;r=i.protocol,e=e?e+"."+i.hostname:i.hostname,i=+i.port;var s=new jr(null,void 0);r&&qr(s,r),e&&(s.g=e),i&&Wr(s,i),n&&(s.l=n),r=s}return n=t.D,e=t.za,n&&e&&Gr(r,n,e),Gr(r,"VER",t.ma),Yi(t,r),r}function cs(t,e,n){if(e&&!t.H)throw Error("Can't create secondary domain capable XhrIo object.");return(e=n&&t.Da&&!t.ra?new Ni(new Ei({jb:!0})):new Ni(t.ra)).Ka(t.H),e}function ls(){}function us(){if(Qe&&!(10<=Number(ln)))throw Error("Environmental error: no available transport.")}function hs(t,e){xn.call(this),this.g=new $i(e),this.l=t,this.h=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.s=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.ya&&(t?t["X-WebChannel-Client-Profile"]=e.ya:t={"X-WebChannel-Client-Profile":e.ya}),this.g.S=t,(t=e&&e.Yb)&&!Be(t)&&(this.g.o=t),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!Be(e)&&(this.g.D=e,null!==(t=this.h)&&e in t&&(e in(t=this.h)&&delete t[e])),this.j=new ps(this)}function ds(t){_r.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.i=t)&&(t=this.i,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function fs(){Er.call(this),this.status=1}function ps(t){this.g=t}(Se=Ni.prototype).Ka=function(t){this.L=t},Se.da=function(t,e,n,r){var i,s,o,a;if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);e=e?e.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():Sr.g(),this.C=this.u?vr(this.u):vr(Sr),this.g.onreadystatechange=Le(this.Ha,this);try{this.F=!0,this.g.open(e,String(t),!0),this.F=!1}catch(h){return void Pi(this,h)}if(t=n||"",n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var c in r)n.set(c,r[c]);else{if("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));try{for(var l=ve(r.keys()),u=l.next();!u.done;u=l.next()){var h=u.value;n.set(h,r.get(h))}}catch(t){i={error:t}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}}r=Array.from(n.keys()).find((function(t){return"content-type"==t.toLowerCase()})),c=Ee.FormData&&t instanceof Ee.FormData,!(0<=xe(Di,e))||r||c||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");try{for(var d=ve(n),f=d.next();!f.done;f=d.next()){var p=we(f.value,2),g=(h=p[0],p[1]);this.g.setRequestHeader(h,g)}}catch(t){o={error:t}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{Fi(this),0<this.B&&((this.K=function(t){return Qe&&an()&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=Le(this.qa,this)):this.A=Jn(this.qa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(h){Pi(this,h)}},Se.qa=function(){void 0!==_e&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,Mn(this,"timeout"),this.abort(8))},Se.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,Mn(this,"complete"),Mn(this,"abort"),Ui(this))},Se.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Ui(this,!0)),Ni.X.M.call(this)},Se.Ha=function(){this.s||(this.F||this.v||this.l?Mi(this):this.fb())},Se.fb=function(){Mi(this)},Se.aa=function(){try{return 2<zi(this)?this.g.status:-1}catch(t){return-1}},Se.fa=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},Se.Sa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Ri(e)}},Se.Ea=function(){return this.m},Se.Oa=function(){return"string"==typeof this.j?this.j:String(this.j)},(Se=$i.prototype).ma=8,Se.G=1,Se.Ja=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.U=Math.floor(1e5*Math.random()),t=this.U++;var e=new Ir(this,this.j,t,void 0),n=this.s;if(this.S&&(n?wn(n=yn(n),this.S):n=this.S),null!==this.o||this.N||(e.H=n,n=null),this.O)t:{for(var r=0,i=0;i<this.i.length;i++){var s=this.i[i];if(void 0===(s="__data__"in s.g&&"string"==typeof(s=s.g.__data__)?s.length:void 0))break;if(4096<(r+=s)){r=i;break t}if(4096===r||i===this.i.length-1){r=i+1;break t}}r=1e3}else r=1e3;r=Ji(this,e,r),Gr(i=$r(this.F),"RID",t),Gr(i,"CVER",22),this.D&&Gr(i,"X-HTTP-Session-Id",this.D),Yi(this,i),n&&(this.N?r="headers="+encodeURIComponent(String(Vi(n)))+"&"+r:this.o&&Hi(i,this.o,n)),mi(this.h,e),this.Ya&&Gr(i,"TYPE","init"),this.O?(Gr(i,"$req",r),Gr(i,"SID","null"),e.Z=!0,Nr(e,i,null)):Nr(e,i,r),this.G=2}}else 3==this.G&&(t?Qi(this,t):0==this.i.length||fi(this.h)||Qi(this))},Se.Ia=function(){if(this.u=null,es(this),this.$&&!(this.K||null==this.g||0>=this.P)){var t=2*this.P;this.j.info("BP detection timer enabled: "+t),this.B=pr(Le(this.eb,this),t)}},Se.eb=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.L=!1,this.K=!0,dr(10),Wi(this),es(this))},Se.cb=function(){null!=this.v&&(this.v=null,Wi(this),Zi(this),dr(19))},Se.kb=function(t){t?(this.j.info("Successfully pinged google.com"),dr(2)):(this.j.info("Failed to ping google.com"),dr(1))},(Se=ls.prototype).xa=function(){},Se.wa=function(){},Se.va=function(){},Se.ua=function(){},Se.Ra=function(){},us.prototype.g=function(t,e){return new hs(t,e)},De(hs,xn),hs.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.H=!0);var t=this.g,e=this.l,n=this.h||void 0;dr(0),t.V=e,t.ia=n||{},t.L=t.Y,t.F=as(t,null,t.V),Gi(t)},hs.prototype.close=function(){qi(this.g)},hs.prototype.u=function(t){var e=this.g;if("string"==typeof t){var n={};n.__data__=t,t=n}else this.v&&((n={}).__data__=Fn(t),t=n);e.i.push(new ui(e.ab++,t)),3==e.G&&Gi(e)},hs.prototype.M=function(){this.g.l=null,delete this.j,qi(this.g),delete this.g,hs.X.M.call(this)},De(ds,_r),De(fs,Er),De(ps,ls),ps.prototype.xa=function(){Mn(this.g,"a")},ps.prototype.wa=function(t){Mn(this.g,new ds(t))},ps.prototype.va=function(t){Mn(this.g,new fs)},ps.prototype.ua=function(){Mn(this.g,"b")},us.prototype.createWebChannel=us.prototype.g,hs.prototype.send=hs.prototype.u,hs.prototype.open=hs.prototype.m,hs.prototype.close=hs.prototype.close,gr.NO_ERROR=0,gr.TIMEOUT=8,gr.HTTP_ERROR=6,mr.COMPLETE="complete",wr.EventType=br,br.OPEN="a",br.CLOSE="b",br.ERROR="c",br.MESSAGE="d",xn.prototype.listen=xn.prototype.N,Ni.prototype.listenOnce=Ni.prototype.O,Ni.prototype.getLastError=Ni.prototype.Oa,Ni.prototype.getLastErrorCode=Ni.prototype.Ea,Ni.prototype.getStatus=Ni.prototype.aa,Ni.prototype.getResponseJson=Ni.prototype.Sa,Ni.prototype.getResponseText=Ni.prototype.fa,Ni.prototype.send=Ni.prototype.da,Ni.prototype.setWithCredentials=Ni.prototype.Ka;var gs=gr,ms=mr,ys=or,vs=10,ws=11,Ss=Ei,bs=wr,_s=Ni;const Es="@firebase/firestore";
400
+ */var de;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(de||(de={}));const fe={debug:de.DEBUG,verbose:de.VERBOSE,info:de.INFO,warn:de.WARN,error:de.ERROR,silent:de.SILENT},pe=de.INFO,ge={[de.DEBUG]:"log",[de.VERBOSE]:"log",[de.INFO]:"info",[de.WARN]:"warn",[de.ERROR]:"error"},me=(t,e,...n)=>{if(e<t.logLevel)return;const r=(new Date).toISOString(),i=ge[e];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`);console[i](`[${r}] ${t.name}:`,...n)};var ye=function(t,e){return ye=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},ye(t,e)};function ve(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function we(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,s=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}var be,Se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},_e=_e||{},Ee=Se||self;function Te(){}function Ie(t){var e=typeof t;return"array"==(e="object"!=e?e:t?Array.isArray(t)?"array":e:"null")||"object"==e&&"number"==typeof t.length}function ke(t){var e=typeof t;return"object"==e&&null!=t||"function"==e}var Ce="closure_uid_"+(1e9*Math.random()>>>0),Ae=0;function Re(t,e,n){return t.call.apply(t.bind,arguments)}function Ne(t,e,n){if(!t)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),t.apply(e,n)}}return function(){return t.apply(e,arguments)}}function Le(t,e,n){return(Le=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?Re:Ne).apply(null,arguments)}function Oe(t,e){var n=Array.prototype.slice.call(arguments,1);return function(){var e=n.slice();return e.push.apply(e,arguments),t.apply(this,e)}}function De(t,e){function n(){}n.prototype=e.prototype,t.X=e.prototype,t.prototype=new n,t.prototype.constructor=t,t.Wb=function(t,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return e.prototype[n].apply(t,i)}}function Pe(){this.s=this.s,this.o=this.o}Pe.prototype.s=!1,Pe.prototype.na=function(){var t;!this.s&&(this.s=!0,this.M(),0)&&(t=this,Object.prototype.hasOwnProperty.call(t,Ce)&&t[Ce]||(t[Ce]=++Ae))},Pe.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};var xe=Array.prototype.indexOf?function(t,e){return Array.prototype.indexOf.call(t,e,void 0)}:function(t,e){if("string"==typeof t)return"string"!=typeof e||1!=e.length?-1:t.indexOf(e,0);for(var n=0;n<t.length;n++)if(n in t&&t[n]===e)return n;return-1};function Me(t){var e=t.length;if(0<e){for(var n=Array(e),r=0;r<e;r++)n[r]=t[r];return n}return[]}function Ue(t,e){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(Ie(r)){var i=t.length||0,s=r.length||0;t.length=i+s;for(var o=0;o<s;o++)t[i+o]=r[o]}else t.push(r)}}function Fe(t,e){this.type=t,this.g=this.target=e,this.defaultPrevented=!1}Fe.prototype.h=function(){this.defaultPrevented=!0};var ze=function(){if(!Ee.addEventListener||!Object.defineProperty)return!1;var t=!1,e=Object.defineProperty({},"passive",{get:function(){t=!0}});try{Ee.addEventListener("test",Te,e),Ee.removeEventListener("test",Te,e)}catch(t){}return t}();function Be(t){return/^[\s\xa0]*$/.test(t)}var Ve=String.prototype.trim?function(t){return t.trim()}:function(t){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(t)[1]};function He(t,e){return t<e?-1:t>e?1:0}function je(){var t=Ee.navigator;return t&&(t=t.userAgent)?t:""}function $e(t){return-1!=je().indexOf(t)}function qe(t){return qe[" "](t),t}qe[" "]=Te;var We,Ke,Ge=$e("Opera"),Qe=$e("Trident")||$e("MSIE"),Ye=$e("Edge"),Je=Ye||Qe,Xe=$e("Gecko")&&!(-1!=je().toLowerCase().indexOf("webkit")&&!$e("Edge"))&&!($e("Trident")||$e("MSIE"))&&!$e("Edge"),Ze=-1!=je().toLowerCase().indexOf("webkit")&&!$e("Edge");function tn(){var t=Ee.document;return t?t.documentMode:void 0}t:{var en="",nn=(Ke=je(),Xe?/rv:([^\);]+)(\)|;)/.exec(Ke):Ye?/Edge\/([\d\.]+)/.exec(Ke):Qe?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(Ke):Ze?/WebKit\/(\S+)/.exec(Ke):Ge?/(?:Version)[ \/]?(\S+)/.exec(Ke):void 0);if(nn&&(en=nn?nn[1]:""),Qe){var rn=tn();if(null!=rn&&rn>parseFloat(en)){We=String(rn);break t}}We=en}var sn,on={};function an(){return function(t){var e=on;return Object.prototype.hasOwnProperty.call(e,9)?e[9]:e[9]=t(9)}((function(){for(var t=0,e=Ve(String(We)).split("."),n=Ve("9").split("."),r=Math.max(e.length,n.length),i=0;0==t&&i<r;i++){var s=e[i]||"",o=n[i]||"";do{if(s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],o=/(\d*)(\D*)(.*)/.exec(o)||["","","",""],0==s[0].length&&0==o[0].length)break;t=He(0==s[1].length?0:parseInt(s[1],10),0==o[1].length?0:parseInt(o[1],10))||He(0==s[2].length,0==o[2].length)||He(s[2],o[2]),s=s[3],o=o[3]}while(0==t)}return 0<=t}))}if(Ee.document&&Qe){var cn=tn();sn=cn||(parseInt(We,10)||void 0)}else sn=void 0;var ln=sn;function un(t,e){if(Fe.call(this,t?t.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,t){var n=this.type=t.type,r=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:null;if(this.target=t.target||t.srcElement,this.g=e,e=t.relatedTarget){if(Xe){t:{try{qe(e.nodeName);var i=!0;break t}catch(t){}i=!1}i||(e=null)}}else"mouseover"==n?e=t.fromElement:"mouseout"==n&&(e=t.toElement);this.relatedTarget=e,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==t.clientX?t.clientX:t.pageX,this.clientY=void 0!==t.clientY?t.clientY:t.pageY,this.screenX=t.screenX||0,this.screenY=t.screenY||0),this.button=t.button,this.key=t.key||"",this.ctrlKey=t.ctrlKey,this.altKey=t.altKey,this.shiftKey=t.shiftKey,this.metaKey=t.metaKey,this.pointerId=t.pointerId||0,this.pointerType="string"==typeof t.pointerType?t.pointerType:hn[t.pointerType]||"",this.state=t.state,this.i=t,t.defaultPrevented&&un.X.h.call(this)}}De(un,Fe);var hn={2:"touch",3:"pen",4:"mouse"};un.prototype.h=function(){un.X.h.call(this);var t=this.i;t.preventDefault?t.preventDefault():t.returnValue=!1};var dn="closure_listenable_"+(1e6*Math.random()|0),fn=0;function pn(t,e,n,r,i){this.listener=t,this.proxy=null,this.src=e,this.type=n,this.capture=!!r,this.ha=i,this.key=++fn,this.ba=this.ea=!1}function gn(t){t.ba=!0,t.listener=null,t.proxy=null,t.src=null,t.ha=null}function mn(t,e,n){for(var r in t)e.call(n,t[r],r,t)}function yn(t){var e={};for(var n in t)e[n]=t[n];return e}var vn="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function wn(t,e){for(var n,r,i=1;i<arguments.length;i++){for(n in r=arguments[i])t[n]=r[n];for(var s=0;s<vn.length;s++)n=vn[s],Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}}function bn(t){this.src=t,this.g={},this.h=0}function Sn(t,e){var n=e.type;if(n in t.g){var r,i=t.g[n],s=xe(i,e);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(gn(e),0==t.g[n].length&&(delete t.g[n],t.h--))}}function _n(t,e,n,r){for(var i=0;i<t.length;++i){var s=t[i];if(!s.ba&&s.listener==e&&s.capture==!!n&&s.ha==r)return i}return-1}bn.prototype.add=function(t,e,n,r,i){var s=t.toString();(t=this.g[s])||(t=this.g[s]=[],this.h++);var o=_n(t,e,r,i);return-1<o?(e=t[o],n||(e.ea=!1)):((e=new pn(e,this.src,s,!!r,i)).ea=n,t.push(e)),e};var En="closure_lm_"+(1e6*Math.random()|0),Tn={};function In(t,e,n,r,i){if(r&&r.once)return Cn(t,e,n,r,i);if(Array.isArray(e)){for(var s=0;s<e.length;s++)In(t,e[s],n,r,i);return null}return n=Pn(n),t&&t[dn]?t.N(e,n,ke(r)?!!r.capture:!!r,i):kn(t,e,n,!1,r,i)}function kn(t,e,n,r,i,s){if(!e)throw Error("Invalid event type");var o=ke(i)?!!i.capture:!!i,a=On(t);if(a||(t[En]=a=new bn(t)),(n=a.add(e,n,r,o,s)).proxy)return n;if(r=function(){function t(n){return e.call(t.src,t.listener,n)}var e=Ln;return t}(),n.proxy=r,r.src=t,r.listener=n,t.addEventListener)ze||(i=o),void 0===i&&(i=!1),t.addEventListener(e.toString(),r,i);else if(t.attachEvent)t.attachEvent(Nn(e.toString()),r);else{if(!t.addListener||!t.removeListener)throw Error("addEventListener and attachEvent are unavailable.");t.addListener(r)}return n}function Cn(t,e,n,r,i){if(Array.isArray(e)){for(var s=0;s<e.length;s++)Cn(t,e[s],n,r,i);return null}return n=Pn(n),t&&t[dn]?t.O(e,n,ke(r)?!!r.capture:!!r,i):kn(t,e,n,!0,r,i)}function An(t,e,n,r,i){if(Array.isArray(e))for(var s=0;s<e.length;s++)An(t,e[s],n,r,i);else r=ke(r)?!!r.capture:!!r,n=Pn(n),t&&t[dn]?(t=t.i,(e=String(e).toString())in t.g&&(-1<(n=_n(s=t.g[e],n,r,i))&&(gn(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete t.g[e],t.h--)))):t&&(t=On(t))&&(e=t.g[e.toString()],t=-1,e&&(t=_n(e,n,r,i)),(n=-1<t?e[t]:null)&&Rn(n))}function Rn(t){if("number"!=typeof t&&t&&!t.ba){var e=t.src;if(e&&e[dn])Sn(e.i,t);else{var n=t.type,r=t.proxy;e.removeEventListener?e.removeEventListener(n,r,t.capture):e.detachEvent?e.detachEvent(Nn(n),r):e.addListener&&e.removeListener&&e.removeListener(r),(n=On(e))?(Sn(n,t),0==n.h&&(n.src=null,e[En]=null)):gn(t)}}}function Nn(t){return t in Tn?Tn[t]:Tn[t]="on"+t}function Ln(t,e){if(t.ba)t=!0;else{e=new un(e,this);var n=t.listener,r=t.ha||t.src;t.ea&&Rn(t),t=n.call(r,e)}return t}function On(t){return(t=t[En])instanceof bn?t:null}var Dn="__closure_events_fn_"+(1e9*Math.random()>>>0);function Pn(t){return"function"==typeof t?t:(t[Dn]||(t[Dn]=function(e){return t.handleEvent(e)}),t[Dn])}function xn(){Pe.call(this),this.i=new bn(this),this.P=this,this.I=null}function Mn(t,e){var n,r=t.I;if(r)for(n=[];r;r=r.I)n.push(r);if(t=t.P,r=e.type||e,"string"==typeof e)e=new Fe(e,t);else if(e instanceof Fe)e.target=e.target||t;else{var i=e;wn(e=new Fe(r,t),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=e.g=n[s];i=Un(o,r,!0,e)&&i}if(i=Un(o=e.g=t,r,!0,e)&&i,i=Un(o,r,!1,e)&&i,n)for(s=0;s<n.length;s++)i=Un(o=e.g=n[s],r,!1,e)&&i}function Un(t,e,n,r){if(!(e=t.i.g[String(e)]))return!0;e=e.concat();for(var i=!0,s=0;s<e.length;++s){var o=e[s];if(o&&!o.ba&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.ea&&Sn(t.i,o),i=!1!==a.call(c,r)&&i}}return i&&!r.defaultPrevented}De(xn,Pe),xn.prototype[dn]=!0,xn.prototype.removeEventListener=function(t,e,n,r){An(this,t,e,n,r)},xn.prototype.M=function(){if(xn.X.M.call(this),this.i){var t,e=this.i;for(t in e.g){for(var n=e.g[t],r=0;r<n.length;r++)gn(n[r]);delete e.g[t],e.h--}}this.I=null},xn.prototype.N=function(t,e,n,r){return this.i.add(String(t),e,!1,n,r)},xn.prototype.O=function(t,e,n,r){return this.i.add(String(t),e,!0,n,r)};var Fn=Ee.JSON.stringify;function zn(){var t=Kn,e=null;return t.g&&(e=t.g,t.g=t.g.next,t.g||(t.h=null),e.next=null),e}var Bn,Vn=function(){function t(){this.h=this.g=null}return t.prototype.add=function(t,e){var n=Hn.get();n.set(t,e),this.h?this.h.next=n:this.g=n,this.h=n},t}(),Hn=new(function(){function t(t,e){this.i=t,this.j=e,this.h=0,this.g=null}return t.prototype.get=function(){var t;return 0<this.h?(this.h--,t=this.g,this.g=t.next,t.next=null):t=this.i(),t},t}())((function(){return new jn}),(function(t){return t.reset()})),jn=function(){function t(){this.next=this.g=this.h=null}return t.prototype.set=function(t,e){this.h=t,this.g=e,this.next=null},t.prototype.reset=function(){this.next=this.g=this.h=null},t}();function $n(t){Ee.setTimeout((function(){throw t}),0)}function qn(t,e){Bn||function(){var t=Ee.Promise.resolve(void 0);Bn=function(){t.then(Gn)}}(),Wn||(Bn(),Wn=!0),Kn.add(t,e)}var Wn=!1,Kn=new Vn;function Gn(){for(var t;t=zn();){try{t.h.call(t.g)}catch(t){$n(t)}var e=Hn;e.j(t),100>e.h&&(e.h++,t.next=e.g,e.g=t)}Wn=!1}function Qn(t,e){xn.call(this),this.h=t||1,this.g=e||Ee,this.j=Le(this.lb,this),this.l=Date.now()}function Yn(t){t.ca=!1,t.R&&(t.g.clearTimeout(t.R),t.R=null)}function Jn(t,e,n){if("function"==typeof t)n&&(t=Le(t,n));else{if(!t||"function"!=typeof t.handleEvent)throw Error("Invalid listener argument");t=Le(t.handleEvent,t)}return 2147483647<Number(e)?-1:Ee.setTimeout(t,e||0)}function Xn(t){t.g=Jn((function(){t.g=null,t.i&&(t.i=!1,Xn(t))}),t.j);var e=t.h;t.h=null,t.m.apply(null,e)}De(Qn,xn),(be=Qn.prototype).ca=!1,be.R=null,be.lb=function(){if(this.ca){var t=Date.now()-this.l;0<t&&t<.8*this.h?this.R=this.g.setTimeout(this.j,this.h-t):(this.R&&(this.g.clearTimeout(this.R),this.R=null),Mn(this,"tick"),this.ca&&(Yn(this),this.start()))}},be.start=function(){this.ca=!0,this.R||(this.R=this.g.setTimeout(this.j,this.h),this.l=Date.now())},be.M=function(){Qn.X.M.call(this),Yn(this),delete this.g};var Zn=function(t){function e(e,n){var r=t.call(this)||this;return r.m=e,r.j=n,r.h=null,r.i=!1,r.g=null,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}ye(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.l=function(t){this.h=arguments,this.g?this.i=!0:Xn(this)},e.prototype.M=function(){t.prototype.M.call(this),this.g&&(Ee.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)},e}(Pe);function tr(t){Pe.call(this),this.h=t,this.g={}}De(tr,Pe);var er=[];function nr(t,e,n,r){Array.isArray(n)||(n&&(er[0]=n.toString()),n=er);for(var i=0;i<n.length;i++){var s=In(e,n[i],r||t.handleEvent,!1,t.h||t);if(!s)break;t.g[s.key]=s}}function rr(t){mn(t.g,(function(t,e){this.g.hasOwnProperty(e)&&Rn(t)}),t),t.g={}}function ir(){this.g=!0}function sr(t,e,n,r){t.info((function(){return"XMLHTTP TEXT ("+e+"): "+function(t,e){if(!t.g)return e;if(!e)return null;try{var n=JSON.parse(e);if(n)for(t=0;t<n.length;t++)if(Array.isArray(n[t])){var r=n[t];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return Fn(n)}catch(t){return e}}(t,n)+(r?" "+r:"")}))}tr.prototype.M=function(){tr.X.M.call(this),rr(this)},tr.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},ir.prototype.Aa=function(){this.g=!1},ir.prototype.info=function(){};var or={},ar=null;function cr(){return ar=ar||new xn}function lr(t){Fe.call(this,or.Pa,t)}function ur(t){var e=cr();Mn(e,new lr(e))}function hr(t,e){Fe.call(this,or.STAT_EVENT,t),this.stat=e}function dr(t){var e=cr();Mn(e,new hr(e,t))}function fr(t,e){Fe.call(this,or.Qa,t),this.size=e}function pr(t,e){if("function"!=typeof t)throw Error("Fn must not be null and must be a function");return Ee.setTimeout((function(){t()}),e)}or.Pa="serverreachability",De(lr,Fe),or.STAT_EVENT="statevent",De(hr,Fe),or.Qa="timingevent",De(fr,Fe);var gr={NO_ERROR:0,mb:1,zb:2,yb:3,tb:4,xb:5,Ab:6,Ma:7,TIMEOUT:8,Db:9},mr={rb:"complete",Nb:"success",Na:"error",Ma:"abort",Fb:"ready",Gb:"readystatechange",TIMEOUT:"timeout",Bb:"incrementaldata",Eb:"progress",ub:"downloadprogress",Vb:"uploadprogress"};function yr(){}function vr(t){return t.h||(t.h=t.i())}function wr(){}yr.prototype.h=null;var br,Sr={OPEN:"a",qb:"b",Na:"c",Cb:"d"};function _r(){Fe.call(this,"d")}function Er(){Fe.call(this,"c")}function Tr(){}function Ir(t,e,n,r){this.l=t,this.j=e,this.m=n,this.U=r||1,this.S=new tr(this),this.O=Cr,t=Je?125:void 0,this.T=new Qn(t),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.V=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.Y=-1,this.I=!1,this.N=0,this.L=null,this.$=this.J=this.Z=this.P=!1,this.h=new kr}function kr(){this.i=null,this.g="",this.h=!1}De(_r,Fe),De(Er,Fe),De(Tr,yr),Tr.prototype.g=function(){return new XMLHttpRequest},Tr.prototype.i=function(){return{}},br=new Tr;var Cr=45e3,Ar={},Rr={};function Nr(t,e,n){t.K=1,t.v=Qr($r(e)),t.s=n,t.P=!0,Lr(t,null)}function Lr(t,e){t.F=Date.now(),xr(t),t.A=$r(t.v);var n=t.A,r=t.U;Array.isArray(r)||(r=[String(r)]),ci(n.i,"t",r),t.C=0,n=t.l.H,t.h=new kr,t.g=cs(t.l,n?e:null,!t.s),0<t.N&&(t.L=new Zn(Le(t.La,t,t.g),t.N)),nr(t.S,t.g,"readystatechange",t.ib),e=t.H?yn(t.H):{},t.s?(t.u||(t.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",t.g.da(t.A,t.u,t.s,e)):(t.u="GET",t.g.da(t.A,t.u,null,e)),ur(),function(t,e,n,r,i,s){t.info((function(){if(t.g)if(s)for(var o="",a=s.split("&"),c=0;c<a.length;c++){var l=a[c].split("=");if(1<l.length){var u=l[0];l=l[1];var h=u.split("_");o=2<=h.length&&"type"==h[1]?o+(u+"=")+l+"&":o+(u+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+e+"\n"+n+"\n"+o}))}(t.j,t.u,t.A,t.m,t.U,t.s)}function Or(t){return!!t.g&&("GET"==t.u&&2!=t.K&&t.l.Da)}function Dr(t,e,n){for(var r,i=!0;!t.I&&t.C<n.length;){if((r=Pr(t,n))==Rr){4==e&&(t.o=4,dr(14),i=!1),sr(t.j,t.m,null,"[Incomplete Response]");break}if(r==Ar){t.o=4,dr(15),sr(t.j,t.m,n,"[Invalid Chunk]"),i=!1;break}sr(t.j,t.m,r,null),Br(t,r)}Or(t)&&r!=Rr&&r!=Ar&&(t.h.g="",t.C=0),4!=e||0!=n.length||t.h.h||(t.o=1,dr(16),i=!1),t.i=t.i&&i,i?0<n.length&&!t.$&&(t.$=!0,(e=t.l).g==t&&e.$&&!e.K&&(e.j.info("Great, no buffering proxy detected. Bytes received: "+n.length),ts(e),e.K=!0,dr(11))):(sr(t.j,t.m,n,"[Invalid Chunked Response]"),zr(t),Fr(t))}function Pr(t,e){var n=t.C,r=e.indexOf("\n",n);return-1==r?Rr:(n=Number(e.substring(n,r)),isNaN(n)?Ar:(r+=1)+n>e.length?Rr:(e=e.substr(r,n),t.C=r+n,e))}function xr(t){t.V=Date.now()+t.O,Mr(t,t.O)}function Mr(t,e){if(null!=t.B)throw Error("WatchDog timer not null");t.B=pr(Le(t.gb,t),e)}function Ur(t){t.B&&(Ee.clearTimeout(t.B),t.B=null)}function Fr(t){0==t.l.G||t.I||rs(t.l,t)}function zr(t){Ur(t);var e=t.L;e&&"function"==typeof e.na&&e.na(),t.L=null,Yn(t.T),rr(t.S),t.g&&(e=t.g,t.g=null,e.abort(),e.na())}function Br(t,e){try{var n=t.l;if(0!=n.G&&(n.g==t||gi(n.h,t)))if(!t.J&&gi(n.h,t)&&3==n.G){try{var r=n.Fa.g.parse(e)}catch(s){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){t:if(!n.u){if(n.g){if(!(n.g.F+3e3<t.F))break t;ns(n),Wi(n)}Zi(n),dr(18)}}else n.Ba=i[1],0<n.Ba-n.T&&37500>i[2]&&n.L&&0==n.A&&!n.v&&(n.v=pr(Le(n.cb,n),6e3));if(1>=pi(n.h)&&n.ja){try{n.ja()}catch(s){}n.ja=void 0}}else ss(n,11)}else if((t.J||n.g==t)&&ns(n),!Be(e))for(i=n.Fa.g.parse(e),e=0;e<i.length;e++){var s=i[e];if(n.T=s[0],s=s[1],2==n.G)if("c"==s[0]){n.I=s[1],n.ka=s[2];var o=s[3];null!=o&&(n.ma=o,n.j.info("VER="+n.ma));var a=s[4];null!=a&&(n.Ca=a,n.j.info("SVER="+n.Ca));var c=s[5];null!=c&&"number"==typeof c&&0<c&&(r=1.5*c,n.J=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;var l=t.g;if(l){var u=l.g?l.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(u){var h=r.h;h.g||-1==u.indexOf("spdy")&&-1==u.indexOf("quic")&&-1==u.indexOf("h2")||(h.j=h.l,h.g=new Set,h.h&&(mi(h,h.h),h.h=null))}if(r.D){var d=l.g?l.g.getResponseHeader("X-HTTP-Session-Id"):null;d&&(r.za=d,Gr(r.F,r.D,d))}}n.G=3,n.l&&n.l.xa(),n.$&&(n.P=Date.now()-t.F,n.j.info("Handshake RTT: "+n.P+"ms"));var f=t;if((r=n).sa=as(r,r.H?r.ka:null,r.V),f.J){yi(r.h,f);var p=f,g=r.J;g&&p.setTimeout(g),p.B&&(Ur(p),xr(p)),r.g=f}else Xi(r);0<n.i.length&&Gi(n)}else"stop"!=s[0]&&"close"!=s[0]||ss(n,7);else 3==n.G&&("stop"==s[0]||"close"==s[0]?"stop"==s[0]?ss(n,7):qi(n):"noop"!=s[0]&&n.l&&n.l.wa(s),n.A=0)}ur()}catch(s){}}function Vr(t,e){if(t.forEach&&"function"==typeof t.forEach)t.forEach(e,void 0);else if(Ie(t)||"string"==typeof t)Array.prototype.forEach.call(t,e,void 0);else for(var n=function(t){if(t.oa&&"function"==typeof t.oa)return t.oa();if(!t.W||"function"!=typeof t.W){if("undefined"!=typeof Map&&t instanceof Map)return Array.from(t.keys());if(!("undefined"!=typeof Set&&t instanceof Set)){if(Ie(t)||"string"==typeof t){var e=[];t=t.length;for(var n=0;n<t;n++)e.push(n);return e}for(var r in e=[],n=0,t)e[n++]=r;return e}}}(t),r=function(t){if(t.W&&"function"==typeof t.W)return t.W();if("undefined"!=typeof Map&&t instanceof Map||"undefined"!=typeof Set&&t instanceof Set)return Array.from(t.values());if("string"==typeof t)return t.split("");if(Ie(t)){for(var e=[],n=t.length,r=0;r<n;r++)e.push(t[r]);return e}for(r in e=[],n=0,t)e[n++]=t[r];return e}(t),i=r.length,s=0;s<i;s++)e.call(void 0,r[s],n&&n[s],t)}(be=Ir.prototype).setTimeout=function(t){this.O=t},be.ib=function(t){t=t.target;var e=this.L;e&&3==zi(t)?e.l():this.La(t)},be.La=function(t){try{if(t==this.g)t:{var e=zi(this.g),n=this.g.Ea();this.g.aa();if(!(3>e)&&(3!=e||Je||this.g&&(this.h.h||this.g.fa()||Bi(this.g)))){this.I||4!=e||7==n||ur(),Ur(this);var r=this.g.aa();this.Y=r;e:if(Or(this)){var i=Bi(this.g);t="";var s=i.length,o=4==zi(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){zr(this),Fr(this);var a="";break e}this.h.i=new Ee.TextDecoder}for(n=0;n<s;n++)this.h.h=!0,t+=this.h.i.decode(i[n],{stream:o&&n==s-1});i.splice(0,s),this.h.g+=t,this.C=0,a=this.h.g}else a=this.g.fa();if(this.i=200==r,function(t,e,n,r,i,s,o){t.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+e+"\n"+n+"\n"+s+" "+o}))}(this.j,this.u,this.A,this.m,this.U,e,r),this.i){if(this.Z&&!this.J){e:{if(this.g){var c,l=this.g;if((c=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!Be(c)){var u=c;break e}}u=null}if(!(r=u)){this.i=!1,this.o=3,dr(12),zr(this),Fr(this);break t}sr(this.j,this.m,r,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,Br(this,r)}this.P?(Dr(this,e,a),Je&&this.i&&3==e&&(nr(this.S,this.T,"tick",this.hb),this.T.start())):(sr(this.j,this.m,a,null),Br(this,a)),4==e&&zr(this),this.i&&!this.I&&(4==e?rs(this.l,this):(this.i=!1,xr(this)))}else 400==r&&0<a.indexOf("Unknown SID")?(this.o=3,dr(12)):(this.o=0,dr(13)),zr(this),Fr(this)}}}catch(e){}},be.hb=function(){if(this.g){var t=zi(this.g),e=this.g.fa();this.C<e.length&&(Ur(this),Dr(this,t,e),this.i&&4!=t&&xr(this))}},be.cancel=function(){this.I=!0,zr(this)},be.gb=function(){this.B=null;var t=Date.now();0<=t-this.V?(function(t,e){t.info((function(){return"TIMEOUT: "+e}))}(this.j,this.A),2!=this.K&&(ur(),dr(17)),zr(this),this.o=2,Fr(this)):Mr(this,this.V-t)};var Hr=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function jr(t,e){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,t instanceof jr){this.h=void 0!==e?e:t.h,qr(this,t.j),this.s=t.s,this.g=t.g,Wr(this,t.m),this.l=t.l,e=t.i;var n=new ii;n.i=e.i,e.g&&(n.g=new Map(e.g),n.h=e.h),Kr(this,n),this.o=t.o}else t&&(n=String(t).match(Hr))?(this.h=!!e,qr(this,n[1]||"",!0),this.s=Yr(n[2]||""),this.g=Yr(n[3]||"",!0),Wr(this,n[4]),this.l=Yr(n[5]||"",!0),Kr(this,n[6]||"",!0),this.o=Yr(n[7]||"")):(this.h=!!e,this.i=new ii(null,this.h))}function $r(t){return new jr(t)}function qr(t,e,n){t.j=n?Yr(e,!0):e,t.j&&(t.j=t.j.replace(/:$/,""))}function Wr(t,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);t.m=e}else t.m=null}function Kr(t,e,n){e instanceof ii?(t.i=e,function(t,e){e&&!t.j&&(si(t),t.i=null,t.g.forEach((function(t,e){var n=e.toLowerCase();e!=n&&(oi(this,e),ci(this,n,t))}),t)),t.j=e}(t.i,t.h)):(n||(e=Jr(e,ni)),t.i=new ii(e,t.h))}function Gr(t,e,n){t.i.set(e,n)}function Qr(t){return Gr(t,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),t}function Yr(t,e){return t?e?decodeURI(t.replace(/%25/g,"%2525")):decodeURIComponent(t):""}function Jr(t,e,n){return"string"==typeof t?(t=encodeURI(t).replace(e,Xr),n&&(t=t.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t):null}function Xr(t){return"%"+((t=t.charCodeAt(0))>>4&15).toString(16)+(15&t).toString(16)}jr.prototype.toString=function(){var t=[],e=this.j;e&&t.push(Jr(e,Zr,!0),":");var n=this.g;return(n||"file"==e)&&(t.push("//"),(e=this.s)&&t.push(Jr(e,Zr,!0),"@"),t.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&&t.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&t.push("/"),t.push(Jr(n,"/"==n.charAt(0)?ei:ti,!0))),(n=this.i.toString())&&t.push("?",n),(n=this.o)&&t.push("#",Jr(n,ri)),t.join("")};var Zr=/[#\/\?@]/g,ti=/[#\?:]/g,ei=/[#\?]/g,ni=/[#\?@]/g,ri=/#/g;function ii(t,e){this.h=this.g=null,this.i=t||null,this.j=!!e}function si(t){t.g||(t.g=new Map,t.h=0,t.i&&function(t,e){if(t){t=t.split("&");for(var n=0;n<t.length;n++){var r=t[n].indexOf("="),i=null;if(0<=r){var s=t[n].substring(0,r);i=t[n].substring(r+1)}else s=t[n];e(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(t.i,(function(e,n){t.add(decodeURIComponent(e.replace(/\+/g," ")),n)})))}function oi(t,e){si(t),e=li(t,e),t.g.has(e)&&(t.i=null,t.h-=t.g.get(e).length,t.g.delete(e))}function ai(t,e){return si(t),e=li(t,e),t.g.has(e)}function ci(t,e,n){oi(t,e),0<n.length&&(t.i=null,t.g.set(li(t,e),Me(n)),t.h+=n.length)}function li(t,e){return e=String(e),t.j&&(e=e.toLowerCase()),e}(be=ii.prototype).add=function(t,e){si(this),this.i=null,t=li(this,t);var n=this.g.get(t);return n||this.g.set(t,n=[]),n.push(e),this.h+=1,this},be.forEach=function(t,e){si(this),this.g.forEach((function(n,r){n.forEach((function(n){t.call(e,n,r,this)}),this)}),this)},be.oa=function(){si(this);for(var t=Array.from(this.g.values()),e=Array.from(this.g.keys()),n=[],r=0;r<e.length;r++)for(var i=t[r],s=0;s<i.length;s++)n.push(e[r]);return n},be.W=function(t){si(this);var e=[];if("string"==typeof t)ai(this,t)&&(e=e.concat(this.g.get(li(this,t))));else{t=Array.from(this.g.values());for(var n=0;n<t.length;n++)e=e.concat(t[n])}return e},be.set=function(t,e){return si(this),this.i=null,ai(this,t=li(this,t))&&(this.h-=this.g.get(t).length),this.g.set(t,[e]),this.h+=1,this},be.get=function(t,e){return t&&0<(t=this.W(t)).length?String(t[0]):e},be.toString=function(){if(this.i)return this.i;if(!this.g)return"";for(var t=[],e=Array.from(this.g.keys()),n=0;n<e.length;n++){var r=e[n],i=encodeURIComponent(String(r)),s=this.W(r);for(r=0;r<s.length;r++){var o=i;""!==s[r]&&(o+="="+encodeURIComponent(String(s[r]))),t.push(o)}}return this.i=t.join("&")};var ui=function(t,e){this.h=t,this.g=e};function hi(t){this.l=t||di,Ee.PerformanceNavigationTiming?t=0<(t=Ee.performance.getEntriesByType("navigation")).length&&("hq"==t[0].nextHopProtocol||"h2"==t[0].nextHopProtocol):t=!!(Ee.g&&Ee.g.Ga&&Ee.g.Ga()&&Ee.g.Ga().$b),this.j=t?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var di=10;function fi(t){return!!t.h||!!t.g&&t.g.size>=t.j}function pi(t){return t.h?1:t.g?t.g.size:0}function gi(t,e){return t.h?t.h==e:!!t.g&&t.g.has(e)}function mi(t,e){t.g?t.g.add(e):t.h=e}function yi(t,e){t.h&&t.h==e?t.h=null:t.g&&t.g.has(e)&&t.g.delete(e)}function vi(t){var e,n;if(null!=t.h)return t.i.concat(t.h.D);if(null!=t.g&&0!==t.g.size){var r=t.i;try{for(var i=ve(t.g.values()),s=i.next();!s.done;s=i.next()){var o=s.value;r=r.concat(o.D)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}return Me(t.i)}function wi(){}function bi(){this.g=new wi}function Si(t,e,n){var r=n||"";try{Vr(t,(function(t,n){var i=t;ke(t)&&(i=Fn(t)),e.push(r+n+"="+encodeURIComponent(i))}))}catch(t){throw e.push(r+"type="+encodeURIComponent("_badmap")),t}}function _i(t,e,n,r,i){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,i(r)}catch(t){}}function Ei(t){this.l=t.ac||null,this.j=t.jb||!1}function Ti(t,e){xn.call(this),this.D=t,this.u=e,this.m=void 0,this.readyState=Ii,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}hi.prototype.cancel=function(){var t,e;if(this.i=vi(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){try{for(var n=ve(this.g.values()),r=n.next();!r.done;r=n.next()){r.value.cancel()}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}this.g.clear()}},wi.prototype.stringify=function(t){return Ee.JSON.stringify(t,void 0)},wi.prototype.parse=function(t){return Ee.JSON.parse(t,void 0)},De(Ei,yr),Ei.prototype.g=function(){return new Ti(this.l,this.j)},Ei.prototype.i=function(t){return function(){return t}}({}),De(Ti,xn);var Ii=0;function ki(t){t.j.read().then(t.Ta.bind(t)).catch(t.ga.bind(t))}function Ci(t){t.readyState=4,t.l=null,t.j=null,t.A=null,Ai(t)}function Ai(t){t.onreadystatechange&&t.onreadystatechange.call(t)}(be=Ti.prototype).open=function(t,e){if(this.readyState!=Ii)throw this.abort(),Error("Error reopening a connection");this.C=t,this.B=e,this.readyState=1,Ai(this)},be.send=function(t){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;var e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};t&&(e.body=t),(this.D||Ee).fetch(new Request(this.B,e)).then(this.Wa.bind(this),this.ga.bind(this))},be.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch((function(){})),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Ci(this)),this.readyState=Ii},be.Wa=function(t){if(this.g&&(this.l=t,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=t.headers,this.readyState=2,Ai(this)),this.g&&(this.readyState=3,Ai(this),this.g)))if("arraybuffer"===this.responseType)t.arrayBuffer().then(this.Ua.bind(this),this.ga.bind(this));else if(void 0!==Ee.ReadableStream&&"body"in t){if(this.j=t.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;ki(this)}else t.text().then(this.Va.bind(this),this.ga.bind(this))},be.Ta=function(t){if(this.g){if(this.u&&t.value)this.response.push(t.value);else if(!this.u){var e=t.value?t.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!t.done}))&&(this.response=this.responseText+=e)}t.done?Ci(this):Ai(this),3==this.readyState&&ki(this)}},be.Va=function(t){this.g&&(this.response=this.responseText=t,Ci(this))},be.Ua=function(t){this.g&&(this.response=t,Ci(this))},be.ga=function(){this.g&&Ci(this)},be.setRequestHeader=function(t,e){this.v.append(t,e)},be.getResponseHeader=function(t){return this.h&&this.h.get(t.toLowerCase())||""},be.getAllResponseHeaders=function(){if(!this.h)return"";for(var t=[],e=this.h.entries(),n=e.next();!n.done;)n=n.value,t.push(n[0]+": "+n[1]),n=e.next();return t.join("\r\n")},Object.defineProperty(Ti.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(t){this.m=t?"include":"same-origin"}});var Ri=Ee.JSON.parse;function Ni(t){xn.call(this),this.headers=new Map,this.u=t||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=Li,this.K=this.L=!1}De(Ni,xn);var Li="",Oi=/^https?$/i,Di=["POST","PUT"];function Pi(t,e){t.h=!1,t.g&&(t.l=!0,t.g.abort(),t.l=!1),t.j=e,t.m=5,xi(t),Ui(t)}function xi(t){t.D||(t.D=!0,Mn(t,"complete"),Mn(t,"error"))}function Mi(t){if(t.h&&void 0!==_e&&(!t.C[1]||4!=zi(t)||2!=t.aa()))if(t.v&&4==zi(t))Jn(t.Ha,0,t);else if(Mn(t,"readystatechange"),4==zi(t)){t.h=!1;try{var e,n=t.aa();t:switch(n){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var r=!0;break t;default:r=!1}if(!(e=r)){var i;if(i=0===n){var s=String(t.H).match(Hr)[1]||null;if(!s&&Ee.self&&Ee.self.location){var o=Ee.self.location.protocol;s=o.substr(0,o.length-1)}i=!Oi.test(s?s.toLowerCase():"")}e=i}if(e)Mn(t,"complete"),Mn(t,"success");else{t.m=6;try{var a=2<zi(t)?t.g.statusText:""}catch(t){a=""}t.j=a+" ["+t.aa()+"]",xi(t)}}finally{Ui(t)}}}function Ui(t,e){if(t.g){Fi(t);var n=t.g,r=t.C[0]?Te:null;t.g=null,t.C=null,e||Mn(t,"ready");try{n.onreadystatechange=r}catch(t){}}}function Fi(t){t.g&&t.K&&(t.g.ontimeout=null),t.A&&(Ee.clearTimeout(t.A),t.A=null)}function zi(t){return t.g?t.g.readyState:0}function Bi(t){try{if(!t.g)return null;if("response"in t.g)return t.g.response;switch(t.J){case Li:case"text":return t.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in t.g)return t.g.mozResponseArrayBuffer}return null}catch(t){return null}}function Vi(t){var e="";return mn(t,(function(t,n){e+=n,e+=":",e+=t,e+="\r\n"})),e}function Hi(t,e,n){t:{for(r in n){var r=!1;break t}r=!0}r||(n=Vi(n),"string"==typeof t?null!=n&&encodeURIComponent(String(n)):Gr(t,e,n))}function ji(t,e,n){return n&&n.internalChannelParams&&n.internalChannelParams[t]||e}function $i(t){this.Ca=0,this.i=[],this.j=new ir,this.ka=this.sa=this.F=this.V=this.g=this.za=this.D=this.ia=this.o=this.S=this.s=null,this.ab=this.U=0,this.Za=ji("failFast",!1,t),this.L=this.v=this.u=this.m=this.l=null,this.Y=!0,this.pa=this.Ba=this.T=-1,this.Z=this.A=this.C=0,this.Xa=ji("baseRetryDelayMs",5e3,t),this.bb=ji("retryDelaySeedMs",1e4,t),this.$a=ji("forwardChannelMaxRetries",2,t),this.ta=ji("forwardChannelRequestTimeoutMs",2e4,t),this.ra=t&&t.xmlHttpFactory||void 0,this.Da=t&&t.Zb||!1,this.J=void 0,this.H=t&&t.supportsCrossDomainXhr||!1,this.I="",this.h=new hi(t&&t.concurrentRequestLimit),this.Fa=new bi,this.O=t&&t.fastHandshake||!1,this.N=t&&t.encodeInitMessageHeaders||!1,this.O&&this.N&&(this.N=!1),this.Ya=t&&t.Xb||!1,t&&t.Aa&&this.j.Aa(),t&&t.forceLongPolling&&(this.Y=!1),this.$=!this.O&&this.Y&&t&&t.detectBufferingProxy||!1,this.ja=void 0,this.P=0,this.K=!1,this.la=this.B=null}function qi(t){if(Ki(t),3==t.G){var e=t.U++,n=$r(t.F);Gr(n,"SID",t.I),Gr(n,"RID",e),Gr(n,"TYPE","terminate"),Yi(t,n),(e=new Ir(t,t.j,e,void 0)).K=2,e.v=Qr($r(n)),n=!1,Ee.navigator&&Ee.navigator.sendBeacon&&(n=Ee.navigator.sendBeacon(e.v.toString(),"")),!n&&Ee.Image&&((new Image).src=e.v,n=!0),n||(e.g=cs(e.l,null),e.g.da(e.v)),e.F=Date.now(),xr(e)}os(t)}function Wi(t){t.g&&(ts(t),t.g.cancel(),t.g=null)}function Ki(t){Wi(t),t.u&&(Ee.clearTimeout(t.u),t.u=null),ns(t),t.h.cancel(),t.m&&("number"==typeof t.m&&Ee.clearTimeout(t.m),t.m=null)}function Gi(t){fi(t.h)||t.m||(t.m=!0,qn(t.Ja,t),t.C=0)}function Qi(t,e){var n;n=e?e.m:t.U++;var r=$r(t.F);Gr(r,"SID",t.I),Gr(r,"RID",n),Gr(r,"AID",t.T),Yi(t,r),t.o&&t.s&&Hi(r,t.o,t.s),n=new Ir(t,t.j,n,t.C+1),null===t.o&&(n.H=t.s),e&&(t.i=e.D.concat(t.i)),e=Ji(t,n,1e3),n.setTimeout(Math.round(.5*t.ta)+Math.round(.5*t.ta*Math.random())),mi(t.h,n),Nr(n,r,e)}function Yi(t,e){t.ia&&mn(t.ia,(function(t,n){Gr(e,n,t)})),t.l&&Vr({},(function(t,n){Gr(e,n,t)}))}function Ji(t,e,n){n=Math.min(t.i.length,n);var r=t.l?Le(t.l.Ra,t.l,t):null;t:for(var i=t.i,s=-1;;){var o=["count="+n];-1==s?0<n?(s=i[0].h,o.push("ofs="+s)):s=0:o.push("ofs="+s);for(var a=!0,c=0;c<n;c++){var l=i[c].h,u=i[c].g;if(0>(l-=s))s=Math.max(0,i[c].h-100),a=!1;else try{Si(u,o,"req"+l+"_")}catch(t){r&&r(u)}}if(a){r=o.join("&");break t}}return t=t.i.splice(0,n),e.D=t,r}function Xi(t){t.g||t.u||(t.Z=1,qn(t.Ia,t),t.A=0)}function Zi(t){return!(t.g||t.u||3<=t.A)&&(t.Z++,t.u=pr(Le(t.Ia,t),is(t,t.A)),t.A++,!0)}function ts(t){null!=t.B&&(Ee.clearTimeout(t.B),t.B=null)}function es(t){t.g=new Ir(t,t.j,"rpc",t.Z),null===t.o&&(t.g.H=t.s),t.g.N=0;var e=$r(t.sa);Gr(e,"RID","rpc"),Gr(e,"SID",t.I),Gr(e,"CI",t.L?"0":"1"),Gr(e,"AID",t.T),Gr(e,"TYPE","xmlhttp"),Yi(t,e),t.o&&t.s&&Hi(e,t.o,t.s),t.J&&t.g.setTimeout(t.J);var n=t.g;t=t.ka,n.K=1,n.v=Qr($r(e)),n.s=null,n.P=!0,Lr(n,t)}function ns(t){null!=t.v&&(Ee.clearTimeout(t.v),t.v=null)}function rs(t,e){var n=null;if(t.g==e){ns(t),ts(t),t.g=null;var r=2}else{if(!gi(t.h,e))return;n=e.D,yi(t.h,e),r=1}if(0!=t.G)if(t.pa=e.Y,e.i)if(1==r){n=e.s?e.s.length:0,e=Date.now()-e.F;var i=t.C;Mn(r=cr(),new fr(r,n)),Gi(t)}else Xi(t);else if(3==(i=e.o)||0==i&&0<t.pa||!(1==r&&function(t,e){return!(pi(t.h)>=t.h.j-(t.m?1:0)||(t.m?(t.i=e.D.concat(t.i),0):1==t.G||2==t.G||t.C>=(t.Za?0:t.$a)||(t.m=pr(Le(t.Ja,t,e),is(t,t.C)),t.C++,0)))}(t,e)||2==r&&Zi(t)))switch(n&&0<n.length&&(e=t.h,e.i=e.i.concat(n)),i){case 1:ss(t,5);break;case 4:ss(t,10);break;case 3:ss(t,6);break;default:ss(t,2)}}function is(t,e){var n=t.Xa+Math.floor(Math.random()*t.bb);return t.l||(n*=2),n*e}function ss(t,e){if(t.j.info("Error code "+e),2==e){var n=null;t.l&&(n=null);var r=Le(t.kb,t);n||(n=new jr("//www.google.com/images/cleardot.gif"),Ee.location&&"http"==Ee.location.protocol||qr(n,"https"),Qr(n)),function(t,e){var n=new ir;if(Ee.Image){var r=new Image;r.onload=Oe(_i,n,r,"TestLoadImage: loaded",!0,e),r.onerror=Oe(_i,n,r,"TestLoadImage: error",!1,e),r.onabort=Oe(_i,n,r,"TestLoadImage: abort",!1,e),r.ontimeout=Oe(_i,n,r,"TestLoadImage: timeout",!1,e),Ee.setTimeout((function(){r.ontimeout&&r.ontimeout()}),1e4),r.src=t}else e(!1)}(n.toString(),r)}else dr(2);t.G=0,t.l&&t.l.va(e),os(t),Ki(t)}function os(t){if(t.G=0,t.la=[],t.l){var e=vi(t.h);0==e.length&&0==t.i.length||(Ue(t.la,e),Ue(t.la,t.i),t.h.i.length=0,Me(t.i),t.i.length=0),t.l.ua()}}function as(t,e,n){var r=n instanceof jr?$r(n):new jr(n,void 0);if(""!=r.g)e&&(r.g=e+"."+r.g),Wr(r,r.m);else{var i=Ee.location;r=i.protocol,e=e?e+"."+i.hostname:i.hostname,i=+i.port;var s=new jr(null,void 0);r&&qr(s,r),e&&(s.g=e),i&&Wr(s,i),n&&(s.l=n),r=s}return n=t.D,e=t.za,n&&e&&Gr(r,n,e),Gr(r,"VER",t.ma),Yi(t,r),r}function cs(t,e,n){if(e&&!t.H)throw Error("Can't create secondary domain capable XhrIo object.");return(e=n&&t.Da&&!t.ra?new Ni(new Ei({jb:!0})):new Ni(t.ra)).Ka(t.H),e}function ls(){}function us(){if(Qe&&!(10<=Number(ln)))throw Error("Environmental error: no available transport.")}function hs(t,e){xn.call(this),this.g=new $i(e),this.l=t,this.h=e&&e.messageUrlParams||null,t=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(t?t["X-Client-Protocol"]="webchannel":t={"X-Client-Protocol":"webchannel"}),this.g.s=t,t=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(t?t["X-WebChannel-Content-Type"]=e.messageContentType:t={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.ya&&(t?t["X-WebChannel-Client-Profile"]=e.ya:t={"X-WebChannel-Client-Profile":e.ya}),this.g.S=t,(t=e&&e.Yb)&&!Be(t)&&(this.g.o=t),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!Be(e)&&(this.g.D=e,null!==(t=this.h)&&e in t&&(e in(t=this.h)&&delete t[e])),this.j=new ps(this)}function ds(t){_r.call(this);var e=t.__sm__;if(e){t:{for(var n in e){t=n;break t}t=void 0}(this.i=t)&&(t=this.i,e=null!==e&&t in e?e[t]:void 0),this.data=e}else this.data=t}function fs(){Er.call(this),this.status=1}function ps(t){this.g=t}(be=Ni.prototype).Ka=function(t){this.L=t},be.da=function(t,e,n,r){var i,s,o,a;if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+t);e=e?e.toUpperCase():"GET",this.H=t,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():br.g(),this.C=this.u?vr(this.u):vr(br),this.g.onreadystatechange=Le(this.Ha,this);try{this.F=!0,this.g.open(e,String(t),!0),this.F=!1}catch(h){return void Pi(this,h)}if(t=n||"",n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var c in r)n.set(c,r[c]);else{if("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));try{for(var l=ve(r.keys()),u=l.next();!u.done;u=l.next()){var h=u.value;n.set(h,r.get(h))}}catch(t){i={error:t}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}}r=Array.from(n.keys()).find((function(t){return"content-type"==t.toLowerCase()})),c=Ee.FormData&&t instanceof Ee.FormData,!(0<=xe(Di,e))||r||c||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");try{for(var d=ve(n),f=d.next();!f.done;f=d.next()){var p=we(f.value,2),g=(h=p[0],p[1]);this.g.setRequestHeader(h,g)}}catch(t){o={error:t}}finally{try{f&&!f.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{Fi(this),0<this.B&&((this.K=function(t){return Qe&&an()&&"number"==typeof t.timeout&&void 0!==t.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=Le(this.qa,this)):this.A=Jn(this.qa,this.B,this)),this.v=!0,this.g.send(t),this.v=!1}catch(h){Pi(this,h)}},be.qa=function(){void 0!==_e&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,Mn(this,"timeout"),this.abort(8))},be.abort=function(t){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=t||7,Mn(this,"complete"),Mn(this,"abort"),Ui(this))},be.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Ui(this,!0)),Ni.X.M.call(this)},be.Ha=function(){this.s||(this.F||this.v||this.l?Mi(this):this.fb())},be.fb=function(){Mi(this)},be.aa=function(){try{return 2<zi(this)?this.g.status:-1}catch(t){return-1}},be.fa=function(){try{return this.g?this.g.responseText:""}catch(t){return""}},be.Sa=function(t){if(this.g){var e=this.g.responseText;return t&&0==e.indexOf(t)&&(e=e.substring(t.length)),Ri(e)}},be.Ea=function(){return this.m},be.Oa=function(){return"string"==typeof this.j?this.j:String(this.j)},(be=$i.prototype).ma=8,be.G=1,be.Ja=function(t){if(this.m)if(this.m=null,1==this.G){if(!t){this.U=Math.floor(1e5*Math.random()),t=this.U++;var e=new Ir(this,this.j,t,void 0),n=this.s;if(this.S&&(n?wn(n=yn(n),this.S):n=this.S),null!==this.o||this.N||(e.H=n,n=null),this.O)t:{for(var r=0,i=0;i<this.i.length;i++){var s=this.i[i];if(void 0===(s="__data__"in s.g&&"string"==typeof(s=s.g.__data__)?s.length:void 0))break;if(4096<(r+=s)){r=i;break t}if(4096===r||i===this.i.length-1){r=i+1;break t}}r=1e3}else r=1e3;r=Ji(this,e,r),Gr(i=$r(this.F),"RID",t),Gr(i,"CVER",22),this.D&&Gr(i,"X-HTTP-Session-Id",this.D),Yi(this,i),n&&(this.N?r="headers="+encodeURIComponent(String(Vi(n)))+"&"+r:this.o&&Hi(i,this.o,n)),mi(this.h,e),this.Ya&&Gr(i,"TYPE","init"),this.O?(Gr(i,"$req",r),Gr(i,"SID","null"),e.Z=!0,Nr(e,i,null)):Nr(e,i,r),this.G=2}}else 3==this.G&&(t?Qi(this,t):0==this.i.length||fi(this.h)||Qi(this))},be.Ia=function(){if(this.u=null,es(this),this.$&&!(this.K||null==this.g||0>=this.P)){var t=2*this.P;this.j.info("BP detection timer enabled: "+t),this.B=pr(Le(this.eb,this),t)}},be.eb=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.L=!1,this.K=!0,dr(10),Wi(this),es(this))},be.cb=function(){null!=this.v&&(this.v=null,Wi(this),Zi(this),dr(19))},be.kb=function(t){t?(this.j.info("Successfully pinged google.com"),dr(2)):(this.j.info("Failed to ping google.com"),dr(1))},(be=ls.prototype).xa=function(){},be.wa=function(){},be.va=function(){},be.ua=function(){},be.Ra=function(){},us.prototype.g=function(t,e){return new hs(t,e)},De(hs,xn),hs.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.H=!0);var t=this.g,e=this.l,n=this.h||void 0;dr(0),t.V=e,t.ia=n||{},t.L=t.Y,t.F=as(t,null,t.V),Gi(t)},hs.prototype.close=function(){qi(this.g)},hs.prototype.u=function(t){var e=this.g;if("string"==typeof t){var n={};n.__data__=t,t=n}else this.v&&((n={}).__data__=Fn(t),t=n);e.i.push(new ui(e.ab++,t)),3==e.G&&Gi(e)},hs.prototype.M=function(){this.g.l=null,delete this.j,qi(this.g),delete this.g,hs.X.M.call(this)},De(ds,_r),De(fs,Er),De(ps,ls),ps.prototype.xa=function(){Mn(this.g,"a")},ps.prototype.wa=function(t){Mn(this.g,new ds(t))},ps.prototype.va=function(t){Mn(this.g,new fs)},ps.prototype.ua=function(){Mn(this.g,"b")},us.prototype.createWebChannel=us.prototype.g,hs.prototype.send=hs.prototype.u,hs.prototype.open=hs.prototype.m,hs.prototype.close=hs.prototype.close,gr.NO_ERROR=0,gr.TIMEOUT=8,gr.HTTP_ERROR=6,mr.COMPLETE="complete",wr.EventType=Sr,Sr.OPEN="a",Sr.CLOSE="b",Sr.ERROR="c",Sr.MESSAGE="d",xn.prototype.listen=xn.prototype.N,Ni.prototype.listenOnce=Ni.prototype.O,Ni.prototype.getLastError=Ni.prototype.Oa,Ni.prototype.getLastErrorCode=Ni.prototype.Ea,Ni.prototype.getStatus=Ni.prototype.aa,Ni.prototype.getResponseJson=Ni.prototype.Sa,Ni.prototype.getResponseText=Ni.prototype.fa,Ni.prototype.send=Ni.prototype.da,Ni.prototype.setWithCredentials=Ni.prototype.Ka;var gs=gr,ms=mr,ys=or,vs=10,ws=11,bs=Ei,Ss=wr,_s=Ni;const Es="@firebase/firestore";
401
401
  /**
402
402
  * @license
403
403
  * Copyright 2017 Google LLC
@@ -752,7 +752,7 @@ class fo{constructor(t,e,n,r,i,s,o,a){this.databaseId=t,this.appId=e,this.persis
752
752
  * See the License for the specific language governing permissions and
753
753
  * limitations under the License.
754
754
  */
755
- class So{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new So(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t);return new So(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return t=this.binaryString,btoa(t);var t}toUint8Array(){return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}
755
+ class bo{constructor(t){this.binaryString=t}static fromBase64String(t){const e=atob(t);return new bo(e)}static fromUint8Array(t){const e=function(t){let e="";for(let n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(t);return new bo(e)}[Symbol.iterator](){let t=0;return{next:()=>t<this.binaryString.length?{value:this.binaryString.charCodeAt(t++),done:!1}:{value:void 0,done:!0}}}toBase64(){return t=this.binaryString,btoa(t);var t}toUint8Array(){return function(t){const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}
756
756
  /**
757
757
  * @license
758
758
  * Copyright 2020 Google LLC
@@ -768,7 +768,7 @@ class So{constructor(t){this.binaryString=t}static fromBase64String(t){const e=a
768
768
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
769
769
  * See the License for the specific language governing permissions and
770
770
  * limitations under the License.
771
- */(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return Gs(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}So.EMPTY_BYTE_STRING=new So("");const bo=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function _o(t){if(Ds(!!t),"string"==typeof t){let e=0;const n=bo.exec(t);if(Ds(!!n),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:Eo(t.seconds),nanos:Eo(t.nanos)}}function Eo(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function To(t){return"string"==typeof t?So.fromBase64String(t):So.fromUint8Array(t)}
771
+ */(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(t){return Gs(this.binaryString,t.binaryString)}isEqual(t){return this.binaryString===t.binaryString}}bo.EMPTY_BYTE_STRING=new bo("");const So=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function _o(t){if(Ds(!!t),"string"==typeof t){let e=0;const n=So.exec(t);if(Ds(!!n),n[1]){let t=n[1];t=(t+"000000000").substr(0,9),e=Number(t)}const r=new Date(t);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:Eo(t.seconds),nanos:Eo(t.nanos)}}function Eo(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function To(t){return"string"==typeof t?bo.fromBase64String(t):bo.fromUint8Array(t)}
772
772
  /**
773
773
  * @license
774
774
  * Copyright 2020 Google LLC
@@ -945,7 +945,7 @@ class fa{constructor(t){this.comparator=t,this.data=new ua(this.comparator)}has(
945
945
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
946
946
  * See the License for the specific language governing permissions and
947
947
  * limitations under the License.
948
- */class wa{constructor(t,e=null,n=[],r=[],i=null,s=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.ft=null}}function Sa(t,e=null,n=[],r=[],i=null,s=null,o=null){return new wa(t,e,n,r,i,s,o)}function ba(t){const e=Ps(t);if(null===e.ft){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((t=>Jo(t))).join(","),t+="|ob:",t+=e.orderBy.map((t=>function(t){return t.field.canonicalString()+t.dir}(t))).join(","),vo(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((t=>Po(t))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((t=>Po(t))).join(",")),e.ft=t}return e.ft}function _a(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!la(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let n=0;n<t.filters.length;n++)if(!Xo(t.filters[n],e.filters[n]))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!qo(t.startAt,e.startAt)&&qo(t.endAt,e.endAt)}function Ea(t){return no.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}
948
+ */class wa{constructor(t,e=null,n=[],r=[],i=null,s=null,o=null){this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.ft=null}}function ba(t,e=null,n=[],r=[],i=null,s=null,o=null){return new wa(t,e,n,r,i,s,o)}function Sa(t){const e=Ps(t);if(null===e.ft){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map((t=>Jo(t))).join(","),t+="|ob:",t+=e.orderBy.map((t=>function(t){return t.field.canonicalString()+t.dir}(t))).join(","),vo(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((t=>Po(t))).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((t=>Po(t))).join(",")),e.ft=t}return e.ft}function _a(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(let n=0;n<t.orderBy.length;n++)if(!la(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(let n=0;n<t.filters.length;n++)if(!Xo(t.filters[n],e.filters[n]))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!qo(t.startAt,e.startAt)&&qo(t.endAt,e.endAt)}function Ea(t){return no.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}
949
949
  /**
950
950
  * @license
951
951
  * Copyright 2017 Google LLC
@@ -961,7 +961,7 @@ class fa{constructor(t){this.comparator=t,this.data=new ua(this.comparator)}has(
961
961
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
962
962
  * See the License for the specific language governing permissions and
963
963
  * limitations under the License.
964
- */class Ta{constructor(t,e=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.dt=null,this._t=null,this.startAt,this.endAt}}function Ia(t){return new Ta(t)}function ka(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}function Ca(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function Aa(t){for(const e of t.filters){const t=e.getFirstInequalityField();if(null!==t)return t}return null}function Ra(t){return null!==t.collectionGroup}function Na(t){const e=Ps(t);if(null===e.dt){e.dt=[];const t=Aa(e),n=Ca(e);if(null!==t&&null===n)t.isKeyField()||e.dt.push(new ca(t)),e.dt.push(new ca(eo.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e.dt.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.dt.push(new ca(eo.keyField(),t))}}}return e.dt}function La(t){const e=Ps(t);if(!e._t)if("F"===e.limitType)e._t=Sa(e.path,e.collectionGroup,Na(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of Na(e)){const e="desc"===n.dir?"asc":"desc";t.push(new ca(n.field,e))}const n=e.endAt?new jo(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new jo(e.startAt.position,e.startAt.inclusive):null;e._t=Sa(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}return e._t}function Oa(t,e){e.getFirstInequalityField(),Aa(t);const n=t.filters.concat([e]);return new Ta(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}function Da(t,e,n){return new Ta(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Pa(t,e){return _a(La(t),La(e))&&t.limitType===e.limitType}function xa(t){return`${ba(La(t))}|lt:${t.limitType}`}function Ma(t){return`Query(target=${function(t){let e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=`, filters: [${t.filters.map((t=>Zo(t))).join(", ")}]`),vo(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=`, orderBy: [${t.orderBy.map((t=>function(t){return`${t.field.canonicalString()} (${t.dir})`}(t))).join(", ")}]`),t.startAt&&(e+=", startAt: ",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((t=>Po(t))).join(",")),t.endAt&&(e+=", endAt: ",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((t=>Po(t))).join(",")),`Target(${e})`}(La(t))}; limitType=${t.limitType})`}function Ua(t,e){return e.isFoundDocument()&&function(t,e){const n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):no.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(const n of Na(t))if(!n.field.isKeyField()&&null===e.data.field(n.field))return!1;return!0}(t,e)&&function(t,e){for(const n of t.filters)if(!n.matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!function(t,e,n){const r=$o(t,e,n);return t.inclusive?r<=0:r<0}(t.startAt,Na(t),e))&&!(t.endAt&&!function(t,e,n){const r=$o(t,e,n);return t.inclusive?r>=0:r>0}(t.endAt,Na(t),e))}(t,e)}function Fa(t){return(e,n)=>{let r=!1;for(const i of Na(t)){const t=za(i,e,n);if(0!==t)return t;r=r||i.field.isKeyField()}return 0}}function za(t,e,n){const r=t.field.isKeyField()?no.comparator(e.key,n.key):function(t,e,n){const r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?Oo(r,i):Os()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return Os()}}
964
+ */class Ta{constructor(t,e=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.dt=null,this._t=null,this.startAt,this.endAt}}function Ia(t){return new Ta(t)}function ka(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}function Ca(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function Aa(t){for(const e of t.filters){const t=e.getFirstInequalityField();if(null!==t)return t}return null}function Ra(t){return null!==t.collectionGroup}function Na(t){const e=Ps(t);if(null===e.dt){e.dt=[];const t=Aa(e),n=Ca(e);if(null!==t&&null===n)t.isKeyField()||e.dt.push(new ca(t)),e.dt.push(new ca(eo.keyField(),"asc"));else{let t=!1;for(const n of e.explicitOrderBy)e.dt.push(n),n.field.isKeyField()&&(t=!0);if(!t){const t=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.dt.push(new ca(eo.keyField(),t))}}}return e.dt}function La(t){const e=Ps(t);if(!e._t)if("F"===e.limitType)e._t=ba(e.path,e.collectionGroup,Na(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const n of Na(e)){const e="desc"===n.dir?"asc":"desc";t.push(new ca(n.field,e))}const n=e.endAt?new jo(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new jo(e.startAt.position,e.startAt.inclusive):null;e._t=ba(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}return e._t}function Oa(t,e){e.getFirstInequalityField(),Aa(t);const n=t.filters.concat([e]);return new Ta(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}function Da(t,e,n){return new Ta(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Pa(t,e){return _a(La(t),La(e))&&t.limitType===e.limitType}function xa(t){return`${Sa(La(t))}|lt:${t.limitType}`}function Ma(t){return`Query(target=${function(t){let e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=`, filters: [${t.filters.map((t=>Zo(t))).join(", ")}]`),vo(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=`, orderBy: [${t.orderBy.map((t=>function(t){return`${t.field.canonicalString()} (${t.dir})`}(t))).join(", ")}]`),t.startAt&&(e+=", startAt: ",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((t=>Po(t))).join(",")),t.endAt&&(e+=", endAt: ",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((t=>Po(t))).join(",")),`Target(${e})`}(La(t))}; limitType=${t.limitType})`}function Ua(t,e){return e.isFoundDocument()&&function(t,e){const n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):no.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(const n of Na(t))if(!n.field.isKeyField()&&null===e.data.field(n.field))return!1;return!0}(t,e)&&function(t,e){for(const n of t.filters)if(!n.matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!function(t,e,n){const r=$o(t,e,n);return t.inclusive?r<=0:r<0}(t.startAt,Na(t),e))&&!(t.endAt&&!function(t,e,n){const r=$o(t,e,n);return t.inclusive?r>=0:r>0}(t.endAt,Na(t),e))}(t,e)}function Fa(t){return(e,n)=>{let r=!1;for(const i of Na(t)){const t=za(i,e,n);if(0!==t)return t;r=r||i.field.isKeyField()}return 0}}function za(t,e,n){const r=t.field.isKeyField()?no.comparator(e.key,n.key):function(t,e,n){const r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?Oo(r,i):Os()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return Os()}}
965
965
  /**
966
966
  * @license
967
967
  * Copyright 2020 Google LLC
@@ -1025,7 +1025,7 @@ class fa{constructor(t){this.comparator=t,this.data=new ua(this.comparator)}has(
1025
1025
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1026
1026
  * See the License for the specific language governing permissions and
1027
1027
  * limitations under the License.
1028
- */var vc,wc;function Sc(t){if(void 0===t)return Rs("GRPC error has no .code"),xs.UNKNOWN;switch(t){case vc.OK:return xs.OK;case vc.CANCELLED:return xs.CANCELLED;case vc.UNKNOWN:return xs.UNKNOWN;case vc.DEADLINE_EXCEEDED:return xs.DEADLINE_EXCEEDED;case vc.RESOURCE_EXHAUSTED:return xs.RESOURCE_EXHAUSTED;case vc.INTERNAL:return xs.INTERNAL;case vc.UNAVAILABLE:return xs.UNAVAILABLE;case vc.UNAUTHENTICATED:return xs.UNAUTHENTICATED;case vc.INVALID_ARGUMENT:return xs.INVALID_ARGUMENT;case vc.NOT_FOUND:return xs.NOT_FOUND;case vc.ALREADY_EXISTS:return xs.ALREADY_EXISTS;case vc.PERMISSION_DENIED:return xs.PERMISSION_DENIED;case vc.FAILED_PRECONDITION:return xs.FAILED_PRECONDITION;case vc.ABORTED:return xs.ABORTED;case vc.OUT_OF_RANGE:return xs.OUT_OF_RANGE;case vc.UNIMPLEMENTED:return xs.UNIMPLEMENTED;case vc.DATA_LOSS:return xs.DATA_LOSS;default:return Os()}}(wc=vc||(vc={}))[wc.OK=0]="OK",wc[wc.CANCELLED=1]="CANCELLED",wc[wc.UNKNOWN=2]="UNKNOWN",wc[wc.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",wc[wc.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",wc[wc.NOT_FOUND=5]="NOT_FOUND",wc[wc.ALREADY_EXISTS=6]="ALREADY_EXISTS",wc[wc.PERMISSION_DENIED=7]="PERMISSION_DENIED",wc[wc.UNAUTHENTICATED=16]="UNAUTHENTICATED",wc[wc.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",wc[wc.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",wc[wc.ABORTED=10]="ABORTED",wc[wc.OUT_OF_RANGE=11]="OUT_OF_RANGE",wc[wc.UNIMPLEMENTED=12]="UNIMPLEMENTED",wc[wc.INTERNAL=13]="INTERNAL",wc[wc.UNAVAILABLE=14]="UNAVAILABLE",wc[wc.DATA_LOSS=15]="DATA_LOSS";
1028
+ */var vc,wc;function bc(t){if(void 0===t)return Rs("GRPC error has no .code"),xs.UNKNOWN;switch(t){case vc.OK:return xs.OK;case vc.CANCELLED:return xs.CANCELLED;case vc.UNKNOWN:return xs.UNKNOWN;case vc.DEADLINE_EXCEEDED:return xs.DEADLINE_EXCEEDED;case vc.RESOURCE_EXHAUSTED:return xs.RESOURCE_EXHAUSTED;case vc.INTERNAL:return xs.INTERNAL;case vc.UNAVAILABLE:return xs.UNAVAILABLE;case vc.UNAUTHENTICATED:return xs.UNAUTHENTICATED;case vc.INVALID_ARGUMENT:return xs.INVALID_ARGUMENT;case vc.NOT_FOUND:return xs.NOT_FOUND;case vc.ALREADY_EXISTS:return xs.ALREADY_EXISTS;case vc.PERMISSION_DENIED:return xs.PERMISSION_DENIED;case vc.FAILED_PRECONDITION:return xs.FAILED_PRECONDITION;case vc.ABORTED:return xs.ABORTED;case vc.OUT_OF_RANGE:return xs.OUT_OF_RANGE;case vc.UNIMPLEMENTED:return xs.UNIMPLEMENTED;case vc.DATA_LOSS:return xs.DATA_LOSS;default:return Os()}}(wc=vc||(vc={}))[wc.OK=0]="OK",wc[wc.CANCELLED=1]="CANCELLED",wc[wc.UNKNOWN=2]="UNKNOWN",wc[wc.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",wc[wc.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",wc[wc.NOT_FOUND=5]="NOT_FOUND",wc[wc.ALREADY_EXISTS=6]="ALREADY_EXISTS",wc[wc.PERMISSION_DENIED=7]="PERMISSION_DENIED",wc[wc.UNAUTHENTICATED=16]="UNAUTHENTICATED",wc[wc.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",wc[wc.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",wc[wc.ABORTED=10]="ABORTED",wc[wc.OUT_OF_RANGE=11]="OUT_OF_RANGE",wc[wc.UNIMPLEMENTED=12]="UNIMPLEMENTED",wc[wc.INTERNAL=13]="INTERNAL",wc[wc.UNAVAILABLE=14]="UNAVAILABLE",wc[wc.DATA_LOSS=15]="DATA_LOSS";
1029
1029
  /**
1030
1030
  * @license
1031
1031
  * Copyright 2017 Google LLC
@@ -1042,7 +1042,7 @@ class fa{constructor(t){this.comparator=t,this.data=new ua(this.comparator)}has(
1042
1042
  * See the License for the specific language governing permissions and
1043
1043
  * limitations under the License.
1044
1044
  */
1045
- class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(const[e,r]of n)if(this.equalsFn(e,t))return r}has(t){return void 0!==this.get(t)}set(t,e){const n=this.mapKeyFn(t),r=this.inner[n];if(void 0===r)return this.inner[n]=[[t,e]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],t))return void(r[n]=[t,e]);r.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(t){mo(this.inner,((e,n)=>{for(const[e,r]of n)t(e,r)}))}isEmpty(){return yo(this.inner)}size(){return this.innerSize}}
1045
+ class Sc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.innerSize=0}get(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(const[e,r]of n)if(this.equalsFn(e,t))return r}has(t){return void 0!==this.get(t)}set(t,e){const n=this.mapKeyFn(t),r=this.inner[n];if(void 0===r)return this.inner[n]=[[t,e]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],t))return void(r[n]=[t,e]);r.push([t,e]),this.innerSize++}delete(t){const e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(t){mo(this.inner,((e,n)=>{for(const[e,r]of n)t(e,r)}))}isEmpty(){return yo(this.inner)}size(){return this.innerSize}}
1046
1046
  /**
1047
1047
  * @license
1048
1048
  * Copyright 2017 Google LLC
@@ -1058,7 +1058,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1058
1058
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1059
1059
  * See the License for the specific language governing permissions and
1060
1060
  * limitations under the License.
1061
- */const _c=new ua(no.comparator);function Ec(){return _c}const Tc=new ua(no.comparator);function Ic(...t){let e=Tc;for(const n of t)e=e.insert(n.key,n);return e}function kc(t){let e=Tc;return t.forEach(((t,n)=>e=e.insert(t,n.overlayedDocument))),e}function Cc(){return Rc()}function Ac(){return Rc()}function Rc(){return new bc((t=>t.toString()),((t,e)=>t.isEqual(e)))}const Nc=new ua(no.comparator),Lc=new fa(no.comparator);function Oc(...t){let e=Lc;for(const n of t)e=e.add(n);return e}const Dc=new fa(Gs);function Pc(){return Dc}
1061
+ */const _c=new ua(no.comparator);function Ec(){return _c}const Tc=new ua(no.comparator);function Ic(...t){let e=Tc;for(const n of t)e=e.insert(n.key,n);return e}function kc(t){let e=Tc;return t.forEach(((t,n)=>e=e.insert(t,n.overlayedDocument))),e}function Cc(){return Rc()}function Ac(){return Rc()}function Rc(){return new Sc((t=>t.toString()),((t,e)=>t.isEqual(e)))}const Nc=new ua(no.comparator),Lc=new fa(no.comparator);function Oc(...t){let e=Lc;for(const n of t)e=e.add(n);return e}const Dc=new fa(Gs);function Pc(){return Dc}
1062
1062
  /**
1063
1063
  * @license
1064
1064
  * Copyright 2017 Google LLC
@@ -1090,7 +1090,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1090
1090
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1091
1091
  * See the License for the specific language governing permissions and
1092
1092
  * limitations under the License.
1093
- */class Uc{constructor(t,e,n,r){this.It=t,this.removedTargetIds=e,this.key=n,this.Tt=r}}class Fc{constructor(t,e){this.targetId=t,this.Et=e}}class zc{constructor(t,e,n=So.EMPTY_BYTE_STRING,r=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}}class Bc{constructor(){this.At=0,this.Rt=jc(),this.bt=So.EMPTY_BYTE_STRING,this.Pt=!1,this.vt=!0}get current(){return this.Pt}get resumeToken(){return this.bt}get Vt(){return 0!==this.At}get St(){return this.vt}Dt(t){t.approximateByteSize()>0&&(this.vt=!0,this.bt=t)}Ct(){let t=Oc(),e=Oc(),n=Oc();return this.Rt.forEach(((r,i)=>{switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:Os()}})),new Mc(this.bt,this.Pt,t,e,n)}xt(){this.vt=!1,this.Rt=jc()}Nt(t,e){this.vt=!0,this.Rt=this.Rt.insert(t,e)}kt(t){this.vt=!0,this.Rt=this.Rt.remove(t)}Ot(){this.At+=1}Mt(){this.At-=1}Ft(){this.vt=!0,this.Pt=!0}}class Vc{constructor(t){this.$t=t,this.Bt=new Map,this.Lt=Ec(),this.qt=Hc(),this.Ut=new fa(Gs)}Kt(t){for(const e of t.It)t.Tt&&t.Tt.isFoundDocument()?this.Gt(e,t.Tt):this.Qt(e,t.key,t.Tt);for(const e of t.removedTargetIds)this.Qt(e,t.key,t.Tt)}jt(t){this.forEachTarget(t,(e=>{const n=this.Wt(e);switch(t.state){case 0:this.zt(e)&&n.Dt(t.resumeToken);break;case 1:n.Mt(),n.Vt||n.xt(),n.Dt(t.resumeToken);break;case 2:n.Mt(),n.Vt||this.removeTarget(e);break;case 3:this.zt(e)&&(n.Ft(),n.Dt(t.resumeToken));break;case 4:this.zt(e)&&(this.Ht(e),n.Dt(t.resumeToken));break;default:Os()}}))}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Bt.forEach(((t,n)=>{this.zt(n)&&e(n)}))}Jt(t){const e=t.targetId,n=t.Et.count,r=this.Yt(e);if(r){const t=r.target;if(Ea(t))if(0===n){const n=new no(t.path);this.Qt(e,n,va.newNoDocument(n,Js.min()))}else Ds(1===n);else this.Xt(e)!==n&&(this.Ht(e),this.Ut=this.Ut.add(e))}}Zt(t){const e=new Map;this.Bt.forEach(((n,r)=>{const i=this.Yt(r);if(i){if(n.current&&Ea(i.target)){const e=new no(i.target.path);null!==this.Lt.get(e)||this.te(r,e)||this.Qt(r,e,va.newNoDocument(e,t))}n.St&&(e.set(r,n.Ct()),n.xt())}}));let n=Oc();this.qt.forEach(((t,e)=>{let r=!0;e.forEachWhile((t=>{const e=this.Yt(t);return!e||2===e.purpose||(r=!1,!1)})),r&&(n=n.add(t))})),this.Lt.forEach(((e,n)=>n.setReadTime(t)));const r=new xc(t,e,this.Ut,this.Lt,n);return this.Lt=Ec(),this.qt=Hc(),this.Ut=new fa(Gs),r}Gt(t,e){if(!this.zt(t))return;const n=this.te(t,e.key)?2:0;this.Wt(t).Nt(e.key,n),this.Lt=this.Lt.insert(e.key,e),this.qt=this.qt.insert(e.key,this.ee(e.key).add(t))}Qt(t,e,n){if(!this.zt(t))return;const r=this.Wt(t);this.te(t,e)?r.Nt(e,1):r.kt(e),this.qt=this.qt.insert(e,this.ee(e).delete(t)),n&&(this.Lt=this.Lt.insert(e,n))}removeTarget(t){this.Bt.delete(t)}Xt(t){const e=this.Wt(t).Ct();return this.$t.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}Ot(t){this.Wt(t).Ot()}Wt(t){let e=this.Bt.get(t);return e||(e=new Bc,this.Bt.set(t,e)),e}ee(t){let e=this.qt.get(t);return e||(e=new fa(Gs),this.qt=this.qt.insert(t,e)),e}zt(t){const e=null!==this.Yt(t);return e||As("WatchChangeAggregator","Detected inactive target",t),e}Yt(t){const e=this.Bt.get(t);return e&&e.Vt?null:this.$t.ne(t)}Ht(t){this.Bt.set(t,new Bc),this.$t.getRemoteKeysForTarget(t).forEach((e=>{this.Qt(t,e,null)}))}te(t,e){return this.$t.getRemoteKeysForTarget(t).has(e)}}function Hc(){return new ua(no.comparator)}function jc(){return new ua(no.comparator)}
1093
+ */class Uc{constructor(t,e,n,r){this.It=t,this.removedTargetIds=e,this.key=n,this.Tt=r}}class Fc{constructor(t,e){this.targetId=t,this.Et=e}}class zc{constructor(t,e,n=bo.EMPTY_BYTE_STRING,r=null){this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r}}class Bc{constructor(){this.At=0,this.Rt=jc(),this.bt=bo.EMPTY_BYTE_STRING,this.Pt=!1,this.vt=!0}get current(){return this.Pt}get resumeToken(){return this.bt}get Vt(){return 0!==this.At}get St(){return this.vt}Dt(t){t.approximateByteSize()>0&&(this.vt=!0,this.bt=t)}Ct(){let t=Oc(),e=Oc(),n=Oc();return this.Rt.forEach(((r,i)=>{switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:Os()}})),new Mc(this.bt,this.Pt,t,e,n)}xt(){this.vt=!1,this.Rt=jc()}Nt(t,e){this.vt=!0,this.Rt=this.Rt.insert(t,e)}kt(t){this.vt=!0,this.Rt=this.Rt.remove(t)}Ot(){this.At+=1}Mt(){this.At-=1}Ft(){this.vt=!0,this.Pt=!0}}class Vc{constructor(t){this.$t=t,this.Bt=new Map,this.Lt=Ec(),this.qt=Hc(),this.Ut=new fa(Gs)}Kt(t){for(const e of t.It)t.Tt&&t.Tt.isFoundDocument()?this.Gt(e,t.Tt):this.Qt(e,t.key,t.Tt);for(const e of t.removedTargetIds)this.Qt(e,t.key,t.Tt)}jt(t){this.forEachTarget(t,(e=>{const n=this.Wt(e);switch(t.state){case 0:this.zt(e)&&n.Dt(t.resumeToken);break;case 1:n.Mt(),n.Vt||n.xt(),n.Dt(t.resumeToken);break;case 2:n.Mt(),n.Vt||this.removeTarget(e);break;case 3:this.zt(e)&&(n.Ft(),n.Dt(t.resumeToken));break;case 4:this.zt(e)&&(this.Ht(e),n.Dt(t.resumeToken));break;default:Os()}}))}forEachTarget(t,e){t.targetIds.length>0?t.targetIds.forEach(e):this.Bt.forEach(((t,n)=>{this.zt(n)&&e(n)}))}Jt(t){const e=t.targetId,n=t.Et.count,r=this.Yt(e);if(r){const t=r.target;if(Ea(t))if(0===n){const n=new no(t.path);this.Qt(e,n,va.newNoDocument(n,Js.min()))}else Ds(1===n);else this.Xt(e)!==n&&(this.Ht(e),this.Ut=this.Ut.add(e))}}Zt(t){const e=new Map;this.Bt.forEach(((n,r)=>{const i=this.Yt(r);if(i){if(n.current&&Ea(i.target)){const e=new no(i.target.path);null!==this.Lt.get(e)||this.te(r,e)||this.Qt(r,e,va.newNoDocument(e,t))}n.St&&(e.set(r,n.Ct()),n.xt())}}));let n=Oc();this.qt.forEach(((t,e)=>{let r=!0;e.forEachWhile((t=>{const e=this.Yt(t);return!e||2===e.purpose||(r=!1,!1)})),r&&(n=n.add(t))})),this.Lt.forEach(((e,n)=>n.setReadTime(t)));const r=new xc(t,e,this.Ut,this.Lt,n);return this.Lt=Ec(),this.qt=Hc(),this.Ut=new fa(Gs),r}Gt(t,e){if(!this.zt(t))return;const n=this.te(t,e.key)?2:0;this.Wt(t).Nt(e.key,n),this.Lt=this.Lt.insert(e.key,e),this.qt=this.qt.insert(e.key,this.ee(e.key).add(t))}Qt(t,e,n){if(!this.zt(t))return;const r=this.Wt(t);this.te(t,e)?r.Nt(e,1):r.kt(e),this.qt=this.qt.insert(e,this.ee(e).delete(t)),n&&(this.Lt=this.Lt.insert(e,n))}removeTarget(t){this.Bt.delete(t)}Xt(t){const e=this.Wt(t).Ct();return this.$t.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size}Ot(t){this.Wt(t).Ot()}Wt(t){let e=this.Bt.get(t);return e||(e=new Bc,this.Bt.set(t,e)),e}ee(t){let e=this.qt.get(t);return e||(e=new fa(Gs),this.qt=this.qt.insert(t,e)),e}zt(t){const e=null!==this.Yt(t);return e||As("WatchChangeAggregator","Detected inactive target",t),e}Yt(t){const e=this.Bt.get(t);return e&&e.Vt?null:this.$t.ne(t)}Ht(t){this.Bt.set(t,new Bc),this.$t.getRemoteKeysForTarget(t).forEach((e=>{this.Qt(t,e,null)}))}te(t,e){return this.$t.getRemoteKeysForTarget(t).has(e)}}function Hc(){return new ua(no.comparator)}function jc(){return new ua(no.comparator)}
1094
1094
  /**
1095
1095
  * @license
1096
1096
  * Copyright 2017 Google LLC
@@ -1138,7 +1138,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1138
1138
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1139
1139
  * See the License for the specific language governing permissions and
1140
1140
  * limitations under the License.
1141
- */class Sl{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return null!==t&&this.mutation===t.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}}
1141
+ */class bl{constructor(t,e){this.largestBatchId=t,this.mutation=e}getKey(){return this.mutation.key}isEqual(t){return null!==t&&this.mutation===t.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}}
1142
1142
  /**
1143
1143
  * @license
1144
1144
  * Copyright 2017 Google LLC
@@ -1154,7 +1154,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1154
1154
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1155
1155
  * See the License for the specific language governing permissions and
1156
1156
  * limitations under the License.
1157
- */class bl{constructor(t,e,n,r,i=Js.min(),s=Js.min(),o=So.EMPTY_BYTE_STRING){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o}withSequenceNumber(t){return new bl(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(t,e){return new bl(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)}withLastLimboFreeSnapshotVersion(t){return new bl(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)}}
1157
+ */class Sl{constructor(t,e,n,r,i=Js.min(),s=Js.min(),o=bo.EMPTY_BYTE_STRING){this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o}withSequenceNumber(t){return new Sl(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(t,e){return new Sl(this.target,this.targetId,this.purpose,this.sequenceNumber,e,this.lastLimboFreeSnapshotVersion,t)}withLastLimboFreeSnapshotVersion(t){return new Sl(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken)}}
1158
1158
  /**
1159
1159
  * @license
1160
1160
  * Copyright 2017 Google LLC
@@ -1218,7 +1218,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1218
1218
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1219
1219
  * See the License for the specific language governing permissions and
1220
1220
  * limitations under the License.
1221
- */class Cl{constructor(){this.changes=new bc((t=>t.toString()),((t,e)=>t.isEqual(e))),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,va.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return void 0!==n?lo.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}
1221
+ */class Cl{constructor(){this.changes=new Sc((t=>t.toString()),((t,e)=>t.isEqual(e))),this.changesApplied=!1}addEntry(t){this.assertNotApplied(),this.changes.set(t.key,t)}removeEntry(t,e){this.assertNotApplied(),this.changes.set(t,va.newInvalidDocument(t).setReadTime(e))}getEntry(t,e){this.assertNotApplied();const n=this.changes.get(e);return void 0!==n?lo.resolve(n):this.getFromCache(t,e)}getEntries(t,e){return this.getAllFromCache(t,e)}apply(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)}assertNotApplied(){}}
1222
1222
  /**
1223
1223
  * @license
1224
1224
  * Copyright 2017 Google LLC
@@ -1298,7 +1298,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1298
1298
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1299
1299
  * See the License for the specific language governing permissions and
1300
1300
  * limitations under the License.
1301
- */class Ll{constructor(){this.overlays=new ua(no.comparator),this.es=new Map}getOverlay(t,e){return lo.resolve(this.overlays.get(e))}getOverlays(t,e){const n=Cc();return lo.forEach(e,(e=>this.getOverlay(t,e).next((t=>{null!==t&&n.set(e,t)})))).next((()=>n))}saveOverlays(t,e,n){return n.forEach(((n,r)=>{this.oe(t,e,r)})),lo.resolve()}removeOverlaysForBatchId(t,e,n){const r=this.es.get(n);return void 0!==r&&(r.forEach((t=>this.overlays=this.overlays.remove(t))),this.es.delete(n)),lo.resolve()}getOverlaysForCollection(t,e,n){const r=Cc(),i=e.length+1,s=new no(e.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const t=o.getNext().value,s=t.getKey();if(!e.isPrefixOf(s.path))break;s.path.length===i&&t.largestBatchId>n&&r.set(t.getKey(),t)}return lo.resolve(r)}getOverlaysForCollectionGroup(t,e,n,r){let i=new ua(((t,e)=>t-e));const s=this.overlays.getIterator();for(;s.hasNext();){const t=s.getNext().value;if(t.getKey().getCollectionGroup()===e&&t.largestBatchId>n){let e=i.get(t.largestBatchId);null===e&&(e=Cc(),i=i.insert(t.largestBatchId,e)),e.set(t.getKey(),t)}}const o=Cc(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((t,e)=>o.set(t,e))),!(o.size()>=r)););return lo.resolve(o)}oe(t,e,n){const r=this.overlays.get(n.key);if(null!==r){const t=this.es.get(r.largestBatchId).delete(n.key);this.es.set(r.largestBatchId,t)}this.overlays=this.overlays.insert(n.key,new Sl(e,n));let i=this.es.get(e);void 0===i&&(i=Oc(),this.es.set(e,i)),this.es.set(e,i.add(n.key))}}
1301
+ */class Ll{constructor(){this.overlays=new ua(no.comparator),this.es=new Map}getOverlay(t,e){return lo.resolve(this.overlays.get(e))}getOverlays(t,e){const n=Cc();return lo.forEach(e,(e=>this.getOverlay(t,e).next((t=>{null!==t&&n.set(e,t)})))).next((()=>n))}saveOverlays(t,e,n){return n.forEach(((n,r)=>{this.oe(t,e,r)})),lo.resolve()}removeOverlaysForBatchId(t,e,n){const r=this.es.get(n);return void 0!==r&&(r.forEach((t=>this.overlays=this.overlays.remove(t))),this.es.delete(n)),lo.resolve()}getOverlaysForCollection(t,e,n){const r=Cc(),i=e.length+1,s=new no(e.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const t=o.getNext().value,s=t.getKey();if(!e.isPrefixOf(s.path))break;s.path.length===i&&t.largestBatchId>n&&r.set(t.getKey(),t)}return lo.resolve(r)}getOverlaysForCollectionGroup(t,e,n,r){let i=new ua(((t,e)=>t-e));const s=this.overlays.getIterator();for(;s.hasNext();){const t=s.getNext().value;if(t.getKey().getCollectionGroup()===e&&t.largestBatchId>n){let e=i.get(t.largestBatchId);null===e&&(e=Cc(),i=i.insert(t.largestBatchId,e)),e.set(t.getKey(),t)}}const o=Cc(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach(((t,e)=>o.set(t,e))),!(o.size()>=r)););return lo.resolve(o)}oe(t,e,n){const r=this.overlays.get(n.key);if(null!==r){const t=this.es.get(r.largestBatchId).delete(n.key);this.es.set(r.largestBatchId,t)}this.overlays=this.overlays.insert(n.key,new bl(e,n));let i=this.es.get(e);void 0===i&&(i=Oc(),this.es.set(e,i)),this.es.set(e,i.add(n.key))}}
1302
1302
  /**
1303
1303
  * @license
1304
1304
  * Copyright 2017 Google LLC
@@ -1362,7 +1362,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1362
1362
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1363
1363
  * See the License for the specific language governing permissions and
1364
1364
  * limitations under the License.
1365
- */class Ul{constructor(t){this.persistence=t,this.Rs=new bc((t=>ba(t)),_a),this.lastRemoteSnapshotVersion=Js.min(),this.highestTargetId=0,this.bs=0,this.Ps=new Ol,this.targetCount=0,this.vs=kl.Pn()}forEachTarget(t,e){return this.Rs.forEach(((t,n)=>e(n))),lo.resolve()}getLastRemoteSnapshotVersion(t){return lo.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return lo.resolve(this.bs)}allocateTargetId(t){return this.highestTargetId=this.vs.next(),lo.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.bs&&(this.bs=e),lo.resolve()}Dn(t){this.Rs.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.vs=new kl(e),this.highestTargetId=e),t.sequenceNumber>this.bs&&(this.bs=t.sequenceNumber)}addTargetData(t,e){return this.Dn(e),this.targetCount+=1,lo.resolve()}updateTargetData(t,e){return this.Dn(e),lo.resolve()}removeTargetData(t,e){return this.Rs.delete(e.target),this.Ps.ls(e.targetId),this.targetCount-=1,lo.resolve()}removeTargets(t,e,n){let r=0;const i=[];return this.Rs.forEach(((s,o)=>{o.sequenceNumber<=e&&null===n.get(o.targetId)&&(this.Rs.delete(s),i.push(this.removeMatchingKeysForTargetId(t,o.targetId)),r++)})),lo.waitFor(i).next((()=>r))}getTargetCount(t){return lo.resolve(this.targetCount)}getTargetData(t,e){const n=this.Rs.get(e)||null;return lo.resolve(n)}addMatchingKeys(t,e,n){return this.Ps.us(e,n),lo.resolve()}removeMatchingKeys(t,e,n){this.Ps.hs(e,n);const r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((e=>{i.push(r.markPotentiallyOrphaned(t,e))})),lo.waitFor(i)}removeMatchingKeysForTargetId(t,e){return this.Ps.ls(e),lo.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Ps.ds(e);return lo.resolve(n)}containsKey(t,e){return lo.resolve(this.Ps.containsKey(e))}}
1365
+ */class Ul{constructor(t){this.persistence=t,this.Rs=new Sc((t=>Sa(t)),_a),this.lastRemoteSnapshotVersion=Js.min(),this.highestTargetId=0,this.bs=0,this.Ps=new Ol,this.targetCount=0,this.vs=kl.Pn()}forEachTarget(t,e){return this.Rs.forEach(((t,n)=>e(n))),lo.resolve()}getLastRemoteSnapshotVersion(t){return lo.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(t){return lo.resolve(this.bs)}allocateTargetId(t){return this.highestTargetId=this.vs.next(),lo.resolve(this.highestTargetId)}setTargetsMetadata(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.bs&&(this.bs=e),lo.resolve()}Dn(t){this.Rs.set(t.target,t);const e=t.targetId;e>this.highestTargetId&&(this.vs=new kl(e),this.highestTargetId=e),t.sequenceNumber>this.bs&&(this.bs=t.sequenceNumber)}addTargetData(t,e){return this.Dn(e),this.targetCount+=1,lo.resolve()}updateTargetData(t,e){return this.Dn(e),lo.resolve()}removeTargetData(t,e){return this.Rs.delete(e.target),this.Ps.ls(e.targetId),this.targetCount-=1,lo.resolve()}removeTargets(t,e,n){let r=0;const i=[];return this.Rs.forEach(((s,o)=>{o.sequenceNumber<=e&&null===n.get(o.targetId)&&(this.Rs.delete(s),i.push(this.removeMatchingKeysForTargetId(t,o.targetId)),r++)})),lo.waitFor(i).next((()=>r))}getTargetCount(t){return lo.resolve(this.targetCount)}getTargetData(t,e){const n=this.Rs.get(e)||null;return lo.resolve(n)}addMatchingKeys(t,e,n){return this.Ps.us(e,n),lo.resolve()}removeMatchingKeys(t,e,n){this.Ps.hs(e,n);const r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((e=>{i.push(r.markPotentiallyOrphaned(t,e))})),lo.waitFor(i)}removeMatchingKeysForTargetId(t,e){return this.Ps.ls(e),lo.resolve()}getMatchingKeysForTargetId(t,e){const n=this.Ps.ds(e);return lo.resolve(n)}containsKey(t,e){return lo.resolve(this.Ps.containsKey(e))}}
1366
1366
  /**
1367
1367
  * @license
1368
1368
  * Copyright 2017 Google LLC
@@ -1426,7 +1426,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1426
1426
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1427
1427
  * See the License for the specific language governing permissions and
1428
1428
  * limitations under the License.
1429
- */class jl{constructor(t,e,n,r){this.persistence=t,this.Li=e,this.yt=r,this.qi=new ua(Gs),this.Ui=new bc((t=>ba(t)),_a),this.Ki=new Map,this.Gi=t.getRemoteDocumentCache(),this.Cs=t.getTargetCache(),this.Ns=t.getBundleCache(),this.Qi(n)}Qi(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Rl(this.Gi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Gi.setIndexManager(this.indexManager),this.Li.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(e=>t.collect(e,this.qi)))}}async function $l(t,e){const n=Ps(t);return await n.persistence.runTransaction("Handle user change","readonly",(t=>{let r;return n.mutationQueue.getAllMutationBatches(t).next((i=>(r=i,n.Qi(e),n.mutationQueue.getAllMutationBatches(t)))).next((e=>{const i=[],s=[];let o=Oc();for(const t of r){i.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}for(const t of e){s.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}return n.localDocuments.getDocuments(t,o).next((t=>({ji:t,removedBatchIds:i,addedBatchIds:s})))}))}))}function ql(t){const e=Ps(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.Cs.getLastRemoteSnapshotVersion(t)))}function Wl(t,e){const n=Ps(t),r=e.snapshotVersion;let i=n.qi;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(t=>{const s=n.Gi.newChangeBuffer({trackRemovals:!0});i=n.qi;const o=[];e.targetChanges.forEach(((s,a)=>{const c=i.get(a);if(!c)return;o.push(n.Cs.removeMatchingKeys(t,s.removedDocuments,a).next((()=>n.Cs.addMatchingKeys(t,s.addedDocuments,a))));let l=c.withSequenceNumber(t.currentSequenceNumber);e.targetMismatches.has(a)?l=l.withResumeToken(So.EMPTY_BYTE_STRING,Js.min()).withLastLimboFreeSnapshotVersion(Js.min()):s.resumeToken.approximateByteSize()>0&&(l=l.withResumeToken(s.resumeToken,r)),i=i.insert(a,l),function(t,e,n){return 0===t.resumeToken.approximateByteSize()||(e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0)}(c,l,s)&&o.push(n.Cs.updateTargetData(t,l))}));let a=Ec(),c=Oc();if(e.documentUpdates.forEach((r=>{e.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))})),o.push(function(t,e,n){let r=Oc(),i=Oc();return n.forEach((t=>r=r.add(t))),e.getEntries(t,r).next((t=>{let r=Ec();return n.forEach(((n,s)=>{const o=t.get(n);s.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(Js.min())?(e.removeEntry(n,s.readTime),r=r.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)>0||0===s.version.compareTo(o.version)&&o.hasPendingWrites?(e.addEntry(s),r=r.insert(n,s)):As("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)})),{Wi:r,zi:i}}))}(t,s,e.documentUpdates).next((t=>{a=t.Wi,c=t.zi}))),!r.isEqual(Js.min())){const e=n.Cs.getLastRemoteSnapshotVersion(t).next((e=>n.Cs.setTargetsMetadata(t,t.currentSequenceNumber,r)));o.push(e)}return lo.waitFor(o).next((()=>s.apply(t))).next((()=>n.localDocuments.getLocalViewOfDocuments(t,a,c))).next((()=>a))})).then((t=>(n.qi=i,t)))}function Kl(t,e){const n=Ps(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(t=>(void 0===e&&(e=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(t,e))))}async function Gl(t,e,n){const r=Ps(t),i=r.qi.get(e),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(t=>r.persistence.referenceDelegate.removeTarget(t,i)))}catch(t){if(!uo(t))throw t;As("LocalStore",`Failed to update sequence numbers for target ${e}: ${t}`)}r.qi=r.qi.remove(e),r.Ui.delete(i.target)}function Ql(t,e,n){const r=Ps(t);let i=Js.min(),s=Oc();return r.persistence.runTransaction("Execute query","readonly",(t=>function(t,e,n){const r=Ps(t),i=r.Ui.get(n);return void 0!==i?lo.resolve(r.qi.get(i)):r.Cs.getTargetData(e,n)}(r,t,La(e)).next((e=>{if(e)return i=e.lastLimboFreeSnapshotVersion,r.Cs.getMatchingKeysForTargetId(t,e.targetId).next((t=>{s=t}))})).next((()=>r.Li.getDocumentsMatchingQuery(t,e,n?i:Js.min(),n?s:Oc()))).next((t=>(function(t,e,n){let r=t.Ki.get(e)||Js.min();n.forEach(((t,e)=>{e.readTime.compareTo(r)>0&&(r=e.readTime)})),t.Ki.set(e,r)}(r,function(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}(e),t),{documents:t,Hi:s})))))}class Yl{constructor(){this.activeTargetIds=Pc()}er(t){this.activeTargetIds=this.activeTargetIds.add(t)}nr(t){this.activeTargetIds=this.activeTargetIds.delete(t)}tr(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class Jl{constructor(){this.Lr=new Yl,this.qr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t){return this.Lr.er(t),this.qr[t]||"not-current"}updateQueryState(t,e,n){this.qr[t]=e}removeLocalQueryTarget(t){this.Lr.nr(t)}isLocalQueryTarget(t){return this.Lr.activeTargetIds.has(t)}clearQueryState(t){delete this.qr[t]}getAllActiveQueryTargets(){return this.Lr.activeTargetIds}isActiveQueryTarget(t){return this.Lr.activeTargetIds.has(t)}start(){return this.Lr=new Yl,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}
1429
+ */class jl{constructor(t,e,n,r){this.persistence=t,this.Li=e,this.yt=r,this.qi=new ua(Gs),this.Ui=new Sc((t=>Sa(t)),_a),this.Ki=new Map,this.Gi=t.getRemoteDocumentCache(),this.Cs=t.getTargetCache(),this.Ns=t.getBundleCache(),this.Qi(n)}Qi(t){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(t),this.indexManager=this.persistence.getIndexManager(t),this.mutationQueue=this.persistence.getMutationQueue(t,this.indexManager),this.localDocuments=new Rl(this.Gi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Gi.setIndexManager(this.indexManager),this.Li.initialize(this.localDocuments,this.indexManager)}collectGarbage(t){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(e=>t.collect(e,this.qi)))}}async function $l(t,e){const n=Ps(t);return await n.persistence.runTransaction("Handle user change","readonly",(t=>{let r;return n.mutationQueue.getAllMutationBatches(t).next((i=>(r=i,n.Qi(e),n.mutationQueue.getAllMutationBatches(t)))).next((e=>{const i=[],s=[];let o=Oc();for(const t of r){i.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}for(const t of e){s.push(t.batchId);for(const e of t.mutations)o=o.add(e.key)}return n.localDocuments.getDocuments(t,o).next((t=>({ji:t,removedBatchIds:i,addedBatchIds:s})))}))}))}function ql(t){const e=Ps(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(t=>e.Cs.getLastRemoteSnapshotVersion(t)))}function Wl(t,e){const n=Ps(t),r=e.snapshotVersion;let i=n.qi;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(t=>{const s=n.Gi.newChangeBuffer({trackRemovals:!0});i=n.qi;const o=[];e.targetChanges.forEach(((s,a)=>{const c=i.get(a);if(!c)return;o.push(n.Cs.removeMatchingKeys(t,s.removedDocuments,a).next((()=>n.Cs.addMatchingKeys(t,s.addedDocuments,a))));let l=c.withSequenceNumber(t.currentSequenceNumber);e.targetMismatches.has(a)?l=l.withResumeToken(bo.EMPTY_BYTE_STRING,Js.min()).withLastLimboFreeSnapshotVersion(Js.min()):s.resumeToken.approximateByteSize()>0&&(l=l.withResumeToken(s.resumeToken,r)),i=i.insert(a,l),function(t,e,n){return 0===t.resumeToken.approximateByteSize()||(e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0)}(c,l,s)&&o.push(n.Cs.updateTargetData(t,l))}));let a=Ec(),c=Oc();if(e.documentUpdates.forEach((r=>{e.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))})),o.push(function(t,e,n){let r=Oc(),i=Oc();return n.forEach((t=>r=r.add(t))),e.getEntries(t,r).next((t=>{let r=Ec();return n.forEach(((n,s)=>{const o=t.get(n);s.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(Js.min())?(e.removeEntry(n,s.readTime),r=r.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)>0||0===s.version.compareTo(o.version)&&o.hasPendingWrites?(e.addEntry(s),r=r.insert(n,s)):As("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)})),{Wi:r,zi:i}}))}(t,s,e.documentUpdates).next((t=>{a=t.Wi,c=t.zi}))),!r.isEqual(Js.min())){const e=n.Cs.getLastRemoteSnapshotVersion(t).next((e=>n.Cs.setTargetsMetadata(t,t.currentSequenceNumber,r)));o.push(e)}return lo.waitFor(o).next((()=>s.apply(t))).next((()=>n.localDocuments.getLocalViewOfDocuments(t,a,c))).next((()=>a))})).then((t=>(n.qi=i,t)))}function Kl(t,e){const n=Ps(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(t=>(void 0===e&&(e=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(t,e))))}async function Gl(t,e,n){const r=Ps(t),i=r.qi.get(e),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(t=>r.persistence.referenceDelegate.removeTarget(t,i)))}catch(t){if(!uo(t))throw t;As("LocalStore",`Failed to update sequence numbers for target ${e}: ${t}`)}r.qi=r.qi.remove(e),r.Ui.delete(i.target)}function Ql(t,e,n){const r=Ps(t);let i=Js.min(),s=Oc();return r.persistence.runTransaction("Execute query","readonly",(t=>function(t,e,n){const r=Ps(t),i=r.Ui.get(n);return void 0!==i?lo.resolve(r.qi.get(i)):r.Cs.getTargetData(e,n)}(r,t,La(e)).next((e=>{if(e)return i=e.lastLimboFreeSnapshotVersion,r.Cs.getMatchingKeysForTargetId(t,e.targetId).next((t=>{s=t}))})).next((()=>r.Li.getDocumentsMatchingQuery(t,e,n?i:Js.min(),n?s:Oc()))).next((t=>(function(t,e,n){let r=t.Ki.get(e)||Js.min();n.forEach(((t,e)=>{e.readTime.compareTo(r)>0&&(r=e.readTime)})),t.Ki.set(e,r)}(r,function(t){return t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2))}(e),t),{documents:t,Hi:s})))))}class Yl{constructor(){this.activeTargetIds=Pc()}er(t){this.activeTargetIds=this.activeTargetIds.add(t)}nr(t){this.activeTargetIds=this.activeTargetIds.delete(t)}tr(){const t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)}}class Jl{constructor(){this.Lr=new Yl,this.qr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(t){}updateMutationState(t,e,n){}addLocalQueryTarget(t){return this.Lr.er(t),this.qr[t]||"not-current"}updateQueryState(t,e,n){this.qr[t]=e}removeLocalQueryTarget(t){this.Lr.nr(t)}isLocalQueryTarget(t){return this.Lr.activeTargetIds.has(t)}clearQueryState(t){delete this.qr[t]}getAllActiveQueryTargets(){return this.Lr.activeTargetIds}isActiveQueryTarget(t){return this.Lr.activeTargetIds.has(t)}start(){return this.Lr=new Yl,Promise.resolve()}handleUserChange(t,e,n){}setOnlineState(t){}shutdown(){}writeSequenceNumber(t){}notifyBundleLoaded(t){}}
1430
1430
  /**
1431
1431
  * @license
1432
1432
  * Copyright 2019 Google LLC
@@ -1506,7 +1506,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1506
1506
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1507
1507
  * See the License for the specific language governing permissions and
1508
1508
  * limitations under the License.
1509
- */class nu extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.oo=e+"://"+t.host,this.uo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get co(){return!1}ao(t,e,n,r,i){const s=this.ho(t,e);As("RestConnection","Sending: ",s,n);const o={};return this.lo(o,r,i),this.fo(t,s,o,n).then((t=>(As("RestConnection","Received: ",t),t)),(e=>{throw Ns("RestConnection",`${t} failed with error: `,e,"url: ",s,"request:",n),e}))}_o(t,e,n,r,i,s){return this.ao(t,e,n,r,i)}lo(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+Is,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((e,n)=>t[n]=e)),n&&n.headers.forEach(((e,n)=>t[n]=e))}ho(t,e){const n=tu[t];return`${this.oo}/v1/${e}:${n}`}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams}fo(t,e,n,r){return new Promise(((i,s)=>{const o=new _s;o.setWithCredentials(!0),o.listenOnce(ms.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case gs.NO_ERROR:const e=o.getResponseJson();As("Connection","XHR received:",JSON.stringify(e)),i(e);break;case gs.TIMEOUT:As("Connection",'RPC "'+t+'" timed out'),s(new Ms(xs.DEADLINE_EXCEEDED,"Request time out"));break;case gs.HTTP_ERROR:const n=o.getStatus();if(As("Connection",'RPC "'+t+'" failed with status:',n,"response text:",o.getResponseText()),n>0){let t=o.getResponseJson();Array.isArray(t)&&(t=t[0]);const e=null==t?void 0:t.error;if(e&&e.status&&e.message){const t=function(t){const e=t.toLowerCase().replace(/_/g,"-");return Object.values(xs).indexOf(e)>=0?e:xs.UNKNOWN}(e.status);s(new Ms(t,e.message))}else s(new Ms(xs.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new Ms(xs.UNAVAILABLE,"Connection failed."));break;default:Os()}}finally{As("Connection",'RPC "'+t+'" completed.')}}));const a=JSON.stringify(r);o.send(e,"POST",a,n,15)}))}wo(t,e,n){const r=[this.oo,"/","google.firestore.v1.Firestore","/",t,"/channel"],i=new us,s=cr(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(o.xmlHttpFactory=new Ss({})),this.lo(o.initMessageHeaders,e,n),o.encodeInitMessageHeaders=!0;const a=r.join("");As("Connection","Creating WebChannel: "+a,o);const c=i.createWebChannel(a,o);let l=!1,u=!1;const h=new eu({Hr:t=>{u?As("Connection","Not sending because WebChannel is closed:",t):(l||(As("Connection","Opening WebChannel transport."),c.open(),l=!0),As("Connection","WebChannel sending:",t),c.send(t))},Jr:()=>c.close()}),d=(t,e,n)=>{t.listen(e,(t=>{try{n(t)}catch(t){setTimeout((()=>{throw t}),0)}}))};return d(c,bs.EventType.OPEN,(()=>{u||As("Connection","WebChannel transport opened.")})),d(c,bs.EventType.CLOSE,(()=>{u||(u=!0,As("Connection","WebChannel transport closed"),h.io())})),d(c,bs.EventType.ERROR,(t=>{u||(u=!0,Ns("Connection","WebChannel transport errored:",t),h.io(new Ms(xs.UNAVAILABLE,"The operation could not be completed")))})),d(c,bs.EventType.MESSAGE,(t=>{var e;if(!u){const n=t.data[0];Ds(!!n);const r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){As("Connection","WebChannel received error:",i);const t=i.status;let e=function(t){const e=vc[t];if(void 0!==e)return Sc(e)}(t),n=i.message;void 0===e&&(e=xs.INTERNAL,n="Unknown error status: "+t+" with message "+i.message),u=!0,h.io(new Ms(e,n)),c.close()}else As("Connection","WebChannel received:",n),h.ro(n)}})),d(s,ys.STAT_EVENT,(t=>{t.stat===vs?As("Connection","Detected buffering proxy"):t.stat===ws&&As("Connection","Detected no buffering proxy")})),setTimeout((()=>{h.so()}),0),h}}function ru(){return"undefined"!=typeof document?document:null}
1509
+ */class nu extends class{constructor(t){this.databaseInfo=t,this.databaseId=t.databaseId;const e=t.ssl?"https":"http";this.oo=e+"://"+t.host,this.uo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get co(){return!1}ao(t,e,n,r,i){const s=this.ho(t,e);As("RestConnection","Sending: ",s,n);const o={};return this.lo(o,r,i),this.fo(t,s,o,n).then((t=>(As("RestConnection","Received: ",t),t)),(e=>{throw Ns("RestConnection",`${t} failed with error: `,e,"url: ",s,"request:",n),e}))}_o(t,e,n,r,i,s){return this.ao(t,e,n,r,i)}lo(t,e,n){t["X-Goog-Api-Client"]="gl-js/ fire/"+Is,t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e&&e.headers.forEach(((e,n)=>t[n]=e)),n&&n.headers.forEach(((e,n)=>t[n]=e))}ho(t,e){const n=tu[t];return`${this.oo}/v1/${e}:${n}`}}{constructor(t){super(t),this.forceLongPolling=t.forceLongPolling,this.autoDetectLongPolling=t.autoDetectLongPolling,this.useFetchStreams=t.useFetchStreams}fo(t,e,n,r){return new Promise(((i,s)=>{const o=new _s;o.setWithCredentials(!0),o.listenOnce(ms.COMPLETE,(()=>{try{switch(o.getLastErrorCode()){case gs.NO_ERROR:const e=o.getResponseJson();As("Connection","XHR received:",JSON.stringify(e)),i(e);break;case gs.TIMEOUT:As("Connection",'RPC "'+t+'" timed out'),s(new Ms(xs.DEADLINE_EXCEEDED,"Request time out"));break;case gs.HTTP_ERROR:const n=o.getStatus();if(As("Connection",'RPC "'+t+'" failed with status:',n,"response text:",o.getResponseText()),n>0){let t=o.getResponseJson();Array.isArray(t)&&(t=t[0]);const e=null==t?void 0:t.error;if(e&&e.status&&e.message){const t=function(t){const e=t.toLowerCase().replace(/_/g,"-");return Object.values(xs).indexOf(e)>=0?e:xs.UNKNOWN}(e.status);s(new Ms(t,e.message))}else s(new Ms(xs.UNKNOWN,"Server responded with status "+o.getStatus()))}else s(new Ms(xs.UNAVAILABLE,"Connection failed."));break;default:Os()}}finally{As("Connection",'RPC "'+t+'" completed.')}}));const a=JSON.stringify(r);o.send(e,"POST",a,n,15)}))}wo(t,e,n){const r=[this.oo,"/","google.firestore.v1.Firestore","/",t,"/channel"],i=new us,s=cr(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(o.xmlHttpFactory=new bs({})),this.lo(o.initMessageHeaders,e,n),o.encodeInitMessageHeaders=!0;const a=r.join("");As("Connection","Creating WebChannel: "+a,o);const c=i.createWebChannel(a,o);let l=!1,u=!1;const h=new eu({Hr:t=>{u?As("Connection","Not sending because WebChannel is closed:",t):(l||(As("Connection","Opening WebChannel transport."),c.open(),l=!0),As("Connection","WebChannel sending:",t),c.send(t))},Jr:()=>c.close()}),d=(t,e,n)=>{t.listen(e,(t=>{try{n(t)}catch(t){setTimeout((()=>{throw t}),0)}}))};return d(c,Ss.EventType.OPEN,(()=>{u||As("Connection","WebChannel transport opened.")})),d(c,Ss.EventType.CLOSE,(()=>{u||(u=!0,As("Connection","WebChannel transport closed"),h.io())})),d(c,Ss.EventType.ERROR,(t=>{u||(u=!0,Ns("Connection","WebChannel transport errored:",t),h.io(new Ms(xs.UNAVAILABLE,"The operation could not be completed")))})),d(c,Ss.EventType.MESSAGE,(t=>{var e;if(!u){const n=t.data[0];Ds(!!n);const r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){As("Connection","WebChannel received error:",i);const t=i.status;let e=function(t){const e=vc[t];if(void 0!==e)return bc(e)}(t),n=i.message;void 0===e&&(e=xs.INTERNAL,n="Unknown error status: "+t+" with message "+i.message),u=!0,h.io(new Ms(e,n)),c.close()}else As("Connection","WebChannel received:",n),h.ro(n)}})),d(s,ys.STAT_EVENT,(t=>{t.stat===vs?As("Connection","Detected buffering proxy"):t.stat===ws&&As("Connection","Detected no buffering proxy")})),setTimeout((()=>{h.so()}),0),h}}function ru(){return"undefined"!=typeof document?document:null}
1510
1510
  /**
1511
1511
  * @license
1512
1512
  * Copyright 2020 Google LLC
@@ -1538,7 +1538,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1538
1538
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1539
1539
  * See the License for the specific language governing permissions and
1540
1540
  * limitations under the License.
1541
- */class ou{constructor(t,e,n,r,i,s,o,a){this.Hs=t,this.vo=n,this.Vo=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.So=0,this.Do=null,this.Co=null,this.stream=null,this.xo=new su(t,e)}No(){return 1===this.state||5===this.state||this.ko()}ko(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.Oo()}async stop(){this.No()&&await this.close(0)}Mo(){this.state=0,this.xo.reset()}Fo(){this.ko()&&null===this.Do&&(this.Do=this.Hs.enqueueAfterDelay(this.vo,6e4,(()=>this.$o())))}Bo(t){this.Lo(),this.stream.send(t)}async $o(){if(this.ko())return this.close(0)}Lo(){this.Do&&(this.Do.cancel(),this.Do=null)}qo(){this.Co&&(this.Co.cancel(),this.Co=null)}async close(t,e){this.Lo(),this.qo(),this.xo.cancel(),this.So++,4!==t?this.xo.reset():e&&e.code===xs.RESOURCE_EXHAUSTED?(Rs(e.toString()),Rs("Using maximum backoff delay to prevent overloading the backend."),this.xo.Ao()):e&&e.code===xs.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Uo(),this.stream.close(),this.stream=null),this.state=t,await this.listener.Zr(e)}Uo(){}auth(){this.state=1;const t=this.Ko(this.So),e=this.So;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([t,n])=>{this.So===e&&this.Go(t,n)}),(e=>{t((()=>{const t=new Ms(xs.UNKNOWN,"Fetching auth token failed: "+e.message);return this.Qo(t)}))}))}Go(t,e){const n=this.Ko(this.So);this.stream=this.jo(t,e),this.stream.Yr((()=>{n((()=>(this.state=2,this.Co=this.Hs.enqueueAfterDelay(this.Vo,1e4,(()=>(this.ko()&&(this.state=3),Promise.resolve()))),this.listener.Yr())))})),this.stream.Zr((t=>{n((()=>this.Qo(t)))})),this.stream.onMessage((t=>{n((()=>this.onMessage(t)))}))}Oo(){this.state=5,this.xo.Ro((async()=>{this.state=0,this.start()}))}Qo(t){return As("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}Ko(t){return e=>{this.Hs.enqueueAndForget((()=>this.So===t?e():(As("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class au extends ou{constructor(t,e,n,r,i,s){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,r,s),this.yt=i}jo(t,e){return this.connection.wo("Listen",t,e)}onMessage(t){this.xo.reset();const e=function(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:Os()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(t,e){return t.wt?(Ds(void 0===e||"string"==typeof e),So.fromBase64String(e||"")):(Ds(void 0===e||e instanceof Uint8Array),So.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(t){const e=void 0===t.code?xs.UNKNOWN:Sc(t.code);return new Ms(e,t.message||"")}(o);n=new zc(r,i,s,a||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const i=el(t,r.document.name),s=Jc(r.document.updateTime),o=r.document.createTime?Jc(r.document.createTime):Js.min(),a=new ma({mapValue:{fields:r.document.fields}}),c=va.newFoundDocument(i,s,o,a),l=r.targetIds||[],u=r.removedTargetIds||[];n=new Uc(l,u,c.key,c)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const i=el(t,r.document),s=r.readTime?Jc(r.readTime):Js.min(),o=va.newNoDocument(i,s),a=r.removedTargetIds||[];n=new Uc([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const i=el(t,r.document),s=r.removedTargetIds||[];n=new Uc([],s,i,null)}else{if(!("filter"in e))return Os();{e.filter;const t=e.filter;t.targetId;const r=t.count||0,i=new yc(r),s=t.targetId;n=new Fc(s,i)}}return n}(this.yt,t),n=function(t){if(!("targetChange"in t))return Js.min();const e=t.targetChange;return e.targetIds&&e.targetIds.length?Js.min():e.readTime?Jc(e.readTime):Js.min()}(t);return this.listener.Wo(e,n)}zo(t){const e={};e.database=rl(this.yt),e.addTarget=function(t,e){let n;const r=e.target;return n=Ea(r)?{documents:ol(t,r)}:{query:al(t,r)},n.targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=Qc(t,e.resumeToken):e.snapshotVersion.compareTo(Js.min())>0&&(n.readTime=Gc(t,e.snapshotVersion.toTimestamp())),n}(this.yt,t);const n=function(t,e){const n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Os()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.yt,t);n&&(e.labels=n),this.Bo(e)}Ho(t){const e={};e.database=rl(this.yt),e.removeTarget=t,this.Bo(e)}}class cu extends ou{constructor(t,e,n,r,i,s){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,r,s),this.yt=i,this.Jo=!1}get Yo(){return this.Jo}start(){this.Jo=!1,this.lastStreamToken=void 0,super.start()}Uo(){this.Jo&&this.Xo([])}jo(t,e){return this.connection.wo("Write",t,e)}onMessage(t){if(Ds(!!t.streamToken),this.lastStreamToken=t.streamToken,this.Jo){this.xo.reset();const e=function(t,e){return t&&t.length>0?(Ds(void 0!==e),t.map((t=>function(t,e){let n=t.updateTime?Jc(t.updateTime):Jc(e);return n.isEqual(Js.min())&&(n=Jc(e)),new ec(n,t.transformResults||[])}(t,e)))):[]}(t.writeResults,t.commitTime),n=Jc(t.commitTime);return this.listener.Zo(n,e)}return Ds(!t.writeResults||0===t.writeResults.length),this.Jo=!0,this.listener.tu()}eu(){const t={};t.database=rl(this.yt),this.Bo(t)}Xo(t){const e={streamToken:this.lastStreamToken,writes:t.map((t=>function(t,e){let n;if(e instanceof uc)n={update:sl(t,e.key,e.value)};else if(e instanceof gc)n={delete:tl(t,e.key)};else if(e instanceof hc)n={update:sl(t,e.key,e.data),updateMask:ml(e.fieldMask)};else{if(!(e instanceof mc))return Os();n={verify:tl(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof Ka)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Ga)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Ya)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Xa)return{fieldPath:e.field.canonicalString(),increment:n.gt};throw Os()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:Yc(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:Os()}(t,e.precondition)),n}(this.yt,t)))};this.Bo(e)}}
1541
+ */class ou{constructor(t,e,n,r,i,s,o,a){this.Hs=t,this.vo=n,this.Vo=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.So=0,this.Do=null,this.Co=null,this.stream=null,this.xo=new su(t,e)}No(){return 1===this.state||5===this.state||this.ko()}ko(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.Oo()}async stop(){this.No()&&await this.close(0)}Mo(){this.state=0,this.xo.reset()}Fo(){this.ko()&&null===this.Do&&(this.Do=this.Hs.enqueueAfterDelay(this.vo,6e4,(()=>this.$o())))}Bo(t){this.Lo(),this.stream.send(t)}async $o(){if(this.ko())return this.close(0)}Lo(){this.Do&&(this.Do.cancel(),this.Do=null)}qo(){this.Co&&(this.Co.cancel(),this.Co=null)}async close(t,e){this.Lo(),this.qo(),this.xo.cancel(),this.So++,4!==t?this.xo.reset():e&&e.code===xs.RESOURCE_EXHAUSTED?(Rs(e.toString()),Rs("Using maximum backoff delay to prevent overloading the backend."),this.xo.Ao()):e&&e.code===xs.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.Uo(),this.stream.close(),this.stream=null),this.state=t,await this.listener.Zr(e)}Uo(){}auth(){this.state=1;const t=this.Ko(this.So),e=this.So;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([t,n])=>{this.So===e&&this.Go(t,n)}),(e=>{t((()=>{const t=new Ms(xs.UNKNOWN,"Fetching auth token failed: "+e.message);return this.Qo(t)}))}))}Go(t,e){const n=this.Ko(this.So);this.stream=this.jo(t,e),this.stream.Yr((()=>{n((()=>(this.state=2,this.Co=this.Hs.enqueueAfterDelay(this.Vo,1e4,(()=>(this.ko()&&(this.state=3),Promise.resolve()))),this.listener.Yr())))})),this.stream.Zr((t=>{n((()=>this.Qo(t)))})),this.stream.onMessage((t=>{n((()=>this.onMessage(t)))}))}Oo(){this.state=5,this.xo.Ro((async()=>{this.state=0,this.start()}))}Qo(t){return As("PersistentStream",`close with error: ${t}`),this.stream=null,this.close(4,t)}Ko(t){return e=>{this.Hs.enqueueAndForget((()=>this.So===t?e():(As("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class au extends ou{constructor(t,e,n,r,i,s){super(t,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",e,n,r,s),this.yt=i}jo(t,e){return this.connection.wo("Listen",t,e)}onMessage(t){this.xo.reset();const e=function(t,e){let n;if("targetChange"in e){e.targetChange;const r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:Os()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],s=function(t,e){return t.wt?(Ds(void 0===e||"string"==typeof e),bo.fromBase64String(e||"")):(Ds(void 0===e||e instanceof Uint8Array),bo.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(t){const e=void 0===t.code?xs.UNKNOWN:bc(t.code);return new Ms(e,t.message||"")}(o);n=new zc(r,i,s,a||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const i=el(t,r.document.name),s=Jc(r.document.updateTime),o=r.document.createTime?Jc(r.document.createTime):Js.min(),a=new ma({mapValue:{fields:r.document.fields}}),c=va.newFoundDocument(i,s,o,a),l=r.targetIds||[],u=r.removedTargetIds||[];n=new Uc(l,u,c.key,c)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const i=el(t,r.document),s=r.readTime?Jc(r.readTime):Js.min(),o=va.newNoDocument(i,s),a=r.removedTargetIds||[];n=new Uc([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const i=el(t,r.document),s=r.removedTargetIds||[];n=new Uc([],s,i,null)}else{if(!("filter"in e))return Os();{e.filter;const t=e.filter;t.targetId;const r=t.count||0,i=new yc(r),s=t.targetId;n=new Fc(s,i)}}return n}(this.yt,t),n=function(t){if(!("targetChange"in t))return Js.min();const e=t.targetChange;return e.targetIds&&e.targetIds.length?Js.min():e.readTime?Jc(e.readTime):Js.min()}(t);return this.listener.Wo(e,n)}zo(t){const e={};e.database=rl(this.yt),e.addTarget=function(t,e){let n;const r=e.target;return n=Ea(r)?{documents:ol(t,r)}:{query:al(t,r)},n.targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=Qc(t,e.resumeToken):e.snapshotVersion.compareTo(Js.min())>0&&(n.readTime=Gc(t,e.snapshotVersion.toTimestamp())),n}(this.yt,t);const n=function(t,e){const n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return Os()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.yt,t);n&&(e.labels=n),this.Bo(e)}Ho(t){const e={};e.database=rl(this.yt),e.removeTarget=t,this.Bo(e)}}class cu extends ou{constructor(t,e,n,r,i,s){super(t,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",e,n,r,s),this.yt=i,this.Jo=!1}get Yo(){return this.Jo}start(){this.Jo=!1,this.lastStreamToken=void 0,super.start()}Uo(){this.Jo&&this.Xo([])}jo(t,e){return this.connection.wo("Write",t,e)}onMessage(t){if(Ds(!!t.streamToken),this.lastStreamToken=t.streamToken,this.Jo){this.xo.reset();const e=function(t,e){return t&&t.length>0?(Ds(void 0!==e),t.map((t=>function(t,e){let n=t.updateTime?Jc(t.updateTime):Jc(e);return n.isEqual(Js.min())&&(n=Jc(e)),new ec(n,t.transformResults||[])}(t,e)))):[]}(t.writeResults,t.commitTime),n=Jc(t.commitTime);return this.listener.Zo(n,e)}return Ds(!t.writeResults||0===t.writeResults.length),this.Jo=!0,this.listener.tu()}eu(){const t={};t.database=rl(this.yt),this.Bo(t)}Xo(t){const e={streamToken:this.lastStreamToken,writes:t.map((t=>function(t,e){let n;if(e instanceof uc)n={update:sl(t,e.key,e.value)};else if(e instanceof gc)n={delete:tl(t,e.key)};else if(e instanceof hc)n={update:sl(t,e.key,e.data),updateMask:ml(e.fieldMask)};else{if(!(e instanceof mc))return Os();n={verify:tl(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((t=>function(t,e){const n=e.transform;if(n instanceof Ka)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Ga)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Ya)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Xa)return{fieldPath:e.field.canonicalString(),increment:n.gt};throw Os()}(0,t)))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:Yc(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:Os()}(t,e.precondition)),n}(this.yt,t)))};this.Bo(e)}}
1542
1542
  /**
1543
1543
  * @license
1544
1544
  * Copyright 2017 Google LLC
@@ -1570,7 +1570,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1570
1570
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1571
1571
  * See the License for the specific language governing permissions and
1572
1572
  * limitations under the License.
1573
- */class hu{constructor(t,e,n,r,i){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.fu=[],this.du=new Map,this._u=new Set,this.wu=[],this.mu=i,this.mu.Ur((t=>{n.enqueueAndForget((async()=>{Su(this)&&(As("RemoteStore","Restarting streams for network reachability change."),await async function(t){const e=Ps(t);e._u.add(4),await fu(e),e.gu.set("Unknown"),e._u.delete(4),await du(e)}(this))}))})),this.gu=new uu(n,r)}}async function du(t){if(Su(t))for(const e of t.wu)await e(!0)}async function fu(t){for(const e of t.wu)await e(!1)}function pu(t,e){const n=Ps(t);n.du.has(e.targetId)||(n.du.set(e.targetId,e),wu(n)?vu(n):Uu(n).ko()&&mu(n,e))}function gu(t,e){const n=Ps(t),r=Uu(n);n.du.delete(e),r.ko()&&yu(n,e),0===n.du.size&&(r.ko()?r.Fo():Su(n)&&n.gu.set("Unknown"))}function mu(t,e){t.yu.Ot(e.targetId),Uu(t).zo(e)}function yu(t,e){t.yu.Ot(e),Uu(t).Ho(e)}function vu(t){t.yu=new Vc({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),ne:e=>t.du.get(e)||null}),Uu(t).start(),t.gu.uu()}function wu(t){return Su(t)&&!Uu(t).No()&&t.du.size>0}function Su(t){return 0===Ps(t)._u.size}function bu(t){t.yu=void 0}async function _u(t){t.du.forEach(((e,n)=>{mu(t,e)}))}async function Eu(t,e){bu(t),wu(t)?(t.gu.hu(e),vu(t)):t.gu.set("Unknown")}async function Tu(t,e,n){if(t.gu.set("Online"),e instanceof zc&&2===e.state&&e.cause)try{await async function(t,e){const n=e.cause;for(const r of e.targetIds)t.du.has(r)&&(await t.remoteSyncer.rejectListen(r,n),t.du.delete(r),t.yu.removeTarget(r))}(t,e)}catch(n){As("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await Iu(t,n)}else if(e instanceof Uc?t.yu.Kt(e):e instanceof Fc?t.yu.Jt(e):t.yu.jt(e),!n.isEqual(Js.min()))try{const e=await ql(t.localStore);n.compareTo(e)>=0&&await function(t,e){const n=t.yu.Zt(e);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=t.du.get(r);i&&t.du.set(r,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((e=>{const n=t.du.get(e);if(!n)return;t.du.set(e,n.withResumeToken(So.EMPTY_BYTE_STRING,n.snapshotVersion)),yu(t,e);const r=new bl(n.target,e,1,n.sequenceNumber);mu(t,r)})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)}catch(e){As("RemoteStore","Failed to raise snapshot:",e),await Iu(t,e)}}async function Iu(t,e,n){if(!uo(e))throw e;t._u.add(1),await fu(t),t.gu.set("Offline"),n||(n=()=>ql(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{As("RemoteStore","Retrying IndexedDB access"),await n(),t._u.delete(1),await du(t)}))}function ku(t,e){return e().catch((n=>Iu(t,n,e)))}async function Cu(t){const e=Ps(t),n=Fu(e);let r=e.fu.length>0?e.fu[e.fu.length-1].batchId:-1;for(;Au(e);)try{const t=await Kl(e.localStore,r);if(null===t){0===e.fu.length&&n.Fo();break}r=t.batchId,Ru(e,t)}catch(t){await Iu(e,t)}Nu(e)&&Lu(e)}function Au(t){return Su(t)&&t.fu.length<10}function Ru(t,e){t.fu.push(e);const n=Fu(t);n.ko()&&n.Yo&&n.Xo(e.mutations)}function Nu(t){return Su(t)&&!Fu(t).No()&&t.fu.length>0}function Lu(t){Fu(t).start()}async function Ou(t){Fu(t).eu()}async function Du(t){const e=Fu(t);for(const n of t.fu)e.Xo(n.mutations)}async function Pu(t,e,n){const r=t.fu.shift(),i=wl.from(r,e,n);await ku(t,(()=>t.remoteSyncer.applySuccessfulWrite(i))),await Cu(t)}async function xu(t,e){e&&Fu(t).Yo&&await async function(t,e){if(function(t){switch(t){default:return Os();case xs.CANCELLED:case xs.UNKNOWN:case xs.DEADLINE_EXCEEDED:case xs.RESOURCE_EXHAUSTED:case xs.INTERNAL:case xs.UNAVAILABLE:case xs.UNAUTHENTICATED:return!1;case xs.INVALID_ARGUMENT:case xs.NOT_FOUND:case xs.ALREADY_EXISTS:case xs.PERMISSION_DENIED:case xs.FAILED_PRECONDITION:case xs.ABORTED:case xs.OUT_OF_RANGE:case xs.UNIMPLEMENTED:case xs.DATA_LOSS:return!0}}(n=e.code)&&n!==xs.ABORTED){const n=t.fu.shift();Fu(t).Mo(),await ku(t,(()=>t.remoteSyncer.rejectFailedWrite(n.batchId,e))),await Cu(t)}var n}(t,e),Nu(t)&&Lu(t)}async function Mu(t,e){const n=Ps(t);n.asyncQueue.verifyOperationInProgress(),As("RemoteStore","RemoteStore received new credentials");const r=Su(n);n._u.add(3),await fu(n),r&&n.gu.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n._u.delete(3),await du(n)}function Uu(t){return t.pu||(t.pu=function(t,e,n){const r=Ps(t);return r.su(),new au(e,r.connection,r.authCredentials,r.appCheckCredentials,r.yt,n)
1573
+ */class hu{constructor(t,e,n,r,i){this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.fu=[],this.du=new Map,this._u=new Set,this.wu=[],this.mu=i,this.mu.Ur((t=>{n.enqueueAndForget((async()=>{bu(this)&&(As("RemoteStore","Restarting streams for network reachability change."),await async function(t){const e=Ps(t);e._u.add(4),await fu(e),e.gu.set("Unknown"),e._u.delete(4),await du(e)}(this))}))})),this.gu=new uu(n,r)}}async function du(t){if(bu(t))for(const e of t.wu)await e(!0)}async function fu(t){for(const e of t.wu)await e(!1)}function pu(t,e){const n=Ps(t);n.du.has(e.targetId)||(n.du.set(e.targetId,e),wu(n)?vu(n):Uu(n).ko()&&mu(n,e))}function gu(t,e){const n=Ps(t),r=Uu(n);n.du.delete(e),r.ko()&&yu(n,e),0===n.du.size&&(r.ko()?r.Fo():bu(n)&&n.gu.set("Unknown"))}function mu(t,e){t.yu.Ot(e.targetId),Uu(t).zo(e)}function yu(t,e){t.yu.Ot(e),Uu(t).Ho(e)}function vu(t){t.yu=new Vc({getRemoteKeysForTarget:e=>t.remoteSyncer.getRemoteKeysForTarget(e),ne:e=>t.du.get(e)||null}),Uu(t).start(),t.gu.uu()}function wu(t){return bu(t)&&!Uu(t).No()&&t.du.size>0}function bu(t){return 0===Ps(t)._u.size}function Su(t){t.yu=void 0}async function _u(t){t.du.forEach(((e,n)=>{mu(t,e)}))}async function Eu(t,e){Su(t),wu(t)?(t.gu.hu(e),vu(t)):t.gu.set("Unknown")}async function Tu(t,e,n){if(t.gu.set("Online"),e instanceof zc&&2===e.state&&e.cause)try{await async function(t,e){const n=e.cause;for(const r of e.targetIds)t.du.has(r)&&(await t.remoteSyncer.rejectListen(r,n),t.du.delete(r),t.yu.removeTarget(r))}(t,e)}catch(n){As("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),n),await Iu(t,n)}else if(e instanceof Uc?t.yu.Kt(e):e instanceof Fc?t.yu.Jt(e):t.yu.jt(e),!n.isEqual(Js.min()))try{const e=await ql(t.localStore);n.compareTo(e)>=0&&await function(t,e){const n=t.yu.Zt(e);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=t.du.get(r);i&&t.du.set(r,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((e=>{const n=t.du.get(e);if(!n)return;t.du.set(e,n.withResumeToken(bo.EMPTY_BYTE_STRING,n.snapshotVersion)),yu(t,e);const r=new Sl(n.target,e,1,n.sequenceNumber);mu(t,r)})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)}catch(e){As("RemoteStore","Failed to raise snapshot:",e),await Iu(t,e)}}async function Iu(t,e,n){if(!uo(e))throw e;t._u.add(1),await fu(t),t.gu.set("Offline"),n||(n=()=>ql(t.localStore)),t.asyncQueue.enqueueRetryable((async()=>{As("RemoteStore","Retrying IndexedDB access"),await n(),t._u.delete(1),await du(t)}))}function ku(t,e){return e().catch((n=>Iu(t,n,e)))}async function Cu(t){const e=Ps(t),n=Fu(e);let r=e.fu.length>0?e.fu[e.fu.length-1].batchId:-1;for(;Au(e);)try{const t=await Kl(e.localStore,r);if(null===t){0===e.fu.length&&n.Fo();break}r=t.batchId,Ru(e,t)}catch(t){await Iu(e,t)}Nu(e)&&Lu(e)}function Au(t){return bu(t)&&t.fu.length<10}function Ru(t,e){t.fu.push(e);const n=Fu(t);n.ko()&&n.Yo&&n.Xo(e.mutations)}function Nu(t){return bu(t)&&!Fu(t).No()&&t.fu.length>0}function Lu(t){Fu(t).start()}async function Ou(t){Fu(t).eu()}async function Du(t){const e=Fu(t);for(const n of t.fu)e.Xo(n.mutations)}async function Pu(t,e,n){const r=t.fu.shift(),i=wl.from(r,e,n);await ku(t,(()=>t.remoteSyncer.applySuccessfulWrite(i))),await Cu(t)}async function xu(t,e){e&&Fu(t).Yo&&await async function(t,e){if(function(t){switch(t){default:return Os();case xs.CANCELLED:case xs.UNKNOWN:case xs.DEADLINE_EXCEEDED:case xs.RESOURCE_EXHAUSTED:case xs.INTERNAL:case xs.UNAVAILABLE:case xs.UNAUTHENTICATED:return!1;case xs.INVALID_ARGUMENT:case xs.NOT_FOUND:case xs.ALREADY_EXISTS:case xs.PERMISSION_DENIED:case xs.FAILED_PRECONDITION:case xs.ABORTED:case xs.OUT_OF_RANGE:case xs.UNIMPLEMENTED:case xs.DATA_LOSS:return!0}}(n=e.code)&&n!==xs.ABORTED){const n=t.fu.shift();Fu(t).Mo(),await ku(t,(()=>t.remoteSyncer.rejectFailedWrite(n.batchId,e))),await Cu(t)}var n}(t,e),Nu(t)&&Lu(t)}async function Mu(t,e){const n=Ps(t);n.asyncQueue.verifyOperationInProgress(),As("RemoteStore","RemoteStore received new credentials");const r=bu(n);n._u.add(3),await fu(n),r&&n.gu.set("Unknown"),await n.remoteSyncer.handleCredentialChange(e),n._u.delete(3),await du(n)}function Uu(t){return t.pu||(t.pu=function(t,e,n){const r=Ps(t);return r.su(),new au(e,r.connection,r.authCredentials,r.appCheckCredentials,r.yt,n)
1574
1574
  /**
1575
1575
  * @license
1576
1576
  * Copyright 2018 Google LLC
@@ -1586,7 +1586,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1586
1586
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1587
1587
  * See the License for the specific language governing permissions and
1588
1588
  * limitations under the License.
1589
- */}(t.datastore,t.asyncQueue,{Yr:_u.bind(null,t),Zr:Eu.bind(null,t),Wo:Tu.bind(null,t)}),t.wu.push((async e=>{e?(t.pu.Mo(),wu(t)?vu(t):t.gu.set("Unknown")):(await t.pu.stop(),bu(t))}))),t.pu}function Fu(t){return t.Iu||(t.Iu=function(t,e,n){const r=Ps(t);return r.su(),new cu(e,r.connection,r.authCredentials,r.appCheckCredentials,r.yt,n)}(t.datastore,t.asyncQueue,{Yr:Ou.bind(null,t),Zr:xu.bind(null,t),tu:Du.bind(null,t),Zo:Pu.bind(null,t)}),t.wu.push((async e=>{e?(t.Iu.Mo(),await Cu(t)):(await t.Iu.stop(),t.fu.length>0&&(As("RemoteStore",`Stopping write stream with ${t.fu.length} pending writes`),t.fu=[]))}))),t.Iu
1589
+ */}(t.datastore,t.asyncQueue,{Yr:_u.bind(null,t),Zr:Eu.bind(null,t),Wo:Tu.bind(null,t)}),t.wu.push((async e=>{e?(t.pu.Mo(),wu(t)?vu(t):t.gu.set("Unknown")):(await t.pu.stop(),Su(t))}))),t.pu}function Fu(t){return t.Iu||(t.Iu=function(t,e,n){const r=Ps(t);return r.su(),new cu(e,r.connection,r.authCredentials,r.appCheckCredentials,r.yt,n)}(t.datastore,t.asyncQueue,{Yr:Ou.bind(null,t),Zr:xu.bind(null,t),tu:Du.bind(null,t),Zo:Pu.bind(null,t)}),t.wu.push((async e=>{e?(t.Iu.Mo(),await Cu(t)):(await t.Iu.stop(),t.fu.length>0&&(As("RemoteStore",`Stopping write stream with ${t.fu.length} pending writes`),t.fu=[]))}))),t.Iu
1590
1590
  /**
1591
1591
  * @license
1592
1592
  * Copyright 2017 Google LLC
@@ -1650,7 +1650,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1650
1650
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1651
1651
  * See the License for the specific language governing permissions and
1652
1652
  * limitations under the License.
1653
- */class $u{constructor(){this.Au=void 0,this.listeners=[]}}class qu{constructor(){this.queries=new bc((t=>xa(t)),Pa),this.onlineState="Unknown",this.Ru=new Set}}async function Wu(t,e){const n=Ps(t),r=e.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new $u),i)try{s.Au=await n.onListen(r)}catch(t){const n=Bu(t,`Initialization of query '${Ma(e.query)}' failed`);return void e.onError(n)}n.queries.set(r,s),s.listeners.push(e),e.bu(n.onlineState),s.Au&&e.Pu(s.Au)&&Yu(n)}async function Ku(t,e){const n=Ps(t),r=e.query;let i=!1;const s=n.queries.get(r);if(s){const t=s.listeners.indexOf(e);t>=0&&(s.listeners.splice(t,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function Gu(t,e){const n=Ps(t);let r=!1;for(const t of e){const e=t.query,i=n.queries.get(e);if(i){for(const e of i.listeners)e.Pu(t)&&(r=!0);i.Au=t}}r&&Yu(n)}function Qu(t,e,n){const r=Ps(t),i=r.queries.get(e);if(i)for(const t of i.listeners)t.onError(n);r.queries.delete(e)}function Yu(t){t.Ru.forEach((t=>{t.next()}))}class Ju{constructor(t,e,n){this.query=t,this.vu=e,this.Vu=!1,this.Su=null,this.onlineState="Unknown",this.options=n||{}}Pu(t){if(!this.options.includeMetadataChanges){const e=[];for(const n of t.docChanges)3!==n.type&&e.push(n);t=new ju(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.Vu?this.Du(t)&&(this.vu.next(t),e=!0):this.Cu(t,this.onlineState)&&(this.xu(t),e=!0),this.Su=t,e}onError(t){this.vu.error(t)}bu(t){this.onlineState=t;let e=!1;return this.Su&&!this.Vu&&this.Cu(this.Su,t)&&(this.xu(this.Su),e=!0),e}Cu(t,e){if(!t.fromCache)return!0;const n="Offline"!==e;return(!this.options.Nu||!n)&&(!t.docs.isEmpty()||t.hasCachedResults||"Offline"===e)}Du(t){if(t.docChanges.length>0)return!0;const e=this.Su&&this.Su.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges}xu(t){t=ju.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.Vu=!0,this.vu.next(t)}}
1653
+ */class $u{constructor(){this.Au=void 0,this.listeners=[]}}class qu{constructor(){this.queries=new Sc((t=>xa(t)),Pa),this.onlineState="Unknown",this.Ru=new Set}}async function Wu(t,e){const n=Ps(t),r=e.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new $u),i)try{s.Au=await n.onListen(r)}catch(t){const n=Bu(t,`Initialization of query '${Ma(e.query)}' failed`);return void e.onError(n)}n.queries.set(r,s),s.listeners.push(e),e.bu(n.onlineState),s.Au&&e.Pu(s.Au)&&Yu(n)}async function Ku(t,e){const n=Ps(t),r=e.query;let i=!1;const s=n.queries.get(r);if(s){const t=s.listeners.indexOf(e);t>=0&&(s.listeners.splice(t,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function Gu(t,e){const n=Ps(t);let r=!1;for(const t of e){const e=t.query,i=n.queries.get(e);if(i){for(const e of i.listeners)e.Pu(t)&&(r=!0);i.Au=t}}r&&Yu(n)}function Qu(t,e,n){const r=Ps(t),i=r.queries.get(e);if(i)for(const t of i.listeners)t.onError(n);r.queries.delete(e)}function Yu(t){t.Ru.forEach((t=>{t.next()}))}class Ju{constructor(t,e,n){this.query=t,this.vu=e,this.Vu=!1,this.Su=null,this.onlineState="Unknown",this.options=n||{}}Pu(t){if(!this.options.includeMetadataChanges){const e=[];for(const n of t.docChanges)3!==n.type&&e.push(n);t=new ju(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0,t.hasCachedResults)}let e=!1;return this.Vu?this.Du(t)&&(this.vu.next(t),e=!0):this.Cu(t,this.onlineState)&&(this.xu(t),e=!0),this.Su=t,e}onError(t){this.vu.error(t)}bu(t){this.onlineState=t;let e=!1;return this.Su&&!this.Vu&&this.Cu(this.Su,t)&&(this.xu(this.Su),e=!0),e}Cu(t,e){if(!t.fromCache)return!0;const n="Offline"!==e;return(!this.options.Nu||!n)&&(!t.docs.isEmpty()||t.hasCachedResults||"Offline"===e)}Du(t){if(t.docChanges.length>0)return!0;const e=this.Su&&this.Su.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges}xu(t){t=ju.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache,t.hasCachedResults),this.Vu=!0,this.vu.next(t)}}
1654
1654
  /**
1655
1655
  * @license
1656
1656
  * Copyright 2017 Google LLC
@@ -1682,7 +1682,7 @@ class bc{constructor(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={},this.inn
1682
1682
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1683
1683
  * See the License for the specific language governing permissions and
1684
1684
  * limitations under the License.
1685
- */(t.type,e.type)||this.Gu(t.doc,e.doc))),this.Ju(n);const s=e?this.Yu():[],o=0===this.Ku.size&&this.current?1:0,a=o!==this.Uu;return this.Uu=o,0!==i.length||a?{snapshot:new ju(this.query,t.Qu,r,i,t.mutatedKeys,0===o,a,!1,!!n&&n.resumeToken.approximateByteSize()>0),Xu:s}:{Xu:s}}bu(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({Qu:this.Qu,zu:new Hu,mutatedKeys:this.mutatedKeys,$i:!1},!1)):{Xu:[]}}Zu(t){return!this.qu.has(t)&&!!this.Qu.has(t)&&!this.Qu.get(t).hasLocalMutations}Ju(t){t&&(t.addedDocuments.forEach((t=>this.qu=this.qu.add(t))),t.modifiedDocuments.forEach((t=>{})),t.removedDocuments.forEach((t=>this.qu=this.qu.delete(t))),this.current=t.current)}Yu(){if(!this.current)return[];const t=this.Ku;this.Ku=Oc(),this.Qu.forEach((t=>{this.Zu(t.key)&&(this.Ku=this.Ku.add(t.key))}));const e=[];return t.forEach((t=>{this.Ku.has(t)||e.push(new Zu(t))})),this.Ku.forEach((n=>{t.has(n)||e.push(new Xu(n))})),e}tc(t){this.qu=t.Hi,this.Ku=Oc();const e=this.Wu(t.documents);return this.applyChanges(e,!0)}ec(){return ju.fromInitialDocuments(this.query,this.Qu,this.mutatedKeys,0===this.Uu,this.hasCachedResults)}}class eh{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class nh{constructor(t){this.key=t,this.nc=!1}}class rh{constructor(t,e,n,r,i,s){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.sc={},this.ic=new bc((t=>xa(t)),Pa),this.rc=new Map,this.oc=new Set,this.uc=new ua(no.comparator),this.cc=new Map,this.ac=new Ol,this.hc={},this.lc=new Map,this.fc=kl.vn(),this.onlineState="Unknown",this.dc=void 0}get isPrimaryClient(){return!0===this.dc}}async function ih(t,e){const n=function(t){const e=Ps(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=ah.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=bh.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=lh.bind(null,e),e.sc.Wo=Gu.bind(null,e.eventManager),e.sc.wc=Qu.bind(null,e.eventManager),e}(t);let r,i;const s=n.ic.get(e);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.ec();else{const t=await function(t,e){const n=Ps(t);return n.persistence.runTransaction("Allocate target","readwrite",(t=>{let r;return n.Cs.getTargetData(t,e).next((i=>i?(r=i,lo.resolve(r)):n.Cs.allocateTargetId(t).next((i=>(r=new bl(e,i,0,t.currentSequenceNumber),n.Cs.addTargetData(t,r).next((()=>r)))))))})).then((t=>{const r=n.qi.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.qi=n.qi.insert(t.targetId,t),n.Ui.set(e,t.targetId)),t}))}(n.localStore,La(e));n.isPrimaryClient&&pu(n.remoteStore,t);const s=n.sharedClientState.addLocalQueryTarget(t.targetId);r=t.targetId,i=await async function(t,e,n,r,i){t._c=(e,n,r)=>async function(t,e,n,r){let i=e.view.Wu(n);i.$i&&(i=await Ql(t.localStore,e.query,!1).then((({documents:t})=>e.view.Wu(t,i))));const s=r&&r.targetChanges.get(e.targetId),o=e.view.applyChanges(i,t.isPrimaryClient,s);return mh(t,e.targetId,o.Xu),o.snapshot}(t,e,n,r);const s=await Ql(t.localStore,e,!0),o=new th(e,s.Hi),a=o.Wu(s.documents),c=Mc.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==t.onlineState,i),l=o.applyChanges(a,t.isPrimaryClient,c);mh(t,n,l.Xu);const u=new eh(e,n,o);return t.ic.set(e,u),t.rc.has(n)?t.rc.get(n).push(e):t.rc.set(n,[e]),l.snapshot}(n,e,r,"current"===s,t.resumeToken)}return i}async function sh(t,e){const n=Ps(t),r=n.ic.get(e),i=n.rc.get(r.targetId);if(i.length>1)return n.rc.set(r.targetId,i.filter((t=>!Pa(t,e)))),void n.ic.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await Gl(n.localStore,r.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(r.targetId),gu(n.remoteStore,r.targetId),ph(n,r.targetId)})).catch(co)):(ph(n,r.targetId),await Gl(n.localStore,r.targetId,!0))}async function oh(t,e,n){const r=function(t){const e=Ps(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=uh.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=hh.bind(null,e),e}(t);try{const t=await function(t,e){const n=Ps(t),r=Ys.now(),i=e.reduce(((t,e)=>t.add(e.key)),Oc());let s,o;return n.persistence.runTransaction("Locally write mutations","readwrite",(t=>{let a=Ec(),c=Oc();return n.Gi.getEntries(t,i).next((t=>{a=t,a.forEach(((t,e)=>{e.isValidDocument()||(c=c.add(t))}))})).next((()=>n.localDocuments.getOverlayedDocuments(t,a))).next((i=>{s=i;const o=[];for(const t of e){const e=cc(t,s.get(t.key).overlayedDocument);null!=e&&o.push(new hc(t.key,e,ya(e.value.mapValue),nc.exists(!0)))}return n.mutationQueue.addMutationBatch(t,r,o,e)})).next((e=>{o=e;const r=e.applyToLocalDocumentSet(s,c);return n.documentOverlayCache.saveOverlays(t,e.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:kc(s)})))}(r.localStore,e);r.sharedClientState.addPendingMutation(t.batchId),function(t,e,n){let r=t.hc[t.currentUser.toKey()];r||(r=new ua(Gs)),r=r.insert(e,n),t.hc[t.currentUser.toKey()]=r}(r,t.batchId,n),await wh(r,t.changes),await Cu(r.remoteStore)}catch(t){const e=Bu(t,"Failed to persist write");n.reject(e)}}async function ah(t,e){const n=Ps(t);try{const t=await Wl(n.localStore,e);e.targetChanges.forEach(((t,e)=>{const r=n.cc.get(e);r&&(Ds(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?r.nc=!0:t.modifiedDocuments.size>0?Ds(r.nc):t.removedDocuments.size>0&&(Ds(r.nc),r.nc=!1))})),await wh(n,t,e)}catch(t){await co(t)}}function ch(t,e,n){const r=Ps(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const t=[];r.ic.forEach(((n,r)=>{const i=r.view.bu(e);i.snapshot&&t.push(i.snapshot)})),function(t,e){const n=Ps(t);n.onlineState=e;let r=!1;n.queries.forEach(((t,n)=>{for(const t of n.listeners)t.bu(e)&&(r=!0)})),r&&Yu(n)}(r.eventManager,e),t.length&&r.sc.Wo(t),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function lh(t,e,n){const r=Ps(t);r.sharedClientState.updateQueryState(e,"rejected",n);const i=r.cc.get(e),s=i&&i.key;if(s){let t=new ua(no.comparator);t=t.insert(s,va.newNoDocument(s,Js.min()));const n=Oc().add(s),i=new xc(Js.min(),new Map,new fa(Gs),t,n);await ah(r,i),r.uc=r.uc.remove(s),r.cc.delete(e),vh(r)}else await Gl(r.localStore,e,!1).then((()=>ph(r,e,n))).catch(co)}async function uh(t,e){const n=Ps(t),r=e.batch.batchId;try{const t=await function(t,e){const n=Ps(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(t=>{const r=e.batch.keys(),i=n.Gi.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){const i=n.batch,s=i.keys();let o=lo.resolve();return s.forEach((t=>{o=o.next((()=>r.getEntry(e,t))).next((e=>{const s=n.docVersions.get(t);Ds(null!==s),e.version.compareTo(s)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&(e.setReadTime(n.commitVersion),r.addEntry(e)))}))})),o.next((()=>t.mutationQueue.removeMutationBatch(e,i)))}(n,t,e,i).next((()=>i.apply(t))).next((()=>n.mutationQueue.performConsistencyCheck(t))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(t,r,e.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,function(t){let e=Oc();for(let n=0;n<t.mutationResults.length;++n)t.mutationResults[n].transformResults.length>0&&(e=e.add(t.batch.mutations[n].key));return e}(e)))).next((()=>n.localDocuments.getDocuments(t,r)))}))}(n.localStore,e);fh(n,r,null),dh(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await wh(n,t)}catch(t){await co(t)}}async function hh(t,e,n){const r=Ps(t);try{const t=await function(t,e){const n=Ps(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(t=>{let r;return n.mutationQueue.lookupMutationBatch(t,e).next((e=>(Ds(null!==e),r=e.keys(),n.mutationQueue.removeMutationBatch(t,e)))).next((()=>n.mutationQueue.performConsistencyCheck(t))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(t,r,e))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,r))).next((()=>n.localDocuments.getDocuments(t,r)))}))}(r.localStore,e);fh(r,e,n),dh(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),await wh(r,t)}catch(n){await co(n)}}function dh(t,e){(t.lc.get(e)||[]).forEach((t=>{t.resolve()})),t.lc.delete(e)}function fh(t,e,n){const r=Ps(t);let i=r.hc[r.currentUser.toKey()];if(i){const t=i.get(e);t&&(n?t.reject(n):t.resolve(),i=i.remove(e)),r.hc[r.currentUser.toKey()]=i}}function ph(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.rc.get(e))t.ic.delete(r),n&&t.sc.wc(r,n);t.rc.delete(e),t.isPrimaryClient&&t.ac.ls(e).forEach((e=>{t.ac.containsKey(e)||gh(t,e)}))}function gh(t,e){t.oc.delete(e.path.canonicalString());const n=t.uc.get(e);null!==n&&(gu(t.remoteStore,n),t.uc=t.uc.remove(e),t.cc.delete(n),vh(t))}function mh(t,e,n){for(const r of n)r instanceof Xu?(t.ac.addReference(r.key,e),yh(t,r)):r instanceof Zu?(As("SyncEngine","Document no longer in limbo: "+r.key),t.ac.removeReference(r.key,e),t.ac.containsKey(r.key)||gh(t,r.key)):Os()}function yh(t,e){const n=e.key,r=n.path.canonicalString();t.uc.get(n)||t.oc.has(r)||(As("SyncEngine","New document in limbo: "+n),t.oc.add(r),vh(t))}function vh(t){for(;t.oc.size>0&&t.uc.size<t.maxConcurrentLimboResolutions;){const e=t.oc.values().next().value;t.oc.delete(e);const n=new no(Zs.fromString(e)),r=t.fc.next();t.cc.set(r,new nh(n)),t.uc=t.uc.insert(n,r),pu(t.remoteStore,new bl(La(Ia(n.path)),r,2,ho.at))}}async function wh(t,e,n){const r=Ps(t),i=[],s=[],o=[];r.ic.isEmpty()||(r.ic.forEach(((t,a)=>{o.push(r._c(a,e,n).then((t=>{if((t||n)&&r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,(null==t?void 0:t.fromCache)?"not-current":"current"),t){i.push(t);const e=Vl.Ci(a.targetId,t);s.push(e)}})))})),await Promise.all(o),r.sc.Wo(i),await async function(t,e){const n=Ps(t);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(t=>lo.forEach(e,(e=>lo.forEach(e.Si,(r=>n.persistence.referenceDelegate.addReference(t,e.targetId,r))).next((()=>lo.forEach(e.Di,(r=>n.persistence.referenceDelegate.removeReference(t,e.targetId,r)))))))))}catch(t){if(!uo(t))throw t;As("LocalStore","Failed to update sequence numbers: "+t)}for(const t of e){const e=t.targetId;if(!t.fromCache){const t=n.qi.get(e),r=t.snapshotVersion,i=t.withLastLimboFreeSnapshotVersion(r);n.qi=n.qi.insert(e,i)}}}(r.localStore,s))}async function Sh(t,e){const n=Ps(t);if(!n.currentUser.isEqual(e)){As("SyncEngine","User change. New user:",e.toKey());const t=await $l(n.localStore,e);n.currentUser=e,function(t,e){t.lc.forEach((t=>{t.forEach((t=>{t.reject(new Ms(xs.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.lc.clear()}(n),n.sharedClientState.handleUserChange(e,t.removedBatchIds,t.addedBatchIds),await wh(n,t.ji)}}function bh(t,e){const n=Ps(t),r=n.cc.get(e);if(r&&r.nc)return Oc().add(r.key);{let t=Oc();const r=n.rc.get(e);if(!r)return t;for(const e of r){const r=n.ic.get(e);t=t.unionWith(r.view.ju)}return t}}class _h{constructor(){this.synchronizeTabs=!1}async initialize(t){this.yt=iu(t.databaseInfo.databaseId),this.sharedClientState=this.gc(t),this.persistence=this.yc(t),await this.persistence.start(),this.localStore=this.Ic(t),this.gcScheduler=this.Tc(t,this.localStore),this.indexBackfillerScheduler=this.Ec(t,this.localStore)}Tc(t,e){return null}Ec(t,e){return null}Ic(t){return function(t,e,n,r){return new jl(t,e,n,r)}(this.persistence,new Hl,t.initialUser,this.yt)}yc(t){return new Fl(Bl.Bs,this.yt)}gc(t){return new Jl}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class Eh{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=t=>ch(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=Sh.bind(null,this.syncEngine),await async function(t,e){const n=Ps(t);e?(n._u.delete(2),await du(n)):e||(n._u.add(2),await fu(n),n.gu.set("Unknown"))}(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new qu}createDatastore(t){const e=iu(t.databaseInfo.databaseId),n=(r=t.databaseInfo,new nu(r));var r;return function(t,e,n,r){return new lu(t,e,n,r)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=t=>ch(this.syncEngine,t,0),s=Zl.C()?new Zl:new Xl,new hu(e,n,r,i,s);var e,n,r,i,s}createSyncEngine(t,e){return function(t,e,n,r,i,s,o){const a=new rh(t,e,n,r,i,s);return o&&(a.dc=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}terminate(){return async function(t){const e=Ps(t);As("RemoteStore","RemoteStore shutting down."),e._u.add(5),await fu(e),e.mu.shutdown(),e.gu.set("Unknown")}(this.remoteStore)}}
1685
+ */(t.type,e.type)||this.Gu(t.doc,e.doc))),this.Ju(n);const s=e?this.Yu():[],o=0===this.Ku.size&&this.current?1:0,a=o!==this.Uu;return this.Uu=o,0!==i.length||a?{snapshot:new ju(this.query,t.Qu,r,i,t.mutatedKeys,0===o,a,!1,!!n&&n.resumeToken.approximateByteSize()>0),Xu:s}:{Xu:s}}bu(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({Qu:this.Qu,zu:new Hu,mutatedKeys:this.mutatedKeys,$i:!1},!1)):{Xu:[]}}Zu(t){return!this.qu.has(t)&&!!this.Qu.has(t)&&!this.Qu.get(t).hasLocalMutations}Ju(t){t&&(t.addedDocuments.forEach((t=>this.qu=this.qu.add(t))),t.modifiedDocuments.forEach((t=>{})),t.removedDocuments.forEach((t=>this.qu=this.qu.delete(t))),this.current=t.current)}Yu(){if(!this.current)return[];const t=this.Ku;this.Ku=Oc(),this.Qu.forEach((t=>{this.Zu(t.key)&&(this.Ku=this.Ku.add(t.key))}));const e=[];return t.forEach((t=>{this.Ku.has(t)||e.push(new Zu(t))})),this.Ku.forEach((n=>{t.has(n)||e.push(new Xu(n))})),e}tc(t){this.qu=t.Hi,this.Ku=Oc();const e=this.Wu(t.documents);return this.applyChanges(e,!0)}ec(){return ju.fromInitialDocuments(this.query,this.Qu,this.mutatedKeys,0===this.Uu,this.hasCachedResults)}}class eh{constructor(t,e,n){this.query=t,this.targetId=e,this.view=n}}class nh{constructor(t){this.key=t,this.nc=!1}}class rh{constructor(t,e,n,r,i,s){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.sc={},this.ic=new Sc((t=>xa(t)),Pa),this.rc=new Map,this.oc=new Set,this.uc=new ua(no.comparator),this.cc=new Map,this.ac=new Ol,this.hc={},this.lc=new Map,this.fc=kl.vn(),this.onlineState="Unknown",this.dc=void 0}get isPrimaryClient(){return!0===this.dc}}async function ih(t,e){const n=function(t){const e=Ps(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=ah.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Sh.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=lh.bind(null,e),e.sc.Wo=Gu.bind(null,e.eventManager),e.sc.wc=Qu.bind(null,e.eventManager),e}(t);let r,i;const s=n.ic.get(e);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.ec();else{const t=await function(t,e){const n=Ps(t);return n.persistence.runTransaction("Allocate target","readwrite",(t=>{let r;return n.Cs.getTargetData(t,e).next((i=>i?(r=i,lo.resolve(r)):n.Cs.allocateTargetId(t).next((i=>(r=new Sl(e,i,0,t.currentSequenceNumber),n.Cs.addTargetData(t,r).next((()=>r)))))))})).then((t=>{const r=n.qi.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.qi=n.qi.insert(t.targetId,t),n.Ui.set(e,t.targetId)),t}))}(n.localStore,La(e));n.isPrimaryClient&&pu(n.remoteStore,t);const s=n.sharedClientState.addLocalQueryTarget(t.targetId);r=t.targetId,i=await async function(t,e,n,r,i){t._c=(e,n,r)=>async function(t,e,n,r){let i=e.view.Wu(n);i.$i&&(i=await Ql(t.localStore,e.query,!1).then((({documents:t})=>e.view.Wu(t,i))));const s=r&&r.targetChanges.get(e.targetId),o=e.view.applyChanges(i,t.isPrimaryClient,s);return mh(t,e.targetId,o.Xu),o.snapshot}(t,e,n,r);const s=await Ql(t.localStore,e,!0),o=new th(e,s.Hi),a=o.Wu(s.documents),c=Mc.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==t.onlineState,i),l=o.applyChanges(a,t.isPrimaryClient,c);mh(t,n,l.Xu);const u=new eh(e,n,o);return t.ic.set(e,u),t.rc.has(n)?t.rc.get(n).push(e):t.rc.set(n,[e]),l.snapshot}(n,e,r,"current"===s,t.resumeToken)}return i}async function sh(t,e){const n=Ps(t),r=n.ic.get(e),i=n.rc.get(r.targetId);if(i.length>1)return n.rc.set(r.targetId,i.filter((t=>!Pa(t,e)))),void n.ic.delete(e);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await Gl(n.localStore,r.targetId,!1).then((()=>{n.sharedClientState.clearQueryState(r.targetId),gu(n.remoteStore,r.targetId),ph(n,r.targetId)})).catch(co)):(ph(n,r.targetId),await Gl(n.localStore,r.targetId,!0))}async function oh(t,e,n){const r=function(t){const e=Ps(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=uh.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=hh.bind(null,e),e}(t);try{const t=await function(t,e){const n=Ps(t),r=Ys.now(),i=e.reduce(((t,e)=>t.add(e.key)),Oc());let s,o;return n.persistence.runTransaction("Locally write mutations","readwrite",(t=>{let a=Ec(),c=Oc();return n.Gi.getEntries(t,i).next((t=>{a=t,a.forEach(((t,e)=>{e.isValidDocument()||(c=c.add(t))}))})).next((()=>n.localDocuments.getOverlayedDocuments(t,a))).next((i=>{s=i;const o=[];for(const t of e){const e=cc(t,s.get(t.key).overlayedDocument);null!=e&&o.push(new hc(t.key,e,ya(e.value.mapValue),nc.exists(!0)))}return n.mutationQueue.addMutationBatch(t,r,o,e)})).next((e=>{o=e;const r=e.applyToLocalDocumentSet(s,c);return n.documentOverlayCache.saveOverlays(t,e.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:kc(s)})))}(r.localStore,e);r.sharedClientState.addPendingMutation(t.batchId),function(t,e,n){let r=t.hc[t.currentUser.toKey()];r||(r=new ua(Gs)),r=r.insert(e,n),t.hc[t.currentUser.toKey()]=r}(r,t.batchId,n),await wh(r,t.changes),await Cu(r.remoteStore)}catch(t){const e=Bu(t,"Failed to persist write");n.reject(e)}}async function ah(t,e){const n=Ps(t);try{const t=await Wl(n.localStore,e);e.targetChanges.forEach(((t,e)=>{const r=n.cc.get(e);r&&(Ds(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?r.nc=!0:t.modifiedDocuments.size>0?Ds(r.nc):t.removedDocuments.size>0&&(Ds(r.nc),r.nc=!1))})),await wh(n,t,e)}catch(t){await co(t)}}function ch(t,e,n){const r=Ps(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const t=[];r.ic.forEach(((n,r)=>{const i=r.view.bu(e);i.snapshot&&t.push(i.snapshot)})),function(t,e){const n=Ps(t);n.onlineState=e;let r=!1;n.queries.forEach(((t,n)=>{for(const t of n.listeners)t.bu(e)&&(r=!0)})),r&&Yu(n)}(r.eventManager,e),t.length&&r.sc.Wo(t),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function lh(t,e,n){const r=Ps(t);r.sharedClientState.updateQueryState(e,"rejected",n);const i=r.cc.get(e),s=i&&i.key;if(s){let t=new ua(no.comparator);t=t.insert(s,va.newNoDocument(s,Js.min()));const n=Oc().add(s),i=new xc(Js.min(),new Map,new fa(Gs),t,n);await ah(r,i),r.uc=r.uc.remove(s),r.cc.delete(e),vh(r)}else await Gl(r.localStore,e,!1).then((()=>ph(r,e,n))).catch(co)}async function uh(t,e){const n=Ps(t),r=e.batch.batchId;try{const t=await function(t,e){const n=Ps(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(t=>{const r=e.batch.keys(),i=n.Gi.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){const i=n.batch,s=i.keys();let o=lo.resolve();return s.forEach((t=>{o=o.next((()=>r.getEntry(e,t))).next((e=>{const s=n.docVersions.get(t);Ds(null!==s),e.version.compareTo(s)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&(e.setReadTime(n.commitVersion),r.addEntry(e)))}))})),o.next((()=>t.mutationQueue.removeMutationBatch(e,i)))}(n,t,e,i).next((()=>i.apply(t))).next((()=>n.mutationQueue.performConsistencyCheck(t))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(t,r,e.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,function(t){let e=Oc();for(let n=0;n<t.mutationResults.length;++n)t.mutationResults[n].transformResults.length>0&&(e=e.add(t.batch.mutations[n].key));return e}(e)))).next((()=>n.localDocuments.getDocuments(t,r)))}))}(n.localStore,e);fh(n,r,null),dh(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await wh(n,t)}catch(t){await co(t)}}async function hh(t,e,n){const r=Ps(t);try{const t=await function(t,e){const n=Ps(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(t=>{let r;return n.mutationQueue.lookupMutationBatch(t,e).next((e=>(Ds(null!==e),r=e.keys(),n.mutationQueue.removeMutationBatch(t,e)))).next((()=>n.mutationQueue.performConsistencyCheck(t))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(t,r,e))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(t,r))).next((()=>n.localDocuments.getDocuments(t,r)))}))}(r.localStore,e);fh(r,e,n),dh(r,e),r.sharedClientState.updateMutationState(e,"rejected",n),await wh(r,t)}catch(n){await co(n)}}function dh(t,e){(t.lc.get(e)||[]).forEach((t=>{t.resolve()})),t.lc.delete(e)}function fh(t,e,n){const r=Ps(t);let i=r.hc[r.currentUser.toKey()];if(i){const t=i.get(e);t&&(n?t.reject(n):t.resolve(),i=i.remove(e)),r.hc[r.currentUser.toKey()]=i}}function ph(t,e,n=null){t.sharedClientState.removeLocalQueryTarget(e);for(const r of t.rc.get(e))t.ic.delete(r),n&&t.sc.wc(r,n);t.rc.delete(e),t.isPrimaryClient&&t.ac.ls(e).forEach((e=>{t.ac.containsKey(e)||gh(t,e)}))}function gh(t,e){t.oc.delete(e.path.canonicalString());const n=t.uc.get(e);null!==n&&(gu(t.remoteStore,n),t.uc=t.uc.remove(e),t.cc.delete(n),vh(t))}function mh(t,e,n){for(const r of n)r instanceof Xu?(t.ac.addReference(r.key,e),yh(t,r)):r instanceof Zu?(As("SyncEngine","Document no longer in limbo: "+r.key),t.ac.removeReference(r.key,e),t.ac.containsKey(r.key)||gh(t,r.key)):Os()}function yh(t,e){const n=e.key,r=n.path.canonicalString();t.uc.get(n)||t.oc.has(r)||(As("SyncEngine","New document in limbo: "+n),t.oc.add(r),vh(t))}function vh(t){for(;t.oc.size>0&&t.uc.size<t.maxConcurrentLimboResolutions;){const e=t.oc.values().next().value;t.oc.delete(e);const n=new no(Zs.fromString(e)),r=t.fc.next();t.cc.set(r,new nh(n)),t.uc=t.uc.insert(n,r),pu(t.remoteStore,new Sl(La(Ia(n.path)),r,2,ho.at))}}async function wh(t,e,n){const r=Ps(t),i=[],s=[],o=[];r.ic.isEmpty()||(r.ic.forEach(((t,a)=>{o.push(r._c(a,e,n).then((t=>{if((t||n)&&r.isPrimaryClient&&r.sharedClientState.updateQueryState(a.targetId,(null==t?void 0:t.fromCache)?"not-current":"current"),t){i.push(t);const e=Vl.Ci(a.targetId,t);s.push(e)}})))})),await Promise.all(o),r.sc.Wo(i),await async function(t,e){const n=Ps(t);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(t=>lo.forEach(e,(e=>lo.forEach(e.Si,(r=>n.persistence.referenceDelegate.addReference(t,e.targetId,r))).next((()=>lo.forEach(e.Di,(r=>n.persistence.referenceDelegate.removeReference(t,e.targetId,r)))))))))}catch(t){if(!uo(t))throw t;As("LocalStore","Failed to update sequence numbers: "+t)}for(const t of e){const e=t.targetId;if(!t.fromCache){const t=n.qi.get(e),r=t.snapshotVersion,i=t.withLastLimboFreeSnapshotVersion(r);n.qi=n.qi.insert(e,i)}}}(r.localStore,s))}async function bh(t,e){const n=Ps(t);if(!n.currentUser.isEqual(e)){As("SyncEngine","User change. New user:",e.toKey());const t=await $l(n.localStore,e);n.currentUser=e,function(t,e){t.lc.forEach((t=>{t.forEach((t=>{t.reject(new Ms(xs.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.lc.clear()}(n),n.sharedClientState.handleUserChange(e,t.removedBatchIds,t.addedBatchIds),await wh(n,t.ji)}}function Sh(t,e){const n=Ps(t),r=n.cc.get(e);if(r&&r.nc)return Oc().add(r.key);{let t=Oc();const r=n.rc.get(e);if(!r)return t;for(const e of r){const r=n.ic.get(e);t=t.unionWith(r.view.ju)}return t}}class _h{constructor(){this.synchronizeTabs=!1}async initialize(t){this.yt=iu(t.databaseInfo.databaseId),this.sharedClientState=this.gc(t),this.persistence=this.yc(t),await this.persistence.start(),this.localStore=this.Ic(t),this.gcScheduler=this.Tc(t,this.localStore),this.indexBackfillerScheduler=this.Ec(t,this.localStore)}Tc(t,e){return null}Ec(t,e){return null}Ic(t){return function(t,e,n,r){return new jl(t,e,n,r)}(this.persistence,new Hl,t.initialUser,this.yt)}yc(t){return new Fl(Bl.Bs,this.yt)}gc(t){return new Jl}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class Eh{async initialize(t,e){this.localStore||(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=t=>ch(this.syncEngine,t,1),this.remoteStore.remoteSyncer.handleCredentialChange=bh.bind(null,this.syncEngine),await async function(t,e){const n=Ps(t);e?(n._u.delete(2),await du(n)):e||(n._u.add(2),await fu(n),n.gu.set("Unknown"))}(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(t){return new qu}createDatastore(t){const e=iu(t.databaseInfo.databaseId),n=(r=t.databaseInfo,new nu(r));var r;return function(t,e,n,r){return new lu(t,e,n,r)}(t.authCredentials,t.appCheckCredentials,n,e)}createRemoteStore(t){return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=t=>ch(this.syncEngine,t,0),s=Zl.C()?new Zl:new Xl,new hu(e,n,r,i,s);var e,n,r,i,s}createSyncEngine(t,e){return function(t,e,n,r,i,s,o){const a=new rh(t,e,n,r,i,s);return o&&(a.dc=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)}terminate(){return async function(t){const e=Ps(t);As("RemoteStore","RemoteStore shutting down."),e._u.add(5),await fu(e),e.mu.shutdown(),e.gu.set("Unknown")}(this.remoteStore)}}
1686
1686
  /**
1687
1687
  * @license
1688
1688
  * Copyright 2017 Google LLC
@@ -1907,7 +1907,7 @@ function(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported b
1907
1907
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1908
1908
  * See the License for the specific language governing permissions and
1909
1909
  * limitations under the License.
1910
- */class Gh{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Gh(So.fromBase64String(t))}catch(t){throw new Ms(xs.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new Gh(So.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}
1910
+ */class Gh{constructor(t){this._byteString=t}static fromBase64String(t){try{return new Gh(bo.fromBase64String(t))}catch(t){throw new Ms(xs.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(t){return new Gh(bo.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(t){return this._byteString.isEqual(t._byteString)}}
1911
1911
  /**
1912
1912
  * @license
1913
1913
  * Copyright 2020 Google LLC
@@ -2004,7 +2004,7 @@ class Yh{constructor(t){this._methodName=t}}
2004
2004
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2005
2005
  * See the License for the specific language governing permissions and
2006
2006
  * limitations under the License.
2007
- */function yd(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new Ms(xs.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class vd{}class wd extends vd{}function Sd(t,e,...n){let r=[];e instanceof vd&&r.push(e),r=r.concat(n),function(t){const e=t.filter((t=>t instanceof Ed)).length,n=t.filter((t=>t instanceof bd)).length;if(e>1||e>0&&n>0)throw new Ms(xs.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}
2007
+ */function yd(t){if("L"===t.limitType&&0===t.explicitOrderBy.length)throw new Ms(xs.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class vd{}class wd extends vd{}function bd(t,e,...n){let r=[];e instanceof vd&&r.push(e),r=r.concat(n),function(t){const e=t.filter((t=>t instanceof Ed)).length,n=t.filter((t=>t instanceof Sd)).length;if(e>1||e>0&&n>0)throw new Ms(xs.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}
2008
2008
  /**
2009
2009
  * @license
2010
2010
  * Copyright 2020 Google LLC
@@ -2020,7 +2020,7 @@ class Yh{constructor(t){this._methodName=t}}
2020
2020
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2021
2021
  * See the License for the specific language governing permissions and
2022
2022
  * limitations under the License.
2023
- */(r);for(const e of r)t=e._apply(t);return t}class bd extends wd{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new bd(t,e,n)}_apply(t){const e=this._parse(t);return kd(t._query,e),new Ph(t.firestore,t.converter,Oa(t._query,e))}_parse(t){const e=rd(t.firestore),n=function(t,e,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new Ms(xs.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){Id(o,s);const e=[];for(const n of o)e.push(Td(r,t,n));a={arrayValue:{values:e}}}else a=Td(r,t,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||Id(o,s),a=function(t,e,n,r=!1){return sd(n,t.da(r?4:3,e))}(n,"where",o,"in"===s||"not-in"===s);return Ko.create(i,s,a)}(t._query,0,e,t.firestore._databaseId,this._field,this._op,this._value);return n}}function _d(t,e,n){const r=e,i=md("where",t);return bd._create(i,r,n)}class Ed extends vd{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new Ed(t,e)}_parse(t){const e=this._queryConstraints.map((e=>e._parse(t))).filter((t=>t.getFilters().length>0));return 1===e.length?e[0]:Go.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return 0===e.getFilters().length?t:(function(t,e){let n=t;const r=e.getFlattenedFilters();for(const t of r)kd(n,t),n=Oa(n,t)}(t._query,e),new Ph(t.firestore,t.converter,Oa(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function Td(t,e,n){if("string"==typeof(n=ue(n))){if(""===n)throw new Ms(xs.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ra(e)&&-1!==n.indexOf("/"))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(Zs.fromString(n));if(!no.isDocumentKey(r))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Mo(t,new no(r))}if(n instanceof Dh)return Mo(t,n._key);throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ch(n)}.`)}function Id(t,e){if(!Array.isArray(t)||0===t.length)throw new Ms(xs.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Ms(xs.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function kd(t,e){if(e.isInequality()){const n=Aa(t),r=e.field;if(null!==n&&!n.isEqual(r))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${r.toString()}'`);const i=Ca(t);null!==i&&function(t,e,n){if(!n.isEqual(e))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}(0,r,i)}const n=function(t,e){for(const n of t)for(const t of n.getFlattenedFilters())if(e.indexOf(t.op)>=0)return t.op;return null}(t.filters,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Ms(xs.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Ms(xs.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}class Cd{convertValue(t,e="none"){switch(Ro(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Eo(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(To(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Os()}}convertObject(t,e){const n={};return mo(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new Jh(Eo(t.latitude),Eo(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=ko(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Co(t));default:return null}}convertTimestamp(t){const e=_o(t);return new Ys(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=Zs.fromString(t);Ds(yl(n));const r=new po(n.get(1),n.get(3)),i=new no(n.popFirst(5));return r.isEqual(e)||Rs(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),i}}
2023
+ */(r);for(const e of r)t=e._apply(t);return t}class Sd extends wd{constructor(t,e,n){super(),this._field=t,this._op=e,this._value=n,this.type="where"}static _create(t,e,n){return new Sd(t,e,n)}_apply(t){const e=this._parse(t);return kd(t._query,e),new Ph(t.firestore,t.converter,Oa(t._query,e))}_parse(t){const e=rd(t.firestore),n=function(t,e,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new Ms(xs.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){Id(o,s);const e=[];for(const n of o)e.push(Td(r,t,n));a={arrayValue:{values:e}}}else a=Td(r,t,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||Id(o,s),a=function(t,e,n,r=!1){return sd(n,t.da(r?4:3,e))}(n,"where",o,"in"===s||"not-in"===s);return Ko.create(i,s,a)}(t._query,0,e,t.firestore._databaseId,this._field,this._op,this._value);return n}}function _d(t,e,n){const r=e,i=md("where",t);return Sd._create(i,r,n)}class Ed extends vd{constructor(t,e){super(),this.type=t,this._queryConstraints=e}static _create(t,e){return new Ed(t,e)}_parse(t){const e=this._queryConstraints.map((e=>e._parse(t))).filter((t=>t.getFilters().length>0));return 1===e.length?e[0]:Go.create(e,this._getOperator())}_apply(t){const e=this._parse(t);return 0===e.getFilters().length?t:(function(t,e){let n=t;const r=e.getFlattenedFilters();for(const t of r)kd(n,t),n=Oa(n,t)}(t._query,e),new Ph(t.firestore,t.converter,Oa(t._query,e)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function Td(t,e,n){if("string"==typeof(n=ue(n))){if(""===n)throw new Ms(xs.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ra(e)&&-1!==n.indexOf("/"))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=e.path.child(Zs.fromString(n));if(!no.isDocumentKey(r))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Mo(t,new no(r))}if(n instanceof Dh)return Mo(t,n._key);throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Ch(n)}.`)}function Id(t,e){if(!Array.isArray(t)||0===t.length)throw new Ms(xs.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(t.length>10)throw new Ms(xs.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function kd(t,e){if(e.isInequality()){const n=Aa(t),r=e.field;if(null!==n&&!n.isEqual(r))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${r.toString()}'`);const i=Ca(t);null!==i&&function(t,e,n){if(!n.isEqual(e))throw new Ms(xs.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}(0,r,i)}const n=function(t,e){for(const n of t)for(const t of n.getFlattenedFilters())if(e.indexOf(t.op)>=0)return t.op;return null}(t.filters,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==n)throw n===e.op?new Ms(xs.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new Ms(xs.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${n.toString()}' filters.`)}class Cd{convertValue(t,e="none"){switch(Ro(t)){case 0:return null;case 1:return t.booleanValue;case 2:return Eo(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(To(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw Os()}}convertObject(t,e){const n={};return mo(t.fields,((t,r)=>{n[t]=this.convertValue(r,e)})),n}convertGeoPoint(t){return new Jh(Eo(t.latitude),Eo(t.longitude))}convertArray(t,e){return(t.values||[]).map((t=>this.convertValue(t,e)))}convertServerTimestamp(t,e){switch(e){case"previous":const n=ko(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(Co(t));default:return null}}convertTimestamp(t){const e=_o(t);return new Ys(e.seconds,e.nanos)}convertDocumentKey(t,e){const n=Zs.fromString(t);Ds(yl(n));const r=new po(n.get(1),n.get(3)),i=new no(n.popFirst(5));return r.isEqual(e)||Rs(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${e.projectId}/${e.database}) instead.`),i}}
2024
2024
  /**
2025
2025
  * @license
2026
2026
  * Copyright 2020 Google LLC
@@ -2086,7 +2086,7 @@ class Ad{constructor(t,e){this.hasPendingWrites=t,this.fromCache=e}isEqual(t){re
2086
2086
  * See the License for the specific language governing permissions and
2087
2087
  * limitations under the License.
2088
2088
  */
2089
- Vt("firebase","10.13.0","app");class zd{constructor(){}static getInstance(){return zd.instance||(zd.instance=new zd),zd.instance}setEnv(t){switch(t){case"production":case"prod":this.env="prod";break;default:this.env="dev"}}get firebase(){return"prod"===this.env?Vd.firebase:Bd.firebase}get api(){return"prod"===this.env?Vd.api:Bd.api}get config(){return"prod"===this.env?Vd.config:Bd.config}}const Bd={firebase:{apiKey:"AIzaSyDfjBWzpmzb-mhGN8VSURxzLg6nkzmKUD8",authDomain:"fittingroom-dev-5d248.firebaseapp.com",projectId:"fittingroom-dev-5d248",storageBucket:"fittingroom-dev-5d248.appspot.com",messagingSenderId:"2298664147",appId:"1:2298664147:web:340bda75cd5d25f3997026"},api:{url:"https://tfr.dev.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}},Vd={firebase:{apiKey:"AIzaSyA3kQ6w1vkA9l9lgY0nNACVPXe-QmP5T1Y",authDomain:"fittingroom-prod.firebaseapp.com",projectId:"fittingroom-prod",storageBucket:"fittingroom-prod.appspot.com",messagingSenderId:"965656825574",appId:"1:965656825574:web:933493cddc73213bd43527"},api:{url:"https://tfr.p.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}};var Hd=1e3,jd=6e4,$d=36e5,qd="millisecond",Wd="second",Kd="minute",Gd="hour",Qd="day",Yd="week",Jd="month",Xd="quarter",Zd="year",tf="date",ef="Invalid Date",nf=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,rf=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,sf={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},of=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},af={s:of,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+of(r,2,"0")+":"+of(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,Jd),s=n-i<0,o=e.clone().add(r+(s?-1:1),Jd);return+(-(r+(n-i)/(s?i-o:o-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:Jd,y:Zd,w:Yd,d:Qd,D:tf,h:Gd,m:Kd,s:Wd,ms:qd,Q:Xd}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},cf="en",lf={};lf[cf]=sf;var uf="$isDayjsObject",hf=function(t){return t instanceof gf||!(!t||!t[uf])},df=function t(e,n,r){var i;if(!e)return cf;if("string"==typeof e){var s=e.toLowerCase();lf[s]&&(i=s),n&&(lf[s]=n,i=s);var o=e.split("-");if(!i&&o.length>1)return t(o[0])}else{var a=e.name;lf[a]=e,i=a}return!r&&i&&(cf=i),i||!r&&cf},ff=function(t,e){if(hf(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new gf(n)},pf=af;pf.l=df,pf.i=hf,pf.w=function(t,e){return ff(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var gf=function(){function t(t){this.$L=df(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[uf]=!0}var e=t.prototype;return e.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(pf.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(nf);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},e.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},e.$utils=function(){return pf},e.isValid=function(){return!(this.$d.toString()===ef)},e.isSame=function(t,e){var n=ff(t);return this.startOf(e)<=n&&n<=this.endOf(e)},e.isAfter=function(t,e){return ff(t)<this.startOf(e)},e.isBefore=function(t,e){return this.endOf(e)<ff(t)},e.$g=function(t,e,n){return pf.u(t)?this[e]:this.set(n,t)},e.unix=function(){return Math.floor(this.valueOf()/1e3)},e.valueOf=function(){return this.$d.getTime()},e.startOf=function(t,e){var n=this,r=!!pf.u(e)||e,i=pf.p(t),s=function(t,e){var i=pf.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(Qd)},o=function(t,e){return pf.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},a=this.$W,c=this.$M,l=this.$D,u="set"+(this.$u?"UTC":"");switch(i){case Zd:return r?s(1,0):s(31,11);case Jd:return r?s(1,c):s(0,c+1);case Yd:var h=this.$locale().weekStart||0,d=(a<h?a+7:a)-h;return s(r?l-d:l+(6-d),c);case Qd:case tf:return o(u+"Hours",0);case Gd:return o(u+"Minutes",1);case Kd:return o(u+"Seconds",2);case Wd:return o(u+"Milliseconds",3);default:return this.clone()}},e.endOf=function(t){return this.startOf(t,!1)},e.$set=function(t,e){var n,r=pf.p(t),i="set"+(this.$u?"UTC":""),s=(n={},n[Qd]=i+"Date",n[tf]=i+"Date",n[Jd]=i+"Month",n[Zd]=i+"FullYear",n[Gd]=i+"Hours",n[Kd]=i+"Minutes",n[Wd]=i+"Seconds",n[qd]=i+"Milliseconds",n)[r],o=r===Qd?this.$D+(e-this.$W):e;if(r===Jd||r===Zd){var a=this.clone().set(tf,1);a.$d[s](o),a.init(),this.$d=a.set(tf,Math.min(this.$D,a.daysInMonth())).$d}else s&&this.$d[s](o);return this.init(),this},e.set=function(t,e){return this.clone().$set(t,e)},e.get=function(t){return this[pf.p(t)]()},e.add=function(t,e){var n,r=this;t=Number(t);var i=pf.p(e),s=function(e){var n=ff(r);return pf.w(n.date(n.date()+Math.round(e*t)),r)};if(i===Jd)return this.set(Jd,this.$M+t);if(i===Zd)return this.set(Zd,this.$y+t);if(i===Qd)return s(1);if(i===Yd)return s(7);var o=(n={},n[Kd]=jd,n[Gd]=$d,n[Wd]=Hd,n)[i]||1,a=this.$d.getTime()+t*o;return pf.w(a,this)},e.subtract=function(t,e){return this.add(-1*t,e)},e.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||ef;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=pf.z(this),s=this.$H,o=this.$m,a=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return pf.s(s%12||12,t,"0")},f=u||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(rf,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return pf.s(e.$y,4,"0");case"M":return a+1;case"MM":return pf.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,l,3);case"MMMM":return h(l,a);case"D":return e.$D;case"DD":return pf.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,c,2);case"ddd":return h(n.weekdaysShort,e.$W,c,3);case"dddd":return c[e.$W];case"H":return String(s);case"HH":return pf.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return f(s,o,!0);case"A":return f(s,o,!1);case"m":return String(o);case"mm":return pf.s(o,2,"0");case"s":return String(e.$s);case"ss":return pf.s(e.$s,2,"0");case"SSS":return pf.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},e.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},e.diff=function(t,e,n){var r,i=this,s=pf.p(e),o=ff(t),a=(o.utcOffset()-this.utcOffset())*jd,c=this-o,l=function(){return pf.m(i,o)};switch(s){case Zd:r=l()/12;break;case Jd:r=l();break;case Xd:r=l()/3;break;case Yd:r=(c-a)/6048e5;break;case Qd:r=(c-a)/864e5;break;case Gd:r=c/$d;break;case Kd:r=c/jd;break;case Wd:r=c/Hd;break;default:r=c}return n?r:pf.a(r)},e.daysInMonth=function(){return this.endOf(Jd).$D},e.$locale=function(){return lf[this.$L]},e.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=df(t,e,!0);return r&&(n.$L=r),n},e.clone=function(){return pf.w(this.$d,this)},e.toDate=function(){return new Date(this.valueOf())},e.toJSON=function(){return this.isValid()?this.toISOString():null},e.toISOString=function(){return this.$d.toISOString()},e.toString=function(){return this.$d.toUTCString()},t}(),mf=gf.prototype;function yf(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function vf(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}ff.prototype=mf,[["$ms",qd],["$s",Wd],["$m",Kd],["$H",Gd],["$W",Qd],["$M",Jd],["$y",Zd],["$D",tf]].forEach((function(t){mf[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),ff.extend=function(t,e){return t.$i||(t(e,gf,ff),t.$i=!0),ff},ff.locale=df,ff.isDayjs=hf,ff.unix=function(t){return ff(1e3*t)},ff.en=lf[cf],ff.Ls=lf,ff.p={},"function"==typeof SuppressedError&&SuppressedError;const wf=vf,Sf=new g("auth","Firebase",{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}),bf="auth/user-disabled",_f=new P("@firebase/auth");function Ef(t,...e){_f.logLevel<=R.ERROR&&_f.error(`Auth (${Ft}): ${t}`,...e)}
2089
+ Vt("firebase","10.13.0","app");class zd{constructor(){}static getInstance(){return zd.instance||(zd.instance=new zd),zd.instance}setEnv(t){switch(t){case"production":case"prod":this.env="prod";break;default:this.env="dev"}}get firebase(){return"prod"===this.env?Vd.firebase:Bd.firebase}get api(){return"prod"===this.env?Vd.api:Bd.api}get config(){return"prod"===this.env?Vd.config:Bd.config}}const Bd={firebase:{apiKey:"AIzaSyDfjBWzpmzb-mhGN8VSURxzLg6nkzmKUD8",authDomain:"fittingroom-dev-5d248.firebaseapp.com",projectId:"fittingroom-dev-5d248",storageBucket:"fittingroom-dev-5d248.appspot.com",messagingSenderId:"2298664147",appId:"1:2298664147:web:340bda75cd5d25f3997026"},api:{url:"https://tfr.dev.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}},Vd={firebase:{apiKey:"AIzaSyA3kQ6w1vkA9l9lgY0nNACVPXe-QmP5T1Y",authDomain:"fittingroom-prod.firebaseapp.com",projectId:"fittingroom-prod",storageBucket:"fittingroom-prod.appspot.com",messagingSenderId:"965656825574",appId:"1:965656825574:web:933493cddc73213bd43527"},api:{url:"https://tfr.p.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}};var Hd=1e3,jd=6e4,$d=36e5,qd="millisecond",Wd="second",Kd="minute",Gd="hour",Qd="day",Yd="week",Jd="month",Xd="quarter",Zd="year",tf="date",ef="Invalid Date",nf=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,rf=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,sf={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},of=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},af={s:of,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+of(r,2,"0")+":"+of(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,Jd),s=n-i<0,o=e.clone().add(r+(s?-1:1),Jd);return+(-(r+(n-i)/(s?i-o:o-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:Jd,y:Zd,w:Yd,d:Qd,D:tf,h:Gd,m:Kd,s:Wd,ms:qd,Q:Xd}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},cf="en",lf={};lf[cf]=sf;var uf="$isDayjsObject",hf=function(t){return t instanceof gf||!(!t||!t[uf])},df=function t(e,n,r){var i;if(!e)return cf;if("string"==typeof e){var s=e.toLowerCase();lf[s]&&(i=s),n&&(lf[s]=n,i=s);var o=e.split("-");if(!i&&o.length>1)return t(o[0])}else{var a=e.name;lf[a]=e,i=a}return!r&&i&&(cf=i),i||!r&&cf},ff=function(t,e){if(hf(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new gf(n)},pf=af;pf.l=df,pf.i=hf,pf.w=function(t,e){return ff(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var gf=function(){function t(t){this.$L=df(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[uf]=!0}var e=t.prototype;return e.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(pf.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(nf);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},e.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},e.$utils=function(){return pf},e.isValid=function(){return!(this.$d.toString()===ef)},e.isSame=function(t,e){var n=ff(t);return this.startOf(e)<=n&&n<=this.endOf(e)},e.isAfter=function(t,e){return ff(t)<this.startOf(e)},e.isBefore=function(t,e){return this.endOf(e)<ff(t)},e.$g=function(t,e,n){return pf.u(t)?this[e]:this.set(n,t)},e.unix=function(){return Math.floor(this.valueOf()/1e3)},e.valueOf=function(){return this.$d.getTime()},e.startOf=function(t,e){var n=this,r=!!pf.u(e)||e,i=pf.p(t),s=function(t,e){var i=pf.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(Qd)},o=function(t,e){return pf.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},a=this.$W,c=this.$M,l=this.$D,u="set"+(this.$u?"UTC":"");switch(i){case Zd:return r?s(1,0):s(31,11);case Jd:return r?s(1,c):s(0,c+1);case Yd:var h=this.$locale().weekStart||0,d=(a<h?a+7:a)-h;return s(r?l-d:l+(6-d),c);case Qd:case tf:return o(u+"Hours",0);case Gd:return o(u+"Minutes",1);case Kd:return o(u+"Seconds",2);case Wd:return o(u+"Milliseconds",3);default:return this.clone()}},e.endOf=function(t){return this.startOf(t,!1)},e.$set=function(t,e){var n,r=pf.p(t),i="set"+(this.$u?"UTC":""),s=(n={},n[Qd]=i+"Date",n[tf]=i+"Date",n[Jd]=i+"Month",n[Zd]=i+"FullYear",n[Gd]=i+"Hours",n[Kd]=i+"Minutes",n[Wd]=i+"Seconds",n[qd]=i+"Milliseconds",n)[r],o=r===Qd?this.$D+(e-this.$W):e;if(r===Jd||r===Zd){var a=this.clone().set(tf,1);a.$d[s](o),a.init(),this.$d=a.set(tf,Math.min(this.$D,a.daysInMonth())).$d}else s&&this.$d[s](o);return this.init(),this},e.set=function(t,e){return this.clone().$set(t,e)},e.get=function(t){return this[pf.p(t)]()},e.add=function(t,e){var n,r=this;t=Number(t);var i=pf.p(e),s=function(e){var n=ff(r);return pf.w(n.date(n.date()+Math.round(e*t)),r)};if(i===Jd)return this.set(Jd,this.$M+t);if(i===Zd)return this.set(Zd,this.$y+t);if(i===Qd)return s(1);if(i===Yd)return s(7);var o=(n={},n[Kd]=jd,n[Gd]=$d,n[Wd]=Hd,n)[i]||1,a=this.$d.getTime()+t*o;return pf.w(a,this)},e.subtract=function(t,e){return this.add(-1*t,e)},e.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||ef;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=pf.z(this),s=this.$H,o=this.$m,a=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return pf.s(s%12||12,t,"0")},f=u||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(rf,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return pf.s(e.$y,4,"0");case"M":return a+1;case"MM":return pf.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,l,3);case"MMMM":return h(l,a);case"D":return e.$D;case"DD":return pf.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,c,2);case"ddd":return h(n.weekdaysShort,e.$W,c,3);case"dddd":return c[e.$W];case"H":return String(s);case"HH":return pf.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return f(s,o,!0);case"A":return f(s,o,!1);case"m":return String(o);case"mm":return pf.s(o,2,"0");case"s":return String(e.$s);case"ss":return pf.s(e.$s,2,"0");case"SSS":return pf.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},e.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},e.diff=function(t,e,n){var r,i=this,s=pf.p(e),o=ff(t),a=(o.utcOffset()-this.utcOffset())*jd,c=this-o,l=function(){return pf.m(i,o)};switch(s){case Zd:r=l()/12;break;case Jd:r=l();break;case Xd:r=l()/3;break;case Yd:r=(c-a)/6048e5;break;case Qd:r=(c-a)/864e5;break;case Gd:r=c/$d;break;case Kd:r=c/jd;break;case Wd:r=c/Hd;break;default:r=c}return n?r:pf.a(r)},e.daysInMonth=function(){return this.endOf(Jd).$D},e.$locale=function(){return lf[this.$L]},e.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=df(t,e,!0);return r&&(n.$L=r),n},e.clone=function(){return pf.w(this.$d,this)},e.toDate=function(){return new Date(this.valueOf())},e.toJSON=function(){return this.isValid()?this.toISOString():null},e.toISOString=function(){return this.$d.toISOString()},e.toString=function(){return this.$d.toUTCString()},t}(),mf=gf.prototype;function yf(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function vf(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}ff.prototype=mf,[["$ms",qd],["$s",Wd],["$m",Kd],["$H",Gd],["$W",Qd],["$M",Jd],["$y",Zd],["$D",tf]].forEach((function(t){mf[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),ff.extend=function(t,e){return t.$i||(t(e,gf,ff),t.$i=!0),ff},ff.locale=df,ff.isDayjs=hf,ff.unix=function(t){return ff(1e3*t)},ff.en=lf[cf],ff.Ls=lf,ff.p={},"function"==typeof SuppressedError&&SuppressedError;const wf=vf,bf=new g("auth","Firebase",{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}),Sf="auth/user-disabled",_f=new P("@firebase/auth");function Ef(t,...e){_f.logLevel<=R.ERROR&&_f.error(`Auth (${Ft}): ${t}`,...e)}
2090
2090
  /**
2091
2091
  * @license
2092
2092
  * Copyright 2020 Google LLC
@@ -2102,7 +2102,7 @@ Vt("firebase","10.13.0","app");class zd{constructor(){}static getInstance(){retu
2102
2102
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2103
2103
  * See the License for the specific language governing permissions and
2104
2104
  * limitations under the License.
2105
- */function Tf(t,...e){throw Af(t,...e)}function If(t,...e){return Af(t,...e)}function kf(t,e,n){const r=Object.assign(Object.assign({},wf()),{[e]:n});return new g("auth","Firebase",r).create(e,{appName:t.name})}function Cf(t){return kf(t,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Af(t,...e){if("string"!=typeof t){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return Sf.create(t,...e)}function Rf(t,e,...n){if(!t)throw Af(e,...n)}function Nf(t){const e="INTERNAL ASSERTION FAILED: "+t;throw Ef(e),new Error(e)}function Lf(t,e){t||Nf(e)}
2105
+ */function Tf(t,...e){throw Af(t,...e)}function If(t,...e){return Af(t,...e)}function kf(t,e,n){const r=Object.assign(Object.assign({},wf()),{[e]:n});return new g("auth","Firebase",r).create(e,{appName:t.name})}function Cf(t){return kf(t,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Af(t,...e){if("string"!=typeof t){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return bf.create(t,...e)}function Rf(t,e,...n){if(!t)throw Af(e,...n)}function Nf(t){const e="INTERNAL ASSERTION FAILED: "+t;throw Ef(e),new Error(e)}function Lf(t,e){t||Nf(e)}
2106
2106
  /**
2107
2107
  * @license
2108
2108
  * Copyright 2020 Google LLC
@@ -2361,7 +2361,7 @@ class op{constructor(){this.refreshToken=null,this.accessToken=null,this.expirat
2361
2361
  * See the License for the specific language governing permissions and
2362
2362
  * limitations under the License.
2363
2363
  */
2364
- async function(t,e){return Vf(t,"POST","/v1/accounts:delete",e)}(this.auth,{idToken:t})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map((t=>Object.assign({},t))),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(t,e){var n,r,i,s,o,a,c,l;const u=null!==(n=e.displayName)&&void 0!==n?n:void 0,h=null!==(r=e.email)&&void 0!==r?r:void 0,d=null!==(i=e.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=e.photoURL)&&void 0!==s?s:void 0,p=null!==(o=e.tenantId)&&void 0!==o?o:void 0,g=null!==(a=e._redirectEventId)&&void 0!==a?a:void 0,m=null!==(c=e.createdAt)&&void 0!==c?c:void 0,y=null!==(l=e.lastLoginAt)&&void 0!==l?l:void 0,{uid:v,emailVerified:w,isAnonymous:S,providerData:b,stsTokenManager:_}=e;Rf(v&&_,t,"internal-error");const E=op.fromJSON(this.name,_);Rf("string"==typeof v,t,"internal-error"),ap(u,t.name),ap(h,t.name),Rf("boolean"==typeof w,t,"internal-error"),Rf("boolean"==typeof S,t,"internal-error"),ap(d,t.name),ap(f,t.name),ap(p,t.name),ap(g,t.name),ap(m,t.name),ap(y,t.name);const T=new cp({uid:v,auth:t,email:h,emailVerified:w,displayName:u,isAnonymous:S,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:E,createdAt:m,lastLoginAt:y});return b&&Array.isArray(b)&&(T.providerData=b.map((t=>Object.assign({},t)))),g&&(T._redirectEventId=g),T}static async _fromIdTokenResponse(t,e,n=!1){const r=new op;r.updateFromServerResponse(e);const i=new cp({uid:e.localId,auth:t,stsTokenManager:r,isAnonymous:n});return await ip(i),i}static async _fromGetAccountInfoResponse(t,e,n){const r=e.users[0];Rf(void 0!==r.localId,"internal-error");const i=void 0!==r.providerUserInfo?sp(r.providerUserInfo):[],s=!(r.email&&r.passwordHash||(null==i?void 0:i.length)),o=new op;o.updateFromIdToken(n);const a=new cp({uid:r.localId,auth:t,stsTokenManager:o,isAnonymous:s}),c={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new rp(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash||(null==i?void 0:i.length))};return Object.assign(a,c),a}}
2364
+ async function(t,e){return Vf(t,"POST","/v1/accounts:delete",e)}(this.auth,{idToken:t})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map((t=>Object.assign({},t))),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(t,e){var n,r,i,s,o,a,c,l;const u=null!==(n=e.displayName)&&void 0!==n?n:void 0,h=null!==(r=e.email)&&void 0!==r?r:void 0,d=null!==(i=e.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=e.photoURL)&&void 0!==s?s:void 0,p=null!==(o=e.tenantId)&&void 0!==o?o:void 0,g=null!==(a=e._redirectEventId)&&void 0!==a?a:void 0,m=null!==(c=e.createdAt)&&void 0!==c?c:void 0,y=null!==(l=e.lastLoginAt)&&void 0!==l?l:void 0,{uid:v,emailVerified:w,isAnonymous:b,providerData:S,stsTokenManager:_}=e;Rf(v&&_,t,"internal-error");const E=op.fromJSON(this.name,_);Rf("string"==typeof v,t,"internal-error"),ap(u,t.name),ap(h,t.name),Rf("boolean"==typeof w,t,"internal-error"),Rf("boolean"==typeof b,t,"internal-error"),ap(d,t.name),ap(f,t.name),ap(p,t.name),ap(g,t.name),ap(m,t.name),ap(y,t.name);const T=new cp({uid:v,auth:t,email:h,emailVerified:w,displayName:u,isAnonymous:b,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:E,createdAt:m,lastLoginAt:y});return S&&Array.isArray(S)&&(T.providerData=S.map((t=>Object.assign({},t)))),g&&(T._redirectEventId=g),T}static async _fromIdTokenResponse(t,e,n=!1){const r=new op;r.updateFromServerResponse(e);const i=new cp({uid:e.localId,auth:t,stsTokenManager:r,isAnonymous:n});return await ip(i),i}static async _fromGetAccountInfoResponse(t,e,n){const r=e.users[0];Rf(void 0!==r.localId,"internal-error");const i=void 0!==r.providerUserInfo?sp(r.providerUserInfo):[],s=!(r.email&&r.passwordHash||(null==i?void 0:i.length)),o=new op;o.updateFromIdToken(n);const a=new cp({uid:r.localId,auth:t,stsTokenManager:o,isAnonymous:s}),c={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new rp(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash||(null==i?void 0:i.length))};return Object.assign(a,c),a}}
2365
2365
  /**
2366
2366
  * @license
2367
2367
  * Copyright 2020 Google LLC
@@ -2425,7 +2425,7 @@ async function(t,e){return Vf(t,"POST","/v1/accounts:delete",e)}(this.auth,{idTo
2425
2425
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2426
2426
  * See the License for the specific language governing permissions and
2427
2427
  * limitations under the License.
2428
- */function gp(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(wp(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(mp(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(bp(e))return"Blackberry";if(_p(e))return"Webos";if(yp(e))return"Safari";if((e.includes("chrome/")||vp(e))&&!e.includes("edge/"))return"Chrome";if(Sp(e))return"Android";{const e=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=t.match(e);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function mp(t=f()){return/firefox\//i.test(t)}function yp(t=f()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function vp(t=f()){return/crios\//i.test(t)}function wp(t=f()){return/iemobile/i.test(t)}function Sp(t=f()){return/android/i.test(t)}function bp(t=f()){return/blackberry/i.test(t)}function _p(t=f()){return/webos/i.test(t)}function Ep(t=f()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function Tp(){return function(){const t=f();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}()&&10===document.documentMode}function Ip(t=f()){return Ep(t)||Sp(t)||_p(t)||bp(t)||/windows phone/i.test(t)||wp(t)}
2428
+ */function gp(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(wp(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(mp(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(Sp(e))return"Blackberry";if(_p(e))return"Webos";if(yp(e))return"Safari";if((e.includes("chrome/")||vp(e))&&!e.includes("edge/"))return"Chrome";if(bp(e))return"Android";{const e=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=t.match(e);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function mp(t=f()){return/firefox\//i.test(t)}function yp(t=f()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function vp(t=f()){return/crios\//i.test(t)}function wp(t=f()){return/iemobile/i.test(t)}function bp(t=f()){return/android/i.test(t)}function Sp(t=f()){return/blackberry/i.test(t)}function _p(t=f()){return/webos/i.test(t)}function Ep(t=f()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function Tp(){return function(){const t=f();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}()&&10===document.documentMode}function Ip(t=f()){return Ep(t)||bp(t)||_p(t)||Sp(t)||/windows phone/i.test(t)||wp(t)}
2429
2429
  /**
2430
2430
  * @license
2431
2431
  * Copyright 2020 Google LLC
@@ -2489,7 +2489,7 @@ async function(t,e){return Vf(t,"POST","/v1/accounts:delete",e)}(this.auth,{idTo
2489
2489
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2490
2490
  * See the License for the specific language governing permissions and
2491
2491
  * limitations under the License.
2492
- */class Rp{constructor(t,e,n,r){this.app=t,this.heartbeatServiceProvider=e,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Lp(this),this.idTokenSubscription=new Lp(this),this.beforeStateQueue=new Cp(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Sf,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=r.sdkClientVersion}_initializeWithPersistence(t,e){return e&&(this._popupRedirectResolver=up(e)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await pp.create(this,t),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(t){}await this.initializeCurrentUser(e),this.lastNotifiedUid=(null===(r=this.currentUser)||void 0===r?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}})),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();return this.currentUser||t?this.currentUser&&t&&this.currentUser.uid===t.uid?(this._currentUser._assign(t),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(t,!0):void 0}async initializeCurrentUserFromIdToken(t){try{const e=await Yf(this,{idToken:t}),n=await cp._fromGetAccountInfoResponse(this,e,t);await this.directlySetCurrentUser(n)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(t){var e;if(xt(this.app)){const t=this.app.settings.authIdToken;return t?new Promise((e=>{setTimeout((()=>this.initializeCurrentUserFromIdToken(t).then(e,e)))})):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let r=n,i=!1;if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(e=this.redirectUser)||void 0===e?void 0:e._redirectEventId,s=null==r?void 0:r._redirectEventId,o=await this.tryRedirectSignIn(t);n&&n!==s||!(null==o?void 0:o.user)||(r=o.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(t){r=n,this._popupRedirectResolver._overrideRedirectResult(this,(()=>Promise.reject(t)))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return Rf(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(t){let e=null;try{e=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch(t){await this._setRedirectUser(null)}return e}async reloadAndSetCurrentUserOrClear(t){try{await ip(t)}catch(t){if("auth/network-request-failed"!==(null==t?void 0:t.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(t){if(xt(this.app))return Promise.reject(Cf(this));const e=t?T(t):null;return e&&Rf(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this))}async _updateCurrentUser(t,e=!1){if(!this._deleted)return t&&Rf(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),e||await this.beforeStateQueue.runMiddleware(t),this.queue((async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()}))}async signOut(){return xt(this.app)?Promise.reject(Cf(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(t){return xt(this.app)?Promise.reject(Cf(this)):this.queue((async()=>{await this.assertedPersistence.setPersistence(up(t))}))}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(t){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const e=this._getPasswordPolicyInternal();return e.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):e.validatePassword(t)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const t=await async function(t,e={}){return Vf(t,"GET","/v2/passwordPolicy",Bf(t,e))}
2492
+ */class Rp{constructor(t,e,n,r){this.app=t,this.heartbeatServiceProvider=e,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Lp(this),this.idTokenSubscription=new Lp(this),this.beforeStateQueue=new Cp(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=bf,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=t.name,this.clientVersion=r.sdkClientVersion}_initializeWithPersistence(t,e){return e&&(this._popupRedirectResolver=up(e)),this._initializationPromise=this.queue((async()=>{var n,r;if(!this._deleted&&(this.persistenceManager=await pp.create(this,t),!this._deleted)){if(null===(n=this._popupRedirectResolver)||void 0===n?void 0:n._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(t){}await this.initializeCurrentUser(e),this.lastNotifiedUid=(null===(r=this.currentUser)||void 0===r?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}})),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const t=await this.assertedPersistence.getCurrentUser();return this.currentUser||t?this.currentUser&&t&&this.currentUser.uid===t.uid?(this._currentUser._assign(t),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(t,!0):void 0}async initializeCurrentUserFromIdToken(t){try{const e=await Yf(this,{idToken:t}),n=await cp._fromGetAccountInfoResponse(this,e,t);await this.directlySetCurrentUser(n)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(t){var e;if(xt(this.app)){const t=this.app.settings.authIdToken;return t?new Promise((e=>{setTimeout((()=>this.initializeCurrentUserFromIdToken(t).then(e,e)))})):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let r=n,i=!1;if(t&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(e=this.redirectUser)||void 0===e?void 0:e._redirectEventId,s=null==r?void 0:r._redirectEventId,o=await this.tryRedirectSignIn(t);n&&n!==s||!(null==o?void 0:o.user)||(r=o.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(t){r=n,this._popupRedirectResolver._overrideRedirectResult(this,(()=>Promise.reject(t)))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return Rf(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(t){let e=null;try{e=await this._popupRedirectResolver._completeRedirectFn(this,t,!0)}catch(t){await this._setRedirectUser(null)}return e}async reloadAndSetCurrentUserOrClear(t){try{await ip(t)}catch(t){if("auth/network-request-failed"!==(null==t?void 0:t.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(t)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(t){if(xt(this.app))return Promise.reject(Cf(this));const e=t?T(t):null;return e&&Rf(e.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(e&&e._clone(this))}async _updateCurrentUser(t,e=!1){if(!this._deleted)return t&&Rf(this.tenantId===t.tenantId,this,"tenant-id-mismatch"),e||await this.beforeStateQueue.runMiddleware(t),this.queue((async()=>{await this.directlySetCurrentUser(t),this.notifyAuthListeners()}))}async signOut(){return xt(this.app)?Promise.reject(Cf(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(t){return xt(this.app)?Promise.reject(Cf(this)):this.queue((async()=>{await this.assertedPersistence.setPersistence(up(t))}))}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(t){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const e=this._getPasswordPolicyInternal();return e.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):e.validatePassword(t)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const t=await async function(t,e={}){return Vf(t,"GET","/v2/passwordPolicy",Bf(t,e))}
2493
2493
  /**
2494
2494
  * @license
2495
2495
  * Copyright 2023 Google LLC
@@ -2666,7 +2666,7 @@ class $p extends Bp{constructor(t,e,n,r=null){super("password",n),this._email=t,
2666
2666
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2667
2667
  * See the License for the specific language governing permissions and
2668
2668
  * limitations under the License.
2669
- */class Kp{constructor(t){var e,n,r,i,s,o;const a=S(b(t)),c=null!==(e=a.apiKey)&&void 0!==e?e:null,l=null!==(n=a.oobCode)&&void 0!==n?n:null,u=function(t){switch(t){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(r=a.mode)&&void 0!==r?r:null);Rf(c&&l&&u,"argument-error"),this.apiKey=c,this.operation=u,this.code=l,this.continueUrl=null!==(i=a.continueUrl)&&void 0!==i?i:null,this.languageCode=null!==(s=a.languageCode)&&void 0!==s?s:null,this.tenantId=null!==(o=a.tenantId)&&void 0!==o?o:null}static parseLink(t){const e=function(t){const e=S(b(t)).link,n=e?S(b(e)).deep_link_id:null,r=S(b(t)).deep_link_id;return(r?S(b(r)).link:null)||r||n||e||t}(t);try{return new Kp(e)}catch(t){return null}}}
2669
+ */class Kp{constructor(t){var e,n,r,i,s,o;const a=b(S(t)),c=null!==(e=a.apiKey)&&void 0!==e?e:null,l=null!==(n=a.oobCode)&&void 0!==n?n:null,u=function(t){switch(t){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(r=a.mode)&&void 0!==r?r:null);Rf(c&&l&&u,"argument-error"),this.apiKey=c,this.operation=u,this.code=l,this.continueUrl=null!==(i=a.continueUrl)&&void 0!==i?i:null,this.languageCode=null!==(s=a.languageCode)&&void 0!==s?s:null,this.tenantId=null!==(o=a.tenantId)&&void 0!==o?o:null}static parseLink(t){const e=function(t){const e=b(S(t)).link,n=e?b(S(e)).deep_link_id:null,r=b(S(t)).deep_link_id;return(r?b(S(r)).link:null)||r||n||e||t}(t);try{return new Kp(e)}catch(t){return null}}}
2670
2670
  /**
2671
2671
  * @license
2672
2672
  * Copyright 2020 Google LLC
@@ -3013,7 +3013,7 @@ function yg(t="",e=10){let n="";for(let t=0;t<e;t++)n+=Math.floor(10*Math.random
3013
3013
  * See the License for the specific language governing permissions and
3014
3014
  * limitations under the License.
3015
3015
  */
3016
- function Sg(){return void 0!==wg().WorkerGlobalScope&&"function"==typeof wg().importScripts}
3016
+ function bg(){return void 0!==wg().WorkerGlobalScope&&"function"==typeof wg().importScripts}
3017
3017
  /**
3018
3018
  * @license
3019
3019
  * Copyright 2019 Google LLC
@@ -3030,7 +3030,7 @@ function Sg(){return void 0!==wg().WorkerGlobalScope&&"function"==typeof wg().im
3030
3030
  * See the License for the specific language governing permissions and
3031
3031
  * limitations under the License.
3032
3032
  */
3033
- const bg="firebaseLocalStorageDb",_g="firebaseLocalStorage",Eg="fbase_key";class Tg{constructor(t){this.request=t}toPromise(){return new Promise(((t,e)=>{this.request.addEventListener("success",(()=>{t(this.request.result)})),this.request.addEventListener("error",(()=>{e(this.request.error)}))}))}}function Ig(t,e){return t.transaction([_g],e?"readwrite":"readonly").objectStore(_g)}function kg(){const t=indexedDB.open(bg,1);return new Promise(((e,n)=>{t.addEventListener("error",(()=>{n(t.error)})),t.addEventListener("upgradeneeded",(()=>{const e=t.result;try{e.createObjectStore(_g,{keyPath:Eg})}catch(t){n(t)}})),t.addEventListener("success",(async()=>{const n=t.result;n.objectStoreNames.contains(_g)?e(n):(n.close(),await function(){const t=indexedDB.deleteDatabase(bg);return new Tg(t).toPromise()}(),e(await kg()))}))}))}async function Cg(t,e,n){const r=Ig(t,!0).put({[Eg]:e,value:n});return new Tg(r).toPromise()}function Ag(t,e){const n=Ig(t,!0).delete(e);return new Tg(n).toPromise()}class Rg{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then((()=>{}),(()=>{}))}async _openDb(){return this.db||(this.db=await kg()),this.db}async _withRetries(t){let e=0;for(;;)try{const e=await this._openDb();return await t(e)}catch(t){if(e++>3)throw t;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Sg()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=mg._getInstance(Sg()?self:null),this.receiver._subscribe("keyChanged",(async(t,e)=>({keyProcessed:(await this._poll()).includes(e.key)}))),this.receiver._subscribe("ping",(async(t,e)=>["keyChanged"]))}async initializeSender(){var t,e;if(this.activeServiceWorker=await async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(t){return null}}(),!this.activeServiceWorker)return;this.sender=new vg(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(t=n[0])||void 0===t?void 0:t.fulfilled)&&(null===(e=n[0])||void 0===e?void 0:e.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){if(this.sender&&this.activeServiceWorker&&function(){var t;return(null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null}()===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await kg();return await Cg(t,ug,"1"),await Ag(t,ug),!0}catch(t){}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,e){return this._withPendingWrite((async()=>(await this._withRetries((n=>Cg(n,t,e))),this.localCache[t]=e,this.notifyServiceWorker(t))))}async _get(t){const e=await this._withRetries((e=>async function(t,e){const n=Ig(t,!1).get(e),r=await new Tg(n).toPromise();return void 0===r?null:r.value}(e,t)));return this.localCache[t]=e,e}async _remove(t){return this._withPendingWrite((async()=>(await this._withRetries((e=>Ag(e,t))),delete this.localCache[t],this.notifyServiceWorker(t))))}async _poll(){const t=await this._withRetries((t=>{const e=Ig(t,!1).getAll();return new Tg(e).toPromise()}));if(!t)return[];if(0!==this.pendingWrites)return[];const e=[],n=new Set;if(0!==t.length)for(const{fbase_key:r,value:i}of t)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),e.push(r));for(const t of Object.keys(this.localCache))this.localCache[t]&&!n.has(t)&&(this.notifyListeners(t,null),e.push(t));return e}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,e){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&this.stopPolling()}}Rg.type="LOCAL";const Ng=Rg;new xf(3e4,6e4);
3033
+ const Sg="firebaseLocalStorageDb",_g="firebaseLocalStorage",Eg="fbase_key";class Tg{constructor(t){this.request=t}toPromise(){return new Promise(((t,e)=>{this.request.addEventListener("success",(()=>{t(this.request.result)})),this.request.addEventListener("error",(()=>{e(this.request.error)}))}))}}function Ig(t,e){return t.transaction([_g],e?"readwrite":"readonly").objectStore(_g)}function kg(){const t=indexedDB.open(Sg,1);return new Promise(((e,n)=>{t.addEventListener("error",(()=>{n(t.error)})),t.addEventListener("upgradeneeded",(()=>{const e=t.result;try{e.createObjectStore(_g,{keyPath:Eg})}catch(t){n(t)}})),t.addEventListener("success",(async()=>{const n=t.result;n.objectStoreNames.contains(_g)?e(n):(n.close(),await function(){const t=indexedDB.deleteDatabase(Sg);return new Tg(t).toPromise()}(),e(await kg()))}))}))}async function Cg(t,e,n){const r=Ig(t,!0).put({[Eg]:e,value:n});return new Tg(r).toPromise()}function Ag(t,e){const n=Ig(t,!0).delete(e);return new Tg(n).toPromise()}class Rg{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then((()=>{}),(()=>{}))}async _openDb(){return this.db||(this.db=await kg()),this.db}async _withRetries(t){let e=0;for(;;)try{const e=await this._openDb();return await t(e)}catch(t){if(e++>3)throw t;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return bg()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=mg._getInstance(bg()?self:null),this.receiver._subscribe("keyChanged",(async(t,e)=>({keyProcessed:(await this._poll()).includes(e.key)}))),this.receiver._subscribe("ping",(async(t,e)=>["keyChanged"]))}async initializeSender(){var t,e;if(this.activeServiceWorker=await async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(t){return null}}(),!this.activeServiceWorker)return;this.sender=new vg(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(t=n[0])||void 0===t?void 0:t.fulfilled)&&(null===(e=n[0])||void 0===e?void 0:e.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(t){if(this.sender&&this.activeServiceWorker&&function(){var t;return(null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null}()===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:t},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const t=await kg();return await Cg(t,ug,"1"),await Ag(t,ug),!0}catch(t){}return!1}async _withPendingWrite(t){this.pendingWrites++;try{await t()}finally{this.pendingWrites--}}async _set(t,e){return this._withPendingWrite((async()=>(await this._withRetries((n=>Cg(n,t,e))),this.localCache[t]=e,this.notifyServiceWorker(t))))}async _get(t){const e=await this._withRetries((e=>async function(t,e){const n=Ig(t,!1).get(e),r=await new Tg(n).toPromise();return void 0===r?null:r.value}(e,t)));return this.localCache[t]=e,e}async _remove(t){return this._withPendingWrite((async()=>(await this._withRetries((e=>Ag(e,t))),delete this.localCache[t],this.notifyServiceWorker(t))))}async _poll(){const t=await this._withRetries((t=>{const e=Ig(t,!1).getAll();return new Tg(e).toPromise()}));if(!t)return[];if(0!==this.pendingWrites)return[];const e=[],n=new Set;if(0!==t.length)for(const{fbase_key:r,value:i}of t)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),e.push(r));for(const t of Object.keys(this.localCache))this.localCache[t]&&!n.has(t)&&(this.notifyListeners(t,null),e.push(t));return e}notifyListeners(t,e){this.localCache[t]=e;const n=this.listeners[t];if(n)for(const t of Array.from(n))t(e)}startPolling(){this.stopPolling(),this.pollTimer=setInterval((async()=>this._poll()),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(t,e){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[t]||(this.listeners[t]=new Set,this._get(t)),this.listeners[t].add(e)}_removeListener(t,e){this.listeners[t]&&(this.listeners[t].delete(e),0===this.listeners[t].size&&delete this.listeners[t]),0===Object.keys(this.listeners).length&&this.stopPolling()}}Rg.type="LOCAL";const Ng=Rg;new xf(3e4,6e4);
3034
3034
  /**
3035
3035
  * @license
3036
3036
  * Copyright 2019 Google LLC
@@ -3310,4 +3310,4 @@ class vm{constructor(t){this.auth=t,this.internalListeners=new Map}getUid(){var
3310
3310
  * See the License for the specific language governing permissions and
3311
3311
  * limitations under the License.
3312
3312
  */
3313
- const wm=h("authIdTokenMaxAge")||300;let Sm=null;function bm(t=Bt()){const e=Pt(t,"auth");if(e.isInitialized())return e.getImmediate();const n=function(t,e){const n=Pt(t,"auth");if(n.isInitialized()){const t=n.getImmediate();if(y(n.getOptions(),null!=e?e:{}))return t;Tf(t,"already-initialized")}return n.initialize({options:e})}(t,{popupRedirectResolver:gm,persistence:[Ng,fg,gg]}),r=h("authTokenSyncURL");if(r&&"boolean"==typeof isSecureContext&&isSecureContext){const t=new URL(r,location.origin);if(location.origin===t.origin){const e=(i=t.toString(),async t=>{const e=t&&await t.getIdTokenResult(),n=e&&((new Date).getTime()-Date.parse(e.issuedAtTime))/1e3;if(n&&n>wm)return;const r=null==e?void 0:e.token;Sm!==r&&(Sm=r,await fetch(i,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});!function(t,e,n){T(t).beforeAuthStateChanged(e,n)}(n,e,(()=>e(n.currentUser))),function(t,e,n,r){T(t).onIdTokenChanged(e,n,r)}(n,(t=>e(t)))}}var i;const s=(t=>{var e,n;return null===(n=null===(e=l())||void 0===e?void 0:e.emulatorHosts)||void 0===n?void 0:n[t]})("auth");return s&&Up(n,`http://${s}`),n}var _m;!function(t){Op=t}({loadJS:t=>new Promise(((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=t=>{const e=If("internal-error");e.customData=t,n(e)},r.type="text/javascript",r.charset="UTF-8",function(){var t,e;return null!==(e=null===(t=document.getElementsByTagName("head"))||void 0===t?void 0:t[0])&&void 0!==e?e:document}().appendChild(r)})),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="}),_m="Browser",Dt(new I("auth",((t,{options:e})=>{const n=t.getProvider("app").getImmediate(),r=t.getProvider("heartbeat"),i=t.getProvider("app-check-internal"),{apiKey:s,authDomain:o}=n.options;Rf(s&&!s.includes(":"),"invalid-api-key",{appName:n.name});const a={apiKey:s,authDomain:o,clientPlatform:_m,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:kp(_m)},c=new Rp(n,r,i,a);return function(t,e){const n=(null==e?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(up);(null==e?void 0:e.errorMap)&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,null==e?void 0:e.popupRedirectResolver)}(c,e),c}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((t,e,n)=>{t.getProvider("auth-internal").initialize()}))),Dt(new I("auth-internal",(t=>(t=>new vm(t))(Np(t.getProvider("auth").getImmediate()))),"PRIVATE").setInstantiationMode("EXPLICIT")),Vt(mm,ym,function(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(_m)),Vt(mm,ym,"esm2017");class Em extends Error{constructor(){super("Avatar not created"),this.name="AvatarNotCreatedError"}}class Tm extends Error{constructor(){super("user not logged in"),this.name="UserNotLoggedInError"}}class Im extends Error{constructor(){super("no colorway size assets found"),this.name="NoColorwaySizeAssetsFoundError"}}class km{constructor(t,e){this.firestore=t,this.brandUserId=null,this.auth=bm(e),this.auth.setPersistence(fg)}get id(){var t;return null===(t=this.user)||void 0===t?void 0:t.uid}async onInit(t){this.auth.onAuthStateChanged((e=>{this.setUser(e),e&&this.logUserLogin(t,e)})),await this.auth.authStateReady();const e=this.auth.currentUser;return this.setUser(e),Boolean(e)}setUser(t){this.user=t}async logUserLogin(t,e){var n,r,i,s,o;try{const a=Uh(this.firestore,"user_logging",e.uid),c=await Dd(a),l=new Date,u=c.exists?c.data():null,h=null===(r=null===(n=null==u?void 0:u.brands)||void 0===n?void 0:n[t])||void 0===r?void 0:r.last_login;if(h&&ff(l).diff(ff(1e3*h.seconds),"seconds")<=10080)return;const d=null!==(o=null===(s=null===(i=null==u?void 0:u.brands)||void 0===i?void 0:i[t])||void 0===s?void 0:s.logins)&&void 0!==o?o:[];d.push(l);const f={brands:{[t]:{brand_id:t,last_login:l,logins:d}},last_brand_id:t,created_at:c.exists()?c.data().created_at:l,updated_at:l};await Md(a,f,{merge:!0})}catch(t){console.error("LOGGING ERROR:",t)}}setBrandUserId(t){this.brandUserId=t}async getToken(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Tm;return await this.user.getIdToken()}async getUserProfile(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Tm;return(await Dd(Uh(this.firestore,"users",this.id))).data()}watchUserProfileForChanges(t){let e;const n=Sd(Mh(this.firestore,"users"),_d(new Qh("__name__"),"==",this.id));return e=Ud(n,(e=>t(e.docs[0].data()))),()=>e()}async login(t,e){this.auth.currentUser&&await this.auth.signOut();const n=await lg(this.auth,t,e);this.setUser(n.user)}async logout(){await this.auth.signOut(),this.setUser(null)}async sendPasswordResetEmail(t){await ag(this.auth,t)}async confirmPasswordReset(t,e){await cg(this.auth,t,e)}}class Cm{constructor(){this.promisefyOnSnapshot=(t,e)=>{let n;return{promise:new Promise((r=>{n=Ud(t,(t=>{r(t),e&&n()}))})),unsubscribe:()=>n()}};const t=zt(zd.getInstance().firebase);this.firestore=function(t,e){const n="string"==typeof t?t:e||"(default)",r=Pt("object"==typeof t?t:Bt(),"firestore").getImmediate({identifier:n});if(!r._initialized){const t=oe("firestore");t&&Oh(r,...t)}return r}(t),this.user=new km(this.firestore,t)}onInit(t){return this.user.onInit(t)}query(t,e,n=!0){const r=Sd(Mh(this.firestore,t),e);return this.promisefyOnSnapshot(r,n)}getDocs(t,e){return xd(Sd(Mh(this.firestore,t),...e))}async getDoc(t,e){const n=Uh(this.firestore,t,e),r=await Dd(n);return r.exists()?r.data():null}}const Am=t=>{if(t.code===bf)throw new Error("account has been disabled");throw new Error(t.message)};class Rm{static get endpoint(){return zd.getInstance().api.url}static async Fetch({user:t,endpointPath:e,method:n,body:r,useToken:i=!0}){const s=this.getUrl(e,i),o={method:n,headers:await this.getHeaders(t,i),credentials:"omit"};r&&(o.body=JSON.stringify(r));const a=await fetch(s,o);if(a.ok)return a;if(500===a.status)throw new Error(a.statusText);const c=await a.json();return Promise.reject(c)}static getUrl(t,e){return e?`${this.endpoint}/v1${t}`:this.endpoint+t}static async getHeaders(t,e){if(!e)return{"Content-Type":"application/json"};return{"Content-Type":"application/json",Authorization:`Bearer ${await t.getToken()}`}}static Get(t,e,n){return this.Fetch({user:t,endpointPath:e,method:"GET",body:null,useToken:n})}static Post(t,e,n=null,r){return this.Fetch({user:t,endpointPath:e,method:"POST",body:n,useToken:r})}static Put(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PUT",body:n,useToken:r})}static Patch(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PATCH",body:n,useToken:r})}static Delete(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"DELETE",body:n,useToken:r})}}class Nm{constructor(t,e){this.brandId=t,this.firebase=e,this.measurementLocations=new Map}get user(){return this.firebase.user}get isLoggedIn(){return!this.firebase||Boolean(this.user.id)}async onInit(){return await this.getMeasurementLocations(),this.firebase.onInit(this.brandId)}async getRecommendedSizes(t){var e,n;if(!this.isLoggedIn)throw new Tm;try{const r=await Rm.Get(this.user,`/styles/${t}/recommendation`),i=await r.json();return(null===(e=null==i?void 0:i.fits)||void 0===e?void 0:e.length)&&(null===(n=null==i?void 0:i.recommended_size)||void 0===n?void 0:n.id)?i:null}catch(t){if("avatar not created"===(null==t?void 0:t.error))throw new Em;throw t}}async submitTelephoneNumber(t){const e=t.replace(/[^\+0-9]/g,""),n=await Rm.Post(this.user,"/ios-app-link",{phone_number:e},!1);console.log(n)}async getColorwaySizeAssetFromSku(t){const e=await this.getColorwaySizeAssets(null,[t]);if(!(null==e?void 0:e.size))throw new Im;return Array.from(e.values())[0]}async getColorwaySizeAssetFromBrandStyleId(t){const e=await this.getColorwaySizeAssets(t);if(!(null==e?void 0:e.size))throw new Im;return Array.from(e.values())[0]}async getMeasurementLocationsFromSku(t,e=[]){const n=await this.getColorwaySizeAssetFromSku(t);if(!n)throw new Error("No colorway size asset found for sku");const r=await this.getStyle(n.style_id);if(!r)throw new Error("Style category not found for style id");const i=await this.getGetTaxonomy(r.style_garment_category_id);if(!i)throw new Error("Taxonomy not found for style garment category id");return(e.length?i.measurement_locations.female.filter((t=>e.includes(t))):i.measurement_locations.female).map((t=>this.measurementLocations.has(t)?this.measurementLocations.get(t):{name:t,sort_order:1/0})).sort(((t,e)=>t.sort_order<e.sort_order?-1:0)).map((t=>t.name))}async getMeasurementLocationsFromBrandStyleId(t,e=[]){const n=await this.getColorwaySizeAssetFromBrandStyleId(t);if(!n)throw new Error("No colorway size asset found for brand style id");const r=await this.getStyle(n.style_id);if(!r)throw new Error("Style category not found for style id");const i=await this.getGetTaxonomy(r.style_garment_category_id);if(!i)throw new Error("Taxonomy not found for style garment category id");return(e.length?i.measurement_locations.female.filter((t=>e.includes(t))):i.measurement_locations.female).map((t=>this.measurementLocations.has(t)?this.measurementLocations.get(t):{name:t,sort_order:1/0})).sort(((t,e)=>t.sort_order<e.sort_order?-1:0)).map((t=>t.name))}async getStyleByBrandStyleId(t){var e,n;try{const r=[_d("brand_id","==",this.brandId)];r.push(_d("brand_style_id","==",t));return null===(n=null===(e=(await this.firebase.getDocs("styles",r)).docs)||void 0===e?void 0:e[0])||void 0===n?void 0:n.data()}catch(t){return Am(t)}}async getColorwaySizeAssets(t,e){const n=[_d("brand_id","==",this.brandId)];t&&n.push(_d("style_id","==",t)),(null==e?void 0:e.length)>0&&n.push(_d("sku","in",e));try{const t=await this.firebase.getDocs("colorway_size_assets",n),e=new Map;return t.forEach((t=>{const n=t.data();e.set(n.id,n)})),e}catch(t){return Am(t)}}async getStyle(t){try{return await this.firebase.getDoc("styles",String(t))}catch(t){return Am(t)}}getMeasurementLocationName(t){return this.measurementLocations.has(t)?this.measurementLocations.get(t).name:t}getMeasurementLocationSortOrder(t){return this.measurementLocations.has(t)?this.measurementLocations.get(t).sort_order:1/0}async getGetTaxonomy(t){try{return await this.firebase.getDoc("style_garment_categories",String(t))}catch(t){return Am(t)}}async getMeasurementLocations(){(await this.fetchMeasurementLocations()).forEach((t=>{this.measurementLocations.set(t.name,{name:t.garment_label,sort_order:t.sort_order})}))}async fetchMeasurementLocations(){try{return(await this.firebase.getDocs("measurement_locations",[])).docs.map((t=>t.data()))}catch(t){return Am(t)}}}var Lm;!function(t){t.ACROSS_BACK="across_back",t.ACROSS_FRONT="across_front",t.ACROSS_SHOULDER="across_shoulder",t.ANKLE="ankle",t.ARMEYE="arm_eye",t.ARM_LENGTH_FROM_SHOULDER="arm_length_from_shoulder",t.BACK_CROTCH_LENGTH="back_crotch_length",t.BACK_NECK_TO_EBLOW="back_neck_to_elbow",t.BELOW_KNEE="below_knee",t.BICEP="bicep",t.BUST="bust",t.BUST_POINT_TO_BUST_POINT="bust_point_to_bust_point",t.CALF="calf",t.CB_NECK_TO_WAIST="cb_neck_to_waist",t.CB_NECK_TO_WRIST="cb_neck_to_wrist",t.CF_NECK_TO_WAIST="cf_neck_to_waist",t.ELBOW="elbow",t.FOREARM="forearm",t.FRONT_CROTCH_LENGTH="front_crotch_length",t.HIGH_HIP_PLACEMENT_FROM_WAIST="high_hip_placement",t.HIGH_HIP="high_hip",t.HSP_TO_ACROSS_BACK="hsp_to_across_back",t.HSP_TO_ACROSS_FRONT="hsp_to_across_front",t.HSP_TO_BUST_POINT="hsp_to_bust_point",t.HSP_TO_LOW_HIP_POSITION="hsp_to_low_hip_position",t.HSP_TO_WAIST_POSITION="hsp_to_waist_position",t.INSEAM="inseam",t.KNEE="knee",t.LOW_HIP="low_hip",t.LOW_HIP_PLACEMENT_FROM_WAIST="low_hip_placement",t.MID_NECK="mid_neck",t.NECK_AT_BASE="neck_base",t.SHOULDER_DROP="shoulder_drop",t.SHOULDER_TO_SHOULDER="shoulder_to_shoulder",t.SIDE_WAIST_TO_FLOOR="side_waist_to_floor",t.SIDE_WAIST_TO_KNEE="side_waist_to_knee",t.THIGH="thigh",t.TOTAL_RISE_LENGTH="total_rise_length",t.UNDER_BUST="under_bust",t.VERTICAL_TRUNK="vertical_trunk",t.WAIST="waist",t.WRIST="wrist"}(Lm||(Lm={}));const Om={[Lm.ACROSS_BACK]:"Across back",[Lm.ACROSS_FRONT]:"Across front",[Lm.ACROSS_SHOULDER]:"Across shoulder",[Lm.ANKLE]:"Ankle",[Lm.ARMEYE]:"Armeye",[Lm.ARM_LENGTH_FROM_SHOULDER]:"Arm length from shoulder",[Lm.BACK_CROTCH_LENGTH]:"Back crotch length",[Lm.BACK_NECK_TO_EBLOW]:"Back neck to eblow",[Lm.BELOW_KNEE]:"Below knee",[Lm.BICEP]:"Bicep",[Lm.BUST]:"Chest/Bust",[Lm.BUST_POINT_TO_BUST_POINT]:"Bust point to bust point",[Lm.CALF]:"Calf",[Lm.CB_NECK_TO_WAIST]:"Cb neck to waist",[Lm.CB_NECK_TO_WRIST]:"Cb neck to wrist",[Lm.CF_NECK_TO_WAIST]:"Cf neck to waist",[Lm.ELBOW]:"Elbow",[Lm.FOREARM]:"Forearm",[Lm.FRONT_CROTCH_LENGTH]:"Front crotch length",[Lm.HIGH_HIP_PLACEMENT_FROM_WAIST]:"High hip placement from waist",[Lm.HIGH_HIP]:"High hip",[Lm.HSP_TO_ACROSS_BACK]:"Hsp to across back",[Lm.HSP_TO_ACROSS_FRONT]:"Hsp to across front",[Lm.HSP_TO_BUST_POINT]:"Hsp to bust point",[Lm.HSP_TO_LOW_HIP_POSITION]:"Hsp to low hip position",[Lm.HSP_TO_WAIST_POSITION]:"Hsp to waist position",[Lm.INSEAM]:"Inseam",[Lm.KNEE]:"Knee",[Lm.LOW_HIP]:"Low hip",[Lm.LOW_HIP_PLACEMENT_FROM_WAIST]:"Low hip placement from waist",[Lm.MID_NECK]:"Mid neck",[Lm.NECK_AT_BASE]:"Neck at base",[Lm.SHOULDER_DROP]:"Shoulder drop",[Lm.SHOULDER_TO_SHOULDER]:"Shoulder to shoulder",[Lm.SIDE_WAIST_TO_FLOOR]:"Side waist to floor",[Lm.SIDE_WAIST_TO_KNEE]:"Side waist to knee",[Lm.THIGH]:"Thigh",[Lm.TOTAL_RISE_LENGTH]:"Total rise length",[Lm.UNDER_BUST]:"Under bust",[Lm.VERTICAL_TRUNK]:"Vertical trunk",[Lm.WAIST]:"Waist",[Lm.WRIST]:"Wrist"};var Dm;!function(t){t.BLOUSES="blouses",t.COATS="coats",t.DRESSES="dresses",t.JACKETS="jackets",t.PANTS="pants",t.PUFFERS_AND_PARKAS="puffer_and_parkas",t.SHORTS="shorts",t.SKIRTS="skirts",t.SWEATERS="sweaters",t.T_SHIRTS_AND_TANKS="t_shirts_and_tanks"}(Dm||(Dm={}));const Pm={[Dm.BLOUSES]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.COATS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.DRESSES]:[Lm.LOW_HIP,Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST],[Dm.JACKETS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.PANTS]:[Lm.LOW_HIP,Lm.WAIST,Lm.THIGH,Lm.INSEAM],[Dm.PUFFERS_AND_PARKAS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.SHORTS]:[Lm.LOW_HIP,Lm.WAIST,Lm.THIGH,Lm.INSEAM],[Dm.SKIRTS]:[Lm.LOW_HIP,Lm.WAIST],[Dm.SWEATERS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.T_SHIRTS_AND_TANKS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP]},xm={activewear:"Active Wear",dresses:"Dresses",jackets_and_coats:"Jackets and Coats",jeans:"Jeans",jumpsuits_and_rompers:"Jumpsuits and Rompers",pants_and_shorts:"Pants and Shorts",skirts:"Skirts",suits_and_tailoring:"Suits and Tailoring",sweaters:"Sweaters",tops:"Tops"},Mm={a_line:"A Line",a_line_flared:"A Line Flared",blazers:"Blazers",bodycon:"Bodycon",bodysuits:"Bodysuits",boiler_suits:"Boiler Suits",bootcut:"Bootcut",cardigans:"Cardigans",cigarette:"Cigarette",corsets_and_bustiers:"Corsets and Bustiers",crewnecks:"Crewnecks",culottes:"Culottes",denim:"Denim",denim_jackets:"Denim Jackets",denim_shorts:"Denim Shorts",fit_and_flare:"Fit and Flare",flared:"Flared",hoodies_and_zipups:"Hoodies and Zipups",joggers:"Joggers",jumpsuits:"Jumpsuits",knit:"Knit",leggings:"Leggings",mom:"Mom",overalls:"Overalls",parkas:"Parkas",peacoats:"Peacoats",pencil:"Pencil",pleated:"Pleated",polos:"Polos",puffer_jackets:"Puffer Jackets",raincoats:"Raincoats",relaxed:"Relaxed",rompers:"Rompers",shackets:"Shackets",shirt:"Shirt",shirts_and_blouses:"Shirts and Blouses",skater:"Skater",skinny:"Skinny",slim:"Slim",slip:"Slip",sports_bras:"Sports Bras",straight:"Straight",suit_jackets:"Suit Jackets",suit_skirts:"Suit Skirts",suit_trousers:"Suit Trousers",suit_vests:"Suit Vests",sweatshirts:"Sweatshirts",t_shirts:"T-Shirts",tank_tops_and_camisoles:"Tank Tops and Camisoles",tapered:"Tapered",trench_coats:"Trench Coats",trousers:"Trousers",turtlenecks:"Turtleneck",unitards:"Unitards",v_necks:"V-Necks",wide_leg:"Wide Leg",wrap:"Wrap"},Um={activewear:{leggings:Dm.PANTS,joggers:Dm.PANTS,sweatshirts:Dm.SWEATERS},dresses:{a_line:Dm.DRESSES,bodycon:Dm.DRESSES,fit_and_flare:Dm.DRESSES,knit:Dm.DRESSES,shirt:Dm.DRESSES,slip:Dm.DRESSES,straight:Dm.DRESSES,wrap:Dm.DRESSES},jackets_and_coats:{denim_jackets:Dm.JACKETS,parkas:Dm.PUFFERS_AND_PARKAS,peacoats:Dm.COATS,puffer_jackets:Dm.PUFFERS_AND_PARKAS,raincoats:Dm.COATS,rompers:Dm.COATS,shackets:Dm.JACKETS,trench_coats:Dm.COATS},jeans:{bootcut:Dm.PANTS,flared:Dm.PANTS,mom:Dm.PANTS,relaxed:Dm.PANTS,skinny:Dm.PANTS,slim:Dm.PANTS,straight:Dm.PANTS,tapered:Dm.PANTS,wide_leg:Dm.PANTS},jumpsuits_and_rompers:{boiler_suits:Dm.DRESSES,denim:Dm.DRESSES,jumpsuits:Dm.DRESSES,overalls:Dm.DRESSES,rompers:Dm.DRESSES,unitards:Dm.DRESSES},pants_and_shorts:{cigarette:Dm.PANTS,culottes:Dm.SHORTS,denim_shorts:Dm.SHORTS,flared:Dm.PANTS,joggers:Dm.PANTS,leggings:Dm.PANTS,skinny:Dm.PANTS,wide_leg:Dm.PANTS},skirts:{a_line_flared:Dm.SKIRTS,denim:Dm.SKIRTS,knit:Dm.SKIRTS,pencil:Dm.SKIRTS,pleated:Dm.SKIRTS,skater:Dm.SKIRTS,slip:Dm.SKIRTS,wrap:Dm.SKIRTS},suits_and_tailoring:{blazers:Dm.JACKETS,suit_jackets:Dm.JACKETS,suit_skirts:Dm.SKIRTS,suit_trousers:Dm.PANTS,suit_vests:Dm.SWEATERS,trousers:Dm.PANTS},sweaters:{cardigans:Dm.SWEATERS,crewnecks:Dm.SWEATERS,hoodies_and_zipups:Dm.SWEATERS,sweatshirts:Dm.SWEATERS,turtlenecks:Dm.SWEATERS,v_necks:Dm.SWEATERS},tops:{bodysuits:Dm.BLOUSES,corsets_and_bustiers:Dm.BLOUSES,polos:Dm.T_SHIRTS_AND_TANKS,shirts_and_blouses:Dm.BLOUSES,t_shirts:Dm.T_SHIRTS_AND_TANKS,tank_tops_and_camisoles:Dm.T_SHIRTS_AND_TANKS}};var Fm;!function(t){t.TOO_TIGHT="too_tight",t.TIGHT="tight",t.SLIGHTLY_TIGHT="slightly_tight",t.PERFECT_FIT="perfect_fit",t.SLIGHTLY_LOOSE="slightly_loose",t.LOOSE="loose",t.OVERSIZED="oversized",t.TOO_SHORT="too_short",t.SHORT="short",t.SLIGHTLY_SHORT="slightly_short",t.SLIGHTLY_LONG="slightly_long",t.LONG="long",t.TOO_LONG="too_long"}(Fm||(Fm={}));const zm={[Fm.TOO_TIGHT]:"Too Tight",[Fm.TIGHT]:"Tight",[Fm.SLIGHTLY_TIGHT]:"Slightly Tight",[Fm.PERFECT_FIT]:"Perfect Fit",[Fm.SLIGHTLY_LOOSE]:"Slightly Loose",[Fm.LOOSE]:"Loose",[Fm.OVERSIZED]:"Oversized",[Fm.TOO_SHORT]:"Too Short",[Fm.SHORT]:"Short",[Fm.SLIGHTLY_SHORT]:"Slightly Short",[Fm.SLIGHTLY_LONG]:"Slightly Long",[Fm.LONG]:"Long",[Fm.TOO_LONG]:"Too Long"};var Bm;!function(t){t.NOT_CREATED="NOT_CREATED",t.CREATED="CREATED",t.PENDING="PENDING"}(Bm||(Bm={}));var Vm=Object.freeze({__proto__:null,get AvatarState(){return Bm},get MeasurementLocation(){return Lm},MeasurementLocationName:Om,get Classification(){return Dm},ClassificationLocations:Pm,CategoryNames:xm,Categories:["activewear","dresses","jackets_and_coats","jeans","jumpsuits_and_rompers","pants_and_shorts","skirts","suits_and_tailoring","sweaters","tops"],SubcategoryNames:Mm,Taxonomy:Um,get Fit(){return Fm},FitNames:zm}),Hm="Back to sign in",jm="Click here to download the app",$m="Don't have an account?",qm="Whoops! Looks like you don't have an avatar yet.",Wm="Email address",Km="Please enter a valid email address.",Gm="Enter your email address, we will send you a link to reset your password.",Qm="Forgot password?",Ym="Have an account? Sign in",Jm="Your avatar is loading...",Xm="Unfortunately, that size is not available for try on.",Zm="or",ty="Password",ey="Please enter a valid password (at least 7 characters).",ny="Return to Catalog Page",ry="Return to Product Page",iy="Return to site",sy="Please return to The Fitting Room app to create your avatar.",oy="Scan to download the app",ay="Send",cy="Sign back in",ly="Sign in",uy="Something went wrong. Try again!",hy="You have successfully logged out!",dy="The Fitting Room",fy="Username or password is empty.",py="Username or password is incorrect.",gy="End size uncertainty with",my="Our technology captures your precise measurements, and considers things like fabric stretch and your individual physique to find your perfect fit every time.";var yy=[],vy=[];function wy(t,e){if(t&&"undefined"!=typeof document){var n,r=!0===e.prepend?"prepend":"append",i=!0===e.singleTag,s="string"==typeof e.container?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(i){var o=yy.indexOf(s);-1===o&&(o=yy.push(s)-1,vy[o]={}),n=vy[o]&&vy[o][r]?vy[o][r]:vy[o][r]=a()}else n=a();65279===t.charCodeAt(0)&&(t=t.substring(1)),n.styleSheet?n.styleSheet.cssText+=t:n.appendChild(document.createTextNode(t))}function a(){var t=document.createElement("style");if(t.setAttribute("type","text/css"),e.attributes)for(var n=Object.keys(e.attributes),i=0;i<n.length;i++)t.setAttribute(n[i],e.attributes[n[i]]);var o="prepend"===r?"afterbegin":"beforeend";return s.insertAdjacentElement(o,t),t}}wy(".tfr-c-white{color:var(--tfr-white)}.tfr-c-brand{color:var(--tfr-brand-color)}.tfr-c-brand-bg{background-color:var(--tfr-brand-color)}.tfr-c-black{color:var(--tfr-black)}.tfr-c-black-o5{color:rgba(0,0,0,.5)}.tfr-c-red{color:var(--tfr-red)}",{});wy(".tfr-home-button-container{display:flex;flex-wrap:wrap;margin:20px}.tfr-home-button-container>button{border:0;cursor:pointer;height:60px;margin:20px;width:200px}.tfr-home-button-container>button:hover{background-color:#e6e6e6}[data-tfr=hidden]{display:none}.tfr-modal{background-color:rgba(0,0,0,.53);display:flex;height:100%;left:0;position:fixed;top:0;width:100%;z-index:10000}.tfr-modal-content{margin:0 auto;text-align:center;width:90%}.tfr-modal-content-flex{align-items:center;display:flex}.tfr-modal-content-container{background-color:#fff;border:1px solid #434343;border-radius:0;box-shadow:0 6px 6px #00000029;line-height:normal;max-height:100vh;max-width:850px;overflow:auto;width:100%}.tfr-close-container{text-align:end}.tfr-close{color:#aaa;font-size:28px;font-weight:700;height:50px;width:50px}.tfr-close:focus,.tfr-close:hover{color:#000;text-decoration:none}.tfr-cursor:hover{cursor:pointer}.tfr-underline{text-decoration:underline}.tfr-standard-button{border:0;border-radius:3px;color:#fff;height:43px;width:138px}.tfr-logo-container{align-items:center;display:flex}.tfr-modal-title-logo-container{align-items:center;display:flex;justify-content:center}.tfr-girl-clothes{display:inline-block;height:316px;width:253px}.tfr-t-a-center{text-align:center}.tfr-w-70-p{width:70%}.tfr-w-80-p{width:80%}.tfr-w-85-p{width:85%}.tfr-w-150{width:150px}.tfr-h-150{height:150px}.tfr-d-none{display:none}.tfr-d-block{display:block}.tfr-d-flex{display:flex}.tfr-how-it-works-item{align-items:center;display:flex;justify-items:center}.tfr-try-on-content{margin-left:60px}#tfr-tryon-image{max-width:30vw}.progress-bar{background-color:#fff;border:1px solid #bdbdbd;height:10px;margin:15px auto 0;width:55%}.progress-bar-fill{animation-duration:120s;animation-name:progress;background-color:#209da7;color:#fff;display:block;font-size:16px;height:100%;text-align:center;transition:width .6s linear}#tfr-video{height:100%;max-height:350px;max-width:350px}.tfr-logo-box{margin:auto;max-height:400px;max-width:860px;padding:20px}.tfr-flex,.tfr-logo-box{align-items:center;display:flex;justify-content:center}.tfr-qr-code{width:200px}.tfr-space-above{margin-top:10px}.tfr-max-w-600{margin:auto;max-width:600px}#tfr-qr-border-box{align-items:center;border:2px solid var(--tfr-brand-color);border-radius:16px;display:flex;flex-direction:column;height:350px;justify-content:center;margin-left:20px;padding:0 30px;width:300px}.tfr-mobile-logo{height:60px}#email-input,#password-input{font-size:16px}",{});wy("input{border:none;box-shadow:none!important;width:100%}input:focus,select:focus,textarea:focus{border:none;outline:none}.tfr-fieldset{margin-left:auto;margin-right:auto;width:65%}.tfr-fieldset,.tfr-fieldset-inline{border-color:rgba(0,0,0,.5);border-radius:10px;border-width:1px;padding:5px 10px 10px;text-align:left}.tfr-fieldset-inline{margin-right:10px;width:250px}.tfr-fieldset-err{border-color:red}",{});wy(".lds-ellipsis{display:inline-block;height:80px;position:relative;width:80px}.lds-ellipsis div{animation-timing-function:cubic-bezier(0,1,1,0);background:var(--tfr-brand-color);border-radius:50%;display:block;height:13px;position:absolute;top:33px;width:13px}.lds-ellipsis div:first-child{animation:lds-ellipsis1 .6s infinite;left:8px}.lds-ellipsis div:nth-child(2){animation:lds-ellipsis2 .6s infinite;left:8px}.lds-ellipsis div:nth-child(3){animation:lds-ellipsis2 .6s infinite;left:32px}.lds-ellipsis div:nth-child(4){animation:lds-ellipsis3 .6s infinite;left:56px}@keyframes lds-ellipsis1{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0)}to{transform:translate(24px)}}",{});wy("@media screen and (max-width:702px){.tfr-modal-title-logo-container{display:flex;flex-direction:column}}@media screen and (min-width:600px){.tfr-modal-content-container{border-radius:10px;height:auto;margin:auto;width:100%}}@media screen and (max-width:599px){#tfr-size-recommendations{width:calc(100vw - 30px)!important}.tfr-mobile-hidden{display:none}.tfr-modal-content-container{max-height:none;max-width:100vw;min-height:100vh;min-width:100vw}.trf-logo-title{margin-bottom:10px}.tfr-modal-content-flex{overflow:auto}}@media screen and (max-width:500px){.tfr-fieldset{width:90%}.tfr-how-it-works-item{flex-direction:column}.tfr-try-on-content{margin-left:0;margin-top:20px}}@media screen and (max-width:380){#tfr-size-rec-subtitle{min-width:none}}@media screen and (max-height:800px){.tfr-video-responsive{height:280px!important}}",{});wy("#tfr-size-recommendations{align-items:center;background-color:var(--tfr-main-bg-color);border:var(--tfr-main-border-width) solid var(--tfr-main-border-color);border-radius:var(--tfr-main-border-radius);color:var(--tfr-dark);display:flex;flex-direction:column;font-family:var(--tfr-main-font);justify-content:center;padding:var(--tfr-main-v-padding) var(--tfr-main-h-padding);width:var(--tfr-main-width)}#tfr-size-recommendations-container{align-items:center;display:none;flex-direction:column;justify-content:center;position:relative;width:100%}#tfr-size-rec-select-container{align-items:center;display:none;flex-direction:column;font-size:13px;width:100%}#tfr-size-rec-title{align-items:center;display:flex;font-family:var(--tfr-title-font);margin-bottom:8px}#tfr-size-rec-title-toggle{color:var(--tfr-grey);cursor:pointer;position:absolute;right:0;top:0;transition:all .3s ease}.tfr-chevron-up{transform:rotate(180deg) scaleY(.6)}.tfr-chevron-down{transform:rotate(0deg) scaleY(.6)}#tfr-size-rec-subtitle{background-color:var(--tfr-grey);border-radius:4px;color:var(--tfr-white);font-family:var(--tfr-subtitle-font);min-width:318px;padding:8px;text-align:center;width:100%}#tfr-size-rec-subtitle,#tfr-size-rec-title{font-size:14px}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;padding:0 10px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:0}.tfr-size-rec-table-row{align-items:center;border-top:var(--tfr-main-border-width) solid var(--tfr-main-border-color);display:flex;font-family:var(--tfr-row-font);justify-content:center;min-height:40px}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{flex-grow:1;padding-left:8px;text-align:right}.tfr-size-rec-table-cell-right{margin-left:16px;padding-right:8px}.tfr-size-rec-table-cell-right.perfect{color:var(--tfr-brand-color)}#tfr-size-rec-size{display:inline-block}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:var(--tfr-muted);display:flex;width:150px}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none;font-family:var(--tfr-cta-font)}#tfr-size-rec-action{cursor:pointer;font-size:16px;text-decoration:underline}#tfr-size-rec-select{background-color:var(--tfr-size-selector-bg-color);border-color:var(--tfr-size-selector-border-color);border-radius:var(--tfr-size-selector-button-radius);border-style:solid;border-width:var(--tfr-size-selector-border-width);box-shadow:var(--tfr-size-selector-button-shadow);color:var(--tfr-size-selector-text-color);display:none;font-size:var(--tfr-size-selector-font-size);font-weight:var(--tfr-size-selector-font-weight);margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:var(--tfr-size-selector-button-height);justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active){background-color:var(--tfr-size-selector-bg-color-hover);opacity:.7}.tfr-size-rec-select-button.active{background-color:var(--tfr-size-selector-bg-color-active);border-color:var(--tfr-size-selector-button-active-border-color);border-style:solid;border-width:var(--tfr-size-selector-button-active-border-width);height:var(--tfr-size-selector-button-active-height)}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:var(--tfr-size-selector-button-radius);border-top-left-radius:var(--tfr-size-selector-button-radius)}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:var(--tfr-size-selector-button-radius);border-top-right-radius:var(--tfr-size-selector-button-radius)}.tfr-powered-by{align-items:center;display:flex;font-size:10px;margin-top:10px}.tfr-powered-by-logo{margin:0 4px}.tfr-powered-by-logo,.tfr-powered-by-logo img{height:24px}.tfr-powered-by-text-bold{font-weight:700}#tfr-size-recommendation-error{color:#8d0000;display:none}#tfr-sign-in-nav{margin-bottom:80px}",{});wy(".tfr-mt-10{margin-top:10px}.tfr-mt-20{margin-top:20px}.tfr-mt-15{margin-top:15px}.tfr-mt-30{margin-top:30px}.mt-40{margin-top:40px}.tfr-mb-40{margin-bottom:40px}.tfr-mb-20{margin-bottom:20px}.tfr-mr-10{margin-right:10px}.tfr-mr-15{margin-right:15px}.tfr-mt-50{margin-top:50px}.tfr-mt-60{margin-top:60px}.tfr-mb-60{margin-bottom:60px}.tfr-mr-20{margin-right:20px}.tfr-mt-15-p{margin-top:15%}.tfr-mb-13-p{margin-bottom:13%}.tfr-m-h-auto{margin-left:auto;margin-right:auto}.tfr-pt-20{padding-top:20px}.tfr-pb-50{padding-bottom:50px}.tfr-p-20{padding:20px 10px}.tfr-pr-20{padding-right:20px}.tfr-pl-20{padding-left:20px}.tfr-pb-7-p{padding-bottom:7%}",{});wy(".flag-container{bottom:0;left:0;padding:1px;right:0;right:auto;top:0}.flag-container:hover{cursor:pointer}.selected-flag{align-items:center;display:flex;height:100%;padding:0 6px 0 8px;position:relative;z-index:1}.flag.bd{background-position:-418px 0;height:12px}.arrow{border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #555;height:0;margin-left:6px;width:0}.arrow-up{border-bottom:6px solid #555;border-top:none}.country-list{-webkit-overflow-scrolling:touch;background-color:#fff;border-radius:5px;box-shadow:0 8px 10px 1px rgba(57,64,78,.7),0 3px 14px 2px rgba(57,64,78,.7),0 5px 5px -3px rgba(57,64,78,.7);cursor:pointer;display:none;font-size:16px;line-height:18px;list-style:none;margin:0 0 0 -1px;max-height:500px;overflow:auto;padding:0;position:absolute;text-align:left;top:50%;transform:translateY(-50%);white-space:nowrap;width:100%;width:auto;z-index:2}.country-list.active{display:inline-block}.country{outline:0;padding:5px 26px 5px 15px}.country-list .divider{border-bottom:1px solid rgba(0,0,0,.12);margin-bottom:5px;padding-bottom:5px}.country.highlight{background-color:#c7cace}.flag-box{display:inline-block;width:20px}.country-name,.flag-box{margin-right:6px}.country-name,.dial-code,.flag-box{vertical-align:middle}",{});wy(".tfr-title-font{font-family:Poppins,sans-serif}.tfr-body-font{font-family:Roboto,sans-serif}.tfr-light-24-300{font-size:24px;font-weight:300}.tfr-light-24-500{font-size:24px;font-weight:500}.tfr-light-22-300{font-size:22px;font-weight:300}.tfr-light-16-300{font-size:16px;font-weight:300}.tfr-medium-16-default{font-size:16px}.tfr-12-default{font-size:12px}.tfr-14-default{font-size:14px}.tfr-16-default{font-size:16px}.tfr-24-bold{font-size:24px;font-weight:700}",{});wy(":root{--tfr-brand-color:#209da7;--tfr-black:#000;--tfr-red:red;--tfr-white:#fff;--tfr-muted:#a7a7a7;--tfr-dark:#121212;--tfr-grey:#878787;--tfr-light-grey:#dbdcdc;--tfr-dark-grey:#3f3f3f;--tfr-main-border-color:hsla(0,0%,7%,.55);--tfr-main-border-radius:0;--tfr-main-border-width:1px;--tfr-main-bg-color:inherit;--tfr-main-width:440px;--tfr-main-v-padding:14px;--tfr-main-h-padding:20px;--tfr-main-font:inherit;--tfr-title-font:var(--tfr-main-font);--tfr-subtitle-font:var(--tfr-main-font);--tfr-row-font:var(--tfr-main-font);--tfr-cta-font:var(--tfr-main-font);--tfr-size-selector-text-color:var(--tfr-white);--tfr-size-selector-font-size:14px;--tfr-size-selector-font-weight:400;--tfr-size-selector-border-color:transparent;--tfr-size-selector-border-width:0;--tfr-size-selector-bg-color:var(--tfr-grey);--tfr-size-selector-bg-color-hover:var(--tfr-dark-grey);--tfr-size-selector-bg-color-active:var(--tfr-dark);--tfr-size-selector-button-height:35px;--tfr-size-selector-button-active-height:45px;--tfr-size-selector-button-active-border-color:transparent;--tfr-size-selector-button-active-border-width:0;--tfr-size-selector-button-radius:8px;--tfr-size-selector-button-shadow:0 4px 4px 0 rgba(0,0,0,.3)}",{});const Sy=t=>({Hook:()=>{const e=document.querySelector(".progress-bar-fill");!function(t,e){let n=0;const r=t/200;e.style.width=n+"%";const i=setInterval((()=>{n>=100?clearInterval(i):(n+=.5,e.style.width=n+"%")}),r)}(t.timeoutMS,e)},Unhook:()=>{},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mt-60" > ${Jm} </div>\n <div class="progress-bar">\n <span class="progress-bar-fill"></span>\n </div>\n `}),by=t=>{const e=document.getElementById(t),n=document.querySelector("body");if(!e)throw new Error(`element with id ${t} not found`);let r;const i=()=>{n.style.overflow="auto",r&&(r.Unhook(),c()),e.style.display="none"},s=t=>{"Escape"===t.key&&i()},o=t=>{const n=e.querySelector("#tfr-modal-background");t.target===n&&(console.debug("container close"),i())},a=()=>{e.querySelector("#tfr-close-container").addEventListener("click",i),document.addEventListener("keydown",s),document.addEventListener("click",o)},c=()=>{var n;const r=e.querySelector("#tfr-close-container");r?r.removeEventListener("click",i):(console.error("#tfr-close-container not found on unhook"),console.debug(null===(n=document.getElementById(t))||void 0===n?void 0:n.innerHTML)),document.removeEventListener("keydown",s),document.removeEventListener("click",o)};return{open:t=>{var i;n.style.overflow="hidden",r&&r.Unhook(),e.innerHTML=(i=t.Body(),`\n <div class="tfr-modal" id="tfr-modal-background">\n <div class="tfr-modal-content-container tfr-p-20">\n <div class="tfr-close-container">\n <span id="tfr-close-container" class="tfr-close tfr-cursor">&times;</span>\n </div>\n\n <div class="tfr-modal-content-flex">\n <div class="tfr-modal-content">\n <div class="tfr-modal-title-logo-container">\n <div tfr-element="true" class="trf-logo-title tfr-title-font tfr-light-24-300 tfr-c-black tfr-mr-10">${gy}</div>\n <div tfr-element="true" class="tfr-logo-container">\n <div class="tfr-mr-15">\n <svg width="26" height="47" viewBox="0 0 68 124" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M0.911938 0L67.4819 17.09V106.49L0.911938 123.51V0Z" fill="#209DA7">\n </path>\n <path d="M52.8019 64.44C54.7791 64.44 56.3819 62.4387 56.3819 59.97C56.3819 57.5013 54.7791 55.5 52.8019 55.5C50.8248 55.5 49.2219 57.5013 49.2219 59.97C49.2219 62.4387 50.8248 64.44 52.8019 64.44Z" fill="white">\n </path>\n </svg>\n </div>\n <div tfr-element="true" class="tfr-title-font tfr-light-24-500 tfr-c-black tfr-mr-10">${dy}</div>\n </div>\n </div>\n ${i}\n </div>\n </div>\n </div>\n </div>\n `),a(),t.Hook(),e.style.display="block",r=t},close:i,Content:()=>r}},_y=t=>{const e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),n=()=>{t.onSignInNav()},r=()=>{window.open("https://apps.apple.com/us/app/the-fitting-room-3d-body-scan/id1577417373","_blank")},i=()=>{window.open("https://play.google.com/store/apps/details?id=com.thefittingroom.marketplace","_blank")},s="https://assets.dev.thefittingroom.xyz/images/";return{Hook:()=>{var t,s,o;if(e||(document.getElementById("tfr-sign-in-nav").style.marginBottom="0"),e){document.getElementById("tfr-video").classList.add("tfr-video-responsive")}null===(t=document.getElementById("tfr-sign-in-nav"))||void 0===t||t.addEventListener("click",n),null===(s=document.getElementById("tfr-app-store"))||void 0===s||s.addEventListener("click",r),null===(o=document.getElementById("tfr-google-play"))||void 0===o||o.addEventListener("click",i)},Unhook:()=>{var t,e,s;null===(t=document.getElementById("tfr-sign-in-nav"))||void 0===t||t.removeEventListener("click",n),null===(e=document.getElementById("tfr-app-store"))||void 0===e||e.removeEventListener("click",r),null===(s=document.getElementById("tfr-google-play"))||void 0===s||s.removeEventListener("click",i)},Body:()=>`\n <div tfr-element="true">\n <div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-10">${my}</div>\n \n </div>\n <div tfr-element="true" class="tfr-logo-box">\n <video id="tfr-video" controls loop autoplay playsinline>\n <source src="https://assets.dev.thefittingroom.xyz/videos/the-fitting-room.mp4" />\n </video>\n\n ${e?"":`<div id="tfr-qr-border-box">\n <div tfr-element="true" class="tfr-title-font tfr-24-bold">${oy}</div>\n \n <img src="${s}qr.png" class="tfr-qr-code" />\n\n <div id="tfr-sign-in-nav" tfr-element="true" class="tfr-body-font tfr-mt-20 tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${Ym}</div>\n </div>`}\n </div>\n\n ${e?`<div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-10 tfr-max-w-600">${jm}</div>\n\n <div tfr-element="true" class="tfr-flex tfr-space-above">\n <img class="tfr-mobile-logo" src="${s}apple.png" id="tfr-app-store" />\n <img class="tfr-mobile-logo" src="${s}google.png" id="tfr-google-play" />\n </div>\n \n <div id="tfr-sign-in-nav" tfr-element="true" class="tfr-body-font tfr-mt-20 tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${Ym}</div>\n `:""}\n `}};class Ey{constructor(t,e,n,r){this.signIn=e,this.forgotPassword=n,this.submitTel=r,this.manager=by(t)}close(){this.manager.close()}onSignOut(){this.manager.open((t=>{const e=()=>{t.onNavSignIn("")},n=()=>{t.onClose()};return{Hook:()=>{var t,r;null===(t=document.getElementById("tfr-sign-in"))||void 0===t||t.addEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.addEventListener("click",n)},Unhook:()=>{var t,r;null===(t=document.getElementById("tfr-sign-in"))||void 0===t||t.removeEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.removeEventListener("click",n)},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-mt-15-p tfr-mb-13-p">${hy}</div>\n <div class="tfr-t-a-center">\n <span id="tfr-sign-in" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${cy}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" >${iy}</span>\n </div>\n `}})({onNavSignIn:()=>this.toSignIn(),onClose:()=>this.close()}))}onNotCreated(){this.manager.open({Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mt-60">${qm}</div>\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mb-60">${sy}</div>\n `,Hook:()=>{},Unhook:()=>{}})}onLoading(){this.manager.open(Sy({timeoutMS:1e4}))}toScan(){this.manager.open(_y({onSignInNav:()=>this.toSignIn(),onTelSubmit:t=>this.submitTel(t)}))}toSignIn(){this.manager.open((t=>{const{email:e}=t,n=e=>{e.preventDefault();const n=document.getElementById("email-input").value,r=document.getElementById("password-input").value;s(),t.onSignIn(n,r,o)},r=()=>{const e=document.getElementById("email-input").value;t.onNavForgotPassword(e)},i=()=>{t.onNavScanCode()},s=()=>{document.querySelectorAll(".tfr-fieldset-element").forEach((t=>{t.classList.remove("tfr-fieldset-err")})),document.querySelectorAll(".tfr-label-element").forEach((t=>{t.classList.remove("tfr-c-red")}));const t=document.querySelector("#tfr-form-error");t.classList.remove("tfr-d-block"),t.innerHTML=""},o=t=>{document.querySelectorAll(".tfr-fieldset-element").forEach((t=>{t.classList.add("tfr-fieldset-err")})),document.querySelectorAll(".tfr-label-element").forEach((t=>{t.classList.add("tfr-c-red")}));const e=document.querySelector("#tfr-form-error");e.innerHTML=t||"Something went wrong",e.classList.add("tfr-d-block")};return{Hook:()=>{var t,e,s,o;null===(t=document.getElementById("tfr-sign-in-form"))||void 0===t||t.addEventListener("submit",n),null===(e=document.getElementById("tfr-sign-in"))||void 0===e||e.addEventListener("click",n),null===(s=document.getElementById("tfr-forgot-password"))||void 0===s||s.addEventListener("click",r),null===(o=document.getElementById("tfr-scan-code"))||void 0===o||o.addEventListener("click",i)},Unhook:()=>{var t,e,s,o;null===(t=document.getElementById("tfr-sign-in-form"))||void 0===t||t.removeEventListener("submit",n),null===(e=document.getElementById("tfr-sign-in"))||void 0===e||e.removeEventListener("click",n),null===(s=document.getElementById("tfr-forgot-password"))||void 0===s||s.removeEventListener("click",r),null===(o=document.getElementById("tfr-scan-code"))||void 0===o||o.removeEventListener("click",i)},Body:()=>`\n <form id="tfr-sign-in-form">\n <div class="tfr-title-font tfr-light-22-300 tfr-mt-10">${ly}</div>\n\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-20">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${Wm}</legend>\n <input tfr-element="true" type="email" id="email-input" value="${e||""}" />\n </fieldset>\n\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-20">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${ty}</legend>\n <input tfr-element="true" type="password" id="password-input" />\n </fieldset>\n\n <div tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-red tfr-mt-10 tfr-d-none" id="tfr-form-error"></div>\n\n <div class="tfr-mt-20">\n <span id="tfr-forgot-password" tfr-element="true" class="tfr-body-font tfr-14-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-15">${Qm}</span>\n <span id="tfr-scan-code" tfr-element="true" class="tfr-body-font tfr-14-default tfr-c-black-o5 tfr-underline tfr-cursor">${$m}</span>\n </div>\n\n <button id="tfr-sign-in" tfr-element="true" class="tfr-standard-button tfr-c-brand-bg tfr-c-whitetfr-title-font tfr-medium-16-default tfr-cursor tfr-mt-30" id="sign-in-button" type="submit">\n ${ly}\n </button>\n </form>\n `}})({onSignIn:this.signIn,onNavForgotPassword:()=>this.toForgotPassword(),onNavScanCode:()=>this.toScan()}))}toForgotPassword(){this.manager.open((t=>{const e=()=>{const e=document.getElementById("tfr-email").value;t.onNavSignIn(e)},n=()=>{const e=document.getElementById("tfr-email").value;t.onPasswordReset(e)};return{Hook:()=>{var t,r;null===(t=document.getElementById("tfr-send-password-reset"))||void 0===t||t.addEventListener("click",n),null===(r=document.getElementById("tfr-back-to-signin"))||void 0===r||r.addEventListener("click",e)},Unhook:()=>{var t,r;null===(t=document.getElementById("tfr-send-password-reset"))||void 0===t||t.removeEventListener("click",n),null===(r=document.getElementById("tfr-back-to-signin"))||void 0===r||r.removeEventListener("click",e)},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-20 tfr-w-70-p tfr-m-h-auto">${Gm}</div>\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-30">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${Wm}</legend>\n <input tfr-element="true" type="email" id="tfr-email" />\n </fieldset>\n <div tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-red tfr-mt-10 tfr-d-none" id="error-msg"></div>\n <div id="tfr-back-to-signin" tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mt-30">${Hm}</div>\n <button id="tfr-send-password-reset" tfr-element="true" class="tfr-standard-button tfr-c-brand-bg tfr-c-whitetfr-title-font tfr-medium-16-default tfr-cursor tfr-mt-30">\n ${ay}\n </button>\n `}})({onNavSignIn:()=>this.toSignIn(),onPasswordReset:this.forgotPassword}))}toPasswordReset(){}onTryOn(t){this.manager.open((t=>{let e=()=>{};const r=()=>{t.onNavBack()},i=()=>{t.onClose()};return{Hook:()=>{var s,o;const a=document.getElementById("tfr-tryon-image"),c=n("tfr-slider",((t,e)=>{console.debug("slider change",t,e),a.src=e}));if(Array.isArray(t.frames)&&t.frames.length>0){const n=c.Load(t.frames);if(n instanceof Error)return void console.error(n);e=n}null===(s=document.getElementById("tfr-back"))||void 0===s||s.addEventListener("click",r),null===(o=document.getElementById("tfr-close"))||void 0===o||o.addEventListener("click",i)},Unhook:()=>{var t,n;e(),null===(t=document.getElementById("tfr-back"))||void 0===t||t.removeEventListener("click",r),null===(n=document.getElementById("tfr-close"))||void 0===n||n.removeEventListener("click",i)},Body:()=>`\n <div class="tfr-slider-wrapper">\n\t\t\t\t<img id="tfr-tryon-image" src="" />\n\t\t\t\t<input type="range" id="tfr-slider" />\n\t\t\t\t</div>\n\t\t\t\t<div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${ny}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" id="returnToSite">${ry}</span>\n </div>\n `}})({frames:t,onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}onError(t){this.manager.open((t=>{const{error:e}=t,n=()=>{t.onNavBack()},r=()=>{t.onClose()};return{Hook:()=>{var t,e;null===(t=document.getElementById("tfr-back"))||void 0===t||t.addEventListener("click",n),null===(e=document.getElementById("tfr-close"))||void 0===e||e.addEventListener("click",r)},Unhook:()=>{var t,e;null===(t=document.getElementById("tfr-back"))||void 0===t||t.removeEventListener("click",n),null===(e=document.getElementById("tfr-close"))||void 0===e||e.removeEventListener("click",r)},Body:()=>(e||console.error("ErrorModal: No error provided"),`\n <div class="tfr-mt-15-p tfr-mb-13-p">\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black">${e||uy}</div>\n </div>\n\n <div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${ny}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" id="returnToSite">${ry}</span>\n </div>\n `)}})({error:t,onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}onSizeError(t,e){this.manager.open((t=>{const e=()=>{t.onNavBack()},n=()=>{t.onClose()};return{Hook:()=>{var t,r;null===(t=document.getElementById("tfr-back"))||void 0===t||t.addEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.addEventListener("click",n)},Unhook:()=>{var t,r;null===(t=document.getElementById("tfr-back"))||void 0===t||t.removeEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.removeEventListener("click",n)},Body:()=>{var e,n,r;return console.debug("rendering size error modal",t),`\n <div class="tfr-mt-15-p tfr-mb-13-p">\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black">\n\t\t\t\t\t\t\t${Xm} ${null===(e=t.sizes)||void 0===e?void 0:e.recommended} ${Zm} ${null===(r=null===(n=t.sizes)||void 0===n?void 0:n.available)||void 0===r?void 0:r.join(" or ")}\n\t\t\t\t\t\t</div>\n </div>\n\n <div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${ny}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${ry}</span>\n </div>\n `}}})({sizes:{recommended:t,available:e},onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}navBack(){window.history.back()}}const Ty="https://assets.dev.thefittingroom.xyz/shop-sdk/assets/login-icon.svg";class Iy{constructor(t,e,n){this.onSignInClick=e,this.onSignOutClick=n,this._sku="",this.isLoggedIn=!1,this.isCollapsed=!1,this.redraw=null,this.init(t)}get sku(){return this._sku}setSku(t){this._sku=t}setIsLoggedIn(t){this.isLoggedIn=t,this.tfrSizeRecSelectContainer.style.display="flex",t?(this.tfrSizeRecActionLogin.style.display="none",this.tfrSizeRecActionLogout.style.display="block",this.tfrSizeRecTitle.style.display="flex",this.tfrSizeRecSubtitle.style.display="block",this.isCollapsed=!1,this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-down"),this.tfrSizeHowItFits.style.display="block"):(this.tfrSizeRecActionLogin.style.display="block",this.tfrSizeRecActionLogout.style.display="none",this.tfrSizeRecTitle.style.display="flex",this.tfrSizeRecSubtitle.style.display="block",this.tfrSizeRecommendationError.style.display="none",this.tfrSizeRecommendationError.innerHTML="",this.tfrSizeHowItFits.style.display="none")}setLoading(t){t?(this.tfrSizeRecLoading.style.display="block",this.tfrSizeRecommendationsContainer.style.display="none"):(this.tfrSizeRecLoading.style.display="none",this.tfrSizeRecommendationsContainer.style.display="flex")}setGarmentLocations(t){if(!t||!t.length)return this.tfrSizeRecTitle.style.display="none",void(this.tfrSizeRecSubtitle.style.display="none");this.renderGarmentLocations(t),this.tfrSizeRecSelect.style.display="none"}setRecommendedSize({recommended:t,sizes:e}){this.renderSizeRec(t,e),this.tfrSizeRecSelect.style.display="flex"}setError(){this.tfrSizeRecTitle.style.display="none",this.tfrSizeRecSubtitle.style.display="none",this.isLoggedIn&&(this.tfrSizeRecommendationError.style.display="block",this.tfrSizeRecommendationError.innerHTML="No recommended size found.")}init(t){const e=document.getElementById(t);if(!e)throw new Error("Size rec main div not found");this.render(e),this.setElements(),this.bindEvents()}setElements(){this.tfrSizeHowItFits=document.getElementById("tfr-size-how-it-fits"),this.tfrSizeRecTitle=document.getElementById("tfr-size-rec-title"),this.tfrSizeRecSubtitle=document.getElementById("tfr-size-rec-subtitle"),this.tfrSizeRecActionLogin=document.getElementById("tfr-size-rec-action-login"),this.tfrSizeRecActionLogout=document.getElementById("tfr-size-rec-action-logout"),this.tfrSizeRecTable=document.getElementById("tfr-size-rec-table"),this.tfrSizeRecommendationError=document.getElementById("tfr-size-recommendation-error"),this.tfrSizeRecSize=document.getElementById("tfr-size-rec-size"),this.tfrSizeRecSelect=document.getElementById("tfr-size-rec-select"),this.tfrSizeRecLoading=document.getElementById("tfr-size-rec-loading"),this.tfrSizeRecTitleToggle=document.getElementById("tfr-size-rec-title-toggle"),this.tfrSizeRecSelectContainer=document.getElementById("tfr-size-rec-select-container"),this.tfrSizeRecommendationsContainer=document.getElementById("tfr-size-recommendations-container")}bindEvents(){this.tfrSizeRecActionLogin.addEventListener("click",this.onSignInClick),this.tfrSizeRecActionLogout.addEventListener("click",this.onSignOutClick),this.tfrSizeRecSelect.addEventListener("click",this.onSizeRecSelectClick.bind(this)),this.tfrSizeRecTitleToggle.addEventListener("click",this.toggletSizeRecSelectContainer.bind(this))}onSizeRecSelectClick(t){const e=t.target;if(!e.classList.contains("tfr-size-rec-select-button"))return;t.preventDefault();const n=Number(e.getAttribute("data-index"));if(Number.isNaN(n))return;const r=document.querySelectorAll(".tfr-size-rec-select-button");r.forEach((t=>t.classList.remove("active"))),r.item(n).classList.add("active"),this.redraw(n)}renderSizeRec(t,e){this.tfrSizeRecSize.innerHTML=`&nbsp;${t}`;const n=e.findIndex((({size:e})=>e===t));this.redraw=t=>this.renderSizeRecTable(e,t),this.redraw(n),this.renderSizeRecSelect(e,n)}renderSizeRecTable(t,e){const{locations:n}=t[e],r=n.map((({location:t,fit:e,isPerfect:n})=>this.renderSizeRecTableRow(t,e,n))).join("");this.tfrSizeRecTable.innerHTML=r}renderSizeRecSelect(t,e){const n=t.map((({size:t})=>t)).map(((t,n)=>`<div class="tfr-size-rec-select-button ${n===e?"active":""}" data-index="${n}">${t}</div>`)).join("");this.tfrSizeRecSelect.innerHTML=n}renderSizeRecTableRow(t,e,n=!1){return`<div class="tfr-size-rec-table-row">\n <div class="tfr-size-rec-table-cell-left">${t}</div>\n <div class="tfr-size-rec-table-cell-right ${n?"perfect":""}">\n ${e}\n </div>\n </div>`}renderLoginCta(){return`<div class="tfr-size-rec-login-cta"><img src="${Ty}" /> Sign up or login to view</div>`}renderGarmentLocations(t){const e=t.map((t=>this.renderSizeRecTableRow(t,this.renderLoginCta()))).join("");this.tfrSizeRecTable.innerHTML=e,this.tfrSizeRecSize.innerHTML=this.renderLoginCta()}toggletSizeRecSelectContainer(){this.isCollapsed?(this.isCollapsed=!1,this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-down"),this.tfrSizeRecSelectContainer.style.display="flex"):(this.isCollapsed=!0,this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-down"),this.tfrSizeRecSelectContainer.style.display="none")}render(t){const e=`<div id="tfr-size-recommendations">\n <div id="tfr-size-rec-loading">\n <div class="lds-ellipsis">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n <div id="tfr-size-recommendations-container">\n <div id="tfr-size-rec-title-toggle" class="tfr-chevron-up">v</div>\n\n <div id="tfr-size-rec-title">\n Recommended Size:\n <div id="tfr-size-rec-size">\n <div class="tfr-size-rec-login-cta">\n <img src="${Ty}" /> Sign up or login to view\n </div>\n </div>\n </div>\n\n <div id="tfr-size-rec-select-container">\n <div id="tfr-size-how-it-fits">Select size to see how it fits:</div>\n\n <div id="tfr-size-rec-select"></div>\n \n <div id="tfr-size-rec-subtitle">How it fits</div>\n \n <div id="tfr-size-rec-table"></div>\n </div>\n \n <div id="tfr-size-rec-action">\n <div id="tfr-size-rec-action-login">Sign up or login</div>\n <div id="tfr-size-rec-action-logout">Log out</div>\n </div>\n\n <div class="tfr-powered-by">\n <div>Powered by</div>\n <div class="tfr-powered-by-logo"><img src="https://assets.dev.thefittingroom.xyz/shop-sdk/assets/tfr-door-brand.svg" /></div>\n <div class="tfr-powered-by-text-bold">The Fitting Room</div>\n </div>\n </div>\n </div>\n <div id="tfr-size-recommendation-error"></div>`;t.innerHTML=e}}class ky{constructor(t,e,n,r,i){this.tfrShop=n,this.onSignInClick=r,this.onSignOutClick=i,this.perfectFits=[Vm.Fit.PERFECT_FIT,Vm.Fit.SLIGHTLY_LOOSE,Vm.Fit.SLIGHTLY_TIGHT],this.setCssVariables(e),this.sizeRecComponent=new Iy(t,this.onSignInClick,this.onSignOutClick)}get sku(){return this.sizeRecComponent.sku}setSku(t){this.sizeRecComponent.setSku(t)}setIsLoggedIn(t){this.sizeRecComponent.setIsLoggedIn(t)}async setGarmentLocations(t=[]){this.sizeRecComponent.setLoading(!0);const e=await this.getGarmentLocations(t);console.debug("locations",e),console.debug("filledLocations",t),this.sizeRecComponent.setGarmentLocations(e||[]),this.sizeRecComponent.setLoading(!1)}async setRecommendedSize(){this.sizeRecComponent.setLoading(!0);const t=await this.getRecommenedSize();if(!t)return console.error("No sizes found for sku"),this.sizeRecComponent.setLoading(!1),void this.sizeRecComponent.setError();this.sizeRecComponent.setRecommendedSize(t),this.sizeRecComponent.setLoading(!1)}async getGarmentLocations(t){try{return await this.tfrShop.getMeasurementLocationsFromSku(this.sku,t)}catch(e){try{const e=await this.tfrShop.getStyleByBrandStyleId(this.sku);return await this.tfrShop.getMeasurementLocationsFromBrandStyleId(e.id,t)}catch(t){return console.error(t),this.sizeRecComponent.setError(),null}}}async getRecommenedSize(){try{const t=await this.tfrShop.getColorwaySizeAssetFromSku(this.sku);return await this.getRecommendedSizes(String(t.style_id))}catch(t){try{const t=await this.tfrShop.getStyleByBrandStyleId(this.sku);return await this.getRecommendedSizes(String(t.id))}catch(t){return console.error(t),this.sizeRecComponent.setError(),null}}}async getRecommendedSizes(t){const e=await this.tfrShop.getRecommendedSizes(t);return e?{recommended:e.recommended_size.label,sizes:e.fits.map((t=>({size:e.available_sizes.find((e=>e.id===t.size_id)).label,locations:t.measurement_location_fits.map((t=>({fit:Vm.FitNames[t.fit],isPerfect:this.perfectFits.includes(t.fit),location:this.tfrShop.getMeasurementLocationName(t.measurement_location),sortOrder:this.tfrShop.getMeasurementLocationSortOrder(t.measurement_location)}))).sort(((t,e)=>t.sortOrder<e.sortOrder?-1:1))})))}:null}setCssVariables(t){const e=document.querySelector(":root");t.brandColor&&e.style.setProperty("--tfr-brand-color",t.brandColor),t.black&&e.style.setProperty("--tfr-black",t.black),t.red&&e.style.setProperty("--tfr-red",t.red),t.white&&e.style.setProperty("--tfr-white",t.white),t.muted&&e.style.setProperty("--tfr-muted",t.muted),t.dark&&e.style.setProperty("--tfr-dark",t.dark),t.grey&&e.style.setProperty("--tfr-grey",t.grey),t.lightGrey&&e.style.setProperty("--tfr-light-grey",t.lightGrey),t.mainBorderColor&&e.style.setProperty("--tfr-main-border-color",t.mainBorderColor),t.mainBorderRadius&&e.style.setProperty("--tfr-main-border-radius",t.mainBorderRadius),t.mainBorderWidth&&e.style.setProperty("--tfr-main-border-width",t.mainBorderWidth),t.mainBgColor&&e.style.setProperty("--tfr-main-bg-color",t.mainBgColor),t.mainWidth&&e.style.setProperty("--tfr-main-width",t.mainWidth),t.mainVPadding&&e.style.setProperty("--tfr-main-v-padding",t.mainVPadding),t.mainHPadding&&e.style.setProperty("--tfr-main-h-padding",t.mainHPadding),t.mainFont&&e.style.setProperty("--tfr-main-font",t.mainFont),t.titleFont&&e.style.setProperty("--tfr-title-font",t.titleFont),t.subtitleFont&&e.style.setProperty("--tfr-subtitle-font",t.subtitleFont),t.rowFont&&e.style.setProperty("--tfr-row-font",t.rowFont),t.ctaFont&&e.style.setProperty("--tfr-cta-font",t.ctaFont),t.sizeSelectorTextColor&&e.style.setProperty("--tfr-size-selector-text-color",t.sizeSelectorTextColor),t.sizeSelectorFontSize&&e.style.setProperty("--tfr-size-selector-font-size",t.sizeSelectorFontSize),t.sizeSelectorFontWeight&&e.style.setProperty("--tfr-size-selector-font-weight",t.sizeSelectorFontWeight),t.sizeSelectorBgColor&&e.style.setProperty("--tfr-size-selector-bg-color",t.sizeSelectorBgColor),t.sizeSelectorBorderColor&&e.style.setProperty("--tfr-size-selector-border-color",t.sizeSelectorBorderColor),t.sizeSelectorBorderWidth&&e.style.setProperty("--tfr-size-selector-border-width",t.sizeSelectorBorderWidth),t.sizeSelectorBgColorHover&&e.style.setProperty("--tfr-size-selector-bg-color-hover",t.sizeSelectorBgColorHover),t.sizeSelectorBgColorActive&&e.style.setProperty("--tfr-size-selector-bg-color-active",t.sizeSelectorBgColorActive),t.sizeSelectorButtonHeight&&e.style.setProperty("--tfr-size-selector-button-height",t.sizeSelectorButtonHeight),t.sizeSelectorButtonActiveHeight&&e.style.setProperty("--tfr-size-selector-button-active-height",t.sizeSelectorButtonActiveHeight),t.sizeSelectorButtonActiveBorderColor&&e.style.setProperty("--tfr-size-selector-button-active-border-color",t.sizeSelectorButtonActiveBorderColor),t.sizeSelectorButtonActiveBorderWidth&&e.style.setProperty("--tfr-size-selector-button-active-border-width",t.sizeSelectorButtonActiveBorderWidth),t.sizeSelectorButtonRadius&&e.style.setProperty("--tfr-size-selector-button-radius",t.sizeSelectorButtonRadius),t.sizeSelectorButtonShadow&&e.style.setProperty("--tfr-size-selector-button-shadow",t.sizeSelectorButtonShadow)}}var Cy;!function(t){t.NOT_CREATED="NOT_CREATED",t.CREATED="CREATED",t.PENDING="PENDING"}(Cy||(Cy={}));class Ay{constructor(t,e,n,r={},i,s){this.shopId=t,this.hooks=r,this.isLoggedIn=!1,this.unsub=null;const o=s||("undefined"!=typeof process?process.env.NODE_ENV:"dev");console.log("tfr-env",o),this.tfrModal=new Ey(e,this.signIn.bind(this),this.forgotPassword.bind(this),this.submitTel.bind(this)),this.tfrShop=((t,e="dev")=>("dev"!==e&&"development"!==e||console.warn("TfrShop is in development mode"),zd.getInstance().setEnv(e),new Nm(t,new Cm)))(Number(this.shopId),o),this.tfrSizeRec=new ky(n,i,this.tfrShop,this.onSignInClick.bind(this),this.signOut.bind(this))}get shop(){return this.tfrShop}get sku(){return this.tfrSizeRec.sku}async checkIfPublished(t){const e=await this.getStyle(t);return Boolean(null==e?void 0:e.is_published)}setSku(t){this.tfrSizeRec.setSku(t),this.isLoggedIn?this.tfrSizeRec.setRecommendedSize():this.setGarmentLocations()}async onInit(){var t,e;return this.isLoggedIn=await this.tfrShop.onInit(),this.tfrSizeRec.setIsLoggedIn(this.isLoggedIn),this.isLoggedIn?((null===(t=this.hooks)||void 0===t?void 0:t.onLogin)&&this.hooks.onLogin(),this.subscribeToProfileChanges()):((null===(e=this.hooks)||void 0===e?void 0:e.onLogout)&&this.hooks.onLogout(),this.unsubscribeFromProfileChanges()),this.isLoggedIn}close(){this.tfrModal.close()}async signOut(){var t;await this.tfrShop.user.logout(),(null===(t=this.hooks)||void 0===t?void 0:t.onLogout)&&this.hooks.onLogout(),this.isLoggedIn=!1,this.tfrSizeRec.setIsLoggedIn(!1),this.setGarmentLocations(),this.unsubscribeFromProfileChanges()}async signIn(t,e,n){var r;if(0==t.length||0==e.length)return n(fy);if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/.test(t))return n(Km);if(!(t=>!!t.match(/^.{7,}$/))(e))return n(ey);try{await this.tfrShop.user.login(t,e),(null===(r=this.hooks)||void 0===r?void 0:r.onLogin)&&this.hooks.onLogin(),this.tfrModal.close(),this.isLoggedIn=!0,this.tfrSizeRec.setIsLoggedIn(!0),this.tfrSizeRec.setRecommendedSize(),this.subscribeToProfileChanges()}catch(t){return n(py)}}setBrandUserId(t){this.tfrShop.user.setBrandUserId(t)}async submitTel(t){try{await this.tfrShop.submitTelephoneNumber(t),this.tfrModal.toSignIn()}catch(t){this.tfrModal.onError(uy)}}async forgotPassword(t){await this.tfrShop.user.sendPasswordResetEmail(t),this.tfrModal.toSignIn()}async passwordReset(t,e){await this.tfrShop.user.confirmPasswordReset(t,e),this.tfrModal.toPasswordReset()}async getMeasurementLocationsFromSku(t){return this.tfrShop.getMeasurementLocationsFromSku(t)}onSignInClick(){this.tfrModal.toScan()}onUserProfileChange(t){var e,n,r,i;switch(t.avatar_status){case Cy.NOT_CREATED:(null===(e=this.hooks)||void 0===e?void 0:e.onError)&&this.hooks.onError(qm),this.tfrModal.onNotCreated();break;case Cy.PENDING:(null===(n=this.hooks)||void 0===n?void 0:n.onLoading)&&this.hooks.onLoading();break;case Cy.CREATED:(null===(r=this.hooks)||void 0===r?void 0:r.onLoadingComplete)&&this.hooks.onLoadingComplete();break;default:(null===(i=this.hooks)||void 0===i?void 0:i.onError)&&this.hooks.onError(uy),this.tfrModal.onError(uy)}}subscribeToProfileChanges(){this.unsub||(this.unsub=this.tfrShop.user.watchUserProfileForChanges((t=>this.onUserProfileChange(t))))}unsubscribeFromProfileChanges(){this.unsub&&(this.unsub(),this.unsub=null)}async setGarmentLocations(){var t,e;const n=await this.getStyle(this.sku),r=(null===(e=null===(t=null==n?void 0:n.sizes)||void 0===t?void 0:t[0])||void 0===e?void 0:e.garment_measurements.map((t=>t.measurement_location)))||[];this.tfrSizeRec.setGarmentLocations(r)}async getStyle(t){try{const e=await this.tfrShop.getColorwaySizeAssetFromSku(t);return await this.tfrShop.getStyle(e.style_id)}catch(e){try{return await this.tfrShop.getStyleByBrandStyleId(t)}catch(t){return null}}}}const Ry=async(t,e,n,r={},i={},s="dev")=>{const o=new Ay(t,e,n,r,i,s);return await o.onInit(),o};export{n as InitImageSlider,Ry as initFittingRoom};
3313
+ const wm=h("authIdTokenMaxAge")||300;let bm=null;function Sm(t=Bt()){const e=Pt(t,"auth");if(e.isInitialized())return e.getImmediate();const n=function(t,e){const n=Pt(t,"auth");if(n.isInitialized()){const t=n.getImmediate();if(y(n.getOptions(),null!=e?e:{}))return t;Tf(t,"already-initialized")}return n.initialize({options:e})}(t,{popupRedirectResolver:gm,persistence:[Ng,fg,gg]}),r=h("authTokenSyncURL");if(r&&"boolean"==typeof isSecureContext&&isSecureContext){const t=new URL(r,location.origin);if(location.origin===t.origin){const e=(i=t.toString(),async t=>{const e=t&&await t.getIdTokenResult(),n=e&&((new Date).getTime()-Date.parse(e.issuedAtTime))/1e3;if(n&&n>wm)return;const r=null==e?void 0:e.token;bm!==r&&(bm=r,await fetch(i,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))});!function(t,e,n){T(t).beforeAuthStateChanged(e,n)}(n,e,(()=>e(n.currentUser))),function(t,e,n,r){T(t).onIdTokenChanged(e,n,r)}(n,(t=>e(t)))}}var i;const s=(t=>{var e,n;return null===(n=null===(e=l())||void 0===e?void 0:e.emulatorHosts)||void 0===n?void 0:n[t]})("auth");return s&&Up(n,`http://${s}`),n}var _m;!function(t){Op=t}({loadJS:t=>new Promise(((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=t=>{const e=If("internal-error");e.customData=t,n(e)},r.type="text/javascript",r.charset="UTF-8",function(){var t,e;return null!==(e=null===(t=document.getElementsByTagName("head"))||void 0===t?void 0:t[0])&&void 0!==e?e:document}().appendChild(r)})),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="}),_m="Browser",Dt(new I("auth",((t,{options:e})=>{const n=t.getProvider("app").getImmediate(),r=t.getProvider("heartbeat"),i=t.getProvider("app-check-internal"),{apiKey:s,authDomain:o}=n.options;Rf(s&&!s.includes(":"),"invalid-api-key",{appName:n.name});const a={apiKey:s,authDomain:o,clientPlatform:_m,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:kp(_m)},c=new Rp(n,r,i,a);return function(t,e){const n=(null==e?void 0:e.persistence)||[],r=(Array.isArray(n)?n:[n]).map(up);(null==e?void 0:e.errorMap)&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,null==e?void 0:e.popupRedirectResolver)}(c,e),c}),"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback(((t,e,n)=>{t.getProvider("auth-internal").initialize()}))),Dt(new I("auth-internal",(t=>(t=>new vm(t))(Np(t.getProvider("auth").getImmediate()))),"PRIVATE").setInstantiationMode("EXPLICIT")),Vt(mm,ym,function(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(_m)),Vt(mm,ym,"esm2017");class Em extends Error{constructor(){super("Avatar not created"),this.name="AvatarNotCreatedError"}}class Tm extends Error{constructor(){super("user not logged in"),this.name="UserNotLoggedInError"}}class Im extends Error{constructor(){super("no colorway size assets found"),this.name="NoColorwaySizeAssetsFoundError"}}class km{constructor(t,e){this.firestore=t,this.brandUserId=null,this.auth=Sm(e),this.auth.setPersistence(fg)}get id(){var t;return null===(t=this.user)||void 0===t?void 0:t.uid}async onInit(t){this.auth.onAuthStateChanged((e=>{this.setUser(e),e&&this.logUserLogin(t,e)})),await this.auth.authStateReady();const e=this.auth.currentUser;return this.setUser(e),Boolean(e)}setUser(t){this.user=t}async logUserLogin(t,e){var n,r,i,s,o;try{const a=Uh(this.firestore,"user_logging",e.uid),c=await Dd(a),l=new Date,u=c.exists?c.data():null,h=null===(r=null===(n=null==u?void 0:u.brands)||void 0===n?void 0:n[t])||void 0===r?void 0:r.last_login;if(h&&ff(l).diff(ff(1e3*h.seconds),"seconds")<=10080)return;const d=null!==(o=null===(s=null===(i=null==u?void 0:u.brands)||void 0===i?void 0:i[t])||void 0===s?void 0:s.logins)&&void 0!==o?o:[];d.push(l);const f={brands:{[t]:{brand_id:t,last_login:l,logins:d}},last_brand_id:t,created_at:c.exists()?c.data().created_at:l,updated_at:l};await Md(a,f,{merge:!0})}catch(t){console.error("LOGGING ERROR:",t)}}setBrandUserId(t){this.brandUserId=t}async getToken(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Tm;return await this.user.getIdToken()}async getUserProfile(){var t;if(!(null===(t=this.user)||void 0===t?void 0:t.uid))throw new Tm;return(await Dd(Uh(this.firestore,"users",this.id))).data()}watchUserProfileForChanges(t){let e;const n=bd(Mh(this.firestore,"users"),_d(new Qh("__name__"),"==",this.id));return e=Ud(n,(e=>t(e.docs[0].data()))),()=>e()}async login(t,e){this.auth.currentUser&&await this.auth.signOut();const n=await lg(this.auth,t,e);this.setUser(n.user)}async logout(){await this.auth.signOut(),this.setUser(null)}async sendPasswordResetEmail(t){await ag(this.auth,t)}async confirmPasswordReset(t,e){await cg(this.auth,t,e)}}class Cm{constructor(){this.promisefyOnSnapshot=(t,e)=>{let n;return{promise:new Promise((r=>{n=Ud(t,(t=>{r(t),e&&n()}))})),unsubscribe:()=>n()}};const t=zt(zd.getInstance().firebase);this.firestore=function(t,e){const n="string"==typeof t?t:e||"(default)",r=Pt("object"==typeof t?t:Bt(),"firestore").getImmediate({identifier:n});if(!r._initialized){const t=oe("firestore");t&&Oh(r,...t)}return r}(t),this.user=new km(this.firestore,t)}onInit(t){return this.user.onInit(t)}query(t,e,n=!0){const r=bd(Mh(this.firestore,t),e);return this.promisefyOnSnapshot(r,n)}getDocs(t,e){return xd(bd(Mh(this.firestore,t),...e))}async getDoc(t,e){const n=Uh(this.firestore,t,e),r=await Dd(n);return r.exists()?r.data():null}}const Am=t=>{if(t.code===Sf)throw new Error("account has been disabled");throw new Error(t.message)};class Rm{static get endpoint(){return zd.getInstance().api.url}static async Fetch({user:t,endpointPath:e,method:n,body:r,useToken:i=!0}){const s=this.getUrl(e,i),o={method:n,headers:await this.getHeaders(t,i),credentials:"omit"};r&&(o.body=JSON.stringify(r));const a=await fetch(s,o);if(a.ok)return a;if(500===a.status)throw new Error(a.statusText);const c=await a.json();return Promise.reject(c)}static getUrl(t,e){return e?`${this.endpoint}/v1${t}`:this.endpoint+t}static async getHeaders(t,e){if(!e)return{"Content-Type":"application/json"};return{"Content-Type":"application/json",Authorization:`Bearer ${await t.getToken()}`}}static Get(t,e,n){return this.Fetch({user:t,endpointPath:e,method:"GET",body:null,useToken:n})}static Post(t,e,n=null,r){return this.Fetch({user:t,endpointPath:e,method:"POST",body:n,useToken:r})}static Put(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PUT",body:n,useToken:r})}static Patch(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"PATCH",body:n,useToken:r})}static Delete(t,e,n,r){return this.Fetch({user:t,endpointPath:e,method:"DELETE",body:n,useToken:r})}}class Nm{constructor(t,e){this.brandId=t,this.firebase=e,this.measurementLocations=new Map}get user(){return this.firebase.user}get isLoggedIn(){return!this.firebase||Boolean(this.user.id)}async onInit(){return await this.getMeasurementLocations(),this.firebase.onInit(this.brandId)}async getRecommendedSizes(t){var e,n;if(!this.isLoggedIn)throw new Tm;try{const r=await Rm.Get(this.user,`/styles/${t}/recommendation`),i=await r.json();return(null===(e=null==i?void 0:i.fits)||void 0===e?void 0:e.length)&&(null===(n=null==i?void 0:i.recommended_size)||void 0===n?void 0:n.id)?i:null}catch(t){if("avatar not created"===(null==t?void 0:t.error))throw new Em;throw t}}async submitTelephoneNumber(t){const e=t.replace(/[^\+0-9]/g,""),n=await Rm.Post(this.user,"/ios-app-link",{phone_number:e},!1);console.log(n)}async getColorwaySizeAssetFromSku(t){const e=await this.getColorwaySizeAssets(null,[t]);if(!(null==e?void 0:e.size))throw new Im;return Array.from(e.values())[0]}async getColorwaySizeAssetFromBrandStyleId(t){const e=await this.getColorwaySizeAssets(t);if(!(null==e?void 0:e.size))throw new Im;return Array.from(e.values())[0]}async getMeasurementLocationsFromSku(t,e=[]){const n=await this.getColorwaySizeAssetFromSku(t);if(!n)throw new Error("No colorway size asset found for sku");const r=await this.getStyle(n.style_id);if(!r)throw new Error("Style category not found for style id");const i=await this.getGetTaxonomy(r.style_garment_category_id);if(!i)throw new Error("Taxonomy not found for style garment category id");return(e.length?i.measurement_locations.female.filter((t=>e.includes(t))):i.measurement_locations.female).map((t=>this.measurementLocations.has(t)?this.measurementLocations.get(t):{name:t,sort_order:1/0})).sort(((t,e)=>t.sort_order<e.sort_order?-1:0)).map((t=>t.name))}async getMeasurementLocationsFromBrandStyleId(t,e=[]){const n=await this.getColorwaySizeAssetFromBrandStyleId(t);if(!n)throw new Error("No colorway size asset found for brand style id");const r=await this.getStyle(n.style_id);if(!r)throw new Error("Style category not found for style id");const i=await this.getGetTaxonomy(r.style_garment_category_id);if(!i)throw new Error("Taxonomy not found for style garment category id");return(e.length?i.measurement_locations.female.filter((t=>e.includes(t))):i.measurement_locations.female).map((t=>this.measurementLocations.has(t)?this.measurementLocations.get(t):{name:t,sort_order:1/0})).sort(((t,e)=>t.sort_order<e.sort_order?-1:0)).map((t=>t.name))}async getStyleByBrandStyleId(t){var e,n;try{const r=[_d("brand_id","==",this.brandId)];r.push(_d("brand_style_id","==",t));return null===(n=null===(e=(await this.firebase.getDocs("styles",r)).docs)||void 0===e?void 0:e[0])||void 0===n?void 0:n.data()}catch(t){return Am(t)}}async getColorwaySizeAssets(t,e){const n=[_d("brand_id","==",this.brandId)];t&&n.push(_d("style_id","==",t)),(null==e?void 0:e.length)>0&&n.push(_d("sku","in",e));try{const t=await this.firebase.getDocs("colorway_size_assets",n),e=new Map;return t.forEach((t=>{const n=t.data();e.set(n.id,n)})),e}catch(t){return Am(t)}}async getStyle(t){try{return await this.firebase.getDoc("styles",String(t))}catch(t){return Am(t)}}getMeasurementLocationName(t){return this.measurementLocations.has(t)?this.measurementLocations.get(t).name:t}getMeasurementLocationSortOrder(t){return this.measurementLocations.has(t)?this.measurementLocations.get(t).sort_order:1/0}async getGetTaxonomy(t){try{return await this.firebase.getDoc("style_garment_categories",String(t))}catch(t){return Am(t)}}async getMeasurementLocations(){(await this.fetchMeasurementLocations()).forEach((t=>{this.measurementLocations.set(t.name,{name:t.garment_label,sort_order:t.sort_order})}))}async fetchMeasurementLocations(){try{return(await this.firebase.getDocs("measurement_locations",[])).docs.map((t=>t.data()))}catch(t){return Am(t)}}}var Lm;!function(t){t.ACROSS_BACK="across_back",t.ACROSS_FRONT="across_front",t.ACROSS_SHOULDER="across_shoulder",t.ANKLE="ankle",t.ARMEYE="arm_eye",t.ARM_LENGTH_FROM_SHOULDER="arm_length_from_shoulder",t.BACK_CROTCH_LENGTH="back_crotch_length",t.BACK_NECK_TO_EBLOW="back_neck_to_elbow",t.BELOW_KNEE="below_knee",t.BICEP="bicep",t.BUST="bust",t.BUST_POINT_TO_BUST_POINT="bust_point_to_bust_point",t.CALF="calf",t.CB_NECK_TO_WAIST="cb_neck_to_waist",t.CB_NECK_TO_WRIST="cb_neck_to_wrist",t.CF_NECK_TO_WAIST="cf_neck_to_waist",t.ELBOW="elbow",t.FOREARM="forearm",t.FRONT_CROTCH_LENGTH="front_crotch_length",t.HIGH_HIP_PLACEMENT_FROM_WAIST="high_hip_placement",t.HIGH_HIP="high_hip",t.HSP_TO_ACROSS_BACK="hsp_to_across_back",t.HSP_TO_ACROSS_FRONT="hsp_to_across_front",t.HSP_TO_BUST_POINT="hsp_to_bust_point",t.HSP_TO_LOW_HIP_POSITION="hsp_to_low_hip_position",t.HSP_TO_WAIST_POSITION="hsp_to_waist_position",t.INSEAM="inseam",t.KNEE="knee",t.LOW_HIP="low_hip",t.LOW_HIP_PLACEMENT_FROM_WAIST="low_hip_placement",t.MID_NECK="mid_neck",t.NECK_AT_BASE="neck_base",t.SHOULDER_DROP="shoulder_drop",t.SHOULDER_TO_SHOULDER="shoulder_to_shoulder",t.SIDE_WAIST_TO_FLOOR="side_waist_to_floor",t.SIDE_WAIST_TO_KNEE="side_waist_to_knee",t.THIGH="thigh",t.TOTAL_RISE_LENGTH="total_rise_length",t.UNDER_BUST="under_bust",t.VERTICAL_TRUNK="vertical_trunk",t.WAIST="waist",t.WRIST="wrist"}(Lm||(Lm={}));const Om={[Lm.ACROSS_BACK]:"Across back",[Lm.ACROSS_FRONT]:"Across front",[Lm.ACROSS_SHOULDER]:"Across shoulder",[Lm.ANKLE]:"Ankle",[Lm.ARMEYE]:"Armeye",[Lm.ARM_LENGTH_FROM_SHOULDER]:"Arm length from shoulder",[Lm.BACK_CROTCH_LENGTH]:"Back crotch length",[Lm.BACK_NECK_TO_EBLOW]:"Back neck to eblow",[Lm.BELOW_KNEE]:"Below knee",[Lm.BICEP]:"Bicep",[Lm.BUST]:"Chest/Bust",[Lm.BUST_POINT_TO_BUST_POINT]:"Bust point to bust point",[Lm.CALF]:"Calf",[Lm.CB_NECK_TO_WAIST]:"Cb neck to waist",[Lm.CB_NECK_TO_WRIST]:"Cb neck to wrist",[Lm.CF_NECK_TO_WAIST]:"Cf neck to waist",[Lm.ELBOW]:"Elbow",[Lm.FOREARM]:"Forearm",[Lm.FRONT_CROTCH_LENGTH]:"Front crotch length",[Lm.HIGH_HIP_PLACEMENT_FROM_WAIST]:"High hip placement from waist",[Lm.HIGH_HIP]:"High hip",[Lm.HSP_TO_ACROSS_BACK]:"Hsp to across back",[Lm.HSP_TO_ACROSS_FRONT]:"Hsp to across front",[Lm.HSP_TO_BUST_POINT]:"Hsp to bust point",[Lm.HSP_TO_LOW_HIP_POSITION]:"Hsp to low hip position",[Lm.HSP_TO_WAIST_POSITION]:"Hsp to waist position",[Lm.INSEAM]:"Inseam",[Lm.KNEE]:"Knee",[Lm.LOW_HIP]:"Low hip",[Lm.LOW_HIP_PLACEMENT_FROM_WAIST]:"Low hip placement from waist",[Lm.MID_NECK]:"Mid neck",[Lm.NECK_AT_BASE]:"Neck at base",[Lm.SHOULDER_DROP]:"Shoulder drop",[Lm.SHOULDER_TO_SHOULDER]:"Shoulder to shoulder",[Lm.SIDE_WAIST_TO_FLOOR]:"Side waist to floor",[Lm.SIDE_WAIST_TO_KNEE]:"Side waist to knee",[Lm.THIGH]:"Thigh",[Lm.TOTAL_RISE_LENGTH]:"Total rise length",[Lm.UNDER_BUST]:"Under bust",[Lm.VERTICAL_TRUNK]:"Vertical trunk",[Lm.WAIST]:"Waist",[Lm.WRIST]:"Wrist"};var Dm;!function(t){t.BLOUSES="blouses",t.COATS="coats",t.DRESSES="dresses",t.JACKETS="jackets",t.PANTS="pants",t.PUFFERS_AND_PARKAS="puffer_and_parkas",t.SHORTS="shorts",t.SKIRTS="skirts",t.SWEATERS="sweaters",t.T_SHIRTS_AND_TANKS="t_shirts_and_tanks"}(Dm||(Dm={}));const Pm={[Dm.BLOUSES]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.COATS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.DRESSES]:[Lm.LOW_HIP,Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST],[Dm.JACKETS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.PANTS]:[Lm.LOW_HIP,Lm.WAIST,Lm.THIGH,Lm.INSEAM],[Dm.PUFFERS_AND_PARKAS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.SHORTS]:[Lm.LOW_HIP,Lm.WAIST,Lm.THIGH,Lm.INSEAM],[Dm.SKIRTS]:[Lm.LOW_HIP,Lm.WAIST],[Dm.SWEATERS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP],[Dm.T_SHIRTS_AND_TANKS]:[Lm.BUST,Lm.ACROSS_SHOULDER,Lm.WAIST,Lm.LOW_HIP,Lm.HIGH_HIP]},xm={activewear:"Active Wear",dresses:"Dresses",jackets_and_coats:"Jackets and Coats",jeans:"Jeans",jumpsuits_and_rompers:"Jumpsuits and Rompers",pants_and_shorts:"Pants and Shorts",skirts:"Skirts",suits_and_tailoring:"Suits and Tailoring",sweaters:"Sweaters",tops:"Tops"},Mm={a_line:"A Line",a_line_flared:"A Line Flared",blazers:"Blazers",bodycon:"Bodycon",bodysuits:"Bodysuits",boiler_suits:"Boiler Suits",bootcut:"Bootcut",cardigans:"Cardigans",cigarette:"Cigarette",corsets_and_bustiers:"Corsets and Bustiers",crewnecks:"Crewnecks",culottes:"Culottes",denim:"Denim",denim_jackets:"Denim Jackets",denim_shorts:"Denim Shorts",fit_and_flare:"Fit and Flare",flared:"Flared",hoodies_and_zipups:"Hoodies and Zipups",joggers:"Joggers",jumpsuits:"Jumpsuits",knit:"Knit",leggings:"Leggings",mom:"Mom",overalls:"Overalls",parkas:"Parkas",peacoats:"Peacoats",pencil:"Pencil",pleated:"Pleated",polos:"Polos",puffer_jackets:"Puffer Jackets",raincoats:"Raincoats",relaxed:"Relaxed",rompers:"Rompers",shackets:"Shackets",shirt:"Shirt",shirts_and_blouses:"Shirts and Blouses",skater:"Skater",skinny:"Skinny",slim:"Slim",slip:"Slip",sports_bras:"Sports Bras",straight:"Straight",suit_jackets:"Suit Jackets",suit_skirts:"Suit Skirts",suit_trousers:"Suit Trousers",suit_vests:"Suit Vests",sweatshirts:"Sweatshirts",t_shirts:"T-Shirts",tank_tops_and_camisoles:"Tank Tops and Camisoles",tapered:"Tapered",trench_coats:"Trench Coats",trousers:"Trousers",turtlenecks:"Turtleneck",unitards:"Unitards",v_necks:"V-Necks",wide_leg:"Wide Leg",wrap:"Wrap"},Um={activewear:{leggings:Dm.PANTS,joggers:Dm.PANTS,sweatshirts:Dm.SWEATERS},dresses:{a_line:Dm.DRESSES,bodycon:Dm.DRESSES,fit_and_flare:Dm.DRESSES,knit:Dm.DRESSES,shirt:Dm.DRESSES,slip:Dm.DRESSES,straight:Dm.DRESSES,wrap:Dm.DRESSES},jackets_and_coats:{denim_jackets:Dm.JACKETS,parkas:Dm.PUFFERS_AND_PARKAS,peacoats:Dm.COATS,puffer_jackets:Dm.PUFFERS_AND_PARKAS,raincoats:Dm.COATS,rompers:Dm.COATS,shackets:Dm.JACKETS,trench_coats:Dm.COATS},jeans:{bootcut:Dm.PANTS,flared:Dm.PANTS,mom:Dm.PANTS,relaxed:Dm.PANTS,skinny:Dm.PANTS,slim:Dm.PANTS,straight:Dm.PANTS,tapered:Dm.PANTS,wide_leg:Dm.PANTS},jumpsuits_and_rompers:{boiler_suits:Dm.DRESSES,denim:Dm.DRESSES,jumpsuits:Dm.DRESSES,overalls:Dm.DRESSES,rompers:Dm.DRESSES,unitards:Dm.DRESSES},pants_and_shorts:{cigarette:Dm.PANTS,culottes:Dm.SHORTS,denim_shorts:Dm.SHORTS,flared:Dm.PANTS,joggers:Dm.PANTS,leggings:Dm.PANTS,skinny:Dm.PANTS,wide_leg:Dm.PANTS},skirts:{a_line_flared:Dm.SKIRTS,denim:Dm.SKIRTS,knit:Dm.SKIRTS,pencil:Dm.SKIRTS,pleated:Dm.SKIRTS,skater:Dm.SKIRTS,slip:Dm.SKIRTS,wrap:Dm.SKIRTS},suits_and_tailoring:{blazers:Dm.JACKETS,suit_jackets:Dm.JACKETS,suit_skirts:Dm.SKIRTS,suit_trousers:Dm.PANTS,suit_vests:Dm.SWEATERS,trousers:Dm.PANTS},sweaters:{cardigans:Dm.SWEATERS,crewnecks:Dm.SWEATERS,hoodies_and_zipups:Dm.SWEATERS,sweatshirts:Dm.SWEATERS,turtlenecks:Dm.SWEATERS,v_necks:Dm.SWEATERS},tops:{bodysuits:Dm.BLOUSES,corsets_and_bustiers:Dm.BLOUSES,polos:Dm.T_SHIRTS_AND_TANKS,shirts_and_blouses:Dm.BLOUSES,t_shirts:Dm.T_SHIRTS_AND_TANKS,tank_tops_and_camisoles:Dm.T_SHIRTS_AND_TANKS}};var Fm;!function(t){t.TOO_TIGHT="too_tight",t.TIGHT="tight",t.SLIGHTLY_TIGHT="slightly_tight",t.PERFECT_FIT="perfect_fit",t.SLIGHTLY_LOOSE="slightly_loose",t.LOOSE="loose",t.OVERSIZED="oversized",t.TOO_SHORT="too_short",t.SHORT="short",t.SLIGHTLY_SHORT="slightly_short",t.SLIGHTLY_LONG="slightly_long",t.LONG="long",t.TOO_LONG="too_long"}(Fm||(Fm={}));const zm={[Fm.TOO_TIGHT]:"Too Tight",[Fm.TIGHT]:"Tight",[Fm.SLIGHTLY_TIGHT]:"Slightly Tight",[Fm.PERFECT_FIT]:"Perfect Fit",[Fm.SLIGHTLY_LOOSE]:"Slightly Loose",[Fm.LOOSE]:"Loose",[Fm.OVERSIZED]:"Oversized",[Fm.TOO_SHORT]:"Too Short",[Fm.SHORT]:"Short",[Fm.SLIGHTLY_SHORT]:"Slightly Short",[Fm.SLIGHTLY_LONG]:"Slightly Long",[Fm.LONG]:"Long",[Fm.TOO_LONG]:"Too Long"};var Bm;!function(t){t.NOT_CREATED="NOT_CREATED",t.CREATED="CREATED",t.PENDING="PENDING"}(Bm||(Bm={}));var Vm=Object.freeze({__proto__:null,get AvatarState(){return Bm},get MeasurementLocation(){return Lm},MeasurementLocationName:Om,get Classification(){return Dm},ClassificationLocations:Pm,CategoryNames:xm,Categories:["activewear","dresses","jackets_and_coats","jeans","jumpsuits_and_rompers","pants_and_shorts","skirts","suits_and_tailoring","sweaters","tops"],SubcategoryNames:Mm,Taxonomy:Um,get Fit(){return Fm},FitNames:zm}),Hm="Back to sign in",jm="Click here to download the app",$m="Don't have an account?",qm="Whoops! Looks like you don't have an avatar yet.",Wm="Email address",Km="Please enter a valid email address.",Gm="Enter your email address, we will send you a link to reset your password.",Qm="Forgot password?",Ym="Have an account? Sign in",Jm="Your avatar is loading...",Xm="Unfortunately, that size is not available for try on.",Zm="or",ty="Password",ey="Please enter a valid password (at least 7 characters).",ny="Return to Catalog Page",ry="Return to Product Page",iy="Return to site",sy="Please return to The Fitting Room app to create your avatar.",oy="Scan to download the app",ay="Send",cy="Sign back in",ly="Sign in",uy="Something went wrong. Try again!",hy="You have successfully logged out!",dy="The Fitting Room",fy="Username or password is empty.",py="Username or password is incorrect.",gy="End size uncertainty with",my="Our technology captures your precise measurements, and considers things like fabric stretch and your individual physique to find your perfect fit every time.";var yy=[],vy=[];function wy(t,e){if(t&&"undefined"!=typeof document){var n,r=!0===e.prepend?"prepend":"append",i=!0===e.singleTag,s="string"==typeof e.container?document.querySelector(e.container):document.getElementsByTagName("head")[0];if(i){var o=yy.indexOf(s);-1===o&&(o=yy.push(s)-1,vy[o]={}),n=vy[o]&&vy[o][r]?vy[o][r]:vy[o][r]=a()}else n=a();65279===t.charCodeAt(0)&&(t=t.substring(1)),n.styleSheet?n.styleSheet.cssText+=t:n.appendChild(document.createTextNode(t))}function a(){var t=document.createElement("style");if(t.setAttribute("type","text/css"),e.attributes)for(var n=Object.keys(e.attributes),i=0;i<n.length;i++)t.setAttribute(n[i],e.attributes[n[i]]);var o="prepend"===r?"afterbegin":"beforeend";return s.insertAdjacentElement(o,t),t}}wy(".tfr-c-white{color:var(--tfr-white)}.tfr-c-brand{color:var(--tfr-brand-color)}.tfr-c-brand-bg{background-color:var(--tfr-brand-color)}.tfr-c-black{color:var(--tfr-black)}.tfr-c-black-o5{color:rgba(0,0,0,.5)}.tfr-c-red{color:var(--tfr-red)}",{});wy(".tfr-home-button-container{display:flex;flex-wrap:wrap;margin:20px}.tfr-home-button-container>button{border:0;cursor:pointer;height:60px;margin:20px;width:200px}.tfr-home-button-container>button:hover{background-color:#e6e6e6}[data-tfr=hidden]{display:none}.tfr-modal{background-color:rgba(0,0,0,.53);display:flex;height:100%;left:0;position:fixed;top:0;width:100%;z-index:10000}.tfr-modal-content{margin:0 auto;text-align:center;width:90%}.tfr-modal-content-flex{align-items:center;display:flex}.tfr-modal-content-container{background-color:#fff;border:1px solid #434343;border-radius:0;box-shadow:0 6px 6px #00000029;line-height:normal;max-height:100vh;max-width:850px;overflow:auto;width:100%}.tfr-close-container{text-align:end}.tfr-close{color:#aaa;font-size:28px;font-weight:700;height:50px;width:50px}.tfr-close:focus,.tfr-close:hover{color:#000;text-decoration:none}.tfr-cursor:hover{cursor:pointer}.tfr-underline{text-decoration:underline}.tfr-standard-button{border:0;border-radius:3px;color:#fff;height:43px;width:138px}.tfr-logo-container{align-items:center;display:flex}.tfr-modal-title-logo-container{align-items:center;display:flex;justify-content:center}.tfr-girl-clothes{display:inline-block;height:316px;width:253px}.tfr-t-a-center{text-align:center}.tfr-w-70-p{width:70%}.tfr-w-80-p{width:80%}.tfr-w-85-p{width:85%}.tfr-w-150{width:150px}.tfr-h-150{height:150px}.tfr-d-none{display:none}.tfr-d-block{display:block}.tfr-d-flex{display:flex}.tfr-how-it-works-item{align-items:center;display:flex;justify-items:center}.tfr-try-on-content{margin-left:60px}#tfr-tryon-image{max-width:30vw}.progress-bar{background-color:#fff;border:1px solid #bdbdbd;height:10px;margin:15px auto 0;width:55%}.progress-bar-fill{animation-duration:120s;animation-name:progress;background-color:#209da7;color:#fff;display:block;font-size:16px;height:100%;text-align:center;transition:width .6s linear}#tfr-video{height:100%;max-height:350px;max-width:350px}.tfr-logo-box{margin:auto;max-height:400px;max-width:860px;padding:20px}.tfr-flex,.tfr-logo-box{align-items:center;display:flex;justify-content:center}.tfr-qr-code{width:200px}.tfr-space-above{margin-top:10px}.tfr-max-w-600{margin:auto;max-width:600px}#tfr-qr-border-box{align-items:center;border:2px solid var(--tfr-brand-color);border-radius:16px;display:flex;flex-direction:column;height:350px;justify-content:center;margin-left:20px;padding:0 30px;width:300px}.tfr-mobile-logo{height:60px}#email-input,#password-input{font-size:16px}",{});wy("input{border:none;box-shadow:none!important;width:100%}input:focus,select:focus,textarea:focus{border:none;outline:none}.tfr-fieldset{margin-left:auto;margin-right:auto;width:65%}.tfr-fieldset,.tfr-fieldset-inline{border-color:rgba(0,0,0,.5);border-radius:10px;border-width:1px;padding:5px 10px 10px;text-align:left}.tfr-fieldset-inline{margin-right:10px;width:250px}.tfr-fieldset-err{border-color:red}",{});wy(".lds-ellipsis{display:inline-block;height:80px;position:relative;width:80px}.lds-ellipsis div{animation-timing-function:cubic-bezier(0,1,1,0);background:var(--tfr-brand-color);border-radius:50%;display:block;height:13px;position:absolute;top:33px;width:13px}.lds-ellipsis div:first-child{animation:lds-ellipsis1 .6s infinite;left:8px}.lds-ellipsis div:nth-child(2){animation:lds-ellipsis2 .6s infinite;left:8px}.lds-ellipsis div:nth-child(3){animation:lds-ellipsis2 .6s infinite;left:32px}.lds-ellipsis div:nth-child(4){animation:lds-ellipsis3 .6s infinite;left:56px}@keyframes lds-ellipsis1{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0)}to{transform:translate(24px)}}",{});wy("@media screen and (max-width:702px){.tfr-modal-title-logo-container{display:flex;flex-direction:column}}@media screen and (min-width:600px){.tfr-modal-content-container{border-radius:10px;height:auto;margin:auto;width:100%}}@media screen and (max-width:599px){#tfr-size-recommendations{width:calc(100vw - 30px)!important}.tfr-mobile-hidden{display:none}.tfr-modal-content-container{max-height:none;max-width:100vw;min-height:100vh;min-width:100vw}.trf-logo-title{margin-bottom:10px}.tfr-modal-content-flex{overflow:auto}}@media screen and (max-width:500px){.tfr-fieldset{width:90%}.tfr-how-it-works-item{flex-direction:column}.tfr-try-on-content{margin-left:0;margin-top:20px}}@media screen and (max-width:380){#tfr-size-rec-subtitle{min-width:none}}@media screen and (max-height:800px){.tfr-video-responsive{height:280px!important}}",{});wy("#tfr-size-recommendations{align-items:center;background-color:var(--tfr-main-bg-color);border:var(--tfr-main-border-width) solid var(--tfr-main-border-color);border-radius:var(--tfr-main-border-radius);color:var(--tfr-dark);display:flex;flex-direction:column;font-family:var(--tfr-main-font);justify-content:center;padding:var(--tfr-main-v-padding) var(--tfr-main-h-padding);width:var(--tfr-main-width)}#tfr-size-recommendations-container{align-items:center;display:none;flex-direction:column;justify-content:center;position:relative;width:100%}#tfr-size-rec-select-container{align-items:center;display:none;flex-direction:column;font-size:13px;width:100%}#tfr-size-rec-title{align-items:center;display:flex;font-family:var(--tfr-title-font);margin-bottom:8px}#tfr-size-rec-title-toggle{color:var(--tfr-grey);cursor:pointer;position:absolute;right:0;top:0;transition:all .3s ease}.tfr-chevron-up{transform:rotate(180deg) scaleY(.6)}.tfr-chevron-down{transform:rotate(0deg) scaleY(.6)}#tfr-size-rec-subtitle{background-color:var(--tfr-grey);border-radius:4px;color:var(--tfr-white);font-family:var(--tfr-subtitle-font);min-width:318px;padding:8px;text-align:center;width:100%}#tfr-size-rec-subtitle,#tfr-size-rec-title{font-size:14px}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;padding:0 10px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:0}.tfr-size-rec-table-row{align-items:center;border-top:var(--tfr-main-border-width) solid var(--tfr-main-border-color);display:flex;font-family:var(--tfr-row-font);justify-content:center;min-height:40px}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{flex-grow:1;padding-left:8px;text-align:right}.tfr-size-rec-table-cell-right{margin-left:16px;padding-right:8px}.tfr-size-rec-table-cell-right.perfect{color:var(--tfr-brand-color)}#tfr-size-rec-size{display:inline-block}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:var(--tfr-muted);display:flex;width:150px}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none;font-family:var(--tfr-cta-font)}#tfr-size-rec-action{cursor:pointer;font-size:16px;text-decoration:underline}#tfr-size-rec-select{background-color:var(--tfr-size-selector-bg-color);border-color:var(--tfr-size-selector-border-color);border-radius:var(--tfr-size-selector-button-radius);border-style:solid;border-width:var(--tfr-size-selector-border-width);box-shadow:var(--tfr-size-selector-button-shadow);color:var(--tfr-size-selector-text-color);display:none;font-size:var(--tfr-size-selector-font-size);font-weight:var(--tfr-size-selector-font-weight);margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:var(--tfr-size-selector-button-height);justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active){background-color:var(--tfr-size-selector-bg-color-hover);opacity:.7}.tfr-size-rec-select-button.active{background-color:var(--tfr-size-selector-bg-color-active);border-color:var(--tfr-size-selector-button-active-border-color);border-style:solid;border-width:var(--tfr-size-selector-button-active-border-width);height:var(--tfr-size-selector-button-active-height)}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:var(--tfr-size-selector-button-radius);border-top-left-radius:var(--tfr-size-selector-button-radius)}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:var(--tfr-size-selector-button-radius);border-top-right-radius:var(--tfr-size-selector-button-radius)}.tfr-powered-by{align-items:center;display:flex;font-size:10px;margin-top:10px}.tfr-powered-by-logo{margin:0 4px}.tfr-powered-by-logo,.tfr-powered-by-logo img{height:24px}.tfr-powered-by-text-bold{font-weight:700}#tfr-size-recommendation-error{color:#8d0000;display:none}#tfr-sign-in-nav{margin-bottom:80px}",{});wy(".tfr-mt-10{margin-top:10px}.tfr-mt-20{margin-top:20px}.tfr-mt-15{margin-top:15px}.tfr-mt-30{margin-top:30px}.mt-40{margin-top:40px}.tfr-mb-40{margin-bottom:40px}.tfr-mb-20{margin-bottom:20px}.tfr-mr-10{margin-right:10px}.tfr-mr-15{margin-right:15px}.tfr-mt-50{margin-top:50px}.tfr-mt-60{margin-top:60px}.tfr-mb-60{margin-bottom:60px}.tfr-mr-20{margin-right:20px}.tfr-mt-15-p{margin-top:15%}.tfr-mb-13-p{margin-bottom:13%}.tfr-m-h-auto{margin-left:auto;margin-right:auto}.tfr-pt-20{padding-top:20px}.tfr-pb-50{padding-bottom:50px}.tfr-p-20{padding:20px 10px}.tfr-pr-20{padding-right:20px}.tfr-pl-20{padding-left:20px}.tfr-pb-7-p{padding-bottom:7%}",{});wy(".flag-container{bottom:0;left:0;padding:1px;right:0;right:auto;top:0}.flag-container:hover{cursor:pointer}.selected-flag{align-items:center;display:flex;height:100%;padding:0 6px 0 8px;position:relative;z-index:1}.flag.bd{background-position:-418px 0;height:12px}.arrow{border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #555;height:0;margin-left:6px;width:0}.arrow-up{border-bottom:6px solid #555;border-top:none}.country-list{-webkit-overflow-scrolling:touch;background-color:#fff;border-radius:5px;box-shadow:0 8px 10px 1px rgba(57,64,78,.7),0 3px 14px 2px rgba(57,64,78,.7),0 5px 5px -3px rgba(57,64,78,.7);cursor:pointer;display:none;font-size:16px;line-height:18px;list-style:none;margin:0 0 0 -1px;max-height:500px;overflow:auto;padding:0;position:absolute;text-align:left;top:50%;transform:translateY(-50%);white-space:nowrap;width:100%;width:auto;z-index:2}.country-list.active{display:inline-block}.country{outline:0;padding:5px 26px 5px 15px}.country-list .divider{border-bottom:1px solid rgba(0,0,0,.12);margin-bottom:5px;padding-bottom:5px}.country.highlight{background-color:#c7cace}.flag-box{display:inline-block;width:20px}.country-name,.flag-box{margin-right:6px}.country-name,.dial-code,.flag-box{vertical-align:middle}",{});wy(".tfr-title-font{font-family:Poppins,sans-serif}.tfr-body-font{font-family:Roboto,sans-serif}.tfr-light-24-300{font-size:24px;font-weight:300}.tfr-light-24-500{font-size:24px;font-weight:500}.tfr-light-22-300{font-size:22px;font-weight:300}.tfr-light-16-300{font-size:16px;font-weight:300}.tfr-medium-16-default{font-size:16px}.tfr-12-default{font-size:12px}.tfr-14-default{font-size:14px}.tfr-16-default{font-size:16px}.tfr-24-bold{font-size:24px;font-weight:700}",{});wy(":root{--tfr-brand-color:#209da7;--tfr-black:#000;--tfr-red:red;--tfr-white:#fff;--tfr-muted:#a7a7a7;--tfr-dark:#121212;--tfr-grey:#878787;--tfr-light-grey:#dbdcdc;--tfr-dark-grey:#3f3f3f;--tfr-main-border-color:hsla(0,0%,7%,.55);--tfr-main-border-radius:0;--tfr-main-border-width:1px;--tfr-main-bg-color:inherit;--tfr-main-width:440px;--tfr-main-v-padding:14px;--tfr-main-h-padding:20px;--tfr-main-font:inherit;--tfr-title-font:var(--tfr-main-font);--tfr-subtitle-font:var(--tfr-main-font);--tfr-row-font:var(--tfr-main-font);--tfr-cta-font:var(--tfr-main-font);--tfr-size-selector-text-color:var(--tfr-white);--tfr-size-selector-font-size:14px;--tfr-size-selector-font-weight:400;--tfr-size-selector-border-color:transparent;--tfr-size-selector-border-width:0;--tfr-size-selector-bg-color:var(--tfr-grey);--tfr-size-selector-bg-color-hover:var(--tfr-dark-grey);--tfr-size-selector-bg-color-active:var(--tfr-dark);--tfr-size-selector-button-height:35px;--tfr-size-selector-button-active-height:45px;--tfr-size-selector-button-active-border-color:transparent;--tfr-size-selector-button-active-border-width:0;--tfr-size-selector-button-radius:8px;--tfr-size-selector-button-shadow:0 4px 4px 0 rgba(0,0,0,.3)}",{});const by=t=>({Hook:()=>{const e=document.querySelector(".progress-bar-fill");!function(t,e){let n=0;const r=t/200;e.style.width=n+"%";const i=setInterval((()=>{n>=100?clearInterval(i):(n+=.5,e.style.width=n+"%")}),r)}(t.timeoutMS,e)},Unhook:()=>{},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mt-60" > ${Jm} </div>\n <div class="progress-bar">\n <span class="progress-bar-fill"></span>\n </div>\n `}),Sy=t=>{const e=document.getElementById(t),n=document.querySelector("body");if(!e)throw new Error(`element with id ${t} not found`);let r;const i=()=>{n.style.overflow="auto",r&&(r.Unhook(),c()),e.style.display="none"},s=t=>{"Escape"===t.key&&i()},o=t=>{const n=e.querySelector("#tfr-modal-background");t.target===n&&(console.debug("container close"),i())},a=()=>{e.querySelector("#tfr-close-container").addEventListener("click",i),document.addEventListener("keydown",s),document.addEventListener("click",o)},c=()=>{var n;const r=e.querySelector("#tfr-close-container");r?r.removeEventListener("click",i):(console.error("#tfr-close-container not found on unhook"),console.debug(null===(n=document.getElementById(t))||void 0===n?void 0:n.innerHTML)),document.removeEventListener("keydown",s),document.removeEventListener("click",o)};return{open:t=>{var i;n.style.overflow="hidden",r&&r.Unhook(),e.innerHTML=(i=t.Body(),`\n <div class="tfr-modal" id="tfr-modal-background">\n <div class="tfr-modal-content-container tfr-p-20">\n <div class="tfr-close-container">\n <span id="tfr-close-container" class="tfr-close tfr-cursor">&times;</span>\n </div>\n\n <div class="tfr-modal-content-flex">\n <div class="tfr-modal-content">\n <div class="tfr-modal-title-logo-container">\n <div tfr-element="true" class="trf-logo-title tfr-title-font tfr-light-24-300 tfr-c-black tfr-mr-10">${gy}</div>\n <div tfr-element="true" class="tfr-logo-container">\n <div class="tfr-mr-15">\n <svg width="26" height="47" viewBox="0 0 68 124" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M0.911938 0L67.4819 17.09V106.49L0.911938 123.51V0Z" fill="#209DA7">\n </path>\n <path d="M52.8019 64.44C54.7791 64.44 56.3819 62.4387 56.3819 59.97C56.3819 57.5013 54.7791 55.5 52.8019 55.5C50.8248 55.5 49.2219 57.5013 49.2219 59.97C49.2219 62.4387 50.8248 64.44 52.8019 64.44Z" fill="white">\n </path>\n </svg>\n </div>\n <div tfr-element="true" class="tfr-title-font tfr-light-24-500 tfr-c-black tfr-mr-10">${dy}</div>\n </div>\n </div>\n ${i}\n </div>\n </div>\n </div>\n </div>\n `),a(),t.Hook(),e.style.display="block",r=t},close:i,Content:()=>r}},_y=t=>{const e=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),n=()=>{t.onSignInNav()},r=()=>{window.open("https://apps.apple.com/us/app/the-fitting-room-3d-body-scan/id1577417373","_blank")},i=()=>{window.open("https://play.google.com/store/apps/details?id=com.thefittingroom.marketplace","_blank")},s="https://assets.dev.thefittingroom.xyz/images/";return{Hook:()=>{var t,s,o;if(e||(document.getElementById("tfr-sign-in-nav").style.marginBottom="0"),e){document.getElementById("tfr-video").classList.add("tfr-video-responsive")}null===(t=document.getElementById("tfr-sign-in-nav"))||void 0===t||t.addEventListener("click",n),null===(s=document.getElementById("tfr-app-store"))||void 0===s||s.addEventListener("click",r),null===(o=document.getElementById("tfr-google-play"))||void 0===o||o.addEventListener("click",i)},Unhook:()=>{var t,e,s;null===(t=document.getElementById("tfr-sign-in-nav"))||void 0===t||t.removeEventListener("click",n),null===(e=document.getElementById("tfr-app-store"))||void 0===e||e.removeEventListener("click",r),null===(s=document.getElementById("tfr-google-play"))||void 0===s||s.removeEventListener("click",i)},Body:()=>`\n <div tfr-element="true">\n <div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-10">${my}</div>\n \n </div>\n <div tfr-element="true" class="tfr-logo-box">\n <video id="tfr-video" controls loop autoplay playsinline>\n <source src="https://assets.dev.thefittingroom.xyz/videos/the-fitting-room.mp4" />\n </video>\n\n ${e?"":`<div id="tfr-qr-border-box">\n <div tfr-element="true" class="tfr-title-font tfr-24-bold">${oy}</div>\n \n <img src="${s}qr.png" class="tfr-qr-code" />\n\n <div id="tfr-sign-in-nav" tfr-element="true" class="tfr-body-font tfr-mt-20 tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${Ym}</div>\n </div>`}\n </div>\n\n ${e?`<div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-10 tfr-max-w-600">${jm}</div>\n\n <div tfr-element="true" class="tfr-flex tfr-space-above">\n <img class="tfr-mobile-logo" src="${s}apple.png" id="tfr-app-store" />\n <img class="tfr-mobile-logo" src="${s}google.png" id="tfr-google-play" />\n </div>\n \n <div id="tfr-sign-in-nav" tfr-element="true" class="tfr-body-font tfr-mt-20 tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${Ym}</div>\n `:""}\n `}};class Ey{constructor(t,e,n,r){this.signIn=e,this.forgotPassword=n,this.submitTel=r,this.manager=Sy(t)}close(){this.manager.close()}onSignOut(){this.manager.open((t=>{const e=()=>{t.onNavSignIn("")},n=()=>{t.onClose()};return{Hook:()=>{var t,r;null===(t=document.getElementById("tfr-sign-in"))||void 0===t||t.addEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.addEventListener("click",n)},Unhook:()=>{var t,r;null===(t=document.getElementById("tfr-sign-in"))||void 0===t||t.removeEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.removeEventListener("click",n)},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-mt-15-p tfr-mb-13-p">${hy}</div>\n <div class="tfr-t-a-center">\n <span id="tfr-sign-in" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${cy}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" >${iy}</span>\n </div>\n `}})({onNavSignIn:()=>this.toSignIn(),onClose:()=>this.close()}))}onNotCreated(){this.manager.open({Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mt-60">${qm}</div>\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mb-60">${sy}</div>\n `,Hook:()=>{},Unhook:()=>{}})}onLoading(){this.manager.open(by({timeoutMS:1e4}))}toScan(){this.manager.open(_y({onSignInNav:()=>this.toSignIn(),onTelSubmit:t=>this.submitTel(t)}))}toSignIn(){this.manager.open((t=>{const{email:e}=t,n=e=>{e.preventDefault();const n=document.getElementById("email-input").value,r=document.getElementById("password-input").value;s(),t.onSignIn(n,r,o)},r=()=>{const e=document.getElementById("email-input").value;t.onNavForgotPassword(e)},i=()=>{t.onNavScanCode()},s=()=>{document.querySelectorAll(".tfr-fieldset-element").forEach((t=>{t.classList.remove("tfr-fieldset-err")})),document.querySelectorAll(".tfr-label-element").forEach((t=>{t.classList.remove("tfr-c-red")}));const t=document.querySelector("#tfr-form-error");t.classList.remove("tfr-d-block"),t.innerHTML=""},o=t=>{document.querySelectorAll(".tfr-fieldset-element").forEach((t=>{t.classList.add("tfr-fieldset-err")})),document.querySelectorAll(".tfr-label-element").forEach((t=>{t.classList.add("tfr-c-red")}));const e=document.querySelector("#tfr-form-error");e.innerHTML=t||"Something went wrong",e.classList.add("tfr-d-block")};return{Hook:()=>{var t,e,s,o;null===(t=document.getElementById("tfr-sign-in-form"))||void 0===t||t.addEventListener("submit",n),null===(e=document.getElementById("tfr-sign-in"))||void 0===e||e.addEventListener("click",n),null===(s=document.getElementById("tfr-forgot-password"))||void 0===s||s.addEventListener("click",r),null===(o=document.getElementById("tfr-scan-code"))||void 0===o||o.addEventListener("click",i)},Unhook:()=>{var t,e,s,o;null===(t=document.getElementById("tfr-sign-in-form"))||void 0===t||t.removeEventListener("submit",n),null===(e=document.getElementById("tfr-sign-in"))||void 0===e||e.removeEventListener("click",n),null===(s=document.getElementById("tfr-forgot-password"))||void 0===s||s.removeEventListener("click",r),null===(o=document.getElementById("tfr-scan-code"))||void 0===o||o.removeEventListener("click",i)},Body:()=>`\n <form id="tfr-sign-in-form">\n <div class="tfr-title-font tfr-light-22-300 tfr-mt-10">${ly}</div>\n\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-20">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${Wm}</legend>\n <input tfr-element="true" type="email" id="email-input" value="${e||""}" />\n </fieldset>\n\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-20">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${ty}</legend>\n <input tfr-element="true" type="password" id="password-input" />\n </fieldset>\n\n <div tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-red tfr-mt-10 tfr-d-none" id="tfr-form-error"></div>\n\n <div class="tfr-mt-20">\n <span id="tfr-forgot-password" tfr-element="true" class="tfr-body-font tfr-14-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-15">${Qm}</span>\n <span id="tfr-scan-code" tfr-element="true" class="tfr-body-font tfr-14-default tfr-c-black-o5 tfr-underline tfr-cursor">${$m}</span>\n </div>\n\n <button id="tfr-sign-in" tfr-element="true" class="tfr-standard-button tfr-c-brand-bg tfr-c-whitetfr-title-font tfr-medium-16-default tfr-cursor tfr-mt-30" id="sign-in-button" type="submit">\n ${ly}\n </button>\n </form>\n `}})({onSignIn:this.signIn,onNavForgotPassword:()=>this.toForgotPassword(),onNavScanCode:()=>this.toScan()}))}toForgotPassword(){this.manager.open((t=>{const e=()=>{const e=document.getElementById("tfr-email").value;t.onNavSignIn(e)},n=()=>{const e=document.getElementById("tfr-email").value;t.onPasswordReset(e)};return{Hook:()=>{var t,r;null===(t=document.getElementById("tfr-send-password-reset"))||void 0===t||t.addEventListener("click",n),null===(r=document.getElementById("tfr-back-to-signin"))||void 0===r||r.addEventListener("click",e)},Unhook:()=>{var t,r;null===(t=document.getElementById("tfr-send-password-reset"))||void 0===t||t.removeEventListener("click",n),null===(r=document.getElementById("tfr-back-to-signin"))||void 0===r||r.removeEventListener("click",e)},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-20 tfr-w-70-p tfr-m-h-auto">${Gm}</div>\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-30">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${Wm}</legend>\n <input tfr-element="true" type="email" id="tfr-email" />\n </fieldset>\n <div tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-red tfr-mt-10 tfr-d-none" id="error-msg"></div>\n <div id="tfr-back-to-signin" tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mt-30">${Hm}</div>\n <button id="tfr-send-password-reset" tfr-element="true" class="tfr-standard-button tfr-c-brand-bg tfr-c-whitetfr-title-font tfr-medium-16-default tfr-cursor tfr-mt-30">\n ${ay}\n </button>\n `}})({onNavSignIn:()=>this.toSignIn(),onPasswordReset:this.forgotPassword}))}toPasswordReset(){}onTryOn(t){this.manager.open((t=>{let e=()=>{};const r=()=>{t.onNavBack()},i=()=>{t.onClose()};return{Hook:()=>{var s,o;const a=document.getElementById("tfr-tryon-image"),c=n("tfr-slider",((t,e)=>{console.debug("slider change",t,e),a.src=e}));if(Array.isArray(t.frames)&&t.frames.length>0){const n=c.Load(t.frames);if(n instanceof Error)return void console.error(n);e=n}null===(s=document.getElementById("tfr-back"))||void 0===s||s.addEventListener("click",r),null===(o=document.getElementById("tfr-close"))||void 0===o||o.addEventListener("click",i)},Unhook:()=>{var t,n;e(),null===(t=document.getElementById("tfr-back"))||void 0===t||t.removeEventListener("click",r),null===(n=document.getElementById("tfr-close"))||void 0===n||n.removeEventListener("click",i)},Body:()=>`\n <div class="tfr-slider-wrapper">\n\t\t\t\t<img id="tfr-tryon-image" src="" />\n\t\t\t\t<input type="range" id="tfr-slider" />\n\t\t\t\t</div>\n\t\t\t\t<div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${ny}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" id="returnToSite">${ry}</span>\n </div>\n `}})({frames:t,onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}onError(t){this.manager.open((t=>{const{error:e}=t,n=()=>{t.onNavBack()},r=()=>{t.onClose()};return{Hook:()=>{var t,e;null===(t=document.getElementById("tfr-back"))||void 0===t||t.addEventListener("click",n),null===(e=document.getElementById("tfr-close"))||void 0===e||e.addEventListener("click",r)},Unhook:()=>{var t,e;null===(t=document.getElementById("tfr-back"))||void 0===t||t.removeEventListener("click",n),null===(e=document.getElementById("tfr-close"))||void 0===e||e.removeEventListener("click",r)},Body:()=>(e||console.error("ErrorModal: No error provided"),`\n <div class="tfr-mt-15-p tfr-mb-13-p">\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black">${e||uy}</div>\n </div>\n\n <div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${ny}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" id="returnToSite">${ry}</span>\n </div>\n `)}})({error:t,onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}onSizeError(t,e){this.manager.open((t=>{const e=()=>{t.onNavBack()},n=()=>{t.onClose()};return{Hook:()=>{var t,r;null===(t=document.getElementById("tfr-back"))||void 0===t||t.addEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.addEventListener("click",n)},Unhook:()=>{var t,r;null===(t=document.getElementById("tfr-back"))||void 0===t||t.removeEventListener("click",e),null===(r=document.getElementById("tfr-close"))||void 0===r||r.removeEventListener("click",n)},Body:()=>{var e,n,r;return console.debug("rendering size error modal",t),`\n <div class="tfr-mt-15-p tfr-mb-13-p">\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black">\n\t\t\t\t\t\t\t${Xm} ${null===(e=t.sizes)||void 0===e?void 0:e.recommended} ${Zm} ${null===(r=null===(n=t.sizes)||void 0===n?void 0:n.available)||void 0===r?void 0:r.join(" or ")}\n\t\t\t\t\t\t</div>\n </div>\n\n <div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${ny}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${ry}</span>\n </div>\n `}}})({sizes:{recommended:t,available:e},onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}navBack(){window.history.back()}}const Ty="https://assets.dev.thefittingroom.xyz/shop-sdk/assets/login-icon.svg";class Iy{constructor(t,e,n){this.onSignInClick=e,this.onSignOutClick=n,this._sku="",this.isLoggedIn=!1,this.isCollapsed=!1,this.redraw=null,this.init(t)}get sku(){return this._sku}setSku(t){this._sku=t}setIsLoggedIn(t){this.isLoggedIn=t,this.tfrSizeRecSelectContainer.style.display="flex",t?(this.tfrSizeRecActionLogin.style.display="none",this.tfrSizeRecActionLogout.style.display="block",this.tfrSizeRecTitle.style.display="flex",this.tfrSizeRecSubtitle.style.display="block",this.isCollapsed=!1,this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-down"),this.tfrSizeHowItFits.style.display="block"):(this.tfrSizeRecActionLogin.style.display="block",this.tfrSizeRecActionLogout.style.display="none",this.tfrSizeRecTitle.style.display="flex",this.tfrSizeRecSubtitle.style.display="block",this.tfrSizeRecommendationError.style.display="none",this.tfrSizeRecommendationError.innerHTML="",this.tfrSizeHowItFits.style.display="none")}setLoading(t){t?(this.tfrSizeRecLoading.style.display="block",this.tfrSizeRecommendationsContainer.style.display="none"):(this.tfrSizeRecLoading.style.display="none",this.tfrSizeRecommendationsContainer.style.display="flex")}setGarmentLocations(t){if(!t||!t.length)return this.tfrSizeRecTitle.style.display="none",void(this.tfrSizeRecSubtitle.style.display="none");this.renderGarmentLocations(t),this.tfrSizeRecSelect.style.display="none"}setRecommendedSize({recommended:t,sizes:e}){this.renderSizeRec(t,e),this.tfrSizeRecSelect.style.display="flex"}setError(){this.tfrSizeRecTitle.style.display="none",this.tfrSizeRecSubtitle.style.display="none",this.isLoggedIn&&(this.tfrSizeRecommendationError.style.display="block",this.tfrSizeRecommendationError.innerHTML="No recommended size found.")}init(t){const e=document.getElementById(t);if(!e)throw new Error("Size rec main div not found");this.render(e),this.setElements(),this.bindEvents()}setElements(){this.tfrSizeHowItFits=document.getElementById("tfr-size-how-it-fits"),this.tfrSizeRecTitle=document.getElementById("tfr-size-rec-title"),this.tfrSizeRecSubtitle=document.getElementById("tfr-size-rec-subtitle"),this.tfrSizeRecActionLogin=document.getElementById("tfr-size-rec-action-login"),this.tfrSizeRecActionLogout=document.getElementById("tfr-size-rec-action-logout"),this.tfrSizeRecTable=document.getElementById("tfr-size-rec-table"),this.tfrSizeRecommendationError=document.getElementById("tfr-size-recommendation-error"),this.tfrSizeRecSize=document.getElementById("tfr-size-rec-size"),this.tfrSizeRecSelect=document.getElementById("tfr-size-rec-select"),this.tfrSizeRecLoading=document.getElementById("tfr-size-rec-loading"),this.tfrSizeRecTitleToggle=document.getElementById("tfr-size-rec-title-toggle"),this.tfrSizeRecSelectContainer=document.getElementById("tfr-size-rec-select-container"),this.tfrSizeRecommendationsContainer=document.getElementById("tfr-size-recommendations-container")}bindEvents(){this.tfrSizeRecActionLogin.addEventListener("click",this.onSignInClick),this.tfrSizeRecActionLogout.addEventListener("click",this.onSignOutClick),this.tfrSizeRecSelect.addEventListener("click",this.onSizeRecSelectClick.bind(this)),this.tfrSizeRecTitleToggle.addEventListener("click",this.toggletSizeRecSelectContainer.bind(this))}onSizeRecSelectClick(t){const e=t.target;if(!e.classList.contains("tfr-size-rec-select-button"))return;t.preventDefault();const n=Number(e.getAttribute("data-index"));if(Number.isNaN(n))return;const r=document.querySelectorAll(".tfr-size-rec-select-button");r.forEach((t=>t.classList.remove("active"))),r.item(n).classList.add("active"),this.redraw(n)}renderSizeRec(t,e){this.tfrSizeRecSize.innerHTML=`&nbsp;${t}`;const n=e.findIndex((({size:e})=>e===t));this.redraw=t=>this.renderSizeRecTable(e,t),this.redraw(n),this.renderSizeRecSelect(e,n)}renderSizeRecTable(t,e){const{locations:n}=t[e],r=n.map((({location:t,fit:e,isPerfect:n})=>this.renderSizeRecTableRow(t,e,n))).join("");this.tfrSizeRecTable.innerHTML=r}renderSizeRecSelect(t,e){const n=t.map((({size:t})=>t)).map(((t,n)=>`<div class="tfr-size-rec-select-button ${n===e?"active":""}" data-index="${n}">${t}</div>`)).join("");this.tfrSizeRecSelect.innerHTML=n}renderSizeRecTableRow(t,e,n=!1){return`<div class="tfr-size-rec-table-row">\n <div class="tfr-size-rec-table-cell-left">${t}</div>\n <div class="tfr-size-rec-table-cell-right ${n?"perfect":""}">\n ${e}\n </div>\n </div>`}renderLoginCta(){return`<div class="tfr-size-rec-login-cta"><img src="${Ty}" /> Sign up or login to view</div>`}renderGarmentLocations(t){const e=t.map((t=>this.renderSizeRecTableRow(t,this.renderLoginCta()))).join("");this.tfrSizeRecTable.innerHTML=e,this.tfrSizeRecSize.innerHTML=this.renderLoginCta()}toggletSizeRecSelectContainer(){this.isCollapsed?(this.isCollapsed=!1,this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-down"),this.tfrSizeRecSelectContainer.style.display="flex"):(this.isCollapsed=!0,this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-down"),this.tfrSizeRecSelectContainer.style.display="none")}render(t){const e=`<div id="tfr-size-recommendations">\n <div id="tfr-size-rec-loading">\n <div class="lds-ellipsis">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n <div id="tfr-size-recommendations-container">\n <div id="tfr-size-rec-title-toggle" class="tfr-chevron-up">v</div>\n\n <div id="tfr-size-rec-title">\n Recommended Size:\n <div id="tfr-size-rec-size">\n <div class="tfr-size-rec-login-cta">\n <img src="${Ty}" /> Sign up or login to view\n </div>\n </div>\n </div>\n\n <div id="tfr-size-rec-select-container">\n <div id="tfr-size-how-it-fits">Select size to see how it fits:</div>\n\n <div id="tfr-size-rec-select"></div>\n \n <div id="tfr-size-rec-subtitle">How it fits</div>\n \n <div id="tfr-size-rec-table"></div>\n </div>\n \n <div id="tfr-size-rec-action">\n <div id="tfr-size-rec-action-login">Sign up or login</div>\n <div id="tfr-size-rec-action-logout">Log out</div>\n </div>\n\n <div class="tfr-powered-by">\n <div>Powered by</div>\n <div class="tfr-powered-by-logo"><img src="https://assets.dev.thefittingroom.xyz/shop-sdk/assets/tfr-door-brand.svg" /></div>\n <div class="tfr-powered-by-text-bold">The Fitting Room</div>\n </div>\n </div>\n </div>\n <div id="tfr-size-recommendation-error"></div>`;t.innerHTML=e}}class ky{constructor(t,e,n,r,i){this.tfrShop=n,this.onSignInClick=r,this.onSignOutClick=i,this.perfectFits=[Vm.Fit.PERFECT_FIT,Vm.Fit.SLIGHTLY_LOOSE,Vm.Fit.SLIGHTLY_TIGHT],this.setCssVariables(e),this.sizeRecComponent=new Iy(t,this.onSignInClick,this.onSignOutClick)}get sku(){return this.sizeRecComponent.sku}setSku(t){this.sizeRecComponent.setSku(t)}setIsLoggedIn(t){this.sizeRecComponent.setIsLoggedIn(t)}async setGarmentLocations(t=[]){this.sizeRecComponent.setLoading(!0);const e=await this.getGarmentLocations(t);console.debug("locations",e),console.debug("filledLocations",t),this.sizeRecComponent.setGarmentLocations(e||[]),this.sizeRecComponent.setLoading(!1)}async setRecommendedSize(){this.sizeRecComponent.setLoading(!0);const t=await this.getRecommenedSize();if(!t)return console.error("No sizes found for sku"),this.sizeRecComponent.setLoading(!1),void this.sizeRecComponent.setError();this.sizeRecComponent.setRecommendedSize(t),this.sizeRecComponent.setLoading(!1)}async getGarmentLocations(t){try{return await this.tfrShop.getMeasurementLocationsFromSku(this.sku,t)}catch(e){try{const e=await this.tfrShop.getStyleByBrandStyleId(this.sku);return await this.tfrShop.getMeasurementLocationsFromBrandStyleId(e.id,t)}catch(t){return console.error(t),this.sizeRecComponent.setError(),null}}}async getRecommenedSize(){try{const t=await this.tfrShop.getColorwaySizeAssetFromSku(this.sku);return await this.getRecommendedSizes(String(t.style_id))}catch(t){try{const t=await this.tfrShop.getStyleByBrandStyleId(this.sku);return await this.getRecommendedSizes(String(t.id))}catch(t){return console.error(t),this.sizeRecComponent.setError(),null}}}async getRecommendedSizes(t){const e=await this.tfrShop.getRecommendedSizes(t);return e?{recommended:e.recommended_size.label,sizes:e.fits.map((t=>({size:e.available_sizes.find((e=>e.id===t.size_id)).label,locations:t.measurement_location_fits.map((t=>({fit:"string"==typeof t.fit_label&&t.fit_label?t.fit_label:Vm.FitNames[t.fit],isPerfect:this.perfectFits.includes(t.fit),location:this.tfrShop.getMeasurementLocationName(t.measurement_location),sortOrder:this.tfrShop.getMeasurementLocationSortOrder(t.measurement_location)}))).sort(((t,e)=>t.sortOrder<e.sortOrder?-1:1))})))}:null}setCssVariables(t){const e=document.querySelector(":root");t.brandColor&&e.style.setProperty("--tfr-brand-color",t.brandColor),t.black&&e.style.setProperty("--tfr-black",t.black),t.red&&e.style.setProperty("--tfr-red",t.red),t.white&&e.style.setProperty("--tfr-white",t.white),t.muted&&e.style.setProperty("--tfr-muted",t.muted),t.dark&&e.style.setProperty("--tfr-dark",t.dark),t.grey&&e.style.setProperty("--tfr-grey",t.grey),t.lightGrey&&e.style.setProperty("--tfr-light-grey",t.lightGrey),t.mainBorderColor&&e.style.setProperty("--tfr-main-border-color",t.mainBorderColor),t.mainBorderRadius&&e.style.setProperty("--tfr-main-border-radius",t.mainBorderRadius),t.mainBorderWidth&&e.style.setProperty("--tfr-main-border-width",t.mainBorderWidth),t.mainBgColor&&e.style.setProperty("--tfr-main-bg-color",t.mainBgColor),t.mainWidth&&e.style.setProperty("--tfr-main-width",t.mainWidth),t.mainVPadding&&e.style.setProperty("--tfr-main-v-padding",t.mainVPadding),t.mainHPadding&&e.style.setProperty("--tfr-main-h-padding",t.mainHPadding),t.mainFont&&e.style.setProperty("--tfr-main-font",t.mainFont),t.titleFont&&e.style.setProperty("--tfr-title-font",t.titleFont),t.subtitleFont&&e.style.setProperty("--tfr-subtitle-font",t.subtitleFont),t.rowFont&&e.style.setProperty("--tfr-row-font",t.rowFont),t.ctaFont&&e.style.setProperty("--tfr-cta-font",t.ctaFont),t.sizeSelectorTextColor&&e.style.setProperty("--tfr-size-selector-text-color",t.sizeSelectorTextColor),t.sizeSelectorFontSize&&e.style.setProperty("--tfr-size-selector-font-size",t.sizeSelectorFontSize),t.sizeSelectorFontWeight&&e.style.setProperty("--tfr-size-selector-font-weight",t.sizeSelectorFontWeight),t.sizeSelectorBgColor&&e.style.setProperty("--tfr-size-selector-bg-color",t.sizeSelectorBgColor),t.sizeSelectorBorderColor&&e.style.setProperty("--tfr-size-selector-border-color",t.sizeSelectorBorderColor),t.sizeSelectorBorderWidth&&e.style.setProperty("--tfr-size-selector-border-width",t.sizeSelectorBorderWidth),t.sizeSelectorBgColorHover&&e.style.setProperty("--tfr-size-selector-bg-color-hover",t.sizeSelectorBgColorHover),t.sizeSelectorBgColorActive&&e.style.setProperty("--tfr-size-selector-bg-color-active",t.sizeSelectorBgColorActive),t.sizeSelectorButtonHeight&&e.style.setProperty("--tfr-size-selector-button-height",t.sizeSelectorButtonHeight),t.sizeSelectorButtonActiveHeight&&e.style.setProperty("--tfr-size-selector-button-active-height",t.sizeSelectorButtonActiveHeight),t.sizeSelectorButtonActiveBorderColor&&e.style.setProperty("--tfr-size-selector-button-active-border-color",t.sizeSelectorButtonActiveBorderColor),t.sizeSelectorButtonActiveBorderWidth&&e.style.setProperty("--tfr-size-selector-button-active-border-width",t.sizeSelectorButtonActiveBorderWidth),t.sizeSelectorButtonRadius&&e.style.setProperty("--tfr-size-selector-button-radius",t.sizeSelectorButtonRadius),t.sizeSelectorButtonShadow&&e.style.setProperty("--tfr-size-selector-button-shadow",t.sizeSelectorButtonShadow)}}var Cy;!function(t){t.NOT_CREATED="NOT_CREATED",t.CREATED="CREATED",t.PENDING="PENDING"}(Cy||(Cy={}));class Ay{constructor(t,e,n,r={},i,s){this.shopId=t,this.hooks=r,this.isLoggedIn=!1,this.unsub=null;const o=s||("undefined"!=typeof process?process.env.NODE_ENV:"dev");console.log("tfr-env",o),this.tfrModal=new Ey(e,this.signIn.bind(this),this.forgotPassword.bind(this),this.submitTel.bind(this)),this.tfrShop=((t,e="dev")=>("dev"!==e&&"development"!==e||console.warn("TfrShop is in development mode"),zd.getInstance().setEnv(e),new Nm(t,new Cm)))(Number(this.shopId),o),this.tfrSizeRec=new ky(n,i,this.tfrShop,this.onSignInClick.bind(this),this.signOut.bind(this))}get shop(){return this.tfrShop}get sku(){return this.tfrSizeRec.sku}async checkIfPublished(t){const e=await this.getStyle(t);return Boolean(null==e?void 0:e.is_published)}setSku(t){this.tfrSizeRec.setSku(t),this.isLoggedIn?this.tfrSizeRec.setRecommendedSize():this.setGarmentLocations()}async onInit(){var t,e;return this.isLoggedIn=await this.tfrShop.onInit(),this.tfrSizeRec.setIsLoggedIn(this.isLoggedIn),this.isLoggedIn?((null===(t=this.hooks)||void 0===t?void 0:t.onLogin)&&this.hooks.onLogin(),this.subscribeToProfileChanges()):((null===(e=this.hooks)||void 0===e?void 0:e.onLogout)&&this.hooks.onLogout(),this.unsubscribeFromProfileChanges()),this.isLoggedIn}close(){this.tfrModal.close()}async signOut(){var t;await this.tfrShop.user.logout(),(null===(t=this.hooks)||void 0===t?void 0:t.onLogout)&&this.hooks.onLogout(),this.isLoggedIn=!1,this.tfrSizeRec.setIsLoggedIn(!1),this.setGarmentLocations(),this.unsubscribeFromProfileChanges()}async signIn(t,e,n){var r;if(0==t.length||0==e.length)return n(fy);if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/.test(t))return n(Km);if(!(t=>!!t.match(/^.{7,}$/))(e))return n(ey);try{await this.tfrShop.user.login(t,e),(null===(r=this.hooks)||void 0===r?void 0:r.onLogin)&&this.hooks.onLogin(),this.tfrModal.close(),this.isLoggedIn=!0,this.tfrSizeRec.setIsLoggedIn(!0),this.tfrSizeRec.setRecommendedSize(),this.subscribeToProfileChanges()}catch(t){return n(py)}}setBrandUserId(t){this.tfrShop.user.setBrandUserId(t)}async submitTel(t){try{await this.tfrShop.submitTelephoneNumber(t),this.tfrModal.toSignIn()}catch(t){this.tfrModal.onError(uy)}}async forgotPassword(t){await this.tfrShop.user.sendPasswordResetEmail(t),this.tfrModal.toSignIn()}async passwordReset(t,e){await this.tfrShop.user.confirmPasswordReset(t,e),this.tfrModal.toPasswordReset()}async getMeasurementLocationsFromSku(t){return this.tfrShop.getMeasurementLocationsFromSku(t)}onSignInClick(){this.tfrModal.toScan()}onUserProfileChange(t){var e,n,r,i;switch(t.avatar_status){case Cy.NOT_CREATED:(null===(e=this.hooks)||void 0===e?void 0:e.onError)&&this.hooks.onError(qm),this.tfrModal.onNotCreated();break;case Cy.PENDING:(null===(n=this.hooks)||void 0===n?void 0:n.onLoading)&&this.hooks.onLoading();break;case Cy.CREATED:(null===(r=this.hooks)||void 0===r?void 0:r.onLoadingComplete)&&this.hooks.onLoadingComplete();break;default:(null===(i=this.hooks)||void 0===i?void 0:i.onError)&&this.hooks.onError(uy),this.tfrModal.onError(uy)}}subscribeToProfileChanges(){this.unsub||(this.unsub=this.tfrShop.user.watchUserProfileForChanges((t=>this.onUserProfileChange(t))))}unsubscribeFromProfileChanges(){this.unsub&&(this.unsub(),this.unsub=null)}async setGarmentLocations(){var t,e;const n=await this.getStyle(this.sku),r=(null===(e=null===(t=null==n?void 0:n.sizes)||void 0===t?void 0:t[0])||void 0===e?void 0:e.garment_measurements.map((t=>t.measurement_location)))||[];this.tfrSizeRec.setGarmentLocations(r)}async getStyle(t){try{const e=await this.tfrShop.getColorwaySizeAssetFromSku(t);return await this.tfrShop.getStyle(e.style_id)}catch(e){try{return await this.tfrShop.getStyleByBrandStyleId(t)}catch(t){return null}}}}const Ry=async(t,e,n,r={},i={},s="dev")=>{const o=new Ay(t,e,n,r,i,s);return await o.onInit(),o};export{n as InitImageSlider,Ry as initFittingRoom};