@wiajs/core 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wia core v1.0.1
2
+ * wia core v1.0.2
3
3
  * (c) 2015-2023 Sibyl Yu and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -123,6 +123,970 @@
123
123
  _setPrototypeOf(subClass, superClass);
124
124
  }
125
125
 
126
+ function _extends() {
127
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
128
+ for (var i = 1; i < arguments.length; i++) {
129
+ var source = arguments[i];
130
+ for (var key in source) {
131
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
132
+ target[key] = source[key];
133
+ }
134
+ }
135
+ }
136
+ return target;
137
+ };
138
+ return _extends.apply(this, arguments);
139
+ }
140
+
141
+ function _arrayLikeToArray(arr, len) {
142
+ if (len == null || len > arr.length) len = arr.length;
143
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
144
+ return arr2;
145
+ }
146
+
147
+ function _unsupportedIterableToArray(o, minLen) {
148
+ if (!o) return;
149
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
150
+ var n = Object.prototype.toString.call(o).slice(8, -1);
151
+ if (n === "Object" && o.constructor) n = o.constructor.name;
152
+ if (n === "Map" || n === "Set") return Array.from(o);
153
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
154
+ }
155
+
156
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
157
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
158
+ if (it) return (it = it.call(o)).next.bind(it);
159
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
160
+ if (it) o = it;
161
+ var i = 0;
162
+ return function () {
163
+ if (i >= o.length) return {
164
+ done: true
165
+ };
166
+ return {
167
+ done: false,
168
+ value: o[i++]
169
+ };
170
+ };
171
+ }
172
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
173
+ }
174
+
175
+ function signum(num) {
176
+ return num < 0 ? -1 : 0 === num ? 0 : 1;
177
+ }
178
+ function lerp(start, stop, amount) {
179
+ return (1 - amount) * start + amount * stop;
180
+ }
181
+ function clampInt(min, max, input) {
182
+ return input < min ? min : input > max ? max : input;
183
+ }
184
+ function sanitizeDegreesDouble(degrees) {
185
+ return (degrees %= 360) < 0 && (degrees += 360), degrees;
186
+ }
187
+ function rotationDirection(from, to) {
188
+ return sanitizeDegreesDouble(to - from) <= 180 ? 1 : -1;
189
+ }
190
+ function differenceDegrees(a, b) {
191
+ return 180 - Math.abs(Math.abs(a - b) - 180);
192
+ }
193
+ function matrixMultiply(row, matrix) {
194
+ return [row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2], row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2], row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2]];
195
+ }
196
+ var SRGB_TO_XYZ = [[.41233895, .35762064, .18051042], [.2126, .7152, .0722], [.01932141, .11916382, .95034478]],
197
+ XYZ_TO_SRGB = [[3.2413774792388685, -1.5376652402851851, -.49885366846268053], [-.9691452513005321, 1.8758853451067872, .04156585616912061], [.05562093689691305, -.20395524564742123, 1.0571799111220335]],
198
+ WHITE_POINT_D65 = [95.047, 100, 108.883];
199
+ function argbFromRgb(red, green, blue) {
200
+ return (255 << 24 | (255 & red) << 16 | (255 & green) << 8 | 255 & blue) >>> 0;
201
+ }
202
+ function argbFromLinrgb(linrgb) {
203
+ return argbFromRgb(delinearized(linrgb[0]), delinearized(linrgb[1]), delinearized(linrgb[2]));
204
+ }
205
+ function redFromArgb(argb) {
206
+ return argb >> 16 & 255;
207
+ }
208
+ function greenFromArgb(argb) {
209
+ return argb >> 8 & 255;
210
+ }
211
+ function blueFromArgb(argb) {
212
+ return 255 & argb;
213
+ }
214
+ function argbFromXyz(x, y, z) {
215
+ var matrix = XYZ_TO_SRGB,
216
+ linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z,
217
+ linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z,
218
+ linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;
219
+ return argbFromRgb(delinearized(linearR), delinearized(linearG), delinearized(linearB));
220
+ }
221
+ function xyzFromArgb(argb) {
222
+ return matrixMultiply([linearized(redFromArgb(argb)), linearized(greenFromArgb(argb)), linearized(blueFromArgb(argb))], SRGB_TO_XYZ);
223
+ }
224
+ function argbFromLstar(lstar) {
225
+ var component = delinearized(yFromLstar(lstar));
226
+ return argbFromRgb(component, component, component);
227
+ }
228
+ function lstarFromArgb(argb) {
229
+ return 116 * labF(xyzFromArgb(argb)[1] / 100) - 16;
230
+ }
231
+ function yFromLstar(lstar) {
232
+ return 100 * labInvf((lstar + 16) / 116);
233
+ }
234
+ function linearized(rgbComponent) {
235
+ var normalized = rgbComponent / 255;
236
+ return normalized <= .040449936 ? normalized / 12.92 * 100 : 100 * Math.pow((normalized + .055) / 1.055, 2.4);
237
+ }
238
+ function delinearized(rgbComponent) {
239
+ var normalized = rgbComponent / 100;
240
+ var delinearized = 0;
241
+ return delinearized = normalized <= .0031308 ? 12.92 * normalized : 1.055 * Math.pow(normalized, 1 / 2.4) - .055, clampInt(0, 255, Math.round(255 * delinearized));
242
+ }
243
+ function whitePointD65() {
244
+ return WHITE_POINT_D65;
245
+ }
246
+ function labF(t) {
247
+ return t > 216 / 24389 ? Math.pow(t, 1 / 3) : (903.2962962962963 * t + 16) / 116;
248
+ }
249
+ function labInvf(ft) {
250
+ var ft3 = ft * ft * ft;
251
+ return ft3 > 216 / 24389 ? ft3 : (116 * ft - 16) / 903.2962962962963;
252
+ }
253
+ var ViewingConditions = function () {
254
+ ViewingConditions.make = function make(whitePoint, adaptingLuminance, backgroundLstar, surround, discountingIlluminant) {
255
+ if (whitePoint === void 0) {
256
+ whitePoint = whitePointD65();
257
+ }
258
+ if (adaptingLuminance === void 0) {
259
+ adaptingLuminance = 200 / Math.PI * yFromLstar(50) / 100;
260
+ }
261
+ if (backgroundLstar === void 0) {
262
+ backgroundLstar = 50;
263
+ }
264
+ if (surround === void 0) {
265
+ surround = 2;
266
+ }
267
+ if (discountingIlluminant === void 0) {
268
+ discountingIlluminant = !1;
269
+ }
270
+ var xyz = whitePoint,
271
+ rW = .401288 * xyz[0] + .650173 * xyz[1] + -.051461 * xyz[2],
272
+ gW = -.250268 * xyz[0] + 1.204414 * xyz[1] + .045854 * xyz[2],
273
+ bW = -.002079 * xyz[0] + .048952 * xyz[1] + .953127 * xyz[2],
274
+ f = .8 + surround / 10,
275
+ c = f >= .9 ? lerp(.59, .69, 10 * (f - .9)) : lerp(.525, .59, 10 * (f - .8));
276
+ var d = discountingIlluminant ? 1 : f * (1 - 1 / 3.6 * Math.exp((-adaptingLuminance - 42) / 92));
277
+ d = d > 1 ? 1 : d < 0 ? 0 : d;
278
+ var nc = f,
279
+ rgbD = [d * (100 / rW) + 1 - d, d * (100 / gW) + 1 - d, d * (100 / bW) + 1 - d],
280
+ k = 1 / (5 * adaptingLuminance + 1),
281
+ k4 = k * k * k * k,
282
+ k4F = 1 - k4,
283
+ fl = k4 * adaptingLuminance + .1 * k4F * k4F * Math.cbrt(5 * adaptingLuminance),
284
+ n = yFromLstar(backgroundLstar) / whitePoint[1],
285
+ z = 1.48 + Math.sqrt(n),
286
+ nbb = .725 / Math.pow(n, .2),
287
+ ncb = nbb,
288
+ rgbAFactors = [Math.pow(fl * rgbD[0] * rW / 100, .42), Math.pow(fl * rgbD[1] * gW / 100, .42), Math.pow(fl * rgbD[2] * bW / 100, .42)],
289
+ rgbA = [400 * rgbAFactors[0] / (rgbAFactors[0] + 27.13), 400 * rgbAFactors[1] / (rgbAFactors[1] + 27.13), 400 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)];
290
+ return new ViewingConditions(n, (2 * rgbA[0] + rgbA[1] + .05 * rgbA[2]) * nbb, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, .25), z);
291
+ };
292
+ function ViewingConditions(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
293
+ this.n = n, this.aw = aw, this.nbb = nbb, this.ncb = ncb, this.c = c, this.nc = nc, this.rgbD = rgbD, this.fl = fl, this.fLRoot = fLRoot, this.z = z;
294
+ }
295
+ return ViewingConditions;
296
+ }();
297
+ ViewingConditions.DEFAULT = ViewingConditions.make();
298
+ var Cam16 = function () {
299
+ function Cam16(hue, chroma, j, q, m, s, jstar, astar, bstar) {
300
+ this.hue = hue, this.chroma = chroma, this.j = j, this.q = q, this.m = m, this.s = s, this.jstar = jstar, this.astar = astar, this.bstar = bstar;
301
+ }
302
+ var _proto = Cam16.prototype;
303
+ _proto.distance = function distance(other) {
304
+ var dJ = this.jstar - other.jstar,
305
+ dA = this.astar - other.astar,
306
+ dB = this.bstar - other.bstar,
307
+ dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
308
+ return 1.41 * Math.pow(dEPrime, .63);
309
+ };
310
+ Cam16.fromInt = function fromInt(argb) {
311
+ return Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);
312
+ };
313
+ Cam16.fromIntInViewingConditions = function fromIntInViewingConditions(argb, viewingConditions) {
314
+ var green = (65280 & argb) >> 8,
315
+ blue = 255 & argb,
316
+ redL = linearized((16711680 & argb) >> 16),
317
+ greenL = linearized(green),
318
+ blueL = linearized(blue),
319
+ x = .41233895 * redL + .35762064 * greenL + .18051042 * blueL,
320
+ y = .2126 * redL + .7152 * greenL + .0722 * blueL,
321
+ z = .01932141 * redL + .11916382 * greenL + .95034478 * blueL,
322
+ rC = .401288 * x + .650173 * y - .051461 * z,
323
+ gC = -.250268 * x + 1.204414 * y + .045854 * z,
324
+ bC = -.002079 * x + .048952 * y + .953127 * z,
325
+ rD = viewingConditions.rgbD[0] * rC,
326
+ gD = viewingConditions.rgbD[1] * gC,
327
+ bD = viewingConditions.rgbD[2] * bC,
328
+ rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, .42),
329
+ gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, .42),
330
+ bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, .42),
331
+ rA = 400 * signum(rD) * rAF / (rAF + 27.13),
332
+ gA = 400 * signum(gD) * gAF / (gAF + 27.13),
333
+ bA = 400 * signum(bD) * bAF / (bAF + 27.13),
334
+ a = (11 * rA + -12 * gA + bA) / 11,
335
+ b = (rA + gA - 2 * bA) / 9,
336
+ u = (20 * rA + 20 * gA + 21 * bA) / 20,
337
+ p2 = (40 * rA + 20 * gA + bA) / 20,
338
+ atanDegrees = 180 * Math.atan2(b, a) / Math.PI,
339
+ hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees,
340
+ hueRadians = hue * Math.PI / 180,
341
+ ac = p2 * viewingConditions.nbb,
342
+ j = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z),
343
+ q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot,
344
+ huePrime = hue < 20.14 ? hue + 360 : hue,
345
+ t = 5e4 / 13 * (.25 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8)) * viewingConditions.nc * viewingConditions.ncb * Math.sqrt(a * a + b * b) / (u + .305),
346
+ alpha = Math.pow(t, .9) * Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73),
347
+ c = alpha * Math.sqrt(j / 100),
348
+ m = c * viewingConditions.fLRoot,
349
+ s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)),
350
+ jstar = (1 + 100 * .007) * j / (1 + .007 * j),
351
+ mstar = 1 / .0228 * Math.log(1 + .0228 * m),
352
+ astar = mstar * Math.cos(hueRadians),
353
+ bstar = mstar * Math.sin(hueRadians);
354
+ return new Cam16(hue, c, j, q, m, s, jstar, astar, bstar);
355
+ };
356
+ Cam16.fromJch = function fromJch(j, c, h) {
357
+ return Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);
358
+ };
359
+ Cam16.fromJchInViewingConditions = function fromJchInViewingConditions(j, c, h, viewingConditions) {
360
+ var q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot,
361
+ m = c * viewingConditions.fLRoot,
362
+ alpha = c / Math.sqrt(j / 100),
363
+ s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)),
364
+ hueRadians = h * Math.PI / 180,
365
+ jstar = (1 + 100 * .007) * j / (1 + .007 * j),
366
+ mstar = 1 / .0228 * Math.log(1 + .0228 * m),
367
+ astar = mstar * Math.cos(hueRadians),
368
+ bstar = mstar * Math.sin(hueRadians);
369
+ return new Cam16(h, c, j, q, m, s, jstar, astar, bstar);
370
+ };
371
+ Cam16.fromUcs = function fromUcs(jstar, astar, bstar) {
372
+ return Cam16.fromUcsInViewingConditions(jstar, astar, bstar, ViewingConditions.DEFAULT);
373
+ };
374
+ Cam16.fromUcsInViewingConditions = function fromUcsInViewingConditions(jstar, astar, bstar, viewingConditions) {
375
+ var a = astar,
376
+ b = bstar,
377
+ m = Math.sqrt(a * a + b * b),
378
+ c = (Math.exp(.0228 * m) - 1) / .0228 / viewingConditions.fLRoot;
379
+ var h = Math.atan2(b, a) * (180 / Math.PI);
380
+ h < 0 && (h += 360);
381
+ var j = jstar / (1 - .007 * (jstar - 100));
382
+ return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
383
+ };
384
+ _proto.toInt = function toInt() {
385
+ return this.viewed(ViewingConditions.DEFAULT);
386
+ };
387
+ _proto.viewed = function viewed(viewingConditions) {
388
+ var alpha = 0 === this.chroma || 0 === this.j ? 0 : this.chroma / Math.sqrt(this.j / 100),
389
+ t = Math.pow(alpha / Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73), 1 / .9),
390
+ hRad = this.hue * Math.PI / 180,
391
+ eHue = .25 * (Math.cos(hRad + 2) + 3.8),
392
+ ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z),
393
+ p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb,
394
+ p2 = ac / viewingConditions.nbb,
395
+ hSin = Math.sin(hRad),
396
+ hCos = Math.cos(hRad),
397
+ gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin),
398
+ a = gamma * hCos,
399
+ b = gamma * hSin,
400
+ rA = (460 * p2 + 451 * a + 288 * b) / 1403,
401
+ gA = (460 * p2 - 891 * a - 261 * b) / 1403,
402
+ bA = (460 * p2 - 220 * a - 6300 * b) / 1403,
403
+ rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))),
404
+ rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / .42),
405
+ gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))),
406
+ gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / .42),
407
+ bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))),
408
+ bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / .42),
409
+ rF = rC / viewingConditions.rgbD[0],
410
+ gF = gC / viewingConditions.rgbD[1],
411
+ bF = bC / viewingConditions.rgbD[2];
412
+ return argbFromXyz(1.86206786 * rF - 1.01125463 * gF + .14918677 * bF, .38752654 * rF + .62144744 * gF - .00897398 * bF, -.0158415 * rF - .03412294 * gF + 1.04996444 * bF);
413
+ };
414
+ return Cam16;
415
+ }();
416
+ var HctSolver = function () {
417
+ function HctSolver() {}
418
+ HctSolver.sanitizeRadians = function sanitizeRadians(angle) {
419
+ return (angle + 8 * Math.PI) % (2 * Math.PI);
420
+ };
421
+ HctSolver.trueDelinearized = function trueDelinearized(rgbComponent) {
422
+ var normalized = rgbComponent / 100;
423
+ var delinearized = 0;
424
+ return delinearized = normalized <= .0031308 ? 12.92 * normalized : 1.055 * Math.pow(normalized, 1 / 2.4) - .055, 255 * delinearized;
425
+ };
426
+ HctSolver.chromaticAdaptation = function chromaticAdaptation(component) {
427
+ var af = Math.pow(Math.abs(component), .42);
428
+ return 400 * signum(component) * af / (af + 27.13);
429
+ };
430
+ HctSolver.hueOf = function hueOf(linrgb) {
431
+ var scaledDiscount = matrixMultiply(linrgb, HctSolver.SCALED_DISCOUNT_FROM_LINRGB),
432
+ rA = HctSolver.chromaticAdaptation(scaledDiscount[0]),
433
+ gA = HctSolver.chromaticAdaptation(scaledDiscount[1]),
434
+ bA = HctSolver.chromaticAdaptation(scaledDiscount[2]),
435
+ a = (11 * rA + -12 * gA + bA) / 11,
436
+ b = (rA + gA - 2 * bA) / 9;
437
+ return Math.atan2(b, a);
438
+ };
439
+ HctSolver.areInCyclicOrder = function areInCyclicOrder(a, b, c) {
440
+ return HctSolver.sanitizeRadians(b - a) < HctSolver.sanitizeRadians(c - a);
441
+ };
442
+ HctSolver.intercept = function intercept(source, mid, target) {
443
+ return (mid - source) / (target - source);
444
+ };
445
+ HctSolver.lerpPoint = function lerpPoint(source, t, target) {
446
+ return [source[0] + (target[0] - source[0]) * t, source[1] + (target[1] - source[1]) * t, source[2] + (target[2] - source[2]) * t];
447
+ };
448
+ HctSolver.setCoordinate = function setCoordinate(source, coordinate, target, axis) {
449
+ var t = HctSolver.intercept(source[axis], coordinate, target[axis]);
450
+ return HctSolver.lerpPoint(source, t, target);
451
+ };
452
+ HctSolver.isBounded = function isBounded(x) {
453
+ return 0 <= x && x <= 100;
454
+ };
455
+ HctSolver.nthVertex = function nthVertex(y, n) {
456
+ var kR = HctSolver.Y_FROM_LINRGB[0],
457
+ kG = HctSolver.Y_FROM_LINRGB[1],
458
+ kB = HctSolver.Y_FROM_LINRGB[2],
459
+ coordA = n % 4 <= 1 ? 0 : 100,
460
+ coordB = n % 2 == 0 ? 0 : 100;
461
+ if (n < 4) {
462
+ var g = coordA,
463
+ b = coordB,
464
+ r = (y - g * kG - b * kB) / kR;
465
+ return HctSolver.isBounded(r) ? [r, g, b] : [-1, -1, -1];
466
+ }
467
+ if (n < 8) {
468
+ var _b = coordA,
469
+ _r = coordB,
470
+ _g = (y - _r * kR - _b * kB) / kG;
471
+ return HctSolver.isBounded(_g) ? [_r, _g, _b] : [-1, -1, -1];
472
+ }
473
+ {
474
+ var _r2 = coordA,
475
+ _g2 = coordB,
476
+ _b2 = (y - _r2 * kR - _g2 * kG) / kB;
477
+ return HctSolver.isBounded(_b2) ? [_r2, _g2, _b2] : [-1, -1, -1];
478
+ }
479
+ };
480
+ HctSolver.bisectToSegment = function bisectToSegment(y, targetHue) {
481
+ var left = [-1, -1, -1],
482
+ right = left,
483
+ leftHue = 0,
484
+ rightHue = 0,
485
+ initialized = !1,
486
+ uncut = !0;
487
+ for (var n = 0; n < 12; n++) {
488
+ var mid = HctSolver.nthVertex(y, n);
489
+ if (mid[0] < 0) continue;
490
+ var midHue = HctSolver.hueOf(mid);
491
+ initialized ? (uncut || HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) && (uncut = !1, HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rightHue = midHue) : (left = mid, leftHue = midHue)) : (left = mid, right = mid, leftHue = midHue, rightHue = midHue, initialized = !0);
492
+ }
493
+ return [left, right];
494
+ };
495
+ HctSolver.midpoint = function midpoint(a, b) {
496
+ return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
497
+ };
498
+ HctSolver.criticalPlaneBelow = function criticalPlaneBelow(x) {
499
+ return Math.floor(x - .5);
500
+ };
501
+ HctSolver.criticalPlaneAbove = function criticalPlaneAbove(x) {
502
+ return Math.ceil(x - .5);
503
+ };
504
+ HctSolver.bisectToLimit = function bisectToLimit(y, targetHue) {
505
+ var segment = HctSolver.bisectToSegment(y, targetHue);
506
+ var left = segment[0],
507
+ leftHue = HctSolver.hueOf(left),
508
+ right = segment[1];
509
+ for (var axis = 0; axis < 3; axis++) if (left[axis] !== right[axis]) {
510
+ var lPlane = -1,
511
+ rPlane = 255;
512
+ left[axis] < right[axis] ? (lPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(left[axis])), rPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(right[axis]))) : (lPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(left[axis])), rPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(right[axis])));
513
+ for (var i = 0; i < 8 && !(Math.abs(rPlane - lPlane) <= 1); i++) {
514
+ var mPlane = Math.floor((lPlane + rPlane) / 2),
515
+ midPlaneCoordinate = HctSolver.CRITICAL_PLANES[mPlane],
516
+ mid = HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis),
517
+ midHue = HctSolver.hueOf(mid);
518
+ HctSolver.areInCyclicOrder(leftHue, targetHue, midHue) ? (right = mid, rPlane = mPlane) : (left = mid, leftHue = midHue, lPlane = mPlane);
519
+ }
520
+ }
521
+ return HctSolver.midpoint(left, right);
522
+ };
523
+ HctSolver.inverseChromaticAdaptation = function inverseChromaticAdaptation(adapted) {
524
+ var adaptedAbs = Math.abs(adapted),
525
+ base = Math.max(0, 27.13 * adaptedAbs / (400 - adaptedAbs));
526
+ return signum(adapted) * Math.pow(base, 1 / .42);
527
+ };
528
+ HctSolver.findResultByJ = function findResultByJ(hueRadians, chroma, y) {
529
+ var j = 11 * Math.sqrt(y);
530
+ var viewingConditions = ViewingConditions.DEFAULT,
531
+ tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73),
532
+ p1 = .25 * (Math.cos(hueRadians + 2) + 3.8) * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb,
533
+ hSin = Math.sin(hueRadians),
534
+ hCos = Math.cos(hueRadians);
535
+ for (var iterationRound = 0; iterationRound < 5; iterationRound++) {
536
+ var jNormalized = j / 100,
537
+ alpha = 0 === chroma || 0 === j ? 0 : chroma / Math.sqrt(jNormalized),
538
+ t = Math.pow(alpha * tInnerCoeff, 1 / .9),
539
+ p2 = viewingConditions.aw * Math.pow(jNormalized, 1 / viewingConditions.c / viewingConditions.z) / viewingConditions.nbb,
540
+ gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin),
541
+ a = gamma * hCos,
542
+ b = gamma * hSin,
543
+ rA = (460 * p2 + 451 * a + 288 * b) / 1403,
544
+ gA = (460 * p2 - 891 * a - 261 * b) / 1403,
545
+ bA = (460 * p2 - 220 * a - 6300 * b) / 1403,
546
+ linrgb = matrixMultiply([HctSolver.inverseChromaticAdaptation(rA), HctSolver.inverseChromaticAdaptation(gA), HctSolver.inverseChromaticAdaptation(bA)], HctSolver.LINRGB_FROM_SCALED_DISCOUNT);
547
+ if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) return 0;
548
+ var kR = HctSolver.Y_FROM_LINRGB[0],
549
+ kG = HctSolver.Y_FROM_LINRGB[1],
550
+ kB = HctSolver.Y_FROM_LINRGB[2],
551
+ fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];
552
+ if (fnj <= 0) return 0;
553
+ if (4 === iterationRound || Math.abs(fnj - y) < .002) return linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01 ? 0 : argbFromLinrgb(linrgb);
554
+ j -= (fnj - y) * j / (2 * fnj);
555
+ }
556
+ return 0;
557
+ };
558
+ HctSolver.solveToInt = function solveToInt(hueDegrees, chroma, lstar) {
559
+ if (chroma < 1e-4 || lstar < 1e-4 || lstar > 99.9999) return argbFromLstar(lstar);
560
+ var hueRadians = (hueDegrees = sanitizeDegreesDouble(hueDegrees)) / 180 * Math.PI,
561
+ y = yFromLstar(lstar),
562
+ exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);
563
+ if (0 !== exactAnswer) return exactAnswer;
564
+ return argbFromLinrgb(HctSolver.bisectToLimit(y, hueRadians));
565
+ };
566
+ HctSolver.solveToCam = function solveToCam(hueDegrees, chroma, lstar) {
567
+ return Cam16.fromInt(HctSolver.solveToInt(hueDegrees, chroma, lstar));
568
+ };
569
+ return HctSolver;
570
+ }();
571
+ HctSolver.SCALED_DISCOUNT_FROM_LINRGB = [[.001200833568784504, .002389694492170889, .0002795742885861124], [.0005891086651375999, .0029785502573438758, .0003270666104008398], [.00010146692491640572, .0005364214359186694, .0032979401770712076]], HctSolver.LINRGB_FROM_SCALED_DISCOUNT = [[1373.2198709594231, -1100.4251190754821, -7.278681089101213], [-271.815969077903, 559.6580465940733, -32.46047482791194], [1.9622899599665666, -57.173814538844006, 308.7233197812385]], HctSolver.Y_FROM_LINRGB = [.2126, .7152, .0722], HctSolver.CRITICAL_PLANES = [.015176349177441876, .045529047532325624, .07588174588720938, .10623444424209313, .13658714259697685, .16693984095186062, .19729253930674434, .2276452376616281, .2579979360165119, .28835063437139563, .3188300904430532, .350925934958123, .3848314933096426, .42057480301049466, .458183274052838, .4976837250274023, .5391024159806381, .5824650784040898, .6277969426914107, .6751227633498623, .7244668422128921, .775853049866786, .829304845476233, .8848452951698498, .942497089126609, 1.0022825574869039, 1.0642236851973577, 1.1283421258858297, 1.1946592148522128, 1.2631959812511864, 1.3339731595349034, 1.407011200216447, 1.4823302800086415, 1.5599503113873272, 1.6398909516233677, 1.7221716113234105, 1.8068114625156377, 1.8938294463134073, 1.9832442801866852, 2.075074464868551, 2.1693382909216234, 2.2660538449872063, 2.36523901573795, 2.4669114995532007, 2.5710888059345764, 2.6777882626779785, 2.7870270208169257, 2.898822059350997, 3.0131901897720907, 3.1301480604002863, 3.2497121605402226, 3.3718988244681087, 3.4967242352587946, 3.624204428461639, 3.754355295633311, 3.887192587735158, 4.022731918402185, 4.160988767090289, 4.301978482107941, 4.445716283538092, 4.592217266055746, 4.741496401646282, 4.893568542229298, 5.048448422192488, 5.20615066083972, 5.3666897647573375, 5.5300801301023865, 5.696336044816294, 5.865471690767354, 6.037501145825082, 6.212438385869475, 6.390297286737924, 6.571091626112461, 6.7548350853498045, 6.941541251256611, 7.131223617812143, 7.323895587840543, 7.5195704746346665, 7.7182615035334345, 7.919981813454504, 8.124744458384042, 8.332562408825165, 8.543448553206703, 8.757415699253682, 8.974476575321063, 9.194643831691977, 9.417930041841839, 9.644347703669503, 9.873909240696694, 10.106627003236781, 10.342513269534024, 10.58158024687427, 10.8238400726681, 11.069304815507364, 11.317986476196008, 11.569896988756009, 11.825048221409341, 12.083451977536606, 12.345119996613247, 12.610063955123938, 12.878295467455942, 13.149826086772048, 13.42466730586372, 13.702830557985108, 13.984327217668513, 14.269168601521828, 14.55736596900856, 14.848930523210871, 15.143873411576273, 15.44220572664832, 15.743938506781891, 16.04908273684337, 16.35764934889634, 16.66964922287304, 16.985093187232053, 17.30399201960269, 17.62635644741625, 17.95219714852476, 18.281524751807332, 18.614349837764564, 18.95068293910138, 19.290534541298456, 19.633915083172692, 19.98083495742689, 20.331304511189067, 20.685334046541502, 21.042933821039977, 21.404114048223256, 21.76888489811322, 22.137256497705877, 22.50923893145328, 22.884842241736916, 23.264076429332462, 23.6469514538663, 24.033477234264016, 24.42366364919083, 24.817520537484558, 25.21505769858089, 25.61628489293138, 26.021211842414342, 26.429848230738664, 26.842203703840827, 27.258287870275353, 27.678110301598522, 28.10168053274597, 28.529008062403893, 28.96010235337422, 29.39497283293396, 29.83362889318845, 30.276079891419332, 30.722335150426627, 31.172403958865512, 31.62629557157785, 32.08401920991837, 32.54558406207592, 33.010999283389665, 33.4802739966603, 33.953417292456834, 34.430438229418264, 34.911345834551085, 35.39614910352207, 35.88485700094671, 36.37747846067349, 36.87402238606382, 37.37449765026789, 37.87891309649659, 38.38727753828926, 38.89959975977785, 39.41588851594697, 39.93615253289054, 40.460400508064545, 40.98864111053629, 41.520882981230194, 42.05713473317016, 42.597404951718396, 43.141702194811224, 43.6900349931913, 44.24241185063697, 44.798841244188324, 45.35933162437017, 45.92389141541209, 46.49252901546552, 47.065252796817916, 47.64207110610409, 48.22299226451468, 48.808024568002054, 49.3971762874833, 49.9904556690408, 50.587870934119984, 51.189430279724725, 51.79514187861014, 52.40501387947288, 53.0190544071392, 53.637271562750364, 54.259673423945976, 54.88626804504493, 55.517063457223934, 56.15206766869424, 56.79128866487574, 57.43473440856916, 58.08241284012621, 58.734331877617365, 59.39049941699807, 60.05092333227251, 60.715611475655585, 61.38457167773311, 62.057811747619894, 62.7353394731159, 63.417162620860914, 64.10328893648692, 64.79372614476921, 65.48848194977529, 66.18756403501224, 66.89098006357258, 67.59873767827808, 68.31084450182222, 69.02730813691093, 69.74813616640164, 70.47333615344107, 71.20291564160104, 71.93688215501312, 72.67524319850172, 73.41800625771542, 74.16517879925733, 74.9167682708136, 75.67278210128072, 76.43322770089146, 77.1981124613393, 77.96744375590167, 78.74122893956174, 79.51947534912904, 80.30219030335869, 81.08938110306934, 81.88105503125999, 82.67721935322541, 83.4778813166706, 84.28304815182372, 85.09272707154808, 85.90692527145302, 86.72564993000343, 87.54890820862819, 88.3767072518277, 89.2090541872801, 90.04595612594655, 90.88742016217518, 91.73345337380438, 92.58406282226491, 93.43925555268066, 94.29903859396902, 95.16341895893969, 96.03240364439274, 96.9059996312159, 97.78421388448044, 98.6670533535366, 99.55452497210776];
572
+ var Hct = function () {
573
+ Hct.from = function from(hue, chroma, tone) {
574
+ return new Hct(HctSolver.solveToInt(hue, chroma, tone));
575
+ };
576
+ Hct.fromInt = function fromInt(argb) {
577
+ return new Hct(argb);
578
+ };
579
+ var _proto2 = Hct.prototype;
580
+ _proto2.toInt = function toInt() {
581
+ return this.argb;
582
+ };
583
+ function Hct(argb) {
584
+ this.argb = argb;
585
+ var cam = Cam16.fromInt(argb);
586
+ this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
587
+ }
588
+ _proto2.setInternalState = function setInternalState(argb) {
589
+ var cam = Cam16.fromInt(argb);
590
+ this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
591
+ };
592
+ _createClass(Hct, [{
593
+ key: "hue",
594
+ get: function get() {
595
+ return this.internalHue;
596
+ },
597
+ set: function set(newHue) {
598
+ this.setInternalState(HctSolver.solveToInt(newHue, this.internalChroma, this.internalTone));
599
+ }
600
+ }, {
601
+ key: "chroma",
602
+ get: function get() {
603
+ return this.internalChroma;
604
+ },
605
+ set: function set(newChroma) {
606
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, newChroma, this.internalTone));
607
+ }
608
+ }, {
609
+ key: "tone",
610
+ get: function get() {
611
+ return this.internalTone;
612
+ },
613
+ set: function set(newTone) {
614
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, this.internalChroma, newTone));
615
+ }
616
+ }]);
617
+ return Hct;
618
+ }();
619
+ var Blend = function () {
620
+ function Blend() {}
621
+ Blend.harmonize = function harmonize(designColor, sourceColor) {
622
+ var fromHct = Hct.fromInt(designColor),
623
+ toHct = Hct.fromInt(sourceColor),
624
+ differenceDegrees$1 = differenceDegrees(fromHct.hue, toHct.hue),
625
+ rotationDegrees = Math.min(.5 * differenceDegrees$1, 15),
626
+ outputHue = sanitizeDegreesDouble(fromHct.hue + rotationDegrees * rotationDirection(fromHct.hue, toHct.hue));
627
+ return Hct.from(outputHue, fromHct.chroma, fromHct.tone).toInt();
628
+ };
629
+ Blend.hctHue = function hctHue(from, to, amount) {
630
+ var ucs = Blend.cam16Ucs(from, to, amount),
631
+ ucsCam = Cam16.fromInt(ucs),
632
+ fromCam = Cam16.fromInt(from);
633
+ return Hct.from(ucsCam.hue, fromCam.chroma, lstarFromArgb(from)).toInt();
634
+ };
635
+ Blend.cam16Ucs = function cam16Ucs(from, to, amount) {
636
+ var fromCam = Cam16.fromInt(from),
637
+ toCam = Cam16.fromInt(to),
638
+ fromJ = fromCam.jstar,
639
+ fromA = fromCam.astar,
640
+ fromB = fromCam.bstar,
641
+ jstar = fromJ + (toCam.jstar - fromJ) * amount,
642
+ astar = fromA + (toCam.astar - fromA) * amount,
643
+ bstar = fromB + (toCam.bstar - fromB) * amount;
644
+ return Cam16.fromUcs(jstar, astar, bstar).toInt();
645
+ };
646
+ return Blend;
647
+ }();
648
+ var TonalPalette = function () {
649
+ TonalPalette.fromInt = function fromInt(argb) {
650
+ var hct = Hct.fromInt(argb);
651
+ return TonalPalette.fromHueAndChroma(hct.hue, hct.chroma);
652
+ };
653
+ TonalPalette.fromHueAndChroma = function fromHueAndChroma(hue, chroma) {
654
+ return new TonalPalette(hue, chroma);
655
+ };
656
+ function TonalPalette(hue, chroma) {
657
+ this.hue = hue, this.chroma = chroma, this.cache = new Map();
658
+ }
659
+ var _proto3 = TonalPalette.prototype;
660
+ _proto3.tone = function tone(_tone) {
661
+ var argb = this.cache.get(_tone);
662
+ return void 0 === argb && (argb = Hct.from(this.hue, this.chroma, _tone).toInt(), this.cache.set(_tone, argb)), argb;
663
+ };
664
+ return TonalPalette;
665
+ }();
666
+ var CorePalette = function () {
667
+ CorePalette.of = function of(argb) {
668
+ return new CorePalette(argb, !1);
669
+ };
670
+ CorePalette.contentOf = function contentOf(argb) {
671
+ return new CorePalette(argb, !0);
672
+ };
673
+ CorePalette.fromColors = function fromColors(colors) {
674
+ return CorePalette.createPaletteFromColors(!1, colors);
675
+ };
676
+ CorePalette.contentFromColors = function contentFromColors(colors) {
677
+ return CorePalette.createPaletteFromColors(!0, colors);
678
+ };
679
+ CorePalette.createPaletteFromColors = function createPaletteFromColors(content, colors) {
680
+ var palette = new CorePalette(colors.primary, content);
681
+ if (colors.secondary) {
682
+ var p = new CorePalette(colors.secondary, content);
683
+ palette.a2 = p.a1;
684
+ }
685
+ if (colors.tertiary) {
686
+ var _p = new CorePalette(colors.tertiary, content);
687
+ palette.a3 = _p.a1;
688
+ }
689
+ if (colors.error) {
690
+ var _p2 = new CorePalette(colors.error, content);
691
+ palette.error = _p2.a1;
692
+ }
693
+ if (colors.neutral) {
694
+ var _p3 = new CorePalette(colors.neutral, content);
695
+ palette.n1 = _p3.n1;
696
+ }
697
+ if (colors.neutralVariant) {
698
+ var _p4 = new CorePalette(colors.neutralVariant, content);
699
+ palette.n2 = _p4.n2;
700
+ }
701
+ return palette;
702
+ };
703
+ function CorePalette(argb, isContent) {
704
+ var hct = Hct.fromInt(argb),
705
+ hue = hct.hue,
706
+ chroma = hct.chroma;
707
+ isContent ? (this.a1 = TonalPalette.fromHueAndChroma(hue, chroma), this.a2 = TonalPalette.fromHueAndChroma(hue, chroma / 3), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, chroma / 2), this.n1 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 12, 4)), this.n2 = TonalPalette.fromHueAndChroma(hue, Math.min(chroma / 6, 8))) : (this.a1 = TonalPalette.fromHueAndChroma(hue, Math.max(48, chroma)), this.a2 = TonalPalette.fromHueAndChroma(hue, 16), this.a3 = TonalPalette.fromHueAndChroma(hue + 60, 24), this.n1 = TonalPalette.fromHueAndChroma(hue, 4), this.n2 = TonalPalette.fromHueAndChroma(hue, 8)), this.error = TonalPalette.fromHueAndChroma(25, 84);
708
+ }
709
+ return CorePalette;
710
+ }();
711
+ var Scheme = function () {
712
+ Scheme.light = function light(argb) {
713
+ return Scheme.lightFromCorePalette(CorePalette.of(argb));
714
+ };
715
+ Scheme.dark = function dark(argb) {
716
+ return Scheme.darkFromCorePalette(CorePalette.of(argb));
717
+ };
718
+ Scheme.lightContent = function lightContent(argb) {
719
+ return Scheme.lightFromCorePalette(CorePalette.contentOf(argb));
720
+ };
721
+ Scheme.darkContent = function darkContent(argb) {
722
+ return Scheme.darkFromCorePalette(CorePalette.contentOf(argb));
723
+ };
724
+ Scheme.lightFromCorePalette = function lightFromCorePalette(core) {
725
+ return new Scheme({
726
+ primary: core.a1.tone(40),
727
+ onPrimary: core.a1.tone(100),
728
+ primaryContainer: core.a1.tone(90),
729
+ onPrimaryContainer: core.a1.tone(10),
730
+ secondary: core.a2.tone(40),
731
+ onSecondary: core.a2.tone(100),
732
+ secondaryContainer: core.a2.tone(90),
733
+ onSecondaryContainer: core.a2.tone(10),
734
+ tertiary: core.a3.tone(40),
735
+ onTertiary: core.a3.tone(100),
736
+ tertiaryContainer: core.a3.tone(90),
737
+ onTertiaryContainer: core.a3.tone(10),
738
+ error: core.error.tone(40),
739
+ onError: core.error.tone(100),
740
+ errorContainer: core.error.tone(90),
741
+ onErrorContainer: core.error.tone(10),
742
+ background: core.n1.tone(99),
743
+ onBackground: core.n1.tone(10),
744
+ surface: core.n1.tone(99),
745
+ onSurface: core.n1.tone(10),
746
+ surfaceVariant: core.n2.tone(90),
747
+ onSurfaceVariant: core.n2.tone(30),
748
+ outline: core.n2.tone(50),
749
+ outlineVariant: core.n2.tone(80),
750
+ shadow: core.n1.tone(0),
751
+ scrim: core.n1.tone(0),
752
+ inverseSurface: core.n1.tone(20),
753
+ inverseOnSurface: core.n1.tone(95),
754
+ inversePrimary: core.a1.tone(80)
755
+ });
756
+ };
757
+ Scheme.darkFromCorePalette = function darkFromCorePalette(core) {
758
+ return new Scheme({
759
+ primary: core.a1.tone(80),
760
+ onPrimary: core.a1.tone(20),
761
+ primaryContainer: core.a1.tone(30),
762
+ onPrimaryContainer: core.a1.tone(90),
763
+ secondary: core.a2.tone(80),
764
+ onSecondary: core.a2.tone(20),
765
+ secondaryContainer: core.a2.tone(30),
766
+ onSecondaryContainer: core.a2.tone(90),
767
+ tertiary: core.a3.tone(80),
768
+ onTertiary: core.a3.tone(20),
769
+ tertiaryContainer: core.a3.tone(30),
770
+ onTertiaryContainer: core.a3.tone(90),
771
+ error: core.error.tone(80),
772
+ onError: core.error.tone(20),
773
+ errorContainer: core.error.tone(30),
774
+ onErrorContainer: core.error.tone(80),
775
+ background: core.n1.tone(10),
776
+ onBackground: core.n1.tone(90),
777
+ surface: core.n1.tone(10),
778
+ onSurface: core.n1.tone(90),
779
+ surfaceVariant: core.n2.tone(30),
780
+ onSurfaceVariant: core.n2.tone(80),
781
+ outline: core.n2.tone(60),
782
+ outlineVariant: core.n2.tone(30),
783
+ shadow: core.n1.tone(0),
784
+ scrim: core.n1.tone(0),
785
+ inverseSurface: core.n1.tone(90),
786
+ inverseOnSurface: core.n1.tone(20),
787
+ inversePrimary: core.a1.tone(40)
788
+ });
789
+ };
790
+ function Scheme(props) {
791
+ this.props = props;
792
+ }
793
+ var _proto4 = Scheme.prototype;
794
+ _proto4.toJSON = function toJSON() {
795
+ return _extends({}, this.props);
796
+ };
797
+ _createClass(Scheme, [{
798
+ key: "primary",
799
+ get: function get() {
800
+ return this.props.primary;
801
+ }
802
+ }, {
803
+ key: "onPrimary",
804
+ get: function get() {
805
+ return this.props.onPrimary;
806
+ }
807
+ }, {
808
+ key: "primaryContainer",
809
+ get: function get() {
810
+ return this.props.primaryContainer;
811
+ }
812
+ }, {
813
+ key: "onPrimaryContainer",
814
+ get: function get() {
815
+ return this.props.onPrimaryContainer;
816
+ }
817
+ }, {
818
+ key: "secondary",
819
+ get: function get() {
820
+ return this.props.secondary;
821
+ }
822
+ }, {
823
+ key: "onSecondary",
824
+ get: function get() {
825
+ return this.props.onSecondary;
826
+ }
827
+ }, {
828
+ key: "secondaryContainer",
829
+ get: function get() {
830
+ return this.props.secondaryContainer;
831
+ }
832
+ }, {
833
+ key: "onSecondaryContainer",
834
+ get: function get() {
835
+ return this.props.onSecondaryContainer;
836
+ }
837
+ }, {
838
+ key: "tertiary",
839
+ get: function get() {
840
+ return this.props.tertiary;
841
+ }
842
+ }, {
843
+ key: "onTertiary",
844
+ get: function get() {
845
+ return this.props.onTertiary;
846
+ }
847
+ }, {
848
+ key: "tertiaryContainer",
849
+ get: function get() {
850
+ return this.props.tertiaryContainer;
851
+ }
852
+ }, {
853
+ key: "onTertiaryContainer",
854
+ get: function get() {
855
+ return this.props.onTertiaryContainer;
856
+ }
857
+ }, {
858
+ key: "error",
859
+ get: function get() {
860
+ return this.props.error;
861
+ }
862
+ }, {
863
+ key: "onError",
864
+ get: function get() {
865
+ return this.props.onError;
866
+ }
867
+ }, {
868
+ key: "errorContainer",
869
+ get: function get() {
870
+ return this.props.errorContainer;
871
+ }
872
+ }, {
873
+ key: "onErrorContainer",
874
+ get: function get() {
875
+ return this.props.onErrorContainer;
876
+ }
877
+ }, {
878
+ key: "background",
879
+ get: function get() {
880
+ return this.props.background;
881
+ }
882
+ }, {
883
+ key: "onBackground",
884
+ get: function get() {
885
+ return this.props.onBackground;
886
+ }
887
+ }, {
888
+ key: "surface",
889
+ get: function get() {
890
+ return this.props.surface;
891
+ }
892
+ }, {
893
+ key: "onSurface",
894
+ get: function get() {
895
+ return this.props.onSurface;
896
+ }
897
+ }, {
898
+ key: "surfaceVariant",
899
+ get: function get() {
900
+ return this.props.surfaceVariant;
901
+ }
902
+ }, {
903
+ key: "onSurfaceVariant",
904
+ get: function get() {
905
+ return this.props.onSurfaceVariant;
906
+ }
907
+ }, {
908
+ key: "outline",
909
+ get: function get() {
910
+ return this.props.outline;
911
+ }
912
+ }, {
913
+ key: "outlineVariant",
914
+ get: function get() {
915
+ return this.props.outlineVariant;
916
+ }
917
+ }, {
918
+ key: "shadow",
919
+ get: function get() {
920
+ return this.props.shadow;
921
+ }
922
+ }, {
923
+ key: "scrim",
924
+ get: function get() {
925
+ return this.props.scrim;
926
+ }
927
+ }, {
928
+ key: "inverseSurface",
929
+ get: function get() {
930
+ return this.props.inverseSurface;
931
+ }
932
+ }, {
933
+ key: "inverseOnSurface",
934
+ get: function get() {
935
+ return this.props.inverseOnSurface;
936
+ }
937
+ }, {
938
+ key: "inversePrimary",
939
+ get: function get() {
940
+ return this.props.inversePrimary;
941
+ }
942
+ }]);
943
+ return Scheme;
944
+ }();
945
+ function hexFromArgb(argb) {
946
+ var r = redFromArgb(argb),
947
+ g = greenFromArgb(argb),
948
+ b = blueFromArgb(argb),
949
+ outParts = [r.toString(16), g.toString(16), b.toString(16)];
950
+ for (var _iterator = _createForOfIteratorHelperLoose(outParts.entries()), _step; !(_step = _iterator()).done;) {
951
+ var _step$value = _step.value,
952
+ i = _step$value[0],
953
+ part = _step$value[1];
954
+ 1 === part.length && (outParts[i] = "0" + part);
955
+ }
956
+ return "#" + outParts.join("");
957
+ }
958
+ function argbFromHex(hex) {
959
+ var isThree = 3 === (hex = hex.replace("#", "")).length,
960
+ isSix = 6 === hex.length,
961
+ isEight = 8 === hex.length;
962
+ if (!isThree && !isSix && !isEight) throw new Error("unexpected hex " + hex);
963
+ var r = 0,
964
+ g = 0,
965
+ b = 0;
966
+ return isThree ? (r = parseIntHex(hex.slice(0, 1).repeat(2)), g = parseIntHex(hex.slice(1, 2).repeat(2)), b = parseIntHex(hex.slice(2, 3).repeat(2))) : isSix ? (r = parseIntHex(hex.slice(0, 2)), g = parseIntHex(hex.slice(2, 4)), b = parseIntHex(hex.slice(4, 6))) : isEight && (r = parseIntHex(hex.slice(2, 4)), g = parseIntHex(hex.slice(4, 6)), b = parseIntHex(hex.slice(6, 8))), (255 << 24 | (255 & r) << 16 | (255 & g) << 8 | 255 & b) >>> 0;
967
+ }
968
+ function parseIntHex(value) {
969
+ return parseInt(value, 16);
970
+ }
971
+ function themeFromSourceColor(source, customColors) {
972
+ if (customColors === void 0) {
973
+ customColors = [];
974
+ }
975
+ var palette = CorePalette.of(source);
976
+ return {
977
+ source: source,
978
+ schemes: {
979
+ light: Scheme.light(source),
980
+ dark: Scheme.dark(source)
981
+ },
982
+ palettes: {
983
+ primary: palette.a1,
984
+ secondary: palette.a2,
985
+ tertiary: palette.a3,
986
+ neutral: palette.n1,
987
+ neutralVariant: palette.n2,
988
+ error: palette.error
989
+ },
990
+ customColors: customColors.map(function (c) {
991
+ return customColor(source, c);
992
+ })
993
+ };
994
+ }
995
+ function customColor(source, color) {
996
+ var value = color.value;
997
+ var from = value,
998
+ to = source;
999
+ color.blend && (value = Blend.harmonize(from, to));
1000
+ var tones = CorePalette.of(value).a1;
1001
+ return {
1002
+ color: color,
1003
+ value: value,
1004
+ light: {
1005
+ color: tones.tone(40),
1006
+ onColor: tones.tone(100),
1007
+ colorContainer: tones.tone(90),
1008
+ onColorContainer: tones.tone(10)
1009
+ },
1010
+ dark: {
1011
+ color: tones.tone(80),
1012
+ onColor: tones.tone(20),
1013
+ colorContainer: tones.tone(30),
1014
+ onColorContainer: tones.tone(90)
1015
+ }
1016
+ };
1017
+ }
1018
+
1019
+ function toRGBA(d) {
1020
+ var r = Math.round;
1021
+ var l = d.length;
1022
+ var rgba = {};
1023
+ if (d.slice(0, 3).toLowerCase() === 'rgb') {
1024
+ d = d.replace(' ', '').split(',');
1025
+ rgba[0] = parseInt(d[0].slice(d[3].toLowerCase() === 'a' ? 5 : 4), 10);
1026
+ rgba[1] = parseInt(d[1], 10);
1027
+ rgba[2] = parseInt(d[2], 10);
1028
+ rgba[3] = d[3] ? parseFloat(d[3]) : -1;
1029
+ } else {
1030
+ if (l < 6) d = parseInt(String(d[1]) + d[1] + d[2] + d[2] + d[3] + d[3] + (l > 4 ? String(d[4]) + d[4] : ''), 16);else d = parseInt(d.slice(1), 16);
1031
+ rgba[0] = d >> 16 & 255;
1032
+ rgba[1] = d >> 8 & 255;
1033
+ rgba[2] = d & 255;
1034
+ rgba[3] = l === 9 || l === 5 ? r((d >> 24 & 255) / 255 * 10000) / 10000 : -1;
1035
+ }
1036
+ return rgba;
1037
+ }
1038
+ function blend(from, to, p) {
1039
+ if (p === void 0) {
1040
+ p = 0.5;
1041
+ }
1042
+ var r = Math.round;
1043
+ from = from.trim();
1044
+ to = to.trim();
1045
+ var b = p < 0;
1046
+ p = b ? p * -1 : p;
1047
+ var f = toRGBA(from);
1048
+ var t = toRGBA(to);
1049
+ if (to[0] === 'r') {
1050
+ return 'rgb' + (to[3] === 'a' ? 'a(' : '(') + r((t[0] - f[0]) * p + f[0]) + ',' + r((t[1] - f[1]) * p + f[1]) + ',' + r((t[2] - f[2]) * p + f[2]) + (f[3] < 0 && t[3] < 0 ? '' : ',' + (f[3] > -1 && t[3] > -1 ? r(((t[3] - f[3]) * p + f[3]) * 10000) / 10000 : t[3] < 0 ? f[3] : t[3])) + ')';
1051
+ }
1052
+ return '#' + (0x100000000 + (f[3] > -1 && t[3] > -1 ? r(((t[3] - f[3]) * p + f[3]) * 255) : t[3] > -1 ? r(t[3] * 255) : f[3] > -1 ? r(f[3] * 255) : 255) * 0x1000000 + r((t[0] - f[0]) * p + f[0]) * 0x10000 + r((t[1] - f[1]) * p + f[1]) * 0x100 + r((t[2] - f[2]) * p + f[2])).toString(16).slice(f[3] > -1 || t[3] > -1 ? 1 : 3);
1053
+ }
1054
+ var materialColors = function materialColors(hexColor) {
1055
+ if (hexColor === void 0) {
1056
+ hexColor = '';
1057
+ }
1058
+ var theme = themeFromSourceColor(argbFromHex("#" + hexColor.replace('#', '')));
1059
+ [0.05, 0.08, 0.11, 0.12, 0.14].forEach(function (amount, index) {
1060
+ theme.schemes.light.props["surface" + (index + 1)] = argbFromHex(blend(hexFromArgb(theme.schemes.light.props.surface), hexFromArgb(theme.schemes.light.props.primary), amount));
1061
+ theme.schemes.dark.props["surface" + (index + 1)] = argbFromHex(blend(hexFromArgb(theme.schemes.dark.props.surface), hexFromArgb(theme.schemes.dark.props.primary), amount));
1062
+ });
1063
+ var name = function name(n) {
1064
+ return n.split('').map(function (_char) {
1065
+ return _char.toUpperCase() === _char && _char !== '-' && _char !== '7' ? "-" + _char.toLowerCase() : _char;
1066
+ }).join('');
1067
+ };
1068
+ var shouldSkip = function shouldSkip(prop) {
1069
+ var skip = ['tertiary', 'shadow', 'scrim', 'error', 'background'];
1070
+ return skip.filter(function (v) {
1071
+ return prop.toLowerCase().includes(v);
1072
+ }).length > 0;
1073
+ };
1074
+ var light = {};
1075
+ var dark = {};
1076
+ Object.keys(theme.schemes.light.props).forEach(function (prop) {
1077
+ if (shouldSkip(prop)) return;
1078
+ light[name("--f7-md-" + prop)] = hexFromArgb(theme.schemes.light.props[prop]);
1079
+ });
1080
+ Object.keys(theme.schemes.dark.props).forEach(function (prop) {
1081
+ if (shouldSkip(prop)) return;
1082
+ dark[name("--f7-md-" + prop)] = hexFromArgb(theme.schemes.dark.props[prop]);
1083
+ });
1084
+ return {
1085
+ light: light,
1086
+ dark: dark
1087
+ };
1088
+ };
1089
+
126
1090
  var _uniqueNumber = 1;
