bhd-components 0.10.23 → 0.10.24

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,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { version as version$4, isValidElement as isValidElement$1, useContext as useContext$1, createContext as createContext$1, useState, useMemo as useMemo$1, useRef, useEffect, useLayoutEffect as useLayoutEffect$2, forwardRef, createRef, useCallback, useImperativeHandle, memo, Children, cloneElement as cloneElement$1, Component, PureComponent, createElement as createElement$2 } from 'react';
2
+ import React__default, { version as version$4, isValidElement as isValidElement$1, useContext as useContext$1, createContext as createContext$1, useState, useMemo as useMemo$1, useRef, useEffect, useLayoutEffect as useLayoutEffect$2, forwardRef, createRef, useCallback, useImperativeHandle, memo, Children, cloneElement as cloneElement$1, Component, createElement as createElement$2, PureComponent } from 'react';
3
3
  import * as ReactDOM from 'react-dom';
4
4
  import ReactDOM__default, { unstable_batchedUpdates, createPortal, flushSync } from 'react-dom';
5
5
  import { jsx as jsx$1, jsxs as jsxs$1 } from 'react/jsx-runtime';
@@ -101160,406 +101160,1605 @@ $$6({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
101160
101160
  }
101161
101161
  });
101162
101162
 
101163
- var call$2 = functionCall;
101164
- var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic;
101165
- var anObject$1 = anObject$l;
101166
- var isNullOrUndefined$1 = isNullOrUndefined$b;
101167
- var toLength$2 = toLength$a;
101168
- var toString$3 = toString$n;
101169
- var requireObjectCoercible$3 = requireObjectCoercible$f;
101170
- var getMethod$1 = getMethod$8;
101171
- var advanceStringIndex$1 = advanceStringIndex$3;
101172
- var regExpExec$1 = regexpExecAbstract;
101163
+ var PUBLISH = 0;
101164
+ var SUBSCRIBE = 1;
101165
+ var RESET = 2;
101166
+ var VALUE = 4;
101173
101167
 
101174
- // @@match logic
101175
- fixRegExpWellKnownSymbolLogic$1('match', function (MATCH, nativeMatch, maybeCallNative) {
101176
- return [
101177
- // `String.prototype.match` method
101178
- // https://tc39.es/ecma262/#sec-string.prototype.match
101179
- function match(regexp) {
101180
- var O = requireObjectCoercible$3(this);
101181
- var matcher = isNullOrUndefined$1(regexp) ? undefined : getMethod$1(regexp, MATCH);
101182
- return matcher ? call$2(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$3(O));
101183
- },
101184
- // `RegExp.prototype[@@match]` method
101185
- // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
101186
- function (string) {
101187
- var rx = anObject$1(this);
101188
- var S = toString$3(string);
101189
- var res = maybeCallNative(nativeMatch, rx, S);
101168
+ /**
101169
+ * Utils includes
101170
+ * - a handful of functional utilities inspired by or taken from the [Ramda library](https://ramdajs.com/);
101171
+ * - TypeScript crutches - the [[tup]] function.
101172
+ *
101173
+ * Use these for your convenience - they are here so that urx is zero-dependency package.
101174
+ *
101175
+ * @packageDocumentation
101176
+ */
101190
101177
 
101191
- if (res.done) return res.value;
101178
+ /**
101179
+ * Performs left to right composition of two functions.
101180
+ */
101181
+ function compose(a, b) {
101182
+ return function (arg) {
101183
+ return a(b(arg));
101184
+ };
101185
+ }
101186
+ /**
101187
+ * Takes a value and applies a function to it.
101188
+ */
101192
101189
 
101193
- if (!rx.global) return regExpExec$1(rx, S);
101190
+ function thrush(arg, proc) {
101191
+ return proc(arg);
101192
+ }
101193
+ /**
101194
+ * Takes a 2 argument function and partially applies the first argument.
101195
+ */
101194
101196
 
101195
- var fullUnicode = rx.unicode;
101196
- rx.lastIndex = 0;
101197
- var A = [];
101198
- var n = 0;
101199
- var result;
101200
- while ((result = regExpExec$1(rx, S)) !== null) {
101201
- var matchStr = toString$3(result[0]);
101202
- A[n] = matchStr;
101203
- if (matchStr === '') rx.lastIndex = advanceStringIndex$1(S, toLength$2(rx.lastIndex), fullUnicode);
101204
- n++;
101205
- }
101206
- return n === 0 ? null : A;
101207
- }
101208
- ];
101209
- });
101197
+ function curry2to1(proc, arg1) {
101198
+ return function (arg2) {
101199
+ return proc(arg1, arg2);
101200
+ };
101201
+ }
101202
+ /**
101203
+ * Takes a 1 argument function and returns a function which when called, executes it with the provided argument.
101204
+ */
101210
101205
 
101211
- var toIntegerOrInfinity = toIntegerOrInfinity$c;
101212
- var toString$2 = toString$n;
101213
- var requireObjectCoercible$2 = requireObjectCoercible$f;
101206
+ function curry1to0(proc, arg) {
101207
+ return function () {
101208
+ return proc(arg);
101209
+ };
101210
+ }
101211
+ /**
101212
+ * Calls callback with the first argument, and returns it.
101213
+ */
101214
101214
 
101215
- var $RangeError = RangeError;
101215
+ function tap(arg, proc) {
101216
+ proc(arg);
101217
+ return arg;
101218
+ }
101219
+ /**
101220
+ * Utility function to help typescript figure out that what we pass is a tuple and not a generic array.
101221
+ * Taken from (this StackOverflow tread)[https://stackoverflow.com/questions/49729550/implicitly-create-a-tuple-in-typescript/52445008#52445008]
101222
+ */
101216
101223
 
101217
- // `String.prototype.repeat` method implementation
101218
- // https://tc39.es/ecma262/#sec-string.prototype.repeat
101219
- var stringRepeat = function repeat(count) {
101220
- var str = toString$2(requireObjectCoercible$2(this));
101221
- var result = '';
101222
- var n = toIntegerOrInfinity(count);
101223
- if (n < 0 || n === Infinity) throw new $RangeError('Wrong number of repetitions');
101224
- for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
101225
- return result;
101226
- };
101224
+ function tup() {
101225
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
101226
+ args[_key] = arguments[_key];
101227
+ }
101227
101228
 
101228
- // https://github.com/tc39/proposal-string-pad-start-end
101229
- var uncurryThis$3 = functionUncurryThis;
101230
- var toLength$1 = toLength$a;
101231
- var toString$1 = toString$n;
101232
- var $repeat = stringRepeat;
101233
- var requireObjectCoercible$1 = requireObjectCoercible$f;
101229
+ return args;
101230
+ }
101231
+ /**
101232
+ * Calls the passed function.
101233
+ */
101234
101234
 
101235
- var repeat = uncurryThis$3($repeat);
101236
- var stringSlice$2 = uncurryThis$3(''.slice);
101237
- var ceil = Math.ceil;
101235
+ function call$2(proc) {
101236
+ proc();
101237
+ }
101238
+ /**
101239
+ * returns a function which when called always returns the passed value
101240
+ */
101238
101241
 
101239
- // `String.prototype.{ padStart, padEnd }` methods implementation
101240
- var createMethod = function (IS_END) {
101241
- return function ($this, maxLength, fillString) {
101242
- var S = toString$1(requireObjectCoercible$1($this));
101243
- var intMaxLength = toLength$1(maxLength);
101244
- var stringLength = S.length;
101245
- var fillStr = fillString === undefined ? ' ' : toString$1(fillString);
101246
- var fillLen, stringFiller;
101247
- if (intMaxLength <= stringLength || fillStr === '') return S;
101248
- fillLen = intMaxLength - stringLength;
101249
- stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length));
101250
- if (stringFiller.length > fillLen) stringFiller = stringSlice$2(stringFiller, 0, fillLen);
101251
- return IS_END ? S + stringFiller : stringFiller + S;
101242
+ function always(value) {
101243
+ return function () {
101244
+ return value;
101252
101245
  };
101253
- };
101246
+ }
101247
+ /**
101248
+ * returns a function which calls all passed functions in the passed order.
101249
+ * joinProc does not pass arguments or collect return values.
101250
+ */
101254
101251
 
101255
- var stringPad = {
101256
- // `String.prototype.padStart` method
101257
- // https://tc39.es/ecma262/#sec-string.prototype.padstart
101258
- start: createMethod(false),
101259
- // `String.prototype.padEnd` method
101260
- // https://tc39.es/ecma262/#sec-string.prototype.padend
101261
- end: createMethod(true)
101262
- };
101252
+ function joinProc() {
101253
+ for (var _len2 = arguments.length, procs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
101254
+ procs[_key2] = arguments[_key2];
101255
+ }
101263
101256
 
101264
- // https://github.com/zloirock/core-js/issues/280
101265
- var userAgent = environmentUserAgent;
101257
+ return function () {
101258
+ procs.map(call$2);
101259
+ };
101260
+ }
101261
+ function noop() {}
101266
101262
 
101267
- var stringPadWebkitBug = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent);
101263
+ /**
101264
+ * urx Actions operate on streams - `publish` publishes data in a stream, and `subscribe` attaches a subscription to a stream.
101265
+ * @packageDocumentation
101266
+ */
101267
+ /**
101268
+ * Subscribes the specified [[Subscription]] to the updates from the Emitter.
101269
+ * The emitter calls the subscription with the new data each time new data is published into it.
101270
+ *
101271
+ * ```ts
101272
+ * const foo = stream<number>();
101273
+ * subscribe(foo, (value) => console.log(value));
101274
+ * ```
101275
+ *
101276
+ * @returns an [[Unsubscribe]] handle - calling it will unbind the subscription from the emitter.
101277
+ *```ts
101278
+ * const foo = stream<number>();
101279
+ * const unsub = subscribe(foo, (value) => console.log(value));
101280
+ * unsub();
101281
+ *```
101282
+ */
101268
101283
 
101269
- var $$5 = _export;
101270
- var $padStart = stringPad.start;
101271
- var WEBKIT_BUG = stringPadWebkitBug;
101284
+ function subscribe(emitter, subscription) {
101285
+ return emitter(SUBSCRIBE, subscription);
101286
+ }
101287
+ /**
101288
+ * Publishes the value into the passed [[Publisher]].
101289
+ *
101290
+ * ```ts
101291
+ * const foo = stream<number>();
101292
+ * publish(foo, 42);
101293
+ * ```
101294
+ */
101272
101295
 
101273
- // `String.prototype.padStart` method
101274
- // https://tc39.es/ecma262/#sec-string.prototype.padstart
101275
- $$5({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
101276
- padStart: function padStart(maxLength /* , fillString = ' ' */) {
101277
- return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
101278
- }
101279
- });
101296
+ function publish(publisher, value) {
101297
+ publisher(PUBLISH, value);
101298
+ }
101299
+ /**
101300
+ * Clears all subscriptions from the [[Emitter]].
101301
+ * ```ts
101302
+ * const foo = stream<number>();
101303
+ * subscribe(foo, (value) => console.log(value));
101304
+ * reset(foo);
101305
+ * publish(foo, 42);
101306
+ * ```
101307
+ */
101280
101308
 
101281
- var $$4 = _export;
101282
- var lastIndexOf = arrayLastIndexOf;
101309
+ function reset(emitter) {
101310
+ emitter(RESET);
101311
+ }
101312
+ /**
101313
+ * Extracts the current value from a stateful stream. Use it only as an escape hatch, as it violates the concept of reactive programming.
101314
+ * ```ts
101315
+ * const foo = statefulStream(42);
101316
+ * console.log(getValue(foo));
101317
+ * ```
101318
+ */
101283
101319
 
101284
- // `Array.prototype.lastIndexOf` method
101285
- // https://tc39.es/ecma262/#sec-array.prototype.lastindexof
101286
- // eslint-disable-next-line es/no-array-prototype-lastindexof -- required for testing
101287
- $$4({ target: 'Array', proto: true, forced: lastIndexOf !== [].lastIndexOf }, {
101288
- lastIndexOf: lastIndexOf
101289
- });
101320
+ function getValue(depot) {
101321
+ return depot(VALUE);
101322
+ }
101323
+ /**
101324
+ * Connects two streams - any value emitted from the emitter will be published in the publisher.
101325
+ * ```ts
101326
+ * const foo = stream<number>();
101327
+ * const bar = stream<number>();
101328
+ * subscribe(bar, (value) => console.log(`Bar emitted ${value}`));
101329
+ *
101330
+ * connect(foo, bar);
101331
+ * publish(foo);
101332
+ * ```
101333
+ * @returns an [[Unsubscribe]] handle which will disconnect the two streams.
101334
+ */
101290
101335
 
101291
- const M$1 = {
101292
- x: 0,
101293
- y: 0,
101294
- width: 0,
101295
- height: 0,
101296
- unit: "px"
101297
- }, v$1 = (o, e, t) => Math.min(Math.max(o, e), t), S$1 = (...o) => o.filter((e) => e && typeof e == "string").join(" "), Y$1 = (o, e) => o === e || o.width === e.width && o.height === e.height && o.x === e.x && o.y === e.y && o.unit === e.unit;
101298
- function H$1(o, e, t, h) {
101299
- const i = y$1(o, t, h);
101300
- return o.width && (i.height = i.width / e), o.height && (i.width = i.height * e), i.y + i.height > h && (i.height = h - i.y, i.width = i.height * e), i.x + i.width > t && (i.width = t - i.x, i.height = i.width / e), o.unit === "%" ? D$1(i, t, h) : i;
101336
+ function connect(emitter, publisher) {
101337
+ return subscribe(emitter, curry2to1(publisher, PUBLISH));
101301
101338
  }
101302
- function I$1(o, e, t) {
101303
- const h = y$1(o, e, t);
101304
- return h.x = (e - h.width) / 2, h.y = (t - h.height) / 2, o.unit === "%" ? D$1(h, e, t) : h;
101339
+ /**
101340
+ * Executes the passed subscription at most once, for the next emit from the emitter.
101341
+ * ```ts
101342
+ * const foo = stream<number>()
101343
+ * handleNext(foo, value => console.log(value)) // called once, with 42
101344
+ * publish(foo, 42)
101345
+ * publish(foo, 43)
101346
+ * ```
101347
+ * @returns an [[Unsubscribe]] handle to unbind the subscription if necessary.
101348
+ */
101349
+
101350
+ function handleNext(emitter, subscription) {
101351
+ var unsub = emitter(SUBSCRIBE, function (value) {
101352
+ unsub();
101353
+ subscription(value);
101354
+ });
101355
+ return unsub;
101305
101356
  }
101306
- function D$1(o, e, t) {
101307
- return o.unit === "%" ? { ...M$1, ...o, unit: "%" } : {
101308
- unit: "%",
101309
- x: o.x ? o.x / e * 100 : 0,
101310
- y: o.y ? o.y / t * 100 : 0,
101311
- width: o.width ? o.width / e * 100 : 0,
101312
- height: o.height ? o.height / t * 100 : 0
101357
+
101358
+ /**
101359
+ * Streams are the basic building blocks of a reactive system. Think of them as the system permanent "data tubes".
101360
+ *
101361
+ * A stream acts as both an [[Emitter]] and [[Publisher]]. Each stream can have multiple {@link Subscription | Subscriptions}.
101362
+ *
101363
+ * urx streams are either **stateless** or **stateful**.
101364
+ * Stateless streams emit data to existing subscriptions when published, without keeping track of it.
101365
+ * Stateful streams remember the last published value and immediately publish it to new subscriptions.
101366
+ *
101367
+ * ```ts
101368
+ * import { stream, statefulStream, publish, subscribe } from "@virtuoso.dev/urx";
101369
+ *
101370
+ * // foo is a stateless stream
101371
+ * const foo = stream<number>();
101372
+ *
101373
+ * publish(foo, 42);
101374
+ * // this subsription will not be called...
101375
+ * subscribe(foo, (value) => console.log(value));
101376
+ * // it will only catch published values after it
101377
+ * publish(foo, 43);
101378
+ *
101379
+ * // stateful streams always start with an initial value
101380
+ * const bar = statefulStream(42);
101381
+ *
101382
+ * // subscribing to a stateful stream
101383
+ * // immediately calls the subscription with the current value
101384
+ * subscribe(bar, (value) => console.log(value));
101385
+ *
101386
+ * // subsequent publishing works just like stateless streams
101387
+ * publish(bar, 43);
101388
+ * ```
101389
+ * @packageDocumentation
101390
+ */
101391
+ /**
101392
+ * Constructs a new stateless stream.
101393
+ * ```ts
101394
+ * const foo = stream<number>();
101395
+ * ```
101396
+ * @typeParam T the type of values to publish in the stream.
101397
+ * @returns a [[Stream]]
101398
+ */
101399
+
101400
+ function stream() {
101401
+ var subscriptions = [];
101402
+ return function (action, arg) {
101403
+ switch (action) {
101404
+ case RESET:
101405
+ subscriptions.splice(0, subscriptions.length);
101406
+ return;
101407
+
101408
+ case SUBSCRIBE:
101409
+ subscriptions.push(arg);
101410
+ return function () {
101411
+ var indexOf = subscriptions.indexOf(arg);
101412
+
101413
+ if (indexOf > -1) {
101414
+ subscriptions.splice(indexOf, 1);
101415
+ }
101416
+ };
101417
+
101418
+ case PUBLISH:
101419
+ subscriptions.slice().forEach(function (subscription) {
101420
+ subscription(arg);
101421
+ });
101422
+ return;
101423
+
101424
+ default:
101425
+ throw new Error("unrecognized action " + action);
101426
+ }
101313
101427
  };
101314
101428
  }
101315
- function y$1(o, e, t) {
101316
- return o.unit ? o.unit === "px" ? { ...M$1, ...o, unit: "px" } : {
101317
- unit: "px",
101318
- x: o.x ? o.x * e / 100 : 0,
101319
- y: o.y ? o.y * t / 100 : 0,
101320
- width: o.width ? o.width * e / 100 : 0,
101321
- height: o.height ? o.height * t / 100 : 0
101322
- } : { ...M$1, ...o, unit: "px" };
101429
+ /**
101430
+ * Constructs a new stateful stream.
101431
+ * ```ts
101432
+ * const foo = statefulStream(42);
101433
+ * ```
101434
+ * @param initial the initial value in the stream.
101435
+ * @typeParam T the type of values to publish in the stream. If omitted, the function infers it from the initial value.
101436
+ * @returns a [[StatefulStream]]
101437
+ */
101438
+
101439
+ function statefulStream(initial) {
101440
+ var value = initial;
101441
+ var innerSubject = stream();
101442
+ return function (action, arg) {
101443
+ switch (action) {
101444
+ case SUBSCRIBE:
101445
+ var subscription = arg;
101446
+ subscription(value);
101447
+ break;
101448
+
101449
+ case PUBLISH:
101450
+ value = arg;
101451
+ break;
101452
+
101453
+ case VALUE:
101454
+ return value;
101455
+ }
101456
+
101457
+ return innerSubject(action, arg);
101458
+ };
101323
101459
  }
101324
- function P$1(o, e, t, h, i, n = 0, s = 0, w = h, a = i) {
101325
- const r = { ...o };
101326
- let c = Math.min(n, h), d = Math.min(s, i), g = Math.min(w, h), l = Math.min(a, i);
101327
- e && (e > 1 ? (c = s ? s * e : c, d = c / e, g = w * e) : (d = n ? n / e : d, c = d * e, l = a / e)), r.y < 0 && (r.height = Math.max(r.height + r.y, d), r.y = 0), r.x < 0 && (r.width = Math.max(r.width + r.x, c), r.x = 0);
101328
- const m = h - (r.x + r.width);
101329
- m < 0 && (r.x = Math.min(r.x, h - c), r.width += m);
101330
- const x = i - (r.y + r.height);
101331
- if (x < 0 && (r.y = Math.min(r.y, i - d), r.height += x), r.width < c && ((t === "sw" || t == "nw") && (r.x -= c - r.width), r.width = c), r.height < d && ((t === "nw" || t == "ne") && (r.y -= d - r.height), r.height = d), r.width > g && ((t === "sw" || t == "nw") && (r.x -= g - r.width), r.width = g), r.height > l && ((t === "nw" || t == "ne") && (r.y -= l - r.height), r.height = l), e) {
101332
- const b = r.width / r.height;
101333
- if (b < e) {
101334
- const C = Math.max(r.width / e, d);
101335
- (t === "nw" || t == "ne") && (r.y -= C - r.height), r.height = C;
101336
- } else if (b > e) {
101337
- const C = Math.max(r.height * e, c);
101338
- (t === "sw" || t == "nw") && (r.x -= C - r.width), r.width = C;
101460
+ /**
101461
+ * Event handlers are special emitters which can have **at most one active subscription**.
101462
+ * Subscribing to an event handler unsubscribes the previous subscription, if present.
101463
+ * ```ts
101464
+ * const foo = stream<number>();
101465
+ * const fooEvent = eventHandler(foo);
101466
+ *
101467
+ * // will be called once with 42
101468
+ * subscribe(fooEvent, (value) => console.log(`Sub 1 ${value}`));
101469
+ * publish(foo, 42);
101470
+ *
101471
+ * // unsubscribes sub 1
101472
+ * subscribe(fooEvent, (value) => console.log(`Sub 2 ${value}`));
101473
+ * publish(foo, 43);
101474
+ * ```
101475
+ * @param emitter the source emitter.
101476
+ * @returns the single-subscription emitter.
101477
+ */
101478
+
101479
+ function eventHandler(emitter) {
101480
+ var unsub;
101481
+ var currentSubscription;
101482
+
101483
+ var cleanup = function cleanup() {
101484
+ return unsub && unsub();
101485
+ };
101486
+
101487
+ return function (action, subscription) {
101488
+ switch (action) {
101489
+ case SUBSCRIBE:
101490
+ if (subscription) {
101491
+ if (currentSubscription === subscription) {
101492
+ return;
101493
+ }
101494
+
101495
+ cleanup();
101496
+ currentSubscription = subscription;
101497
+ unsub = subscribe(emitter, subscription);
101498
+ return unsub;
101499
+ } else {
101500
+ cleanup();
101501
+ return noop;
101502
+ }
101503
+
101504
+ case RESET:
101505
+ cleanup();
101506
+ currentSubscription = null;
101507
+ return;
101508
+
101509
+ default:
101510
+ throw new Error("unrecognized action " + action);
101339
101511
  }
101340
- }
101341
- return r;
101512
+ };
101342
101513
  }
101343
- function _$1(o, e, t, h) {
101344
- const i = { ...o };
101345
- return e === "ArrowLeft" ? h === "nw" ? (i.x -= t, i.y -= t, i.width += t, i.height += t) : h === "w" ? (i.x -= t, i.width += t) : h === "sw" ? (i.x -= t, i.width += t, i.height += t) : h === "ne" ? (i.y += t, i.width -= t, i.height -= t) : h === "e" ? i.width -= t : h === "se" && (i.width -= t, i.height -= t) : e === "ArrowRight" && (h === "nw" ? (i.x += t, i.y += t, i.width -= t, i.height -= t) : h === "w" ? (i.x += t, i.width -= t) : h === "sw" ? (i.x += t, i.width -= t, i.height -= t) : h === "ne" ? (i.y -= t, i.width += t, i.height += t) : h === "e" ? i.width += t : h === "se" && (i.width += t, i.height += t)), e === "ArrowUp" ? h === "nw" ? (i.x -= t, i.y -= t, i.width += t, i.height += t) : h === "n" ? (i.y -= t, i.height += t) : h === "ne" ? (i.y -= t, i.width += t, i.height += t) : h === "sw" ? (i.x += t, i.width -= t, i.height -= t) : h === "s" ? i.height -= t : h === "se" && (i.width -= t, i.height -= t) : e === "ArrowDown" && (h === "nw" ? (i.x += t, i.y += t, i.width -= t, i.height -= t) : h === "n" ? (i.y += t, i.height -= t) : h === "ne" ? (i.y += t, i.width -= t, i.height -= t) : h === "sw" ? (i.x -= t, i.width += t, i.height += t) : h === "s" ? i.height += t : h === "se" && (i.width += t, i.height += t)), i;
101514
+ /**
101515
+ * Creates and connects a "junction" stream to the specified emitter. Often used with [[pipe]], to avoid the multiple evaluation of operator sets.
101516
+ *
101517
+ * ```ts
101518
+ * const foo = stream<number>();
101519
+ *
101520
+ * const fooX2 = pipe(
101521
+ * foo,
101522
+ * map((value) => {
101523
+ * console.log(`multiplying ${value}`);
101524
+ * return value * 2;
101525
+ * })
101526
+ * );
101527
+ *
101528
+ * subscribe(fooX2, (value) => console.log(value));
101529
+ * subscribe(fooX2, (value) => console.log(value));
101530
+ *
101531
+ * publish(foo, 42); // executes the map operator twice for each subscription.
101532
+ *
101533
+ * const sharedFooX2 = streamFromEmitter(pipe(
101534
+ * foo,
101535
+ * map((value) => {
101536
+ * console.log(`shared multiplying ${value}`);
101537
+ * return value * 2;
101538
+ * })
101539
+ * ));
101540
+ *
101541
+ * subscribe(sharedFooX2, (value) => console.log(value));
101542
+ * subscribe(sharedFooX2, (value) => console.log(value));
101543
+ *
101544
+ * publish(foo, 42);
101545
+ *```
101546
+ * @returns the resulting stream.
101547
+ */
101548
+
101549
+ function streamFromEmitter(emitter) {
101550
+ return tap(stream(), function (stream) {
101551
+ return connect(emitter, stream);
101552
+ });
101346
101553
  }
101347
- const f$2 = { capture: !0, passive: !1 };
101348
- let $$3 = 0;
101349
- const u$1 = class u extends PureComponent {
101350
- constructor() {
101351
- super(...arguments), this.docMoveBound = !1, this.mouseDownOnCrop = !1, this.dragStarted = !1, this.evData = {
101352
- startClientX: 0,
101353
- startClientY: 0,
101354
- startCropX: 0,
101355
- startCropY: 0,
101356
- clientX: 0,
101357
- clientY: 0,
101358
- isResize: !0
101359
- }, this.componentRef = createRef(), this.mediaRef = createRef(), this.initChangeCalled = !1, this.instanceId = `rc-${$$3++}`, this.state = {
101360
- cropIsActive: !1,
101361
- newCropIsBeingDrawn: !1
101362
- }, this.onCropPointerDown = (e) => {
101363
- const { crop: t, disabled: h } = this.props, i = this.getBox();
101364
- if (!t)
101365
- return;
101366
- const n = y$1(t, i.width, i.height);
101367
- if (h)
101554
+ /**
101555
+ * Creates and connects a "junction" stateful stream to the specified emitter. Often used with [[pipe]], to avoid the multiple evaluation of operator sets.
101556
+ *
101557
+ * ```ts
101558
+ * const foo = stream<number>();
101559
+ *
101560
+ * const fooX2 = pipe(
101561
+ * foo,
101562
+ * map((value) => {
101563
+ * console.log(`multiplying ${value}`);
101564
+ * return value * 2;
101565
+ * })
101566
+ * );
101567
+ *
101568
+ * subscribe(fooX2, (value) => console.log(value));
101569
+ * subscribe(fooX2, (value) => console.log(value));
101570
+ *
101571
+ * publish(foo, 42); // executes the map operator twice for each subscription.
101572
+ *
101573
+ * const sharedFooX2 = statefulStreamFromEmitter(pipe(
101574
+ * foo,
101575
+ * map((value) => {
101576
+ * console.log(`shared multiplying ${value}`);
101577
+ * return value * 2;
101578
+ * })
101579
+ * ), 42);
101580
+ *
101581
+ * subscribe(sharedFooX2, (value) => console.log(value));
101582
+ * subscribe(sharedFooX2, (value) => console.log(value));
101583
+ *
101584
+ * publish(foo, 42);
101585
+ *```
101586
+ * @param initial the initial value in the stream.
101587
+ * @returns the resulting stateful stream.
101588
+ */
101589
+
101590
+ function statefulStreamFromEmitter(emitter, initial) {
101591
+ return tap(statefulStream(initial), function (stream) {
101592
+ return connect(emitter, stream);
101593
+ });
101594
+ }
101595
+
101596
+ /**
101597
+ *
101598
+ * Stream values can be transformed and controlled by {@link pipe | **piping**} through **operators**.
101599
+ * urx includes several operators like [[map]], [[filter]], [[scan]], and [[throttleTime]].
101600
+ * The [[withLatestFrom]] operator allows the combination of values from other streams.
101601
+ *
101602
+ * ```ts
101603
+ * const foo = stream<number>()
101604
+ *
101605
+ * // create an emitter that first adds 2 to the passed value, then multiplies it by * 2
101606
+ * const bar = pipe(foo, map(value => value + 2), map(value => value * 2))
101607
+ * subscribe(bar, value => console.log(value))
101608
+ * publish(foo, 2) // outputs 8
101609
+ * ```
101610
+ *
101611
+ * ### Implementing Custom Operators
101612
+ * To implement your own operators, implement the [[Operator]] interface.
101613
+ * @packageDocumentation
101614
+ */
101615
+ /** @internal */
101616
+
101617
+ function combineOperators() {
101618
+ for (var _len = arguments.length, operators = new Array(_len), _key = 0; _key < _len; _key++) {
101619
+ operators[_key] = arguments[_key];
101620
+ }
101621
+
101622
+ return function (subscriber) {
101623
+ return operators.reduceRight(thrush, subscriber);
101624
+ };
101625
+ }
101626
+
101627
+ function pipe(source) {
101628
+ for (var _len2 = arguments.length, operators = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
101629
+ operators[_key2 - 1] = arguments[_key2];
101630
+ }
101631
+
101632
+ // prettier-ignore
101633
+ var project = combineOperators.apply(void 0, operators);
101634
+ return function (action, subscription) {
101635
+ switch (action) {
101636
+ case SUBSCRIBE:
101637
+ return subscribe(source, project(subscription));
101638
+
101639
+ case RESET:
101640
+ reset(source);
101368
101641
  return;
101369
- e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
101370
- const s = e.target.dataset.ord, w = !!s;
101371
- let a = e.clientX, r = e.clientY, c = n.x, d = n.y;
101372
- if (s) {
101373
- const g = e.clientX - i.x, l = e.clientY - i.y;
101374
- let m = 0, x = 0;
101375
- s === "ne" || s == "e" ? (m = g - (n.x + n.width), x = l - n.y, c = n.x, d = n.y + n.height) : s === "se" || s === "s" ? (m = g - (n.x + n.width), x = l - (n.y + n.height), c = n.x, d = n.y) : s === "sw" || s == "w" ? (m = g - n.x, x = l - (n.y + n.height), c = n.x + n.width, d = n.y) : (s === "nw" || s == "n") && (m = g - n.x, x = l - n.y, c = n.x + n.width, d = n.y + n.height), a = c + i.x + m, r = d + i.y + x;
101642
+
101643
+ default:
101644
+ throw new Error("unrecognized action " + action);
101645
+ }
101646
+ };
101647
+ }
101648
+ /**
101649
+ * The default [[Comparator]] for [[distinctUntilChanged]] and [[duc]].
101650
+ */
101651
+
101652
+ function defaultComparator(previous, next) {
101653
+ return previous === next;
101654
+ }
101655
+ /**
101656
+ * Filters out identical values. Pass an optional [[Comparator]] if you need to filter non-primitive values.
101657
+ * ```ts
101658
+ * const foo = stream<number>()
101659
+ *
101660
+ * subscribe(
101661
+ * pipe(foo, distinctUntilChanged()),
101662
+ * console.log
101663
+ * ) // will be called only once
101664
+ *
101665
+ * publish(foo, 42)
101666
+ * publish(foo, 42)
101667
+ * ```
101668
+ */
101669
+
101670
+ function distinctUntilChanged(comparator) {
101671
+ if (comparator === void 0) {
101672
+ comparator = defaultComparator;
101673
+ }
101674
+
101675
+ var current;
101676
+ return function (done) {
101677
+ return function (next) {
101678
+ if (!comparator(current, next)) {
101679
+ current = next;
101680
+ done(next);
101376
101681
  }
101377
- this.evData = {
101378
- startClientX: a,
101379
- startClientY: r,
101380
- startCropX: c,
101381
- startCropY: d,
101382
- clientX: e.clientX,
101383
- clientY: e.clientY,
101384
- isResize: w,
101385
- ord: s
101386
- }, this.mouseDownOnCrop = !0, this.setState({ cropIsActive: !0 });
101387
- }, this.onComponentPointerDown = (e) => {
101388
- const { crop: t, disabled: h, locked: i, keepSelection: n, onChange: s } = this.props, w = this.getBox();
101389
- if (h || i || n && t)
101390
- return;
101391
- e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
101392
- const a = e.clientX - w.x, r = e.clientY - w.y, c = {
101393
- unit: "px",
101394
- x: a,
101395
- y: r,
101396
- width: 0,
101397
- height: 0
101398
- };
101399
- this.evData = {
101400
- startClientX: e.clientX,
101401
- startClientY: e.clientY,
101402
- startCropX: a,
101403
- startCropY: r,
101404
- clientX: e.clientX,
101405
- clientY: e.clientY,
101406
- isResize: !0
101407
- }, this.mouseDownOnCrop = !0, s(y$1(c, w.width, w.height), D$1(c, w.width, w.height)), this.setState({ cropIsActive: !0, newCropIsBeingDrawn: !0 });
101408
- }, this.onDocPointerMove = (e) => {
101409
- const { crop: t, disabled: h, onChange: i, onDragStart: n } = this.props, s = this.getBox();
101410
- if (h || !t || !this.mouseDownOnCrop)
101411
- return;
101412
- e.cancelable && e.preventDefault(), this.dragStarted || (this.dragStarted = !0, n && n(e));
101413
- const { evData: w } = this;
101414
- w.clientX = e.clientX, w.clientY = e.clientY;
101415
- let a;
101416
- w.isResize ? a = this.resizeCrop() : a = this.dragCrop(), Y$1(t, a) || i(
101417
- y$1(a, s.width, s.height),
101418
- D$1(a, s.width, s.height)
101419
- );
101420
- }, this.onComponentKeyDown = (e) => {
101421
- const { crop: t, disabled: h, onChange: i, onComplete: n } = this.props;
101422
- if (h)
101423
- return;
101424
- const s = e.key;
101425
- let w = !1;
101426
- if (!t)
101682
+ };
101683
+ };
101684
+ }
101685
+ /**
101686
+ * Filters out values for which the predicator does not return `true`-ish.
101687
+ * ```ts
101688
+ * const foo = stream<number>()
101689
+ *
101690
+ * subscribe(
101691
+ * pipe(foo, filter(value => value % 2 === 0)),
101692
+ * console.log
101693
+ * ) // will be called only with even values
101694
+ *
101695
+ * publish(foo, 2)
101696
+ * publish(foo, 3)
101697
+ * publish(foo, 4)
101698
+ * publish(foo, 5)
101699
+ * ```
101700
+ */
101701
+
101702
+ function filter(predicate) {
101703
+ return function (done) {
101704
+ return function (value) {
101705
+ predicate(value) && done(value);
101706
+ };
101707
+ };
101708
+ }
101709
+ /**
101710
+ * Maps values using the provided project function.
101711
+ * ```ts
101712
+ * const foo = stream<number>()
101713
+ *
101714
+ * subscribe(
101715
+ * pipe(foo, map(value => value * 2)),
101716
+ * console.log
101717
+ * ) // 4, 6
101718
+ *
101719
+ * publish(foo, 2)
101720
+ * publish(foo, 3)
101721
+ * ```
101722
+ */
101723
+
101724
+ function map(project) {
101725
+ return function (done) {
101726
+ return compose(done, project);
101727
+ };
101728
+ }
101729
+ /**
101730
+ * Maps values to the hard-coded value.
101731
+ * ```ts
101732
+ * const foo = stream<number>()
101733
+ *
101734
+ * subscribe(
101735
+ * pipe(foo, mapTo(3)),
101736
+ * console.log
101737
+ * ) // 3, 3
101738
+ *
101739
+ * publish(foo, 1)
101740
+ * publish(foo, 2)
101741
+ * ```
101742
+ */
101743
+
101744
+ function mapTo(value) {
101745
+ return function (done) {
101746
+ return function () {
101747
+ return done(value);
101748
+ };
101749
+ };
101750
+ }
101751
+ /**
101752
+ * Works like Array#reduce.
101753
+ * Applies an accumulator function on the emitter, and outputs intermediate result. Starts with the initial value.
101754
+ * ```ts
101755
+ * const foo = stream<number>()
101756
+ *
101757
+ * subscribe(
101758
+ * pipe(foo, scan((acc, value) => acc + value, 2),
101759
+ * console.log
101760
+ * ) // 3, 5
101761
+ *
101762
+ * publish(foo, 1)
101763
+ * publish(foo, 2)
101764
+ * ```
101765
+ */
101766
+
101767
+ function scan(scanner, initial) {
101768
+ return function (done) {
101769
+ return function (value) {
101770
+ return done(initial = scanner(initial, value));
101771
+ };
101772
+ };
101773
+ }
101774
+ /**
101775
+ * Skips the specified amount of values from the emitter.
101776
+ * ```ts
101777
+ * const foo = stream<number>()
101778
+ *
101779
+ * subscribe(
101780
+ * pipe(foo, skip(2)),
101781
+ * console.log
101782
+ * ) // 3, 4
101783
+ *
101784
+ * publish(foo, 1) // skipped
101785
+ * publish(foo, 2) // skipped
101786
+ * publish(foo, 3)
101787
+ * publish(foo, 4)
101788
+ * ```
101789
+ */
101790
+
101791
+ function skip(times) {
101792
+ return function (done) {
101793
+ return function (value) {
101794
+ times > 0 ? times-- : done(value);
101795
+ };
101796
+ };
101797
+ }
101798
+ /**
101799
+ * Throttles flowing values at the provided interval in milliseconds.
101800
+ * [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
101801
+ *
101802
+ * ```ts
101803
+ * const foo = stream<number>()
101804
+ * publish(foo, 1)
101805
+ *
101806
+ * setTimeout(() => publish(foo, 2), 20)
101807
+ * setTimeout(() => publish(foo, 3), 20)
101808
+ *
101809
+ * subscribe(pipe(foo, throttleTime(50)), val => {
101810
+ * console.log(value); // 3
101811
+ * })
101812
+ * ```
101813
+ */
101814
+
101815
+ function throttleTime(interval) {
101816
+ var currentValue;
101817
+ var timeout;
101818
+ return function (done) {
101819
+ return function (value) {
101820
+ currentValue = value;
101821
+
101822
+ if (timeout) {
101427
101823
  return;
101428
- const a = this.getBox(), r = this.makePixelCrop(a), d = (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) ? u.nudgeStepLarge : e.shiftKey ? u.nudgeStepMedium : u.nudgeStep;
101429
- if (s === "ArrowLeft" ? (r.x -= d, w = !0) : s === "ArrowRight" ? (r.x += d, w = !0) : s === "ArrowUp" ? (r.y -= d, w = !0) : s === "ArrowDown" && (r.y += d, w = !0), w) {
101430
- e.cancelable && e.preventDefault(), r.x = v$1(r.x, 0, a.width - r.width), r.y = v$1(r.y, 0, a.height - r.height);
101431
- const g = y$1(r, a.width, a.height), l = D$1(r, a.width, a.height);
101432
- i(g, l), n && n(g, l);
101433
101824
  }
101434
- }, this.onHandlerKeyDown = (e, t) => {
101435
- const {
101436
- aspect: h = 0,
101437
- crop: i,
101438
- disabled: n,
101439
- minWidth: s = 0,
101440
- minHeight: w = 0,
101441
- maxWidth: a,
101442
- maxHeight: r,
101443
- onChange: c,
101444
- onComplete: d
101445
- } = this.props, g = this.getBox();
101446
- if (n || !i)
101447
- return;
101448
- if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight")
101449
- e.stopPropagation(), e.preventDefault();
101450
- else
101451
- return;
101452
- const m = (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) ? u.nudgeStepLarge : e.shiftKey ? u.nudgeStepMedium : u.nudgeStep, x = y$1(i, g.width, g.height), b = _$1(x, e.key, m, t), C = P$1(
101453
- b,
101454
- h,
101455
- t,
101456
- g.width,
101457
- g.height,
101458
- s,
101459
- w,
101460
- a,
101461
- r
101462
- );
101463
- if (!Y$1(i, C)) {
101464
- const R = D$1(C, g.width, g.height);
101465
- c(C, R), d && d(C, R);
101825
+
101826
+ timeout = setTimeout(function () {
101827
+ timeout = undefined;
101828
+ done(currentValue);
101829
+ }, interval);
101830
+ };
101831
+ };
101832
+ }
101833
+ /**
101834
+ * Debounces flowing values at the provided interval in milliseconds.
101835
+ * [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
101836
+ *
101837
+ * ```ts
101838
+ * const foo = stream<number>()
101839
+ * publish(foo, 1)
101840
+ *
101841
+ * setTimeout(() => publish(foo, 2), 20)
101842
+ * setTimeout(() => publish(foo, 3), 20)
101843
+ *
101844
+ * subscribe(pipe(foo, debounceTime(50)), val => {
101845
+ * console.log(value); // 3
101846
+ * })
101847
+ * ```
101848
+ */
101849
+
101850
+ function debounceTime(interval) {
101851
+ var currentValue;
101852
+ var timeout;
101853
+ return function (done) {
101854
+ return function (value) {
101855
+ currentValue = value;
101856
+
101857
+ if (timeout) {
101858
+ clearTimeout(timeout);
101466
101859
  }
101467
- }, this.onDocPointerDone = (e) => {
101468
- const { crop: t, disabled: h, onComplete: i, onDragEnd: n } = this.props, s = this.getBox();
101469
- this.unbindDocMove(), !(h || !t) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, n && n(e), i && i(y$1(t, s.width, s.height), D$1(t, s.width, s.height)), this.setState({ cropIsActive: !1, newCropIsBeingDrawn: !1 }));
101470
- }, this.onDragFocus = () => {
101471
- var e;
101472
- (e = this.componentRef.current) == null || e.scrollTo(0, 0);
101860
+
101861
+ timeout = setTimeout(function () {
101862
+ done(currentValue);
101863
+ }, interval);
101473
101864
  };
101865
+ };
101866
+ }
101867
+ function withLatestFrom() {
101868
+ for (var _len3 = arguments.length, sources = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
101869
+ sources[_key3] = arguments[_key3];
101474
101870
  }
101475
- get document() {
101476
- return document;
101477
- }
101478
- // We unfortunately get the bounding box every time as x+y changes
101479
- // due to scrolling.
101480
- getBox() {
101481
- const e = this.mediaRef.current;
101482
- if (!e)
101483
- return { x: 0, y: 0, width: 0, height: 0 };
101484
- const { x: t, y: h, width: i, height: n } = e.getBoundingClientRect();
101485
- return { x: t, y: h, width: i, height: n };
101486
- }
101487
- componentDidUpdate(e) {
101488
- const { crop: t, onComplete: h } = this.props;
101489
- if (h && !e.crop && t) {
101490
- const { width: i, height: n } = this.getBox();
101491
- i && n && h(y$1(t, i, n), D$1(t, i, n));
101492
- }
101493
- }
101494
- componentWillUnmount() {
101495
- this.resizeObserver && this.resizeObserver.disconnect(), this.unbindDocMove();
101496
- }
101497
- bindDocMove() {
101498
- this.docMoveBound || (this.document.addEventListener("pointermove", this.onDocPointerMove, f$2), this.document.addEventListener("pointerup", this.onDocPointerDone, f$2), this.document.addEventListener("pointercancel", this.onDocPointerDone, f$2), this.docMoveBound = !0);
101499
- }
101500
- unbindDocMove() {
101501
- this.docMoveBound && (this.document.removeEventListener("pointermove", this.onDocPointerMove, f$2), this.document.removeEventListener("pointerup", this.onDocPointerDone, f$2), this.document.removeEventListener("pointercancel", this.onDocPointerDone, f$2), this.docMoveBound = !1);
101502
- }
101503
- getCropStyle() {
101504
- const { crop: e } = this.props;
101505
- if (e)
101506
- return {
101507
- top: `${e.y}${e.unit}`,
101508
- left: `${e.x}${e.unit}`,
101509
- width: `${e.width}${e.unit}`,
101510
- height: `${e.height}${e.unit}`
101871
+
101872
+ var values = new Array(sources.length);
101873
+ var called = 0;
101874
+ var pendingCall = null;
101875
+ var allCalled = Math.pow(2, sources.length) - 1;
101876
+ sources.forEach(function (source, index) {
101877
+ var bit = Math.pow(2, index);
101878
+ subscribe(source, function (value) {
101879
+ var prevCalled = called;
101880
+ called = called | bit;
101881
+ values[index] = value;
101882
+
101883
+ if (prevCalled !== allCalled && called === allCalled && pendingCall) {
101884
+ pendingCall();
101885
+ pendingCall = null;
101886
+ }
101887
+ });
101888
+ });
101889
+ return function (done) {
101890
+ return function (value) {
101891
+ var call = function call() {
101892
+ return done([value].concat(values));
101511
101893
  };
101512
- }
101513
- dragCrop() {
101514
- const { evData: e } = this, t = this.getBox(), h = this.makePixelCrop(t), i = e.clientX - e.startClientX, n = e.clientY - e.startClientY;
101515
- return h.x = v$1(e.startCropX + i, 0, t.width - h.width), h.y = v$1(e.startCropY + n, 0, t.height - h.height), h;
101516
- }
101517
- getPointRegion(e, t, h, i) {
101518
- const { evData: n } = this, s = n.clientX - e.x, w = n.clientY - e.y;
101519
- let a;
101520
- i && t ? a = t === "nw" || t === "n" || t === "ne" : a = w < n.startCropY;
101521
- let r;
101522
- return h && t ? r = t === "nw" || t === "w" || t === "sw" : r = s < n.startCropX, r ? a ? "nw" : "sw" : a ? "ne" : "se";
101523
- }
101524
- resolveMinDimensions(e, t, h = 0, i = 0) {
101525
- const n = Math.min(h, e.width), s = Math.min(i, e.height);
101526
- return !t || !n && !s ? [n, s] : t > 1 ? n ? [n, n / t] : [s * t, s] : s ? [s * t, s] : [n, n / t];
101527
- }
101528
- resizeCrop() {
101529
- const { evData: e } = this, { aspect: t = 0, maxWidth: h, maxHeight: i } = this.props, n = this.getBox(), [s, w] = this.resolveMinDimensions(n, t, this.props.minWidth, this.props.minHeight);
101530
- let a = this.makePixelCrop(n);
101531
- const r = this.getPointRegion(n, e.ord, s, w), c = e.ord || r;
101532
- let d = e.clientX - e.startClientX, g = e.clientY - e.startClientY;
101533
- (s && c === "nw" || c === "w" || c === "sw") && (d = Math.min(d, -s)), (w && c === "nw" || c === "n" || c === "ne") && (g = Math.min(g, -w));
101534
- const l = {
101535
- unit: "px",
101536
- x: 0,
101537
- y: 0,
101538
- width: 0,
101539
- height: 0
101894
+
101895
+ if (called === allCalled) {
101896
+ call();
101897
+ } else {
101898
+ pendingCall = call;
101899
+ }
101540
101900
  };
101541
- r === "ne" ? (l.x = e.startCropX, l.width = d, t ? (l.height = l.width / t, l.y = e.startCropY - l.height) : (l.height = Math.abs(g), l.y = e.startCropY - l.height)) : r === "se" ? (l.x = e.startCropX, l.y = e.startCropY, l.width = d, t ? l.height = l.width / t : l.height = g) : r === "sw" ? (l.x = e.startCropX + d, l.y = e.startCropY, l.width = Math.abs(d), t ? l.height = l.width / t : l.height = g) : r === "nw" && (l.x = e.startCropX + d, l.width = Math.abs(d), t ? (l.height = l.width / t, l.y = e.startCropY - l.height) : (l.height = Math.abs(g), l.y = e.startCropY + g));
101542
- const m = P$1(
101543
- l,
101544
- t,
101545
- r,
101546
- n.width,
101547
- n.height,
101548
- s,
101549
- w,
101550
- h,
101551
- i
101552
- );
101553
- return t || u.xyOrds.indexOf(c) > -1 ? a = m : u.xOrds.indexOf(c) > -1 ? (a.x = m.x, a.width = m.width) : u.yOrds.indexOf(c) > -1 && (a.y = m.y, a.height = m.height), a.x = v$1(a.x, 0, n.width - a.width), a.y = v$1(a.y, 0, n.height - a.height), a;
101554
- }
101555
- renderCropSelection() {
101556
- const {
101557
- ariaLabels: e = u.defaultProps.ariaLabels,
101558
- disabled: t,
101559
- locked: h,
101560
- renderSelectionAddon: i,
101561
- ruleOfThirds: n,
101562
- crop: s
101901
+ };
101902
+ }
101903
+
101904
+ /**
101905
+ * Transformers change and combine streams, similar to operators.
101906
+ * urx comes with two combinators - [[combineLatest]] and [[merge]], and one convenience filter - [[duc]].
101907
+ *
101908
+ * @packageDocumentation
101909
+ */
101910
+ /**
101911
+ * Merges one or more emitters from the same type into a new Emitter which emits values from any of the source emitters.
101912
+ * ```ts
101913
+ * const foo = stream<number>()
101914
+ * const bar = stream<number>()
101915
+ *
101916
+ * subscribe(merge(foo, bar), (value) => console.log(value)) // 42, 43
101917
+ *
101918
+ * publish(foo, 42)
101919
+ * publish(bar, 43)
101920
+ * ```
101921
+ */
101922
+
101923
+ function merge() {
101924
+ for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
101925
+ sources[_key] = arguments[_key];
101926
+ }
101927
+
101928
+ return function (action, subscription) {
101929
+ switch (action) {
101930
+ case SUBSCRIBE:
101931
+ return joinProc.apply(void 0, sources.map(function (source) {
101932
+ return subscribe(source, subscription);
101933
+ }));
101934
+
101935
+ case RESET:
101936
+ // do nothing, we are stateless
101937
+ return;
101938
+
101939
+ default:
101940
+ throw new Error("unrecognized action " + action);
101941
+ }
101942
+ };
101943
+ }
101944
+ /**
101945
+ * A convenience wrapper that emits only the distinct values from the passed Emitter. Wraps [[pipe]] and [[distinctUntilChanged]].
101946
+ *
101947
+ * ```ts
101948
+ * const foo = stream<number>()
101949
+ *
101950
+ * // this line...
101951
+ * const a = duc(foo)
101952
+ *
101953
+ * // is equivalent to this
101954
+ * const b = pipe(distinctUntilChanged(foo))
101955
+ * ```
101956
+ *
101957
+ * @param source The source emitter.
101958
+ * @param comparator optional custom comparison function for the two values.
101959
+ *
101960
+ * @typeParam T the type of the value emitted by the source.
101961
+ *
101962
+ * @returns the resulting emitter.
101963
+ */
101964
+
101965
+ function duc(source, comparator) {
101966
+ if (comparator === void 0) {
101967
+ comparator = defaultComparator;
101968
+ }
101969
+
101970
+ return pipe(source, distinctUntilChanged(comparator));
101971
+ }
101972
+ function combineLatest() {
101973
+ var innerSubject = stream();
101974
+
101975
+ for (var _len2 = arguments.length, emitters = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
101976
+ emitters[_key2] = arguments[_key2];
101977
+ }
101978
+
101979
+ var values = new Array(emitters.length);
101980
+ var called = 0;
101981
+ var allCalled = Math.pow(2, emitters.length) - 1;
101982
+ emitters.forEach(function (source, index) {
101983
+ var bit = Math.pow(2, index);
101984
+ subscribe(source, function (value) {
101985
+ values[index] = value;
101986
+ called = called | bit;
101987
+
101988
+ if (called === allCalled) {
101989
+ publish(innerSubject, values);
101990
+ }
101991
+ });
101992
+ });
101993
+ return function (action, subscription) {
101994
+ switch (action) {
101995
+ case SUBSCRIBE:
101996
+ if (called === allCalled) {
101997
+ subscription(values);
101998
+ }
101999
+
102000
+ return subscribe(innerSubject, subscription);
102001
+
102002
+ case RESET:
102003
+ return reset(innerSubject);
102004
+
102005
+ default:
102006
+ throw new Error("unrecognized action " + action);
102007
+ }
102008
+ };
102009
+ }
102010
+
102011
+ /**
102012
+ * `system` defines a specification of a system - its constructor, dependencies and if it should act as a singleton in a system dependency tree.
102013
+ * When called, system returns a [[SystemSpec]], which is then initialized along with its dependencies by passing it to [[init]].
102014
+ *
102015
+ * ```ts
102016
+ * @import { subscribe, publish, system, init, tup, connect, map, pipe } from 'urx'
102017
+ *
102018
+ * // a simple system with two streams
102019
+ * const sys1 = system(() => {
102020
+ * const a = stream<number>()
102021
+ * const b = stream<number>()
102022
+ *
102023
+ * connect(pipe(a, map(value => value * 2)), b)
102024
+ * return { a, b }
102025
+ * })
102026
+ *
102027
+ * // a second system which depends on the streams from the first one
102028
+ * const sys2 = system(([ {a, b} ]) => {
102029
+ * const c = stream<number>()
102030
+ * connect(pipe(b, map(value => value * 2)), c)
102031
+ * // re-export the `a` stream, keep `b` internal
102032
+ * return { a, c }
102033
+ * }, tup(sys1))
102034
+ *
102035
+ * // init will recursively initialize sys2 dependencies, in this case sys1
102036
+ * const { a, c } = init(sys2)
102037
+ * subscribe(c, c => console.log(`Value multiplied by 4`, c))
102038
+ * publish(a, 2)
102039
+ * ```
102040
+ *
102041
+ * #### Singletons in Dependency Tree
102042
+ *
102043
+ * By default, systems will be initialized only once if encountered multiple times in the dependency tree.
102044
+ * In the below dependency system tree, systems `b` and `c` will receive the same stream instances from system `a` when system `d` is initialized.
102045
+ * ```txt
102046
+ * a
102047
+ * / \
102048
+ * b c
102049
+ * \ /
102050
+ * d
102051
+ * ```
102052
+ * If `a` gets `{singleton: false}` as a last argument, `init` creates two separate instances - one for `b` and one for `c`.
102053
+ *
102054
+ * @param constructor the system constructor function. Initialize and connect the streams in its body.
102055
+ *
102056
+ * @param dependencies the system dependencies, which the constructor will receive as arguments.
102057
+ * Use the [[tup]] utility **For TypeScript type inference to work correctly**.
102058
+ * ```ts
102059
+ * const sys3 = system(() => { ... }, tup(sys2, sys1))
102060
+ * ```
102061
+ * @param __namedParameters Options
102062
+ * @param singleton determines if the system will act as a singleton in a system dependency tree. `true` by default.
102063
+ */
102064
+ function system(constructor, dependencies, _temp) {
102065
+ if (dependencies === void 0) {
102066
+ dependencies = [];
102067
+ }
102068
+
102069
+ var _ref = _temp === void 0 ? {
102070
+ singleton: true
102071
+ } : _temp,
102072
+ singleton = _ref.singleton;
102073
+
102074
+ return {
102075
+ id: id(),
102076
+ constructor: constructor,
102077
+ dependencies: dependencies,
102078
+ singleton: singleton
102079
+ };
102080
+ }
102081
+ /** @internal */
102082
+
102083
+ var id = function id() {
102084
+ return Symbol();
102085
+ };
102086
+ /**
102087
+ * Initializes a [[SystemSpec]] by recursively initializing its dependencies.
102088
+ *
102089
+ * ```ts
102090
+ * // a simple system with two streams
102091
+ * const sys1 = system(() => {
102092
+ * const a = stream<number>()
102093
+ * const b = stream<number>()
102094
+ *
102095
+ * connect(pipe(a, map(value => value * 2)), b)
102096
+ * return { a, b }
102097
+ * })
102098
+ *
102099
+ * const { a, b } = init(sys1)
102100
+ * subscribe(b, b => console.log(b))
102101
+ * publish(a, 2)
102102
+ * ```
102103
+ *
102104
+ * @returns the [[System]] constructed by the spec constructor.
102105
+ * @param systemSpec the system spec to initialize.
102106
+ */
102107
+
102108
+
102109
+ function init(systemSpec) {
102110
+ var singletons = new Map();
102111
+
102112
+ var _init = function _init(_ref2) {
102113
+ var id = _ref2.id,
102114
+ constructor = _ref2.constructor,
102115
+ dependencies = _ref2.dependencies,
102116
+ singleton = _ref2.singleton;
102117
+
102118
+ if (singleton && singletons.has(id)) {
102119
+ return singletons.get(id);
102120
+ }
102121
+
102122
+ var system = constructor(dependencies.map(function (e) {
102123
+ return _init(e);
102124
+ }));
102125
+
102126
+ if (singleton) {
102127
+ singletons.set(id, system);
102128
+ }
102129
+
102130
+ return system;
102131
+ };
102132
+
102133
+ return _init(systemSpec);
102134
+ }
102135
+
102136
+ function _objectWithoutPropertiesLoose(source, excluded) {
102137
+ if (source == null) return {};
102138
+ var target = {};
102139
+ var sourceKeys = Object.keys(source);
102140
+ var key, i;
102141
+
102142
+ for (i = 0; i < sourceKeys.length; i++) {
102143
+ key = sourceKeys[i];
102144
+ if (excluded.indexOf(key) >= 0) continue;
102145
+ target[key] = source[key];
102146
+ }
102147
+
102148
+ return target;
102149
+ }
102150
+
102151
+ function _unsupportedIterableToArray$1(o, minLen) {
102152
+ if (!o) return;
102153
+ if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
102154
+ var n = Object.prototype.toString.call(o).slice(8, -1);
102155
+ if (n === "Object" && o.constructor) n = o.constructor.name;
102156
+ if (n === "Map" || n === "Set") return Array.from(o);
102157
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
102158
+ }
102159
+
102160
+ function _arrayLikeToArray$1(arr, len) {
102161
+ if (len == null || len > arr.length) len = arr.length;
102162
+
102163
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
102164
+
102165
+ return arr2;
102166
+ }
102167
+
102168
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
102169
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
102170
+ if (it) return (it = it.call(o)).next.bind(it);
102171
+
102172
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
102173
+ if (it) o = it;
102174
+ var i = 0;
102175
+ return function () {
102176
+ if (i >= o.length) return {
102177
+ done: true
102178
+ };
102179
+ return {
102180
+ done: false,
102181
+ value: o[i++]
102182
+ };
102183
+ };
102184
+ }
102185
+
102186
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
102187
+ }
102188
+
102189
+ var _excluded = ["children"];
102190
+ /** @internal */
102191
+
102192
+ function omit(keys, obj) {
102193
+ var result = {};
102194
+ var index = {};
102195
+ var idx = 0;
102196
+ var len = keys.length;
102197
+
102198
+ while (idx < len) {
102199
+ index[keys[idx]] = 1;
102200
+ idx += 1;
102201
+ }
102202
+
102203
+ for (var prop in obj) {
102204
+ if (!index.hasOwnProperty(prop)) {
102205
+ result[prop] = obj[prop];
102206
+ }
102207
+ }
102208
+
102209
+ return result;
102210
+ }
102211
+
102212
+ var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect$2 : useEffect;
102213
+ /**
102214
+ * Converts a system spec to React component by mapping the system streams to component properties, events and methods. Returns hooks for querying and modifying
102215
+ * the system streams from the component's child components.
102216
+ * @param systemSpec The return value from a [[system]] call.
102217
+ * @param map The streams to props / events / methods mapping Check [[SystemPropsMap]] for more details.
102218
+ * @param Root The optional React component to render. By default, the resulting component renders nothing, acting as a logical wrapper for its children.
102219
+ * @returns an object containing the following:
102220
+ * - `Component`: the React component.
102221
+ * - `useEmitterValue`: a hook that lets child components use values emitted from the specified output stream.
102222
+ * - `useEmitter`: a hook that calls the provided callback whenever the specified stream emits a value.
102223
+ * - `usePublisher`: a hook which lets child components publish values to the specified stream.
102224
+ * <hr />
102225
+ */
102226
+
102227
+ function systemToComponent(systemSpec, map, Root) {
102228
+ var requiredPropNames = Object.keys(map.required || {});
102229
+ var optionalPropNames = Object.keys(map.optional || {});
102230
+ var methodNames = Object.keys(map.methods || {});
102231
+ var eventNames = Object.keys(map.events || {});
102232
+ var Context = createContext$1({});
102233
+
102234
+ function applyPropsToSystem(system, props) {
102235
+ if (system['propsReady']) {
102236
+ publish(system['propsReady'], false);
102237
+ }
102238
+
102239
+ for (var _iterator = _createForOfIteratorHelperLoose(requiredPropNames), _step; !(_step = _iterator()).done;) {
102240
+ var requiredPropName = _step.value;
102241
+ var stream = system[map.required[requiredPropName]];
102242
+ publish(stream, props[requiredPropName]);
102243
+ }
102244
+
102245
+ for (var _iterator2 = _createForOfIteratorHelperLoose(optionalPropNames), _step2; !(_step2 = _iterator2()).done;) {
102246
+ var optionalPropName = _step2.value;
102247
+
102248
+ if (optionalPropName in props) {
102249
+ var _stream = system[map.optional[optionalPropName]];
102250
+ publish(_stream, props[optionalPropName]);
102251
+ }
102252
+ }
102253
+
102254
+ if (system['propsReady']) {
102255
+ publish(system['propsReady'], true);
102256
+ }
102257
+ }
102258
+
102259
+ function buildMethods(system) {
102260
+ return methodNames.reduce(function (acc, methodName) {
102261
+
102262
+ acc[methodName] = function (value) {
102263
+ var stream = system[map.methods[methodName]];
102264
+ publish(stream, value);
102265
+ };
102266
+
102267
+ return acc;
102268
+ }, {});
102269
+ }
102270
+
102271
+ function buildEventHandlers(system) {
102272
+ return eventNames.reduce(function (handlers, eventName) {
102273
+ handlers[eventName] = eventHandler(system[map.events[eventName]]);
102274
+ return handlers;
102275
+ }, {});
102276
+ }
102277
+ /**
102278
+ * A React component generated from an urx system
102279
+ */
102280
+
102281
+
102282
+ var Component = forwardRef(function (propsWithChildren, ref) {
102283
+ var children = propsWithChildren.children,
102284
+ props = _objectWithoutPropertiesLoose(propsWithChildren, _excluded);
102285
+
102286
+ var _useState = useState(function () {
102287
+ return tap(init(systemSpec), function (system) {
102288
+ return applyPropsToSystem(system, props);
102289
+ });
102290
+ }),
102291
+ system = _useState[0];
102292
+
102293
+ var _useState2 = useState(curry1to0(buildEventHandlers, system)),
102294
+ handlers = _useState2[0];
102295
+
102296
+ useIsomorphicLayoutEffect(function () {
102297
+ for (var _iterator3 = _createForOfIteratorHelperLoose(eventNames), _step3; !(_step3 = _iterator3()).done;) {
102298
+ var eventName = _step3.value;
102299
+
102300
+ if (eventName in props) {
102301
+ subscribe(handlers[eventName], props[eventName]);
102302
+ }
102303
+ }
102304
+
102305
+ return function () {
102306
+ Object.values(handlers).map(reset);
102307
+ };
102308
+ }, [props, handlers, system]);
102309
+ useIsomorphicLayoutEffect(function () {
102310
+ applyPropsToSystem(system, props);
102311
+ });
102312
+ useImperativeHandle(ref, always(buildMethods(system)));
102313
+ return createElement$2(Context.Provider, {
102314
+ value: system
102315
+ }, Root ? createElement$2(Root, omit([].concat(requiredPropNames, optionalPropNames, eventNames), props), children) : children);
102316
+ });
102317
+
102318
+ var usePublisher = function usePublisher(key) {
102319
+ return useCallback(curry2to1(publish, useContext$1(Context)[key]), [key]);
102320
+ };
102321
+ /**
102322
+ * Returns the value emitted from the stream.
102323
+ */
102324
+
102325
+
102326
+ var useEmitterValue = function useEmitterValue(key) {
102327
+ var context = useContext$1(Context);
102328
+ var source = context[key];
102329
+
102330
+ var _useState3 = useState(curry1to0(getValue, source)),
102331
+ value = _useState3[0],
102332
+ setValue = _useState3[1];
102333
+
102334
+ useIsomorphicLayoutEffect(function () {
102335
+ return subscribe(source, function (next) {
102336
+ if (next !== value) {
102337
+ setValue(always(next));
102338
+ }
102339
+ });
102340
+ }, [source, value]);
102341
+ return value;
102342
+ };
102343
+
102344
+ var useEmitter = function useEmitter(key, callback) {
102345
+ var context = useContext$1(Context);
102346
+ var source = context[key];
102347
+ useIsomorphicLayoutEffect(function () {
102348
+ return subscribe(source, callback);
102349
+ }, [callback, source]);
102350
+ };
102351
+
102352
+ return {
102353
+ Component: Component,
102354
+ usePublisher: usePublisher,
102355
+ useEmitterValue: useEmitterValue,
102356
+ useEmitter: useEmitter
102357
+ };
102358
+ }
102359
+
102360
+ function c$1(){return c$1=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);}return t},c$1.apply(this,arguments)}function m(t,e){if(null==t)return {};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(r[n]=t[n]);return r}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}function f$2(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return (n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return d(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var p,h,g="undefined"!=typeof document?useLayoutEffect$2:useEffect;!function(t){t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR";}(h||(h={}));var v$1=((p={})[h.DEBUG]="debug",p[h.INFO]="log",p[h.WARN]="warn",p[h.ERROR]="error",p),S$1=system(function(){var t=statefulStream(h.ERROR);return {log:statefulStream(function(n,o,r){var i;void 0===r&&(r=h.INFO),r>=(null!=(i=("undefined"==typeof globalThis?window:globalThis).VIRTUOSO_LOG_LEVEL)?i:getValue(t))&&console[v$1[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",n,o);}),logLevel:t}},[],{singleton:!0});function C(t,e){void 0===e&&(e=!0);var n=useRef(null),o=function(t){};if("undefined"!=typeof ResizeObserver){var r=new ResizeObserver(function(e){var n=e[0].target;null!==n.offsetParent&&t(n);});o=function(t){t&&e?(r.observe(t),n.current=t):(n.current&&r.unobserve(n.current),n.current=null);};}return {ref:n,callbackRef:o}}function I$1(t,e){return void 0===e&&(e=!0),C(t,e).callbackRef}function T$1(t,e,n,o,r,i,a){return C(function(n){for(var l=function(t,e,n,o){var r=t.length;if(0===r)return null;for(var i=[],a=0;a<r;a++){var l=t.item(a);if(l&&void 0!==l.dataset.index){var s=parseInt(l.dataset.index),u=parseFloat(l.dataset.knownSize),c=e(l,"offsetHeight");if(0===c&&o("Zero-sized element, this should not happen",{child:l},h.ERROR),c!==u){var m=i[i.length-1];0===i.length||m.size!==c||m.endIndex!==s-1?i.push({startIndex:s,endIndex:s,size:c}):i[i.length-1].endIndex++;}}}return i}(n.children,e,0,r),s=n.parentElement;!s.dataset.virtuosoScroller;)s=s.parentElement;var u="window"===s.firstElementChild.dataset.viewportType,c=a?a.scrollTop:u?window.pageYOffset||document.documentElement.scrollTop:s.scrollTop,m=a?a.scrollHeight:u?document.documentElement.scrollHeight:s.scrollHeight,d=a?a.offsetHeight:u?window.innerHeight:s.offsetHeight;o({scrollTop:Math.max(c,0),scrollHeight:m,viewportHeight:d}),null==i||i(function(t,e,n){return "normal"===e||null!=e&&e.endsWith("px")||n("row-gap was not resolved to pixel value correctly",e,h.WARN),"normal"===e?0:parseInt(null!=e?e:"0",10)}(0,getComputedStyle(n).rowGap,r)),null!==l&&t(l);},n)}function w(t,e){return Math.round(t.getBoundingClientRect()[e])}function x(t,e){return Math.abs(t-e)<1.01}function b(t,n,o,l,s){void 0===l&&(l=noop);var c=useRef(null),m=useRef(null),d=useRef(null),f=useRef(!1),p=useCallback(function(e){var o=e.target,r=o===window||o===document,i=r?window.pageYOffset||document.documentElement.scrollTop:o.scrollTop,a=r?document.documentElement.scrollHeight:o.scrollHeight,l=r?window.innerHeight:o.offsetHeight,s=function(){t({scrollTop:Math.max(i,0),scrollHeight:a,viewportHeight:l});};f.current?flushSync(s):s(),f.current=!1,null!==m.current&&(i===m.current||i<=0||i===a-l)&&(m.current=null,n(!0),d.current&&(clearTimeout(d.current),d.current=null));},[t,n]);return useEffect(function(){var t=s||c.current;return l(s||c.current),p({target:t}),t.addEventListener("scroll",p,{passive:!0}),function(){l(null),t.removeEventListener("scroll",p);}},[c,p,o,l,s]),{scrollerRef:c,scrollByCallback:function(t){f.current=!0,c.current.scrollBy(t);},scrollToCallback:function(e){var o=c.current;if(o&&(!("offsetHeight"in o)||0!==o.offsetHeight)){var r,i,a,l="smooth"===e.behavior;if(o===window?(i=Math.max(w(document.documentElement,"height"),document.documentElement.scrollHeight),r=window.innerHeight,a=document.documentElement.scrollTop):(i=o.scrollHeight,r=w(o,"height"),a=o.scrollTop),e.top=Math.ceil(Math.max(Math.min(i-r,e.top),0)),x(r,i)||e.top===a)return t({scrollTop:a,scrollHeight:i,viewportHeight:r}),void(l&&n(!0));l?(m.current=e.top,d.current&&clearTimeout(d.current),d.current=setTimeout(function(){d.current=null,m.current=null,n(!0);},1e3)):m.current=null,o.scrollTo(e);}}}}var y$1=system(function(){var t=stream(),n=stream(),o=statefulStream(0),r=stream(),i=statefulStream(0),a=stream(),l=stream(),s=statefulStream(0),u=statefulStream(0),c=statefulStream(0),m=statefulStream(0),d=stream(),f=stream(),p=statefulStream(!1),h=statefulStream(!1);return connect(pipe(t,map(function(t){return t.scrollTop})),n),connect(pipe(t,map(function(t){return t.scrollHeight})),l),connect(n,i),{scrollContainerState:t,scrollTop:n,viewportHeight:a,headerHeight:s,fixedHeaderHeight:u,fixedFooterHeight:c,footerHeight:m,scrollHeight:l,smoothScrollTargetReached:r,react18ConcurrentRendering:h,scrollTo:d,scrollBy:f,statefulScrollTop:i,deviation:o,scrollingInProgress:p}},[],{singleton:!0}),H$1={lvl:0};function E$1(t,e,n,o,r){return void 0===o&&(o=H$1),void 0===r&&(r=H$1),{k:t,v:e,lvl:n,l:o,r:r}}function R(t){return t===H$1}function L$1(){return H$1}function F$1(t,e){if(R(t))return H$1;var n=t.k,o=t.l,r=t.r;if(e===n){if(R(o))return r;if(R(r))return o;var i=O(o);return U$1(W(t,{k:i[0],v:i[1],l:M$1(o)}))}return U$1(W(t,e<n?{l:F$1(o,e)}:{r:F$1(r,e)}))}function k(t,e,n){if(void 0===n&&(n="k"),R(t))return [-Infinity,void 0];if(t[n]===e)return [t.k,t.v];if(t[n]<e){var o=k(t.r,e,n);return -Infinity===o[0]?[t.k,t.v]:o}return k(t.l,e,n)}function z$1(t,e,n){return R(t)?E$1(e,n,1):e===t.k?W(t,{k:e,v:n}):function(t){return D$1(G(t))}(W(t,e<t.k?{l:z$1(t.l,e,n)}:{r:z$1(t.r,e,n)}))}function B(t,e,n){if(R(t))return [];var o=t.k,r=t.v,i=t.r,a=[];return o>e&&(a=a.concat(B(t.l,e,n))),o>=e&&o<=n&&a.push({k:o,v:r}),o<=n&&(a=a.concat(B(i,e,n))),a}function P$1(t){return R(t)?[]:[].concat(P$1(t.l),[{k:t.k,v:t.v}],P$1(t.r))}function O(t){return R(t.r)?[t.k,t.v]:O(t.r)}function M$1(t){return R(t.r)?t.l:U$1(W(t,{r:M$1(t.r)}))}function W(t,e){return E$1(void 0!==e.k?e.k:t.k,void 0!==e.v?e.v:t.v,void 0!==e.lvl?e.lvl:t.lvl,void 0!==e.l?e.l:t.l,void 0!==e.r?e.r:t.r)}function V$1(t){return R(t)||t.lvl>t.r.lvl}function U$1(t){var e=t.l,n=t.r,o=t.lvl;if(n.lvl>=o-1&&e.lvl>=o-1)return t;if(o>n.lvl+1){if(V$1(e))return G(W(t,{lvl:o-1}));if(R(e)||R(e.r))throw new Error("Unexpected empty nodes");return W(e.r,{l:W(e,{r:e.r.l}),r:W(t,{l:e.r.r,lvl:o-1}),lvl:o})}if(V$1(t))return D$1(W(t,{lvl:o-1}));if(R(n)||R(n.l))throw new Error("Unexpected empty nodes");var r=n.l,i=V$1(r)?n.lvl-1:n.lvl;return W(r,{l:W(t,{r:r.l,lvl:o-1}),r:D$1(W(n,{l:r.r,lvl:i})),lvl:r.lvl+1})}function A$1(t,e,n){return R(t)?[]:N(B(t,k(t,e)[0],n),function(t){return {index:t.k,value:t.v}})}function N(t,e){var n=t.length;if(0===n)return [];for(var o=e(t[0]),r=o.index,i=o.value,a=[],l=1;l<n;l++){var s=e(t[l]),u=s.index,c=s.value;a.push({start:r,end:u-1,value:i}),r=u,i=c;}return a.push({start:r,end:Infinity,value:i}),a}function D$1(t){var e=t.r,n=t.lvl;return R(e)||R(e.r)||e.lvl!==n||e.r.lvl!==n?t:W(e,{l:W(t,{r:e.l}),lvl:n+1})}function G(t){var e=t.l;return R(e)||e.lvl!==t.lvl?t:W(e,{r:W(t,{l:e.r})})}function _$1(t,e,n,o){void 0===o&&(o=0);for(var r=t.length-1;o<=r;){var i=Math.floor((o+r)/2),a=n(t[i],e);if(0===a)return i;if(-1===a){if(r-o<2)return i-1;r=i-1;}else {if(r===o)return i;o=i+1;}}throw new Error("Failed binary finding record in array - "+t.join(",")+", searched for "+e)}function j(t,e,n){return t[_$1(t,e,n)]}var K=system(function(){return {recalcInProgress:statefulStream(!1)}},[],{singleton:!0});function Y$1(t){var e=t.size,n=t.startIndex,o=t.endIndex;return function(t){return t.start===n&&(t.end===o||Infinity===t.end)&&t.value===e}}function q(t,e){var n=t.index;return e===n?0:e<n?-1:1}function Z$1(t,e){var n=t.offset;return e===n?0:e<n?-1:1}function J(t){return {index:t.index,value:t}}function $$5(t,e,n,o){var r=t,i=0,a=0,l=0,s=0;if(0!==e){l=r[s=_$1(r,e-1,q)].offset;var u=k(n,e-1);i=u[0],a=u[1],r.length&&r[s].size===k(n,e)[1]&&(s-=1),r=r.slice(0,s+1);}else r=[];for(var c,m=f$2(A$1(n,e,Infinity));!(c=m()).done;){var d=c.value,p=d.start,h=d.value,g=p-i,v=g*a+l+g*o;r.push({offset:v,size:h,index:p}),i=p,l=v,a=h;}return {offsetTree:r,lastIndex:i,lastOffset:l,lastSize:a}}function Q(t,e){var n=e[0],o=e[1],r=e[3];n.length>0&&(0, e[2])("received item sizes",n,h.DEBUG);var i=t.sizeTree,a=i,l=0;if(o.length>0&&R(i)&&2===n.length){var s=n[0].size,u=n[1].size;a=o.reduce(function(t,e){return z$1(z$1(t,e,s),e+1,u)},a);}else {var c=function(t,e){for(var n,o=R(t)?0:Infinity,r=f$2(e);!(n=r()).done;){var i=n.value,a=i.size,l=i.startIndex,s=i.endIndex;if(o=Math.min(o,l),R(t))t=z$1(t,0,a);else {var u=A$1(t,l-1,s+1);if(!u.some(Y$1(i))){for(var c,m=!1,d=!1,p=f$2(u);!(c=p()).done;){var h=c.value,g=h.start,v=h.end,S=h.value;m?(s>=g||a===S)&&(t=F$1(t,g)):(d=S!==a,m=!0),v>s&&s>=g&&S!==a&&(t=z$1(t,s+1,S));}d&&(t=z$1(t,l,a));}}}return [t,o]}(a,n);a=c[0],l=c[1];}if(a===i)return t;var m=$$5(t.offsetTree,l,a,r),d=m.offsetTree;return {sizeTree:a,offsetTree:d,lastIndex:m.lastIndex,lastOffset:m.lastOffset,lastSize:m.lastSize,groupOffsetTree:o.reduce(function(t,e){return z$1(t,e,X$1(e,d,r))},L$1()),groupIndices:o}}function X$1(t,e,n){if(0===e.length)return 0;var o=j(e,t,q),r=t-o.index,i=o.size*r+(r-1)*n+o.offset;return i>0?i+n:i}function tt$1(t,e,n){if(function(t){return void 0!==t.groupIndex}(t))return e.groupIndices[t.groupIndex]+1;var o=et("LAST"===t.index?n:t.index,e);return Math.max(0,o,Math.min(n,o))}function et(t,e){if(!nt(e))return t;for(var n=0;e.groupIndices[n]<=t+n;)n++;return t+n}function nt(t){return !R(t.groupOffsetTree)}var ot={offsetHeight:"height",offsetWidth:"width"},rt=system(function(t){var n=t[0].log,o=t[1].recalcInProgress,r=stream(),i=stream(),a=statefulStreamFromEmitter(i,0),l=stream(),s=stream(),u=statefulStream(0),m=statefulStream([]),d=statefulStream(void 0),f=statefulStream(void 0),p=statefulStream(function(t,e){return w(t,ot[e])}),g=statefulStream(void 0),v=statefulStream(0),S={offsetTree:[],sizeTree:L$1(),groupOffsetTree:L$1(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]},C=statefulStreamFromEmitter(pipe(r,withLatestFrom(m,n,v),scan(Q,S),distinctUntilChanged()),S);connect(pipe(m,filter(function(t){return t.length>0}),withLatestFrom(C,v),map(function(t){var e=t[0],n=t[1],o=t[2],r=e.reduce(function(t,e,r){return z$1(t,e,X$1(e,n.offsetTree,o)||r)},L$1());return c$1({},n,{groupIndices:e,groupOffsetTree:r})})),C),connect(pipe(i,withLatestFrom(C),filter(function(t){return t[0]<t[1].lastIndex}),map(function(t){var e=t[1];return [{startIndex:t[0],endIndex:e.lastIndex,size:e.lastSize}]})),r),connect(d,f);var I=statefulStreamFromEmitter(pipe(d,map(function(t){return void 0===t})),!0);connect(pipe(f,filter(function(t){return void 0!==t&&R(getValue(C).sizeTree)}),map(function(t){return [{startIndex:0,endIndex:0,size:t}]})),r);var T=streamFromEmitter(pipe(r,withLatestFrom(C),scan(function(t,e){var n=e[1];return {changed:n!==t.sizes,sizes:n}},{changed:!1,sizes:S}),map(function(t){return t.changed})));subscribe(pipe(u,scan(function(t,e){return {diff:t.prev-e,prev:e}},{diff:0,prev:0}),map(function(t){return t.diff})),function(t){t>0?(publish(o,!0),publish(l,t)):t<0&&publish(s,t);}),subscribe(pipe(u,withLatestFrom(n)),function(t){t[0]<0&&(0, t[1])("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:u},h.ERROR);});var x=streamFromEmitter(l);connect(pipe(l,withLatestFrom(C),map(function(t){var e=t[0],n=t[1];if(n.groupIndices.length>0)throw new Error("Virtuoso: prepending items does not work with groups");return P$1(n.sizeTree).reduce(function(t,n){var o=n.k,r=n.v;return {ranges:[].concat(t.ranges,[{startIndex:t.prevIndex,endIndex:o+e-1,size:t.prevSize}]),prevIndex:o+e,prevSize:r}},{ranges:[],prevIndex:0,prevSize:n.lastSize}).ranges})),r);var b=streamFromEmitter(pipe(s,withLatestFrom(C,v),map(function(t){return X$1(-t[0],t[1].offsetTree,t[2])})));return connect(pipe(s,withLatestFrom(C,v),map(function(t){var e=t[0],n=t[1],o=t[2];if(n.groupIndices.length>0)throw new Error("Virtuoso: shifting items does not work with groups");var r=P$1(n.sizeTree).reduce(function(t,n){var o=n.v;return z$1(t,Math.max(0,n.k+e),o)},L$1());return c$1({},n,{sizeTree:r},$$5(n.offsetTree,0,r,o))})),C),{data:g,totalCount:i,sizeRanges:r,groupIndices:m,defaultItemSize:f,fixedItemSize:d,unshiftWith:l,shiftWith:s,shiftWithOffset:b,beforeUnshiftWith:x,firstItemIndex:u,gap:v,sizes:C,listRefresh:T,statefulTotalCount:a,trackItemSizes:I,itemSize:p}},tup(S$1,K),{singleton:!0}),it="undefined"!=typeof document&&"scrollBehavior"in document.documentElement.style;function at(t){var e="number"==typeof t?{index:t}:t;return e.align||(e.align="start"),e.behavior&&it||(e.behavior="auto"),e.offset||(e.offset=0),e}var lt=system(function(t){var n=t[0],o=n.sizes,r=n.totalCount,i=n.listRefresh,a=n.gap,l=t[1],s=l.scrollingInProgress,u=l.viewportHeight,c=l.scrollTo,m=l.smoothScrollTargetReached,d=l.headerHeight,f=l.footerHeight,p=l.fixedHeaderHeight,g=l.fixedFooterHeight,v=t[2].log,S=stream(),C=statefulStream(0),I=null,T=null,w=null;function x(){I&&(I(),I=null),w&&(w(),w=null),T&&(clearTimeout(T),T=null),publish(s,!1);}return connect(pipe(S,withLatestFrom(o,u,r,C,d,f,v),withLatestFrom(a,p,g),map(function(t){var n=t[0],o=n[0],r=n[1],a=n[2],l=n[3],u=n[4],c=n[5],d=n[6],f=n[7],p=t[1],g=t[2],v=t[3],C=at(o),b=C.align,y=C.behavior,H=C.offset,E=l-1,R=tt$1(C,r,E),L=X$1(R,r.offsetTree,p)+c;"end"===b?(L+=g+k(r.sizeTree,R)[1]-a+v,R===E&&(L+=d)):"center"===b?L+=(g+k(r.sizeTree,R)[1]-a+v)/2:L-=u,H&&(L+=H);var F=function(t){x(),t?(f("retrying to scroll to",{location:o},h.DEBUG),publish(S,o)):f("list did not change, scroll successful",{},h.DEBUG);};if(x(),"smooth"===y){var z=!1;w=subscribe(i,function(t){z=z||t;}),I=handleNext(m,function(){F(z);});}else I=handleNext(pipe(i,function(t){var e=setTimeout(function(){t(!1);},150);return function(n){n&&(t(!0),clearTimeout(e));}}),F);return T=setTimeout(function(){x();},1200),publish(s,!0),f("scrolling from index to",{index:R,top:L,behavior:y},h.DEBUG),{top:L,behavior:y}})),c),{scrollToIndex:S,topListHeight:C}},tup(rt,y$1,S$1),{singleton:!0}),st="up",ut={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollTop:0,viewportHeight:0,scrollHeight:0}},ct=system(function(t){var n=t[0],o=n.scrollContainerState,r=n.scrollTop,i=n.viewportHeight,a=n.headerHeight,l=n.footerHeight,s=n.scrollBy,u=statefulStream(!1),c=statefulStream(!0),m=stream(),d=stream(),f=statefulStream(4),p=statefulStream(0),h=statefulStreamFromEmitter(pipe(merge(pipe(duc(r),skip(1),mapTo(!0)),pipe(duc(r),skip(1),mapTo(!1),debounceTime(100))),distinctUntilChanged()),!1),g=statefulStreamFromEmitter(pipe(merge(pipe(s,mapTo(!0)),pipe(s,mapTo(!1),debounceTime(200))),distinctUntilChanged()),!1);connect(pipe(combineLatest(duc(r),duc(p)),map(function(t){return t[0]<=t[1]}),distinctUntilChanged()),c),connect(pipe(c,throttleTime(50)),d);var v=streamFromEmitter(pipe(combineLatest(o,duc(i),duc(a),duc(l),duc(f)),scan(function(t,e){var n,o,r=e[0],i=r.scrollTop,a=r.scrollHeight,l=e[1],s={viewportHeight:l,scrollTop:i,scrollHeight:a};return i+l-a>-e[4]?(i>t.state.scrollTop?(n="SCROLLED_DOWN",o=t.state.scrollTop-i):(n="SIZE_DECREASED",o=t.state.scrollTop-i||t.scrollTopDelta),{atBottom:!0,state:s,atBottomBecause:n,scrollTopDelta:o}):{atBottom:!1,notAtBottomBecause:s.scrollHeight>t.state.scrollHeight?"SIZE_INCREASED":l<t.state.viewportHeight?"VIEWPORT_HEIGHT_DECREASING":i<t.state.scrollTop?"SCROLLING_UPWARDS":"NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",state:s}},ut),distinctUntilChanged(function(t,e){return t&&t.atBottom===e.atBottom}))),S=statefulStreamFromEmitter(pipe(o,scan(function(t,e){var n=e.scrollTop,o=e.scrollHeight,r=e.viewportHeight;return x(t.scrollHeight,o)?{scrollTop:n,scrollHeight:o,jump:0,changed:!1}:t.scrollTop!==n&&o-(n+r)<1?{scrollHeight:o,scrollTop:n,jump:t.scrollTop-n,changed:!0}:{scrollHeight:o,scrollTop:n,jump:0,changed:!0}},{scrollHeight:0,jump:0,scrollTop:0,changed:!1}),filter(function(t){return t.changed}),map(function(t){return t.jump})),0);connect(pipe(v,map(function(t){return t.atBottom})),u),connect(pipe(u,throttleTime(50)),m);var C=statefulStream("down");connect(pipe(o,map(function(t){return t.scrollTop}),distinctUntilChanged(),scan(function(t,n){return getValue(g)?{direction:t.direction,prevScrollTop:n}:{direction:n<t.prevScrollTop?st:"down",prevScrollTop:n}},{direction:"down",prevScrollTop:0}),map(function(t){return t.direction})),C),connect(pipe(o,throttleTime(50),mapTo("none")),C);var I=statefulStream(0);return connect(pipe(h,filter(function(t){return !t}),mapTo(0)),I),connect(pipe(r,throttleTime(100),withLatestFrom(h),filter(function(t){return !!t[1]}),scan(function(t,e){return [t[1],e[0]]},[0,0]),map(function(t){return t[1]-t[0]})),I),{isScrolling:h,isAtTop:c,isAtBottom:u,atBottomState:v,atTopStateChange:d,atBottomStateChange:m,scrollDirection:C,atBottomThreshold:f,atTopThreshold:p,scrollVelocity:I,lastJumpDueToItemResize:S}},tup(y$1)),mt=system(function(t){var n=t[0].log,o=statefulStream(!1),r=streamFromEmitter(pipe(o,filter(function(t){return t}),distinctUntilChanged()));return subscribe(o,function(t){t&&getValue(n)("props updated",{},h.DEBUG);}),{propsReady:o,didMount:r}},tup(S$1),{singleton:!0}),dt=system(function(t){var n=t[0],o=n.sizes,r=n.listRefresh,i=n.defaultItemSize,a=t[1].scrollTop,l=t[2].scrollToIndex,s=t[3].didMount,u=statefulStream(!0),c=statefulStream(0);return connect(pipe(s,withLatestFrom(c),filter(function(t){return !!t[1]}),mapTo(!1)),u),subscribe(pipe(combineLatest(r,s),withLatestFrom(u,o,i),filter(function(t){var e=t[1],n=t[3];return t[0][1]&&(!R(t[2].sizeTree)||void 0!==n)&&!e}),withLatestFrom(c)),function(t){var n=t[1];setTimeout(function(){handleNext(a,function(){publish(u,!0);}),publish(l,n);});}),{scrolledToInitialItem:u,initialTopMostItemIndex:c}},tup(rt,y$1,lt,mt),{singleton:!0});function ft(t){return !!t&&("smooth"===t?"smooth":"auto")}var pt=system(function(t){var n=t[0],o=n.totalCount,r=n.listRefresh,i=t[1],a=i.isAtBottom,l=i.atBottomState,s=t[2].scrollToIndex,u=t[3].scrolledToInitialItem,c=t[4],m=c.propsReady,d=c.didMount,f=t[5].log,p=t[6].scrollingInProgress,g=statefulStream(!1),v=stream(),S=null;function C(t){publish(s,{index:"LAST",align:"end",behavior:t});}function I(t){var n=handleNext(l,function(n){!t||n.atBottom||"SIZE_INCREASED"!==n.notAtBottomBecause||S||(getValue(f)("scrolling to bottom due to increased size",{},h.DEBUG),C("auto"));});setTimeout(n,100);}return subscribe(pipe(combineLatest(pipe(duc(o),skip(1)),d),withLatestFrom(duc(g),a,u,p),map(function(t){var e=t[0],n=e[0],o=e[1]&&t[3],r="auto";return o&&(r=function(t,e){return "function"==typeof t?ft(t(e)):e&&ft(t)}(t[1],t[2]||t[4]),o=o&&!!r),{totalCount:n,shouldFollow:o,followOutputBehavior:r}}),filter(function(t){return t.shouldFollow})),function(t){var n=t.totalCount,o=t.followOutputBehavior;S&&(S(),S=null),S=handleNext(r,function(){getValue(f)("following output to ",{totalCount:n},h.DEBUG),C(o),S=null;});}),subscribe(pipe(combineLatest(duc(g),o,m),filter(function(t){return t[0]&&t[2]}),scan(function(t,e){var n=e[1];return {refreshed:t.value===n,value:n}},{refreshed:!1,value:0}),filter(function(t){return t.refreshed}),withLatestFrom(g,o)),function(t){I(!1!==t[1]);}),subscribe(v,function(){I(!1!==getValue(g));}),subscribe(combineLatest(duc(g),l),function(t){var e=t[1];t[0]&&!e.atBottom&&"VIEWPORT_HEIGHT_DECREASING"===e.notAtBottomBecause&&C("auto");}),{followOutput:g,autoscrollToBottom:v}},tup(rt,ct,lt,dt,mt,S$1,y$1));function ht(t){return t.reduce(function(t,e){return t.groupIndices.push(t.totalCount),t.totalCount+=e+1,t},{totalCount:0,groupIndices:[]})}var gt=system(function(t){var n=t[0],o=n.totalCount,r=n.groupIndices,i=n.sizes,a=t[1],l=a.scrollTop,s=a.headerHeight,u=stream(),c=stream(),m=streamFromEmitter(pipe(u,map(ht)));return connect(pipe(m,map(function(t){return t.totalCount})),o),connect(pipe(m,map(function(t){return t.groupIndices})),r),connect(pipe(combineLatest(l,i,s),filter(function(t){return nt(t[1])}),map(function(t){return k(t[1].groupOffsetTree,Math.max(t[0]-t[2],0),"v")[0]}),distinctUntilChanged(),map(function(t){return [t]})),c),{groupCounts:u,topItemsIndexes:c}},tup(rt,y$1));function vt(t,e){return !(!t||t[0]!==e[0]||t[1]!==e[1])}function St(t,e){return !(!t||t.startIndex!==e.startIndex||t.endIndex!==e.endIndex)}function Ct(t,e,n){return "number"==typeof t?n===st&&"top"===e||"down"===n&&"bottom"===e?t:0:n===st?"top"===e?t.main:t.reverse:"bottom"===e?t.main:t.reverse}function It(t,e){return "number"==typeof t?t:t[e]||0}var Tt=system(function(t){var n=t[0],o=n.scrollTop,r=n.viewportHeight,i=n.deviation,a=n.headerHeight,l=n.fixedHeaderHeight,s=stream(),u=statefulStream(0),c=statefulStream(0),m=statefulStream(0),d=statefulStreamFromEmitter(pipe(combineLatest(duc(o),duc(r),duc(a),duc(s,vt),duc(m),duc(u),duc(l),duc(i),duc(c)),map(function(t){var e=t[0],n=t[1],o=t[2],r=t[3],i=r[0],a=r[1],l=t[4],s=t[6],u=t[7],c=t[8],m=e-u,d=t[5]+s,f=Math.max(o-m,0),p="none",h=It(c,"top"),g=It(c,"bottom");return i-=u,a+=o+s,(i+=o+s)>e+d-h&&(p=st),(a-=u)<e-f+n+g&&(p="down"),"none"!==p?[Math.max(m-o-Ct(l,"top",p)-h,0),m-f-s+n+Ct(l,"bottom",p)+g]:null}),filter(function(t){return null!=t}),distinctUntilChanged(vt)),[0,0]);return {listBoundary:s,overscan:m,topListHeight:u,increaseViewportBy:c,visibleRange:d}},tup(y$1),{singleton:!0}),wt={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0,totalCount:0,firstItemIndex:0};function xt(t,e,n){if(0===t.length)return [];if(!nt(e))return t.map(function(t){return c$1({},t,{index:t.index+n,originalIndex:t.index})});for(var o,r=[],i=A$1(e.groupOffsetTree,t[0].index,t[t.length-1].index),a=void 0,l=0,s=f$2(t);!(o=s()).done;){var u=o.value;(!a||a.end<u.index)&&(a=i.shift(),l=e.groupIndices.indexOf(a.start)),r.push(c$1({},u.index===a.start?{type:"group",index:l}:{index:u.index-(l+1)+n,groupIndex:l},{size:u.size,offset:u.offset,originalIndex:u.index,data:u.data}));}return r}function bt(t,e,n,o,r,i){var a=0,l=0;if(t.length>0){a=t[0].offset;var s=t[t.length-1];l=s.offset+s.size;}var u=n-r.lastIndex,c=a,m=r.lastOffset+u*r.lastSize+(u-1)*o-l;return {items:xt(t,r,i),topItems:xt(e,r,i),topListHeight:e.reduce(function(t,e){return e.size+t},0),offsetTop:a,offsetBottom:m,top:c,bottom:l,totalCount:n,firstItemIndex:i}}var yt=system(function(t){var n=t[0],o=n.sizes,r=n.totalCount,i=n.data,a=n.firstItemIndex,l=n.gap,s=t[1],u=t[2],m=u.visibleRange,d=u.listBoundary,p=u.topListHeight,h=t[3],g=h.scrolledToInitialItem,v=h.initialTopMostItemIndex,S=t[4].topListHeight,C=t[5],I=t[6].didMount,T=t[7].recalcInProgress,w=statefulStream([]),x=stream();connect(s.topItemsIndexes,w);var b=statefulStreamFromEmitter(pipe(combineLatest(I,T,duc(m,vt),duc(r),duc(o),duc(v),g,duc(w),duc(a),duc(l),i),filter(function(t){return t[0]&&!t[1]}),map(function(t){var n=t[2],o=n[0],r=n[1],i=t[3],a=t[5],l=t[6],s=t[7],u=t[8],m=t[9],d=t[10],p=t[4],h=p.sizeTree,g=p.offsetTree;if(0===i||0===o&&0===r)return c$1({},wt,{totalCount:i});if(R(h))return bt(function(t,e,n){if(nt(e)){var o=et(t,e);return [{index:k(e.groupOffsetTree,o)[0],size:0,offset:0},{index:o,size:0,offset:0,data:n&&n[0]}]}return [{index:t,size:0,offset:0,data:n&&n[0]}]}(function(t,e){return "number"==typeof t?t:"LAST"===t.index?e-1:t.index}(a,i),p,d),[],i,m,p,u);var v=[];if(s.length>0)for(var S,C=s[0],I=s[s.length-1],T=0,w=f$2(A$1(h,C,I));!(S=w()).done;)for(var x=S.value,b=x.value,y=Math.max(x.start,C),H=Math.min(x.end,I),E=y;E<=H;E++)v.push({index:E,size:b,offset:T,data:d&&d[E]}),T+=b;if(!l)return bt([],v,i,m,p,u);var L=s.length>0?s[s.length-1]+1:0,F=function(t,e,n,o){return void 0===o&&(o=0),o>0&&(e=Math.max(e,j(t,o,q).offset)),N((i=n,l=_$1(r=t,e,a=Z$1),s=_$1(r,i,a,l),r.slice(l,s+1)),J);var r,i,a,l,s;}(g,o,r,L);if(0===F.length)return null;var z=i-1;return bt(tap([],function(t){for(var e,n=f$2(F);!(e=n()).done;){var i=e.value,a=i.value,l=a.offset,s=i.start,u=a.size;if(a.offset<o){var c=(s+=Math.floor((o-a.offset+m)/(u+m)))-i.start;l+=c*u+c*m;}s<L&&(l+=(L-s)*u,s=L);for(var p=Math.min(i.end,z),h=s;h<=p&&!(l>=r);h++)t.push({index:h,size:u,offset:l,data:d&&d[h]}),l+=u+m;}}),v,i,m,p,u)}),filter(function(t){return null!==t}),distinctUntilChanged()),wt);return connect(pipe(i,filter(function(t){return void 0!==t}),map(function(t){return t.length})),r),connect(pipe(b,map(function(t){return t.topListHeight})),S),connect(S,p),connect(pipe(b,map(function(t){return [t.top,t.bottom]})),d),connect(pipe(b,map(function(t){return t.items})),x),c$1({listState:b,topItemsIndexes:w,endReached:streamFromEmitter(pipe(b,filter(function(t){return t.items.length>0}),withLatestFrom(r,i),filter(function(t){var e=t[0].items;return e[e.length-1].originalIndex===t[1]-1}),map(function(t){return [t[1]-1,t[2]]}),distinctUntilChanged(vt),map(function(t){return t[0]}))),startReached:streamFromEmitter(pipe(b,throttleTime(200),filter(function(t){var e=t.items;return e.length>0&&e[0].originalIndex===t.topItems.length}),map(function(t){return t.items[0].index}),distinctUntilChanged())),rangeChanged:streamFromEmitter(pipe(b,filter(function(t){return t.items.length>0}),map(function(t){for(var e=t.items,n=0,o=e.length-1;"group"===e[n].type&&n<o;)n++;for(;"group"===e[o].type&&o>n;)o--;return {startIndex:e[n].index,endIndex:e[o].index}}),distinctUntilChanged(St))),itemsRendered:x},C)},tup(rt,gt,Tt,dt,lt,ct,mt,K),{singleton:!0}),Ht=system(function(t){var n=t[0],o=n.sizes,r=n.firstItemIndex,i=n.data,a=n.gap,l=t[1].listState,s=t[2].didMount,u=statefulStream(0);return connect(pipe(s,withLatestFrom(u),filter(function(t){return 0!==t[1]}),withLatestFrom(o,r,a,i),map(function(t){var e=t[0][1],n=t[1],o=t[2],r=t[3],i=t[4],a=void 0===i?[]:i,l=0;if(n.groupIndices.length>0)for(var s,u=f$2(n.groupIndices);!((s=u()).done||s.value-l>=e);)l++;var c=e+l;return bt(Array.from({length:c}).map(function(t,e){return {index:e,size:0,offset:0,data:a[e]}}),[],c,r,n,o)})),l),{initialItemCount:u}},tup(rt,yt,mt),{singleton:!0}),Et=system(function(t){var n=t[0].scrollVelocity,o=statefulStream(!1),r=stream(),i=statefulStream(!1);return connect(pipe(n,withLatestFrom(i,o,r),filter(function(t){return !!t[1]}),map(function(t){var e=t[0],n=t[1],o=t[2],r=t[3],i=n.enter;if(o){if((0, n.exit)(e,r))return !1}else if(i(e,r))return !0;return o}),distinctUntilChanged()),o),subscribe(pipe(combineLatest(o,n,r),withLatestFrom(i)),function(t){var e=t[0],n=t[1];return e[0]&&n&&n.change&&n.change(e[1],e[2])}),{isSeeking:o,scrollSeekConfiguration:i,scrollVelocity:n,scrollSeekRangeChanged:r}},tup(ct),{singleton:!0}),Rt=system(function(t){var n=t[0].topItemsIndexes,o=statefulStream(0);return connect(pipe(o,filter(function(t){return t>0}),map(function(t){return Array.from({length:t}).map(function(t,e){return e})})),n),{topItemCount:o}},tup(yt)),Lt=system(function(t){var n=t[0],o=n.footerHeight,r=n.headerHeight,i=n.fixedHeaderHeight,a=n.fixedFooterHeight,l=t[1].listState,s=stream(),u=statefulStreamFromEmitter(pipe(combineLatest(o,a,r,i,l),map(function(t){var e=t[4];return t[0]+t[1]+t[2]+t[3]+e.offsetBottom+e.bottom})),0);return connect(duc(u),s),{totalListHeight:u,totalListHeightChanged:s}},tup(y$1,yt),{singleton:!0});function Ft(t){var e,n=!1;return function(){return n||(n=!0,e=t()),e}}var kt=Ft(function(){return /iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)}),zt=system(function(t){var n=t[0],o=n.scrollBy,r=n.scrollTop,i=n.deviation,a=n.scrollingInProgress,l=t[1],s=l.isScrolling,u=l.isAtBottom,c=l.scrollDirection,m=t[3],d=m.beforeUnshiftWith,f=m.shiftWithOffset,p=m.sizes,g=m.gap,v=t[4].log,S=t[5].recalcInProgress,C=streamFromEmitter(pipe(t[2].listState,withLatestFrom(l.lastJumpDueToItemResize),scan(function(t,e){var n=t[1],o=e[0],r=o.items,i=o.totalCount,a=o.bottom+o.offsetBottom,l=0;return t[2]===i&&n.length>0&&r.length>0&&(0===r[0].originalIndex&&0===n[0].originalIndex||0!=(l=a-t[3])&&(l+=e[1])),[l,r,i,a]},[0,[],0,0]),filter(function(t){return 0!==t[0]}),withLatestFrom(r,c,a,u,v),filter(function(t){return !t[3]&&0!==t[1]&&t[2]===st}),map(function(t){var e=t[0][0];return (0, t[5])("Upward scrolling compensation",{amount:e},h.DEBUG),e})));function I(t){t>0?(publish(o,{top:-t,behavior:"auto"}),publish(i,0)):(publish(i,0),publish(o,{top:-t,behavior:"auto"}));}return subscribe(pipe(C,withLatestFrom(i,s)),function(t){var n=t[0],o=t[1];t[2]&&kt()?publish(i,o-n):I(-n);}),subscribe(pipe(combineLatest(statefulStreamFromEmitter(s,!1),i,S),filter(function(t){return !t[0]&&!t[2]&&0!==t[1]}),map(function(t){return t[1]}),throttleTime(1)),I),connect(pipe(f,map(function(t){return {top:-t}})),o),subscribe(pipe(d,withLatestFrom(p,g),map(function(t){var e=t[0];return e*t[1].lastSize+e*t[2]})),function(t){publish(i,t),requestAnimationFrame(function(){publish(o,{top:t}),requestAnimationFrame(function(){publish(i,0),publish(S,!1);});});}),{deviation:i}},tup(y$1,ct,yt,rt,S$1,K)),Bt=system(function(t){var n=t[0].totalListHeight,o=t[1].didMount,r=t[2].scrollTo,i=statefulStream(0);return subscribe(pipe(o,withLatestFrom(i),filter(function(t){return 0!==t[1]}),map(function(t){return {top:t[1]}})),function(t){handleNext(pipe(n,filter(function(t){return 0!==t})),function(){setTimeout(function(){publish(r,t);});});}),{initialScrollTop:i}},tup(Lt,mt,y$1),{singleton:!0}),Pt=system(function(t){var n=t[0].viewportHeight,o=t[1].totalListHeight,r=statefulStream(!1);return {alignToBottom:r,paddingTopAddition:statefulStreamFromEmitter(pipe(combineLatest(r,n,o),filter(function(t){return t[0]}),map(function(t){return Math.max(0,t[1]-t[2])}),distinctUntilChanged()),0)}},tup(y$1,Lt),{singleton:!0}),Ot=system(function(t){var n=t[0],o=n.scrollTo,r=n.scrollContainerState,i=stream(),a=stream(),l=stream(),s=statefulStream(!1),u=statefulStream(void 0);return connect(pipe(combineLatest(i,a),map(function(t){var e=t[0],n=e.viewportHeight,o=e.scrollHeight;return {scrollTop:Math.max(0,e.scrollTop-t[1].offsetTop),scrollHeight:o,viewportHeight:n}})),r),connect(pipe(o,withLatestFrom(a),map(function(t){var e=t[0];return c$1({},e,{top:e.top+t[1].offsetTop})})),l),{useWindowScroll:s,customScrollParent:u,windowScrollContainerState:i,windowViewportRect:a,windowScrollTo:l}},tup(y$1)),Mt=["done","behavior","align"],Wt=system(function(t){var n=t[0],o=n.sizes,r=n.totalCount,i=n.gap,a=t[1],l=a.scrollTop,s=a.viewportHeight,u=a.headerHeight,d=a.fixedHeaderHeight,f=a.fixedFooterHeight,p=a.scrollingInProgress,h=t[2].scrollToIndex,g=stream();return connect(pipe(g,withLatestFrom(o,s,r,u,d,f,l),withLatestFrom(i),map(function(t){var n=t[0],o=n[0],r=n[1],i=n[2],a=n[3],l=n[4],s=n[5],u=n[6],d=n[7],f=t[1],h=o.done,g=o.behavior,v=o.align,S=m(o,Mt),C=null,I=tt$1(o,r,a-1),T=X$1(I,r.offsetTree,f)+l+s;return T<d+s?C=c$1({},S,{behavior:g,align:null!=v?v:"start"}):T+k(r.sizeTree,I)[1]>d+i-u&&(C=c$1({},S,{behavior:g,align:null!=v?v:"end"})),C?h&&handleNext(pipe(p,skip(1),filter(function(t){return !1===t})),h):h&&h(),C}),filter(function(t){return null!==t})),h),{scrollIntoView:g}},tup(rt,y$1,lt,yt,S$1),{singleton:!0}),Vt=["listState","topItemsIndexes"],Ut=system(function(t){return c$1({},t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},tup(Tt,Ht,mt,Et,Lt,Bt,Pt,Ot,Wt)),At=system(function(t){var n=t[0],o=n.totalCount,r=n.sizeRanges,i=n.fixedItemSize,a=n.defaultItemSize,l=n.trackItemSizes,s=n.itemSize,u=n.data,d=n.firstItemIndex,f=n.groupIndices,p=n.statefulTotalCount,h=n.gap,g=t[1],v=g.initialTopMostItemIndex,S=g.scrolledToInitialItem,C=t[2],I=t[3],T=t[4],w=T.listState,x=T.topItemsIndexes,b=m(T,Vt),y=t[5].scrollToIndex,H=t[7].topItemCount,E=t[8].groupCounts,R=t[9],L=t[10];return connect(b.rangeChanged,R.scrollSeekRangeChanged),connect(pipe(R.windowViewportRect,map(function(t){return t.visibleHeight})),C.viewportHeight),c$1({totalCount:o,data:u,firstItemIndex:d,sizeRanges:r,initialTopMostItemIndex:v,scrolledToInitialItem:S,topItemsIndexes:x,topItemCount:H,groupCounts:E,fixedItemHeight:i,defaultItemHeight:a,gap:h},I,{statefulTotalCount:p,listState:w,scrollToIndex:y,trackItemSizes:l,itemSize:s,groupIndices:f},b,R,C,L)},tup(rt,dt,y$1,pt,yt,lt,zt,Rt,gt,Ut,S$1)),Nt=Ft(function(){if("undefined"==typeof document)return "sticky";var t=document.createElement("div");return t.style.position="-webkit-sticky","-webkit-sticky"===t.style.position?"-webkit-sticky":"sticky"});function Dt(t,e){var n=useRef(null),o=useCallback(function(o){if(null!==o&&o.offsetParent){var r,i,a=o.getBoundingClientRect(),l=a.width;if(e){var s=e.getBoundingClientRect(),u=a.top-s.top;r=s.height-Math.max(0,u),i=u+e.scrollTop;}else r=window.innerHeight-Math.max(0,a.top),i=a.top+window.pageYOffset;n.current={offsetTop:i,visibleHeight:r,visibleWidth:l},t(n.current);}},[t,e]),l=C(o),s=l.callbackRef,u=l.ref,c=useCallback(function(){o(u.current);},[o,u]);return useEffect(function(){if(e){e.addEventListener("scroll",c);var t=new ResizeObserver(c);return t.observe(e),function(){e.removeEventListener("scroll",c),t.unobserve(e);}}return window.addEventListener("scroll",c),window.addEventListener("resize",c),function(){window.removeEventListener("scroll",c),window.removeEventListener("resize",c);}},[c,e]),s}var Gt=React.createContext(void 0),_t=React.createContext(void 0),jt=["placeholder"],Kt=["style","children"],Yt=["style","children"];function qt(t){return t}var Zt=system(function(){var t=statefulStream(function(t){return "Item "+t}),n=statefulStream(null),o=statefulStream(function(t){return "Group "+t}),r=statefulStream({}),i=statefulStream(qt),a=statefulStream("div"),l=statefulStream(noop),s=function(t,n){return void 0===n&&(n=null),statefulStreamFromEmitter(pipe(r,map(function(e){return e[t]}),distinctUntilChanged()),n)};return {context:n,itemContent:t,groupContent:o,components:r,computeItemKey:i,headerFooterTag:a,scrollerRef:l,FooterComponent:s("Footer"),HeaderComponent:s("Header"),TopItemListComponent:s("TopItemList"),ListComponent:s("List","div"),ItemComponent:s("Item","div"),GroupComponent:s("Group","div"),ScrollerComponent:s("Scroller","div"),EmptyPlaceholder:s("EmptyPlaceholder"),ScrollSeekPlaceholder:s("ScrollSeekPlaceholder")}});function Jt(t,n){var o=stream();return subscribe(o,function(){return console.warn("react-virtuoso: You are using a deprecated property. "+n,"color: red;","color: inherit;","color: blue;")}),connect(o,t),o}var $t=system(function(t){var n=t[0],o=t[1],r={item:Jt(o.itemContent,"Rename the %citem%c prop to %citemContent."),group:Jt(o.groupContent,"Rename the %cgroup%c prop to %cgroupContent."),topItems:Jt(n.topItemCount,"Rename the %ctopItems%c prop to %ctopItemCount."),itemHeight:Jt(n.fixedItemHeight,"Rename the %citemHeight%c prop to %cfixedItemHeight."),scrollingStateChange:Jt(n.isScrolling,"Rename the %cscrollingStateChange%c prop to %cisScrolling."),adjustForPrependedItems:stream(),maxHeightCacheSize:stream(),footer:stream(),header:stream(),HeaderContainer:stream(),FooterContainer:stream(),ItemContainer:stream(),ScrollContainer:stream(),GroupContainer:stream(),ListContainer:stream(),emptyComponent:stream(),scrollSeek:stream()};function i(t,n,r){connect(pipe(t,withLatestFrom(o.components),map(function(t){var e,o=t[0],i=t[1];return console.warn("react-virtuoso: "+r+" property is deprecated. Pass components."+n+" instead."),c$1({},i,((e={})[n]=o,e))})),o.components);}return subscribe(r.adjustForPrependedItems,function(){console.warn("react-virtuoso: adjustForPrependedItems is no longer supported. Use the firstItemIndex property instead - https://virtuoso.dev/prepend-items.","color: red;","color: inherit;","color: blue;");}),subscribe(r.maxHeightCacheSize,function(){console.warn("react-virtuoso: maxHeightCacheSize is no longer necessary. Setting it has no effect - remove it from your code.");}),subscribe(r.HeaderContainer,function(){console.warn("react-virtuoso: HeaderContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the header component and pass components.Header to change its contents.");}),subscribe(r.FooterContainer,function(){console.warn("react-virtuoso: FooterContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the footer component and pass components.Footer to change its contents.");}),subscribe(r.scrollSeek,function(t){var r=t.placeholder,i=m(t,jt);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),publish(o.components,c$1({},getValue(o.components),{ScrollSeekPlaceholder:r})),publish(n.scrollSeekConfiguration,i);}),i(r.footer,"Footer","footer"),i(r.header,"Header","header"),i(r.ItemContainer,"Item","ItemContainer"),i(r.ListContainer,"List","ListContainer"),i(r.ScrollContainer,"Scroller","ScrollContainer"),i(r.emptyComponent,"EmptyPlaceholder","emptyComponent"),i(r.GroupContainer,"Group","GroupContainer"),c$1({},n,o,r)},tup(At,Zt)),Qt=function(t){return React.createElement("div",{style:{height:t.height}})},Xt={position:Nt(),zIndex:1,overflowAnchor:"none"},te={overflowAnchor:"none"},ee=React.memo(function(t){var o=t.showTopList,r=void 0!==o&&o,i=ge("listState"),a=he("sizeRanges"),s=ge("useWindowScroll"),u=ge("customScrollParent"),m=he("windowScrollContainerState"),d=he("scrollContainerState"),f=u||s?m:d,p=ge("itemContent"),h=ge("context"),g=ge("groupContent"),v=ge("trackItemSizes"),S=ge("itemSize"),C=ge("log"),I=he("gap"),w=T$1(a,S,v,r?noop:f,C,I,u).callbackRef,x=React.useState(0),b=x[0],y=x[1];ve("deviation",function(t){b!==t&&y(t);});var H=ge("EmptyPlaceholder"),E=ge("ScrollSeekPlaceholder")||Qt,R=ge("ListComponent"),L=ge("ItemComponent"),F=ge("GroupComponent"),k=ge("computeItemKey"),z=ge("isSeeking"),B=ge("groupIndices").length>0,P=ge("paddingTopAddition"),O=r?{}:{boxSizing:"border-box",paddingTop:i.offsetTop+P,paddingBottom:i.offsetBottom,marginTop:b};return !r&&0===i.totalCount&&H?createElement$2(H,ie(H,h)):createElement$2(R,c$1({},ie(R,h),{ref:w,style:O,"data-test-id":r?"virtuoso-top-item-list":"virtuoso-item-list"}),(r?i.topItems:i.items).map(function(t){var e=t.originalIndex,n=k(e+i.firstItemIndex,t.data,h);return z?createElement$2(E,c$1({},ie(E,h),{key:n,index:t.index,height:t.size,type:t.type||"item"},"group"===t.type?{}:{groupIndex:t.groupIndex})):"group"===t.type?createElement$2(F,c$1({},ie(F,h),{key:n,"data-index":e,"data-known-size":t.size,"data-item-index":t.index,style:Xt}),g(t.index)):createElement$2(L,c$1({},ie(L,h),{key:n,"data-index":e,"data-known-size":t.size,"data-item-index":t.index,"data-item-group-index":t.groupIndex,style:te}),B?p(t.index,t.groupIndex,t.data,h):p(t.index,t.data,h))}))}),ne={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},oe={width:"100%",height:"100%",position:"absolute",top:0},re={width:"100%",position:Nt(),top:0};function ie(t,e){if("string"!=typeof t)return {context:e}}var ae=React.memo(function(){var t=ge("HeaderComponent"),e=he("headerHeight"),n=ge("headerFooterTag"),o=I$1(function(t){return e(w(t,"height"))}),r=ge("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null}),le=React.memo(function(){var t=ge("FooterComponent"),e=he("footerHeight"),n=ge("headerFooterTag"),o=I$1(function(t){return e(w(t,"height"))}),r=ge("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null});function se(t){var e=t.usePublisher,o=t.useEmitter,r=t.useEmitterValue;return React.memo(function(t){var n=t.style,i=t.children,a=m(t,Kt),s=e("scrollContainerState"),u=r("ScrollerComponent"),d=e("smoothScrollTargetReached"),f=r("scrollerRef"),p=r("context"),h=b(s,d,u,f),g=h.scrollerRef,v=h.scrollByCallback;return o("scrollTo",h.scrollToCallback),o("scrollBy",v),createElement$2(u,c$1({ref:g,style:c$1({},ne,n),"data-test-id":"virtuoso-scroller","data-virtuoso-scroller":!0,tabIndex:0},a,ie(u,p)),i)})}function ue(t){var o=t.usePublisher,r=t.useEmitter,i=t.useEmitterValue;return React.memo(function(t){var n=t.style,a=t.children,s=m(t,Yt),u=o("windowScrollContainerState"),d=i("ScrollerComponent"),f=o("smoothScrollTargetReached"),p=i("totalListHeight"),h=i("deviation"),v=i("customScrollParent"),S=i("context"),C=b(u,f,d,noop,v),I=C.scrollerRef,T=C.scrollByCallback,w=C.scrollToCallback;return g(function(){return I.current=v||window,function(){I.current=null;}},[I,v]),r("windowScrollTo",w),r("scrollBy",T),createElement$2(d,c$1({style:c$1({position:"relative"},n,0!==p?{height:p+h}:{}),"data-virtuoso-scroller":!0},s,ie(d,S)),a)})}var ce=function(t){var o=t.children,r=useContext$1(Gt),i=he("viewportHeight"),a=he("fixedItemHeight"),l=I$1(compose(i,function(t){return w(t,"height")}));return React.useEffect(function(){r&&(i(r.viewportHeight),a(r.itemHeight));},[r,i,a]),React.createElement("div",{style:oe,ref:l,"data-viewport-type":"element"},o)},me=function(t){var e=t.children,o=useContext$1(Gt),r=he("windowViewportRect"),i=he("fixedItemHeight"),a=ge("customScrollParent"),l=Dt(r,a);return React.useEffect(function(){o&&(i(o.itemHeight),r({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}));},[o,r,i]),React.createElement("div",{ref:l,style:oe,"data-viewport-type":"window"},e)},de=function(t){var e=t.children,n=ge("TopItemListComponent"),o=ge("headerHeight"),r=c$1({},re,{marginTop:o+"px"}),i=ge("context");return createElement$2(n||"div",{style:r,context:i},e)},fe=systemToComponent($t,{required:{},optional:{context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",react18ConcurrentRendering:"react18ConcurrentRendering",item:"item",group:"group",topItems:"topItems",itemHeight:"itemHeight",scrollingStateChange:"scrollingStateChange",maxHeightCacheSize:"maxHeightCacheSize",footer:"footer",header:"header",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",GroupContainer:"GroupContainer",emptyComponent:"emptyComponent",HeaderContainer:"HeaderContainer",FooterContainer:"FooterContainer",scrollSeek:"scrollSeek"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",adjustForPrependedItems:"adjustForPrependedItems",autoscrollToBottom:"autoscrollToBottom"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},React.memo(function(t){var e=ge("useWindowScroll"),o=ge("topItemsIndexes").length>0,r=ge("customScrollParent"),i=r||e?me:ce;return React.createElement(r||e?Ce:Se,c$1({},t),React.createElement(i,null,React.createElement(ae,null),React.createElement(ee,null),React.createElement(le,null)),o&&React.createElement(de,null,React.createElement(ee,{showTopList:!0})))})),pe=fe.Component,he=fe.usePublisher,ge=fe.useEmitterValue,ve=fe.useEmitter,Se=se({usePublisher:he,useEmitterValue:ge,useEmitter:ve}),Ce=ue({usePublisher:he,useEmitterValue:ge,useEmitter:ve}),Ie={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},Te={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},we=Math.round,xe=Math.ceil,be=Math.floor,ye=Math.min,He=Math.max;function Ee(t,e,n){return Array.from({length:e-t+1}).map(function(e,o){return {index:o+t,data:null==n?void 0:n[o+t]}})}function Re(t,e){return t&&t.column===e.column&&t.row===e.row}var Le=system(function(t){var n=t[0],o=n.overscan,r=n.visibleRange,i=n.listBoundary,a=t[1],l=a.scrollTop,s=a.viewportHeight,u=a.scrollBy,m=a.scrollTo,d=a.smoothScrollTargetReached,f=a.scrollContainerState,p=a.footerHeight,h=a.headerHeight,g=t[2],v=t[3],S=t[4],C=S.propsReady,I=S.didMount,T=t[5],w=T.windowViewportRect,x=T.windowScrollTo,b=T.useWindowScroll,y=T.customScrollParent,H=T.windowScrollContainerState,E=t[6],R=statefulStream(0),L=statefulStream(0),F=statefulStream(Ie),k=statefulStream({height:0,width:0}),z=statefulStream({height:0,width:0}),B=stream(),P=stream(),O=statefulStream(0),M=statefulStream(void 0),W=statefulStream({row:0,column:0});connect(pipe(combineLatest(I,L,M),filter(function(t){return 0!==t[1]}),map(function(t){return {items:Ee(0,t[1]-1,t[2]),top:0,bottom:0,offsetBottom:0,offsetTop:0,itemHeight:0,itemWidth:0}})),F),connect(pipe(combineLatest(duc(R),r,duc(W,Re),duc(z,function(t,e){return t&&t.width===e.width&&t.height===e.height}),M),withLatestFrom(k),map(function(t){var e=t[0],n=e[0],o=e[1],r=o[0],i=o[1],a=e[2],l=e[3],s=e[4],u=t[1],m=a.row,d=a.column,f=l.height,p=l.width,h=u.width;if(0===n||0===h)return Ie;if(0===p)return function(t){return c$1({},Te,{items:t})}(Ee(0,0,s));var g=ze(h,p,d),v=g*be((r+m)/(f+m)),S=g*xe((i+m)/(f+m))-1;S=ye(n-1,He(S,g-1));var C=Ee(v=ye(S,He(0,v)),S,s),I=Fe(u,a,l,C),T=I.top,w=I.bottom,x=xe(n/g);return {items:C,offsetTop:T,offsetBottom:x*f+(x-1)*m-w,top:T,bottom:w,itemHeight:f,itemWidth:p}})),F),connect(pipe(M,filter(function(t){return void 0!==t}),map(function(t){return t.length})),R),connect(pipe(k,map(function(t){return t.height})),s),connect(pipe(combineLatest(k,z,F,W),map(function(t){var e=Fe(t[0],t[3],t[1],t[2].items);return [e.top,e.bottom]}),distinctUntilChanged(vt)),i);var V=streamFromEmitter(pipe(duc(F),filter(function(t){return t.items.length>0}),withLatestFrom(R),filter(function(t){var e=t[0].items;return e[e.length-1].index===t[1]-1}),map(function(t){return t[1]-1}),distinctUntilChanged())),U=streamFromEmitter(pipe(duc(F),filter(function(t){var e=t.items;return e.length>0&&0===e[0].index}),mapTo(0),distinctUntilChanged())),A=streamFromEmitter(pipe(duc(F),filter(function(t){return t.items.length>0}),map(function(t){var e=t.items;return {startIndex:e[0].index,endIndex:e[e.length-1].index}}),distinctUntilChanged(St)));connect(A,v.scrollSeekRangeChanged),connect(pipe(B,withLatestFrom(k,z,R,W),map(function(t){var e=t[1],n=t[2],o=t[3],r=t[4],i=at(t[0]),a=i.align,l=i.behavior,s=i.offset,u=i.index;"LAST"===u&&(u=o-1);var c=ke(e,r,n,u=He(0,u,ye(o-1,u)));return "end"===a?c=we(c-e.height+n.height):"center"===a&&(c=we(c-e.height/2+n.height/2)),s&&(c+=s),{top:c,behavior:l}})),m);var N=statefulStreamFromEmitter(pipe(F,map(function(t){return t.offsetBottom+t.bottom})),0);return connect(pipe(w,map(function(t){return {width:t.visibleWidth,height:t.visibleHeight}})),k),c$1({data:M,totalCount:R,viewportDimensions:k,itemDimensions:z,scrollTop:l,scrollHeight:P,overscan:o,scrollBy:u,scrollTo:m,scrollToIndex:B,smoothScrollTargetReached:d,windowViewportRect:w,windowScrollTo:x,useWindowScroll:b,customScrollParent:y,windowScrollContainerState:H,deviation:O,scrollContainerState:f,footerHeight:p,headerHeight:h,initialItemCount:L,gap:W},v,{gridState:F,totalListHeight:N},g,{startReached:U,endReached:V,rangeChanged:A,propsReady:C},E)},tup(Tt,y$1,ct,Et,mt,Ot,S$1));function Fe(t,e,n,o){var r=n.height;return void 0===r||0===o.length?{top:0,bottom:0}:{top:ke(t,e,n,o[0].index),bottom:ke(t,e,n,o[o.length-1].index)+r}}function ke(t,e,n,o){var r=ze(t.width,n.width,e.column),i=be(o/r),a=i*n.height+He(0,i-1)*e.row;return a>0?a+e.row:a}function ze(t,e,n){return He(1,be((t+n)/(e+n)))}var Be=["placeholder"],Pe=system(function(){var t=statefulStream(function(t){return "Item "+t}),n=statefulStream({}),o=statefulStream(null),r=statefulStream("virtuoso-grid-item"),i=statefulStream("virtuoso-grid-list"),a=statefulStream(qt),l=statefulStream("div"),s=statefulStream(noop),u=function(t,o){return void 0===o&&(o=null),statefulStreamFromEmitter(pipe(n,map(function(e){return e[t]}),distinctUntilChanged()),o)};return {context:o,itemContent:t,components:n,computeItemKey:a,itemClassName:r,listClassName:i,headerFooterTag:l,scrollerRef:s,FooterComponent:u("Footer"),HeaderComponent:u("Header"),ListComponent:u("List","div"),ItemComponent:u("Item","div"),ScrollerComponent:u("Scroller","div"),ScrollSeekPlaceholder:u("ScrollSeekPlaceholder","div")}}),Oe=system(function(t){var n=t[0],o=t[1],r={item:Jt(o.itemContent,"Rename the %citem%c prop to %citemContent."),ItemContainer:stream(),ScrollContainer:stream(),ListContainer:stream(),emptyComponent:stream(),scrollSeek:stream()};function i(t,n,r){connect(pipe(t,withLatestFrom(o.components),map(function(t){var e,o=t[0],i=t[1];return console.warn("react-virtuoso: "+r+" property is deprecated. Pass components."+n+" instead."),c$1({},i,((e={})[n]=o,e))})),o.components);}return subscribe(r.scrollSeek,function(t){var r=t.placeholder,i=m(t,Be);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),publish(o.components,c$1({},getValue(o.components),{ScrollSeekPlaceholder:r})),publish(n.scrollSeekConfiguration,i);}),i(r.ItemContainer,"Item","ItemContainer"),i(r.ListContainer,"List","ListContainer"),i(r.ScrollContainer,"Scroller","ScrollContainer"),c$1({},n,o,r)},tup(Le,Pe)),Me=React.memo(function(){var t=_e("gridState"),e=_e("listClassName"),n=_e("itemClassName"),o=_e("itemContent"),r=_e("computeItemKey"),i=_e("isSeeking"),a=Ge("scrollHeight"),s=_e("ItemComponent"),u=_e("ListComponent"),m=_e("ScrollSeekPlaceholder"),d=_e("context"),f=Ge("itemDimensions"),p=Ge("gap"),h=_e("log"),g=I$1(function(t){a(t.parentElement.parentElement.scrollHeight);var e=t.firstChild;e&&f(e.getBoundingClientRect()),p({row:qe("row-gap",getComputedStyle(t).rowGap,h),column:qe("column-gap",getComputedStyle(t).columnGap,h)});});return createElement$2(u,c$1({ref:g,className:e},ie(u,d),{style:{paddingTop:t.offsetTop,paddingBottom:t.offsetBottom}}),t.items.map(function(e){var a=r(e.index,e.data,d);return i?createElement$2(m,c$1({key:a},ie(m,d),{index:e.index,height:t.itemHeight,width:t.itemWidth})):createElement$2(s,c$1({},ie(s,d),{className:n,"data-index":e.index,key:a}),o(e.index,e.data,d))}))}),We=React.memo(function(){var t=_e("HeaderComponent"),e=Ge("headerHeight"),n=_e("headerFooterTag"),o=I$1(function(t){return e(w(t,"height"))}),r=_e("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null}),Ve=React.memo(function(){var t=_e("FooterComponent"),e=Ge("footerHeight"),n=_e("headerFooterTag"),o=I$1(function(t){return e(w(t,"height"))}),r=_e("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null}),Ue=function(t){var e=t.children,o=useContext$1(_t),r=Ge("itemDimensions"),i=Ge("viewportDimensions"),a=I$1(function(t){i(t.getBoundingClientRect());});return React.useEffect(function(){o&&(i({height:o.viewportHeight,width:o.viewportWidth}),r({height:o.itemHeight,width:o.itemWidth}));},[o,i,r]),React.createElement("div",{style:oe,ref:a},e)},Ae=function(t){var e=t.children,o=useContext$1(_t),r=Ge("windowViewportRect"),i=Ge("itemDimensions"),a=_e("customScrollParent"),l=Dt(r,a);return React.useEffect(function(){o&&(i({height:o.itemHeight,width:o.itemWidth}),r({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:o.viewportWidth}));},[o,r,i]),React.createElement("div",{ref:l,style:oe},e)},Ne=systemToComponent(Oe,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",item:"item",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",scrollSeek:"scrollSeek"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange"}},React.memo(function(t){var e=c$1({},t),o=_e("useWindowScroll"),r=_e("customScrollParent"),i=r||o?Ae:Ue;return React.createElement(r||o?Ye:Ke,c$1({},e),React.createElement(i,null,React.createElement(We,null),React.createElement(Me,null),React.createElement(Ve,null)))})),Ge=Ne.usePublisher,_e=Ne.useEmitterValue,je=Ne.useEmitter,Ke=se({usePublisher:Ge,useEmitterValue:_e,useEmitter:je}),Ye=ue({usePublisher:Ge,useEmitterValue:_e,useEmitter:je});function qe(t,e,n){return "normal"===e||null!=e&&e.endsWith("px")||n(t+" was not resolved to pixel value correctly",e,h.WARN),"normal"===e?0:parseInt(null!=e?e:"0",10)}var Ze=system(function(){var t=statefulStream(function(t){return React.createElement("td",null,"Item $",t)}),o=statefulStream(null),r=statefulStream(null),i=statefulStream(null),a=statefulStream({}),l=statefulStream(qt),s=statefulStream(noop),u=function(t,n){return void 0===n&&(n=null),statefulStreamFromEmitter(pipe(a,map(function(e){return e[t]}),distinctUntilChanged()),n)};return {context:o,itemContent:t,fixedHeaderContent:r,fixedFooterContent:i,components:a,computeItemKey:l,scrollerRef:s,TableComponent:u("Table","table"),TableHeadComponent:u("TableHead","thead"),TableFooterComponent:u("TableFoot","tfoot"),TableBodyComponent:u("TableBody","tbody"),TableRowComponent:u("TableRow","tr"),ScrollerComponent:u("Scroller","div"),EmptyPlaceholder:u("EmptyPlaceholder"),ScrollSeekPlaceholder:u("ScrollSeekPlaceholder"),FillerRow:u("FillerRow")}}),Je=system(function(t){return c$1({},t[0],t[1])},tup(At,Ze)),$e=function(t){return React.createElement("tr",null,React.createElement("td",{style:{height:t.height}}))},Qe=function(t){return React.createElement("tr",null,React.createElement("td",{style:{height:t.height,padding:0,border:0}}))},Xe=React.memo(function(){var t=an("listState"),e=rn("sizeRanges"),o=an("useWindowScroll"),r=an("customScrollParent"),i=rn("windowScrollContainerState"),a=rn("scrollContainerState"),s=r||o?i:a,u=an("itemContent"),m=an("trackItemSizes"),d=T$1(e,an("itemSize"),m,s,an("log"),void 0,r),f=d.callbackRef,p=d.ref,h=React.useState(0),g=h[0],v=h[1];ln("deviation",function(t){g!==t&&(p.current.style.marginTop=t+"px",v(t));});var S=an("EmptyPlaceholder"),C=an("ScrollSeekPlaceholder")||$e,I=an("FillerRow")||Qe,w=an("TableBodyComponent"),x=an("TableRowComponent"),b=an("computeItemKey"),y=an("isSeeking"),H=an("paddingTopAddition"),E=an("firstItemIndex"),R=an("statefulTotalCount"),L=an("context");if(0===R&&S)return createElement$2(S,ie(S,L));var F=t.offsetTop+H+g,k=t.offsetBottom,z=F>0?React.createElement(I,{height:F,key:"padding-top"}):null,B=k>0?React.createElement(I,{height:k,key:"padding-bottom"}):null,P=t.items.map(function(t){var e=t.originalIndex,n=b(e+E,t.data,L);return y?createElement$2(C,c$1({},ie(C,L),{key:n,index:t.index,height:t.size,type:t.type||"item"})):createElement$2(x,c$1({},ie(x,L),{key:n,"data-index":e,"data-known-size":t.size,"data-item-index":t.index,style:{overflowAnchor:"none"}}),u(t.index,t.data,L))});return createElement$2(w,c$1({ref:f,"data-test-id":"virtuoso-item-list"},ie(w,L)),[z].concat(P,[B]))}),tn=function(t){var o=t.children,r=useContext$1(Gt),i=rn("viewportHeight"),a=rn("fixedItemHeight"),l=I$1(compose(i,function(t){return w(t,"height")}));return React.useEffect(function(){r&&(i(r.viewportHeight),a(r.itemHeight));},[r,i,a]),React.createElement("div",{style:oe,ref:l,"data-viewport-type":"element"},o)},en=function(t){var e=t.children,o=useContext$1(Gt),r=rn("windowViewportRect"),i=rn("fixedItemHeight"),a=an("customScrollParent"),l=Dt(r,a);return React.useEffect(function(){o&&(i(o.itemHeight),r({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}));},[o,r,i]),React.createElement("div",{ref:l,style:oe,"data-viewport-type":"window"},e)},nn=systemToComponent(Je,{required:{},optional:{context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",react18ConcurrentRendering:"react18ConcurrentRendering"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},React.memo(function(t){var o=an("useWindowScroll"),r=an("customScrollParent"),i=rn("fixedHeaderHeight"),a=rn("fixedFooterHeight"),l=an("fixedHeaderContent"),s=an("fixedFooterContent"),u=an("context"),m=I$1(compose(i,function(t){return w(t,"height")})),d=I$1(compose(a,function(t){return w(t,"height")})),f=r||o?un:sn,p=r||o?en:tn,h=an("TableComponent"),g=an("TableHeadComponent"),v=an("TableFooterComponent"),S=l?React.createElement(g,c$1({key:"TableHead",style:{zIndex:1,position:"sticky",top:0},ref:m},ie(g,u)),l()):null,C=s?React.createElement(v,c$1({key:"TableFoot",style:{zIndex:1,position:"sticky",bottom:0},ref:d},ie(v,u)),s()):null;return React.createElement(f,c$1({},t),React.createElement(p,null,React.createElement(h,c$1({style:{borderSpacing:0}},ie(h,u)),[S,React.createElement(Xe,{key:"TableBody"}),C])))})),rn=nn.usePublisher,an=nn.useEmitterValue,ln=nn.useEmitter,sn=se({usePublisher:rn,useEmitterValue:an,useEmitter:ln}),un=ue({usePublisher:rn,useEmitterValue:an,useEmitter:ln}),cn=pe;
102361
+
102362
+ var call$1 = functionCall;
102363
+ var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic;
102364
+ var anObject$1 = anObject$l;
102365
+ var isNullOrUndefined$1 = isNullOrUndefined$b;
102366
+ var toLength$2 = toLength$a;
102367
+ var toString$3 = toString$n;
102368
+ var requireObjectCoercible$3 = requireObjectCoercible$f;
102369
+ var getMethod$1 = getMethod$8;
102370
+ var advanceStringIndex$1 = advanceStringIndex$3;
102371
+ var regExpExec$1 = regexpExecAbstract;
102372
+
102373
+ // @@match logic
102374
+ fixRegExpWellKnownSymbolLogic$1('match', function (MATCH, nativeMatch, maybeCallNative) {
102375
+ return [
102376
+ // `String.prototype.match` method
102377
+ // https://tc39.es/ecma262/#sec-string.prototype.match
102378
+ function match(regexp) {
102379
+ var O = requireObjectCoercible$3(this);
102380
+ var matcher = isNullOrUndefined$1(regexp) ? undefined : getMethod$1(regexp, MATCH);
102381
+ return matcher ? call$1(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$3(O));
102382
+ },
102383
+ // `RegExp.prototype[@@match]` method
102384
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
102385
+ function (string) {
102386
+ var rx = anObject$1(this);
102387
+ var S = toString$3(string);
102388
+ var res = maybeCallNative(nativeMatch, rx, S);
102389
+
102390
+ if (res.done) return res.value;
102391
+
102392
+ if (!rx.global) return regExpExec$1(rx, S);
102393
+
102394
+ var fullUnicode = rx.unicode;
102395
+ rx.lastIndex = 0;
102396
+ var A = [];
102397
+ var n = 0;
102398
+ var result;
102399
+ while ((result = regExpExec$1(rx, S)) !== null) {
102400
+ var matchStr = toString$3(result[0]);
102401
+ A[n] = matchStr;
102402
+ if (matchStr === '') rx.lastIndex = advanceStringIndex$1(S, toLength$2(rx.lastIndex), fullUnicode);
102403
+ n++;
102404
+ }
102405
+ return n === 0 ? null : A;
102406
+ }
102407
+ ];
102408
+ });
102409
+
102410
+ var toIntegerOrInfinity = toIntegerOrInfinity$c;
102411
+ var toString$2 = toString$n;
102412
+ var requireObjectCoercible$2 = requireObjectCoercible$f;
102413
+
102414
+ var $RangeError = RangeError;
102415
+
102416
+ // `String.prototype.repeat` method implementation
102417
+ // https://tc39.es/ecma262/#sec-string.prototype.repeat
102418
+ var stringRepeat = function repeat(count) {
102419
+ var str = toString$2(requireObjectCoercible$2(this));
102420
+ var result = '';
102421
+ var n = toIntegerOrInfinity(count);
102422
+ if (n < 0 || n === Infinity) throw new $RangeError('Wrong number of repetitions');
102423
+ for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
102424
+ return result;
102425
+ };
102426
+
102427
+ // https://github.com/tc39/proposal-string-pad-start-end
102428
+ var uncurryThis$3 = functionUncurryThis;
102429
+ var toLength$1 = toLength$a;
102430
+ var toString$1 = toString$n;
102431
+ var $repeat = stringRepeat;
102432
+ var requireObjectCoercible$1 = requireObjectCoercible$f;
102433
+
102434
+ var repeat = uncurryThis$3($repeat);
102435
+ var stringSlice$2 = uncurryThis$3(''.slice);
102436
+ var ceil = Math.ceil;
102437
+
102438
+ // `String.prototype.{ padStart, padEnd }` methods implementation
102439
+ var createMethod = function (IS_END) {
102440
+ return function ($this, maxLength, fillString) {
102441
+ var S = toString$1(requireObjectCoercible$1($this));
102442
+ var intMaxLength = toLength$1(maxLength);
102443
+ var stringLength = S.length;
102444
+ var fillStr = fillString === undefined ? ' ' : toString$1(fillString);
102445
+ var fillLen, stringFiller;
102446
+ if (intMaxLength <= stringLength || fillStr === '') return S;
102447
+ fillLen = intMaxLength - stringLength;
102448
+ stringFiller = repeat(fillStr, ceil(fillLen / fillStr.length));
102449
+ if (stringFiller.length > fillLen) stringFiller = stringSlice$2(stringFiller, 0, fillLen);
102450
+ return IS_END ? S + stringFiller : stringFiller + S;
102451
+ };
102452
+ };
102453
+
102454
+ var stringPad = {
102455
+ // `String.prototype.padStart` method
102456
+ // https://tc39.es/ecma262/#sec-string.prototype.padstart
102457
+ start: createMethod(false),
102458
+ // `String.prototype.padEnd` method
102459
+ // https://tc39.es/ecma262/#sec-string.prototype.padend
102460
+ end: createMethod(true)
102461
+ };
102462
+
102463
+ // https://github.com/zloirock/core-js/issues/280
102464
+ var userAgent = environmentUserAgent;
102465
+
102466
+ var stringPadWebkitBug = /Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(userAgent);
102467
+
102468
+ var $$4 = _export;
102469
+ var $padStart = stringPad.start;
102470
+ var WEBKIT_BUG = stringPadWebkitBug;
102471
+
102472
+ // `String.prototype.padStart` method
102473
+ // https://tc39.es/ecma262/#sec-string.prototype.padstart
102474
+ $$4({ target: 'String', proto: true, forced: WEBKIT_BUG }, {
102475
+ padStart: function padStart(maxLength /* , fillString = ' ' */) {
102476
+ return $padStart(this, maxLength, arguments.length > 1 ? arguments[1] : undefined);
102477
+ }
102478
+ });
102479
+
102480
+ var $$3 = _export;
102481
+ var lastIndexOf = arrayLastIndexOf;
102482
+
102483
+ // `Array.prototype.lastIndexOf` method
102484
+ // https://tc39.es/ecma262/#sec-array.prototype.lastindexof
102485
+ // eslint-disable-next-line es/no-array-prototype-lastindexof -- required for testing
102486
+ $$3({ target: 'Array', proto: true, forced: lastIndexOf !== [].lastIndexOf }, {
102487
+ lastIndexOf: lastIndexOf
102488
+ });
102489
+
102490
+ const M = {
102491
+ x: 0,
102492
+ y: 0,
102493
+ width: 0,
102494
+ height: 0,
102495
+ unit: "px"
102496
+ }, v = (o, e, t) => Math.min(Math.max(o, e), t), S = (...o) => o.filter((e) => e && typeof e == "string").join(" "), Y = (o, e) => o === e || o.width === e.width && o.height === e.height && o.x === e.x && o.y === e.y && o.unit === e.unit;
102497
+ function H(o, e, t, h) {
102498
+ const i = y(o, t, h);
102499
+ return o.width && (i.height = i.width / e), o.height && (i.width = i.height * e), i.y + i.height > h && (i.height = h - i.y, i.width = i.height * e), i.x + i.width > t && (i.width = t - i.x, i.height = i.width / e), o.unit === "%" ? D(i, t, h) : i;
102500
+ }
102501
+ function I(o, e, t) {
102502
+ const h = y(o, e, t);
102503
+ return h.x = (e - h.width) / 2, h.y = (t - h.height) / 2, o.unit === "%" ? D(h, e, t) : h;
102504
+ }
102505
+ function D(o, e, t) {
102506
+ return o.unit === "%" ? { ...M, ...o, unit: "%" } : {
102507
+ unit: "%",
102508
+ x: o.x ? o.x / e * 100 : 0,
102509
+ y: o.y ? o.y / t * 100 : 0,
102510
+ width: o.width ? o.width / e * 100 : 0,
102511
+ height: o.height ? o.height / t * 100 : 0
102512
+ };
102513
+ }
102514
+ function y(o, e, t) {
102515
+ return o.unit ? o.unit === "px" ? { ...M, ...o, unit: "px" } : {
102516
+ unit: "px",
102517
+ x: o.x ? o.x * e / 100 : 0,
102518
+ y: o.y ? o.y * t / 100 : 0,
102519
+ width: o.width ? o.width * e / 100 : 0,
102520
+ height: o.height ? o.height * t / 100 : 0
102521
+ } : { ...M, ...o, unit: "px" };
102522
+ }
102523
+ function P(o, e, t, h, i, n = 0, s = 0, w = h, a = i) {
102524
+ const r = { ...o };
102525
+ let c = Math.min(n, h), d = Math.min(s, i), g = Math.min(w, h), l = Math.min(a, i);
102526
+ e && (e > 1 ? (c = s ? s * e : c, d = c / e, g = w * e) : (d = n ? n / e : d, c = d * e, l = a / e)), r.y < 0 && (r.height = Math.max(r.height + r.y, d), r.y = 0), r.x < 0 && (r.width = Math.max(r.width + r.x, c), r.x = 0);
102527
+ const m = h - (r.x + r.width);
102528
+ m < 0 && (r.x = Math.min(r.x, h - c), r.width += m);
102529
+ const x = i - (r.y + r.height);
102530
+ if (x < 0 && (r.y = Math.min(r.y, i - d), r.height += x), r.width < c && ((t === "sw" || t == "nw") && (r.x -= c - r.width), r.width = c), r.height < d && ((t === "nw" || t == "ne") && (r.y -= d - r.height), r.height = d), r.width > g && ((t === "sw" || t == "nw") && (r.x -= g - r.width), r.width = g), r.height > l && ((t === "nw" || t == "ne") && (r.y -= l - r.height), r.height = l), e) {
102531
+ const b = r.width / r.height;
102532
+ if (b < e) {
102533
+ const C = Math.max(r.width / e, d);
102534
+ (t === "nw" || t == "ne") && (r.y -= C - r.height), r.height = C;
102535
+ } else if (b > e) {
102536
+ const C = Math.max(r.height * e, c);
102537
+ (t === "sw" || t == "nw") && (r.x -= C - r.width), r.width = C;
102538
+ }
102539
+ }
102540
+ return r;
102541
+ }
102542
+ function _(o, e, t, h) {
102543
+ const i = { ...o };
102544
+ return e === "ArrowLeft" ? h === "nw" ? (i.x -= t, i.y -= t, i.width += t, i.height += t) : h === "w" ? (i.x -= t, i.width += t) : h === "sw" ? (i.x -= t, i.width += t, i.height += t) : h === "ne" ? (i.y += t, i.width -= t, i.height -= t) : h === "e" ? i.width -= t : h === "se" && (i.width -= t, i.height -= t) : e === "ArrowRight" && (h === "nw" ? (i.x += t, i.y += t, i.width -= t, i.height -= t) : h === "w" ? (i.x += t, i.width -= t) : h === "sw" ? (i.x += t, i.width -= t, i.height -= t) : h === "ne" ? (i.y -= t, i.width += t, i.height += t) : h === "e" ? i.width += t : h === "se" && (i.width += t, i.height += t)), e === "ArrowUp" ? h === "nw" ? (i.x -= t, i.y -= t, i.width += t, i.height += t) : h === "n" ? (i.y -= t, i.height += t) : h === "ne" ? (i.y -= t, i.width += t, i.height += t) : h === "sw" ? (i.x += t, i.width -= t, i.height -= t) : h === "s" ? i.height -= t : h === "se" && (i.width -= t, i.height -= t) : e === "ArrowDown" && (h === "nw" ? (i.x += t, i.y += t, i.width -= t, i.height -= t) : h === "n" ? (i.y += t, i.height -= t) : h === "ne" ? (i.y += t, i.width -= t, i.height -= t) : h === "sw" ? (i.x -= t, i.width += t, i.height += t) : h === "s" ? i.height += t : h === "se" && (i.width += t, i.height += t)), i;
102545
+ }
102546
+ const f$1 = { capture: !0, passive: !1 };
102547
+ let $$2 = 0;
102548
+ const u$1 = class u extends PureComponent {
102549
+ constructor() {
102550
+ super(...arguments), this.docMoveBound = !1, this.mouseDownOnCrop = !1, this.dragStarted = !1, this.evData = {
102551
+ startClientX: 0,
102552
+ startClientY: 0,
102553
+ startCropX: 0,
102554
+ startCropY: 0,
102555
+ clientX: 0,
102556
+ clientY: 0,
102557
+ isResize: !0
102558
+ }, this.componentRef = createRef(), this.mediaRef = createRef(), this.initChangeCalled = !1, this.instanceId = `rc-${$$2++}`, this.state = {
102559
+ cropIsActive: !1,
102560
+ newCropIsBeingDrawn: !1
102561
+ }, this.onCropPointerDown = (e) => {
102562
+ const { crop: t, disabled: h } = this.props, i = this.getBox();
102563
+ if (!t)
102564
+ return;
102565
+ const n = y(t, i.width, i.height);
102566
+ if (h)
102567
+ return;
102568
+ e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
102569
+ const s = e.target.dataset.ord, w = !!s;
102570
+ let a = e.clientX, r = e.clientY, c = n.x, d = n.y;
102571
+ if (s) {
102572
+ const g = e.clientX - i.x, l = e.clientY - i.y;
102573
+ let m = 0, x = 0;
102574
+ s === "ne" || s == "e" ? (m = g - (n.x + n.width), x = l - n.y, c = n.x, d = n.y + n.height) : s === "se" || s === "s" ? (m = g - (n.x + n.width), x = l - (n.y + n.height), c = n.x, d = n.y) : s === "sw" || s == "w" ? (m = g - n.x, x = l - (n.y + n.height), c = n.x + n.width, d = n.y) : (s === "nw" || s == "n") && (m = g - n.x, x = l - n.y, c = n.x + n.width, d = n.y + n.height), a = c + i.x + m, r = d + i.y + x;
102575
+ }
102576
+ this.evData = {
102577
+ startClientX: a,
102578
+ startClientY: r,
102579
+ startCropX: c,
102580
+ startCropY: d,
102581
+ clientX: e.clientX,
102582
+ clientY: e.clientY,
102583
+ isResize: w,
102584
+ ord: s
102585
+ }, this.mouseDownOnCrop = !0, this.setState({ cropIsActive: !0 });
102586
+ }, this.onComponentPointerDown = (e) => {
102587
+ const { crop: t, disabled: h, locked: i, keepSelection: n, onChange: s } = this.props, w = this.getBox();
102588
+ if (h || i || n && t)
102589
+ return;
102590
+ e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
102591
+ const a = e.clientX - w.x, r = e.clientY - w.y, c = {
102592
+ unit: "px",
102593
+ x: a,
102594
+ y: r,
102595
+ width: 0,
102596
+ height: 0
102597
+ };
102598
+ this.evData = {
102599
+ startClientX: e.clientX,
102600
+ startClientY: e.clientY,
102601
+ startCropX: a,
102602
+ startCropY: r,
102603
+ clientX: e.clientX,
102604
+ clientY: e.clientY,
102605
+ isResize: !0
102606
+ }, this.mouseDownOnCrop = !0, s(y(c, w.width, w.height), D(c, w.width, w.height)), this.setState({ cropIsActive: !0, newCropIsBeingDrawn: !0 });
102607
+ }, this.onDocPointerMove = (e) => {
102608
+ const { crop: t, disabled: h, onChange: i, onDragStart: n } = this.props, s = this.getBox();
102609
+ if (h || !t || !this.mouseDownOnCrop)
102610
+ return;
102611
+ e.cancelable && e.preventDefault(), this.dragStarted || (this.dragStarted = !0, n && n(e));
102612
+ const { evData: w } = this;
102613
+ w.clientX = e.clientX, w.clientY = e.clientY;
102614
+ let a;
102615
+ w.isResize ? a = this.resizeCrop() : a = this.dragCrop(), Y(t, a) || i(
102616
+ y(a, s.width, s.height),
102617
+ D(a, s.width, s.height)
102618
+ );
102619
+ }, this.onComponentKeyDown = (e) => {
102620
+ const { crop: t, disabled: h, onChange: i, onComplete: n } = this.props;
102621
+ if (h)
102622
+ return;
102623
+ const s = e.key;
102624
+ let w = !1;
102625
+ if (!t)
102626
+ return;
102627
+ const a = this.getBox(), r = this.makePixelCrop(a), d = (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) ? u.nudgeStepLarge : e.shiftKey ? u.nudgeStepMedium : u.nudgeStep;
102628
+ if (s === "ArrowLeft" ? (r.x -= d, w = !0) : s === "ArrowRight" ? (r.x += d, w = !0) : s === "ArrowUp" ? (r.y -= d, w = !0) : s === "ArrowDown" && (r.y += d, w = !0), w) {
102629
+ e.cancelable && e.preventDefault(), r.x = v(r.x, 0, a.width - r.width), r.y = v(r.y, 0, a.height - r.height);
102630
+ const g = y(r, a.width, a.height), l = D(r, a.width, a.height);
102631
+ i(g, l), n && n(g, l);
102632
+ }
102633
+ }, this.onHandlerKeyDown = (e, t) => {
102634
+ const {
102635
+ aspect: h = 0,
102636
+ crop: i,
102637
+ disabled: n,
102638
+ minWidth: s = 0,
102639
+ minHeight: w = 0,
102640
+ maxWidth: a,
102641
+ maxHeight: r,
102642
+ onChange: c,
102643
+ onComplete: d
102644
+ } = this.props, g = this.getBox();
102645
+ if (n || !i)
102646
+ return;
102647
+ if (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight")
102648
+ e.stopPropagation(), e.preventDefault();
102649
+ else
102650
+ return;
102651
+ const m = (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) ? u.nudgeStepLarge : e.shiftKey ? u.nudgeStepMedium : u.nudgeStep, x = y(i, g.width, g.height), b = _(x, e.key, m, t), C = P(
102652
+ b,
102653
+ h,
102654
+ t,
102655
+ g.width,
102656
+ g.height,
102657
+ s,
102658
+ w,
102659
+ a,
102660
+ r
102661
+ );
102662
+ if (!Y(i, C)) {
102663
+ const R = D(C, g.width, g.height);
102664
+ c(C, R), d && d(C, R);
102665
+ }
102666
+ }, this.onDocPointerDone = (e) => {
102667
+ const { crop: t, disabled: h, onComplete: i, onDragEnd: n } = this.props, s = this.getBox();
102668
+ this.unbindDocMove(), !(h || !t) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, n && n(e), i && i(y(t, s.width, s.height), D(t, s.width, s.height)), this.setState({ cropIsActive: !1, newCropIsBeingDrawn: !1 }));
102669
+ }, this.onDragFocus = () => {
102670
+ var e;
102671
+ (e = this.componentRef.current) == null || e.scrollTo(0, 0);
102672
+ };
102673
+ }
102674
+ get document() {
102675
+ return document;
102676
+ }
102677
+ // We unfortunately get the bounding box every time as x+y changes
102678
+ // due to scrolling.
102679
+ getBox() {
102680
+ const e = this.mediaRef.current;
102681
+ if (!e)
102682
+ return { x: 0, y: 0, width: 0, height: 0 };
102683
+ const { x: t, y: h, width: i, height: n } = e.getBoundingClientRect();
102684
+ return { x: t, y: h, width: i, height: n };
102685
+ }
102686
+ componentDidUpdate(e) {
102687
+ const { crop: t, onComplete: h } = this.props;
102688
+ if (h && !e.crop && t) {
102689
+ const { width: i, height: n } = this.getBox();
102690
+ i && n && h(y(t, i, n), D(t, i, n));
102691
+ }
102692
+ }
102693
+ componentWillUnmount() {
102694
+ this.resizeObserver && this.resizeObserver.disconnect(), this.unbindDocMove();
102695
+ }
102696
+ bindDocMove() {
102697
+ this.docMoveBound || (this.document.addEventListener("pointermove", this.onDocPointerMove, f$1), this.document.addEventListener("pointerup", this.onDocPointerDone, f$1), this.document.addEventListener("pointercancel", this.onDocPointerDone, f$1), this.docMoveBound = !0);
102698
+ }
102699
+ unbindDocMove() {
102700
+ this.docMoveBound && (this.document.removeEventListener("pointermove", this.onDocPointerMove, f$1), this.document.removeEventListener("pointerup", this.onDocPointerDone, f$1), this.document.removeEventListener("pointercancel", this.onDocPointerDone, f$1), this.docMoveBound = !1);
102701
+ }
102702
+ getCropStyle() {
102703
+ const { crop: e } = this.props;
102704
+ if (e)
102705
+ return {
102706
+ top: `${e.y}${e.unit}`,
102707
+ left: `${e.x}${e.unit}`,
102708
+ width: `${e.width}${e.unit}`,
102709
+ height: `${e.height}${e.unit}`
102710
+ };
102711
+ }
102712
+ dragCrop() {
102713
+ const { evData: e } = this, t = this.getBox(), h = this.makePixelCrop(t), i = e.clientX - e.startClientX, n = e.clientY - e.startClientY;
102714
+ return h.x = v(e.startCropX + i, 0, t.width - h.width), h.y = v(e.startCropY + n, 0, t.height - h.height), h;
102715
+ }
102716
+ getPointRegion(e, t, h, i) {
102717
+ const { evData: n } = this, s = n.clientX - e.x, w = n.clientY - e.y;
102718
+ let a;
102719
+ i && t ? a = t === "nw" || t === "n" || t === "ne" : a = w < n.startCropY;
102720
+ let r;
102721
+ return h && t ? r = t === "nw" || t === "w" || t === "sw" : r = s < n.startCropX, r ? a ? "nw" : "sw" : a ? "ne" : "se";
102722
+ }
102723
+ resolveMinDimensions(e, t, h = 0, i = 0) {
102724
+ const n = Math.min(h, e.width), s = Math.min(i, e.height);
102725
+ return !t || !n && !s ? [n, s] : t > 1 ? n ? [n, n / t] : [s * t, s] : s ? [s * t, s] : [n, n / t];
102726
+ }
102727
+ resizeCrop() {
102728
+ const { evData: e } = this, { aspect: t = 0, maxWidth: h, maxHeight: i } = this.props, n = this.getBox(), [s, w] = this.resolveMinDimensions(n, t, this.props.minWidth, this.props.minHeight);
102729
+ let a = this.makePixelCrop(n);
102730
+ const r = this.getPointRegion(n, e.ord, s, w), c = e.ord || r;
102731
+ let d = e.clientX - e.startClientX, g = e.clientY - e.startClientY;
102732
+ (s && c === "nw" || c === "w" || c === "sw") && (d = Math.min(d, -s)), (w && c === "nw" || c === "n" || c === "ne") && (g = Math.min(g, -w));
102733
+ const l = {
102734
+ unit: "px",
102735
+ x: 0,
102736
+ y: 0,
102737
+ width: 0,
102738
+ height: 0
102739
+ };
102740
+ r === "ne" ? (l.x = e.startCropX, l.width = d, t ? (l.height = l.width / t, l.y = e.startCropY - l.height) : (l.height = Math.abs(g), l.y = e.startCropY - l.height)) : r === "se" ? (l.x = e.startCropX, l.y = e.startCropY, l.width = d, t ? l.height = l.width / t : l.height = g) : r === "sw" ? (l.x = e.startCropX + d, l.y = e.startCropY, l.width = Math.abs(d), t ? l.height = l.width / t : l.height = g) : r === "nw" && (l.x = e.startCropX + d, l.width = Math.abs(d), t ? (l.height = l.width / t, l.y = e.startCropY - l.height) : (l.height = Math.abs(g), l.y = e.startCropY + g));
102741
+ const m = P(
102742
+ l,
102743
+ t,
102744
+ r,
102745
+ n.width,
102746
+ n.height,
102747
+ s,
102748
+ w,
102749
+ h,
102750
+ i
102751
+ );
102752
+ return t || u.xyOrds.indexOf(c) > -1 ? a = m : u.xOrds.indexOf(c) > -1 ? (a.x = m.x, a.width = m.width) : u.yOrds.indexOf(c) > -1 && (a.y = m.y, a.height = m.height), a.x = v(a.x, 0, n.width - a.width), a.y = v(a.y, 0, n.height - a.height), a;
102753
+ }
102754
+ renderCropSelection() {
102755
+ const {
102756
+ ariaLabels: e = u.defaultProps.ariaLabels,
102757
+ disabled: t,
102758
+ locked: h,
102759
+ renderSelectionAddon: i,
102760
+ ruleOfThirds: n,
102761
+ crop: s
101563
102762
  } = this.props, w = this.getCropStyle();
101564
102763
  if (s)
101565
102764
  return /* @__PURE__ */ React__default.createElement(
@@ -101659,11 +102858,11 @@ const u$1 = class u extends PureComponent {
101659
102858
  );
101660
102859
  }
101661
102860
  makePixelCrop(e) {
101662
- const t = { ...M$1, ...this.props.crop || {} };
101663
- return y$1(t, e.width, e.height);
102861
+ const t = { ...M, ...this.props.crop || {} };
102862
+ return y(t, e.width, e.height);
101664
102863
  }
101665
102864
  render() {
101666
- const { aspect: e, children: t, circularCrop: h, className: i, crop: n, disabled: s, locked: w, style: a, ruleOfThirds: r } = this.props, { cropIsActive: c, newCropIsBeingDrawn: d } = this.state, g = n ? this.renderCropSelection() : null, l = S$1(
102865
+ const { aspect: e, children: t, circularCrop: h, className: i, crop: n, disabled: s, locked: w, style: a, ruleOfThirds: r } = this.props, { cropIsActive: c, newCropIsBeingDrawn: d } = this.state, g = n ? this.renderCropSelection() : null, l = S(
101667
102866
  "ReactCrop",
101668
102867
  i,
101669
102868
  c && "ReactCrop--active",
@@ -101710,7 +102909,7 @@ u$1.xOrds = ["e", "w"], u$1.yOrds = ["n", "s"], u$1.xyOrds = ["nw", "ne", "se",
101710
102909
  wDragHandle: "Use the up and down arrow keys to move the west drag handle to change the crop selection area"
101711
102910
  }
101712
102911
  };
101713
- let X$1 = u$1;
102912
+ let X = u$1;
101714
102913
 
101715
102914
  // List of valid entities
101716
102915
  //
@@ -121520,7 +122719,7 @@ function requireD () {
121520
122719
  + 'pragma private protected public pure ref return scope shared static struct '
121521
122720
  + 'super switch synchronized template this throw try typedef typeid typeof union '
121522
122721
  + 'unittest version void volatile while with __FILE__ __LINE__ __gshared|10 '
121523
- + '__thread __traits __DATE__ __EOF__ __TIME__ __TIMESTAMP__ __VENDOR__ "0.10.23"',
122722
+ + '__thread __traits __DATE__ __EOF__ __TIME__ __TIMESTAMP__ __VENDOR__ "0.10.24"',
121524
122723
  built_in:
121525
122724
  'bool cdouble cent cfloat char creal dchar delegate double dstring float function '
121526
122725
  + 'idouble ifloat ireal long real short string ubyte ucent uint ulong ushort wchar '
@@ -169933,20 +171132,20 @@ var HighlightJS = /*@__PURE__*/getDefaultExportFromCjs(lib);
169933
171132
 
169934
171133
  // https://nodejs.org/api/packages.html#packages_writing_dual_packages_while_avoiding_or_minimizing_hazards
169935
171134
 
169936
- var $$2 = _export;
171135
+ var $$1 = _export;
169937
171136
  var fill = arrayFill$1;
169938
171137
  var addToUnscopables = addToUnscopables$5;
169939
171138
 
169940
171139
  // `Array.prototype.fill` method
169941
171140
  // https://tc39.es/ecma262/#sec-array.prototype.fill
169942
- $$2({ target: 'Array', proto: true }, {
171141
+ $$1({ target: 'Array', proto: true }, {
169943
171142
  fill: fill
169944
171143
  });
169945
171144
 
169946
171145
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
169947
171146
  addToUnscopables('fill');
169948
171147
 
169949
- var call$1 = functionCall;
171148
+ var call = functionCall;
169950
171149
  var uncurryThis$2 = functionUncurryThis;
169951
171150
  var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
169952
171151
  var anObject = anObject$l;
@@ -169990,7 +171189,7 @@ var BUGGY = 'abbc'.split(/(b)*/)[1] === 'c' ||
169990
171189
  // @@split logic
169991
171190
  fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
169992
171191
  var internalSplit = '0'.split(undefined, 0).length ? function (separator, limit) {
169993
- return separator === undefined && limit === 0 ? [] : call$1(nativeSplit, this, separator, limit);
171192
+ return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit);
169994
171193
  } : nativeSplit;
169995
171194
 
169996
171195
  return [
@@ -170000,8 +171199,8 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
170000
171199
  var O = requireObjectCoercible(this);
170001
171200
  var splitter = isNullOrUndefined(separator) ? undefined : getMethod(separator, SPLIT);
170002
171201
  return splitter
170003
- ? call$1(splitter, separator, O, limit)
170004
- : call$1(internalSplit, toString(O), separator, limit);
171202
+ ? call(splitter, separator, O, limit)
171203
+ : call(internalSplit, toString(O), separator, limit);
170005
171204
  },
170006
171205
  // `RegExp.prototype[@@split]` method
170007
171206
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
@@ -170942,21 +172141,21 @@ var EOF = -1;
170942
172141
  var ZERO = 0x0030;
170943
172142
  var a$1 = 0x0061;
170944
172143
  var e = 0x0065;
170945
- var f$1 = 0x0066;
172144
+ var f = 0x0066;
170946
172145
  var u = 0x0075;
170947
- var z$1 = 0x007a;
170948
- var A$1 = 0x0041;
170949
- var E$1 = 0x0045;
170950
- var F$1 = 0x0046;
170951
- var U$1 = 0x0055;
170952
- var Z$1 = 0x005a;
172146
+ var z = 0x007a;
172147
+ var A = 0x0041;
172148
+ var E = 0x0045;
172149
+ var F = 0x0046;
172150
+ var U = 0x0055;
172151
+ var Z = 0x005a;
170953
172152
  var isDigit = function (codePoint) { return codePoint >= ZERO && codePoint <= 0x0039; };
170954
172153
  var isSurrogateCodePoint = function (codePoint) { return codePoint >= 0xd800 && codePoint <= 0xdfff; };
170955
172154
  var isHex = function (codePoint) {
170956
- return isDigit(codePoint) || (codePoint >= A$1 && codePoint <= F$1) || (codePoint >= a$1 && codePoint <= f$1);
172155
+ return isDigit(codePoint) || (codePoint >= A && codePoint <= F) || (codePoint >= a$1 && codePoint <= f);
170957
172156
  };
170958
- var isLowerCaseLetter = function (codePoint) { return codePoint >= a$1 && codePoint <= z$1; };
170959
- var isUpperCaseLetter = function (codePoint) { return codePoint >= A$1 && codePoint <= Z$1; };
172157
+ var isLowerCaseLetter = function (codePoint) { return codePoint >= a$1 && codePoint <= z; };
172158
+ var isUpperCaseLetter = function (codePoint) { return codePoint >= A && codePoint <= Z; };
170960
172159
  var isLetter = function (codePoint) { return isLowerCaseLetter(codePoint) || isUpperCaseLetter(codePoint); };
170961
172160
  var isNonASCIICodePoint = function (codePoint) { return codePoint >= CONTROL; };
170962
172161
  var isWhiteSpace = function (codePoint) {
@@ -171027,7 +172226,7 @@ var stringToNumber = function (codePoints) {
171027
172226
  }
171028
172227
  var fracd = fraction.length;
171029
172228
  var frac = fracd ? parseInt(fromCodePoint$1.apply(void 0, fraction), 10) : 0;
171030
- if (codePoints[c] === E$1 || codePoints[c] === e) {
172229
+ if (codePoints[c] === E || codePoints[c] === e) {
171031
172230
  c++;
171032
172231
  }
171033
172232
  var expsign = 1;
@@ -171218,7 +172417,7 @@ var Tokenizer = /** @class */ (function () {
171218
172417
  case RIGHT_CURLY_BRACKET:
171219
172418
  return RIGHT_CURLY_BRACKET_TOKEN;
171220
172419
  case u:
171221
- case U$1:
172420
+ case U:
171222
172421
  var u1 = this.peekCodePoint(0);
171223
172422
  var u2 = this.peekCodePoint(1);
171224
172423
  if (u1 === PLUS_SIGN && (isHex(u2) || u2 === QUESTION_MARK)) {
@@ -171288,7 +172487,7 @@ var Tokenizer = /** @class */ (function () {
171288
172487
  }
171289
172488
  if (questionMarks) {
171290
172489
  var start_1 = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? ZERO : digit); })), 16);
171291
- var end = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F$1 : digit); })), 16);
172490
+ var end = parseInt(fromCodePoint$1.apply(void 0, digits.map(function (digit) { return (digit === QUESTION_MARK ? F : digit); })), 16);
171292
172491
  return { type: 30 /* UNICODE_RANGE_TOKEN */, start: start_1, end: end };
171293
172492
  }
171294
172493
  var start = parseInt(fromCodePoint$1.apply(void 0, digits), 16);
@@ -171453,7 +172652,7 @@ var Tokenizer = /** @class */ (function () {
171453
172652
  c1 = this.peekCodePoint(0);
171454
172653
  c2 = this.peekCodePoint(1);
171455
172654
  var c3 = this.peekCodePoint(2);
171456
- if ((c1 === E$1 || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {
172655
+ if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {
171457
172656
  repr.push(this.consumeCodePoint(), this.consumeCodePoint());
171458
172657
  type = FLAG_NUMBER;
171459
172658
  while (isDigit(this.peekCodePoint(0))) {
@@ -174079,9 +175278,9 @@ var LF = 3;
174079
175278
  var Control = 4;
174080
175279
  var Extend = 5;
174081
175280
  var SpacingMark = 7;
174082
- var L$1 = 8;
174083
- var V$1 = 9;
174084
- var T$1 = 10;
175281
+ var L = 8;
175282
+ var V = 9;
175283
+ var T = 10;
174085
175284
  var LV = 11;
174086
175285
  var LVT = 12;
174087
175286
  var ZWJ = 13;
@@ -174163,15 +175362,15 @@ var _graphemeBreakAtIndex = function (_codePoints, classTypes, index) {
174163
175362
  }
174164
175363
  // Do not break Hangul syllable sequences.
174165
175364
  // GB6
174166
- if (current === L$1 && [L$1, V$1, LV, LVT].indexOf(next) !== -1) {
175365
+ if (current === L && [L, V, LV, LVT].indexOf(next) !== -1) {
174167
175366
  return BREAK_NOT_ALLOWED;
174168
175367
  }
174169
175368
  // GB7
174170
- if ((current === LV || current === V$1) && (next === V$1 || next === T$1)) {
175369
+ if ((current === LV || current === V) && (next === V || next === T)) {
174171
175370
  return BREAK_NOT_ALLOWED;
174172
175371
  }
174173
175372
  // GB8
174174
- if ((current === LVT || current === T$1) && next === T$1) {
175373
+ if ((current === LVT || current === T) && next === T) {
174175
175374
  return BREAK_NOT_ALLOWED;
174176
175375
  }
174177
175376
  // GB9 Do not break before extending characters or ZWJ.
@@ -177887,7 +179086,7 @@ var uncurryThis$1 = functionUncurryThis;
177887
179086
  // https://tc39.es/ecma262/#sec-thisnumbervalue
177888
179087
  var thisNumberValue$1 = uncurryThis$1(1.0.valueOf);
177889
179088
 
177890
- var $$1 = _export;
179089
+ var $ = _export;
177891
179090
  var IS_PURE = isPure;
177892
179091
  var DESCRIPTORS = descriptors;
177893
179092
  var globalThis$1 = globalThis_1;
@@ -177979,7 +179178,7 @@ var NumberWrapper = function Number(value) {
177979
179178
  NumberWrapper.prototype = NumberPrototype;
177980
179179
  if (FORCED && !IS_PURE) NumberPrototype.constructor = NumberWrapper;
177981
179180
 
177982
- $$1({ global: true, constructor: true, wrap: true, forced: FORCED }, {
179181
+ $({ global: true, constructor: true, wrap: true, forced: FORCED }, {
177983
179182
  Number: NumberWrapper
177984
179183
  });
177985
179184
 
@@ -178091,23 +179290,23 @@ function _defineProperty(obj, key, value) {
178091
179290
  return obj;
178092
179291
  }
178093
179292
  function _toConsumableArray(arr) {
178094
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();
179293
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
178095
179294
  }
178096
179295
  function _arrayWithoutHoles(arr) {
178097
- if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
179296
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
178098
179297
  }
178099
179298
  function _iterableToArray(iter) {
178100
179299
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
178101
179300
  }
178102
- function _unsupportedIterableToArray$1(o, minLen) {
179301
+ function _unsupportedIterableToArray(o, minLen) {
178103
179302
  if (!o) return;
178104
- if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
179303
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
178105
179304
  var n = Object.prototype.toString.call(o).slice(8, -1);
178106
179305
  if (n === "Object" && o.constructor) n = o.constructor.name;
178107
179306
  if (n === "Map" || n === "Set") return Array.from(o);
178108
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
179307
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
178109
179308
  }
178110
- function _arrayLikeToArray$1(arr, len) {
179309
+ function _arrayLikeToArray(arr, len) {
178111
179310
  if (len == null || len > arr.length) len = arr.length;
178112
179311
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
178113
179312
  return arr2;
@@ -180644,1826 +181843,627 @@ var methods = {
180644
181843
  * Set the canvas position and size with new data.
180645
181844
  * @param {Object} data - The new canvas data.
180646
181845
  * @returns {Cropper} this
180647
- */
180648
- setCanvasData: function setCanvasData(data) {
180649
- var canvasData = this.canvasData;
180650
- var aspectRatio = canvasData.aspectRatio;
180651
- if (this.ready && !this.disabled && isPlainObject(data)) {
180652
- if (isNumber(data.left)) {
180653
- canvasData.left = data.left;
180654
- }
180655
- if (isNumber(data.top)) {
180656
- canvasData.top = data.top;
180657
- }
180658
- if (isNumber(data.width)) {
180659
- canvasData.width = data.width;
180660
- canvasData.height = data.width / aspectRatio;
180661
- } else if (isNumber(data.height)) {
180662
- canvasData.height = data.height;
180663
- canvasData.width = data.height * aspectRatio;
180664
- }
180665
- this.renderCanvas(true);
180666
- }
180667
- return this;
180668
- },
180669
- /**
180670
- * Get the crop box position and size data.
180671
- * @returns {Object} The result crop box data.
180672
- */
180673
- getCropBoxData: function getCropBoxData() {
180674
- var cropBoxData = this.cropBoxData;
180675
- var data;
180676
- if (this.ready && this.cropped) {
180677
- data = {
180678
- left: cropBoxData.left,
180679
- top: cropBoxData.top,
180680
- width: cropBoxData.width,
180681
- height: cropBoxData.height
180682
- };
180683
- }
180684
- return data || {};
180685
- },
180686
- /**
180687
- * Set the crop box position and size with new data.
180688
- * @param {Object} data - The new crop box data.
180689
- * @returns {Cropper} this
180690
- */
180691
- setCropBoxData: function setCropBoxData(data) {
180692
- var cropBoxData = this.cropBoxData;
180693
- var aspectRatio = this.options.aspectRatio;
180694
- var widthChanged;
180695
- var heightChanged;
180696
- if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) {
180697
- if (isNumber(data.left)) {
180698
- cropBoxData.left = data.left;
180699
- }
180700
- if (isNumber(data.top)) {
180701
- cropBoxData.top = data.top;
180702
- }
180703
- if (isNumber(data.width) && data.width !== cropBoxData.width) {
180704
- widthChanged = true;
180705
- cropBoxData.width = data.width;
180706
- }
180707
- if (isNumber(data.height) && data.height !== cropBoxData.height) {
180708
- heightChanged = true;
180709
- cropBoxData.height = data.height;
180710
- }
180711
- if (aspectRatio) {
180712
- if (widthChanged) {
180713
- cropBoxData.height = cropBoxData.width / aspectRatio;
180714
- } else if (heightChanged) {
180715
- cropBoxData.width = cropBoxData.height * aspectRatio;
180716
- }
180717
- }
180718
- this.renderCropBox();
180719
- }
180720
- return this;
180721
- },
180722
- /**
180723
- * Get a canvas drawn the cropped image.
180724
- * @param {Object} [options={}] - The config options.
180725
- * @returns {HTMLCanvasElement} - The result canvas.
180726
- */
180727
- getCroppedCanvas: function getCroppedCanvas() {
180728
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
180729
- if (!this.ready || !window.HTMLCanvasElement) {
180730
- return null;
180731
- }
180732
- var canvasData = this.canvasData;
180733
- var source = getSourceCanvas(this.image, this.imageData, canvasData, options);
180734
-
180735
- // Returns the source canvas if it is not cropped.
180736
- if (!this.cropped) {
180737
- return source;
180738
- }
180739
- var _this$getData = this.getData(options.rounded),
180740
- initialX = _this$getData.x,
180741
- initialY = _this$getData.y,
180742
- initialWidth = _this$getData.width,
180743
- initialHeight = _this$getData.height;
180744
- var ratio = source.width / Math.floor(canvasData.naturalWidth);
180745
- if (ratio !== 1) {
180746
- initialX *= ratio;
180747
- initialY *= ratio;
180748
- initialWidth *= ratio;
180749
- initialHeight *= ratio;
180750
- }
180751
- var aspectRatio = initialWidth / initialHeight;
180752
- var maxSizes = getAdjustedSizes({
180753
- aspectRatio: aspectRatio,
180754
- width: options.maxWidth || Infinity,
180755
- height: options.maxHeight || Infinity
180756
- });
180757
- var minSizes = getAdjustedSizes({
180758
- aspectRatio: aspectRatio,
180759
- width: options.minWidth || 0,
180760
- height: options.minHeight || 0
180761
- }, 'cover');
180762
- var _getAdjustedSizes = getAdjustedSizes({
180763
- aspectRatio: aspectRatio,
180764
- width: options.width || (ratio !== 1 ? source.width : initialWidth),
180765
- height: options.height || (ratio !== 1 ? source.height : initialHeight)
180766
- }),
180767
- width = _getAdjustedSizes.width,
180768
- height = _getAdjustedSizes.height;
180769
- width = Math.min(maxSizes.width, Math.max(minSizes.width, width));
180770
- height = Math.min(maxSizes.height, Math.max(minSizes.height, height));
180771
- var canvas = document.createElement('canvas');
180772
- var context = canvas.getContext('2d');
180773
- canvas.width = normalizeDecimalNumber(width);
180774
- canvas.height = normalizeDecimalNumber(height);
180775
- context.fillStyle = options.fillColor || 'transparent';
180776
- context.fillRect(0, 0, width, height);
180777
- var _options$imageSmoothi = options.imageSmoothingEnabled,
180778
- imageSmoothingEnabled = _options$imageSmoothi === void 0 ? true : _options$imageSmoothi,
180779
- imageSmoothingQuality = options.imageSmoothingQuality;
180780
- context.imageSmoothingEnabled = imageSmoothingEnabled;
180781
- if (imageSmoothingQuality) {
180782
- context.imageSmoothingQuality = imageSmoothingQuality;
180783
- }
180784
-
180785
- // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D.drawImage
180786
- var sourceWidth = source.width;
180787
- var sourceHeight = source.height;
180788
-
180789
- // Source canvas parameters
180790
- var srcX = initialX;
180791
- var srcY = initialY;
180792
- var srcWidth;
180793
- var srcHeight;
180794
-
180795
- // Destination canvas parameters
180796
- var dstX;
180797
- var dstY;
180798
- var dstWidth;
180799
- var dstHeight;
180800
- if (srcX <= -initialWidth || srcX > sourceWidth) {
180801
- srcX = 0;
180802
- srcWidth = 0;
180803
- dstX = 0;
180804
- dstWidth = 0;
180805
- } else if (srcX <= 0) {
180806
- dstX = -srcX;
180807
- srcX = 0;
180808
- srcWidth = Math.min(sourceWidth, initialWidth + srcX);
180809
- dstWidth = srcWidth;
180810
- } else if (srcX <= sourceWidth) {
180811
- dstX = 0;
180812
- srcWidth = Math.min(initialWidth, sourceWidth - srcX);
180813
- dstWidth = srcWidth;
180814
- }
180815
- if (srcWidth <= 0 || srcY <= -initialHeight || srcY > sourceHeight) {
180816
- srcY = 0;
180817
- srcHeight = 0;
180818
- dstY = 0;
180819
- dstHeight = 0;
180820
- } else if (srcY <= 0) {
180821
- dstY = -srcY;
180822
- srcY = 0;
180823
- srcHeight = Math.min(sourceHeight, initialHeight + srcY);
180824
- dstHeight = srcHeight;
180825
- } else if (srcY <= sourceHeight) {
180826
- dstY = 0;
180827
- srcHeight = Math.min(initialHeight, sourceHeight - srcY);
180828
- dstHeight = srcHeight;
180829
- }
180830
- var params = [srcX, srcY, srcWidth, srcHeight];
180831
-
180832
- // Avoid "IndexSizeError"
180833
- if (dstWidth > 0 && dstHeight > 0) {
180834
- var scale = width / initialWidth;
180835
- params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale);
180836
- }
180837
-
180838
- // All the numerical parameters should be integer for `drawImage`
180839
- // https://github.com/fengyuanchen/cropper/issues/476
180840
- context.drawImage.apply(context, [source].concat(_toConsumableArray(params.map(function (param) {
180841
- return Math.floor(normalizeDecimalNumber(param));
180842
- }))));
180843
- return canvas;
180844
- },
180845
- /**
180846
- * Change the aspect ratio of the crop box.
180847
- * @param {number} aspectRatio - The new aspect ratio.
180848
- * @returns {Cropper} this
180849
- */
180850
- setAspectRatio: function setAspectRatio(aspectRatio) {
180851
- var options = this.options;
180852
- if (!this.disabled && !isUndefined(aspectRatio)) {
180853
- // 0 -> NaN
180854
- options.aspectRatio = Math.max(0, aspectRatio) || NaN;
180855
- if (this.ready) {
180856
- this.initCropBox();
180857
- if (this.cropped) {
180858
- this.renderCropBox();
180859
- }
180860
- }
180861
- }
180862
- return this;
180863
- },
180864
- /**
180865
- * Change the drag mode.
180866
- * @param {string} mode - The new drag mode.
180867
- * @returns {Cropper} this
180868
- */
180869
- setDragMode: function setDragMode(mode) {
180870
- var options = this.options,
180871
- dragBox = this.dragBox,
180872
- face = this.face;
180873
- if (this.ready && !this.disabled) {
180874
- var croppable = mode === DRAG_MODE_CROP;
180875
- var movable = options.movable && mode === DRAG_MODE_MOVE;
180876
- mode = croppable || movable ? mode : DRAG_MODE_NONE;
180877
- options.dragMode = mode;
180878
- setData(dragBox, DATA_ACTION, mode);
180879
- toggleClass(dragBox, CLASS_CROP, croppable);
180880
- toggleClass(dragBox, CLASS_MOVE, movable);
180881
- if (!options.cropBoxMovable) {
180882
- // Sync drag mode to crop box when it is not movable
180883
- setData(face, DATA_ACTION, mode);
180884
- toggleClass(face, CLASS_CROP, croppable);
180885
- toggleClass(face, CLASS_MOVE, movable);
180886
- }
180887
- }
180888
- return this;
180889
- }
180890
- };
180891
-
180892
- var AnotherCropper = WINDOW.Cropper;
180893
- var Cropper = /*#__PURE__*/function () {
180894
- /**
180895
- * Create a new Cropper.
180896
- * @param {Element} element - The target element for cropping.
180897
- * @param {Object} [options={}] - The configuration options.
180898
- */
180899
- function Cropper(element) {
180900
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
180901
- _classCallCheck(this, Cropper);
180902
- if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
180903
- throw new Error('The first argument is required and must be an <img> or <canvas> element.');
180904
- }
180905
- this.element = element;
180906
- this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
180907
- this.cropped = false;
180908
- this.disabled = false;
180909
- this.pointers = {};
180910
- this.ready = false;
180911
- this.reloading = false;
180912
- this.replaced = false;
180913
- this.sized = false;
180914
- this.sizing = false;
180915
- this.init();
180916
- }
180917
- return _createClass(Cropper, [{
180918
- key: "init",
180919
- value: function init() {
180920
- var element = this.element;
180921
- var tagName = element.tagName.toLowerCase();
180922
- var url;
180923
- if (element[NAMESPACE]) {
180924
- return;
180925
- }
180926
- element[NAMESPACE] = this;
180927
- if (tagName === 'img') {
180928
- this.isImg = true;
180929
-
180930
- // e.g.: "img/picture.jpg"
180931
- url = element.getAttribute('src') || '';
180932
- this.originalUrl = url;
180933
-
180934
- // Stop when it's a blank image
180935
- if (!url) {
180936
- return;
180937
- }
180938
-
180939
- // e.g.: "https://example.com/img/picture.jpg"
180940
- url = element.src;
180941
- } else if (tagName === 'canvas' && window.HTMLCanvasElement) {
180942
- url = element.toDataURL();
180943
- }
180944
- this.load(url);
180945
- }
180946
- }, {
180947
- key: "load",
180948
- value: function load(url) {
180949
- var _this = this;
180950
- if (!url) {
180951
- return;
180952
- }
180953
- this.url = url;
180954
- this.imageData = {};
180955
- var element = this.element,
180956
- options = this.options;
180957
- if (!options.rotatable && !options.scalable) {
180958
- options.checkOrientation = false;
180959
- }
180960
-
180961
- // Only IE10+ supports Typed Arrays
180962
- if (!options.checkOrientation || !window.ArrayBuffer) {
180963
- this.clone();
180964
- return;
180965
- }
180966
-
180967
- // Detect the mime type of the image directly if it is a Data URL
180968
- if (REGEXP_DATA_URL.test(url)) {
180969
- // Read ArrayBuffer from Data URL of JPEG images directly for better performance
180970
- if (REGEXP_DATA_URL_JPEG.test(url)) {
180971
- this.read(dataURLToArrayBuffer(url));
180972
- } else {
180973
- // Only a JPEG image may contains Exif Orientation information,
180974
- // the rest types of Data URLs are not necessary to check orientation at all.
180975
- this.clone();
180976
- }
180977
- return;
180978
- }
180979
-
180980
- // 1. Detect the mime type of the image by a XMLHttpRequest.
180981
- // 2. Load the image as ArrayBuffer for reading orientation if its a JPEG image.
180982
- var xhr = new XMLHttpRequest();
180983
- var clone = this.clone.bind(this);
180984
- this.reloading = true;
180985
- this.xhr = xhr;
180986
-
180987
- // 1. Cross origin requests are only supported for protocol schemes:
180988
- // http, https, data, chrome, chrome-extension.
180989
- // 2. Access to XMLHttpRequest from a Data URL will be blocked by CORS policy
180990
- // in some browsers as IE11 and Safari.
180991
- xhr.onabort = clone;
180992
- xhr.onerror = clone;
180993
- xhr.ontimeout = clone;
180994
- xhr.onprogress = function () {
180995
- // Abort the request directly if it not a JPEG image for better performance
180996
- if (xhr.getResponseHeader('content-type') !== MIME_TYPE_JPEG) {
180997
- xhr.abort();
180998
- }
180999
- };
181000
- xhr.onload = function () {
181001
- _this.read(xhr.response);
181002
- };
181003
- xhr.onloadend = function () {
181004
- _this.reloading = false;
181005
- _this.xhr = null;
181006
- };
181007
-
181008
- // Bust cache when there is a "crossOrigin" property to avoid browser cache error
181009
- if (options.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) {
181010
- url = addTimestamp(url);
181011
- }
181012
-
181013
- // The third parameter is required for avoiding side-effect (#682)
181014
- xhr.open('GET', url, true);
181015
- xhr.responseType = 'arraybuffer';
181016
- xhr.withCredentials = element.crossOrigin === 'use-credentials';
181017
- xhr.send();
181018
- }
181019
- }, {
181020
- key: "read",
181021
- value: function read(arrayBuffer) {
181022
- var options = this.options,
181023
- imageData = this.imageData;
181024
-
181025
- // Reset the orientation value to its default value 1
181026
- // as some iOS browsers will render image with its orientation
181027
- var orientation = resetAndGetOrientation(arrayBuffer);
181028
- var rotate = 0;
181029
- var scaleX = 1;
181030
- var scaleY = 1;
181031
- if (orientation > 1) {
181032
- // Generate a new URL which has the default orientation value
181033
- this.url = arrayBufferToDataURL(arrayBuffer, MIME_TYPE_JPEG);
181034
- var _parseOrientation = parseOrientation(orientation);
181035
- rotate = _parseOrientation.rotate;
181036
- scaleX = _parseOrientation.scaleX;
181037
- scaleY = _parseOrientation.scaleY;
181038
- }
181039
- if (options.rotatable) {
181040
- imageData.rotate = rotate;
181041
- }
181042
- if (options.scalable) {
181043
- imageData.scaleX = scaleX;
181044
- imageData.scaleY = scaleY;
181045
- }
181046
- this.clone();
181047
- }
181048
- }, {
181049
- key: "clone",
181050
- value: function clone() {
181051
- var element = this.element,
181052
- url = this.url;
181053
- var crossOrigin = element.crossOrigin;
181054
- var crossOriginUrl = url;
181055
- if (this.options.checkCrossOrigin && isCrossOriginURL(url)) {
181056
- if (!crossOrigin) {
181057
- crossOrigin = 'anonymous';
181058
- }
181059
-
181060
- // Bust cache when there is not a "crossOrigin" property (#519)
181061
- crossOriginUrl = addTimestamp(url);
181062
- }
181063
- this.crossOrigin = crossOrigin;
181064
- this.crossOriginUrl = crossOriginUrl;
181065
- var image = document.createElement('img');
181066
- if (crossOrigin) {
181067
- image.crossOrigin = crossOrigin;
181068
- }
181069
- image.src = crossOriginUrl || url;
181070
- image.alt = element.alt || 'The image to crop';
181071
- this.image = image;
181072
- image.onload = this.start.bind(this);
181073
- image.onerror = this.stop.bind(this);
181074
- addClass(image, CLASS_HIDE);
181075
- element.parentNode.insertBefore(image, element.nextSibling);
181076
- }
181077
- }, {
181078
- key: "start",
181079
- value: function start() {
181080
- var _this2 = this;
181081
- var image = this.image;
181082
- image.onload = null;
181083
- image.onerror = null;
181084
- this.sizing = true;
181085
-
181086
- // Match all browsers that use WebKit as the layout engine in iOS devices,
181087
- // such as Safari for iOS, Chrome for iOS, and in-app browsers.
181088
- var isIOSWebKit = WINDOW.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent);
181089
- var done = function done(naturalWidth, naturalHeight) {
181090
- assign(_this2.imageData, {
181091
- naturalWidth: naturalWidth,
181092
- naturalHeight: naturalHeight,
181093
- aspectRatio: naturalWidth / naturalHeight
181094
- });
181095
- _this2.initialImageData = assign({}, _this2.imageData);
181096
- _this2.sizing = false;
181097
- _this2.sized = true;
181098
- _this2.build();
181099
- };
181100
-
181101
- // Most modern browsers (excepts iOS WebKit)
181102
- if (image.naturalWidth && !isIOSWebKit) {
181103
- done(image.naturalWidth, image.naturalHeight);
181104
- return;
181105
- }
181106
- var sizingImage = document.createElement('img');
181107
- var body = document.body || document.documentElement;
181108
- this.sizingImage = sizingImage;
181109
- sizingImage.onload = function () {
181110
- done(sizingImage.width, sizingImage.height);
181111
- if (!isIOSWebKit) {
181112
- body.removeChild(sizingImage);
181113
- }
181114
- };
181115
- sizingImage.src = image.src;
181116
-
181117
- // iOS WebKit will convert the image automatically
181118
- // with its orientation once append it into DOM (#279)
181119
- if (!isIOSWebKit) {
181120
- sizingImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
181121
- body.appendChild(sizingImage);
181122
- }
181123
- }
181124
- }, {
181125
- key: "stop",
181126
- value: function stop() {
181127
- var image = this.image;
181128
- image.onload = null;
181129
- image.onerror = null;
181130
- image.parentNode.removeChild(image);
181131
- this.image = null;
181132
- }
181133
- }, {
181134
- key: "build",
181135
- value: function build() {
181136
- if (!this.sized || this.ready) {
181137
- return;
181138
- }
181139
- var element = this.element,
181140
- options = this.options,
181141
- image = this.image;
181142
-
181143
- // Create cropper elements
181144
- var container = element.parentNode;
181145
- var template = document.createElement('div');
181146
- template.innerHTML = TEMPLATE;
181147
- var cropper = template.querySelector(".".concat(NAMESPACE, "-container"));
181148
- var canvas = cropper.querySelector(".".concat(NAMESPACE, "-canvas"));
181149
- var dragBox = cropper.querySelector(".".concat(NAMESPACE, "-drag-box"));
181150
- var cropBox = cropper.querySelector(".".concat(NAMESPACE, "-crop-box"));
181151
- var face = cropBox.querySelector(".".concat(NAMESPACE, "-face"));
181152
- this.container = container;
181153
- this.cropper = cropper;
181154
- this.canvas = canvas;
181155
- this.dragBox = dragBox;
181156
- this.cropBox = cropBox;
181157
- this.viewBox = cropper.querySelector(".".concat(NAMESPACE, "-view-box"));
181158
- this.face = face;
181159
- canvas.appendChild(image);
181160
-
181161
- // Hide the original image
181162
- addClass(element, CLASS_HIDDEN);
181163
-
181164
- // Inserts the cropper after to the current image
181165
- container.insertBefore(cropper, element.nextSibling);
181166
-
181167
- // Show the hidden image
181168
- removeClass(image, CLASS_HIDE);
181169
- this.initPreview();
181170
- this.bind();
181171
- options.initialAspectRatio = Math.max(0, options.initialAspectRatio) || NaN;
181172
- options.aspectRatio = Math.max(0, options.aspectRatio) || NaN;
181173
- options.viewMode = Math.max(0, Math.min(3, Math.round(options.viewMode))) || 0;
181174
- addClass(cropBox, CLASS_HIDDEN);
181175
- if (!options.guides) {
181176
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-dashed")), CLASS_HIDDEN);
181177
- }
181178
- if (!options.center) {
181179
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-center")), CLASS_HIDDEN);
181180
- }
181181
- if (options.background) {
181182
- addClass(cropper, "".concat(NAMESPACE, "-bg"));
181183
- }
181184
- if (!options.highlight) {
181185
- addClass(face, CLASS_INVISIBLE);
181186
- }
181187
- if (options.cropBoxMovable) {
181188
- addClass(face, CLASS_MOVE);
181189
- setData(face, DATA_ACTION, ACTION_ALL);
181190
- }
181191
- if (!options.cropBoxResizable) {
181192
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-line")), CLASS_HIDDEN);
181193
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-point")), CLASS_HIDDEN);
181194
- }
181195
- this.render();
181196
- this.ready = true;
181197
- this.setDragMode(options.dragMode);
181198
- if (options.autoCrop) {
181199
- this.crop();
181200
- }
181201
- this.setData(options.data);
181202
- if (isFunction(options.ready)) {
181203
- addListener(element, EVENT_READY, options.ready, {
181204
- once: true
181205
- });
181206
- }
181207
- dispatchEvent(element, EVENT_READY);
181208
- }
181209
- }, {
181210
- key: "unbuild",
181211
- value: function unbuild() {
181212
- if (!this.ready) {
181213
- return;
181214
- }
181215
- this.ready = false;
181216
- this.unbind();
181217
- this.resetPreview();
181218
- var parentNode = this.cropper.parentNode;
181219
- if (parentNode) {
181220
- parentNode.removeChild(this.cropper);
181221
- }
181222
- removeClass(this.element, CLASS_HIDDEN);
181223
- }
181224
- }, {
181225
- key: "uncreate",
181226
- value: function uncreate() {
181227
- if (this.ready) {
181228
- this.unbuild();
181229
- this.ready = false;
181230
- this.cropped = false;
181231
- } else if (this.sizing) {
181232
- this.sizingImage.onload = null;
181233
- this.sizing = false;
181234
- this.sized = false;
181235
- } else if (this.reloading) {
181236
- this.xhr.onabort = null;
181237
- this.xhr.abort();
181238
- } else if (this.image) {
181239
- this.stop();
181240
- }
181241
- }
181242
-
181243
- /**
181244
- * Get the no conflict cropper class.
181245
- * @returns {Cropper} The cropper class.
181246
- */
181247
- }], [{
181248
- key: "noConflict",
181249
- value: function noConflict() {
181250
- window.Cropper = AnotherCropper;
181251
- return Cropper;
181252
- }
181253
-
181254
- /**
181255
- * Change the default options.
181256
- * @param {Object} options - The new default options.
181257
- */
181258
- }, {
181259
- key: "setDefaults",
181260
- value: function setDefaults(options) {
181261
- assign(DEFAULTS, isPlainObject(options) && options);
181262
- }
181263
- }]);
181264
- }();
181265
- assign(Cropper.prototype, render, preview, events, handlers, change, methods);
181266
-
181267
- var n=function(){return n=Object.assign||function(e){for(var r,o=1,t=arguments.length;o<t;o++)for(var n in r=arguments[o])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},n.apply(this,arguments)};function a(e,r){var o={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(o[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(t=Object.getOwnPropertySymbols(e);n<t.length;n++)r.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(e,t[n])&&(o[t[n]]=e[t[n]]);}return o}var c$1=["aspectRatio","autoCrop","autoCropArea","background","center","checkCrossOrigin","checkOrientation","cropBoxMovable","cropBoxResizable","data","dragMode","guides","highlight","initialAspectRatio","minCanvasHeight","minCanvasWidth","minContainerHeight","minContainerWidth","minCropBoxHeight","minCropBoxWidth","modal","movable","preview","responsive","restore","rotatable","scalable","toggleDragModeOnDblclick","viewMode","wheelZoomRatio","zoomOnTouch","zoomOnWheel","zoomable","cropstart","cropmove","cropend","crop","zoom","ready"],i={opacity:0,maxWidth:"100%"},l=React__default.forwardRef((function(l,s){var u=a(l,[]),p=u.dragMode,d=void 0===p?"crop":p,v=u.src,f=u.style,m=u.className,g=u.crossOrigin,y=u.scaleX,b=u.scaleY,h=u.enable,O=u.zoomTo,T=u.rotateTo,z=u.alt,C=void 0===z?"picture":z,w=u.ready,x=u.onInitialized,j=a(u,["dragMode","src","style","className","crossOrigin","scaleX","scaleY","enable","zoomTo","rotateTo","alt","ready","onInitialized"]),M={scaleY:b,scaleX:y,enable:h,zoomTo:O,rotateTo:T},E=function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];var n=useRef(null);return React__default.useEffect((function(){o.forEach((function(e){e&&("function"==typeof e?e(n.current):e.current=n.current);}));}),[o]),n}(s,useRef(null));useEffect((function(){var e;(null===(e=E.current)||void 0===e?void 0:e.cropper)&&"number"==typeof O&&E.current.cropper.zoomTo(O);}),[u.zoomTo]),useEffect((function(){var e;(null===(e=E.current)||void 0===e?void 0:e.cropper)&&void 0!==v&&E.current.cropper.reset().clear().replace(v);}),[v]),useEffect((function(){if(null!==E.current){var e=new Cropper(E.current,n(n({dragMode:d},j),{ready:function(e){null!==e.currentTarget&&function(e,r){void 0===r&&(r={});var o=r.enable,t=void 0===o||o,n=r.scaleX,a=void 0===n?1:n,c=r.scaleY,i=void 0===c?1:c,l=r.zoomTo,s=void 0===l?0:l,u=r.rotateTo;t?e.enable():e.disable(),e.scaleX(a),e.scaleY(i),void 0!==u&&e.rotateTo(u),s>0&&e.zoomTo(s);}(e.currentTarget.cropper,M),w&&w(e);}}));x&&x(e);}return function(){var e,r;null===(r=null===(e=E.current)||void 0===e?void 0:e.cropper)||void 0===r||r.destroy();}}),[E]);var R=function(e){return c$1.reduce((function(e,r){var o=e,t=r;return o[t],a(o,["symbol"==typeof t?t:t+""])}),e)}(n(n({},j),{crossOrigin:g,src:v,alt:C}));return React__default.createElement("div",{style:f,className:m},React__default.createElement("img",n({},R,{style:i,ref:E})))}));
181268
-
181269
- var PUBLISH = 0;
181270
- var SUBSCRIBE = 1;
181271
- var RESET = 2;
181272
- var VALUE = 4;
181273
-
181274
- /**
181275
- * Utils includes
181276
- * - a handful of functional utilities inspired by or taken from the [Ramda library](https://ramdajs.com/);
181277
- * - TypeScript crutches - the [[tup]] function.
181278
- *
181279
- * Use these for your convenience - they are here so that urx is zero-dependency package.
181280
- *
181281
- * @packageDocumentation
181282
- */
181283
-
181284
- /**
181285
- * Performs left to right composition of two functions.
181286
- */
181287
- function compose(a, b) {
181288
- return function (arg) {
181289
- return a(b(arg));
181290
- };
181291
- }
181292
- /**
181293
- * Takes a value and applies a function to it.
181294
- */
181295
-
181296
- function thrush(arg, proc) {
181297
- return proc(arg);
181298
- }
181299
- /**
181300
- * Takes a 2 argument function and partially applies the first argument.
181301
- */
181302
-
181303
- function curry2to1(proc, arg1) {
181304
- return function (arg2) {
181305
- return proc(arg1, arg2);
181306
- };
181307
- }
181308
- /**
181309
- * Takes a 1 argument function and returns a function which when called, executes it with the provided argument.
181310
- */
181311
-
181312
- function curry1to0(proc, arg) {
181313
- return function () {
181314
- return proc(arg);
181315
- };
181316
- }
181317
- /**
181318
- * Calls callback with the first argument, and returns it.
181319
- */
181320
-
181321
- function tap(arg, proc) {
181322
- proc(arg);
181323
- return arg;
181324
- }
181325
- /**
181326
- * Utility function to help typescript figure out that what we pass is a tuple and not a generic array.
181327
- * Taken from (this StackOverflow tread)[https://stackoverflow.com/questions/49729550/implicitly-create-a-tuple-in-typescript/52445008#52445008]
181328
- */
181329
-
181330
- function tup() {
181331
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
181332
- args[_key] = arguments[_key];
181333
- }
181334
-
181335
- return args;
181336
- }
181337
- /**
181338
- * Calls the passed function.
181339
- */
181340
-
181341
- function call(proc) {
181342
- proc();
181343
- }
181344
- /**
181345
- * returns a function which when called always returns the passed value
181346
- */
181347
-
181348
- function always(value) {
181349
- return function () {
181350
- return value;
181351
- };
181352
- }
181353
- /**
181354
- * returns a function which calls all passed functions in the passed order.
181355
- * joinProc does not pass arguments or collect return values.
181356
- */
181357
-
181358
- function joinProc() {
181359
- for (var _len2 = arguments.length, procs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
181360
- procs[_key2] = arguments[_key2];
181361
- }
181362
-
181363
- return function () {
181364
- procs.map(call);
181365
- };
181366
- }
181367
- function noop() {}
181368
-
181369
- /**
181370
- * urx Actions operate on streams - `publish` publishes data in a stream, and `subscribe` attaches a subscription to a stream.
181371
- * @packageDocumentation
181372
- */
181373
- /**
181374
- * Subscribes the specified [[Subscription]] to the updates from the Emitter.
181375
- * The emitter calls the subscription with the new data each time new data is published into it.
181376
- *
181377
- * ```ts
181378
- * const foo = stream<number>();
181379
- * subscribe(foo, (value) => console.log(value));
181380
- * ```
181381
- *
181382
- * @returns an [[Unsubscribe]] handle - calling it will unbind the subscription from the emitter.
181383
- *```ts
181384
- * const foo = stream<number>();
181385
- * const unsub = subscribe(foo, (value) => console.log(value));
181386
- * unsub();
181387
- *```
181388
- */
181389
-
181390
- function subscribe(emitter, subscription) {
181391
- return emitter(SUBSCRIBE, subscription);
181392
- }
181393
- /**
181394
- * Publishes the value into the passed [[Publisher]].
181395
- *
181396
- * ```ts
181397
- * const foo = stream<number>();
181398
- * publish(foo, 42);
181399
- * ```
181400
- */
181401
-
181402
- function publish(publisher, value) {
181403
- publisher(PUBLISH, value);
181404
- }
181405
- /**
181406
- * Clears all subscriptions from the [[Emitter]].
181407
- * ```ts
181408
- * const foo = stream<number>();
181409
- * subscribe(foo, (value) => console.log(value));
181410
- * reset(foo);
181411
- * publish(foo, 42);
181412
- * ```
181413
- */
181414
-
181415
- function reset(emitter) {
181416
- emitter(RESET);
181417
- }
181418
- /**
181419
- * Extracts the current value from a stateful stream. Use it only as an escape hatch, as it violates the concept of reactive programming.
181420
- * ```ts
181421
- * const foo = statefulStream(42);
181422
- * console.log(getValue(foo));
181423
- * ```
181424
- */
181425
-
181426
- function getValue(depot) {
181427
- return depot(VALUE);
181428
- }
181429
- /**
181430
- * Connects two streams - any value emitted from the emitter will be published in the publisher.
181431
- * ```ts
181432
- * const foo = stream<number>();
181433
- * const bar = stream<number>();
181434
- * subscribe(bar, (value) => console.log(`Bar emitted ${value}`));
181435
- *
181436
- * connect(foo, bar);
181437
- * publish(foo);
181438
- * ```
181439
- * @returns an [[Unsubscribe]] handle which will disconnect the two streams.
181440
- */
181441
-
181442
- function connect(emitter, publisher) {
181443
- return subscribe(emitter, curry2to1(publisher, PUBLISH));
181444
- }
181445
- /**
181446
- * Executes the passed subscription at most once, for the next emit from the emitter.
181447
- * ```ts
181448
- * const foo = stream<number>()
181449
- * handleNext(foo, value => console.log(value)) // called once, with 42
181450
- * publish(foo, 42)
181451
- * publish(foo, 43)
181452
- * ```
181453
- * @returns an [[Unsubscribe]] handle to unbind the subscription if necessary.
181454
- */
181455
-
181456
- function handleNext(emitter, subscription) {
181457
- var unsub = emitter(SUBSCRIBE, function (value) {
181458
- unsub();
181459
- subscription(value);
181460
- });
181461
- return unsub;
181462
- }
181463
-
181464
- /**
181465
- * Streams are the basic building blocks of a reactive system. Think of them as the system permanent "data tubes".
181466
- *
181467
- * A stream acts as both an [[Emitter]] and [[Publisher]]. Each stream can have multiple {@link Subscription | Subscriptions}.
181468
- *
181469
- * urx streams are either **stateless** or **stateful**.
181470
- * Stateless streams emit data to existing subscriptions when published, without keeping track of it.
181471
- * Stateful streams remember the last published value and immediately publish it to new subscriptions.
181472
- *
181473
- * ```ts
181474
- * import { stream, statefulStream, publish, subscribe } from "@virtuoso.dev/urx";
181475
- *
181476
- * // foo is a stateless stream
181477
- * const foo = stream<number>();
181478
- *
181479
- * publish(foo, 42);
181480
- * // this subsription will not be called...
181481
- * subscribe(foo, (value) => console.log(value));
181482
- * // it will only catch published values after it
181483
- * publish(foo, 43);
181484
- *
181485
- * // stateful streams always start with an initial value
181486
- * const bar = statefulStream(42);
181487
- *
181488
- * // subscribing to a stateful stream
181489
- * // immediately calls the subscription with the current value
181490
- * subscribe(bar, (value) => console.log(value));
181491
- *
181492
- * // subsequent publishing works just like stateless streams
181493
- * publish(bar, 43);
181494
- * ```
181495
- * @packageDocumentation
181496
- */
181497
- /**
181498
- * Constructs a new stateless stream.
181499
- * ```ts
181500
- * const foo = stream<number>();
181501
- * ```
181502
- * @typeParam T the type of values to publish in the stream.
181503
- * @returns a [[Stream]]
181504
- */
181505
-
181506
- function stream() {
181507
- var subscriptions = [];
181508
- return function (action, arg) {
181509
- switch (action) {
181510
- case RESET:
181511
- subscriptions.splice(0, subscriptions.length);
181512
- return;
181513
-
181514
- case SUBSCRIBE:
181515
- subscriptions.push(arg);
181516
- return function () {
181517
- var indexOf = subscriptions.indexOf(arg);
181518
-
181519
- if (indexOf > -1) {
181520
- subscriptions.splice(indexOf, 1);
181521
- }
181522
- };
181523
-
181524
- case PUBLISH:
181525
- subscriptions.slice().forEach(function (subscription) {
181526
- subscription(arg);
181527
- });
181528
- return;
181529
-
181530
- default:
181531
- throw new Error("unrecognized action " + action);
181532
- }
181533
- };
181534
- }
181535
- /**
181536
- * Constructs a new stateful stream.
181537
- * ```ts
181538
- * const foo = statefulStream(42);
181539
- * ```
181540
- * @param initial the initial value in the stream.
181541
- * @typeParam T the type of values to publish in the stream. If omitted, the function infers it from the initial value.
181542
- * @returns a [[StatefulStream]]
181543
- */
181544
-
181545
- function statefulStream(initial) {
181546
- var value = initial;
181547
- var innerSubject = stream();
181548
- return function (action, arg) {
181549
- switch (action) {
181550
- case SUBSCRIBE:
181551
- var subscription = arg;
181552
- subscription(value);
181553
- break;
181554
-
181555
- case PUBLISH:
181556
- value = arg;
181557
- break;
181558
-
181559
- case VALUE:
181560
- return value;
181561
- }
181562
-
181563
- return innerSubject(action, arg);
181564
- };
181565
- }
181566
- /**
181567
- * Event handlers are special emitters which can have **at most one active subscription**.
181568
- * Subscribing to an event handler unsubscribes the previous subscription, if present.
181569
- * ```ts
181570
- * const foo = stream<number>();
181571
- * const fooEvent = eventHandler(foo);
181572
- *
181573
- * // will be called once with 42
181574
- * subscribe(fooEvent, (value) => console.log(`Sub 1 ${value}`));
181575
- * publish(foo, 42);
181576
- *
181577
- * // unsubscribes sub 1
181578
- * subscribe(fooEvent, (value) => console.log(`Sub 2 ${value}`));
181579
- * publish(foo, 43);
181580
- * ```
181581
- * @param emitter the source emitter.
181582
- * @returns the single-subscription emitter.
181583
- */
181584
-
181585
- function eventHandler(emitter) {
181586
- var unsub;
181587
- var currentSubscription;
181588
-
181589
- var cleanup = function cleanup() {
181590
- return unsub && unsub();
181591
- };
181592
-
181593
- return function (action, subscription) {
181594
- switch (action) {
181595
- case SUBSCRIBE:
181596
- if (subscription) {
181597
- if (currentSubscription === subscription) {
181598
- return;
181599
- }
181600
-
181601
- cleanup();
181602
- currentSubscription = subscription;
181603
- unsub = subscribe(emitter, subscription);
181604
- return unsub;
181605
- } else {
181606
- cleanup();
181607
- return noop;
181608
- }
181609
-
181610
- case RESET:
181611
- cleanup();
181612
- currentSubscription = null;
181613
- return;
181614
-
181615
- default:
181616
- throw new Error("unrecognized action " + action);
181617
- }
181618
- };
181619
- }
181620
- /**
181621
- * Creates and connects a "junction" stream to the specified emitter. Often used with [[pipe]], to avoid the multiple evaluation of operator sets.
181622
- *
181623
- * ```ts
181624
- * const foo = stream<number>();
181625
- *
181626
- * const fooX2 = pipe(
181627
- * foo,
181628
- * map((value) => {
181629
- * console.log(`multiplying ${value}`);
181630
- * return value * 2;
181631
- * })
181632
- * );
181633
- *
181634
- * subscribe(fooX2, (value) => console.log(value));
181635
- * subscribe(fooX2, (value) => console.log(value));
181636
- *
181637
- * publish(foo, 42); // executes the map operator twice for each subscription.
181638
- *
181639
- * const sharedFooX2 = streamFromEmitter(pipe(
181640
- * foo,
181641
- * map((value) => {
181642
- * console.log(`shared multiplying ${value}`);
181643
- * return value * 2;
181644
- * })
181645
- * ));
181646
- *
181647
- * subscribe(sharedFooX2, (value) => console.log(value));
181648
- * subscribe(sharedFooX2, (value) => console.log(value));
181649
- *
181650
- * publish(foo, 42);
181651
- *```
181652
- * @returns the resulting stream.
181653
- */
181654
-
181655
- function streamFromEmitter(emitter) {
181656
- return tap(stream(), function (stream) {
181657
- return connect(emitter, stream);
181658
- });
181659
- }
181660
- /**
181661
- * Creates and connects a "junction" stateful stream to the specified emitter. Often used with [[pipe]], to avoid the multiple evaluation of operator sets.
181662
- *
181663
- * ```ts
181664
- * const foo = stream<number>();
181665
- *
181666
- * const fooX2 = pipe(
181667
- * foo,
181668
- * map((value) => {
181669
- * console.log(`multiplying ${value}`);
181670
- * return value * 2;
181671
- * })
181672
- * );
181673
- *
181674
- * subscribe(fooX2, (value) => console.log(value));
181675
- * subscribe(fooX2, (value) => console.log(value));
181676
- *
181677
- * publish(foo, 42); // executes the map operator twice for each subscription.
181678
- *
181679
- * const sharedFooX2 = statefulStreamFromEmitter(pipe(
181680
- * foo,
181681
- * map((value) => {
181682
- * console.log(`shared multiplying ${value}`);
181683
- * return value * 2;
181684
- * })
181685
- * ), 42);
181686
- *
181687
- * subscribe(sharedFooX2, (value) => console.log(value));
181688
- * subscribe(sharedFooX2, (value) => console.log(value));
181689
- *
181690
- * publish(foo, 42);
181691
- *```
181692
- * @param initial the initial value in the stream.
181693
- * @returns the resulting stateful stream.
181694
- */
181695
-
181696
- function statefulStreamFromEmitter(emitter, initial) {
181697
- return tap(statefulStream(initial), function (stream) {
181698
- return connect(emitter, stream);
181699
- });
181700
- }
181701
-
181702
- /**
181703
- *
181704
- * Stream values can be transformed and controlled by {@link pipe | **piping**} through **operators**.
181705
- * urx includes several operators like [[map]], [[filter]], [[scan]], and [[throttleTime]].
181706
- * The [[withLatestFrom]] operator allows the combination of values from other streams.
181707
- *
181708
- * ```ts
181709
- * const foo = stream<number>()
181710
- *
181711
- * // create an emitter that first adds 2 to the passed value, then multiplies it by * 2
181712
- * const bar = pipe(foo, map(value => value + 2), map(value => value * 2))
181713
- * subscribe(bar, value => console.log(value))
181714
- * publish(foo, 2) // outputs 8
181715
- * ```
181716
- *
181717
- * ### Implementing Custom Operators
181718
- * To implement your own operators, implement the [[Operator]] interface.
181719
- * @packageDocumentation
181720
- */
181721
- /** @internal */
181722
-
181723
- function combineOperators() {
181724
- for (var _len = arguments.length, operators = new Array(_len), _key = 0; _key < _len; _key++) {
181725
- operators[_key] = arguments[_key];
181726
- }
181727
-
181728
- return function (subscriber) {
181729
- return operators.reduceRight(thrush, subscriber);
181730
- };
181731
- }
181732
-
181733
- function pipe(source) {
181734
- for (var _len2 = arguments.length, operators = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
181735
- operators[_key2 - 1] = arguments[_key2];
181736
- }
181737
-
181738
- // prettier-ignore
181739
- var project = combineOperators.apply(void 0, operators);
181740
- return function (action, subscription) {
181741
- switch (action) {
181742
- case SUBSCRIBE:
181743
- return subscribe(source, project(subscription));
181744
-
181745
- case RESET:
181746
- reset(source);
181747
- return;
181748
-
181749
- default:
181750
- throw new Error("unrecognized action " + action);
181751
- }
181752
- };
181753
- }
181754
- /**
181755
- * The default [[Comparator]] for [[distinctUntilChanged]] and [[duc]].
181756
- */
181757
-
181758
- function defaultComparator(previous, next) {
181759
- return previous === next;
181760
- }
181761
- /**
181762
- * Filters out identical values. Pass an optional [[Comparator]] if you need to filter non-primitive values.
181763
- * ```ts
181764
- * const foo = stream<number>()
181765
- *
181766
- * subscribe(
181767
- * pipe(foo, distinctUntilChanged()),
181768
- * console.log
181769
- * ) // will be called only once
181770
- *
181771
- * publish(foo, 42)
181772
- * publish(foo, 42)
181773
- * ```
181774
- */
181775
-
181776
- function distinctUntilChanged(comparator) {
181777
- if (comparator === void 0) {
181778
- comparator = defaultComparator;
181779
- }
181780
-
181781
- var current;
181782
- return function (done) {
181783
- return function (next) {
181784
- if (!comparator(current, next)) {
181785
- current = next;
181786
- done(next);
181787
- }
181788
- };
181789
- };
181790
- }
181791
- /**
181792
- * Filters out values for which the predicator does not return `true`-ish.
181793
- * ```ts
181794
- * const foo = stream<number>()
181795
- *
181796
- * subscribe(
181797
- * pipe(foo, filter(value => value % 2 === 0)),
181798
- * console.log
181799
- * ) // will be called only with even values
181800
- *
181801
- * publish(foo, 2)
181802
- * publish(foo, 3)
181803
- * publish(foo, 4)
181804
- * publish(foo, 5)
181805
- * ```
181806
- */
181807
-
181808
- function filter(predicate) {
181809
- return function (done) {
181810
- return function (value) {
181811
- predicate(value) && done(value);
181812
- };
181813
- };
181814
- }
181815
- /**
181816
- * Maps values using the provided project function.
181817
- * ```ts
181818
- * const foo = stream<number>()
181819
- *
181820
- * subscribe(
181821
- * pipe(foo, map(value => value * 2)),
181822
- * console.log
181823
- * ) // 4, 6
181824
- *
181825
- * publish(foo, 2)
181826
- * publish(foo, 3)
181827
- * ```
181828
- */
181829
-
181830
- function map(project) {
181831
- return function (done) {
181832
- return compose(done, project);
181833
- };
181834
- }
181835
- /**
181836
- * Maps values to the hard-coded value.
181837
- * ```ts
181838
- * const foo = stream<number>()
181839
- *
181840
- * subscribe(
181841
- * pipe(foo, mapTo(3)),
181842
- * console.log
181843
- * ) // 3, 3
181844
- *
181845
- * publish(foo, 1)
181846
- * publish(foo, 2)
181847
- * ```
181848
- */
181849
-
181850
- function mapTo(value) {
181851
- return function (done) {
181852
- return function () {
181853
- return done(value);
181854
- };
181855
- };
181856
- }
181857
- /**
181858
- * Works like Array#reduce.
181859
- * Applies an accumulator function on the emitter, and outputs intermediate result. Starts with the initial value.
181860
- * ```ts
181861
- * const foo = stream<number>()
181862
- *
181863
- * subscribe(
181864
- * pipe(foo, scan((acc, value) => acc + value, 2),
181865
- * console.log
181866
- * ) // 3, 5
181867
- *
181868
- * publish(foo, 1)
181869
- * publish(foo, 2)
181870
- * ```
181871
- */
181872
-
181873
- function scan(scanner, initial) {
181874
- return function (done) {
181875
- return function (value) {
181876
- return done(initial = scanner(initial, value));
181877
- };
181878
- };
181879
- }
181880
- /**
181881
- * Skips the specified amount of values from the emitter.
181882
- * ```ts
181883
- * const foo = stream<number>()
181884
- *
181885
- * subscribe(
181886
- * pipe(foo, skip(2)),
181887
- * console.log
181888
- * ) // 3, 4
181889
- *
181890
- * publish(foo, 1) // skipped
181891
- * publish(foo, 2) // skipped
181892
- * publish(foo, 3)
181893
- * publish(foo, 4)
181894
- * ```
181895
- */
181896
-
181897
- function skip(times) {
181898
- return function (done) {
181899
- return function (value) {
181900
- times > 0 ? times-- : done(value);
181901
- };
181902
- };
181903
- }
181904
- /**
181905
- * Throttles flowing values at the provided interval in milliseconds.
181906
- * [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
181907
- *
181908
- * ```ts
181909
- * const foo = stream<number>()
181910
- * publish(foo, 1)
181911
- *
181912
- * setTimeout(() => publish(foo, 2), 20)
181913
- * setTimeout(() => publish(foo, 3), 20)
181914
- *
181915
- * subscribe(pipe(foo, throttleTime(50)), val => {
181916
- * console.log(value); // 3
181917
- * })
181918
- * ```
181919
- */
181920
-
181921
- function throttleTime(interval) {
181922
- var currentValue;
181923
- var timeout;
181924
- return function (done) {
181925
- return function (value) {
181926
- currentValue = value;
181927
-
181928
- if (timeout) {
181929
- return;
181930
- }
181931
-
181932
- timeout = setTimeout(function () {
181933
- timeout = undefined;
181934
- done(currentValue);
181935
- }, interval);
181936
- };
181937
- };
181938
- }
181939
- /**
181940
- * Debounces flowing values at the provided interval in milliseconds.
181941
- * [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
181942
- *
181943
- * ```ts
181944
- * const foo = stream<number>()
181945
- * publish(foo, 1)
181946
- *
181947
- * setTimeout(() => publish(foo, 2), 20)
181948
- * setTimeout(() => publish(foo, 3), 20)
181949
- *
181950
- * subscribe(pipe(foo, debounceTime(50)), val => {
181951
- * console.log(value); // 3
181952
- * })
181953
- * ```
181954
- */
181955
-
181956
- function debounceTime(interval) {
181957
- var currentValue;
181958
- var timeout;
181959
- return function (done) {
181960
- return function (value) {
181961
- currentValue = value;
181962
-
181963
- if (timeout) {
181964
- clearTimeout(timeout);
181846
+ */
181847
+ setCanvasData: function setCanvasData(data) {
181848
+ var canvasData = this.canvasData;
181849
+ var aspectRatio = canvasData.aspectRatio;
181850
+ if (this.ready && !this.disabled && isPlainObject(data)) {
181851
+ if (isNumber(data.left)) {
181852
+ canvasData.left = data.left;
181965
181853
  }
181966
-
181967
- timeout = setTimeout(function () {
181968
- done(currentValue);
181969
- }, interval);
181970
- };
181971
- };
181972
- }
181973
- function withLatestFrom() {
181974
- for (var _len3 = arguments.length, sources = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
181975
- sources[_key3] = arguments[_key3];
181976
- }
181977
-
181978
- var values = new Array(sources.length);
181979
- var called = 0;
181980
- var pendingCall = null;
181981
- var allCalled = Math.pow(2, sources.length) - 1;
181982
- sources.forEach(function (source, index) {
181983
- var bit = Math.pow(2, index);
181984
- subscribe(source, function (value) {
181985
- var prevCalled = called;
181986
- called = called | bit;
181987
- values[index] = value;
181988
-
181989
- if (prevCalled !== allCalled && called === allCalled && pendingCall) {
181990
- pendingCall();
181991
- pendingCall = null;
181854
+ if (isNumber(data.top)) {
181855
+ canvasData.top = data.top;
181992
181856
  }
181993
- });
181994
- });
181995
- return function (done) {
181996
- return function (value) {
181997
- var call = function call() {
181998
- return done([value].concat(values));
181857
+ if (isNumber(data.width)) {
181858
+ canvasData.width = data.width;
181859
+ canvasData.height = data.width / aspectRatio;
181860
+ } else if (isNumber(data.height)) {
181861
+ canvasData.height = data.height;
181862
+ canvasData.width = data.height * aspectRatio;
181863
+ }
181864
+ this.renderCanvas(true);
181865
+ }
181866
+ return this;
181867
+ },
181868
+ /**
181869
+ * Get the crop box position and size data.
181870
+ * @returns {Object} The result crop box data.
181871
+ */
181872
+ getCropBoxData: function getCropBoxData() {
181873
+ var cropBoxData = this.cropBoxData;
181874
+ var data;
181875
+ if (this.ready && this.cropped) {
181876
+ data = {
181877
+ left: cropBoxData.left,
181878
+ top: cropBoxData.top,
181879
+ width: cropBoxData.width,
181880
+ height: cropBoxData.height
181999
181881
  };
182000
-
182001
- if (called === allCalled) {
182002
- call();
182003
- } else {
182004
- pendingCall = call;
181882
+ }
181883
+ return data || {};
181884
+ },
181885
+ /**
181886
+ * Set the crop box position and size with new data.
181887
+ * @param {Object} data - The new crop box data.
181888
+ * @returns {Cropper} this
181889
+ */
181890
+ setCropBoxData: function setCropBoxData(data) {
181891
+ var cropBoxData = this.cropBoxData;
181892
+ var aspectRatio = this.options.aspectRatio;
181893
+ var widthChanged;
181894
+ var heightChanged;
181895
+ if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) {
181896
+ if (isNumber(data.left)) {
181897
+ cropBoxData.left = data.left;
182005
181898
  }
182006
- };
182007
- };
182008
- }
182009
-
182010
- /**
182011
- * Transformers change and combine streams, similar to operators.
182012
- * urx comes with two combinators - [[combineLatest]] and [[merge]], and one convenience filter - [[duc]].
182013
- *
182014
- * @packageDocumentation
182015
- */
182016
- /**
182017
- * Merges one or more emitters from the same type into a new Emitter which emits values from any of the source emitters.
182018
- * ```ts
182019
- * const foo = stream<number>()
182020
- * const bar = stream<number>()
182021
- *
182022
- * subscribe(merge(foo, bar), (value) => console.log(value)) // 42, 43
182023
- *
182024
- * publish(foo, 42)
182025
- * publish(bar, 43)
182026
- * ```
182027
- */
182028
-
182029
- function merge() {
182030
- for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
182031
- sources[_key] = arguments[_key];
182032
- }
182033
-
182034
- return function (action, subscription) {
182035
- switch (action) {
182036
- case SUBSCRIBE:
182037
- return joinProc.apply(void 0, sources.map(function (source) {
182038
- return subscribe(source, subscription);
182039
- }));
182040
-
182041
- case RESET:
182042
- // do nothing, we are stateless
182043
- return;
181899
+ if (isNumber(data.top)) {
181900
+ cropBoxData.top = data.top;
181901
+ }
181902
+ if (isNumber(data.width) && data.width !== cropBoxData.width) {
181903
+ widthChanged = true;
181904
+ cropBoxData.width = data.width;
181905
+ }
181906
+ if (isNumber(data.height) && data.height !== cropBoxData.height) {
181907
+ heightChanged = true;
181908
+ cropBoxData.height = data.height;
181909
+ }
181910
+ if (aspectRatio) {
181911
+ if (widthChanged) {
181912
+ cropBoxData.height = cropBoxData.width / aspectRatio;
181913
+ } else if (heightChanged) {
181914
+ cropBoxData.width = cropBoxData.height * aspectRatio;
181915
+ }
181916
+ }
181917
+ this.renderCropBox();
181918
+ }
181919
+ return this;
181920
+ },
181921
+ /**
181922
+ * Get a canvas drawn the cropped image.
181923
+ * @param {Object} [options={}] - The config options.
181924
+ * @returns {HTMLCanvasElement} - The result canvas.
181925
+ */
181926
+ getCroppedCanvas: function getCroppedCanvas() {
181927
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
181928
+ if (!this.ready || !window.HTMLCanvasElement) {
181929
+ return null;
181930
+ }
181931
+ var canvasData = this.canvasData;
181932
+ var source = getSourceCanvas(this.image, this.imageData, canvasData, options);
182044
181933
 
182045
- default:
182046
- throw new Error("unrecognized action " + action);
181934
+ // Returns the source canvas if it is not cropped.
181935
+ if (!this.cropped) {
181936
+ return source;
181937
+ }
181938
+ var _this$getData = this.getData(options.rounded),
181939
+ initialX = _this$getData.x,
181940
+ initialY = _this$getData.y,
181941
+ initialWidth = _this$getData.width,
181942
+ initialHeight = _this$getData.height;
181943
+ var ratio = source.width / Math.floor(canvasData.naturalWidth);
181944
+ if (ratio !== 1) {
181945
+ initialX *= ratio;
181946
+ initialY *= ratio;
181947
+ initialWidth *= ratio;
181948
+ initialHeight *= ratio;
181949
+ }
181950
+ var aspectRatio = initialWidth / initialHeight;
181951
+ var maxSizes = getAdjustedSizes({
181952
+ aspectRatio: aspectRatio,
181953
+ width: options.maxWidth || Infinity,
181954
+ height: options.maxHeight || Infinity
181955
+ });
181956
+ var minSizes = getAdjustedSizes({
181957
+ aspectRatio: aspectRatio,
181958
+ width: options.minWidth || 0,
181959
+ height: options.minHeight || 0
181960
+ }, 'cover');
181961
+ var _getAdjustedSizes = getAdjustedSizes({
181962
+ aspectRatio: aspectRatio,
181963
+ width: options.width || (ratio !== 1 ? source.width : initialWidth),
181964
+ height: options.height || (ratio !== 1 ? source.height : initialHeight)
181965
+ }),
181966
+ width = _getAdjustedSizes.width,
181967
+ height = _getAdjustedSizes.height;
181968
+ width = Math.min(maxSizes.width, Math.max(minSizes.width, width));
181969
+ height = Math.min(maxSizes.height, Math.max(minSizes.height, height));
181970
+ var canvas = document.createElement('canvas');
181971
+ var context = canvas.getContext('2d');
181972
+ canvas.width = normalizeDecimalNumber(width);
181973
+ canvas.height = normalizeDecimalNumber(height);
181974
+ context.fillStyle = options.fillColor || 'transparent';
181975
+ context.fillRect(0, 0, width, height);
181976
+ var _options$imageSmoothi = options.imageSmoothingEnabled,
181977
+ imageSmoothingEnabled = _options$imageSmoothi === void 0 ? true : _options$imageSmoothi,
181978
+ imageSmoothingQuality = options.imageSmoothingQuality;
181979
+ context.imageSmoothingEnabled = imageSmoothingEnabled;
181980
+ if (imageSmoothingQuality) {
181981
+ context.imageSmoothingQuality = imageSmoothingQuality;
182047
181982
  }
182048
- };
182049
- }
182050
- /**
182051
- * A convenience wrapper that emits only the distinct values from the passed Emitter. Wraps [[pipe]] and [[distinctUntilChanged]].
182052
- *
182053
- * ```ts
182054
- * const foo = stream<number>()
182055
- *
182056
- * // this line...
182057
- * const a = duc(foo)
182058
- *
182059
- * // is equivalent to this
182060
- * const b = pipe(distinctUntilChanged(foo))
182061
- * ```
182062
- *
182063
- * @param source The source emitter.
182064
- * @param comparator optional custom comparison function for the two values.
182065
- *
182066
- * @typeParam T the type of the value emitted by the source.
182067
- *
182068
- * @returns the resulting emitter.
182069
- */
182070
181983
 
182071
- function duc(source, comparator) {
182072
- if (comparator === void 0) {
182073
- comparator = defaultComparator;
182074
- }
181984
+ // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D.drawImage
181985
+ var sourceWidth = source.width;
181986
+ var sourceHeight = source.height;
182075
181987
 
182076
- return pipe(source, distinctUntilChanged(comparator));
182077
- }
182078
- function combineLatest() {
182079
- var innerSubject = stream();
181988
+ // Source canvas parameters
181989
+ var srcX = initialX;
181990
+ var srcY = initialY;
181991
+ var srcWidth;
181992
+ var srcHeight;
182080
181993
 
182081
- for (var _len2 = arguments.length, emitters = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
182082
- emitters[_key2] = arguments[_key2];
182083
- }
181994
+ // Destination canvas parameters
181995
+ var dstX;
181996
+ var dstY;
181997
+ var dstWidth;
181998
+ var dstHeight;
181999
+ if (srcX <= -initialWidth || srcX > sourceWidth) {
182000
+ srcX = 0;
182001
+ srcWidth = 0;
182002
+ dstX = 0;
182003
+ dstWidth = 0;
182004
+ } else if (srcX <= 0) {
182005
+ dstX = -srcX;
182006
+ srcX = 0;
182007
+ srcWidth = Math.min(sourceWidth, initialWidth + srcX);
182008
+ dstWidth = srcWidth;
182009
+ } else if (srcX <= sourceWidth) {
182010
+ dstX = 0;
182011
+ srcWidth = Math.min(initialWidth, sourceWidth - srcX);
182012
+ dstWidth = srcWidth;
182013
+ }
182014
+ if (srcWidth <= 0 || srcY <= -initialHeight || srcY > sourceHeight) {
182015
+ srcY = 0;
182016
+ srcHeight = 0;
182017
+ dstY = 0;
182018
+ dstHeight = 0;
182019
+ } else if (srcY <= 0) {
182020
+ dstY = -srcY;
182021
+ srcY = 0;
182022
+ srcHeight = Math.min(sourceHeight, initialHeight + srcY);
182023
+ dstHeight = srcHeight;
182024
+ } else if (srcY <= sourceHeight) {
182025
+ dstY = 0;
182026
+ srcHeight = Math.min(initialHeight, sourceHeight - srcY);
182027
+ dstHeight = srcHeight;
182028
+ }
182029
+ var params = [srcX, srcY, srcWidth, srcHeight];
182084
182030
 
182085
- var values = new Array(emitters.length);
182086
- var called = 0;
182087
- var allCalled = Math.pow(2, emitters.length) - 1;
182088
- emitters.forEach(function (source, index) {
182089
- var bit = Math.pow(2, index);
182090
- subscribe(source, function (value) {
182091
- values[index] = value;
182092
- called = called | bit;
182031
+ // Avoid "IndexSizeError"
182032
+ if (dstWidth > 0 && dstHeight > 0) {
182033
+ var scale = width / initialWidth;
182034
+ params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale);
182035
+ }
182093
182036
 
182094
- if (called === allCalled) {
182095
- publish(innerSubject, values);
182096
- }
182097
- });
182098
- });
182099
- return function (action, subscription) {
182100
- switch (action) {
182101
- case SUBSCRIBE:
182102
- if (called === allCalled) {
182103
- subscription(values);
182037
+ // All the numerical parameters should be integer for `drawImage`
182038
+ // https://github.com/fengyuanchen/cropper/issues/476
182039
+ context.drawImage.apply(context, [source].concat(_toConsumableArray(params.map(function (param) {
182040
+ return Math.floor(normalizeDecimalNumber(param));
182041
+ }))));
182042
+ return canvas;
182043
+ },
182044
+ /**
182045
+ * Change the aspect ratio of the crop box.
182046
+ * @param {number} aspectRatio - The new aspect ratio.
182047
+ * @returns {Cropper} this
182048
+ */
182049
+ setAspectRatio: function setAspectRatio(aspectRatio) {
182050
+ var options = this.options;
182051
+ if (!this.disabled && !isUndefined(aspectRatio)) {
182052
+ // 0 -> NaN
182053
+ options.aspectRatio = Math.max(0, aspectRatio) || NaN;
182054
+ if (this.ready) {
182055
+ this.initCropBox();
182056
+ if (this.cropped) {
182057
+ this.renderCropBox();
182104
182058
  }
182105
-
182106
- return subscribe(innerSubject, subscription);
182107
-
182108
- case RESET:
182109
- return reset(innerSubject);
182110
-
182111
- default:
182112
- throw new Error("unrecognized action " + action);
182059
+ }
182113
182060
  }
182114
- };
182115
- }
182116
-
182117
- /**
182118
- * `system` defines a specification of a system - its constructor, dependencies and if it should act as a singleton in a system dependency tree.
182119
- * When called, system returns a [[SystemSpec]], which is then initialized along with its dependencies by passing it to [[init]].
182120
- *
182121
- * ```ts
182122
- * @import { subscribe, publish, system, init, tup, connect, map, pipe } from 'urx'
182123
- *
182124
- * // a simple system with two streams
182125
- * const sys1 = system(() => {
182126
- * const a = stream<number>()
182127
- * const b = stream<number>()
182128
- *
182129
- * connect(pipe(a, map(value => value * 2)), b)
182130
- * return { a, b }
182131
- * })
182132
- *
182133
- * // a second system which depends on the streams from the first one
182134
- * const sys2 = system(([ {a, b} ]) => {
182135
- * const c = stream<number>()
182136
- * connect(pipe(b, map(value => value * 2)), c)
182137
- * // re-export the `a` stream, keep `b` internal
182138
- * return { a, c }
182139
- * }, tup(sys1))
182140
- *
182141
- * // init will recursively initialize sys2 dependencies, in this case sys1
182142
- * const { a, c } = init(sys2)
182143
- * subscribe(c, c => console.log(`Value multiplied by 4`, c))
182144
- * publish(a, 2)
182145
- * ```
182146
- *
182147
- * #### Singletons in Dependency Tree
182148
- *
182149
- * By default, systems will be initialized only once if encountered multiple times in the dependency tree.
182150
- * In the below dependency system tree, systems `b` and `c` will receive the same stream instances from system `a` when system `d` is initialized.
182151
- * ```txt
182152
- * a
182153
- * / \
182154
- * b c
182155
- * \ /
182156
- * d
182157
- * ```
182158
- * If `a` gets `{singleton: false}` as a last argument, `init` creates two separate instances - one for `b` and one for `c`.
182159
- *
182160
- * @param constructor the system constructor function. Initialize and connect the streams in its body.
182161
- *
182162
- * @param dependencies the system dependencies, which the constructor will receive as arguments.
182163
- * Use the [[tup]] utility **For TypeScript type inference to work correctly**.
182164
- * ```ts
182165
- * const sys3 = system(() => { ... }, tup(sys2, sys1))
182166
- * ```
182167
- * @param __namedParameters Options
182168
- * @param singleton determines if the system will act as a singleton in a system dependency tree. `true` by default.
182169
- */
182170
- function system(constructor, dependencies, _temp) {
182171
- if (dependencies === void 0) {
182172
- dependencies = [];
182061
+ return this;
182062
+ },
182063
+ /**
182064
+ * Change the drag mode.
182065
+ * @param {string} mode - The new drag mode.
182066
+ * @returns {Cropper} this
182067
+ */
182068
+ setDragMode: function setDragMode(mode) {
182069
+ var options = this.options,
182070
+ dragBox = this.dragBox,
182071
+ face = this.face;
182072
+ if (this.ready && !this.disabled) {
182073
+ var croppable = mode === DRAG_MODE_CROP;
182074
+ var movable = options.movable && mode === DRAG_MODE_MOVE;
182075
+ mode = croppable || movable ? mode : DRAG_MODE_NONE;
182076
+ options.dragMode = mode;
182077
+ setData(dragBox, DATA_ACTION, mode);
182078
+ toggleClass(dragBox, CLASS_CROP, croppable);
182079
+ toggleClass(dragBox, CLASS_MOVE, movable);
182080
+ if (!options.cropBoxMovable) {
182081
+ // Sync drag mode to crop box when it is not movable
182082
+ setData(face, DATA_ACTION, mode);
182083
+ toggleClass(face, CLASS_CROP, croppable);
182084
+ toggleClass(face, CLASS_MOVE, movable);
182085
+ }
182086
+ }
182087
+ return this;
182173
182088
  }
182174
-
182175
- var _ref = _temp === void 0 ? {
182176
- singleton: true
182177
- } : _temp,
182178
- singleton = _ref.singleton;
182179
-
182180
- return {
182181
- id: id(),
182182
- constructor: constructor,
182183
- dependencies: dependencies,
182184
- singleton: singleton
182185
- };
182186
- }
182187
- /** @internal */
182188
-
182189
- var id = function id() {
182190
- return Symbol();
182191
182089
  };
182192
- /**
182193
- * Initializes a [[SystemSpec]] by recursively initializing its dependencies.
182194
- *
182195
- * ```ts
182196
- * // a simple system with two streams
182197
- * const sys1 = system(() => {
182198
- * const a = stream<number>()
182199
- * const b = stream<number>()
182200
- *
182201
- * connect(pipe(a, map(value => value * 2)), b)
182202
- * return { a, b }
182203
- * })
182204
- *
182205
- * const { a, b } = init(sys1)
182206
- * subscribe(b, b => console.log(b))
182207
- * publish(a, 2)
182208
- * ```
182209
- *
182210
- * @returns the [[System]] constructed by the spec constructor.
182211
- * @param systemSpec the system spec to initialize.
182212
- */
182213
-
182214
-
182215
- function init(systemSpec) {
182216
- var singletons = new Map();
182217
-
182218
- var _init = function _init(_ref2) {
182219
- var id = _ref2.id,
182220
- constructor = _ref2.constructor,
182221
- dependencies = _ref2.dependencies,
182222
- singleton = _ref2.singleton;
182223
-
182224
- if (singleton && singletons.has(id)) {
182225
- return singletons.get(id);
182226
- }
182227
-
182228
- var system = constructor(dependencies.map(function (e) {
182229
- return _init(e);
182230
- }));
182231
182090
 
182232
- if (singleton) {
182233
- singletons.set(id, system);
182091
+ var AnotherCropper = WINDOW.Cropper;
182092
+ var Cropper = /*#__PURE__*/function () {
182093
+ /**
182094
+ * Create a new Cropper.
182095
+ * @param {Element} element - The target element for cropping.
182096
+ * @param {Object} [options={}] - The configuration options.
182097
+ */
182098
+ function Cropper(element) {
182099
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
182100
+ _classCallCheck(this, Cropper);
182101
+ if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
182102
+ throw new Error('The first argument is required and must be an <img> or <canvas> element.');
182234
182103
  }
182235
-
182236
- return system;
182237
- };
182238
-
182239
- return _init(systemSpec);
182240
- }
182241
-
182242
- function _objectWithoutPropertiesLoose(source, excluded) {
182243
- if (source == null) return {};
182244
- var target = {};
182245
- var sourceKeys = Object.keys(source);
182246
- var key, i;
182247
-
182248
- for (i = 0; i < sourceKeys.length; i++) {
182249
- key = sourceKeys[i];
182250
- if (excluded.indexOf(key) >= 0) continue;
182251
- target[key] = source[key];
182104
+ this.element = element;
182105
+ this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
182106
+ this.cropped = false;
182107
+ this.disabled = false;
182108
+ this.pointers = {};
182109
+ this.ready = false;
182110
+ this.reloading = false;
182111
+ this.replaced = false;
182112
+ this.sized = false;
182113
+ this.sizing = false;
182114
+ this.init();
182252
182115
  }
182116
+ return _createClass(Cropper, [{
182117
+ key: "init",
182118
+ value: function init() {
182119
+ var element = this.element;
182120
+ var tagName = element.tagName.toLowerCase();
182121
+ var url;
182122
+ if (element[NAMESPACE]) {
182123
+ return;
182124
+ }
182125
+ element[NAMESPACE] = this;
182126
+ if (tagName === 'img') {
182127
+ this.isImg = true;
182253
182128
 
182254
- return target;
182255
- }
182129
+ // e.g.: "img/picture.jpg"
182130
+ url = element.getAttribute('src') || '';
182131
+ this.originalUrl = url;
182256
182132
 
182257
- function _unsupportedIterableToArray(o, minLen) {
182258
- if (!o) return;
182259
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
182260
- var n = Object.prototype.toString.call(o).slice(8, -1);
182261
- if (n === "Object" && o.constructor) n = o.constructor.name;
182262
- if (n === "Map" || n === "Set") return Array.from(o);
182263
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
182264
- }
182133
+ // Stop when it's a blank image
182134
+ if (!url) {
182135
+ return;
182136
+ }
182265
182137
 
182266
- function _arrayLikeToArray(arr, len) {
182267
- if (len == null || len > arr.length) len = arr.length;
182138
+ // e.g.: "https://example.com/img/picture.jpg"
182139
+ url = element.src;
182140
+ } else if (tagName === 'canvas' && window.HTMLCanvasElement) {
182141
+ url = element.toDataURL();
182142
+ }
182143
+ this.load(url);
182144
+ }
182145
+ }, {
182146
+ key: "load",
182147
+ value: function load(url) {
182148
+ var _this = this;
182149
+ if (!url) {
182150
+ return;
182151
+ }
182152
+ this.url = url;
182153
+ this.imageData = {};
182154
+ var element = this.element,
182155
+ options = this.options;
182156
+ if (!options.rotatable && !options.scalable) {
182157
+ options.checkOrientation = false;
182158
+ }
182268
182159
 
182269
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
182160
+ // Only IE10+ supports Typed Arrays
182161
+ if (!options.checkOrientation || !window.ArrayBuffer) {
182162
+ this.clone();
182163
+ return;
182164
+ }
182270
182165
 
182271
- return arr2;
182272
- }
182166
+ // Detect the mime type of the image directly if it is a Data URL
182167
+ if (REGEXP_DATA_URL.test(url)) {
182168
+ // Read ArrayBuffer from Data URL of JPEG images directly for better performance
182169
+ if (REGEXP_DATA_URL_JPEG.test(url)) {
182170
+ this.read(dataURLToArrayBuffer(url));
182171
+ } else {
182172
+ // Only a JPEG image may contains Exif Orientation information,
182173
+ // the rest types of Data URLs are not necessary to check orientation at all.
182174
+ this.clone();
182175
+ }
182176
+ return;
182177
+ }
182273
182178
 
182274
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
182275
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
182276
- if (it) return (it = it.call(o)).next.bind(it);
182179
+ // 1. Detect the mime type of the image by a XMLHttpRequest.
182180
+ // 2. Load the image as ArrayBuffer for reading orientation if its a JPEG image.
182181
+ var xhr = new XMLHttpRequest();
182182
+ var clone = this.clone.bind(this);
182183
+ this.reloading = true;
182184
+ this.xhr = xhr;
182277
182185
 
182278
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
182279
- if (it) o = it;
182280
- var i = 0;
182281
- return function () {
182282
- if (i >= o.length) return {
182283
- done: true
182186
+ // 1. Cross origin requests are only supported for protocol schemes:
182187
+ // http, https, data, chrome, chrome-extension.
182188
+ // 2. Access to XMLHttpRequest from a Data URL will be blocked by CORS policy
182189
+ // in some browsers as IE11 and Safari.
182190
+ xhr.onabort = clone;
182191
+ xhr.onerror = clone;
182192
+ xhr.ontimeout = clone;
182193
+ xhr.onprogress = function () {
182194
+ // Abort the request directly if it not a JPEG image for better performance
182195
+ if (xhr.getResponseHeader('content-type') !== MIME_TYPE_JPEG) {
182196
+ xhr.abort();
182197
+ }
182284
182198
  };
182285
- return {
182286
- done: false,
182287
- value: o[i++]
182199
+ xhr.onload = function () {
182200
+ _this.read(xhr.response);
182201
+ };
182202
+ xhr.onloadend = function () {
182203
+ _this.reloading = false;
182204
+ _this.xhr = null;
182288
182205
  };
182289
- };
182290
- }
182291
-
182292
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
182293
- }
182294
-
182295
- var _excluded = ["children"];
182296
- /** @internal */
182297
-
182298
- function omit(keys, obj) {
182299
- var result = {};
182300
- var index = {};
182301
- var idx = 0;
182302
- var len = keys.length;
182303
-
182304
- while (idx < len) {
182305
- index[keys[idx]] = 1;
182306
- idx += 1;
182307
- }
182308
-
182309
- for (var prop in obj) {
182310
- if (!index.hasOwnProperty(prop)) {
182311
- result[prop] = obj[prop];
182312
- }
182313
- }
182314
-
182315
- return result;
182316
- }
182317
-
182318
- var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect$2 : useEffect;
182319
- /**
182320
- * Converts a system spec to React component by mapping the system streams to component properties, events and methods. Returns hooks for querying and modifying
182321
- * the system streams from the component's child components.
182322
- * @param systemSpec The return value from a [[system]] call.
182323
- * @param map The streams to props / events / methods mapping Check [[SystemPropsMap]] for more details.
182324
- * @param Root The optional React component to render. By default, the resulting component renders nothing, acting as a logical wrapper for its children.
182325
- * @returns an object containing the following:
182326
- * - `Component`: the React component.
182327
- * - `useEmitterValue`: a hook that lets child components use values emitted from the specified output stream.
182328
- * - `useEmitter`: a hook that calls the provided callback whenever the specified stream emits a value.
182329
- * - `usePublisher`: a hook which lets child components publish values to the specified stream.
182330
- * <hr />
182331
- */
182332
-
182333
- function systemToComponent(systemSpec, map, Root) {
182334
- var requiredPropNames = Object.keys(map.required || {});
182335
- var optionalPropNames = Object.keys(map.optional || {});
182336
- var methodNames = Object.keys(map.methods || {});
182337
- var eventNames = Object.keys(map.events || {});
182338
- var Context = createContext$1({});
182339
182206
 
182340
- function applyPropsToSystem(system, props) {
182341
- if (system['propsReady']) {
182342
- publish(system['propsReady'], false);
182343
- }
182207
+ // Bust cache when there is a "crossOrigin" property to avoid browser cache error
182208
+ if (options.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) {
182209
+ url = addTimestamp(url);
182210
+ }
182344
182211
 
182345
- for (var _iterator = _createForOfIteratorHelperLoose(requiredPropNames), _step; !(_step = _iterator()).done;) {
182346
- var requiredPropName = _step.value;
182347
- var stream = system[map.required[requiredPropName]];
182348
- publish(stream, props[requiredPropName]);
182212
+ // The third parameter is required for avoiding side-effect (#682)
182213
+ xhr.open('GET', url, true);
182214
+ xhr.responseType = 'arraybuffer';
182215
+ xhr.withCredentials = element.crossOrigin === 'use-credentials';
182216
+ xhr.send();
182349
182217
  }
182218
+ }, {
182219
+ key: "read",
182220
+ value: function read(arrayBuffer) {
182221
+ var options = this.options,
182222
+ imageData = this.imageData;
182350
182223
 
182351
- for (var _iterator2 = _createForOfIteratorHelperLoose(optionalPropNames), _step2; !(_step2 = _iterator2()).done;) {
182352
- var optionalPropName = _step2.value;
182353
-
182354
- if (optionalPropName in props) {
182355
- var _stream = system[map.optional[optionalPropName]];
182356
- publish(_stream, props[optionalPropName]);
182224
+ // Reset the orientation value to its default value 1
182225
+ // as some iOS browsers will render image with its orientation
182226
+ var orientation = resetAndGetOrientation(arrayBuffer);
182227
+ var rotate = 0;
182228
+ var scaleX = 1;
182229
+ var scaleY = 1;
182230
+ if (orientation > 1) {
182231
+ // Generate a new URL which has the default orientation value
182232
+ this.url = arrayBufferToDataURL(arrayBuffer, MIME_TYPE_JPEG);
182233
+ var _parseOrientation = parseOrientation(orientation);
182234
+ rotate = _parseOrientation.rotate;
182235
+ scaleX = _parseOrientation.scaleX;
182236
+ scaleY = _parseOrientation.scaleY;
182357
182237
  }
182238
+ if (options.rotatable) {
182239
+ imageData.rotate = rotate;
182240
+ }
182241
+ if (options.scalable) {
182242
+ imageData.scaleX = scaleX;
182243
+ imageData.scaleY = scaleY;
182244
+ }
182245
+ this.clone();
182358
182246
  }
182247
+ }, {
182248
+ key: "clone",
182249
+ value: function clone() {
182250
+ var element = this.element,
182251
+ url = this.url;
182252
+ var crossOrigin = element.crossOrigin;
182253
+ var crossOriginUrl = url;
182254
+ if (this.options.checkCrossOrigin && isCrossOriginURL(url)) {
182255
+ if (!crossOrigin) {
182256
+ crossOrigin = 'anonymous';
182257
+ }
182359
182258
 
182360
- if (system['propsReady']) {
182361
- publish(system['propsReady'], true);
182259
+ // Bust cache when there is not a "crossOrigin" property (#519)
182260
+ crossOriginUrl = addTimestamp(url);
182261
+ }
182262
+ this.crossOrigin = crossOrigin;
182263
+ this.crossOriginUrl = crossOriginUrl;
182264
+ var image = document.createElement('img');
182265
+ if (crossOrigin) {
182266
+ image.crossOrigin = crossOrigin;
182267
+ }
182268
+ image.src = crossOriginUrl || url;
182269
+ image.alt = element.alt || 'The image to crop';
182270
+ this.image = image;
182271
+ image.onload = this.start.bind(this);
182272
+ image.onerror = this.stop.bind(this);
182273
+ addClass(image, CLASS_HIDE);
182274
+ element.parentNode.insertBefore(image, element.nextSibling);
182362
182275
  }
182363
- }
182364
-
182365
- function buildMethods(system) {
182366
- return methodNames.reduce(function (acc, methodName) {
182276
+ }, {
182277
+ key: "start",
182278
+ value: function start() {
182279
+ var _this2 = this;
182280
+ var image = this.image;
182281
+ image.onload = null;
182282
+ image.onerror = null;
182283
+ this.sizing = true;
182367
182284
 
182368
- acc[methodName] = function (value) {
182369
- var stream = system[map.methods[methodName]];
182370
- publish(stream, value);
182285
+ // Match all browsers that use WebKit as the layout engine in iOS devices,
182286
+ // such as Safari for iOS, Chrome for iOS, and in-app browsers.
182287
+ var isIOSWebKit = WINDOW.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent);
182288
+ var done = function done(naturalWidth, naturalHeight) {
182289
+ assign(_this2.imageData, {
182290
+ naturalWidth: naturalWidth,
182291
+ naturalHeight: naturalHeight,
182292
+ aspectRatio: naturalWidth / naturalHeight
182293
+ });
182294
+ _this2.initialImageData = assign({}, _this2.imageData);
182295
+ _this2.sizing = false;
182296
+ _this2.sized = true;
182297
+ _this2.build();
182371
182298
  };
182372
182299
 
182373
- return acc;
182374
- }, {});
182375
- }
182376
-
182377
- function buildEventHandlers(system) {
182378
- return eventNames.reduce(function (handlers, eventName) {
182379
- handlers[eventName] = eventHandler(system[map.events[eventName]]);
182380
- return handlers;
182381
- }, {});
182382
- }
182383
- /**
182384
- * A React component generated from an urx system
182385
- */
182386
-
182387
-
182388
- var Component = forwardRef(function (propsWithChildren, ref) {
182389
- var children = propsWithChildren.children,
182390
- props = _objectWithoutPropertiesLoose(propsWithChildren, _excluded);
182391
-
182392
- var _useState = useState(function () {
182393
- return tap(init(systemSpec), function (system) {
182394
- return applyPropsToSystem(system, props);
182395
- });
182396
- }),
182397
- system = _useState[0];
182398
-
182399
- var _useState2 = useState(curry1to0(buildEventHandlers, system)),
182400
- handlers = _useState2[0];
182401
-
182402
- useIsomorphicLayoutEffect(function () {
182403
- for (var _iterator3 = _createForOfIteratorHelperLoose(eventNames), _step3; !(_step3 = _iterator3()).done;) {
182404
- var eventName = _step3.value;
182405
-
182406
- if (eventName in props) {
182407
- subscribe(handlers[eventName], props[eventName]);
182408
- }
182300
+ // Most modern browsers (excepts iOS WebKit)
182301
+ if (image.naturalWidth && !isIOSWebKit) {
182302
+ done(image.naturalWidth, image.naturalHeight);
182303
+ return;
182409
182304
  }
182410
-
182411
- return function () {
182412
- Object.values(handlers).map(reset);
182305
+ var sizingImage = document.createElement('img');
182306
+ var body = document.body || document.documentElement;
182307
+ this.sizingImage = sizingImage;
182308
+ sizingImage.onload = function () {
182309
+ done(sizingImage.width, sizingImage.height);
182310
+ if (!isIOSWebKit) {
182311
+ body.removeChild(sizingImage);
182312
+ }
182413
182313
  };
182414
- }, [props, handlers, system]);
182415
- useIsomorphicLayoutEffect(function () {
182416
- applyPropsToSystem(system, props);
182417
- });
182418
- useImperativeHandle(ref, always(buildMethods(system)));
182419
- return createElement$2(Context.Provider, {
182420
- value: system
182421
- }, Root ? createElement$2(Root, omit([].concat(requiredPropNames, optionalPropNames, eventNames), props), children) : children);
182422
- });
182314
+ sizingImage.src = image.src;
182423
182315
 
182424
- var usePublisher = function usePublisher(key) {
182425
- return useCallback(curry2to1(publish, useContext$1(Context)[key]), [key]);
182426
- };
182427
- /**
182428
- * Returns the value emitted from the stream.
182429
- */
182316
+ // iOS WebKit will convert the image automatically
182317
+ // with its orientation once append it into DOM (#279)
182318
+ if (!isIOSWebKit) {
182319
+ sizingImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
182320
+ body.appendChild(sizingImage);
182321
+ }
182322
+ }
182323
+ }, {
182324
+ key: "stop",
182325
+ value: function stop() {
182326
+ var image = this.image;
182327
+ image.onload = null;
182328
+ image.onerror = null;
182329
+ image.parentNode.removeChild(image);
182330
+ this.image = null;
182331
+ }
182332
+ }, {
182333
+ key: "build",
182334
+ value: function build() {
182335
+ if (!this.sized || this.ready) {
182336
+ return;
182337
+ }
182338
+ var element = this.element,
182339
+ options = this.options,
182340
+ image = this.image;
182430
182341
 
182342
+ // Create cropper elements
182343
+ var container = element.parentNode;
182344
+ var template = document.createElement('div');
182345
+ template.innerHTML = TEMPLATE;
182346
+ var cropper = template.querySelector(".".concat(NAMESPACE, "-container"));
182347
+ var canvas = cropper.querySelector(".".concat(NAMESPACE, "-canvas"));
182348
+ var dragBox = cropper.querySelector(".".concat(NAMESPACE, "-drag-box"));
182349
+ var cropBox = cropper.querySelector(".".concat(NAMESPACE, "-crop-box"));
182350
+ var face = cropBox.querySelector(".".concat(NAMESPACE, "-face"));
182351
+ this.container = container;
182352
+ this.cropper = cropper;
182353
+ this.canvas = canvas;
182354
+ this.dragBox = dragBox;
182355
+ this.cropBox = cropBox;
182356
+ this.viewBox = cropper.querySelector(".".concat(NAMESPACE, "-view-box"));
182357
+ this.face = face;
182358
+ canvas.appendChild(image);
182431
182359
 
182432
- var useEmitterValue = function useEmitterValue(key) {
182433
- var context = useContext$1(Context);
182434
- var source = context[key];
182360
+ // Hide the original image
182361
+ addClass(element, CLASS_HIDDEN);
182435
182362
 
182436
- var _useState3 = useState(curry1to0(getValue, source)),
182437
- value = _useState3[0],
182438
- setValue = _useState3[1];
182363
+ // Inserts the cropper after to the current image
182364
+ container.insertBefore(cropper, element.nextSibling);
182439
182365
 
182440
- useIsomorphicLayoutEffect(function () {
182441
- return subscribe(source, function (next) {
182442
- if (next !== value) {
182443
- setValue(always(next));
182444
- }
182445
- });
182446
- }, [source, value]);
182447
- return value;
182448
- };
182366
+ // Show the hidden image
182367
+ removeClass(image, CLASS_HIDE);
182368
+ this.initPreview();
182369
+ this.bind();
182370
+ options.initialAspectRatio = Math.max(0, options.initialAspectRatio) || NaN;
182371
+ options.aspectRatio = Math.max(0, options.aspectRatio) || NaN;
182372
+ options.viewMode = Math.max(0, Math.min(3, Math.round(options.viewMode))) || 0;
182373
+ addClass(cropBox, CLASS_HIDDEN);
182374
+ if (!options.guides) {
182375
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-dashed")), CLASS_HIDDEN);
182376
+ }
182377
+ if (!options.center) {
182378
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-center")), CLASS_HIDDEN);
182379
+ }
182380
+ if (options.background) {
182381
+ addClass(cropper, "".concat(NAMESPACE, "-bg"));
182382
+ }
182383
+ if (!options.highlight) {
182384
+ addClass(face, CLASS_INVISIBLE);
182385
+ }
182386
+ if (options.cropBoxMovable) {
182387
+ addClass(face, CLASS_MOVE);
182388
+ setData(face, DATA_ACTION, ACTION_ALL);
182389
+ }
182390
+ if (!options.cropBoxResizable) {
182391
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-line")), CLASS_HIDDEN);
182392
+ addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-point")), CLASS_HIDDEN);
182393
+ }
182394
+ this.render();
182395
+ this.ready = true;
182396
+ this.setDragMode(options.dragMode);
182397
+ if (options.autoCrop) {
182398
+ this.crop();
182399
+ }
182400
+ this.setData(options.data);
182401
+ if (isFunction(options.ready)) {
182402
+ addListener(element, EVENT_READY, options.ready, {
182403
+ once: true
182404
+ });
182405
+ }
182406
+ dispatchEvent(element, EVENT_READY);
182407
+ }
182408
+ }, {
182409
+ key: "unbuild",
182410
+ value: function unbuild() {
182411
+ if (!this.ready) {
182412
+ return;
182413
+ }
182414
+ this.ready = false;
182415
+ this.unbind();
182416
+ this.resetPreview();
182417
+ var parentNode = this.cropper.parentNode;
182418
+ if (parentNode) {
182419
+ parentNode.removeChild(this.cropper);
182420
+ }
182421
+ removeClass(this.element, CLASS_HIDDEN);
182422
+ }
182423
+ }, {
182424
+ key: "uncreate",
182425
+ value: function uncreate() {
182426
+ if (this.ready) {
182427
+ this.unbuild();
182428
+ this.ready = false;
182429
+ this.cropped = false;
182430
+ } else if (this.sizing) {
182431
+ this.sizingImage.onload = null;
182432
+ this.sizing = false;
182433
+ this.sized = false;
182434
+ } else if (this.reloading) {
182435
+ this.xhr.onabort = null;
182436
+ this.xhr.abort();
182437
+ } else if (this.image) {
182438
+ this.stop();
182439
+ }
182440
+ }
182449
182441
 
182450
- var useEmitter = function useEmitter(key, callback) {
182451
- var context = useContext$1(Context);
182452
- var source = context[key];
182453
- useIsomorphicLayoutEffect(function () {
182454
- return subscribe(source, callback);
182455
- }, [callback, source]);
182456
- };
182442
+ /**
182443
+ * Get the no conflict cropper class.
182444
+ * @returns {Cropper} The cropper class.
182445
+ */
182446
+ }], [{
182447
+ key: "noConflict",
182448
+ value: function noConflict() {
182449
+ window.Cropper = AnotherCropper;
182450
+ return Cropper;
182451
+ }
182457
182452
 
182458
- return {
182459
- Component: Component,
182460
- usePublisher: usePublisher,
182461
- useEmitterValue: useEmitterValue,
182462
- useEmitter: useEmitter
182463
- };
182464
- }
182453
+ /**
182454
+ * Change the default options.
182455
+ * @param {Object} options - The new default options.
182456
+ */
182457
+ }, {
182458
+ key: "setDefaults",
182459
+ value: function setDefaults(options) {
182460
+ assign(DEFAULTS, isPlainObject(options) && options);
182461
+ }
182462
+ }]);
182463
+ }();
182464
+ assign(Cropper.prototype, render, preview, events, handlers, change, methods);
182465
182465
 
182466
- function c(){return c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);}return t},c.apply(this,arguments)}function m(t,e){if(null==t)return {};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(r[n]=t[n]);return r}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=new Array(e);n<e;n++)o[n]=t[n];return o}function f(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return (n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return d(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var p,h,g="undefined"!=typeof document?useLayoutEffect$2:useEffect;!function(t){t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR";}(h||(h={}));var v=((p={})[h.DEBUG]="debug",p[h.INFO]="log",p[h.WARN]="warn",p[h.ERROR]="error",p),S=system(function(){var t=statefulStream(h.ERROR);return {log:statefulStream(function(n,o,r){var i;void 0===r&&(r=h.INFO),r>=(null!=(i=("undefined"==typeof globalThis?window:globalThis).VIRTUOSO_LOG_LEVEL)?i:getValue(t))&&console[v[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",n,o);}),logLevel:t}},[],{singleton:!0});function C(t,e){void 0===e&&(e=!0);var n=useRef(null),o=function(t){};if("undefined"!=typeof ResizeObserver){var r=new ResizeObserver(function(e){var n=e[0].target;null!==n.offsetParent&&t(n);});o=function(t){t&&e?(r.observe(t),n.current=t):(n.current&&r.unobserve(n.current),n.current=null);};}return {ref:n,callbackRef:o}}function I(t,e){return void 0===e&&(e=!0),C(t,e).callbackRef}function T(t,e,n,o,r,i,a){return C(function(n){for(var l=function(t,e,n,o){var r=t.length;if(0===r)return null;for(var i=[],a=0;a<r;a++){var l=t.item(a);if(l&&void 0!==l.dataset.index){var s=parseInt(l.dataset.index),u=parseFloat(l.dataset.knownSize),c=e(l,"offsetHeight");if(0===c&&o("Zero-sized element, this should not happen",{child:l},h.ERROR),c!==u){var m=i[i.length-1];0===i.length||m.size!==c||m.endIndex!==s-1?i.push({startIndex:s,endIndex:s,size:c}):i[i.length-1].endIndex++;}}}return i}(n.children,e,0,r),s=n.parentElement;!s.dataset.virtuosoScroller;)s=s.parentElement;var u="window"===s.firstElementChild.dataset.viewportType,c=a?a.scrollTop:u?window.pageYOffset||document.documentElement.scrollTop:s.scrollTop,m=a?a.scrollHeight:u?document.documentElement.scrollHeight:s.scrollHeight,d=a?a.offsetHeight:u?window.innerHeight:s.offsetHeight;o({scrollTop:Math.max(c,0),scrollHeight:m,viewportHeight:d}),null==i||i(function(t,e,n){return "normal"===e||null!=e&&e.endsWith("px")||n("row-gap was not resolved to pixel value correctly",e,h.WARN),"normal"===e?0:parseInt(null!=e?e:"0",10)}(0,getComputedStyle(n).rowGap,r)),null!==l&&t(l);},n)}function w(t,e){return Math.round(t.getBoundingClientRect()[e])}function x(t,e){return Math.abs(t-e)<1.01}function b(t,n,o,l,s){void 0===l&&(l=noop);var c=useRef(null),m=useRef(null),d=useRef(null),f=useRef(!1),p=useCallback(function(e){var o=e.target,r=o===window||o===document,i=r?window.pageYOffset||document.documentElement.scrollTop:o.scrollTop,a=r?document.documentElement.scrollHeight:o.scrollHeight,l=r?window.innerHeight:o.offsetHeight,s=function(){t({scrollTop:Math.max(i,0),scrollHeight:a,viewportHeight:l});};f.current?flushSync(s):s(),f.current=!1,null!==m.current&&(i===m.current||i<=0||i===a-l)&&(m.current=null,n(!0),d.current&&(clearTimeout(d.current),d.current=null));},[t,n]);return useEffect(function(){var t=s||c.current;return l(s||c.current),p({target:t}),t.addEventListener("scroll",p,{passive:!0}),function(){l(null),t.removeEventListener("scroll",p);}},[c,p,o,l,s]),{scrollerRef:c,scrollByCallback:function(t){f.current=!0,c.current.scrollBy(t);},scrollToCallback:function(e){var o=c.current;if(o&&(!("offsetHeight"in o)||0!==o.offsetHeight)){var r,i,a,l="smooth"===e.behavior;if(o===window?(i=Math.max(w(document.documentElement,"height"),document.documentElement.scrollHeight),r=window.innerHeight,a=document.documentElement.scrollTop):(i=o.scrollHeight,r=w(o,"height"),a=o.scrollTop),e.top=Math.ceil(Math.max(Math.min(i-r,e.top),0)),x(r,i)||e.top===a)return t({scrollTop:a,scrollHeight:i,viewportHeight:r}),void(l&&n(!0));l?(m.current=e.top,d.current&&clearTimeout(d.current),d.current=setTimeout(function(){d.current=null,m.current=null,n(!0);},1e3)):m.current=null,o.scrollTo(e);}}}}var y=system(function(){var t=stream(),n=stream(),o=statefulStream(0),r=stream(),i=statefulStream(0),a=stream(),l=stream(),s=statefulStream(0),u=statefulStream(0),c=statefulStream(0),m=statefulStream(0),d=stream(),f=stream(),p=statefulStream(!1),h=statefulStream(!1);return connect(pipe(t,map(function(t){return t.scrollTop})),n),connect(pipe(t,map(function(t){return t.scrollHeight})),l),connect(n,i),{scrollContainerState:t,scrollTop:n,viewportHeight:a,headerHeight:s,fixedHeaderHeight:u,fixedFooterHeight:c,footerHeight:m,scrollHeight:l,smoothScrollTargetReached:r,react18ConcurrentRendering:h,scrollTo:d,scrollBy:f,statefulScrollTop:i,deviation:o,scrollingInProgress:p}},[],{singleton:!0}),H={lvl:0};function E(t,e,n,o,r){return void 0===o&&(o=H),void 0===r&&(r=H),{k:t,v:e,lvl:n,l:o,r:r}}function R(t){return t===H}function L(){return H}function F(t,e){if(R(t))return H;var n=t.k,o=t.l,r=t.r;if(e===n){if(R(o))return r;if(R(r))return o;var i=O(o);return U(W(t,{k:i[0],v:i[1],l:M(o)}))}return U(W(t,e<n?{l:F(o,e)}:{r:F(r,e)}))}function k(t,e,n){if(void 0===n&&(n="k"),R(t))return [-Infinity,void 0];if(t[n]===e)return [t.k,t.v];if(t[n]<e){var o=k(t.r,e,n);return -Infinity===o[0]?[t.k,t.v]:o}return k(t.l,e,n)}function z(t,e,n){return R(t)?E(e,n,1):e===t.k?W(t,{k:e,v:n}):function(t){return D(G(t))}(W(t,e<t.k?{l:z(t.l,e,n)}:{r:z(t.r,e,n)}))}function B(t,e,n){if(R(t))return [];var o=t.k,r=t.v,i=t.r,a=[];return o>e&&(a=a.concat(B(t.l,e,n))),o>=e&&o<=n&&a.push({k:o,v:r}),o<=n&&(a=a.concat(B(i,e,n))),a}function P(t){return R(t)?[]:[].concat(P(t.l),[{k:t.k,v:t.v}],P(t.r))}function O(t){return R(t.r)?[t.k,t.v]:O(t.r)}function M(t){return R(t.r)?t.l:U(W(t,{r:M(t.r)}))}function W(t,e){return E(void 0!==e.k?e.k:t.k,void 0!==e.v?e.v:t.v,void 0!==e.lvl?e.lvl:t.lvl,void 0!==e.l?e.l:t.l,void 0!==e.r?e.r:t.r)}function V(t){return R(t)||t.lvl>t.r.lvl}function U(t){var e=t.l,n=t.r,o=t.lvl;if(n.lvl>=o-1&&e.lvl>=o-1)return t;if(o>n.lvl+1){if(V(e))return G(W(t,{lvl:o-1}));if(R(e)||R(e.r))throw new Error("Unexpected empty nodes");return W(e.r,{l:W(e,{r:e.r.l}),r:W(t,{l:e.r.r,lvl:o-1}),lvl:o})}if(V(t))return D(W(t,{lvl:o-1}));if(R(n)||R(n.l))throw new Error("Unexpected empty nodes");var r=n.l,i=V(r)?n.lvl-1:n.lvl;return W(r,{l:W(t,{r:r.l,lvl:o-1}),r:D(W(n,{l:r.r,lvl:i})),lvl:r.lvl+1})}function A(t,e,n){return R(t)?[]:N(B(t,k(t,e)[0],n),function(t){return {index:t.k,value:t.v}})}function N(t,e){var n=t.length;if(0===n)return [];for(var o=e(t[0]),r=o.index,i=o.value,a=[],l=1;l<n;l++){var s=e(t[l]),u=s.index,c=s.value;a.push({start:r,end:u-1,value:i}),r=u,i=c;}return a.push({start:r,end:Infinity,value:i}),a}function D(t){var e=t.r,n=t.lvl;return R(e)||R(e.r)||e.lvl!==n||e.r.lvl!==n?t:W(e,{l:W(t,{r:e.l}),lvl:n+1})}function G(t){var e=t.l;return R(e)||e.lvl!==t.lvl?t:W(e,{r:W(t,{l:e.r})})}function _(t,e,n,o){void 0===o&&(o=0);for(var r=t.length-1;o<=r;){var i=Math.floor((o+r)/2),a=n(t[i],e);if(0===a)return i;if(-1===a){if(r-o<2)return i-1;r=i-1;}else {if(r===o)return i;o=i+1;}}throw new Error("Failed binary finding record in array - "+t.join(",")+", searched for "+e)}function j(t,e,n){return t[_(t,e,n)]}var K=system(function(){return {recalcInProgress:statefulStream(!1)}},[],{singleton:!0});function Y(t){var e=t.size,n=t.startIndex,o=t.endIndex;return function(t){return t.start===n&&(t.end===o||Infinity===t.end)&&t.value===e}}function q(t,e){var n=t.index;return e===n?0:e<n?-1:1}function Z(t,e){var n=t.offset;return e===n?0:e<n?-1:1}function J(t){return {index:t.index,value:t}}function $(t,e,n,o){var r=t,i=0,a=0,l=0,s=0;if(0!==e){l=r[s=_(r,e-1,q)].offset;var u=k(n,e-1);i=u[0],a=u[1],r.length&&r[s].size===k(n,e)[1]&&(s-=1),r=r.slice(0,s+1);}else r=[];for(var c,m=f(A(n,e,Infinity));!(c=m()).done;){var d=c.value,p=d.start,h=d.value,g=p-i,v=g*a+l+g*o;r.push({offset:v,size:h,index:p}),i=p,l=v,a=h;}return {offsetTree:r,lastIndex:i,lastOffset:l,lastSize:a}}function Q(t,e){var n=e[0],o=e[1],r=e[3];n.length>0&&(0, e[2])("received item sizes",n,h.DEBUG);var i=t.sizeTree,a=i,l=0;if(o.length>0&&R(i)&&2===n.length){var s=n[0].size,u=n[1].size;a=o.reduce(function(t,e){return z(z(t,e,s),e+1,u)},a);}else {var c=function(t,e){for(var n,o=R(t)?0:Infinity,r=f(e);!(n=r()).done;){var i=n.value,a=i.size,l=i.startIndex,s=i.endIndex;if(o=Math.min(o,l),R(t))t=z(t,0,a);else {var u=A(t,l-1,s+1);if(!u.some(Y(i))){for(var c,m=!1,d=!1,p=f(u);!(c=p()).done;){var h=c.value,g=h.start,v=h.end,S=h.value;m?(s>=g||a===S)&&(t=F(t,g)):(d=S!==a,m=!0),v>s&&s>=g&&S!==a&&(t=z(t,s+1,S));}d&&(t=z(t,l,a));}}}return [t,o]}(a,n);a=c[0],l=c[1];}if(a===i)return t;var m=$(t.offsetTree,l,a,r),d=m.offsetTree;return {sizeTree:a,offsetTree:d,lastIndex:m.lastIndex,lastOffset:m.lastOffset,lastSize:m.lastSize,groupOffsetTree:o.reduce(function(t,e){return z(t,e,X(e,d,r))},L()),groupIndices:o}}function X(t,e,n){if(0===e.length)return 0;var o=j(e,t,q),r=t-o.index,i=o.size*r+(r-1)*n+o.offset;return i>0?i+n:i}function tt$1(t,e,n){if(function(t){return void 0!==t.groupIndex}(t))return e.groupIndices[t.groupIndex]+1;var o=et("LAST"===t.index?n:t.index,e);return Math.max(0,o,Math.min(n,o))}function et(t,e){if(!nt(e))return t;for(var n=0;e.groupIndices[n]<=t+n;)n++;return t+n}function nt(t){return !R(t.groupOffsetTree)}var ot={offsetHeight:"height",offsetWidth:"width"},rt=system(function(t){var n=t[0].log,o=t[1].recalcInProgress,r=stream(),i=stream(),a=statefulStreamFromEmitter(i,0),l=stream(),s=stream(),u=statefulStream(0),m=statefulStream([]),d=statefulStream(void 0),f=statefulStream(void 0),p=statefulStream(function(t,e){return w(t,ot[e])}),g=statefulStream(void 0),v=statefulStream(0),S={offsetTree:[],sizeTree:L(),groupOffsetTree:L(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]},C=statefulStreamFromEmitter(pipe(r,withLatestFrom(m,n,v),scan(Q,S),distinctUntilChanged()),S);connect(pipe(m,filter(function(t){return t.length>0}),withLatestFrom(C,v),map(function(t){var e=t[0],n=t[1],o=t[2],r=e.reduce(function(t,e,r){return z(t,e,X(e,n.offsetTree,o)||r)},L());return c({},n,{groupIndices:e,groupOffsetTree:r})})),C),connect(pipe(i,withLatestFrom(C),filter(function(t){return t[0]<t[1].lastIndex}),map(function(t){var e=t[1];return [{startIndex:t[0],endIndex:e.lastIndex,size:e.lastSize}]})),r),connect(d,f);var I=statefulStreamFromEmitter(pipe(d,map(function(t){return void 0===t})),!0);connect(pipe(f,filter(function(t){return void 0!==t&&R(getValue(C).sizeTree)}),map(function(t){return [{startIndex:0,endIndex:0,size:t}]})),r);var T=streamFromEmitter(pipe(r,withLatestFrom(C),scan(function(t,e){var n=e[1];return {changed:n!==t.sizes,sizes:n}},{changed:!1,sizes:S}),map(function(t){return t.changed})));subscribe(pipe(u,scan(function(t,e){return {diff:t.prev-e,prev:e}},{diff:0,prev:0}),map(function(t){return t.diff})),function(t){t>0?(publish(o,!0),publish(l,t)):t<0&&publish(s,t);}),subscribe(pipe(u,withLatestFrom(n)),function(t){t[0]<0&&(0, t[1])("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:u},h.ERROR);});var x=streamFromEmitter(l);connect(pipe(l,withLatestFrom(C),map(function(t){var e=t[0],n=t[1];if(n.groupIndices.length>0)throw new Error("Virtuoso: prepending items does not work with groups");return P(n.sizeTree).reduce(function(t,n){var o=n.k,r=n.v;return {ranges:[].concat(t.ranges,[{startIndex:t.prevIndex,endIndex:o+e-1,size:t.prevSize}]),prevIndex:o+e,prevSize:r}},{ranges:[],prevIndex:0,prevSize:n.lastSize}).ranges})),r);var b=streamFromEmitter(pipe(s,withLatestFrom(C,v),map(function(t){return X(-t[0],t[1].offsetTree,t[2])})));return connect(pipe(s,withLatestFrom(C,v),map(function(t){var e=t[0],n=t[1],o=t[2];if(n.groupIndices.length>0)throw new Error("Virtuoso: shifting items does not work with groups");var r=P(n.sizeTree).reduce(function(t,n){var o=n.v;return z(t,Math.max(0,n.k+e),o)},L());return c({},n,{sizeTree:r},$(n.offsetTree,0,r,o))})),C),{data:g,totalCount:i,sizeRanges:r,groupIndices:m,defaultItemSize:f,fixedItemSize:d,unshiftWith:l,shiftWith:s,shiftWithOffset:b,beforeUnshiftWith:x,firstItemIndex:u,gap:v,sizes:C,listRefresh:T,statefulTotalCount:a,trackItemSizes:I,itemSize:p}},tup(S,K),{singleton:!0}),it="undefined"!=typeof document&&"scrollBehavior"in document.documentElement.style;function at(t){var e="number"==typeof t?{index:t}:t;return e.align||(e.align="start"),e.behavior&&it||(e.behavior="auto"),e.offset||(e.offset=0),e}var lt=system(function(t){var n=t[0],o=n.sizes,r=n.totalCount,i=n.listRefresh,a=n.gap,l=t[1],s=l.scrollingInProgress,u=l.viewportHeight,c=l.scrollTo,m=l.smoothScrollTargetReached,d=l.headerHeight,f=l.footerHeight,p=l.fixedHeaderHeight,g=l.fixedFooterHeight,v=t[2].log,S=stream(),C=statefulStream(0),I=null,T=null,w=null;function x(){I&&(I(),I=null),w&&(w(),w=null),T&&(clearTimeout(T),T=null),publish(s,!1);}return connect(pipe(S,withLatestFrom(o,u,r,C,d,f,v),withLatestFrom(a,p,g),map(function(t){var n=t[0],o=n[0],r=n[1],a=n[2],l=n[3],u=n[4],c=n[5],d=n[6],f=n[7],p=t[1],g=t[2],v=t[3],C=at(o),b=C.align,y=C.behavior,H=C.offset,E=l-1,R=tt$1(C,r,E),L=X(R,r.offsetTree,p)+c;"end"===b?(L+=g+k(r.sizeTree,R)[1]-a+v,R===E&&(L+=d)):"center"===b?L+=(g+k(r.sizeTree,R)[1]-a+v)/2:L-=u,H&&(L+=H);var F=function(t){x(),t?(f("retrying to scroll to",{location:o},h.DEBUG),publish(S,o)):f("list did not change, scroll successful",{},h.DEBUG);};if(x(),"smooth"===y){var z=!1;w=subscribe(i,function(t){z=z||t;}),I=handleNext(m,function(){F(z);});}else I=handleNext(pipe(i,function(t){var e=setTimeout(function(){t(!1);},150);return function(n){n&&(t(!0),clearTimeout(e));}}),F);return T=setTimeout(function(){x();},1200),publish(s,!0),f("scrolling from index to",{index:R,top:L,behavior:y},h.DEBUG),{top:L,behavior:y}})),c),{scrollToIndex:S,topListHeight:C}},tup(rt,y,S),{singleton:!0}),st="up",ut={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollTop:0,viewportHeight:0,scrollHeight:0}},ct=system(function(t){var n=t[0],o=n.scrollContainerState,r=n.scrollTop,i=n.viewportHeight,a=n.headerHeight,l=n.footerHeight,s=n.scrollBy,u=statefulStream(!1),c=statefulStream(!0),m=stream(),d=stream(),f=statefulStream(4),p=statefulStream(0),h=statefulStreamFromEmitter(pipe(merge(pipe(duc(r),skip(1),mapTo(!0)),pipe(duc(r),skip(1),mapTo(!1),debounceTime(100))),distinctUntilChanged()),!1),g=statefulStreamFromEmitter(pipe(merge(pipe(s,mapTo(!0)),pipe(s,mapTo(!1),debounceTime(200))),distinctUntilChanged()),!1);connect(pipe(combineLatest(duc(r),duc(p)),map(function(t){return t[0]<=t[1]}),distinctUntilChanged()),c),connect(pipe(c,throttleTime(50)),d);var v=streamFromEmitter(pipe(combineLatest(o,duc(i),duc(a),duc(l),duc(f)),scan(function(t,e){var n,o,r=e[0],i=r.scrollTop,a=r.scrollHeight,l=e[1],s={viewportHeight:l,scrollTop:i,scrollHeight:a};return i+l-a>-e[4]?(i>t.state.scrollTop?(n="SCROLLED_DOWN",o=t.state.scrollTop-i):(n="SIZE_DECREASED",o=t.state.scrollTop-i||t.scrollTopDelta),{atBottom:!0,state:s,atBottomBecause:n,scrollTopDelta:o}):{atBottom:!1,notAtBottomBecause:s.scrollHeight>t.state.scrollHeight?"SIZE_INCREASED":l<t.state.viewportHeight?"VIEWPORT_HEIGHT_DECREASING":i<t.state.scrollTop?"SCROLLING_UPWARDS":"NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",state:s}},ut),distinctUntilChanged(function(t,e){return t&&t.atBottom===e.atBottom}))),S=statefulStreamFromEmitter(pipe(o,scan(function(t,e){var n=e.scrollTop,o=e.scrollHeight,r=e.viewportHeight;return x(t.scrollHeight,o)?{scrollTop:n,scrollHeight:o,jump:0,changed:!1}:t.scrollTop!==n&&o-(n+r)<1?{scrollHeight:o,scrollTop:n,jump:t.scrollTop-n,changed:!0}:{scrollHeight:o,scrollTop:n,jump:0,changed:!0}},{scrollHeight:0,jump:0,scrollTop:0,changed:!1}),filter(function(t){return t.changed}),map(function(t){return t.jump})),0);connect(pipe(v,map(function(t){return t.atBottom})),u),connect(pipe(u,throttleTime(50)),m);var C=statefulStream("down");connect(pipe(o,map(function(t){return t.scrollTop}),distinctUntilChanged(),scan(function(t,n){return getValue(g)?{direction:t.direction,prevScrollTop:n}:{direction:n<t.prevScrollTop?st:"down",prevScrollTop:n}},{direction:"down",prevScrollTop:0}),map(function(t){return t.direction})),C),connect(pipe(o,throttleTime(50),mapTo("none")),C);var I=statefulStream(0);return connect(pipe(h,filter(function(t){return !t}),mapTo(0)),I),connect(pipe(r,throttleTime(100),withLatestFrom(h),filter(function(t){return !!t[1]}),scan(function(t,e){return [t[1],e[0]]},[0,0]),map(function(t){return t[1]-t[0]})),I),{isScrolling:h,isAtTop:c,isAtBottom:u,atBottomState:v,atTopStateChange:d,atBottomStateChange:m,scrollDirection:C,atBottomThreshold:f,atTopThreshold:p,scrollVelocity:I,lastJumpDueToItemResize:S}},tup(y)),mt=system(function(t){var n=t[0].log,o=statefulStream(!1),r=streamFromEmitter(pipe(o,filter(function(t){return t}),distinctUntilChanged()));return subscribe(o,function(t){t&&getValue(n)("props updated",{},h.DEBUG);}),{propsReady:o,didMount:r}},tup(S),{singleton:!0}),dt=system(function(t){var n=t[0],o=n.sizes,r=n.listRefresh,i=n.defaultItemSize,a=t[1].scrollTop,l=t[2].scrollToIndex,s=t[3].didMount,u=statefulStream(!0),c=statefulStream(0);return connect(pipe(s,withLatestFrom(c),filter(function(t){return !!t[1]}),mapTo(!1)),u),subscribe(pipe(combineLatest(r,s),withLatestFrom(u,o,i),filter(function(t){var e=t[1],n=t[3];return t[0][1]&&(!R(t[2].sizeTree)||void 0!==n)&&!e}),withLatestFrom(c)),function(t){var n=t[1];setTimeout(function(){handleNext(a,function(){publish(u,!0);}),publish(l,n);});}),{scrolledToInitialItem:u,initialTopMostItemIndex:c}},tup(rt,y,lt,mt),{singleton:!0});function ft(t){return !!t&&("smooth"===t?"smooth":"auto")}var pt=system(function(t){var n=t[0],o=n.totalCount,r=n.listRefresh,i=t[1],a=i.isAtBottom,l=i.atBottomState,s=t[2].scrollToIndex,u=t[3].scrolledToInitialItem,c=t[4],m=c.propsReady,d=c.didMount,f=t[5].log,p=t[6].scrollingInProgress,g=statefulStream(!1),v=stream(),S=null;function C(t){publish(s,{index:"LAST",align:"end",behavior:t});}function I(t){var n=handleNext(l,function(n){!t||n.atBottom||"SIZE_INCREASED"!==n.notAtBottomBecause||S||(getValue(f)("scrolling to bottom due to increased size",{},h.DEBUG),C("auto"));});setTimeout(n,100);}return subscribe(pipe(combineLatest(pipe(duc(o),skip(1)),d),withLatestFrom(duc(g),a,u,p),map(function(t){var e=t[0],n=e[0],o=e[1]&&t[3],r="auto";return o&&(r=function(t,e){return "function"==typeof t?ft(t(e)):e&&ft(t)}(t[1],t[2]||t[4]),o=o&&!!r),{totalCount:n,shouldFollow:o,followOutputBehavior:r}}),filter(function(t){return t.shouldFollow})),function(t){var n=t.totalCount,o=t.followOutputBehavior;S&&(S(),S=null),S=handleNext(r,function(){getValue(f)("following output to ",{totalCount:n},h.DEBUG),C(o),S=null;});}),subscribe(pipe(combineLatest(duc(g),o,m),filter(function(t){return t[0]&&t[2]}),scan(function(t,e){var n=e[1];return {refreshed:t.value===n,value:n}},{refreshed:!1,value:0}),filter(function(t){return t.refreshed}),withLatestFrom(g,o)),function(t){I(!1!==t[1]);}),subscribe(v,function(){I(!1!==getValue(g));}),subscribe(combineLatest(duc(g),l),function(t){var e=t[1];t[0]&&!e.atBottom&&"VIEWPORT_HEIGHT_DECREASING"===e.notAtBottomBecause&&C("auto");}),{followOutput:g,autoscrollToBottom:v}},tup(rt,ct,lt,dt,mt,S,y));function ht(t){return t.reduce(function(t,e){return t.groupIndices.push(t.totalCount),t.totalCount+=e+1,t},{totalCount:0,groupIndices:[]})}var gt=system(function(t){var n=t[0],o=n.totalCount,r=n.groupIndices,i=n.sizes,a=t[1],l=a.scrollTop,s=a.headerHeight,u=stream(),c=stream(),m=streamFromEmitter(pipe(u,map(ht)));return connect(pipe(m,map(function(t){return t.totalCount})),o),connect(pipe(m,map(function(t){return t.groupIndices})),r),connect(pipe(combineLatest(l,i,s),filter(function(t){return nt(t[1])}),map(function(t){return k(t[1].groupOffsetTree,Math.max(t[0]-t[2],0),"v")[0]}),distinctUntilChanged(),map(function(t){return [t]})),c),{groupCounts:u,topItemsIndexes:c}},tup(rt,y));function vt(t,e){return !(!t||t[0]!==e[0]||t[1]!==e[1])}function St(t,e){return !(!t||t.startIndex!==e.startIndex||t.endIndex!==e.endIndex)}function Ct(t,e,n){return "number"==typeof t?n===st&&"top"===e||"down"===n&&"bottom"===e?t:0:n===st?"top"===e?t.main:t.reverse:"bottom"===e?t.main:t.reverse}function It(t,e){return "number"==typeof t?t:t[e]||0}var Tt=system(function(t){var n=t[0],o=n.scrollTop,r=n.viewportHeight,i=n.deviation,a=n.headerHeight,l=n.fixedHeaderHeight,s=stream(),u=statefulStream(0),c=statefulStream(0),m=statefulStream(0),d=statefulStreamFromEmitter(pipe(combineLatest(duc(o),duc(r),duc(a),duc(s,vt),duc(m),duc(u),duc(l),duc(i),duc(c)),map(function(t){var e=t[0],n=t[1],o=t[2],r=t[3],i=r[0],a=r[1],l=t[4],s=t[6],u=t[7],c=t[8],m=e-u,d=t[5]+s,f=Math.max(o-m,0),p="none",h=It(c,"top"),g=It(c,"bottom");return i-=u,a+=o+s,(i+=o+s)>e+d-h&&(p=st),(a-=u)<e-f+n+g&&(p="down"),"none"!==p?[Math.max(m-o-Ct(l,"top",p)-h,0),m-f-s+n+Ct(l,"bottom",p)+g]:null}),filter(function(t){return null!=t}),distinctUntilChanged(vt)),[0,0]);return {listBoundary:s,overscan:m,topListHeight:u,increaseViewportBy:c,visibleRange:d}},tup(y),{singleton:!0}),wt={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0,totalCount:0,firstItemIndex:0};function xt(t,e,n){if(0===t.length)return [];if(!nt(e))return t.map(function(t){return c({},t,{index:t.index+n,originalIndex:t.index})});for(var o,r=[],i=A(e.groupOffsetTree,t[0].index,t[t.length-1].index),a=void 0,l=0,s=f(t);!(o=s()).done;){var u=o.value;(!a||a.end<u.index)&&(a=i.shift(),l=e.groupIndices.indexOf(a.start)),r.push(c({},u.index===a.start?{type:"group",index:l}:{index:u.index-(l+1)+n,groupIndex:l},{size:u.size,offset:u.offset,originalIndex:u.index,data:u.data}));}return r}function bt(t,e,n,o,r,i){var a=0,l=0;if(t.length>0){a=t[0].offset;var s=t[t.length-1];l=s.offset+s.size;}var u=n-r.lastIndex,c=a,m=r.lastOffset+u*r.lastSize+(u-1)*o-l;return {items:xt(t,r,i),topItems:xt(e,r,i),topListHeight:e.reduce(function(t,e){return e.size+t},0),offsetTop:a,offsetBottom:m,top:c,bottom:l,totalCount:n,firstItemIndex:i}}var yt=system(function(t){var n=t[0],o=n.sizes,r=n.totalCount,i=n.data,a=n.firstItemIndex,l=n.gap,s=t[1],u=t[2],m=u.visibleRange,d=u.listBoundary,p=u.topListHeight,h=t[3],g=h.scrolledToInitialItem,v=h.initialTopMostItemIndex,S=t[4].topListHeight,C=t[5],I=t[6].didMount,T=t[7].recalcInProgress,w=statefulStream([]),x=stream();connect(s.topItemsIndexes,w);var b=statefulStreamFromEmitter(pipe(combineLatest(I,T,duc(m,vt),duc(r),duc(o),duc(v),g,duc(w),duc(a),duc(l),i),filter(function(t){return t[0]&&!t[1]}),map(function(t){var n=t[2],o=n[0],r=n[1],i=t[3],a=t[5],l=t[6],s=t[7],u=t[8],m=t[9],d=t[10],p=t[4],h=p.sizeTree,g=p.offsetTree;if(0===i||0===o&&0===r)return c({},wt,{totalCount:i});if(R(h))return bt(function(t,e,n){if(nt(e)){var o=et(t,e);return [{index:k(e.groupOffsetTree,o)[0],size:0,offset:0},{index:o,size:0,offset:0,data:n&&n[0]}]}return [{index:t,size:0,offset:0,data:n&&n[0]}]}(function(t,e){return "number"==typeof t?t:"LAST"===t.index?e-1:t.index}(a,i),p,d),[],i,m,p,u);var v=[];if(s.length>0)for(var S,C=s[0],I=s[s.length-1],T=0,w=f(A(h,C,I));!(S=w()).done;)for(var x=S.value,b=x.value,y=Math.max(x.start,C),H=Math.min(x.end,I),E=y;E<=H;E++)v.push({index:E,size:b,offset:T,data:d&&d[E]}),T+=b;if(!l)return bt([],v,i,m,p,u);var L=s.length>0?s[s.length-1]+1:0,F=function(t,e,n,o){return void 0===o&&(o=0),o>0&&(e=Math.max(e,j(t,o,q).offset)),N((i=n,l=_(r=t,e,a=Z),s=_(r,i,a,l),r.slice(l,s+1)),J);var r,i,a,l,s;}(g,o,r,L);if(0===F.length)return null;var z=i-1;return bt(tap([],function(t){for(var e,n=f(F);!(e=n()).done;){var i=e.value,a=i.value,l=a.offset,s=i.start,u=a.size;if(a.offset<o){var c=(s+=Math.floor((o-a.offset+m)/(u+m)))-i.start;l+=c*u+c*m;}s<L&&(l+=(L-s)*u,s=L);for(var p=Math.min(i.end,z),h=s;h<=p&&!(l>=r);h++)t.push({index:h,size:u,offset:l,data:d&&d[h]}),l+=u+m;}}),v,i,m,p,u)}),filter(function(t){return null!==t}),distinctUntilChanged()),wt);return connect(pipe(i,filter(function(t){return void 0!==t}),map(function(t){return t.length})),r),connect(pipe(b,map(function(t){return t.topListHeight})),S),connect(S,p),connect(pipe(b,map(function(t){return [t.top,t.bottom]})),d),connect(pipe(b,map(function(t){return t.items})),x),c({listState:b,topItemsIndexes:w,endReached:streamFromEmitter(pipe(b,filter(function(t){return t.items.length>0}),withLatestFrom(r,i),filter(function(t){var e=t[0].items;return e[e.length-1].originalIndex===t[1]-1}),map(function(t){return [t[1]-1,t[2]]}),distinctUntilChanged(vt),map(function(t){return t[0]}))),startReached:streamFromEmitter(pipe(b,throttleTime(200),filter(function(t){var e=t.items;return e.length>0&&e[0].originalIndex===t.topItems.length}),map(function(t){return t.items[0].index}),distinctUntilChanged())),rangeChanged:streamFromEmitter(pipe(b,filter(function(t){return t.items.length>0}),map(function(t){for(var e=t.items,n=0,o=e.length-1;"group"===e[n].type&&n<o;)n++;for(;"group"===e[o].type&&o>n;)o--;return {startIndex:e[n].index,endIndex:e[o].index}}),distinctUntilChanged(St))),itemsRendered:x},C)},tup(rt,gt,Tt,dt,lt,ct,mt,K),{singleton:!0}),Ht=system(function(t){var n=t[0],o=n.sizes,r=n.firstItemIndex,i=n.data,a=n.gap,l=t[1].listState,s=t[2].didMount,u=statefulStream(0);return connect(pipe(s,withLatestFrom(u),filter(function(t){return 0!==t[1]}),withLatestFrom(o,r,a,i),map(function(t){var e=t[0][1],n=t[1],o=t[2],r=t[3],i=t[4],a=void 0===i?[]:i,l=0;if(n.groupIndices.length>0)for(var s,u=f(n.groupIndices);!((s=u()).done||s.value-l>=e);)l++;var c=e+l;return bt(Array.from({length:c}).map(function(t,e){return {index:e,size:0,offset:0,data:a[e]}}),[],c,r,n,o)})),l),{initialItemCount:u}},tup(rt,yt,mt),{singleton:!0}),Et=system(function(t){var n=t[0].scrollVelocity,o=statefulStream(!1),r=stream(),i=statefulStream(!1);return connect(pipe(n,withLatestFrom(i,o,r),filter(function(t){return !!t[1]}),map(function(t){var e=t[0],n=t[1],o=t[2],r=t[3],i=n.enter;if(o){if((0, n.exit)(e,r))return !1}else if(i(e,r))return !0;return o}),distinctUntilChanged()),o),subscribe(pipe(combineLatest(o,n,r),withLatestFrom(i)),function(t){var e=t[0],n=t[1];return e[0]&&n&&n.change&&n.change(e[1],e[2])}),{isSeeking:o,scrollSeekConfiguration:i,scrollVelocity:n,scrollSeekRangeChanged:r}},tup(ct),{singleton:!0}),Rt=system(function(t){var n=t[0].topItemsIndexes,o=statefulStream(0);return connect(pipe(o,filter(function(t){return t>0}),map(function(t){return Array.from({length:t}).map(function(t,e){return e})})),n),{topItemCount:o}},tup(yt)),Lt=system(function(t){var n=t[0],o=n.footerHeight,r=n.headerHeight,i=n.fixedHeaderHeight,a=n.fixedFooterHeight,l=t[1].listState,s=stream(),u=statefulStreamFromEmitter(pipe(combineLatest(o,a,r,i,l),map(function(t){var e=t[4];return t[0]+t[1]+t[2]+t[3]+e.offsetBottom+e.bottom})),0);return connect(duc(u),s),{totalListHeight:u,totalListHeightChanged:s}},tup(y,yt),{singleton:!0});function Ft(t){var e,n=!1;return function(){return n||(n=!0,e=t()),e}}var kt=Ft(function(){return /iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)}),zt=system(function(t){var n=t[0],o=n.scrollBy,r=n.scrollTop,i=n.deviation,a=n.scrollingInProgress,l=t[1],s=l.isScrolling,u=l.isAtBottom,c=l.scrollDirection,m=t[3],d=m.beforeUnshiftWith,f=m.shiftWithOffset,p=m.sizes,g=m.gap,v=t[4].log,S=t[5].recalcInProgress,C=streamFromEmitter(pipe(t[2].listState,withLatestFrom(l.lastJumpDueToItemResize),scan(function(t,e){var n=t[1],o=e[0],r=o.items,i=o.totalCount,a=o.bottom+o.offsetBottom,l=0;return t[2]===i&&n.length>0&&r.length>0&&(0===r[0].originalIndex&&0===n[0].originalIndex||0!=(l=a-t[3])&&(l+=e[1])),[l,r,i,a]},[0,[],0,0]),filter(function(t){return 0!==t[0]}),withLatestFrom(r,c,a,u,v),filter(function(t){return !t[3]&&0!==t[1]&&t[2]===st}),map(function(t){var e=t[0][0];return (0, t[5])("Upward scrolling compensation",{amount:e},h.DEBUG),e})));function I(t){t>0?(publish(o,{top:-t,behavior:"auto"}),publish(i,0)):(publish(i,0),publish(o,{top:-t,behavior:"auto"}));}return subscribe(pipe(C,withLatestFrom(i,s)),function(t){var n=t[0],o=t[1];t[2]&&kt()?publish(i,o-n):I(-n);}),subscribe(pipe(combineLatest(statefulStreamFromEmitter(s,!1),i,S),filter(function(t){return !t[0]&&!t[2]&&0!==t[1]}),map(function(t){return t[1]}),throttleTime(1)),I),connect(pipe(f,map(function(t){return {top:-t}})),o),subscribe(pipe(d,withLatestFrom(p,g),map(function(t){var e=t[0];return e*t[1].lastSize+e*t[2]})),function(t){publish(i,t),requestAnimationFrame(function(){publish(o,{top:t}),requestAnimationFrame(function(){publish(i,0),publish(S,!1);});});}),{deviation:i}},tup(y,ct,yt,rt,S,K)),Bt=system(function(t){var n=t[0].totalListHeight,o=t[1].didMount,r=t[2].scrollTo,i=statefulStream(0);return subscribe(pipe(o,withLatestFrom(i),filter(function(t){return 0!==t[1]}),map(function(t){return {top:t[1]}})),function(t){handleNext(pipe(n,filter(function(t){return 0!==t})),function(){setTimeout(function(){publish(r,t);});});}),{initialScrollTop:i}},tup(Lt,mt,y),{singleton:!0}),Pt=system(function(t){var n=t[0].viewportHeight,o=t[1].totalListHeight,r=statefulStream(!1);return {alignToBottom:r,paddingTopAddition:statefulStreamFromEmitter(pipe(combineLatest(r,n,o),filter(function(t){return t[0]}),map(function(t){return Math.max(0,t[1]-t[2])}),distinctUntilChanged()),0)}},tup(y,Lt),{singleton:!0}),Ot=system(function(t){var n=t[0],o=n.scrollTo,r=n.scrollContainerState,i=stream(),a=stream(),l=stream(),s=statefulStream(!1),u=statefulStream(void 0);return connect(pipe(combineLatest(i,a),map(function(t){var e=t[0],n=e.viewportHeight,o=e.scrollHeight;return {scrollTop:Math.max(0,e.scrollTop-t[1].offsetTop),scrollHeight:o,viewportHeight:n}})),r),connect(pipe(o,withLatestFrom(a),map(function(t){var e=t[0];return c({},e,{top:e.top+t[1].offsetTop})})),l),{useWindowScroll:s,customScrollParent:u,windowScrollContainerState:i,windowViewportRect:a,windowScrollTo:l}},tup(y)),Mt=["done","behavior","align"],Wt=system(function(t){var n=t[0],o=n.sizes,r=n.totalCount,i=n.gap,a=t[1],l=a.scrollTop,s=a.viewportHeight,u=a.headerHeight,d=a.fixedHeaderHeight,f=a.fixedFooterHeight,p=a.scrollingInProgress,h=t[2].scrollToIndex,g=stream();return connect(pipe(g,withLatestFrom(o,s,r,u,d,f,l),withLatestFrom(i),map(function(t){var n=t[0],o=n[0],r=n[1],i=n[2],a=n[3],l=n[4],s=n[5],u=n[6],d=n[7],f=t[1],h=o.done,g=o.behavior,v=o.align,S=m(o,Mt),C=null,I=tt$1(o,r,a-1),T=X(I,r.offsetTree,f)+l+s;return T<d+s?C=c({},S,{behavior:g,align:null!=v?v:"start"}):T+k(r.sizeTree,I)[1]>d+i-u&&(C=c({},S,{behavior:g,align:null!=v?v:"end"})),C?h&&handleNext(pipe(p,skip(1),filter(function(t){return !1===t})),h):h&&h(),C}),filter(function(t){return null!==t})),h),{scrollIntoView:g}},tup(rt,y,lt,yt,S),{singleton:!0}),Vt=["listState","topItemsIndexes"],Ut=system(function(t){return c({},t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},tup(Tt,Ht,mt,Et,Lt,Bt,Pt,Ot,Wt)),At=system(function(t){var n=t[0],o=n.totalCount,r=n.sizeRanges,i=n.fixedItemSize,a=n.defaultItemSize,l=n.trackItemSizes,s=n.itemSize,u=n.data,d=n.firstItemIndex,f=n.groupIndices,p=n.statefulTotalCount,h=n.gap,g=t[1],v=g.initialTopMostItemIndex,S=g.scrolledToInitialItem,C=t[2],I=t[3],T=t[4],w=T.listState,x=T.topItemsIndexes,b=m(T,Vt),y=t[5].scrollToIndex,H=t[7].topItemCount,E=t[8].groupCounts,R=t[9],L=t[10];return connect(b.rangeChanged,R.scrollSeekRangeChanged),connect(pipe(R.windowViewportRect,map(function(t){return t.visibleHeight})),C.viewportHeight),c({totalCount:o,data:u,firstItemIndex:d,sizeRanges:r,initialTopMostItemIndex:v,scrolledToInitialItem:S,topItemsIndexes:x,topItemCount:H,groupCounts:E,fixedItemHeight:i,defaultItemHeight:a,gap:h},I,{statefulTotalCount:p,listState:w,scrollToIndex:y,trackItemSizes:l,itemSize:s,groupIndices:f},b,R,C,L)},tup(rt,dt,y,pt,yt,lt,zt,Rt,gt,Ut,S)),Nt=Ft(function(){if("undefined"==typeof document)return "sticky";var t=document.createElement("div");return t.style.position="-webkit-sticky","-webkit-sticky"===t.style.position?"-webkit-sticky":"sticky"});function Dt(t,e){var n=useRef(null),o=useCallback(function(o){if(null!==o&&o.offsetParent){var r,i,a=o.getBoundingClientRect(),l=a.width;if(e){var s=e.getBoundingClientRect(),u=a.top-s.top;r=s.height-Math.max(0,u),i=u+e.scrollTop;}else r=window.innerHeight-Math.max(0,a.top),i=a.top+window.pageYOffset;n.current={offsetTop:i,visibleHeight:r,visibleWidth:l},t(n.current);}},[t,e]),l=C(o),s=l.callbackRef,u=l.ref,c=useCallback(function(){o(u.current);},[o,u]);return useEffect(function(){if(e){e.addEventListener("scroll",c);var t=new ResizeObserver(c);return t.observe(e),function(){e.removeEventListener("scroll",c),t.unobserve(e);}}return window.addEventListener("scroll",c),window.addEventListener("resize",c),function(){window.removeEventListener("scroll",c),window.removeEventListener("resize",c);}},[c,e]),s}var Gt=React.createContext(void 0),_t=React.createContext(void 0),jt=["placeholder"],Kt=["style","children"],Yt=["style","children"];function qt(t){return t}var Zt=system(function(){var t=statefulStream(function(t){return "Item "+t}),n=statefulStream(null),o=statefulStream(function(t){return "Group "+t}),r=statefulStream({}),i=statefulStream(qt),a=statefulStream("div"),l=statefulStream(noop),s=function(t,n){return void 0===n&&(n=null),statefulStreamFromEmitter(pipe(r,map(function(e){return e[t]}),distinctUntilChanged()),n)};return {context:n,itemContent:t,groupContent:o,components:r,computeItemKey:i,headerFooterTag:a,scrollerRef:l,FooterComponent:s("Footer"),HeaderComponent:s("Header"),TopItemListComponent:s("TopItemList"),ListComponent:s("List","div"),ItemComponent:s("Item","div"),GroupComponent:s("Group","div"),ScrollerComponent:s("Scroller","div"),EmptyPlaceholder:s("EmptyPlaceholder"),ScrollSeekPlaceholder:s("ScrollSeekPlaceholder")}});function Jt(t,n){var o=stream();return subscribe(o,function(){return console.warn("react-virtuoso: You are using a deprecated property. "+n,"color: red;","color: inherit;","color: blue;")}),connect(o,t),o}var $t=system(function(t){var n=t[0],o=t[1],r={item:Jt(o.itemContent,"Rename the %citem%c prop to %citemContent."),group:Jt(o.groupContent,"Rename the %cgroup%c prop to %cgroupContent."),topItems:Jt(n.topItemCount,"Rename the %ctopItems%c prop to %ctopItemCount."),itemHeight:Jt(n.fixedItemHeight,"Rename the %citemHeight%c prop to %cfixedItemHeight."),scrollingStateChange:Jt(n.isScrolling,"Rename the %cscrollingStateChange%c prop to %cisScrolling."),adjustForPrependedItems:stream(),maxHeightCacheSize:stream(),footer:stream(),header:stream(),HeaderContainer:stream(),FooterContainer:stream(),ItemContainer:stream(),ScrollContainer:stream(),GroupContainer:stream(),ListContainer:stream(),emptyComponent:stream(),scrollSeek:stream()};function i(t,n,r){connect(pipe(t,withLatestFrom(o.components),map(function(t){var e,o=t[0],i=t[1];return console.warn("react-virtuoso: "+r+" property is deprecated. Pass components."+n+" instead."),c({},i,((e={})[n]=o,e))})),o.components);}return subscribe(r.adjustForPrependedItems,function(){console.warn("react-virtuoso: adjustForPrependedItems is no longer supported. Use the firstItemIndex property instead - https://virtuoso.dev/prepend-items.","color: red;","color: inherit;","color: blue;");}),subscribe(r.maxHeightCacheSize,function(){console.warn("react-virtuoso: maxHeightCacheSize is no longer necessary. Setting it has no effect - remove it from your code.");}),subscribe(r.HeaderContainer,function(){console.warn("react-virtuoso: HeaderContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the header component and pass components.Header to change its contents.");}),subscribe(r.FooterContainer,function(){console.warn("react-virtuoso: FooterContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the footer component and pass components.Footer to change its contents.");}),subscribe(r.scrollSeek,function(t){var r=t.placeholder,i=m(t,jt);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),publish(o.components,c({},getValue(o.components),{ScrollSeekPlaceholder:r})),publish(n.scrollSeekConfiguration,i);}),i(r.footer,"Footer","footer"),i(r.header,"Header","header"),i(r.ItemContainer,"Item","ItemContainer"),i(r.ListContainer,"List","ListContainer"),i(r.ScrollContainer,"Scroller","ScrollContainer"),i(r.emptyComponent,"EmptyPlaceholder","emptyComponent"),i(r.GroupContainer,"Group","GroupContainer"),c({},n,o,r)},tup(At,Zt)),Qt=function(t){return React.createElement("div",{style:{height:t.height}})},Xt={position:Nt(),zIndex:1,overflowAnchor:"none"},te={overflowAnchor:"none"},ee=React.memo(function(t){var o=t.showTopList,r=void 0!==o&&o,i=ge("listState"),a=he("sizeRanges"),s=ge("useWindowScroll"),u=ge("customScrollParent"),m=he("windowScrollContainerState"),d=he("scrollContainerState"),f=u||s?m:d,p=ge("itemContent"),h=ge("context"),g=ge("groupContent"),v=ge("trackItemSizes"),S=ge("itemSize"),C=ge("log"),I=he("gap"),w=T(a,S,v,r?noop:f,C,I,u).callbackRef,x=React.useState(0),b=x[0],y=x[1];ve("deviation",function(t){b!==t&&y(t);});var H=ge("EmptyPlaceholder"),E=ge("ScrollSeekPlaceholder")||Qt,R=ge("ListComponent"),L=ge("ItemComponent"),F=ge("GroupComponent"),k=ge("computeItemKey"),z=ge("isSeeking"),B=ge("groupIndices").length>0,P=ge("paddingTopAddition"),O=r?{}:{boxSizing:"border-box",paddingTop:i.offsetTop+P,paddingBottom:i.offsetBottom,marginTop:b};return !r&&0===i.totalCount&&H?createElement$2(H,ie(H,h)):createElement$2(R,c({},ie(R,h),{ref:w,style:O,"data-test-id":r?"virtuoso-top-item-list":"virtuoso-item-list"}),(r?i.topItems:i.items).map(function(t){var e=t.originalIndex,n=k(e+i.firstItemIndex,t.data,h);return z?createElement$2(E,c({},ie(E,h),{key:n,index:t.index,height:t.size,type:t.type||"item"},"group"===t.type?{}:{groupIndex:t.groupIndex})):"group"===t.type?createElement$2(F,c({},ie(F,h),{key:n,"data-index":e,"data-known-size":t.size,"data-item-index":t.index,style:Xt}),g(t.index)):createElement$2(L,c({},ie(L,h),{key:n,"data-index":e,"data-known-size":t.size,"data-item-index":t.index,"data-item-group-index":t.groupIndex,style:te}),B?p(t.index,t.groupIndex,t.data,h):p(t.index,t.data,h))}))}),ne={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},oe={width:"100%",height:"100%",position:"absolute",top:0},re={width:"100%",position:Nt(),top:0};function ie(t,e){if("string"!=typeof t)return {context:e}}var ae=React.memo(function(){var t=ge("HeaderComponent"),e=he("headerHeight"),n=ge("headerFooterTag"),o=I(function(t){return e(w(t,"height"))}),r=ge("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null}),le=React.memo(function(){var t=ge("FooterComponent"),e=he("footerHeight"),n=ge("headerFooterTag"),o=I(function(t){return e(w(t,"height"))}),r=ge("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null});function se(t){var e=t.usePublisher,o=t.useEmitter,r=t.useEmitterValue;return React.memo(function(t){var n=t.style,i=t.children,a=m(t,Kt),s=e("scrollContainerState"),u=r("ScrollerComponent"),d=e("smoothScrollTargetReached"),f=r("scrollerRef"),p=r("context"),h=b(s,d,u,f),g=h.scrollerRef,v=h.scrollByCallback;return o("scrollTo",h.scrollToCallback),o("scrollBy",v),createElement$2(u,c({ref:g,style:c({},ne,n),"data-test-id":"virtuoso-scroller","data-virtuoso-scroller":!0,tabIndex:0},a,ie(u,p)),i)})}function ue(t){var o=t.usePublisher,r=t.useEmitter,i=t.useEmitterValue;return React.memo(function(t){var n=t.style,a=t.children,s=m(t,Yt),u=o("windowScrollContainerState"),d=i("ScrollerComponent"),f=o("smoothScrollTargetReached"),p=i("totalListHeight"),h=i("deviation"),v=i("customScrollParent"),S=i("context"),C=b(u,f,d,noop,v),I=C.scrollerRef,T=C.scrollByCallback,w=C.scrollToCallback;return g(function(){return I.current=v||window,function(){I.current=null;}},[I,v]),r("windowScrollTo",w),r("scrollBy",T),createElement$2(d,c({style:c({position:"relative"},n,0!==p?{height:p+h}:{}),"data-virtuoso-scroller":!0},s,ie(d,S)),a)})}var ce=function(t){var o=t.children,r=useContext$1(Gt),i=he("viewportHeight"),a=he("fixedItemHeight"),l=I(compose(i,function(t){return w(t,"height")}));return React.useEffect(function(){r&&(i(r.viewportHeight),a(r.itemHeight));},[r,i,a]),React.createElement("div",{style:oe,ref:l,"data-viewport-type":"element"},o)},me=function(t){var e=t.children,o=useContext$1(Gt),r=he("windowViewportRect"),i=he("fixedItemHeight"),a=ge("customScrollParent"),l=Dt(r,a);return React.useEffect(function(){o&&(i(o.itemHeight),r({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}));},[o,r,i]),React.createElement("div",{ref:l,style:oe,"data-viewport-type":"window"},e)},de=function(t){var e=t.children,n=ge("TopItemListComponent"),o=ge("headerHeight"),r=c({},re,{marginTop:o+"px"}),i=ge("context");return createElement$2(n||"div",{style:r,context:i},e)},fe=systemToComponent($t,{required:{},optional:{context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",react18ConcurrentRendering:"react18ConcurrentRendering",item:"item",group:"group",topItems:"topItems",itemHeight:"itemHeight",scrollingStateChange:"scrollingStateChange",maxHeightCacheSize:"maxHeightCacheSize",footer:"footer",header:"header",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",GroupContainer:"GroupContainer",emptyComponent:"emptyComponent",HeaderContainer:"HeaderContainer",FooterContainer:"FooterContainer",scrollSeek:"scrollSeek"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",adjustForPrependedItems:"adjustForPrependedItems",autoscrollToBottom:"autoscrollToBottom"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},React.memo(function(t){var e=ge("useWindowScroll"),o=ge("topItemsIndexes").length>0,r=ge("customScrollParent"),i=r||e?me:ce;return React.createElement(r||e?Ce:Se,c({},t),React.createElement(i,null,React.createElement(ae,null),React.createElement(ee,null),React.createElement(le,null)),o&&React.createElement(de,null,React.createElement(ee,{showTopList:!0})))})),pe=fe.Component,he=fe.usePublisher,ge=fe.useEmitterValue,ve=fe.useEmitter,Se=se({usePublisher:he,useEmitterValue:ge,useEmitter:ve}),Ce=ue({usePublisher:he,useEmitterValue:ge,useEmitter:ve}),Ie={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},Te={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},we=Math.round,xe=Math.ceil,be=Math.floor,ye=Math.min,He=Math.max;function Ee(t,e,n){return Array.from({length:e-t+1}).map(function(e,o){return {index:o+t,data:null==n?void 0:n[o+t]}})}function Re(t,e){return t&&t.column===e.column&&t.row===e.row}var Le=system(function(t){var n=t[0],o=n.overscan,r=n.visibleRange,i=n.listBoundary,a=t[1],l=a.scrollTop,s=a.viewportHeight,u=a.scrollBy,m=a.scrollTo,d=a.smoothScrollTargetReached,f=a.scrollContainerState,p=a.footerHeight,h=a.headerHeight,g=t[2],v=t[3],S=t[4],C=S.propsReady,I=S.didMount,T=t[5],w=T.windowViewportRect,x=T.windowScrollTo,b=T.useWindowScroll,y=T.customScrollParent,H=T.windowScrollContainerState,E=t[6],R=statefulStream(0),L=statefulStream(0),F=statefulStream(Ie),k=statefulStream({height:0,width:0}),z=statefulStream({height:0,width:0}),B=stream(),P=stream(),O=statefulStream(0),M=statefulStream(void 0),W=statefulStream({row:0,column:0});connect(pipe(combineLatest(I,L,M),filter(function(t){return 0!==t[1]}),map(function(t){return {items:Ee(0,t[1]-1,t[2]),top:0,bottom:0,offsetBottom:0,offsetTop:0,itemHeight:0,itemWidth:0}})),F),connect(pipe(combineLatest(duc(R),r,duc(W,Re),duc(z,function(t,e){return t&&t.width===e.width&&t.height===e.height}),M),withLatestFrom(k),map(function(t){var e=t[0],n=e[0],o=e[1],r=o[0],i=o[1],a=e[2],l=e[3],s=e[4],u=t[1],m=a.row,d=a.column,f=l.height,p=l.width,h=u.width;if(0===n||0===h)return Ie;if(0===p)return function(t){return c({},Te,{items:t})}(Ee(0,0,s));var g=ze(h,p,d),v=g*be((r+m)/(f+m)),S=g*xe((i+m)/(f+m))-1;S=ye(n-1,He(S,g-1));var C=Ee(v=ye(S,He(0,v)),S,s),I=Fe(u,a,l,C),T=I.top,w=I.bottom,x=xe(n/g);return {items:C,offsetTop:T,offsetBottom:x*f+(x-1)*m-w,top:T,bottom:w,itemHeight:f,itemWidth:p}})),F),connect(pipe(M,filter(function(t){return void 0!==t}),map(function(t){return t.length})),R),connect(pipe(k,map(function(t){return t.height})),s),connect(pipe(combineLatest(k,z,F,W),map(function(t){var e=Fe(t[0],t[3],t[1],t[2].items);return [e.top,e.bottom]}),distinctUntilChanged(vt)),i);var V=streamFromEmitter(pipe(duc(F),filter(function(t){return t.items.length>0}),withLatestFrom(R),filter(function(t){var e=t[0].items;return e[e.length-1].index===t[1]-1}),map(function(t){return t[1]-1}),distinctUntilChanged())),U=streamFromEmitter(pipe(duc(F),filter(function(t){var e=t.items;return e.length>0&&0===e[0].index}),mapTo(0),distinctUntilChanged())),A=streamFromEmitter(pipe(duc(F),filter(function(t){return t.items.length>0}),map(function(t){var e=t.items;return {startIndex:e[0].index,endIndex:e[e.length-1].index}}),distinctUntilChanged(St)));connect(A,v.scrollSeekRangeChanged),connect(pipe(B,withLatestFrom(k,z,R,W),map(function(t){var e=t[1],n=t[2],o=t[3],r=t[4],i=at(t[0]),a=i.align,l=i.behavior,s=i.offset,u=i.index;"LAST"===u&&(u=o-1);var c=ke(e,r,n,u=He(0,u,ye(o-1,u)));return "end"===a?c=we(c-e.height+n.height):"center"===a&&(c=we(c-e.height/2+n.height/2)),s&&(c+=s),{top:c,behavior:l}})),m);var N=statefulStreamFromEmitter(pipe(F,map(function(t){return t.offsetBottom+t.bottom})),0);return connect(pipe(w,map(function(t){return {width:t.visibleWidth,height:t.visibleHeight}})),k),c({data:M,totalCount:R,viewportDimensions:k,itemDimensions:z,scrollTop:l,scrollHeight:P,overscan:o,scrollBy:u,scrollTo:m,scrollToIndex:B,smoothScrollTargetReached:d,windowViewportRect:w,windowScrollTo:x,useWindowScroll:b,customScrollParent:y,windowScrollContainerState:H,deviation:O,scrollContainerState:f,footerHeight:p,headerHeight:h,initialItemCount:L,gap:W},v,{gridState:F,totalListHeight:N},g,{startReached:U,endReached:V,rangeChanged:A,propsReady:C},E)},tup(Tt,y,ct,Et,mt,Ot,S));function Fe(t,e,n,o){var r=n.height;return void 0===r||0===o.length?{top:0,bottom:0}:{top:ke(t,e,n,o[0].index),bottom:ke(t,e,n,o[o.length-1].index)+r}}function ke(t,e,n,o){var r=ze(t.width,n.width,e.column),i=be(o/r),a=i*n.height+He(0,i-1)*e.row;return a>0?a+e.row:a}function ze(t,e,n){return He(1,be((t+n)/(e+n)))}var Be=["placeholder"],Pe=system(function(){var t=statefulStream(function(t){return "Item "+t}),n=statefulStream({}),o=statefulStream(null),r=statefulStream("virtuoso-grid-item"),i=statefulStream("virtuoso-grid-list"),a=statefulStream(qt),l=statefulStream("div"),s=statefulStream(noop),u=function(t,o){return void 0===o&&(o=null),statefulStreamFromEmitter(pipe(n,map(function(e){return e[t]}),distinctUntilChanged()),o)};return {context:o,itemContent:t,components:n,computeItemKey:a,itemClassName:r,listClassName:i,headerFooterTag:l,scrollerRef:s,FooterComponent:u("Footer"),HeaderComponent:u("Header"),ListComponent:u("List","div"),ItemComponent:u("Item","div"),ScrollerComponent:u("Scroller","div"),ScrollSeekPlaceholder:u("ScrollSeekPlaceholder","div")}}),Oe=system(function(t){var n=t[0],o=t[1],r={item:Jt(o.itemContent,"Rename the %citem%c prop to %citemContent."),ItemContainer:stream(),ScrollContainer:stream(),ListContainer:stream(),emptyComponent:stream(),scrollSeek:stream()};function i(t,n,r){connect(pipe(t,withLatestFrom(o.components),map(function(t){var e,o=t[0],i=t[1];return console.warn("react-virtuoso: "+r+" property is deprecated. Pass components."+n+" instead."),c({},i,((e={})[n]=o,e))})),o.components);}return subscribe(r.scrollSeek,function(t){var r=t.placeholder,i=m(t,Be);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),publish(o.components,c({},getValue(o.components),{ScrollSeekPlaceholder:r})),publish(n.scrollSeekConfiguration,i);}),i(r.ItemContainer,"Item","ItemContainer"),i(r.ListContainer,"List","ListContainer"),i(r.ScrollContainer,"Scroller","ScrollContainer"),c({},n,o,r)},tup(Le,Pe)),Me=React.memo(function(){var t=_e("gridState"),e=_e("listClassName"),n=_e("itemClassName"),o=_e("itemContent"),r=_e("computeItemKey"),i=_e("isSeeking"),a=Ge("scrollHeight"),s=_e("ItemComponent"),u=_e("ListComponent"),m=_e("ScrollSeekPlaceholder"),d=_e("context"),f=Ge("itemDimensions"),p=Ge("gap"),h=_e("log"),g=I(function(t){a(t.parentElement.parentElement.scrollHeight);var e=t.firstChild;e&&f(e.getBoundingClientRect()),p({row:qe("row-gap",getComputedStyle(t).rowGap,h),column:qe("column-gap",getComputedStyle(t).columnGap,h)});});return createElement$2(u,c({ref:g,className:e},ie(u,d),{style:{paddingTop:t.offsetTop,paddingBottom:t.offsetBottom}}),t.items.map(function(e){var a=r(e.index,e.data,d);return i?createElement$2(m,c({key:a},ie(m,d),{index:e.index,height:t.itemHeight,width:t.itemWidth})):createElement$2(s,c({},ie(s,d),{className:n,"data-index":e.index,key:a}),o(e.index,e.data,d))}))}),We=React.memo(function(){var t=_e("HeaderComponent"),e=Ge("headerHeight"),n=_e("headerFooterTag"),o=I(function(t){return e(w(t,"height"))}),r=_e("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null}),Ve=React.memo(function(){var t=_e("FooterComponent"),e=Ge("footerHeight"),n=_e("headerFooterTag"),o=I(function(t){return e(w(t,"height"))}),r=_e("context");return t?createElement$2(n,{ref:o},createElement$2(t,ie(t,r))):null}),Ue=function(t){var e=t.children,o=useContext$1(_t),r=Ge("itemDimensions"),i=Ge("viewportDimensions"),a=I(function(t){i(t.getBoundingClientRect());});return React.useEffect(function(){o&&(i({height:o.viewportHeight,width:o.viewportWidth}),r({height:o.itemHeight,width:o.itemWidth}));},[o,i,r]),React.createElement("div",{style:oe,ref:a},e)},Ae=function(t){var e=t.children,o=useContext$1(_t),r=Ge("windowViewportRect"),i=Ge("itemDimensions"),a=_e("customScrollParent"),l=Dt(r,a);return React.useEffect(function(){o&&(i({height:o.itemHeight,width:o.itemWidth}),r({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:o.viewportWidth}));},[o,r,i]),React.createElement("div",{ref:l,style:oe},e)},Ne=systemToComponent(Oe,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",item:"item",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",scrollSeek:"scrollSeek"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange"}},React.memo(function(t){var e=c({},t),o=_e("useWindowScroll"),r=_e("customScrollParent"),i=r||o?Ae:Ue;return React.createElement(r||o?Ye:Ke,c({},e),React.createElement(i,null,React.createElement(We,null),React.createElement(Me,null),React.createElement(Ve,null)))})),Ge=Ne.usePublisher,_e=Ne.useEmitterValue,je=Ne.useEmitter,Ke=se({usePublisher:Ge,useEmitterValue:_e,useEmitter:je}),Ye=ue({usePublisher:Ge,useEmitterValue:_e,useEmitter:je});function qe(t,e,n){return "normal"===e||null!=e&&e.endsWith("px")||n(t+" was not resolved to pixel value correctly",e,h.WARN),"normal"===e?0:parseInt(null!=e?e:"0",10)}var Ze=system(function(){var t=statefulStream(function(t){return React.createElement("td",null,"Item $",t)}),o=statefulStream(null),r=statefulStream(null),i=statefulStream(null),a=statefulStream({}),l=statefulStream(qt),s=statefulStream(noop),u=function(t,n){return void 0===n&&(n=null),statefulStreamFromEmitter(pipe(a,map(function(e){return e[t]}),distinctUntilChanged()),n)};return {context:o,itemContent:t,fixedHeaderContent:r,fixedFooterContent:i,components:a,computeItemKey:l,scrollerRef:s,TableComponent:u("Table","table"),TableHeadComponent:u("TableHead","thead"),TableFooterComponent:u("TableFoot","tfoot"),TableBodyComponent:u("TableBody","tbody"),TableRowComponent:u("TableRow","tr"),ScrollerComponent:u("Scroller","div"),EmptyPlaceholder:u("EmptyPlaceholder"),ScrollSeekPlaceholder:u("ScrollSeekPlaceholder"),FillerRow:u("FillerRow")}}),Je=system(function(t){return c({},t[0],t[1])},tup(At,Ze)),$e=function(t){return React.createElement("tr",null,React.createElement("td",{style:{height:t.height}}))},Qe=function(t){return React.createElement("tr",null,React.createElement("td",{style:{height:t.height,padding:0,border:0}}))},Xe=React.memo(function(){var t=an("listState"),e=rn("sizeRanges"),o=an("useWindowScroll"),r=an("customScrollParent"),i=rn("windowScrollContainerState"),a=rn("scrollContainerState"),s=r||o?i:a,u=an("itemContent"),m=an("trackItemSizes"),d=T(e,an("itemSize"),m,s,an("log"),void 0,r),f=d.callbackRef,p=d.ref,h=React.useState(0),g=h[0],v=h[1];ln("deviation",function(t){g!==t&&(p.current.style.marginTop=t+"px",v(t));});var S=an("EmptyPlaceholder"),C=an("ScrollSeekPlaceholder")||$e,I=an("FillerRow")||Qe,w=an("TableBodyComponent"),x=an("TableRowComponent"),b=an("computeItemKey"),y=an("isSeeking"),H=an("paddingTopAddition"),E=an("firstItemIndex"),R=an("statefulTotalCount"),L=an("context");if(0===R&&S)return createElement$2(S,ie(S,L));var F=t.offsetTop+H+g,k=t.offsetBottom,z=F>0?React.createElement(I,{height:F,key:"padding-top"}):null,B=k>0?React.createElement(I,{height:k,key:"padding-bottom"}):null,P=t.items.map(function(t){var e=t.originalIndex,n=b(e+E,t.data,L);return y?createElement$2(C,c({},ie(C,L),{key:n,index:t.index,height:t.size,type:t.type||"item"})):createElement$2(x,c({},ie(x,L),{key:n,"data-index":e,"data-known-size":t.size,"data-item-index":t.index,style:{overflowAnchor:"none"}}),u(t.index,t.data,L))});return createElement$2(w,c({ref:f,"data-test-id":"virtuoso-item-list"},ie(w,L)),[z].concat(P,[B]))}),tn=function(t){var o=t.children,r=useContext$1(Gt),i=rn("viewportHeight"),a=rn("fixedItemHeight"),l=I(compose(i,function(t){return w(t,"height")}));return React.useEffect(function(){r&&(i(r.viewportHeight),a(r.itemHeight));},[r,i,a]),React.createElement("div",{style:oe,ref:l,"data-viewport-type":"element"},o)},en=function(t){var e=t.children,o=useContext$1(Gt),r=rn("windowViewportRect"),i=rn("fixedItemHeight"),a=an("customScrollParent"),l=Dt(r,a);return React.useEffect(function(){o&&(i(o.itemHeight),r({offsetTop:0,visibleHeight:o.viewportHeight,visibleWidth:100}));},[o,r,i]),React.createElement("div",{ref:l,style:oe,"data-viewport-type":"window"},e)},nn=systemToComponent(Je,{required:{},optional:{context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",react18ConcurrentRendering:"react18ConcurrentRendering"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},React.memo(function(t){var o=an("useWindowScroll"),r=an("customScrollParent"),i=rn("fixedHeaderHeight"),a=rn("fixedFooterHeight"),l=an("fixedHeaderContent"),s=an("fixedFooterContent"),u=an("context"),m=I(compose(i,function(t){return w(t,"height")})),d=I(compose(a,function(t){return w(t,"height")})),f=r||o?un:sn,p=r||o?en:tn,h=an("TableComponent"),g=an("TableHeadComponent"),v=an("TableFooterComponent"),S=l?React.createElement(g,c({key:"TableHead",style:{zIndex:1,position:"sticky",top:0},ref:m},ie(g,u)),l()):null,C=s?React.createElement(v,c({key:"TableFoot",style:{zIndex:1,position:"sticky",bottom:0},ref:d},ie(v,u)),s()):null;return React.createElement(f,c({},t),React.createElement(p,null,React.createElement(h,c({style:{borderSpacing:0}},ie(h,u)),[S,React.createElement(Xe,{key:"TableBody"}),C])))})),rn=nn.usePublisher,an=nn.useEmitterValue,ln=nn.useEmitter,sn=se({usePublisher:rn,useEmitterValue:an,useEmitter:ln}),un=ue({usePublisher:rn,useEmitterValue:an,useEmitter:ln}),cn=pe;
182466
+ var n=function(){return n=Object.assign||function(e){for(var r,o=1,t=arguments.length;o<t;o++)for(var n in r=arguments[o])Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);return e},n.apply(this,arguments)};function a(e,r){var o={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(o[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(t=Object.getOwnPropertySymbols(e);n<t.length;n++)r.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(e,t[n])&&(o[t[n]]=e[t[n]]);}return o}var c=["aspectRatio","autoCrop","autoCropArea","background","center","checkCrossOrigin","checkOrientation","cropBoxMovable","cropBoxResizable","data","dragMode","guides","highlight","initialAspectRatio","minCanvasHeight","minCanvasWidth","minContainerHeight","minContainerWidth","minCropBoxHeight","minCropBoxWidth","modal","movable","preview","responsive","restore","rotatable","scalable","toggleDragModeOnDblclick","viewMode","wheelZoomRatio","zoomOnTouch","zoomOnWheel","zoomable","cropstart","cropmove","cropend","crop","zoom","ready"],i={opacity:0,maxWidth:"100%"},l=React__default.forwardRef((function(l,s){var u=a(l,[]),p=u.dragMode,d=void 0===p?"crop":p,v=u.src,f=u.style,m=u.className,g=u.crossOrigin,y=u.scaleX,b=u.scaleY,h=u.enable,O=u.zoomTo,T=u.rotateTo,z=u.alt,C=void 0===z?"picture":z,w=u.ready,x=u.onInitialized,j=a(u,["dragMode","src","style","className","crossOrigin","scaleX","scaleY","enable","zoomTo","rotateTo","alt","ready","onInitialized"]),M={scaleY:b,scaleX:y,enable:h,zoomTo:O,rotateTo:T},E=function(){for(var o=[],t=0;t<arguments.length;t++)o[t]=arguments[t];var n=useRef(null);return React__default.useEffect((function(){o.forEach((function(e){e&&("function"==typeof e?e(n.current):e.current=n.current);}));}),[o]),n}(s,useRef(null));useEffect((function(){var e;(null===(e=E.current)||void 0===e?void 0:e.cropper)&&"number"==typeof O&&E.current.cropper.zoomTo(O);}),[u.zoomTo]),useEffect((function(){var e;(null===(e=E.current)||void 0===e?void 0:e.cropper)&&void 0!==v&&E.current.cropper.reset().clear().replace(v);}),[v]),useEffect((function(){if(null!==E.current){var e=new Cropper(E.current,n(n({dragMode:d},j),{ready:function(e){null!==e.currentTarget&&function(e,r){void 0===r&&(r={});var o=r.enable,t=void 0===o||o,n=r.scaleX,a=void 0===n?1:n,c=r.scaleY,i=void 0===c?1:c,l=r.zoomTo,s=void 0===l?0:l,u=r.rotateTo;t?e.enable():e.disable(),e.scaleX(a),e.scaleY(i),void 0!==u&&e.rotateTo(u),s>0&&e.zoomTo(s);}(e.currentTarget.cropper,M),w&&w(e);}}));x&&x(e);}return function(){var e,r;null===(r=null===(e=E.current)||void 0===e?void 0:e.cropper)||void 0===r||r.destroy();}}),[E]);var R=function(e){return c.reduce((function(e,r){var o=e,t=r;return o[t],a(o,["symbol"==typeof t?t:t+""])}),e)}(n(n({},j),{crossOrigin:g,src:v,alt:C}));return React__default.createElement("div",{style:f,className:m},React__default.createElement("img",n({},R,{style:i,ref:E})))}));
182467
182467
 
182468
182468
  async function getBytes(stream, onChunk) {
182469
182469
  const reader = stream.getReader();
@@ -182663,4 +182663,4 @@ function defaultOnOpen(response) {
182663
182663
  }
182664
182664
  }
182665
182665
 
182666
- export { CloseCircleFilled$1 as $, App$1 as A, Spin$1 as B, ConfigProvider$1 as C, CloseOutlined$1 as D, I$1 as E, html2canvas as F, Remarkable as G, H$1 as H, Icon$1 as I, Drawer as J, HighlightJS as K, LeftOutlined$1 as L, Modal$1 as M, DatePicker$1 as N, Button$2 as O, Pagination$1 as P, l as Q, RightOutlined$1 as R, StyleProvider as S, Tooltip$1 as T, Upload$1 as U, cn as V, Popover$1 as W, X$1 as X, DoubleRightOutlined$1 as Y, ZoomInOutlined$1 as Z, _object_spread as _, AntdMessage as a, Divider$1 as a0, fetchEventSource as a1, Affix$1 as a2, Alert$1 as a3, Anchor$1 as a4, RefAutoComplete$1 as a5, Avatar$1 as a6, FloatButton$1 as a7, index$4 as a8, Badge$1 as a9, Skeleton$1 as aA, Slider$1 as aB, Space$1 as aC, Statistic$1 as aD, Steps$1 as aE, Switch$1 as aF, Tabs as aG, Tag$1 as aH, theme as aI, TimePicker$1 as aJ, Timeline$1 as aK, Tour$1 as aL, Transfer$1 as aM, Tree$1 as aN, TreeSelect$1 as aO, Typography$1 as aP, Watermark$1 as aQ, QRCode$1 as aR, version$3 as aS, en_US$1 as aT, Breadcrumb$1 as aa, Calendar$1 as ab, Card$1 as ac, Carousel$1 as ad, Cascader$1 as ae, Checkbox$1 as af, Col$1 as ag, Collapse$1 as ah, Descriptions as ai, Dropdown$1 as aj, Empty$1 as ak, Form$1 as al, index$3 as am, Image$2 as an, InputNumber$1 as ao, Layout$1 as ap, List$1 as aq, Mentions$1 as ar, Menu$1 as as, Popconfirm$1 as at, Progress$1 as au, Radio$1 as av, Rate$1 as aw, Result$2 as ax, Row$3 as ay, Segmented$1 as az, AntdNotification as b, _extends as c, _object_destructuring_empty as d, _object_spread_props as e, jsxs as f, _sliced_to_array as g, Table$1 as h, _to_consumable_array as i, jsx as j, Select$1 as k, CaretDownOutlined$1 as l, _inherits as m, _create_super as n, _create_class as o, _class_call_check as p, _define_property as q, _assert_this_initialized as r, _async_to_generator as s, transform$2 as t, MinusOutlined$1 as u, PlusOutlined$1 as v, __generator$1 as w, Input$1 as x, SearchOutlined$1 as y, zhCN as z };
182666
+ export { CloseCircleFilled$1 as $, App$1 as A, Spin$1 as B, ConfigProvider$1 as C, CloseOutlined$1 as D, I as E, html2canvas as F, Remarkable as G, H, Icon$1 as I, Drawer as J, HighlightJS as K, LeftOutlined$1 as L, Modal$1 as M, cn as N, DatePicker$1 as O, Pagination$1 as P, Button$2 as Q, RightOutlined$1 as R, StyleProvider as S, Tooltip$1 as T, l as U, Upload$1 as V, Popover$1 as W, X, DoubleRightOutlined$1 as Y, ZoomInOutlined$1 as Z, _object_spread as _, AntdMessage as a, Divider$1 as a0, fetchEventSource as a1, Affix$1 as a2, Alert$1 as a3, Anchor$1 as a4, RefAutoComplete$1 as a5, Avatar$1 as a6, FloatButton$1 as a7, index$4 as a8, Badge$1 as a9, Skeleton$1 as aA, Slider$1 as aB, Space$1 as aC, Statistic$1 as aD, Steps$1 as aE, Switch$1 as aF, Tabs as aG, Tag$1 as aH, theme as aI, TimePicker$1 as aJ, Timeline$1 as aK, Tour$1 as aL, Transfer$1 as aM, Tree$1 as aN, TreeSelect$1 as aO, Typography$1 as aP, Watermark$1 as aQ, QRCode$1 as aR, version$3 as aS, en_US$1 as aT, Breadcrumb$1 as aa, Calendar$1 as ab, Card$1 as ac, Carousel$1 as ad, Cascader$1 as ae, Checkbox$1 as af, Col$1 as ag, Collapse$1 as ah, Descriptions as ai, Dropdown$1 as aj, Empty$1 as ak, Form$1 as al, index$3 as am, Image$2 as an, InputNumber$1 as ao, Layout$1 as ap, List$1 as aq, Mentions$1 as ar, Menu$1 as as, Popconfirm$1 as at, Progress$1 as au, Radio$1 as av, Rate$1 as aw, Result$2 as ax, Row$3 as ay, Segmented$1 as az, AntdNotification as b, _extends as c, _object_destructuring_empty as d, _object_spread_props as e, jsxs as f, _sliced_to_array as g, Table$1 as h, _to_consumable_array as i, jsx as j, Select$1 as k, CaretDownOutlined$1 as l, _inherits as m, _create_super as n, _create_class as o, _class_call_check as p, _define_property as q, _assert_this_initialized as r, _async_to_generator as s, transform$2 as t, MinusOutlined$1 as u, PlusOutlined$1 as v, __generator$1 as w, Input$1 as x, SearchOutlined$1 as y, zhCN as z };