@inditextech/weave-store-azure-web-pubsub 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,73 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright [yyyy] [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,282 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 2025 INDUSTRIA DE DISEÑO TEXTIL S.A. (INDITEX S.A.)
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ -->
6
+
7
+ [![npm version](https://badge.fury.io/js/angular2-expandable-list.svg)](https://badge.fury.io/js/angular2-expandable-list)
8
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
9
+
10
+ # Weave.js / Store using Azure Web PubSub transport
11
+
12
+ > Write a project description
13
+
14
+ ## Prerequisites
15
+
16
+ This project requires NodeJS (version 8 or later) and NPM.
17
+ [Node](http://nodejs.org/) and [NPM](https://npmjs.org/) are really easy to install.
18
+ To make sure you have them available on your machine,
19
+ try running the following command.
20
+
21
+ ```sh
22
+ $ npm -v && node -v
23
+ 6.4.1
24
+ v8.16.0
25
+ ```
26
+
27
+ ## Table of contents
28
+
29
+ - [Project Name](#project-name)
30
+ - [Prerequisites](#prerequisites)
31
+ - [Table of contents](#table-of-contents)
32
+ - [Getting Started](#getting-started)
33
+ - [Installation](#installation)
34
+ - [Usage](#usage)
35
+ - [Serving the app](#serving-the-app)
36
+ - [Running the tests](#running-the-tests)
37
+ - [Building a distribution version](#building-a-distribution-version)
38
+ - [Serving the distribution version](#serving-the-distribution-version)
39
+ - [API](#api)
40
+ - [useBasicFetch](#usebasicfetch)
41
+ - [Options](#options)
42
+ - [fetchData](#fetchdata)
43
+ - [Contributing](#contributing)
44
+ - [Credits](#credits)
45
+ - [Built With](#built-with)
46
+ - [Versioning](#versioning)
47
+ - [Authors](#authors)
48
+ - [License](#license)
49
+
50
+ ## Getting Started
51
+
52
+ These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
53
+
54
+ ## Installation
55
+
56
+ **BEFORE YOU INSTALL:** please read the [prerequisites](#prerequisites)
57
+
58
+ Start with cloning this repo on your local machine:
59
+
60
+ ```sh
61
+ $ git clone https://github.com/ORG/PROJECT.git
62
+ $ cd PROJECT
63
+ ```
64
+
65
+ To install and set up the library, run:
66
+
67
+ ```sh
68
+ $ npm install -S myLib
69
+ ```
70
+
71
+ Or if you prefer using Yarn:
72
+
73
+ ```sh
74
+ $ yarn add --dev myLib
75
+ ```
76
+
77
+ ## Usage
78
+
79
+ ### Serving the app
80
+
81
+ ```sh
82
+ $ npm start
83
+ ```
84
+
85
+ ### Running the tests
86
+
87
+ ```sh
88
+ $ npm test
89
+ ```
90
+
91
+ ### Building a distribution version
92
+
93
+ ```sh
94
+ $ npm run build
95
+ ```
96
+
97
+ This task will create a distribution version of the project
98
+ inside your local `dist/` folder
99
+
100
+ ### Serving the distribution version
101
+
102
+ ```sh
103
+ $ npm run serve:dist
104
+ ```
105
+
106
+ This will use `lite-server` for servign your already
107
+ generated distribution version of the project.
108
+
109
+ _Note_ this requires
110
+ [Building a distribution version](#building-a-distribution-version) first.
111
+
112
+ ## API
113
+
114
+ ### useBasicFetch
115
+
116
+ ```js
117
+ useBasicFetch(((url: string) = ''), ((delay: number) = 0));
118
+ ```
119
+
120
+ Supported options and result fields for the `useBasicFetch` hook are listed below.
121
+
122
+ #### Options
123
+
124
+ `url`
125
+
126
+ | Type | Default value |
127
+ | ------ | ------------- |
128
+ | string | '' |
129
+
130
+ If present, the request will be performed as soon as the component is mounted
131
+
132
+ Example:
133
+
134
+ ```tsx
135
+ const MyComponent: React.FC = () => {
136
+ const { data, error, loading } = useBasicFetch(
137
+ 'https://api.icndb.com/jokes/random'
138
+ );
139
+
140
+ if (error) {
141
+ return <p>Error</p>;
142
+ }
143
+
144
+ if (loading) {
145
+ return <p>Loading...</p>;
146
+ }
147
+
148
+ return (
149
+ <div className="App">
150
+ <h2>Chuck Norris Joke of the day</h2>
151
+ {data && data.value && <p>{data.value.joke}</p>}
152
+ </div>
153
+ );
154
+ };
155
+ ```
156
+
157
+ `delay`
158
+
159
+ | Type | Default value | Description |
160
+ | ------ | ------------- | -------------------- |
161
+ | number | 0 | Time in milliseconds |
162
+
163
+ If present, the request will be delayed by the given amount of time
164
+
165
+ Example:
166
+
167
+ ```tsx
168
+ type Joke = {
169
+ value: {
170
+ id: number;
171
+ joke: string;
172
+ };
173
+ };
174
+
175
+ const MyComponent: React.FC = () => {
176
+ const { data, error, loading } = useBasicFetch<Joke>(
177
+ 'https://api.icndb.com/jokes/random',
178
+ 2000
179
+ );
180
+
181
+ if (error) {
182
+ return <p>Error</p>;
183
+ }
184
+
185
+ if (loading) {
186
+ return <p>Loading...</p>;
187
+ }
188
+
189
+ return (
190
+ <div className="App">
191
+ <h2>Chuck Norris Joke of the day</h2>
192
+ {data && data.value && <p>{data.value.joke}</p>}
193
+ </div>
194
+ );
195
+ };
196
+ ```
197
+
198
+ ### fetchData
199
+
200
+ ```js
201
+ fetchData(url: string)
202
+ ```
203
+
204
+ Perform an asynchronous http request against a given url
205
+
206
+ ```tsx
207
+ type Joke = {
208
+ value: {
209
+ id: number;
210
+ joke: string;
211
+ };
212
+ };
213
+
214
+ const ChuckNorrisJokes: React.FC = () => {
215
+ const { data, fetchData, error, loading } = useBasicFetch<Joke>();
216
+ const [jokeId, setJokeId] = useState(1);
217
+
218
+ useEffect(() => {
219
+ fetchData(`https://api.icndb.com/jokes/${jokeId}`);
220
+ }, [jokeId, fetchData]);
221
+
222
+ const handleNext = () => setJokeId(jokeId + 1);
223
+
224
+ if (error) {
225
+ return <p>Error</p>;
226
+ }
227
+
228
+ const jokeData = data && data.value;
229
+
230
+ return (
231
+ <div className="Comments">
232
+ {loading && <p>Loading...</p>}
233
+ {!loading && jokeData && (
234
+ <div>
235
+ <p>Joke ID: {jokeData.id}</p>
236
+ <p>{jokeData.joke}</p>
237
+ </div>
238
+ )}
239
+ {!loading && jokeData && !jokeData.joke && <p>{jokeData}</p>}
240
+ <button disabled={loading} onClick={handleNext}>
241
+ Next Joke
242
+ </button>
243
+ </div>
244
+ );
245
+ };
246
+ ```
247
+
248
+ ## Contributing
249
+
250
+ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
251
+
252
+ 1. Fork it!
253
+ 2. Create your feature branch: `git checkout -b my-new-feature`
254
+ 3. Add your changes: `git add .`
255
+ 4. Commit your changes: `git commit -am 'Add some feature'`
256
+ 5. Push to the branch: `git push origin my-new-feature`
257
+ 6. Submit a pull request :sunglasses:
258
+
259
+ ## Credits
260
+
261
+ TODO: Write credits
262
+
263
+ ## Built With
264
+
265
+ - Dropwizard - Bla bla bla
266
+ - Maven - Maybe
267
+ - Atom - ergaerga
268
+ - Love
269
+
270
+ ## Versioning
271
+
272
+ We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
273
+
274
+ ## Authors
275
+
276
+ - **John Doe** - _Initial work_ - [JohnDoe](https://github.com/JohnDoe)
277
+
278
+ See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
279
+
280
+ ## License
281
+
282
+ [MIT License](https://andreasonny.mit-license.org/2019) © Andrea SonnY
@@ -0,0 +1,25 @@
1
+ "use strict";var ct=Object.defineProperty;var at=(s,n,o)=>n in s?ct(s,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):s[n]=o;var U=(s,n,o)=>(at(s,typeof n!="symbol"?n+"":n,o),o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ht=require("@inditextech/weave-sdk"),w=require("./constants-Cci7-_3r.cjs"),M=new WeakMap,$=new WeakMap,O=new WeakMap,ne=Symbol("anyProducer"),Oe=Promise.resolve(),ie=Symbol("listenerAdded"),oe=Symbol("listenerRemoved");let se=!1,de=!1;const ue=s=>typeof s=="string"||typeof s=="symbol"||typeof s=="number";function V(s){if(!ue(s))throw new TypeError("`eventName` must be a string, symbol, or number")}function ee(s){if(typeof s!="function")throw new TypeError("listener must be a function")}function z(s,n){const o=$.get(s);if(o.has(n))return o.get(n)}function Z(s,n){const o=ue(n)?n:ne,c=O.get(s);if(c.has(o))return c.get(o)}function ft(s,n,o){const c=O.get(s);if(c.has(n))for(const h of c.get(n))h.enqueue(o);if(c.has(ne)){const h=Promise.all([n,o]);for(const p of c.get(ne))p.enqueue(h)}}function Pe(s,n){n=Array.isArray(n)?n:[n];let o=!1,c=()=>{},h=[];const p={enqueue(l){h.push(l),c()},finish(){o=!0,c()}};for(const l of n){let u=Z(s,l);u||(u=new Set,O.get(s).set(l,u)),u.add(p)}return{async next(){return h?h.length===0?o?(h=void 0,this.next()):(await new Promise(l=>{c=l}),this.next()):{done:!1,value:await h.shift()}:{done:!0}},async return(l){h=void 0;for(const u of n){const y=Z(s,u);y&&(y.delete(p),y.size===0&&O.get(s).delete(u))}return c(),arguments.length>0?{done:!0,value:await l}:{done:!0}},[Symbol.asyncIterator](){return this}}}function De(s){if(s===void 0)return Me;if(!Array.isArray(s))throw new TypeError("`methodNames` must be an array of strings");for(const n of s)if(!Me.includes(n))throw typeof n!="string"?new TypeError("`methodNames` element must be a string"):new Error(`${n} is not Emittery method`);return s}const H=s=>s===ie||s===oe;function te(s,n,o){if(H(n))try{se=!0,s.emit(n,o)}finally{se=!1}}class j{static mixin(n,o){return o=De(o),c=>{if(typeof c!="function")throw new TypeError("`target` must be function");for(const l of o)if(c.prototype[l]!==void 0)throw new Error(`The property \`${l}\` already exists on \`target\``);function h(){return Object.defineProperty(this,n,{enumerable:!1,value:new j}),this[n]}Object.defineProperty(c.prototype,n,{enumerable:!1,get:h});const p=l=>function(...u){return this[n][l](...u)};for(const l of o)Object.defineProperty(c.prototype,l,{enumerable:!1,value:p(l)});return c}}static get isDebugEnabled(){var o;if(typeof((o=globalThis.process)==null?void 0:o.env)!="object")return de;const{env:n}=globalThis.process??{env:{}};return n.DEBUG==="emittery"||n.DEBUG==="*"||de}static set isDebugEnabled(n){de=n}constructor(n={}){M.set(this,new Set),$.set(this,new Map),O.set(this,new Map),O.get(this).set(ne,new Set),this.debug=n.debug??{},this.debug.enabled===void 0&&(this.debug.enabled=!1),this.debug.logger||(this.debug.logger=(o,c,h,p)=>{try{p=JSON.stringify(p)}catch{p=`Object with the following keys failed to stringify: ${Object.keys(p).join(",")}`}(typeof h=="symbol"||typeof h=="number")&&(h=h.toString());const l=new Date,u=`${l.getHours()}:${l.getMinutes()}:${l.getSeconds()}.${l.getMilliseconds()}`;console.log(`[${u}][emittery:${o}][${c}] Event Name: ${h}
2
+ data: ${p}`)})}logIfDebugEnabled(n,o,c){(j.isDebugEnabled||this.debug.enabled)&&this.debug.logger(n,this.debug.name,o,c)}on(n,o,{signal:c}={}){ee(o),n=Array.isArray(n)?n:[n];for(const p of n){V(p);let l=z(this,p);l||(l=new Set,$.get(this).set(p,l)),l.add(o),this.logIfDebugEnabled("subscribe",p,void 0),H(p)||te(this,ie,{eventName:p,listener:o})}const h=()=>{this.off(n,o),c==null||c.removeEventListener("abort",h)};return c==null||c.addEventListener("abort",h,{once:!0}),c!=null&&c.aborted&&h(),h}off(n,o){ee(o),n=Array.isArray(n)?n:[n];for(const c of n){V(c);const h=z(this,c);h&&(h.delete(o),h.size===0&&$.get(this).delete(c)),this.logIfDebugEnabled("unsubscribe",c,void 0),H(c)||te(this,oe,{eventName:c,listener:o})}}once(n){let o;const c=new Promise(h=>{o=this.on(n,p=>{o(),h(p)})});return c.off=o,c}events(n){n=Array.isArray(n)?n:[n];for(const o of n)V(o);return Pe(this,n)}async emit(n,o){if(V(n),H(n)&&!se)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emit",n,o),ft(this,n,o);const c=z(this,n)??new Set,h=M.get(this),p=[...c],l=H(n)?[]:[...h];await Oe,await Promise.all([...p.map(async u=>{if(c.has(u))return u(o)}),...l.map(async u=>{if(h.has(u))return u(n,o)})])}async emitSerial(n,o){if(V(n),H(n)&&!se)throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");this.logIfDebugEnabled("emitSerial",n,o);const c=z(this,n)??new Set,h=M.get(this),p=[...c],l=[...h];await Oe;for(const u of p)c.has(u)&&await u(o);for(const u of l)h.has(u)&&await u(n,o)}onAny(n,{signal:o}={}){ee(n),this.logIfDebugEnabled("subscribeAny",void 0,void 0),M.get(this).add(n),te(this,ie,{listener:n});const c=()=>{this.offAny(n),o==null||o.removeEventListener("abort",c)};return o==null||o.addEventListener("abort",c,{once:!0}),o!=null&&o.aborted&&c(),c}anyEvent(){return Pe(this)}offAny(n){ee(n),this.logIfDebugEnabled("unsubscribeAny",void 0,void 0),te(this,oe,{listener:n}),M.get(this).delete(n)}clearListeners(n){n=Array.isArray(n)?n:[n];for(const o of n)if(this.logIfDebugEnabled("clear",o,void 0),ue(o)){const c=z(this,o);c&&c.clear();const h=Z(this,o);if(h){for(const p of h)p.finish();h.clear()}}else{M.get(this).clear();for(const[c,h]of $.get(this).entries())h.clear(),$.get(this).delete(c);for(const[c,h]of O.get(this).entries()){for(const p of h)p.finish();h.clear(),O.get(this).delete(c)}}}listenerCount(n){var c,h,p;n=Array.isArray(n)?n:[n];let o=0;for(const l of n){if(ue(l)){o+=M.get(this).size+(((c=z(this,l))==null?void 0:c.size)??0)+(((h=Z(this,l))==null?void 0:h.size)??0)+(((p=Z(this))==null?void 0:p.size)??0);continue}l!==void 0&&V(l),o+=M.get(this).size;for(const u of $.get(this).values())o+=u.size;for(const u of O.get(this).values())o+=u.size}return o}bindMethods(n,o){if(typeof n!="object"||n===null)throw new TypeError("`target` must be an object");o=De(o);for(const c of o){if(n[c]!==void 0)throw new Error(`The property \`${c}\` already exists on \`target\``);Object.defineProperty(n,c,{enumerable:!1,value:this[c].bind(this)})}}}const Me=Object.getOwnPropertyNames(j.prototype).filter(s=>s!=="constructor");Object.defineProperty(j,"listenerAdded",{value:ie,writable:!1,enumerable:!0,configurable:!1});Object.defineProperty(j,"listenerRemoved",{value:oe,writable:!1,enumerable:!0,configurable:!1});var Ee={},ce={};ce.byteLength=dt;ce.toByteArray=wt;ce.fromByteArray=_t;var L=[],C=[],lt=typeof Uint8Array<"u"?Uint8Array:Array,ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var q=0,pt=ye.length;q<pt;++q)L[q]=ye[q],C[ye.charCodeAt(q)]=q;C[45]=62;C[95]=63;function ve(s){var n=s.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var o=s.indexOf("=");o===-1&&(o=n);var c=o===n?0:4-o%4;return[o,c]}function dt(s){var n=ve(s),o=n[0],c=n[1];return(o+c)*3/4-c}function yt(s,n,o){return(n+o)*3/4-o}function wt(s){var n,o=ve(s),c=o[0],h=o[1],p=new lt(yt(s,c,h)),l=0,u=h>0?c-4:c,y;for(y=0;y<u;y+=4)n=C[s.charCodeAt(y)]<<18|C[s.charCodeAt(y+1)]<<12|C[s.charCodeAt(y+2)]<<6|C[s.charCodeAt(y+3)],p[l++]=n>>16&255,p[l++]=n>>8&255,p[l++]=n&255;return h===2&&(n=C[s.charCodeAt(y)]<<2|C[s.charCodeAt(y+1)]>>4,p[l++]=n&255),h===1&&(n=C[s.charCodeAt(y)]<<10|C[s.charCodeAt(y+1)]<<4|C[s.charCodeAt(y+2)]>>2,p[l++]=n>>8&255,p[l++]=n&255),p}function gt(s){return L[s>>18&63]+L[s>>12&63]+L[s>>6&63]+L[s&63]}function Et(s,n,o){for(var c,h=[],p=n;p<o;p+=3)c=(s[p]<<16&16711680)+(s[p+1]<<8&65280)+(s[p+2]&255),h.push(gt(c));return h.join("")}function _t(s){for(var n,o=s.length,c=o%3,h=[],p=16383,l=0,u=o-c;l<u;l+=p)h.push(Et(s,l,l+p>u?u:l+p));return c===1?(n=s[o-1],h.push(L[n>>2]+L[n<<4&63]+"==")):c===2&&(n=(s[o-2]<<8)+s[o-1],h.push(L[n>>10]+L[n>>4&63]+L[n<<2&63]+"=")),h.join("")}var _e={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */_e.read=function(s,n,o,c,h){var p,l,u=h*8-c-1,y=(1<<u)-1,x=y>>1,I=-7,B=o?h-1:0,P=o?-1:1,F=s[n+B];for(B+=P,p=F&(1<<-I)-1,F>>=-I,I+=u;I>0;p=p*256+s[n+B],B+=P,I-=8);for(l=p&(1<<-I)-1,p>>=-I,I+=c;I>0;l=l*256+s[n+B],B+=P,I-=8);if(p===0)p=1-x;else{if(p===y)return l?NaN:(F?-1:1)*(1/0);l=l+Math.pow(2,c),p=p-x}return(F?-1:1)*l*Math.pow(2,p-c)};_e.write=function(s,n,o,c,h,p){var l,u,y,x=p*8-h-1,I=(1<<x)-1,B=I>>1,P=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,F=c?0:p-1,Y=c?1:-1,J=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(u=isNaN(n)?1:0,l=I):(l=Math.floor(Math.log(n)/Math.LN2),n*(y=Math.pow(2,-l))<1&&(l--,y*=2),l+B>=1?n+=P/y:n+=P*Math.pow(2,1-B),n*y>=2&&(l++,y/=2),l+B>=I?(u=0,l=I):l+B>=1?(u=(n*y-1)*Math.pow(2,h),l=l+B):(u=n*Math.pow(2,B-1)*Math.pow(2,h),l=0));h>=8;s[o+F]=u&255,F+=Y,u/=256,h-=8);for(l=l<<h|u,x+=h;x>0;s[o+F]=l&255,F+=Y,l/=256,x-=8);s[o+F-Y]|=J*128};/*!
3
+ * The buffer module from node.js, for the browser.
4
+ *
5
+ * @author Feross Aboukhadijeh <https://feross.org>
6
+ * @license MIT
7
+ */(function(s){const n=ce,o=_e,c=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;s.Buffer=u,s.SlowBuffer=Ne,s.INSPECT_MAX_BYTES=50;const h=2147483647;s.kMaxLength=h,u.TYPED_ARRAY_SUPPORT=p(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(r){if(r>h)throw new RangeError('The value "'+r+'" is invalid for option "size"');const e=new Uint8Array(r);return Object.setPrototypeOf(e,u.prototype),e}function u(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(r)}return y(r,e,t)}u.poolSize=8192;function y(r,e,t){if(typeof r=="string")return P(r,e);if(ArrayBuffer.isView(r))return Y(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(R(r,ArrayBuffer)||r&&R(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(R(r,SharedArrayBuffer)||r&&R(r.buffer,SharedArrayBuffer)))return J(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const i=r.valueOf&&r.valueOf();if(i!=null&&i!==r)return u.from(i,e,t);const a=je(r);if(a)return a;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return u.from(r[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}u.from=function(r,e,t){return y(r,e,t)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function x(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function I(r,e,t){return x(r),r<=0?l(r):e!==void 0?typeof t=="string"?l(r).fill(e,t):l(r).fill(e):l(r)}u.alloc=function(r,e,t){return I(r,e,t)};function B(r){return x(r),l(r<0?0:he(r)|0)}u.allocUnsafe=function(r){return B(r)},u.allocUnsafeSlow=function(r){return B(r)};function P(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const t=me(r,e)|0;let i=l(t);const a=i.write(r,e);return a!==t&&(i=i.slice(0,a)),i}function F(r){const e=r.length<0?0:he(r.length)|0,t=l(e);for(let i=0;i<e;i+=1)t[i]=r[i]&255;return t}function Y(r){if(R(r,Uint8Array)){const e=new Uint8Array(r);return J(e.buffer,e.byteOffset,e.byteLength)}return F(r)}function J(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let i;return e===void 0&&t===void 0?i=new Uint8Array(r):t===void 0?i=new Uint8Array(r,e):i=new Uint8Array(r,e,t),Object.setPrototypeOf(i,u.prototype),i}function je(r){if(u.isBuffer(r)){const e=he(r.length)|0,t=l(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||pe(r.length)?l(0):F(r);if(r.type==="Buffer"&&Array.isArray(r.data))return F(r.data)}function he(r){if(r>=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return r|0}function Ne(r){return+r!=r&&(r=0),u.alloc(+r)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(R(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),R(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let i=e.length,a=t.length;for(let f=0,d=Math.min(i,a);f<d;++f)if(e[f]!==t[f]){i=e[f],a=t[f];break}return i<a?-1:a<i?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return u.alloc(0);let i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;const a=u.allocUnsafe(t);let f=0;for(i=0;i<e.length;++i){let d=e[i];if(R(d,Uint8Array))f+d.length>a.length?(u.isBuffer(d)||(d=u.from(d)),d.copy(a,f)):Uint8Array.prototype.set.call(a,d,f);else if(u.isBuffer(d))d.copy(a,f);else throw new TypeError('"list" argument must be an Array of Buffers');f+=d.length}return a};function me(r,e){if(u.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||R(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);const t=r.length,i=arguments.length>2&&arguments[2]===!0;if(!i&&t===0)return 0;let a=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return le(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Le(r).length;default:if(a)return i?-1:le(r).length;e=(""+e).toLowerCase(),a=!0}}u.byteLength=me;function Ge(r,e,t){let i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return Ke(this,e,t);case"utf8":case"utf-8":return Be(this,e,t);case"ascii":return Ze(this,e,t);case"latin1":case"binary":return Xe(this,e,t);case"base64":return Je(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return et(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}u.prototype._isBuffer=!0;function k(r,e,t){const i=r[e];r[e]=r[t],r[t]=i}u.prototype.swap16=function(){const e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;t<e;t+=2)k(this,t,t+1);return this},u.prototype.swap32=function(){const e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e;t+=4)k(this,t,t+3),k(this,t+1,t+2);return this},u.prototype.swap64=function(){const e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let t=0;t<e;t+=8)k(this,t,t+7),k(this,t+1,t+6),k(this,t+2,t+5),k(this,t+3,t+4);return this},u.prototype.toString=function(){const e=this.length;return e===0?"":arguments.length===0?Be(this,0,e):Ge.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:u.compare(this,e)===0},u.prototype.inspect=function(){let e="";const t=s.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},c&&(u.prototype[c]=u.prototype.inspect),u.prototype.compare=function(e,t,i,a,f){if(R(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),a===void 0&&(a=0),f===void 0&&(f=this.length),t<0||i>e.length||a<0||f>this.length)throw new RangeError("out of range index");if(a>=f&&t>=i)return 0;if(a>=f)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,a>>>=0,f>>>=0,this===e)return 0;let d=f-a,g=i-t;const m=Math.min(d,g),_=this.slice(a,f),b=e.slice(t,i);for(let E=0;E<m;++E)if(_[E]!==b[E]){d=_[E],g=b[E];break}return d<g?-1:g<d?1:0};function be(r,e,t,i,a){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,pe(t)&&(t=a?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(a)return-1;t=r.length-1}else if(t<0)if(a)t=0;else return-1;if(typeof e=="string"&&(e=u.from(e,i)),u.isBuffer(e))return e.length===0?-1:xe(r,e,t,i,a);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?a?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):xe(r,[e],t,i,a);throw new TypeError("val must be string, number or Buffer")}function xe(r,e,t,i,a){let f=1,d=r.length,g=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;f=2,d/=2,g/=2,t/=2}function m(b,E){return f===1?b[E]:b.readUInt16BE(E*f)}let _;if(a){let b=-1;for(_=t;_<d;_++)if(m(r,_)===m(e,b===-1?0:_-b)){if(b===-1&&(b=_),_-b+1===g)return b*f}else b!==-1&&(_-=_-b),b=-1}else for(t+g>d&&(t=d-g),_=t;_>=0;_--){let b=!0;for(let E=0;E<g;E++)if(m(r,_+E)!==m(e,E)){b=!1;break}if(b)return _}return-1}u.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1},u.prototype.indexOf=function(e,t,i){return be(this,e,t,i,!0)},u.prototype.lastIndexOf=function(e,t,i){return be(this,e,t,i,!1)};function Ve(r,e,t,i){t=Number(t)||0;const a=r.length-t;i?(i=Number(i),i>a&&(i=a)):i=a;const f=e.length;i>f/2&&(i=f/2);let d;for(d=0;d<i;++d){const g=parseInt(e.substr(d*2,2),16);if(pe(g))return d;r[t+d]=g}return d}function ze(r,e,t,i){return K(le(e,r.length-t),r,t,i)}function qe(r,e,t,i){return K(it(e),r,t,i)}function He(r,e,t,i){return K(Le(e),r,t,i)}function Ye(r,e,t,i){return K(ot(e,r.length-t),r,t,i)}u.prototype.write=function(e,t,i,a){if(t===void 0)a="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")a=t,i=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(i)?(i=i>>>0,a===void 0&&(a="utf8")):(a=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const f=this.length-t;if((i===void 0||i>f)&&(i=f),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");let d=!1;for(;;)switch(a){case"hex":return Ve(this,e,t,i);case"utf8":case"utf-8":return ze(this,e,t,i);case"ascii":case"latin1":case"binary":return qe(this,e,t,i);case"base64":return He(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ye(this,e,t,i);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),d=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Je(r,e,t){return e===0&&t===r.length?n.fromByteArray(r):n.fromByteArray(r.slice(e,t))}function Be(r,e,t){t=Math.min(r.length,t);const i=[];let a=e;for(;a<t;){const f=r[a];let d=null,g=f>239?4:f>223?3:f>191?2:1;if(a+g<=t){let m,_,b,E;switch(g){case 1:f<128&&(d=f);break;case 2:m=r[a+1],(m&192)===128&&(E=(f&31)<<6|m&63,E>127&&(d=E));break;case 3:m=r[a+1],_=r[a+2],(m&192)===128&&(_&192)===128&&(E=(f&15)<<12|(m&63)<<6|_&63,E>2047&&(E<55296||E>57343)&&(d=E));break;case 4:m=r[a+1],_=r[a+2],b=r[a+3],(m&192)===128&&(_&192)===128&&(b&192)===128&&(E=(f&15)<<18|(m&63)<<12|(_&63)<<6|b&63,E>65535&&E<1114112&&(d=E))}}d===null?(d=65533,g=1):d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d),a+=g}return Qe(i)}const Ie=4096;function Qe(r){const e=r.length;if(e<=Ie)return String.fromCharCode.apply(String,r);let t="",i=0;for(;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=Ie));return t}function Ze(r,e,t){let i="";t=Math.min(r.length,t);for(let a=e;a<t;++a)i+=String.fromCharCode(r[a]&127);return i}function Xe(r,e,t){let i="";t=Math.min(r.length,t);for(let a=e;a<t;++a)i+=String.fromCharCode(r[a]);return i}function Ke(r,e,t){const i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);let a="";for(let f=e;f<t;++f)a+=st[r[f]];return a}function et(r,e,t){const i=r.slice(e,t);let a="";for(let f=0;f<i.length-1;f+=2)a+=String.fromCharCode(i[f]+i[f+1]*256);return a}u.prototype.slice=function(e,t){const i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);const a=this.subarray(e,t);return Object.setPrototypeOf(a,u.prototype),a};function A(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||A(e,t,this.length);let a=this[e],f=1,d=0;for(;++d<t&&(f*=256);)a+=this[e+d]*f;return a},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||A(e,t,this.length);let a=this[e+--t],f=1;for(;t>0&&(f*=256);)a+=this[e+--t]*f;return a},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e=e>>>0,t||A(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||A(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||A(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||A(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=D(function(e){e=e>>>0,G(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Q(e,this.length-8);const a=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,f=this[++e]+this[++e]*2**8+this[++e]*2**16+i*2**24;return BigInt(a)+(BigInt(f)<<BigInt(32))}),u.prototype.readBigUInt64BE=D(function(e){e=e>>>0,G(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Q(e,this.length-8);const a=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],f=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i;return(BigInt(a)<<BigInt(32))+BigInt(f)}),u.prototype.readIntLE=function(e,t,i){e=e>>>0,t=t>>>0,i||A(e,t,this.length);let a=this[e],f=1,d=0;for(;++d<t&&(f*=256);)a+=this[e+d]*f;return f*=128,a>=f&&(a-=Math.pow(2,8*t)),a},u.prototype.readIntBE=function(e,t,i){e=e>>>0,t=t>>>0,i||A(e,t,this.length);let a=t,f=1,d=this[e+--a];for(;a>0&&(f*=256);)d+=this[e+--a]*f;return f*=128,d>=f&&(d-=Math.pow(2,8*t)),d},u.prototype.readInt8=function(e,t){return e=e>>>0,t||A(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e=e>>>0,t||A(e,2,this.length);const i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i},u.prototype.readInt16BE=function(e,t){e=e>>>0,t||A(e,2,this.length);const i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i},u.prototype.readInt32LE=function(e,t){return e=e>>>0,t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e=e>>>0,t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=D(function(e){e=e>>>0,G(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Q(e,this.length-8);const a=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(i<<24);return(BigInt(a)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=D(function(e){e=e>>>0,G(e,"offset");const t=this[e],i=this[e+7];(t===void 0||i===void 0)&&Q(e,this.length-8);const a=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(a)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+i)}),u.prototype.readFloatLE=function(e,t){return e=e>>>0,t||A(e,4,this.length),o.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e=e>>>0,t||A(e,4,this.length),o.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||A(e,8,this.length),o.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||A(e,8,this.length),o.read(this,e,!1,52,8)};function T(r,e,t,i,a,f){if(!u.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>a||e<f)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,i,a){if(e=+e,t=t>>>0,i=i>>>0,!a){const g=Math.pow(2,8*i)-1;T(this,e,t,i,g,0)}let f=1,d=0;for(this[t]=e&255;++d<i&&(f*=256);)this[t+d]=e/f&255;return t+i},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,i,a){if(e=+e,t=t>>>0,i=i>>>0,!a){const g=Math.pow(2,8*i)-1;T(this,e,t,i,g,0)}let f=i-1,d=1;for(this[t+f]=e&255;--f>=0&&(d*=256);)this[t+f]=e/d&255;return t+i},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function Ue(r,e,t,i,a){Re(e,i,a,r,t,7);let f=Number(e&BigInt(4294967295));r[t++]=f,f=f>>8,r[t++]=f,f=f>>8,r[t++]=f,f=f>>8,r[t++]=f;let d=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=d,d=d>>8,r[t++]=d,d=d>>8,r[t++]=d,d=d>>8,r[t++]=d,t}function Ae(r,e,t,i,a){Re(e,i,a,r,t,7);let f=Number(e&BigInt(4294967295));r[t+7]=f,f=f>>8,r[t+6]=f,f=f>>8,r[t+5]=f,f=f>>8,r[t+4]=f;let d=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=d,d=d>>8,r[t+2]=d,d=d>>8,r[t+1]=d,d=d>>8,r[t]=d,t+8}u.prototype.writeBigUInt64LE=D(function(e,t=0){return Ue(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=D(function(e,t=0){return Ae(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(e,t,i,a){if(e=+e,t=t>>>0,!a){const m=Math.pow(2,8*i-1);T(this,e,t,i,m-1,-m)}let f=0,d=1,g=0;for(this[t]=e&255;++f<i&&(d*=256);)e<0&&g===0&&this[t+f-1]!==0&&(g=1),this[t+f]=(e/d>>0)-g&255;return t+i},u.prototype.writeIntBE=function(e,t,i,a){if(e=+e,t=t>>>0,!a){const m=Math.pow(2,8*i-1);T(this,e,t,i,m-1,-m)}let f=i-1,d=1,g=0;for(this[t+f]=e&255;--f>=0&&(d*=256);)e<0&&g===0&&this[t+f+1]!==0&&(g=1),this[t+f]=(e/d>>0)-g&255;return t+i},u.prototype.writeInt8=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t>>>0,i||T(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=D(function(e,t=0){return Ue(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=D(function(e,t=0){return Ae(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Se(r,e,t,i,a,f){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Fe(r,e,t,i,a){return e=+e,t=t>>>0,a||Se(r,e,t,4),o.write(r,e,t,i,23,4),t+4}u.prototype.writeFloatLE=function(e,t,i){return Fe(this,e,t,!0,i)},u.prototype.writeFloatBE=function(e,t,i){return Fe(this,e,t,!1,i)};function Te(r,e,t,i,a){return e=+e,t=t>>>0,a||Se(r,e,t,8),o.write(r,e,t,i,52,8),t+8}u.prototype.writeDoubleLE=function(e,t,i){return Te(this,e,t,!0,i)},u.prototype.writeDoubleBE=function(e,t,i){return Te(this,e,t,!1,i)},u.prototype.copy=function(e,t,i,a){if(!u.isBuffer(e))throw new TypeError("argument should be a Buffer");if(i||(i=0),!a&&a!==0&&(a=this.length),t>=e.length&&(t=e.length),t||(t=0),a>0&&a<i&&(a=i),a===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-i&&(a=e.length-t+i);const f=a-i;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,i,a):Uint8Array.prototype.set.call(e,this.subarray(i,a),t),f},u.prototype.fill=function(e,t,i,a){if(typeof e=="string"){if(typeof t=="string"?(a=t,t=0,i=this.length):typeof i=="string"&&(a=i,i=this.length),a!==void 0&&typeof a!="string")throw new TypeError("encoding must be a string");if(typeof a=="string"&&!u.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(e.length===1){const d=e.charCodeAt(0);(a==="utf8"&&d<128||a==="latin1")&&(e=d)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);let f;if(typeof e=="number")for(f=t;f<i;++f)this[f]=e;else{const d=u.isBuffer(e)?e:u.from(e,a),g=d.length;if(g===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(f=0;f<i-t;++f)this[f+t]=d[f%g]}return this};const N={};function fe(r,e,t){N[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(a){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:a,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}fe("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),fe("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError),fe("ERR_OUT_OF_RANGE",function(r,e,t){let i=`The value of "${r}" is out of range.`,a=t;return Number.isInteger(t)&&Math.abs(t)>2**32?a=Ce(String(t)):typeof t=="bigint"&&(a=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(a=Ce(a)),a+="n"),i+=` It must be ${e}. Received ${a}`,i},RangeError);function Ce(r){let e="",t=r.length;const i=r[0]==="-"?1:0;for(;t>=i+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function tt(r,e,t){G(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Q(e,r.length-(t+1))}function Re(r,e,t,i,a,f){if(r>t||r<e){const d=typeof e=="bigint"?"n":"";let g;throw e===0||e===BigInt(0)?g=`>= 0${d} and < 2${d} ** ${(f+1)*8}${d}`:g=`>= -(2${d} ** ${(f+1)*8-1}${d}) and < 2 ** ${(f+1)*8-1}${d}`,new N.ERR_OUT_OF_RANGE("value",g,r)}tt(i,a,f)}function G(r,e){if(typeof r!="number")throw new N.ERR_INVALID_ARG_TYPE(e,"number",r)}function Q(r,e,t){throw Math.floor(r)!==r?(G(r,t),new N.ERR_OUT_OF_RANGE("offset","an integer",r)):e<0?new N.ERR_BUFFER_OUT_OF_BOUNDS:new N.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,r)}const rt=/[^+/0-9A-Za-z-_]/g;function nt(r){if(r=r.split("=")[0],r=r.trim().replace(rt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function le(r,e){e=e||1/0;let t;const i=r.length;let a=null;const f=[];for(let d=0;d<i;++d){if(t=r.charCodeAt(d),t>55295&&t<57344){if(!a){if(t>56319){(e-=3)>-1&&f.push(239,191,189);continue}else if(d+1===i){(e-=3)>-1&&f.push(239,191,189);continue}a=t;continue}if(t<56320){(e-=3)>-1&&f.push(239,191,189),a=t;continue}t=(a-55296<<10|t-56320)+65536}else a&&(e-=3)>-1&&f.push(239,191,189);if(a=null,t<128){if((e-=1)<0)break;f.push(t)}else if(t<2048){if((e-=2)<0)break;f.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;f.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;f.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return f}function it(r){const e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function ot(r,e){let t,i,a;const f=[];for(let d=0;d<r.length&&!((e-=2)<0);++d)t=r.charCodeAt(d),i=t>>8,a=t%256,f.push(a),f.push(i);return f}function Le(r){return n.toByteArray(nt(r))}function K(r,e,t,i){let a;for(a=0;a<i&&!(a+t>=e.length||a>=r.length);++a)e[a+t]=r[a];return a}function R(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function pe(r){return r!==r}const st=function(){const r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){const i=t*16;for(let a=0;a<16;++a)e[i+a]=r[t]+r[a]}return e}();function D(r){return typeof BigInt>"u"?ut:r}function ut(){throw new Error("BigInt not supported")}})(Ee);const S=[];for(let s=0;s<256;++s)S.push((s+256).toString(16).slice(1));function mt(s,n=0){return(S[s[n+0]]+S[s[n+1]]+S[s[n+2]]+S[s[n+3]]+"-"+S[s[n+4]]+S[s[n+5]]+"-"+S[s[n+6]]+S[s[n+7]]+"-"+S[s[n+8]]+S[s[n+9]]+"-"+S[s[n+10]]+S[s[n+11]]+S[s[n+12]]+S[s[n+13]]+S[s[n+14]]+S[s[n+15]]).toLowerCase()}let we;const bt=new Uint8Array(16);function xt(){if(!we){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");we=crypto.getRandomValues.bind(crypto)}return we(bt)}const Bt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ke={randomUUID:Bt};function It(s,n,o){var h;if(ke.randomUUID&&!s)return ke.randomUUID();s=s||{};const c=s.random??((h=s.rng)==null?void 0:h.call(s))??xt();if(c.length<16)throw new Error("Random bytes length must be >= 16");return c[6]=c[6]&15|64,c[8]=c[8]&63|128,mt(c)}/*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation. All rights reserved.
9
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10
+ this file except in compliance with the License. You may obtain a copy of the
11
+ License at http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16
+ MERCHANTABLITY OR NON-INFRINGEMENT.
17
+
18
+ See the Apache Version 2.0 License for specific language governing permissions
19
+ and limitations under the License.
20
+ ***************************************************************************** */var ge=function(s,n){return ge=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,c){o.__proto__=c}||function(o,c){for(var h in c)c.hasOwnProperty(h)&&(o[h]=c[h])},ge(s,n)};function We(s,n){ge(s,n);function o(){this.constructor=s}s.prototype=n===null?Object.create(n):(o.prototype=n.prototype,new o)}function Ut(s){var n=typeof Symbol=="function"&&s[Symbol.iterator],o=0;return n?n.call(s):{next:function(){return s&&o>=s.length&&(s=void 0),{value:s&&s[o++],done:!s}}}}function At(s,n){var o=typeof Symbol=="function"&&s[Symbol.iterator];if(!o)return s;var c=o.call(s),h,p=[],l;try{for(;(n===void 0||n-- >0)&&!(h=c.next()).done;)p.push(h.value)}catch(u){l={error:u}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(l)throw l.error}}return p}function St(){for(var s=[],n=0;n<arguments.length;n++)s=s.concat(At(arguments[n]));return s}var $e=function(){function s(n,o){this.target=o,this.type=n}return s}(),Ft=function(s){We(n,s);function n(o,c){var h=s.call(this,"error",c)||this;return h.message=o.message,h.error=o,h}return n}($e),Tt=function(s){We(n,s);function n(o,c,h){o===void 0&&(o=1e3),c===void 0&&(c="");var p=s.call(this,"close",h)||this;return p.wasClean=!0,p.code=o,p.reason=c,p}return n}($e);/*!
21
+ * Reconnecting WebSocket
22
+ * by Pedro Ladaria <pedro.ladaria@gmail.com>
23
+ * https://github.com/pladaria/reconnecting-websocket
24
+ * License MIT
25
+ */var Ct=function(){if(typeof WebSocket<"u")return WebSocket},Rt=function(s){return typeof s<"u"&&!!s&&s.CLOSING===2},v={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},Lt=function(){function s(n,o,c){var h=this;c===void 0&&(c={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(p){h._debug("open event");var l=h._options.minUptime,u=l===void 0?v.minUptime:l;clearTimeout(h._connectTimeout),h._uptimeTimeout=setTimeout(function(){return h._acceptOpen()},u),h._ws.binaryType=h._binaryType,h._messageQueue.forEach(function(y){return h._ws.send(y)}),h._messageQueue=[],h.onopen&&h.onopen(p),h._listeners.open.forEach(function(y){return h._callEventListener(p,y)})},this._handleMessage=function(p){h._debug("message event"),h.onmessage&&h.onmessage(p),h._listeners.message.forEach(function(l){return h._callEventListener(p,l)})},this._handleError=function(p){h._debug("error event",p.message),h._disconnect(void 0,p.message==="TIMEOUT"?"timeout":void 0),h.onerror&&h.onerror(p),h._debug("exec error listeners"),h._listeners.error.forEach(function(l){return h._callEventListener(p,l)}),h._connect()},this._handleClose=function(p){h._debug("close event"),h._clearTimeouts(),h._shouldReconnect&&h._connect(),h.onclose&&h.onclose(p),h._listeners.close.forEach(function(l){return h._callEventListener(p,l)})},this._url=n,this._protocols=o,this._options=c,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(s,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(s,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(s,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(s,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"CONNECTING",{get:function(){return s.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"OPEN",{get:function(){return s.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"CLOSING",{get:function(){return s.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"CLOSED",{get:function(){return s.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(n){this._binaryType=n,this._ws&&(this._ws.binaryType=n)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"bufferedAmount",{get:function(){var n=this._messageQueue.reduce(function(o,c){return typeof c=="string"?o+=c.length:c instanceof Blob?o+=c.size:o+=c.byteLength,o},0);return n+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?s.CLOSED:s.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),s.prototype.close=function(n,o){if(n===void 0&&(n=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(n,o)},s.prototype.reconnect=function(n,o){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(n,o),this._connect())},s.prototype.send=function(n){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",n),this._ws.send(n);else{var o=this._options.maxEnqueuedMessages,c=o===void 0?v.maxEnqueuedMessages:o;this._messageQueue.length<c&&(this._debug("enqueue",n),this._messageQueue.push(n))}},s.prototype.addEventListener=function(n,o){this._listeners[n]&&this._listeners[n].push(o)},s.prototype.dispatchEvent=function(n){var o,c,h=this._listeners[n.type];if(h)try{for(var p=Ut(h),l=p.next();!l.done;l=p.next()){var u=l.value;this._callEventListener(n,u)}}catch(y){o={error:y}}finally{try{l&&!l.done&&(c=p.return)&&c.call(p)}finally{if(o)throw o.error}}return!0},s.prototype.removeEventListener=function(n,o){this._listeners[n]&&(this._listeners[n]=this._listeners[n].filter(function(c){return c!==o}))},s.prototype._debug=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];this._options.debug&&console.log.apply(console,St(["RWS>"],n))},s.prototype._getNextDelay=function(){var n=this._options,o=n.reconnectionDelayGrowFactor,c=o===void 0?v.reconnectionDelayGrowFactor:o,h=n.minReconnectionDelay,p=h===void 0?v.minReconnectionDelay:h,l=n.maxReconnectionDelay,u=l===void 0?v.maxReconnectionDelay:l,y=0;return this._retryCount>0&&(y=p*Math.pow(c,this._retryCount-1),y>u&&(y=u)),this._debug("next delay",y),y},s.prototype._wait=function(){var n=this;return new Promise(function(o){setTimeout(o,n._getNextDelay())})},s.prototype._getNextUrl=function(n){if(typeof n=="string")return Promise.resolve(n);if(typeof n=="function"){var o=n();if(typeof o=="string")return Promise.resolve(o);if(o.then)return o}throw Error("Invalid URL")},s.prototype._connect=function(){var n=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var o=this._options,c=o.maxRetries,h=c===void 0?v.maxRetries:c,p=o.connectionTimeout,l=p===void 0?v.connectionTimeout:p,u=o.WebSocket,y=u===void 0?Ct():u;if(this._retryCount>=h){this._debug("max retries reached",this._retryCount,">=",h);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!Rt(y))throw Error("No valid WebSocket class provided");this._wait().then(function(){return n._getNextUrl(n._url)}).then(function(x){n._closeCalled||(n._debug("connect",{url:x,protocols:n._protocols}),n._ws=n._protocols?new y(x,n._protocols):new y(x),n._ws.binaryType=n._binaryType,n._connectLock=!1,n._addListeners(),n._connectTimeout=setTimeout(function(){return n._handleTimeout()},l))})}},s.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new Ft(Error("TIMEOUT"),this))},s.prototype._disconnect=function(n,o){if(n===void 0&&(n=1e3),this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(n,o),this._handleClose(new Tt(n,o,this))}catch{}}},s.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},s.prototype._callEventListener=function(n,o){"handleEvent"in o?o.handleEvent(n):o(n)},s.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},s.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},s.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},s}();const re=0,X=1,Ot=3,Pt="json.webpubsub.azure.v1",ae=[];ae[re]=(s,n,o,c,h)=>{w.writeVarUint(s,h);const p=w.readSyncMessage(n,s,o.doc,o);c&&p===w.messageYjsSyncStep2&&!o.synced&&(o.synced=!0)};ae[Ot]=(s,n,o)=>{w.writeVarUint(s,X),w.writeVarUint8Array(s,w.encodeAwarenessUpdate(o.awareness,Array.from(o.awareness.getStates().keys())))};ae[X]=(s,n,o)=>{w.applyAwarenessUpdate(o.awareness,w.readVarUint8Array(n),o)};const Dt=(s,n,o)=>{const c=w.createDecoder(n),h=w.createEncoder(),p=w.readVarUint(c),l=ae[p];if(l)l(h,c,s,o,p);else throw new Error(`unable to handle message with type: ${p}`);return h};class Mt extends j{constructor(o,c,h,p={resyncInterval:15*1e3,tokenProvider:null}){super();U(this,"doc");U(this,"topic");U(this,"_ws");U(this,"_url");U(this,"_connectionUrl");U(this,"_status");U(this,"_wsConnected");U(this,"_synced");U(this,"_resyncInterval");U(this,"_uuid");U(this,"_awareness");U(this,"_updateHandler");U(this,"_awarenessUpdateHandler");this.doc=h,this.topic=c,this._url=o,this._connectionUrl=null,this._uuid=It(),this._status="disconnected",this._wsConnected=!1,this._synced=!1,this._ws=null;const l=new w.Awareness(h);this._awareness=l,this._resyncInterval=null,p.resyncInterval>0&&(this._resyncInterval=setInterval(()=>{if(this._ws){const u=w.createEncoder();w.writeVarUint(u,re),w.writeSyncStep1(u,h),W(this,c,"sync",w.toUint8Array(u))}},p.resyncInterval)),this._updateHandler=(u,y)=>{if(y!==this){const x=w.createEncoder();w.writeVarUint(x,re),w.writeUpdate(x,u),W(this,c,"sync",w.toUint8Array(x))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:u,updated:y,removed:x})=>{const I=u.concat(y).concat(x),B=w.createEncoder();w.writeVarUint(B,X),w.writeVarUint8Array(B,w.encodeAwarenessUpdate(l,I)),W(this,c,"awareness",w.toUint8Array(B))},l.on("update",this._awarenessUpdateHandler)}get awareness(){return this._awareness}get synced(){return this._synced}set synced(o){this._synced!==o&&(this._synced=o)}get ws(){return this._wsConnected?this._ws:null}get id(){return this._uuid}destroy(){this._resyncInterval!==null&&clearInterval(this._resyncInterval),this.stop(),this.doc.off("update",this._updateHandler)}stop(){if(this._ws!==null){const o=w.createEncoder();w.writeVarUint(o,X),w.writeVarUint8Array(o,w.encodeAwarenessUpdate(this.awareness,[this.doc.clientID],new Map));const c=w.toUint8Array(o);W(this,this.topic,"awareness",c),this._ws.close()}}async fetchConnectionUrl(o=fetch){try{const c=await o(this._url);if(c.ok){const h=await c.json();this._connectionUrl=h.url}else throw new Error(`Failed to fetch connection url from: ${this._url}`)}catch{throw new Error(`Failed to fetch connection url from: ${this._url}`)}}async start(){if(this._wsConnected||this._ws||!this._connectionUrl)return;const o=new Lt(this._connectionUrl,Pt);o.binaryType="arraybuffer",this._ws=o,this._wsConnected=!1,this.synced=!1,this._status="connecting",this.emit("status",this._status),o.onmessage=c=>{if(c.data===null)return;const h=JSON.parse(c.data.toString());if(h.type==="system")return;const p=h.data;if(p.t!==void 0&&p.t!==this._uuid)return;const l=Ee.Buffer.from(p.c,"base64"),u=Dt(this,l,!0);w.length(u)>1&&W(this,this.topic,"sync",w.toUint8Array(u))},o.onclose=()=>{this._ws=null,this._wsConnected&&(this._status="disconnected",this.emit("status",this._status),this._wsConnected=!1,this.synced=!1,w.removeAwarenessStates(this.awareness,Array.from(this.awareness.getStates().keys()).filter(c=>c!==this.doc.clientID),this))},o.onerror=c=>{console.error(c)},o.onopen=()=>{this._wsConnected=!0,this._status="connected",this.emit("status",this._status),kt(this,this.topic);const c=w.createEncoder();w.writeVarUint(c,re),w.writeSyncStep1(c,this.doc);const h=w.toUint8Array(c);if(W(this,this.topic,"init",h),this.awareness.getLocalState()!==null){const p=w.createEncoder();w.writeVarUint(p,X),w.writeVarUint8Array(p,w.encodeAwarenessUpdate(this.awareness,[this.doc.clientID]));const l=w.toUint8Array(c);W(this,this.topic,"awareness",l)}}}}function kt(s,n){var o;(o=s.ws)==null||o.send(JSON.stringify({type:"joinGroup",group:n}))}function W(s,n,o,c){var h;(h=s.ws)==null||h.send(JSON.stringify({type:"sendToGroup",group:`${n}.host`,data:{t:o,f:s.id,c:Ee.Buffer.from(c).toString("base64")}}))}class vt extends ht.WeaveStore{constructor(o,c){super(o);U(this,"azureWebPubsubOptions");U(this,"roomId");U(this,"provider");U(this,"name",w.WEAVE_STORE_AZURE_WEB_PUBSUB);U(this,"supportsUndoManager",!0);const{roomId:h}=c;this.azureWebPubsubOptions=c,this.roomId=h,this.init()}init(){const{url:o}=this.azureWebPubsubOptions;this.provider=new Mt(o,this.roomId,this.getDocument(),{resyncInterval:1e3,tokenProvider:null}),this.provider.on("status",c=>{var h,p;(p=(h=this.azureWebPubsubOptions.callbacks)==null?void 0:h.onConnectionStatusChange)==null||p.call(h,c),this.instance.emitEvent("onConnectionStatusChange",c)})}async connect(){var h,p,l,u;const{fetchClient:o}=this.azureWebPubsubOptions;let c=null;try{(p=(h=this.azureWebPubsubOptions.callbacks)==null?void 0:h.onFetchConnectionUrl)==null||p.call(h,{loading:!0,error:null}),this.instance.emitEvent("onFetchConnectionUrl",{loading:!0,error:null}),await this.provider.fetchConnectionUrl(o??fetch)}catch(y){c=y}finally{(u=(l=this.azureWebPubsubOptions.callbacks)==null?void 0:l.onFetchConnectionUrl)==null||u.call(l,{loading:!1,error:c}),this.instance.emitEvent("onFetchConnectionUrl",{loading:!1,error:c})}await this.provider.start()}async disconnect(){this.provider.destroy()}setAwarenessInfo(o,c){this.provider.awareness.setLocalStateField(o,c)}onAwarenessChange(o){const c=this.provider.awareness;c.on("change",()=>{const h=Array.from(c.getStates().values());h.splice(c.clientID,1),o(h)})}}exports.WEAVE_STORE_AZURE_WEB_PUBSUB=w.WEAVE_STORE_AZURE_WEB_PUBSUB;exports.WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS=w.WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS;exports.WeaveStoreAzureWebPubsub=vt;
Binary file
@@ -0,0 +1,102 @@
1
+ import * as awarenessProtocol from 'y-protocols/awareness';
2
+ import { default as default_2 } from 'emittery';
3
+ import { default as default_3 } from 'reconnecting-websocket';
4
+ import { Doc } from 'yjs';
5
+ import { WeaveAwarenessChange } from '@inditextech/weave-types';
6
+ import { WeaveStore } from '@inditextech/weave-sdk';
7
+ import { WeaveStoreOptions } from '@inditextech/weave-types';
8
+ import * as Y from 'yjs';
9
+
10
+ declare interface ClientOptions {
11
+ resyncInterval: number;
12
+ tokenProvider: Promise<string> | null;
13
+ }
14
+
15
+ export declare type FetchClient = (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
16
+
17
+ export declare type FetchInitialState = (doc: Y.Doc) => void;
18
+
19
+ export declare type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
20
+
21
+ export declare type PersistRoom = (roomId: string, actualState: Uint8Array<ArrayBufferLike>) => Promise<void>;
22
+
23
+ export declare const WEAVE_STORE_AZURE_WEB_PUBSUB = "store-azure-web-pubsub";
24
+
25
+ export declare const WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS: {
26
+ readonly CONNECTED: "connected";
27
+ readonly DISCONNECTED: "disconnected";
28
+ };
29
+
30
+ export declare type WeaveAzureWebPubsubConfig = {
31
+ endpoint: string;
32
+ key: string;
33
+ hubName: string;
34
+ };
35
+
36
+ export declare class WeaveStoreAzureWebPubsub extends WeaveStore {
37
+ private azureWebPubsubOptions;
38
+ private roomId;
39
+ protected provider: WeaveStoreAzureWebPubSubSyncClient;
40
+ protected name: string;
41
+ protected supportsUndoManager: boolean;
42
+ constructor(storeOptions: WeaveStoreOptions, azureWebPubsubOptions: WeaveStoreAzureWebPubsubOptions);
43
+ private init;
44
+ connect(): Promise<void>;
45
+ disconnect(): Promise<void>;
46
+ setAwarenessInfo(field: string, value: unknown): void;
47
+ onAwarenessChange<K extends string, T>(callback: (changes: WeaveAwarenessChange<K, T>[]) => void): void;
48
+ }
49
+
50
+ export declare type WeaveStoreAzureWebPubsubConnectionStatus = (typeof WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS)[WeaveStoreAzureWebPubsubConnectionStatusKeys];
51
+
52
+ export declare type WeaveStoreAzureWebPubsubConnectionStatusKeys = keyof typeof WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS;
53
+
54
+ export declare type WeaveStoreAzureWebPubsubOptions = {
55
+ roomId: string;
56
+ url: string;
57
+ fetchClient?: FetchClient;
58
+ callbacks?: WeaveStoreAzureWebPubsubStoreCallbacks;
59
+ };
60
+
61
+ export declare type WeaveStoreAzureWebPubsubStoreCallbacks = {
62
+ onFetchConnectionUrl?: (payload: {
63
+ loading: boolean;
64
+ error: Error | null;
65
+ }) => void;
66
+ onConnectionStatusChange?: (status: WeaveStoreAzureWebPubsubConnectionStatus) => void;
67
+ };
68
+
69
+ declare class WeaveStoreAzureWebPubSubSyncClient extends default_2 {
70
+ doc: Doc;
71
+ topic: string;
72
+ private _ws;
73
+ private _url;
74
+ private _connectionUrl;
75
+ private _status;
76
+ private _wsConnected;
77
+ private _synced;
78
+ private _resyncInterval;
79
+ private _uuid;
80
+ private _awareness;
81
+ private _updateHandler;
82
+ private _awarenessUpdateHandler;
83
+ /**
84
+ * @param {string} url
85
+ * @param {string} topic
86
+ * @param {Doc} doc
87
+ * @param {number} [options.resyncInterval] Request server state every `resyncInterval` milliseconds.
88
+ * @param {number} [options.tokenProvider] token generator for negotiation.
89
+ */
90
+ constructor(url: string, topic: string, doc: Doc, options?: ClientOptions);
91
+ get awareness(): awarenessProtocol.Awareness;
92
+ get synced(): boolean;
93
+ set synced(state: boolean);
94
+ get ws(): default_3 | null;
95
+ get id(): string;
96
+ destroy(): void;
97
+ stop(): void;
98
+ fetchConnectionUrl(fetchClient?: FetchClient): Promise<void>;
99
+ start(): Promise<void>;
100
+ }
101
+
102
+ export { }