127
1091
  var Utils = {
128
1092
  uniqueNumber: function uniqueNumber() {
@@ -142,7 +1106,7 @@
142
1106
  iosPreloaderContent: ("\n\t\t<span class=\"preloader-inner\">\n\t\t\t" + [0, 1, 2, 3, 4, 5, 6, 7].map(function () {
143
1107
  return '<span class="preloader-inner-line"></span>';
144
1108
  }).join('') + "\n\t\t</span>\n ").trim(),
145
- auroraPreloaderContent: "\n <span class=\"preloader-inner\">\n <span class=\"preloader-inner-circle\"></span>\n </span>\n",
1109
+ pcPreloaderContent: "\n <span class=\"preloader-inner\">\n <span class=\"preloader-inner-circle\"></span>\n </span>\n",
146
1110
  eventNameToColonCase: function eventNameToColonCase(eventName) {
147
1111
  var hasColon;
148
1112
  return eventName.split('').map(function (_char, index) {
@@ -156,11 +1120,17 @@
156
1120
  deleteProps: function deleteProps(obj) {
157
1121
  $.deleteProps(obj);
158
1122
  },
159
- nextTick: function nextTick(callback, delay) {
1123
+ requestAnimationFrame: function requestAnimationFrame(cb) {
1124
+ return $.requestAnimationFrame(cb);
1125
+ },
1126
+ cancelAnimationFrame: function cancelAnimationFrame(id) {
1127
+ return $.cancelAnimationFrame(id);
1128
+ },
1129
+ nextTick: function nextTick(cb, delay) {
160
1130
  if (delay === void 0) {
161
1131
  delay = 0;
162
1132
  }
163
- return setTimeout(callback, delay);
1133
+ return $.nextTick(cb, delay);
164
1134
  },
165
1135
  nextFrame: function nextFrame(cb) {
166
1136
  return $.nextFrame(cb);
@@ -168,12 +1138,6 @@
168
1138
  now: function now() {
169
1139
  return Date.now();
170
1140
  },
171
- requestAnimationFrame: function requestAnimationFrame(cb) {
172
- return $.requestAnimationFrame(cb);
173
- },
174
- cancelAnimationFrame: function cancelAnimationFrame(id) {
175
- return $.cancelAnimationFrame(id);
176
- },
177
1141
  parseUrlQuery: function parseUrlQuery(url) {
178
1142
  return $.urlParam(url);
179
1143
  },
@@ -249,9 +1213,8 @@
249
1213
  return (_$2 = $).assign.apply(_$2, [to].concat(args));
250
1214
  },
251
1215
  bindMethods: function bindMethods(instance, obj) {
252
- var _this = this;
253
1216
  Object.keys(obj).forEach(function (key) {
254
- if (_this.isObject(obj[key])) {
1217
+ if (Utils.isObject(obj[key])) {
255
1218
  Object.keys(obj[key]).forEach(function (subKey) {
256
1219
  if (typeof obj[key][subKey] === 'function') {
257
1220
  obj[key][subKey] = obj[key][subKey].bind(instance);
@@ -261,6 +1224,24 @@
261
1224
  instance[key] = obj[key];
262
1225
  });
263
1226
  },
1227
+ flattenArray: function (_flattenArray) {
1228
+ function flattenArray() {
1229
+ return _flattenArray.apply(this, arguments);
1230
+ }
1231
+ flattenArray.toString = function () {
1232
+ return _flattenArray.toString();
1233
+ };
1234
+ return flattenArray;
1235
+ }(function () {
1236
+ var arr = [];
1237
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1238
+ args[_key2] = arguments[_key2];
1239
+ }
1240
+ args.forEach(function (arg) {
1241
+ if (Array.isArray(arg)) arr.push.apply(arr, flattenArray.apply(void 0, arg));else arr.push(arg);
1242
+ });
1243
+ return arr;
1244
+ }),
264
1245
  colorHexToRgb: function colorHexToRgb(hex) {
265
1246
  var h = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
266
1247
  return r + r + g + g + b + b;
@@ -335,11 +1316,22 @@
335
1316
  HSB.s = HSL.l > 0 ? 2 * t / HSB.b : HSB.s;
336
1317
  return [HSB.h, HSB.s, HSB.b];
337
1318
  },
1319
+ getShadeTintColors: function getShadeTintColors(rgb) {
1320
+ var hsl = colorRgbToHsl.apply(void 0, rgb);
1321
+ var hslShade = [hsl[0], hsl[1], Math.max(0, hsl[2] - 0.08)];
1322
+ var hslTint = [hsl[0], hsl[1], Math.max(0, hsl[2] + 0.08)];
1323
+ var shade = colorRgbToHex.apply(void 0, colorHslToRgb.apply(void 0, hslShade));
1324
+ var tint = colorRgbToHex.apply(void 0, colorHslToRgb.apply(void 0, hslTint));
1325
+ return {
1326
+ shade: shade,
1327
+ tint: tint
1328
+ };
1329
+ },
338
1330
  colorThemeCSSProperties: function colorThemeCSSProperties() {
339
1331
  var hex;
340
1332
  var rgb;
341
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
342
- args[_key2] = arguments[_key2];
1333
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1334
+ args[_key3] = arguments[_key3];
343
1335
  }
344
1336
  if (args.length === 1) {
345
1337
  hex = args[0];
@@ -349,17 +1341,85 @@
349
1341
  hex = Utils.colorRgbToHex.apply(Utils, rgb);
350
1342
  }
351
1343
  if (!rgb) return {};
352
- var hsl = Utils.colorRgbToHsl.apply(Utils, rgb);
353
- var hslShade = [hsl[0], hsl[1], Math.max(0, hsl[2] - 0.08)];
354
- var hslTint = [hsl[0], hsl[1], Math.max(0, hsl[2] + 0.08)];
355
- var shade = Utils.colorRgbToHex.apply(Utils, Utils.colorHslToRgb.apply(Utils, hslShade));
356
- var tint = Utils.colorRgbToHex.apply(Utils, Utils.colorHslToRgb.apply(Utils, hslTint));
1344
+ var _materialColors = materialColors(hex),
1345
+ light = _materialColors.light,
1346
+ dark = _materialColors.dark;
1347
+ var shadeTintIos = getShadeTintColors(rgb);
1348
+ var shadeTintMdLight = getShadeTintColors(colorHexToRgb(light['--f7-md-primary']));
1349
+ var shadeTintMdDark = getShadeTintColors(colorHexToRgb(dark['--f7-md-primary']));
1350
+ Object.keys(light).forEach(function (key) {
1351
+ if (key.includes('surface-')) {
1352
+ light[key + "-rgb"] = colorHexToRgb(light[key]);
1353
+ }
1354
+ });
1355
+ Object.keys(dark).forEach(function (key) {
1356
+ if (key.includes('surface-')) {
1357
+ dark[key + "-rgb"] = colorHexToRgb(dark[key]);
1358
+ }
1359
+ });
357
1360
  return {
358
- '--f7-theme-color': hex,
359
- '--f7-theme-color-rgb': rgb.join(', '),
360
- '--f7-theme-color-shade': shade,
361
- '--f7-theme-color-tint': tint
1361
+ ios: {
1362
+ '--f7-theme-color': 'var(--f7-ios-primary)',
1363
+ '--f7-theme-color-rgb': 'var(--f7-ios-primary-rgb)',
1364
+ '--f7-theme-color-shade': 'var(--f7-ios-primary-shade)',
1365
+ '--f7-theme-color-tint': 'var(--f7-ios-primary-tint)'
1366
+ },
1367
+ md: {
1368
+ '--f7-theme-color': 'var(--f7-md-primary)',
1369
+ '--f7-theme-color-rgb': 'var(--f7-md-primary-rgb)',
1370
+ '--f7-theme-color-shade': 'var(--f7-md-primary-shade)',
1371
+ '--f7-theme-color-tint': 'var(--f7-md-primary-tint)'
1372
+ },
1373
+ light: _extends({
1374
+ '--f7-ios-primary': hex,
1375
+ '--f7-ios-primary-shade': shadeTintIos.shade,
1376
+ '--f7-ios-primary-tint': shadeTintIos.tint,
1377
+ '--f7-ios-primary-rgb': rgb.join(', '),
1378
+ '--f7-md-primary-shade': shadeTintMdLight.shade,
1379
+ '--f7-md-primary-tint': shadeTintMdLight.tint,
1380
+ '--f7-md-primary-rgb': colorHexToRgb(light['--f7-md-primary']).join(', ')
1381
+ }, light),
1382
+ dark: _extends({
1383
+ '--f7-md-primary-shade': shadeTintMdDark.shade,
1384
+ '--f7-md-primary-tint': shadeTintMdDark.tint,
1385
+ '--f7-md-primary-rgb': colorHexToRgb(dark['--f7-md-primary']).join(', ')
1386
+ }, dark)
1387
+ };
1388
+ },
1389
+ colorThemeCSSStyles: function colorThemeCSSStyles(colors) {
1390
+ if (colors === void 0) {
1391
+ colors = {};
1392
+ }
1393
+ var stringifyObject = function stringifyObject(obj) {
1394
+ var res = '';
1395
+ Object.keys(obj).forEach(function (key) {
1396
+ res += key + ":" + obj[key] + ";";
1397
+ });
1398
+ return res;
362
1399
  };
1400
+ var colorVars = colorThemeCSSProperties(colors.primary);
1401
+ var primary = [":root{", stringifyObject(colorVars.light), "--swiper-theme-color:var(--f7-theme-color);"].concat(Object.keys(colors).map(function (colorName) {
1402
+ return "--f7-color-" + colorName + ": " + colors[colorName] + ";";
1403
+ }), ["}", ".dark{", stringifyObject(colorVars.dark), "}", ".ios, .ios .dark{", stringifyObject(colorVars.ios), '}', ".md, .md .dark{", stringifyObject(colorVars.md), '}']).join('');
1404
+ var restVars = {};
1405
+ Object.keys(colors).forEach(function (colorName) {
1406
+ var colorValue = colors[colorName];
1407
+ restVars[colorName] = colorThemeCSSProperties(colorValue);
1408
+ });
1409
+ var rest = '';
1410
+ Object.keys(colors).forEach(function (colorName) {
1411
+ var _restVars$colorName = restVars[colorName],
1412
+ light = _restVars$colorName.light,
1413
+ dark = _restVars$colorName.dark,
1414
+ ios = _restVars$colorName.ios,
1415
+ md = _restVars$colorName.md;
1416
+ var whiteColorVars = "\n\t\t\t--f7-ios-primary: #ffffff;\n\t\t\t--f7-ios-primary-shade: #ebebeb;\n\t\t\t--f7-ios-primary-tint: #ffffff;\n\t\t\t--f7-ios-primary-rgb: 255, 255, 255;\n\t\t\t--f7-md-primary-shade: #eee;\n\t\t\t--f7-md-primary-tint: #fff;\n\t\t\t--f7-md-primary-rgb: 255, 255, 255;\n\t\t\t--f7-md-primary: #fff;\n\t\t\t--f7-md-on-primary: #000;\n\t\t\t--f7-md-primary-container: #fff;\n\t\t\t--f7-md-on-primary-container: #000;\n\t\t\t--f7-md-secondary: #fff;\n\t\t\t--f7-md-on-secondary: #000;\n\t\t\t--f7-md-secondary-container: #555;\n\t\t\t--f7-md-on-secondary-container: #fff;\n\t\t\t--f7-md-surface: #fff;\n\t\t\t--f7-md-on-surface: #000;\n\t\t\t--f7-md-surface-variant: #333;\n\t\t\t--f7-md-on-surface-variant: #fff;\n\t\t\t--f7-md-outline: #fff;\n\t\t\t--f7-md-outline-variant: #fff;\n\t\t\t--f7-md-inverse-surface: #000;\n\t\t\t--f7-md-inverse-on-surface: #fff;\n\t\t\t--f7-md-inverse-primary: #000;\n\t\t\t--f7-md-surface-1: #f8f8f8;\n\t\t\t--f7-md-surface-2: #f1f1f1;\n\t\t\t--f7-md-surface-3: #e7e7e7;\n\t\t\t--f7-md-surface-4: #e1e1e1;\n\t\t\t--f7-md-surface-5: #d7d7d7;\n\t\t\t--f7-md-surface-variant-rgb: 51, 51, 51;\n\t\t\t--f7-md-on-surface-variant-rgb: 255, 255, 255;\n\t\t\t--f7-md-surface-1-rgb: 248, 248, 248;\n\t\t\t--f7-md-surface-2-rgb: 241, 241, 241;\n\t\t\t--f7-md-surface-3-rgb: 231, 231, 231;\n\t\t\t--f7-md-surface-4-rgb: 225, 225, 225;\n\t\t\t--f7-md-surface-5-rgb: 215, 215, 215;\n\t\t\t";
1417
+ var blackColorVars = "\n\t\t\t--f7-ios-primary: #000;\n\t\t\t--f7-ios-primary-shade: #000;\n\t\t\t--f7-ios-primary-tint: #232323;\n\t\t\t--f7-ios-primary-rgb: 0, 0, 0;\n\t\t\t--f7-md-primary-shade: #000;\n\t\t\t--f7-md-primary-tint: #232323;\n\t\t\t--f7-md-primary-rgb: 0, 0, 0;\n\t\t\t--f7-md-primary: #000;\n\t\t\t--f7-md-on-primary: #fff;\n\t\t\t--f7-md-primary-container: #000;\n\t\t\t--f7-md-on-primary-container: #fff;\n\t\t\t--f7-md-secondary: #000;\n\t\t\t--f7-md-on-secondary: #fff;\n\t\t\t--f7-md-secondary-container: #aaa;\n\t\t\t--f7-md-on-secondary-container: #000;\n\t\t\t--f7-md-surface: #000;\n\t\t\t--f7-md-on-surface: #fff;\n\t\t\t--f7-md-surface-variant: #ccc;\n\t\t\t--f7-md-on-surface-variant: #000;\n\t\t\t--f7-md-outline: #000;\n\t\t\t--f7-md-outline-variant: #000;\n\t\t\t--f7-md-inverse-surface: #fff;\n\t\t\t--f7-md-inverse-on-surface: #000;\n\t\t\t--f7-md-inverse-primary: #fff;\n\t\t\t--f7-md-surface-1: #070707;\n\t\t\t--f7-md-surface-2: #161616;\n\t\t\t--f7-md-surface-3: #232323;\n\t\t\t--f7-md-surface-4: #303030;\n\t\t\t--f7-md-surface-5: #373737;\n\t\t\t--f7-md-surface-variant-rgb: 204, 204, 204;\n\t\t\t--f7-md-on-surface-variant-rgb: 0, 0, 0;\n\t\t\t--f7-md-surface-1-rgb: 7, 7, 7;\n\t\t\t--f7-md-surface-2-rgb: 22, 22, 22;\n\t\t\t--f7-md-surface-3-rgb: 35, 35, 35;\n\t\t\t--f7-md-surface-4-rgb: 48, 48, 48;\n\t\t\t--f7-md-surface-5-rgb: 55, 55, 55;\n\t\t\t";
1418
+ var lightString = colorName === 'white' ? whiteColorVars : colorName === 'black' ? blackColorVars : stringifyObject(light);
1419
+ var darkString = colorName === 'white' ? whiteColorVars : colorName === 'black' ? blackColorVars : stringifyObject(dark);
1420
+ rest += [".color-" + colorName + " {", lightString, "--swiper-theme-color: var(--f7-theme-color);", "}", ".color-" + colorName + ".dark, .color-" + colorName + " .dark, .dark .color-" + colorName + " {", darkString, "--swiper-theme-color: var(--f7-theme-color);", "}", ".ios .color-" + colorName + ", .ios.color-" + colorName + ", .ios .dark .color-" + colorName + ", .ios .dark.color-" + colorName + " {", stringifyObject(ios), "}", ".md .color-" + colorName + ", .md.color-" + colorName + ", .md .dark .color-" + colorName + ", .md .dark.color-" + colorName + " {", stringifyObject(md), "}", ".text-color-" + colorName + " {", "--f7-theme-color-text-color: " + colors[colorName] + ";", "}", ".bg-color-" + colorName + " {", "--f7-theme-color-bg-color: " + colors[colorName] + ";", "}", ".border-color-" + colorName + " {", "--f7-theme-color-border-color: " + colors[colorName] + ";", "}", ".ripple-color-" + colorName + " {", "--f7-theme-color-ripple-color: rgba(" + light['--f7-ios-primary-rgb'] + ", 0.3);", "}"].join('');
1421
+ });
1422
+ return "" + primary + rest;
363
1423
  }
364
1424
  };
365
1425
 
@@ -603,13 +1663,17 @@
603
1663
  var Module = function (_Event) {
604
1664
  _inheritsLoose(Module, _Event);
605
1665
  function Module(params, parents) {
1666
+ var _this;
606
1667
  if (params === void 0) {
607
1668
  params = {};
608
1669
  }
609
1670
  if (parents === void 0) {
610
1671
  parents = [];
611
1672
  }
612
- return _Event.call(this, params, parents) || this;
1673
+ _this = _Event.call(this, params, parents) || this;
1674
+ var self = _assertThisInitialized(_this);
1675
+ self.params = params;
1676
+ return _this;
613
1677
  }
614
1678
  var _proto = Module.prototype;
615
1679
  _proto.useModuleParams = function useModuleParams(module, instanceParams) {
@@ -762,7 +1826,7 @@
762
1826
  return _construct.apply(null, arguments);
763
1827
  }
764
1828
 
765
- function Constructors (parameters) {
1829
+ function Constructors(parameters) {
766
1830
  if (parameters === void 0) {
767
1831
  parameters = {};
768
1832
  }
@@ -813,38 +1877,73 @@
813
1877
  return methods;
814
1878
  }
815
1879
 
816
- function Modals (parameters) {
1880
+ function Modals(parameters) {
817
1881
  if (parameters === void 0) {
818
1882
  parameters = {};
819
1883
  }
820
1884
  var _parameters = parameters,
821
1885
  defaultSelector = _parameters.defaultSelector,
822
- constructor = _parameters.constructor,
1886
+ Constructor = _parameters.constructor,
823
1887
  app = _parameters.app;
824
1888
  var methods = $.extend(Constructors({
825
1889
  defaultSelector: defaultSelector,
826
- constructor: constructor,
1890
+ constructor: Constructor,
827
1891
  app: app,
828
1892
  domProp: 'f7Modal'
829
1893
  }), {
830
- open: function open(el, animate) {
1894
+ open: function open(el, animate, targetEl) {
831
1895
  var $el = $(el);
1896
+ if ($el.length > 1 && targetEl) {
1897
+ var $targetPage = $(targetEl).parents('.page');
1898
+ if ($targetPage.length) {
1899
+ $el.each(function (modalEl) {
1900
+ var $modalEl = $(modalEl);
1901
+ if ($modalEl.parents($targetPage)[0] === $targetPage[0]) {
1902
+ $el = $modalEl;
1903
+ }
1904
+ });
1905
+ }
1906
+ }
1907
+ if ($el.length > 1) {
1908
+ $el = $el.eq($el.length - 1);
1909
+ }
1910
+ if (!$el.length) return undefined;
832
1911
  var instance = $el[0].f7Modal;
833
- if (!instance) instance = new constructor(app, {
834
- el: $el
835
- });
1912
+ if (!instance) {
1913
+ var params = $el.dataset();
1914
+ instance = new Constructor(app, _extends({
1915
+ el: $el
1916
+ }, params));
1917
+ }
836
1918
  return instance.open(animate);
837
1919
  },
838
- close: function close(el, animate) {
1920
+ close: function close(el, animate, targetEl) {
839
1921
  if (el === void 0) {
840
1922
  el = defaultSelector;
841
1923
  }
842
1924
  var $el = $(el);
843
- if ($el.length === 0) return undefined;
1925
+ if (!$el.length) return undefined;
1926
+ if ($el.length > 1) {
1927
+ var $parentEl;
1928
+ if (targetEl) {
1929
+ var $targetEl = $(targetEl);
1930
+ if ($targetEl.length) {
1931
+ $parentEl = $targetEl.parents($el);
1932
+ }
1933
+ }
1934
+ if ($parentEl && $parentEl.length > 0) {
1935
+ $el = $parentEl;
1936
+ } else {
1937
+ $el = $el.eq($el.length - 1);
1938
+ }
1939
+ }
844
1940
  var instance = $el[0].f7Modal;
845
- if (!instance) instance = new constructor(app, {
846
- el: $el
847
- });
1941
+ if (!instance) {
1942
+ var params = $el.dataset();
1943
+ instance = new Constructor(app, _extends({
1944
+ el: $el
1945
+ }, params));
1946
+ }
848
1947
  return instance.close(animate);
849
1948
  }
850
1949
  });
@@ -962,6 +2061,32 @@
962
2061
  });
963
2062
  }
964
2063
 
2064
+ function jsx(tag, props) {
2065
+ var attrs = props || {};
2066
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2067
+ args[_key - 2] = arguments[_key];
2068
+ }
2069
+ var children = args || [];
2070
+ var attrsString = Object.keys(attrs).map(function (attr) {
2071
+ if (attr[0] === '_') {
2072
+ if (attrs[attr]) return attr.replace('_', '');
2073
+ return '';
2074
+ }
2075
+ return attr + "=\"" + attrs[attr] + "\"";
2076
+ }).filter(function (attr) {
2077
+ return !!attr;
2078
+ }).join(' ');
2079
+ if (['path', 'img', 'circle', 'polygon', 'line', 'input'].indexOf(tag) >= 0) {
2080
+ return ("<" + tag + " " + attrsString + " />").trim();
2081
+ }
2082
+ var childrenContent = children.filter(function (c) {
2083
+ return !!c;
2084
+ }).map(function (c) {
2085
+ return Array.isArray(c) ? c.join('') : c;
2086
+ }).join('');
2087
+ return ("<" + tag + " " + attrsString + ">" + childrenContent + "</" + tag + ">").trim();
2088
+ }
2089
+
965
2090
  var Resize = {
966
2091
  name: 'resize',
967
2092
  instance: {
@@ -1151,6 +2276,7 @@
1151
2276
  init: function init() {
1152
2277
  if (!('serviceWorker' in window.navigator)) return;
1153
2278
  var app = this;
2279
+ if (app.device.cordova || window.Capacitor && window.Capacitor.isNative) return;
1154
2280
  if (!app.serviceWorker.container) return;
1155
2281
  var paths = app.params.serviceWorker.path;
1156
2282
  var scope = app.params.serviceWorker.scope;
@@ -1163,99 +2289,110 @@
1163
2289
  }
1164
2290
  };
1165
2291
 
1166
- var Support$1 = $.support;
1167
- var Device$1 = $.device;
2292
+ var extend = Utils.extend,
2293
+ nextFrame = Utils.nextFrame;
2294
+ var _$ = $,
2295
+ support = _$.Support,
2296
+ device = _$.Device;
2297
+ var def = {
2298
+ version: '1.0.1',
2299
+ el: 'body',
2300
+ root: 'body',
2301
+ theme: 'auto',
2302
+ language: window.navigator.language,
2303
+ routes: [],
2304
+ name: 'App',
2305
+ lazyModulesPath: null,
2306
+ initOnDeviceReady: true,
2307
+ darkMode: undefined,
2308
+ iosTranslucentBars: true,
2309
+ iosTranslucentModals: true,
2310
+ component: undefined,
2311
+ componentUrl: undefined,
2312
+ userAgent: null,
2313
+ url: null,
2314
+ colors: {
2315
+ primary: '#007aff',
2316
+ red: '#ff3b30',
2317
+ green: '#4cd964',
2318
+ blue: '#2196f3',
2319
+ pink: '#ff2d55',
2320
+ yellow: '#ffcc00',
2321
+ orange: '#ff9500',
2322
+ purple: '#9c27b0',
2323
+ deeppurple: '#673ab7',
2324
+ lightblue: '#5ac8fa',
2325
+ teal: '#009688',
2326
+ lime: '#cddc39',
2327
+ deeporange: '#ff6b22',
2328
+ white: '#ffffff',
2329
+ black: '#000000'
2330
+ }
2331
+ };
1168
2332
  var App = function (_Module) {
1169
2333
  _inheritsLoose(App, _Module);
1170
- function App(opt) {
2334
+ function App(opts) {
1171
2335
  var _this;
1172
- _this = _Module.call(this, opt) || this;
1173
- var passedParams = $.extend({}, opt);
2336
+ if (opts === void 0) {
2337
+ opts = {};
2338
+ }
2339
+ _this = _Module.call(this, opts) || this;
2340
+ if (App.instance && typeof window !== 'undefined') {
2341
+ throw new Error("App is already initialized and can't be initialized more than once");
2342
+ }
2343
+ var passedParams = extend({}, opts);
1174
2344
  var app = _assertThisInitialized(_this);
1175
- app.device = Device$1;
1176
- app.support = Support$1;
2345
+ $.App = App;
2346
+ App.instance = app;
2347
+ app.device = device;
2348
+ app.support = support;
1177
2349
  console.log('App constructor', {
1178
- Device: Device$1,
1179
- Support: Support$1
2350
+ Device: device,
2351
+ Support: support
1180
2352
  });
1181
- var def = {
1182
- version: '0.0.1',
1183
- root: 'body',
1184
- theme: 'auto',
1185
- language: window.navigator.language,
1186
- routes: [],
1187
- lazyModulesPath: null,
1188
- initOnDeviceReady: true,
1189
- autoDarkTheme: false,
1190
- iosTranslucentBars: true,
1191
- iosTranslucentModals: true,
1192
- component: undefined,
1193
- componentUrl: undefined
1194
- };
1195
2353
  app.useModulesParams(def);
1196
- app.params = $.extend(def, opt);
1197
- var $rootEl = $(app.params.root);
2354
+ app.params = extend(def, opts);
2355
+ if (opts.root && !opts.el) {
2356
+ app.params.el = opts.root;
2357
+ }
1198
2358
  $.isPage = function (p) {
1199
2359
  return p instanceof Page;
1200
2360
  };
1201
2361
  $.isApp = function (p) {
1202
2362
  return p instanceof App;
1203
2363
  };
1204
- $.extend(app, {
2364
+ extend(app, {
1205
2365
  owner: app.params.owner,
1206
2366
  name: app.params.name,
1207
2367
  id: app.params.owner + "." + app.params.name,
1208
2368
  version: app.params.version,
1209
2369
  routes: app.params.routes,
1210
2370
  language: app.params.language,
1211
- root: $rootEl,
1212
- $el: $rootEl,
1213
2371
  cfg: app.params.cfg,
1214
2372
  api: app.params.api,
1215
- rtl: $rootEl.css('direction') === 'rtl',
1216
- theme: function getTheme() {
2373
+ theme: function () {
1217
2374
  if (app.params.theme === 'auto') {
1218
- if (Device$1.ios) return 'ios';
1219
- if (Device$1.desktop) return 'aurora';
2375
+ if (device.ios) return 'ios';
2376
+ if (device.desktop) return 'pc';
1220
2377
  return 'md';
1221
2378
  }
1222
2379
  return app.params.theme;
1223
2380
  }(),
1224
2381
  passedParams: passedParams,
1225
- online: window.navigator.onLine
2382
+ online: window.navigator.onLine,
2383
+ colors: app.params.colors,
2384
+ darkMode: app.params.darkMode
1226
2385
  });
1227
- if (app.root && app.root[0]) {
1228
- app.root[0].wia = app;
1229
- }
2386
+ if (opts.store) app.params.store = params.store;
1230
2387
  app.touchEvents = {
1231
- start: Support$1.touch ? 'touchstart' : Support$1.pointerEvents ? 'pointerdown' : 'mousedown',
1232
- move: Support$1.touch ? 'touchmove' : Support$1.pointerEvents ? 'pointermove' : 'mousemove',
1233
- end: Support$1.touch ? 'touchend' : Support$1.pointerEvents ? 'pointerup' : 'mouseup'
2388
+ start: support.touch ? 'touchstart' : support.pointerEvents ? 'pointerdown' : 'mousedown',
2389
+ move: support.touch ? 'touchmove' : support.pointerEvents ? 'pointermove' : 'mousemove',
2390
+ end: support.touch ? 'touchend' : support.pointerEvents ? 'pointerup' : 'mouseup'
1234
2391
  };
1235
2392
  app.useModules();
1236
2393
  app.initData();
1237
- var DARK = '(prefers-color-scheme: dark)';
1238
- var LIGHT = '(prefers-color-scheme: light)';
1239
- app.mq = {};
1240
- if (window.matchMedia) {
1241
- app.mq.dark = window.matchMedia(DARK);
1242
- app.mq.light = window.matchMedia(LIGHT);
1243
- }
1244
- app.colorSchemeListener = function (_ref) {
1245
- var matches = _ref.matches,
1246
- media = _ref.media;
1247
- if (!matches) {
1248
- return;
1249
- }
1250
- var html = document.querySelector('html');
1251
- if (media === DARK) {
1252
- html.classList.add('theme-dark');
1253
- } else if (media === LIGHT) {
1254
- html.classList.remove('theme-dark');
1255
- }
1256
- };
1257
- function init() {
1258
- if (Device$1.cordova && app.params.initOnDeviceReady) {
2394
+ if (app.params.init) {
2395
+ if (device.cordova && app.params.initOnDeviceReady) {
1259
2396
  $(document).on('deviceready', function () {
1260
2397
  app.init();
1261
2398
  });
@@ -1263,7 +2400,6 @@
1263
2400
  app.init();
1264
2401
  }
1265
2402
  }
1266
- if (app.params.init) init();
1267
2403
  return app || _assertThisInitialized(_this);
1268
2404
  }
1269
2405
  var _proto = App.prototype;
@@ -1279,6 +2415,62 @@
1279
2415
  _proto.unload = function unload() {
1280
2416
  this.emit('local::unload appUnload');
1281
2417
  };
2418
+ _proto.setColorTheme = function setColorTheme(color) {
2419
+ if (!color) return;
2420
+ var app = this;
2421
+ app.colors.primary = color;
2422
+ app.setColors();
2423
+ };
2424
+ _proto.setColors = function setColors() {
2425
+ var app = this;
2426
+ if (!app.colorsStyleEl) {
2427
+ app.colorsStyleEl = document.createElement('style');
2428
+ document.head.appendChild(app.colorsStyleEl);
2429
+ }
2430
+ app.colorsStyleEl.textContent = app.utils.colorThemeCSSStyles(app.colors);
2431
+ };
2432
+ _proto.mount = function mount(rootEl) {
2433
+ var app = this;
2434
+ var $rootEl = $(rootEl || app.params.el).eq(0);
2435
+ extend(app, {
2436
+ root: $rootEl,
2437
+ $el: $rootEl,
2438
+ el: $rootEl == null ? void 0 : $rootEl[0],
2439
+ rtl: $rootEl.css('direction') === 'rtl'
2440
+ });
2441
+ if (app.root && app.root[0]) {
2442
+ app.root[0].wia = app;
2443
+ }
2444
+ if (app.$el && app.$el[0]) {
2445
+ app.$el[0].wia = app;
2446
+ }
2447
+ app.el.f7 = app;
2448
+ var DARK = '(prefers-color-scheme: dark)';
2449
+ var LIGHT = '(prefers-color-scheme: light)';
2450
+ app.mq = {};
2451
+ if (window.matchMedia) {
2452
+ app.mq.dark = window.matchMedia(DARK);
2453
+ app.mq.light = window.matchMedia(LIGHT);
2454
+ }
2455
+ app.colorSchemeListener = function (_ref) {
2456
+ var matches = _ref.matches,
2457
+ media = _ref.media;
2458
+ if (!matches) {
2459
+ return;
2460
+ }
2461
+ var html = document.querySelector('html');
2462
+ if (media === DARK) {
2463
+ html.classList.add('dark');
2464
+ app.darkMode = true;
2465
+ app.emit('darkModeChange', true);
2466
+ } else if (media === LIGHT) {
2467
+ html.classList.remove('dark');
2468
+ app.darkMode = false;
2469
+ app.emit('darkModeChange', false);
2470
+ }
2471
+ };
2472
+ app.emit('mount');
2473
+ };
1282
2474
  _proto.initData = function initData() {
1283
2475
  var app = this;
1284
2476
  app.data = {};
@@ -1307,9 +2499,13 @@
1307
2499
  app.mq.light.addListener(app.colorSchemeListener);
1308
2500
  }
1309
2501
  if (app.mq.dark && app.mq.dark.matches) {
1310
- html.classList.add('theme-dark');
2502
+ html.classList.add('dark');
2503
+ app.darkMode = true;
2504
+ app.emit('darkModeChange', true);
1311
2505
  } else if (app.mq.light && app.mq.light.matches) {
1312
- html.classList.remove('theme-dark');
2506
+ html.classList.remove('dark');
2507
+ app.darkMode = false;
2508
+ app.emit('darkModeChange', false);
1313
2509
  }
1314
2510
  };
1315
2511
  _proto.disableAutoDarkTheme = function disableAutoDarkTheme() {
@@ -1318,44 +2514,77 @@
1318
2514
  if (app.mq.dark) app.mq.dark.removeListener(app.colorSchemeListener);
1319
2515
  if (app.mq.light) app.mq.light.removeListener(app.colorSchemeListener);
1320
2516
  };
1321
- _proto.init = function init() {
2517
+ _proto.setDarkMode = function setDarkMode(mode) {
1322
2518
  var app = this;
1323
- if (app.initialized) return app;
1324
- $.App = App;
1325
- if (Device$1.ios && Device$1.webView) {
1326
- window.addEventListener('touchstart', function () {});
1327
- }
1328
- app.root.addClass('framework7-initializing');
1329
- if (app.rtl) {
1330
- $('html').attr('dir', 'rtl');
1331
- }
1332
- if (app.params.autoDarkTheme) {
1333
- app.enableAutoDarkTheme();
1334
- }
1335
- window.addEventListener('offline', function () {
1336
- app.online = false;
1337
- app.emit('offline');
1338
- app.emit('connection', false);
1339
- });
1340
- window.addEventListener('online', function () {
1341
- app.online = true;
1342
- app.emit('online');
1343
- app.emit('connection', true);
1344
- });
1345
- app.root.addClass('framework7-root');
1346
- $('html').removeClass('ios md aurora').addClass(app.theme);
1347
- if (app.params.iosTranslucentBars && app.theme === 'ios' && Device$1.ios) {
1348
- $('html').addClass('ios-translucent-bars');
2519
+ if (mode === 'auto') {
2520
+ app.enableAutoDarkMode();
2521
+ } else {
2522
+ app.disableAutoDarkMode();
2523
+ $('html')[mode ? 'addClass' : 'removeClass']('dark');
2524
+ app.darkMode = mode;
1349
2525
  }
1350
- if (app.params.iosTranslucentModals && app.theme === 'ios' && Device$1.ios) {
1351
- $('html').addClass('ios-translucent-modals');
2526
+ };
2527
+ _proto.initAppComponent = function initAppComponent(callback) {
2528
+ var app = this;
2529
+ app.router.componentLoader(app.params.component, app.params.componentUrl, {
2530
+ componentOptions: {
2531
+ el: app.$el[0]
2532
+ }
2533
+ }, function (el) {
2534
+ app.$el = $(el);
2535
+ app.$el[0].wia = app;
2536
+ app.$elComponent = el.f7Component;
2537
+ app.el = app.$el[0];
2538
+ if (callback) callback();
2539
+ }, function () {});
2540
+ };
2541
+ _proto.init = function init(rootEl) {
2542
+ var app = this;
2543
+ app.setColors();
2544
+ app.mount(rootEl);
2545
+ var init = function init() {
2546
+ if (app.initialized) return app;
2547
+ app.$el.addClass('framework7-initializing');
2548
+ if (app.rtl) {
2549
+ $('html').attr('dir', 'rtl');
2550
+ }
2551
+ if (typeof app.params.darkMode === 'undefined') {
2552
+ app.darkMode = $('html').hasClass('dark');
2553
+ } else {
2554
+ app.setDarkMode(app.params.darkMode);
2555
+ }
2556
+ window.addEventListener('offline', function () {
2557
+ app.online = false;
2558
+ app.emit('offline');
2559
+ app.emit('connection', false);
2560
+ });
2561
+ window.addEventListener('online', function () {
2562
+ app.online = true;
2563
+ app.emit('online');
2564
+ app.emit('connection', true);
2565
+ });
2566
+ app.$el.addClass('framework7-root');
2567
+ $('html').removeClass('ios md pc').addClass(app.theme);
2568
+ if (app.params.iosTranslucentBars && app.theme === 'ios') {
2569
+ $('html').addClass('ios-translucent-bars');
2570
+ }
2571
+ if (app.params.iosTranslucentModals && app.theme === 'ios') {
2572
+ $('html').addClass('ios-translucent-modals');
2573
+ }
2574
+ nextFrame(function () {
2575
+ app.$el.removeClass('framework7-initializing');
2576
+ });
2577
+ initStyle();
2578
+ app.initialized = true;
2579
+ app.emit('init');
2580
+ };
2581
+ if (app.params.component || app.params.componentUrl) {
2582
+ app.initAppComponent(function () {
2583
+ init();
2584
+ });
2585
+ } else {
2586
+ init();
1352
2587
  }
1353
- $.nextFrame(function () {
1354
- app.root.removeClass('framework7-initializing');
1355
- });
1356
- initStyle();
1357
- app.initialized = true;
1358
- app.emit('init');
1359
2588
  return app;
1360
2589
  };
1361
2590
  _proto.loadModule = function loadModule(m) {
@@ -1395,6 +2624,16 @@
1395
2624
  get: function get() {
1396
2625
  return Event;
1397
2626
  }
2627
+ }, {
2628
+ key: "Class",
2629
+ get: function get() {
2630
+ return Module;
2631
+ }
2632
+ }, {
2633
+ key: "Events",
2634
+ get: function get() {
2635
+ return Event;
2636
+ }
1398
2637
  }]);
1399
2638
  return App;
1400
2639
  }(Module);
@@ -1404,25 +2643,26 @@
1404
2643
  var html = document.querySelector('html');
1405
2644
  var metaStatusbar = document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');
1406
2645
  if (!html) return;
1407
- if (Device$1.standalone && Device$1.ios && metaStatusbar && metaStatusbar.content === 'black-translucent') {
2646
+ if (device.standalone && device.ios && metaStatusbar && metaStatusbar.content === 'black-translucent') {
1408
2647
  classNames.push('device-full-viewport');
1409
2648
  }
1410
- classNames.push("device-pixel-ratio-" + Math.floor(Device$1.pixelRatio));
1411
- if (Device$1.os && !Device$1.desktop) {
1412
- classNames.push("device-" + Device$1.os);
1413
- } else if (Device$1.desktop) {
2649
+ classNames.push("device-pixel-ratio-" + Math.floor(device.pixelRatio));
2650
+ if (device.os && !device.desktop) {
2651
+ classNames.push("device-" + device.os);
2652
+ } else if (device.desktop) {
1414
2653
  classNames.push('device-desktop');
1415
- if (Device$1.os) {
1416
- classNames.push("device-" + Device$1.os);
2654
+ if (device.os) {
2655
+ classNames.push("device-" + device.os);
1417
2656
  }
1418
2657
  }
1419
- if (Device$1.cordova || Device$1.phonegap) {
2658
+ if (device.cordova || device.phonegap) {
1420
2659
  classNames.push('device-cordova');
1421
2660
  }
1422
2661
  classNames.forEach(function (className) {
1423
2662
  html.classList.add(className);
1424
2663
  });
1425
2664
  }
2665
+ App.jsx = jsx;
1426
2666
  App.ModalMethods = Modals;
1427
2667
  App.ConstructorMethods = Constructors;
1428
2668
  App.loadModule = loadModule;
@@ -1431,8 +2671,8 @@
1431
2671
  return App.loadModule(module);
1432
2672
  }));
1433
2673
  };
1434
- App.support = Support$1;
1435
- App.device = Device$1;
2674
+ App.support = support;
2675
+ App.device = device;
1436
2676
  App.utils = Utils;
1437
2677
  App.use([Resize, Click, SW$1]);
1438
2678
 
@@ -1727,32 +2967,6 @@
1727
2967
  return Modal;
1728
2968
  }(Event);
1729
2969
 
1730
- function jsx(tag, props) {
1731
- var attrs = props || {};
1732
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1733
- args[_key - 2] = arguments[_key];
1734
- }
1735
- var children = args || [];
1736
- var attrsString = Object.keys(attrs).map(function (attr) {
1737
- if (attr[0] === '_') {
1738
- if (attrs[attr]) return attr.replace('_', '');
1739
- return '';
1740
- }
1741
- return attr + "=\"" + attrs[attr] + "\"";
1742
- }).filter(function (attr) {
1743
- return !!attr;
1744
- }).join(' ');
1745
- if (['path', 'img', 'circle', 'polygon', 'line', 'input'].indexOf(tag) >= 0) {
1746
- return ("<" + tag + " " + attrsString + " />").trim();
1747
- }
1748
- var childrenContent = children.filter(function (c) {
1749
- return !!c;
1750
- }).map(function (c) {
1751
- return Array.isArray(c) ? c.join('') : c;
1752
- }).join('');
1753
- return ("<" + tag + " " + attrsString + ">" + childrenContent + "</" + tag + ">").trim();
1754
- }
1755
-
1756
2970
  var Support = $.support;
1757
2971
  var Device = $.device;
1758
2972