@koine/next 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.esm.js +4569 -0
- package/index.umd.js +4626 -0
- package/motion-features.esm.js +2 -0
- package/package.json +28 -0
package/index.esm.js
ADDED
|
@@ -0,0 +1,4569 @@
|
|
|
1
|
+
import { pageview, isArray, isServer, isString, parseURL, buildUrlQueryString, normaliseUrl } from '@koine/utils';
|
|
2
|
+
import React$1, { useState, useEffect, memo, useRef, useCallback, useContext, createContext, useMemo, forwardRef } from 'react';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import Script from 'next/script';
|
|
5
|
+
import Head from 'next/head';
|
|
6
|
+
export { default as Head } from 'next/head';
|
|
7
|
+
import { ThemeProvider as ThemeProvider$1 } from '@mui/material/styles';
|
|
8
|
+
import { CacheProvider, Global, css } from '@emotion/react';
|
|
9
|
+
import CssBaseline from '@mui/material/CssBaseline';
|
|
10
|
+
import { stylesGlobal, ProgressOverlay, StylesGlobal, useDateLocale, Meta, NoJs, getInitialThemeFromRequest, FaviconTags, KoineLink } from '@koine/react';
|
|
11
|
+
import { LazyMotion, AnimatePresence, m } from 'framer-motion';
|
|
12
|
+
import { ThemeProvider as ThemeProvider$2, ServerStyleSheet } from 'styled-components';
|
|
13
|
+
import { SessionProvider, signIn, signOut } from 'next-auth/react';
|
|
14
|
+
import format from 'date-fns/format';
|
|
15
|
+
import useTranslation from 'next-translate/useTranslation';
|
|
16
|
+
export { default as T } from 'next-translate/Trans';
|
|
17
|
+
import NextDocument, { Html, Head as Head$1, Main, NextScript } from 'next/document';
|
|
18
|
+
import createEmotionServer from '@emotion/server/create-instance';
|
|
19
|
+
import { useForm as useForm$1 } from 'react-hook-form';
|
|
20
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
21
|
+
import { useAsyncFn } from 'react-use';
|
|
22
|
+
import NextImage from 'next/image';
|
|
23
|
+
import NextLink from 'next/link';
|
|
24
|
+
|
|
25
|
+
function _arrayLikeToArray$8(arr, len) {
|
|
26
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
27
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
28
|
+
return arr2;
|
|
29
|
+
}
|
|
30
|
+
function _arrayWithHoles$8(arr) {
|
|
31
|
+
if (Array.isArray(arr)) return arr;
|
|
32
|
+
}
|
|
33
|
+
function _iterableToArrayLimit$8(arr, i) {
|
|
34
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
35
|
+
if (_i == null) return;
|
|
36
|
+
var _arr = [];
|
|
37
|
+
var _n = true;
|
|
38
|
+
var _d = false;
|
|
39
|
+
var _s, _e;
|
|
40
|
+
try {
|
|
41
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
42
|
+
_arr.push(_s.value);
|
|
43
|
+
if (i && _arr.length === i) break;
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_d = true;
|
|
47
|
+
_e = err;
|
|
48
|
+
} finally{
|
|
49
|
+
try {
|
|
50
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
51
|
+
} finally{
|
|
52
|
+
if (_d) throw _e;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return _arr;
|
|
56
|
+
}
|
|
57
|
+
function _nonIterableRest$8() {
|
|
58
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
59
|
+
}
|
|
60
|
+
function _slicedToArray$8(arr, i) {
|
|
61
|
+
return _arrayWithHoles$8(arr) || _iterableToArrayLimit$8(arr, i) || _unsupportedIterableToArray$8(arr, i) || _nonIterableRest$8();
|
|
62
|
+
}
|
|
63
|
+
function _unsupportedIterableToArray$8(o, minLen) {
|
|
64
|
+
if (!o) return;
|
|
65
|
+
if (typeof o === "string") return _arrayLikeToArray$8(o, minLen);
|
|
66
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
67
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
68
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
69
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$8(o, minLen);
|
|
70
|
+
}
|
|
71
|
+
var AnalyticsGoogle = function(param) {
|
|
72
|
+
var id = param.id;
|
|
73
|
+
var uid = id || process.env["NEXT_PUBLIC_GTM_ID"];
|
|
74
|
+
var ref = useRouter(), events = ref.events, asPath = ref.asPath, query = ref.query;
|
|
75
|
+
var ref1 = _slicedToArray$8(useState(false), 2), ready = ref1[0], setReady = ref1[1];
|
|
76
|
+
var ref2 = _slicedToArray$8(useState(false), 2), routed = ref2[0], setRouted = ref2[1];
|
|
77
|
+
// const [url, setUrl] = useState("");
|
|
78
|
+
useEffect(function() {
|
|
79
|
+
var handleRouteChange = function() {
|
|
80
|
+
setRouted(true);
|
|
81
|
+
};
|
|
82
|
+
events.on("routeChangeComplete", handleRouteChange);
|
|
83
|
+
return function() {
|
|
84
|
+
events.off("routeChangeComplete", handleRouteChange);
|
|
85
|
+
};
|
|
86
|
+
}, [
|
|
87
|
+
events
|
|
88
|
+
]);
|
|
89
|
+
useEffect(function() {
|
|
90
|
+
if (routed && ready && asPath) {
|
|
91
|
+
// const search = query;
|
|
92
|
+
pageview(asPath);
|
|
93
|
+
}
|
|
94
|
+
}, [
|
|
95
|
+
asPath,
|
|
96
|
+
query,
|
|
97
|
+
routed,
|
|
98
|
+
ready
|
|
99
|
+
]);
|
|
100
|
+
if (!uid) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Script, {
|
|
104
|
+
id: "google-tagmanager",
|
|
105
|
+
src: "https://www.googletagmanager.com/gtag/js?id=".concat(id),
|
|
106
|
+
strategy: "afterInteractive",
|
|
107
|
+
onLoad: function() {
|
|
108
|
+
return setReady(true);
|
|
109
|
+
}
|
|
110
|
+
}), /*#__PURE__*/ React.createElement(Script, {
|
|
111
|
+
id: "google-analytics",
|
|
112
|
+
strategy: "afterInteractive"
|
|
113
|
+
}, "\n window.dataLayer = window.dataLayer || [];\n function gtag(){window.dataLayer.push(arguments);}\n gtag('js', new Date());\n\n gtag('config', '".concat(id, "', { 'send_page_view': false });\n ")));
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
function _extends$e() {
|
|
117
|
+
_extends$e = Object.assign || function(target) {
|
|
118
|
+
for(var i = 1; i < arguments.length; i++){
|
|
119
|
+
var source = arguments[i];
|
|
120
|
+
for(var key in source){
|
|
121
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
122
|
+
target[key] = source[key];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return target;
|
|
127
|
+
};
|
|
128
|
+
return _extends$e.apply(this, arguments);
|
|
129
|
+
}
|
|
130
|
+
var AppHead = function(props) {
|
|
131
|
+
return /*#__PURE__*/ React.createElement(Head, _extends$e({}, props), /*#__PURE__*/ React.createElement("meta", {
|
|
132
|
+
name: "viewport",
|
|
133
|
+
content: "width=device-width"
|
|
134
|
+
}));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
|
|
139
|
+
Based off glamor's StyleSheet, thanks Sunil ❤️
|
|
140
|
+
|
|
141
|
+
high performance StyleSheet for css-in-js systems
|
|
142
|
+
|
|
143
|
+
- uses multiple style tags behind the scenes for millions of rules
|
|
144
|
+
- uses `insertRule` for appending in production for *much* faster performance
|
|
145
|
+
|
|
146
|
+
// usage
|
|
147
|
+
|
|
148
|
+
import { StyleSheet } from '@emotion/sheet'
|
|
149
|
+
|
|
150
|
+
let styleSheet = new StyleSheet({ key: '', container: document.head })
|
|
151
|
+
|
|
152
|
+
styleSheet.insert('#box { border: 1px solid red; }')
|
|
153
|
+
- appends a css rule into the stylesheet
|
|
154
|
+
|
|
155
|
+
styleSheet.flush()
|
|
156
|
+
- empties the stylesheet of all its contents
|
|
157
|
+
|
|
158
|
+
*/ // $FlowFixMe
|
|
159
|
+
function sheetForTag(tag) {
|
|
160
|
+
if (tag.sheet) {
|
|
161
|
+
// $FlowFixMe
|
|
162
|
+
return tag.sheet;
|
|
163
|
+
} // this weirdness brought to you by firefox
|
|
164
|
+
/* istanbul ignore next */ for(var i = 0; i < document.styleSheets.length; i++){
|
|
165
|
+
if (document.styleSheets[i].ownerNode === tag) {
|
|
166
|
+
// $FlowFixMe
|
|
167
|
+
return document.styleSheets[i];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function createStyleElement(options) {
|
|
172
|
+
var tag = document.createElement("style");
|
|
173
|
+
tag.setAttribute("data-emotion", options.key);
|
|
174
|
+
if (options.nonce !== undefined) {
|
|
175
|
+
tag.setAttribute("nonce", options.nonce);
|
|
176
|
+
}
|
|
177
|
+
tag.appendChild(document.createTextNode(""));
|
|
178
|
+
tag.setAttribute("data-s", "");
|
|
179
|
+
return tag;
|
|
180
|
+
}
|
|
181
|
+
var StyleSheet1 = /*#__PURE__*/ function() {
|
|
182
|
+
var StyleSheet = function StyleSheet(options) {
|
|
183
|
+
var _this = this;
|
|
184
|
+
this._insertTag = function(tag) {
|
|
185
|
+
var before;
|
|
186
|
+
if (_this.tags.length === 0) {
|
|
187
|
+
if (_this.insertionPoint) {
|
|
188
|
+
before = _this.insertionPoint.nextSibling;
|
|
189
|
+
} else if (_this.prepend) {
|
|
190
|
+
before = _this.container.firstChild;
|
|
191
|
+
} else {
|
|
192
|
+
before = _this.before;
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
before = _this.tags[_this.tags.length - 1].nextSibling;
|
|
196
|
+
}
|
|
197
|
+
_this.container.insertBefore(tag, before);
|
|
198
|
+
_this.tags.push(tag);
|
|
199
|
+
};
|
|
200
|
+
this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === "production" : options.speedy;
|
|
201
|
+
this.tags = [];
|
|
202
|
+
this.ctr = 0;
|
|
203
|
+
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
|
|
204
|
+
this.key = options.key;
|
|
205
|
+
this.container = options.container;
|
|
206
|
+
this.prepend = options.prepend;
|
|
207
|
+
this.insertionPoint = options.insertionPoint;
|
|
208
|
+
this.before = null;
|
|
209
|
+
};
|
|
210
|
+
var _proto = StyleSheet.prototype;
|
|
211
|
+
_proto.hydrate = function hydrate(nodes) {
|
|
212
|
+
nodes.forEach(this._insertTag);
|
|
213
|
+
};
|
|
214
|
+
_proto.insert = function insert(rule) {
|
|
215
|
+
// the max length is how many rules we have per style tag, it's 65000 in speedy mode
|
|
216
|
+
// it's 1 in dev because we insert source maps that map a single rule to a location
|
|
217
|
+
// and you can only have one source map per style tag
|
|
218
|
+
if (this.ctr % (this.isSpeedy ? 65000 : 1) === 0) {
|
|
219
|
+
this._insertTag(createStyleElement(this));
|
|
220
|
+
}
|
|
221
|
+
var tag = this.tags[this.tags.length - 1];
|
|
222
|
+
if (process.env.NODE_ENV !== "production") {
|
|
223
|
+
var isImportRule = rule.charCodeAt(0) === 64 && rule.charCodeAt(1) === 105;
|
|
224
|
+
if (isImportRule && this._alreadyInsertedOrderInsensitiveRule) {
|
|
225
|
+
// this would only cause problem in speedy mode
|
|
226
|
+
// but we don't want enabling speedy to affect the observable behavior
|
|
227
|
+
// so we report this error at all times
|
|
228
|
+
console.error("You're attempting to insert the following rule:\n" + rule + "\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules.");
|
|
229
|
+
}
|
|
230
|
+
this._alreadyInsertedOrderInsensitiveRule = this._alreadyInsertedOrderInsensitiveRule || !isImportRule;
|
|
231
|
+
}
|
|
232
|
+
if (this.isSpeedy) {
|
|
233
|
+
var sheet = sheetForTag(tag);
|
|
234
|
+
try {
|
|
235
|
+
// this is the ultrafast version, works across browsers
|
|
236
|
+
// the big drawback is that the css won't be editable in devtools
|
|
237
|
+
sheet.insertRule(rule, sheet.cssRules.length);
|
|
238
|
+
} catch (e) {
|
|
239
|
+
if (process.env.NODE_ENV !== "production" && !/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear){/.test(rule)) {
|
|
240
|
+
console.error('There was a problem inserting the following rule: "' + rule + '"', e);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
} else {
|
|
244
|
+
tag.appendChild(document.createTextNode(rule));
|
|
245
|
+
}
|
|
246
|
+
this.ctr++;
|
|
247
|
+
};
|
|
248
|
+
_proto.flush = function flush() {
|
|
249
|
+
// $FlowFixMe
|
|
250
|
+
this.tags.forEach(function(tag) {
|
|
251
|
+
return tag.parentNode && tag.parentNode.removeChild(tag);
|
|
252
|
+
});
|
|
253
|
+
this.tags = [];
|
|
254
|
+
this.ctr = 0;
|
|
255
|
+
if (process.env.NODE_ENV !== "production") {
|
|
256
|
+
this._alreadyInsertedOrderInsensitiveRule = false;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
return StyleSheet;
|
|
260
|
+
}();
|
|
261
|
+
|
|
262
|
+
var MS = "-ms-";
|
|
263
|
+
var MOZ = "-moz-";
|
|
264
|
+
var WEBKIT = "-webkit-";
|
|
265
|
+
var COMMENT = "comm";
|
|
266
|
+
var RULESET = "rule";
|
|
267
|
+
var DECLARATION = "decl";
|
|
268
|
+
var IMPORT = "@import";
|
|
269
|
+
var KEYFRAMES = "@keyframes";
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @param {number}
|
|
273
|
+
* @return {number}
|
|
274
|
+
*/ var abs = Math.abs;
|
|
275
|
+
/**
|
|
276
|
+
* @param {number}
|
|
277
|
+
* @return {string}
|
|
278
|
+
*/ var from = String.fromCharCode;
|
|
279
|
+
/**
|
|
280
|
+
* @param {object}
|
|
281
|
+
* @return {object}
|
|
282
|
+
*/ var assign = Object.assign;
|
|
283
|
+
/**
|
|
284
|
+
* @param {string} value
|
|
285
|
+
* @param {number} length
|
|
286
|
+
* @return {number}
|
|
287
|
+
*/ function hash(value, length) {
|
|
288
|
+
return (((length << 2 ^ charat(value, 0)) << 2 ^ charat(value, 1)) << 2 ^ charat(value, 2)) << 2 ^ charat(value, 3);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* @param {string} value
|
|
292
|
+
* @return {string}
|
|
293
|
+
*/ function trim(value) {
|
|
294
|
+
return value.trim();
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* @param {string} value
|
|
298
|
+
* @param {RegExp} pattern
|
|
299
|
+
* @return {string?}
|
|
300
|
+
*/ function match(value, pattern) {
|
|
301
|
+
return (value = pattern.exec(value)) ? value[0] : value;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @param {string} value
|
|
305
|
+
* @param {(string|RegExp)} pattern
|
|
306
|
+
* @param {string} replacement
|
|
307
|
+
* @return {string}
|
|
308
|
+
*/ function replace(value, pattern, replacement) {
|
|
309
|
+
return value.replace(pattern, replacement);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* @param {string} value
|
|
313
|
+
* @param {string} search
|
|
314
|
+
* @return {number}
|
|
315
|
+
*/ function indexof(value, search) {
|
|
316
|
+
return value.indexOf(search);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @param {string} value
|
|
320
|
+
* @param {number} index
|
|
321
|
+
* @return {number}
|
|
322
|
+
*/ function charat(value, index) {
|
|
323
|
+
return value.charCodeAt(index) | 0;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* @param {string} value
|
|
327
|
+
* @param {number} begin
|
|
328
|
+
* @param {number} end
|
|
329
|
+
* @return {string}
|
|
330
|
+
*/ function substr(value, begin, end) {
|
|
331
|
+
return value.slice(begin, end);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* @param {string} value
|
|
335
|
+
* @return {number}
|
|
336
|
+
*/ function strlen(value) {
|
|
337
|
+
return value.length;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* @param {any[]} value
|
|
341
|
+
* @return {number}
|
|
342
|
+
*/ function sizeof(value) {
|
|
343
|
+
return value.length;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* @param {any} value
|
|
347
|
+
* @param {any[]} array
|
|
348
|
+
* @return {any}
|
|
349
|
+
*/ function append(value, array) {
|
|
350
|
+
return array.push(value), value;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* @param {string[]} array
|
|
354
|
+
* @param {function} callback
|
|
355
|
+
* @return {string}
|
|
356
|
+
*/ function combine(array, callback) {
|
|
357
|
+
return array.map(callback).join("");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
var line = 1;
|
|
361
|
+
var column = 1;
|
|
362
|
+
var length = 0;
|
|
363
|
+
var position = 0;
|
|
364
|
+
var character = 0;
|
|
365
|
+
var characters = "";
|
|
366
|
+
/**
|
|
367
|
+
* @param {string} value
|
|
368
|
+
* @param {object | null} root
|
|
369
|
+
* @param {object | null} parent
|
|
370
|
+
* @param {string} type
|
|
371
|
+
* @param {string[] | string} props
|
|
372
|
+
* @param {object[] | string} children
|
|
373
|
+
* @param {number} length
|
|
374
|
+
*/ function node(value, root, parent, type, props, children, length1) {
|
|
375
|
+
return {
|
|
376
|
+
value: value,
|
|
377
|
+
root: root,
|
|
378
|
+
parent: parent,
|
|
379
|
+
type: type,
|
|
380
|
+
props: props,
|
|
381
|
+
children: children,
|
|
382
|
+
line: line,
|
|
383
|
+
column: column,
|
|
384
|
+
length: length1,
|
|
385
|
+
return: ""
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* @param {object} root
|
|
390
|
+
* @param {object} props
|
|
391
|
+
* @return {object}
|
|
392
|
+
*/ function copy(root, props) {
|
|
393
|
+
return assign(node("", null, null, "", null, null, 0), root, {
|
|
394
|
+
length: -root.length
|
|
395
|
+
}, props);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* @return {number}
|
|
399
|
+
*/ function char() {
|
|
400
|
+
return character;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* @return {number}
|
|
404
|
+
*/ function prev() {
|
|
405
|
+
character = position > 0 ? charat(characters, --position) : 0;
|
|
406
|
+
if (column--, character === 10) column = 1, line--;
|
|
407
|
+
return character;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* @return {number}
|
|
411
|
+
*/ function next() {
|
|
412
|
+
character = position < length ? charat(characters, position++) : 0;
|
|
413
|
+
if (column++, character === 10) column = 1, line++;
|
|
414
|
+
return character;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* @return {number}
|
|
418
|
+
*/ function peek() {
|
|
419
|
+
return charat(characters, position);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* @return {number}
|
|
423
|
+
*/ function caret() {
|
|
424
|
+
return position;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* @param {number} begin
|
|
428
|
+
* @param {number} end
|
|
429
|
+
* @return {string}
|
|
430
|
+
*/ function slice(begin, end) {
|
|
431
|
+
return substr(characters, begin, end);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* @param {number} type
|
|
435
|
+
* @return {number}
|
|
436
|
+
*/ function token(type) {
|
|
437
|
+
switch(type){
|
|
438
|
+
// \0 \t \n \r \s whitespace token
|
|
439
|
+
case 0:
|
|
440
|
+
case 9:
|
|
441
|
+
case 10:
|
|
442
|
+
case 13:
|
|
443
|
+
case 32:
|
|
444
|
+
return 5;
|
|
445
|
+
// ! + , / > @ ~ isolate token
|
|
446
|
+
case 33:
|
|
447
|
+
case 43:
|
|
448
|
+
case 44:
|
|
449
|
+
case 47:
|
|
450
|
+
case 62:
|
|
451
|
+
case 64:
|
|
452
|
+
case 126:
|
|
453
|
+
// ; { } breakpoint token
|
|
454
|
+
case 59:
|
|
455
|
+
case 123:
|
|
456
|
+
case 125:
|
|
457
|
+
return 4;
|
|
458
|
+
// : accompanied token
|
|
459
|
+
case 58:
|
|
460
|
+
return 3;
|
|
461
|
+
// " ' ( [ opening delimit token
|
|
462
|
+
case 34:
|
|
463
|
+
case 39:
|
|
464
|
+
case 40:
|
|
465
|
+
case 91:
|
|
466
|
+
return 2;
|
|
467
|
+
// ) ] closing delimit token
|
|
468
|
+
case 41:
|
|
469
|
+
case 93:
|
|
470
|
+
return 1;
|
|
471
|
+
}
|
|
472
|
+
return 0;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* @param {string} value
|
|
476
|
+
* @return {any[]}
|
|
477
|
+
*/ function alloc(value) {
|
|
478
|
+
return line = column = 1, length = strlen(characters = value), position = 0, [];
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* @param {any} value
|
|
482
|
+
* @return {any}
|
|
483
|
+
*/ function dealloc(value) {
|
|
484
|
+
return characters = "", value;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* @param {number} type
|
|
488
|
+
* @return {string}
|
|
489
|
+
*/ function delimit(type) {
|
|
490
|
+
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* @param {number} type
|
|
494
|
+
* @return {string}
|
|
495
|
+
*/ function whitespace(type) {
|
|
496
|
+
while(character = peek())if (character < 33) next();
|
|
497
|
+
else break;
|
|
498
|
+
return token(type) > 2 || token(character) > 3 ? "" : " ";
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* @param {number} index
|
|
502
|
+
* @param {number} count
|
|
503
|
+
* @return {string}
|
|
504
|
+
*/ function escaping(index, count) {
|
|
505
|
+
while(--count && next())// not 0-9 A-F a-f
|
|
506
|
+
if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97) break;
|
|
507
|
+
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* @param {number} type
|
|
511
|
+
* @return {number}
|
|
512
|
+
*/ function delimiter(type) {
|
|
513
|
+
while(next())switch(character){
|
|
514
|
+
// ] ) " '
|
|
515
|
+
case type:
|
|
516
|
+
return position;
|
|
517
|
+
// " '
|
|
518
|
+
case 34:
|
|
519
|
+
case 39:
|
|
520
|
+
if (type !== 34 && type !== 39) delimiter(character);
|
|
521
|
+
break;
|
|
522
|
+
// (
|
|
523
|
+
case 40:
|
|
524
|
+
if (type === 41) delimiter(type);
|
|
525
|
+
break;
|
|
526
|
+
// \
|
|
527
|
+
case 92:
|
|
528
|
+
next();
|
|
529
|
+
break;
|
|
530
|
+
}
|
|
531
|
+
return position;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* @param {number} type
|
|
535
|
+
* @param {number} index
|
|
536
|
+
* @return {number}
|
|
537
|
+
*/ function commenter(type, index) {
|
|
538
|
+
while(next())// //
|
|
539
|
+
if (type + character === 47 + 10) break;
|
|
540
|
+
else if (type + character === 42 + 42 && peek() === 47) break;
|
|
541
|
+
return "/*" + slice(index, position - 1) + "*" + from(type === 47 ? type : next());
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* @param {number} index
|
|
545
|
+
* @return {string}
|
|
546
|
+
*/ function identifier(index) {
|
|
547
|
+
while(!token(peek()))next();
|
|
548
|
+
return slice(index, position);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* @param {string} value
|
|
553
|
+
* @return {object[]}
|
|
554
|
+
*/ function compile(value) {
|
|
555
|
+
return dealloc(parse("", null, null, null, [
|
|
556
|
+
""
|
|
557
|
+
], value = alloc(value), 0, [
|
|
558
|
+
0
|
|
559
|
+
], value));
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* @param {string} value
|
|
563
|
+
* @param {object} root
|
|
564
|
+
* @param {object?} parent
|
|
565
|
+
* @param {string[]} rule
|
|
566
|
+
* @param {string[]} rules
|
|
567
|
+
* @param {string[]} rulesets
|
|
568
|
+
* @param {number[]} pseudo
|
|
569
|
+
* @param {number[]} points
|
|
570
|
+
* @param {string[]} declarations
|
|
571
|
+
* @return {object}
|
|
572
|
+
*/ function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
|
|
573
|
+
var index = 0;
|
|
574
|
+
var offset = 0;
|
|
575
|
+
var length = pseudo;
|
|
576
|
+
var atrule = 0;
|
|
577
|
+
var property = 0;
|
|
578
|
+
var previous = 0;
|
|
579
|
+
var variable = 1;
|
|
580
|
+
var scanning = 1;
|
|
581
|
+
var ampersand = 1;
|
|
582
|
+
var character = 0;
|
|
583
|
+
var type = "";
|
|
584
|
+
var props = rules;
|
|
585
|
+
var children = rulesets;
|
|
586
|
+
var reference = rule;
|
|
587
|
+
var characters = type;
|
|
588
|
+
while(scanning)switch(previous = character, character = next()){
|
|
589
|
+
// (
|
|
590
|
+
case 40:
|
|
591
|
+
if (previous != 108 && characters.charCodeAt(length - 1) == 58) {
|
|
592
|
+
if (indexof(characters += replace(delimit(character), "&", "&\f"), "&\f") != -1) ampersand = -1;
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
// " ' [
|
|
596
|
+
case 34:
|
|
597
|
+
case 39:
|
|
598
|
+
case 91:
|
|
599
|
+
characters += delimit(character);
|
|
600
|
+
break;
|
|
601
|
+
// \t \n \r \s
|
|
602
|
+
case 9:
|
|
603
|
+
case 10:
|
|
604
|
+
case 13:
|
|
605
|
+
case 32:
|
|
606
|
+
characters += whitespace(previous);
|
|
607
|
+
break;
|
|
608
|
+
// \
|
|
609
|
+
case 92:
|
|
610
|
+
characters += escaping(caret() - 1, 7);
|
|
611
|
+
continue;
|
|
612
|
+
// /
|
|
613
|
+
case 47:
|
|
614
|
+
switch(peek()){
|
|
615
|
+
case 42:
|
|
616
|
+
case 47:
|
|
617
|
+
append(comment(commenter(next(), caret()), root, parent), declarations);
|
|
618
|
+
break;
|
|
619
|
+
default:
|
|
620
|
+
characters += "/";
|
|
621
|
+
}
|
|
622
|
+
break;
|
|
623
|
+
// {
|
|
624
|
+
case 123 * variable:
|
|
625
|
+
points[index++] = strlen(characters) * ampersand;
|
|
626
|
+
// } ; \0
|
|
627
|
+
case 125 * variable:
|
|
628
|
+
case 59:
|
|
629
|
+
case 0:
|
|
630
|
+
switch(character){
|
|
631
|
+
// \0 }
|
|
632
|
+
case 0:
|
|
633
|
+
case 125:
|
|
634
|
+
scanning = 0;
|
|
635
|
+
// ;
|
|
636
|
+
case 59 + offset:
|
|
637
|
+
if (property > 0 && strlen(characters) - length) append(property > 32 ? declaration(characters + ";", rule, parent, length - 1) : declaration(replace(characters, " ", "") + ";", rule, parent, length - 2), declarations);
|
|
638
|
+
break;
|
|
639
|
+
// @ ;
|
|
640
|
+
case 59:
|
|
641
|
+
characters += ";";
|
|
642
|
+
// { rule/at-rule
|
|
643
|
+
default:
|
|
644
|
+
append(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length), rulesets);
|
|
645
|
+
if (character === 123) if (offset === 0) parse(characters, root, reference, reference, props, rulesets, length, points, children);
|
|
646
|
+
else switch(atrule){
|
|
647
|
+
// d m s
|
|
648
|
+
case 100:
|
|
649
|
+
case 109:
|
|
650
|
+
case 115:
|
|
651
|
+
parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length), children), rules, children, length, points, rule ? props : children);
|
|
652
|
+
break;
|
|
653
|
+
default:
|
|
654
|
+
parse(characters, reference, reference, reference, [
|
|
655
|
+
""
|
|
656
|
+
], children, 0, points, children);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
index = offset = property = 0, variable = ampersand = 1, type = characters = "", length = pseudo;
|
|
660
|
+
break;
|
|
661
|
+
// :
|
|
662
|
+
case 58:
|
|
663
|
+
length = 1 + strlen(characters), property = previous;
|
|
664
|
+
default:
|
|
665
|
+
if (variable < 1) {
|
|
666
|
+
if (character == 123) --variable;
|
|
667
|
+
else if (character == 125 && (variable++) == 0 && prev() == 125) continue;
|
|
668
|
+
}
|
|
669
|
+
switch(characters += from(character), character * variable){
|
|
670
|
+
// &
|
|
671
|
+
case 38:
|
|
672
|
+
ampersand = offset > 0 ? 1 : (characters += "\f", -1);
|
|
673
|
+
break;
|
|
674
|
+
// ,
|
|
675
|
+
case 44:
|
|
676
|
+
points[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1;
|
|
677
|
+
break;
|
|
678
|
+
// @
|
|
679
|
+
case 64:
|
|
680
|
+
// -
|
|
681
|
+
if (peek() === 45) characters += delimit(next());
|
|
682
|
+
atrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++;
|
|
683
|
+
break;
|
|
684
|
+
// -
|
|
685
|
+
case 45:
|
|
686
|
+
if (previous === 45 && strlen(characters) == 2) variable = 0;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return rulesets;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* @param {string} value
|
|
693
|
+
* @param {object} root
|
|
694
|
+
* @param {object?} parent
|
|
695
|
+
* @param {number} index
|
|
696
|
+
* @param {number} offset
|
|
697
|
+
* @param {string[]} rules
|
|
698
|
+
* @param {number[]} points
|
|
699
|
+
* @param {string} type
|
|
700
|
+
* @param {string[]} props
|
|
701
|
+
* @param {string[]} children
|
|
702
|
+
* @param {number} length
|
|
703
|
+
* @return {object}
|
|
704
|
+
*/ function ruleset(value, root, parent, index, offset, rules, points, type, props, children, length) {
|
|
705
|
+
var post = offset - 1;
|
|
706
|
+
var rule = offset === 0 ? rules : [
|
|
707
|
+
""
|
|
708
|
+
];
|
|
709
|
+
var size = sizeof(rule);
|
|
710
|
+
for(var i = 0, j = 0, k = 0; i < index; ++i)for(var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)if (z = trim(j > 0 ? rule[x] + " " + y : replace(y, /&\f/g, rule[x]))) props[k++] = z;
|
|
711
|
+
return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* @param {number} value
|
|
715
|
+
* @param {object} root
|
|
716
|
+
* @param {object?} parent
|
|
717
|
+
* @return {object}
|
|
718
|
+
*/ function comment(value, root, parent) {
|
|
719
|
+
return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0);
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* @param {string} value
|
|
723
|
+
* @param {object} root
|
|
724
|
+
* @param {object?} parent
|
|
725
|
+
* @param {number} length
|
|
726
|
+
* @return {object}
|
|
727
|
+
*/ function declaration(value, root, parent, length) {
|
|
728
|
+
return node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* @param {string} value
|
|
733
|
+
* @param {number} length
|
|
734
|
+
* @return {string}
|
|
735
|
+
*/ function prefix(value, length) {
|
|
736
|
+
switch(hash(value, length)){
|
|
737
|
+
// color-adjust
|
|
738
|
+
case 5103:
|
|
739
|
+
return WEBKIT + "print-" + value + value;
|
|
740
|
+
// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
|
|
741
|
+
case 5737:
|
|
742
|
+
case 4201:
|
|
743
|
+
case 3177:
|
|
744
|
+
case 3433:
|
|
745
|
+
case 1641:
|
|
746
|
+
case 4457:
|
|
747
|
+
case 2921:
|
|
748
|
+
// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
|
|
749
|
+
case 5572:
|
|
750
|
+
case 6356:
|
|
751
|
+
case 5844:
|
|
752
|
+
case 3191:
|
|
753
|
+
case 6645:
|
|
754
|
+
case 3005:
|
|
755
|
+
// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
|
|
756
|
+
case 6391:
|
|
757
|
+
case 5879:
|
|
758
|
+
case 5623:
|
|
759
|
+
case 6135:
|
|
760
|
+
case 4599:
|
|
761
|
+
case 4855:
|
|
762
|
+
// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
|
|
763
|
+
case 4215:
|
|
764
|
+
case 6389:
|
|
765
|
+
case 5109:
|
|
766
|
+
case 5365:
|
|
767
|
+
case 5621:
|
|
768
|
+
case 3829:
|
|
769
|
+
return WEBKIT + value + value;
|
|
770
|
+
// appearance, user-select, transform, hyphens, text-size-adjust
|
|
771
|
+
case 5349:
|
|
772
|
+
case 4246:
|
|
773
|
+
case 4810:
|
|
774
|
+
case 6968:
|
|
775
|
+
case 2756:
|
|
776
|
+
return WEBKIT + value + MOZ + value + MS + value + value;
|
|
777
|
+
// flex, flex-direction
|
|
778
|
+
case 6828:
|
|
779
|
+
case 4268:
|
|
780
|
+
return WEBKIT + value + MS + value + value;
|
|
781
|
+
// order
|
|
782
|
+
case 6165:
|
|
783
|
+
return WEBKIT + value + MS + "flex-" + value + value;
|
|
784
|
+
// align-items
|
|
785
|
+
case 5187:
|
|
786
|
+
return WEBKIT + value + replace(value, /(\w+).+(:[^]+)/, WEBKIT + "box-$1$2" + MS + "flex-$1$2") + value;
|
|
787
|
+
// align-self
|
|
788
|
+
case 5443:
|
|
789
|
+
return WEBKIT + value + MS + "flex-item-" + replace(value, /flex-|-self/, "") + value;
|
|
790
|
+
// align-content
|
|
791
|
+
case 4675:
|
|
792
|
+
return WEBKIT + value + MS + "flex-line-pack" + replace(value, /align-content|flex-|-self/, "") + value;
|
|
793
|
+
// flex-shrink
|
|
794
|
+
case 5548:
|
|
795
|
+
return WEBKIT + value + MS + replace(value, "shrink", "negative") + value;
|
|
796
|
+
// flex-basis
|
|
797
|
+
case 5292:
|
|
798
|
+
return WEBKIT + value + MS + replace(value, "basis", "preferred-size") + value;
|
|
799
|
+
// flex-grow
|
|
800
|
+
case 6060:
|
|
801
|
+
return WEBKIT + "box-" + replace(value, "-grow", "") + WEBKIT + value + MS + replace(value, "grow", "positive") + value;
|
|
802
|
+
// transition
|
|
803
|
+
case 4554:
|
|
804
|
+
return WEBKIT + replace(value, /([^-])(transform)/g, "$1" + WEBKIT + "$2") + value;
|
|
805
|
+
// cursor
|
|
806
|
+
case 6187:
|
|
807
|
+
return replace(replace(replace(value, /(zoom-|grab)/, WEBKIT + "$1"), /(image-set)/, WEBKIT + "$1"), value, "") + value;
|
|
808
|
+
// background, background-image
|
|
809
|
+
case 5495:
|
|
810
|
+
case 3959:
|
|
811
|
+
return replace(value, /(image-set\([^]*)/, WEBKIT + "$1" + "$`$1");
|
|
812
|
+
// justify-content
|
|
813
|
+
case 4968:
|
|
814
|
+
return replace(replace(value, /(.+:)(flex-)?(.*)/, WEBKIT + "box-pack:$3" + MS + "flex-pack:$3"), /s.+-b[^;]+/, "justify") + WEBKIT + value + value;
|
|
815
|
+
// (margin|padding)-inline-(start|end)
|
|
816
|
+
case 4095:
|
|
817
|
+
case 3583:
|
|
818
|
+
case 4068:
|
|
819
|
+
case 2532:
|
|
820
|
+
return replace(value, /(.+)-inline(.+)/, WEBKIT + "$1$2") + value;
|
|
821
|
+
// (min|max)?(width|height|inline-size|block-size)
|
|
822
|
+
case 8116:
|
|
823
|
+
case 7059:
|
|
824
|
+
case 5753:
|
|
825
|
+
case 5535:
|
|
826
|
+
case 5445:
|
|
827
|
+
case 5701:
|
|
828
|
+
case 4933:
|
|
829
|
+
case 4677:
|
|
830
|
+
case 5533:
|
|
831
|
+
case 5789:
|
|
832
|
+
case 5021:
|
|
833
|
+
case 4765:
|
|
834
|
+
// stretch, max-content, min-content, fill-available
|
|
835
|
+
if (strlen(value) - 1 - length > 6) switch(charat(value, length + 1)){
|
|
836
|
+
// (m)ax-content, (m)in-content
|
|
837
|
+
case 109:
|
|
838
|
+
// -
|
|
839
|
+
if (charat(value, length + 4) !== 45) break;
|
|
840
|
+
// (f)ill-available, (f)it-content
|
|
841
|
+
case 102:
|
|
842
|
+
return replace(value, /(.+:)(.+)-([^]+)/, "$1" + WEBKIT + "$2-$3" + "$1" + MOZ + (charat(value, length + 3) == 108 ? "$3" : "$2-$3")) + value;
|
|
843
|
+
// (s)tretch
|
|
844
|
+
case 115:
|
|
845
|
+
return ~indexof(value, "stretch") ? prefix(replace(value, "stretch", "fill-available"), length) + value : value;
|
|
846
|
+
}
|
|
847
|
+
break;
|
|
848
|
+
// position: sticky
|
|
849
|
+
case 4949:
|
|
850
|
+
// (s)ticky?
|
|
851
|
+
if (charat(value, length + 1) !== 115) break;
|
|
852
|
+
// display: (flex|inline-flex)
|
|
853
|
+
case 6444:
|
|
854
|
+
switch(charat(value, strlen(value) - 3 - (~indexof(value, "!important") && 10))){
|
|
855
|
+
// stic(k)y
|
|
856
|
+
case 107:
|
|
857
|
+
return replace(value, ":", ":" + WEBKIT) + value;
|
|
858
|
+
// (inline-)?fl(e)x
|
|
859
|
+
case 101:
|
|
860
|
+
return replace(value, /(.+:)([^;!]+)(;|!.+)?/, "$1" + WEBKIT + (charat(value, 14) === 45 ? "inline-" : "") + "box$3" + "$1" + WEBKIT + "$2$3" + "$1" + MS + "$2box$3") + value;
|
|
861
|
+
}
|
|
862
|
+
break;
|
|
863
|
+
// writing-mode
|
|
864
|
+
case 5936:
|
|
865
|
+
switch(charat(value, length + 11)){
|
|
866
|
+
// vertical-l(r)
|
|
867
|
+
case 114:
|
|
868
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb") + value;
|
|
869
|
+
// vertical-r(l)
|
|
870
|
+
case 108:
|
|
871
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "tb-rl") + value;
|
|
872
|
+
// horizontal(-)tb
|
|
873
|
+
case 45:
|
|
874
|
+
return WEBKIT + value + MS + replace(value, /[svh]\w+-[tblr]{2}/, "lr") + value;
|
|
875
|
+
}
|
|
876
|
+
return WEBKIT + value + MS + value + value;
|
|
877
|
+
}
|
|
878
|
+
return value;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* @param {object[]} children
|
|
883
|
+
* @param {function} callback
|
|
884
|
+
* @return {string}
|
|
885
|
+
*/ function serialize(children, callback) {
|
|
886
|
+
var output = "";
|
|
887
|
+
var length = sizeof(children);
|
|
888
|
+
for(var i = 0; i < length; i++)output += callback(children[i], i, children, callback) || "";
|
|
889
|
+
return output;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* @param {object} element
|
|
893
|
+
* @param {number} index
|
|
894
|
+
* @param {object[]} children
|
|
895
|
+
* @param {function} callback
|
|
896
|
+
* @return {string}
|
|
897
|
+
*/ function stringify(element, index, children, callback) {
|
|
898
|
+
switch(element.type){
|
|
899
|
+
case IMPORT:
|
|
900
|
+
case DECLARATION:
|
|
901
|
+
return element.return = element.return || element.value;
|
|
902
|
+
case COMMENT:
|
|
903
|
+
return "";
|
|
904
|
+
case KEYFRAMES:
|
|
905
|
+
return element.return = element.value + "{" + serialize(element.children, callback) + "}";
|
|
906
|
+
case RULESET:
|
|
907
|
+
element.value = element.props.join(",");
|
|
908
|
+
}
|
|
909
|
+
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* @param {function[]} collection
|
|
914
|
+
* @return {function}
|
|
915
|
+
*/ function middleware(collection) {
|
|
916
|
+
var length = sizeof(collection);
|
|
917
|
+
return function(element, index, children, callback) {
|
|
918
|
+
var output = "";
|
|
919
|
+
for(var i = 0; i < length; i++)output += collection[i](element, index, children, callback) || "";
|
|
920
|
+
return output;
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* @param {function} callback
|
|
925
|
+
* @return {function}
|
|
926
|
+
*/ function rulesheet(callback) {
|
|
927
|
+
return function(element) {
|
|
928
|
+
if (!element.root) {
|
|
929
|
+
if (element = element.return) callback(element);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* @param {object} element
|
|
935
|
+
* @param {number} index
|
|
936
|
+
* @param {object[]} children
|
|
937
|
+
* @param {function} callback
|
|
938
|
+
*/ function prefixer(element, index, children, callback) {
|
|
939
|
+
if (element.length > -1) {
|
|
940
|
+
if (!element.return) switch(element.type){
|
|
941
|
+
case DECLARATION:
|
|
942
|
+
element.return = prefix(element.value, element.length);
|
|
943
|
+
break;
|
|
944
|
+
case KEYFRAMES:
|
|
945
|
+
return serialize([
|
|
946
|
+
copy(element, {
|
|
947
|
+
value: replace(element.value, "@", "@" + WEBKIT)
|
|
948
|
+
})
|
|
949
|
+
], callback);
|
|
950
|
+
case RULESET:
|
|
951
|
+
if (element.length) return combine(element.props, function(value) {
|
|
952
|
+
switch(match(value, /(::plac\w+|:read-\w+)/)){
|
|
953
|
+
// :read-(only|write)
|
|
954
|
+
case ":read-only":
|
|
955
|
+
case ":read-write":
|
|
956
|
+
return serialize([
|
|
957
|
+
copy(element, {
|
|
958
|
+
props: [
|
|
959
|
+
replace(value, /:(read-\w+)/, ":" + MOZ + "$1")
|
|
960
|
+
]
|
|
961
|
+
})
|
|
962
|
+
], callback);
|
|
963
|
+
// :placeholder
|
|
964
|
+
case "::placeholder":
|
|
965
|
+
return serialize([
|
|
966
|
+
copy(element, {
|
|
967
|
+
props: [
|
|
968
|
+
replace(value, /:(plac\w+)/, ":" + WEBKIT + "input-$1")
|
|
969
|
+
]
|
|
970
|
+
}),
|
|
971
|
+
copy(element, {
|
|
972
|
+
props: [
|
|
973
|
+
replace(value, /:(plac\w+)/, ":" + MOZ + "$1")
|
|
974
|
+
]
|
|
975
|
+
}),
|
|
976
|
+
copy(element, {
|
|
977
|
+
props: [
|
|
978
|
+
replace(value, /:(plac\w+)/, MS + "input-$1")
|
|
979
|
+
]
|
|
980
|
+
})
|
|
981
|
+
], callback);
|
|
982
|
+
}
|
|
983
|
+
return "";
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
var weakMemoize = function weakMemoize(func) {
|
|
990
|
+
// $FlowFixMe flow doesn't include all non-primitive types as allowed for weakmaps
|
|
991
|
+
var cache = new WeakMap();
|
|
992
|
+
return function(arg) {
|
|
993
|
+
if (cache.has(arg)) {
|
|
994
|
+
// $FlowFixMe
|
|
995
|
+
return cache.get(arg);
|
|
996
|
+
}
|
|
997
|
+
var ret = func(arg);
|
|
998
|
+
cache.set(arg, ret);
|
|
999
|
+
return ret;
|
|
1000
|
+
};
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
function memoize(fn) {
|
|
1004
|
+
var cache = {};
|
|
1005
|
+
return function(arg) {
|
|
1006
|
+
if (cache[arg] === undefined) cache[arg] = fn(arg);
|
|
1007
|
+
return cache[arg];
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
var last = function last(arr) {
|
|
1012
|
+
return arr.length ? arr[arr.length - 1] : null;
|
|
1013
|
+
}; // based on https://github.com/thysultan/stylis.js/blob/e6843c373ebcbbfade25ebcc23f540ed8508da0a/src/Tokenizer.js#L239-L244
|
|
1014
|
+
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
|
|
1015
|
+
var previous = 0;
|
|
1016
|
+
var character = 0;
|
|
1017
|
+
while(true){
|
|
1018
|
+
previous = character;
|
|
1019
|
+
character = peek(); // &\f
|
|
1020
|
+
if (previous === 38 && character === 12) {
|
|
1021
|
+
points[index] = 1;
|
|
1022
|
+
}
|
|
1023
|
+
if (token(character)) {
|
|
1024
|
+
break;
|
|
1025
|
+
}
|
|
1026
|
+
next();
|
|
1027
|
+
}
|
|
1028
|
+
return slice(begin, position);
|
|
1029
|
+
};
|
|
1030
|
+
var toRules = function toRules(parsed, points) {
|
|
1031
|
+
// pretend we've started with a comma
|
|
1032
|
+
var index = -1;
|
|
1033
|
+
var character = 44;
|
|
1034
|
+
do {
|
|
1035
|
+
switch(token(character)){
|
|
1036
|
+
case 0:
|
|
1037
|
+
// &\f
|
|
1038
|
+
if (character === 38 && peek() === 12) {
|
|
1039
|
+
// this is not 100% correct, we don't account for literal sequences here - like for example quoted strings
|
|
1040
|
+
// stylis inserts \f after & to know when & where it should replace this sequence with the context selector
|
|
1041
|
+
// and when it should just concatenate the outer and inner selectors
|
|
1042
|
+
// it's very unlikely for this sequence to actually appear in a different context, so we just leverage this fact here
|
|
1043
|
+
points[index] = 1;
|
|
1044
|
+
}
|
|
1045
|
+
parsed[index] += identifierWithPointTracking(position - 1, points, index);
|
|
1046
|
+
break;
|
|
1047
|
+
case 2:
|
|
1048
|
+
parsed[index] += delimit(character);
|
|
1049
|
+
break;
|
|
1050
|
+
case 4:
|
|
1051
|
+
// comma
|
|
1052
|
+
if (character === 44) {
|
|
1053
|
+
// colon
|
|
1054
|
+
parsed[++index] = peek() === 58 ? "&\f" : "";
|
|
1055
|
+
points[index] = parsed[index].length;
|
|
1056
|
+
break;
|
|
1057
|
+
}
|
|
1058
|
+
// fallthrough
|
|
1059
|
+
default:
|
|
1060
|
+
parsed[index] += from(character);
|
|
1061
|
+
}
|
|
1062
|
+
}while (character = next());
|
|
1063
|
+
return parsed;
|
|
1064
|
+
};
|
|
1065
|
+
var getRules = function getRules(value, points) {
|
|
1066
|
+
return dealloc(toRules(alloc(value), points));
|
|
1067
|
+
}; // WeakSet would be more appropriate, but only WeakMap is supported in IE11
|
|
1068
|
+
var fixedElements = /* #__PURE__ */ new WeakMap();
|
|
1069
|
+
var compat = function compat(element) {
|
|
1070
|
+
if (element.type !== "rule" || !element.parent || // negative .length indicates that this rule has been already prefixed
|
|
1071
|
+
element.length < 1) {
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
var value = element.value, parent = element.parent;
|
|
1075
|
+
var isImplicitRule = element.column === parent.column && element.line === parent.line;
|
|
1076
|
+
while(parent.type !== "rule"){
|
|
1077
|
+
parent = parent.parent;
|
|
1078
|
+
if (!parent) return;
|
|
1079
|
+
} // short-circuit for the simplest case
|
|
1080
|
+
if (element.props.length === 1 && value.charCodeAt(0) !== 58 && !fixedElements.get(parent)) {
|
|
1081
|
+
return;
|
|
1082
|
+
} // if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
|
|
1083
|
+
// then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent"
|
|
1084
|
+
if (isImplicitRule) {
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
fixedElements.set(element, true);
|
|
1088
|
+
var points = [];
|
|
1089
|
+
var rules = getRules(value, points);
|
|
1090
|
+
var parentRules = parent.props;
|
|
1091
|
+
for(var i = 0, k = 0; i < rules.length; i++){
|
|
1092
|
+
for(var j = 0; j < parentRules.length; j++, k++){
|
|
1093
|
+
element.props[k] = points[i] ? rules[i].replace(/&\f/g, parentRules[j]) : parentRules[j] + " " + rules[i];
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
var removeLabel = function removeLabel(element) {
|
|
1098
|
+
if (element.type === "decl") {
|
|
1099
|
+
var value = element.value;
|
|
1100
|
+
if (value.charCodeAt(0) === 108 && value.charCodeAt(2) === 98) {
|
|
1101
|
+
// this ignores label
|
|
1102
|
+
element["return"] = "";
|
|
1103
|
+
element.value = "";
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
var ignoreFlag = "emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason";
|
|
1108
|
+
var isIgnoringComment = function isIgnoringComment(element) {
|
|
1109
|
+
return !!element && element.type === "comm" && element.children.indexOf(ignoreFlag) > -1;
|
|
1110
|
+
};
|
|
1111
|
+
var createUnsafeSelectorsAlarm = function createUnsafeSelectorsAlarm(cache) {
|
|
1112
|
+
return function(element, index, children) {
|
|
1113
|
+
if (element.type !== "rule") return;
|
|
1114
|
+
var unsafePseudoClasses = element.value.match(/(:first|:nth|:nth-last)-child/g);
|
|
1115
|
+
if (unsafePseudoClasses && cache.compat !== true) {
|
|
1116
|
+
var prevElement = index > 0 ? children[index - 1] : null;
|
|
1117
|
+
if (prevElement && isIgnoringComment(last(prevElement.children))) {
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
unsafePseudoClasses.forEach(function(unsafePseudoClass) {
|
|
1121
|
+
console.error('The pseudo class "' + unsafePseudoClass + '" is potentially unsafe when doing server-side rendering. Try changing it to "' + unsafePseudoClass.split("-child")[0] + '-of-type".');
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
var isImportRule = function isImportRule(element) {
|
|
1127
|
+
return element.type.charCodeAt(1) === 105 && element.type.charCodeAt(0) === 64;
|
|
1128
|
+
};
|
|
1129
|
+
var isPrependedWithRegularRules = function isPrependedWithRegularRules(index, children) {
|
|
1130
|
+
for(var i = index - 1; i >= 0; i--){
|
|
1131
|
+
if (!isImportRule(children[i])) {
|
|
1132
|
+
return true;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return false;
|
|
1136
|
+
}; // use this to remove incorrect elements from further processing
|
|
1137
|
+
// so they don't get handed to the `sheet` (or anything else)
|
|
1138
|
+
// as that could potentially lead to additional logs which in turn could be overhelming to the user
|
|
1139
|
+
var nullifyElement = function nullifyElement(element) {
|
|
1140
|
+
element.type = "";
|
|
1141
|
+
element.value = "";
|
|
1142
|
+
element["return"] = "";
|
|
1143
|
+
element.children = "";
|
|
1144
|
+
element.props = "";
|
|
1145
|
+
};
|
|
1146
|
+
var incorrectImportAlarm = function incorrectImportAlarm(element, index, children) {
|
|
1147
|
+
if (!isImportRule(element)) {
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
if (element.parent) {
|
|
1151
|
+
console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles.");
|
|
1152
|
+
nullifyElement(element);
|
|
1153
|
+
} else if (isPrependedWithRegularRules(index, children)) {
|
|
1154
|
+
console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.");
|
|
1155
|
+
nullifyElement(element);
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
var isBrowser = typeof document !== "undefined";
|
|
1159
|
+
var getServerStylisCache = isBrowser ? undefined : weakMemoize(function() {
|
|
1160
|
+
return memoize(function() {
|
|
1161
|
+
var cache = {};
|
|
1162
|
+
return function(name) {
|
|
1163
|
+
return cache[name];
|
|
1164
|
+
};
|
|
1165
|
+
});
|
|
1166
|
+
});
|
|
1167
|
+
var defaultStylisPlugins = [
|
|
1168
|
+
prefixer
|
|
1169
|
+
];
|
|
1170
|
+
var createCache = function createCache(options) {
|
|
1171
|
+
var key = options.key;
|
|
1172
|
+
if (process.env.NODE_ENV !== "production" && !key) {
|
|
1173
|
+
throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\n" + 'If multiple caches share the same key they might "fight" for each other\'s style elements.');
|
|
1174
|
+
}
|
|
1175
|
+
if (isBrowser && key === "css") {
|
|
1176
|
+
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
|
|
1177
|
+
// document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
|
|
1178
|
+
// note this very very intentionally targets all style elements regardless of the key to ensure
|
|
1179
|
+
// that creating a cache works inside of render of a React component
|
|
1180
|
+
Array.prototype.forEach.call(ssrStyles, function(node) {
|
|
1181
|
+
// we want to only move elements which have a space in the data-emotion attribute value
|
|
1182
|
+
// because that indicates that it is an Emotion 11 server-side rendered style elements
|
|
1183
|
+
// while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
|
|
1184
|
+
// Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
|
|
1185
|
+
// so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
|
|
1186
|
+
// will not result in the Emotion 10 styles being destroyed
|
|
1187
|
+
var dataEmotionAttribute = node.getAttribute("data-emotion");
|
|
1188
|
+
if (dataEmotionAttribute.indexOf(" ") === -1) {
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
document.head.appendChild(node);
|
|
1192
|
+
node.setAttribute("data-s", "");
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
|
|
1196
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1197
|
+
// $FlowFixMe
|
|
1198
|
+
if (/[^a-z-]/.test(key)) {
|
|
1199
|
+
throw new Error('Emotion key must only contain lower case alphabetical characters and - but "' + key + '" was passed');
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
var inserted = {}; // $FlowFixMe
|
|
1203
|
+
var container;
|
|
1204
|
+
var nodesToHydrate = [];
|
|
1205
|
+
if (isBrowser) {
|
|
1206
|
+
container = options.container || document.head;
|
|
1207
|
+
Array.prototype.forEach.call(// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
|
|
1208
|
+
document.querySelectorAll('style[data-emotion^="' + key + ' "]'), function(node) {
|
|
1209
|
+
var attrib = node.getAttribute("data-emotion").split(" "); // $FlowFixMe
|
|
1210
|
+
for(var i = 1; i < attrib.length; i++){
|
|
1211
|
+
inserted[attrib[i]] = true;
|
|
1212
|
+
}
|
|
1213
|
+
nodesToHydrate.push(node);
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
var _insert;
|
|
1217
|
+
var omnipresentPlugins = [
|
|
1218
|
+
compat,
|
|
1219
|
+
removeLabel
|
|
1220
|
+
];
|
|
1221
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1222
|
+
omnipresentPlugins.push(createUnsafeSelectorsAlarm({
|
|
1223
|
+
get compat () {
|
|
1224
|
+
return cache.compat;
|
|
1225
|
+
}
|
|
1226
|
+
}), incorrectImportAlarm);
|
|
1227
|
+
}
|
|
1228
|
+
if (isBrowser) {
|
|
1229
|
+
var currentSheet;
|
|
1230
|
+
var finalizingPlugins = [
|
|
1231
|
+
stringify,
|
|
1232
|
+
process.env.NODE_ENV !== "production" ? function(element) {
|
|
1233
|
+
if (!element.root) {
|
|
1234
|
+
if (element["return"]) {
|
|
1235
|
+
currentSheet.insert(element["return"]);
|
|
1236
|
+
} else if (element.value && element.type !== COMMENT) {
|
|
1237
|
+
// insert empty rule in non-production environments
|
|
1238
|
+
// so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet
|
|
1239
|
+
currentSheet.insert(element.value + "{}");
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
} : rulesheet(function(rule) {
|
|
1243
|
+
currentSheet.insert(rule);
|
|
1244
|
+
})
|
|
1245
|
+
];
|
|
1246
|
+
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
|
|
1247
|
+
var stylis = function stylis(styles) {
|
|
1248
|
+
return serialize(compile(styles), serializer);
|
|
1249
|
+
};
|
|
1250
|
+
_insert = function insert(selector, serialized, sheet, shouldCache) {
|
|
1251
|
+
currentSheet = sheet;
|
|
1252
|
+
if (process.env.NODE_ENV !== "production" && serialized.map !== undefined) {
|
|
1253
|
+
currentSheet = {
|
|
1254
|
+
insert: function insert(rule) {
|
|
1255
|
+
sheet.insert(rule + serialized.map);
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
|
1260
|
+
if (shouldCache) {
|
|
1261
|
+
cache.inserted[serialized.name] = true;
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
} else {
|
|
1265
|
+
var _finalizingPlugins = [
|
|
1266
|
+
stringify
|
|
1267
|
+
];
|
|
1268
|
+
var _serializer = middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
|
|
1269
|
+
var _stylis = function _stylis(styles) {
|
|
1270
|
+
return serialize(compile(styles), _serializer);
|
|
1271
|
+
}; // $FlowFixMe
|
|
1272
|
+
var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
|
|
1273
|
+
var getRules1 = function getRules(selector, serialized) {
|
|
1274
|
+
var name = serialized.name;
|
|
1275
|
+
if (serverStylisCache[name] === undefined) {
|
|
1276
|
+
serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
|
1277
|
+
}
|
|
1278
|
+
return serverStylisCache[name];
|
|
1279
|
+
};
|
|
1280
|
+
_insert = function _insert(selector, serialized, sheet, shouldCache) {
|
|
1281
|
+
var name = serialized.name;
|
|
1282
|
+
var rules = getRules1(selector, serialized);
|
|
1283
|
+
if (cache.compat === undefined) {
|
|
1284
|
+
// in regular mode, we don't set the styles on the inserted cache
|
|
1285
|
+
// since we don't need to and that would be wasting memory
|
|
1286
|
+
// we return them so that they are rendered in a style tag
|
|
1287
|
+
if (shouldCache) {
|
|
1288
|
+
cache.inserted[name] = true;
|
|
1289
|
+
}
|
|
1290
|
+
if (// because if people do ssr in tests, the source maps showing up would be annoying
|
|
1291
|
+
process.env.NODE_ENV === "development" && serialized.map !== undefined) {
|
|
1292
|
+
return rules + serialized.map;
|
|
1293
|
+
}
|
|
1294
|
+
return rules;
|
|
1295
|
+
} else {
|
|
1296
|
+
// in compat mode, we put the styles on the inserted cache so
|
|
1297
|
+
// that emotion-server can pull out the styles
|
|
1298
|
+
// except when we don't want to cache it which was in Global but now
|
|
1299
|
+
// is nowhere but we don't want to do a major right now
|
|
1300
|
+
// and just in case we're going to leave the case here
|
|
1301
|
+
// it's also not affecting client side bundle size
|
|
1302
|
+
// so it's really not a big deal
|
|
1303
|
+
if (shouldCache) {
|
|
1304
|
+
cache.inserted[name] = rules;
|
|
1305
|
+
} else {
|
|
1306
|
+
return rules;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
}
|
|
1311
|
+
var cache = {
|
|
1312
|
+
key: key,
|
|
1313
|
+
sheet: new StyleSheet1({
|
|
1314
|
+
key: key,
|
|
1315
|
+
container: container,
|
|
1316
|
+
nonce: options.nonce,
|
|
1317
|
+
speedy: options.speedy,
|
|
1318
|
+
prepend: options.prepend,
|
|
1319
|
+
insertionPoint: options.insertionPoint
|
|
1320
|
+
}),
|
|
1321
|
+
nonce: options.nonce,
|
|
1322
|
+
inserted: inserted,
|
|
1323
|
+
registered: {},
|
|
1324
|
+
insert: _insert
|
|
1325
|
+
};
|
|
1326
|
+
cache.sheet.hydrate(nodesToHydrate);
|
|
1327
|
+
return cache;
|
|
1328
|
+
};
|
|
1329
|
+
var createCache$1 = createCache;
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* prepend: true moves MUI styles to the top of the <head> so they're loaded first.
|
|
1333
|
+
* It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
|
|
1334
|
+
*/ function createEmotionCache() {
|
|
1335
|
+
return createCache$1({
|
|
1336
|
+
key: "css",
|
|
1337
|
+
prepend: true
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
function _taggedTemplateLiteral(strings, raw) {
|
|
1342
|
+
if (!raw) {
|
|
1343
|
+
raw = strings.slice(0);
|
|
1344
|
+
}
|
|
1345
|
+
return Object.freeze(Object.defineProperties(strings, {
|
|
1346
|
+
raw: {
|
|
1347
|
+
value: Object.freeze(raw)
|
|
1348
|
+
}
|
|
1349
|
+
}));
|
|
1350
|
+
}
|
|
1351
|
+
function _templateObject() {
|
|
1352
|
+
var data = _taggedTemplateLiteral([
|
|
1353
|
+
"\n ",
|
|
1354
|
+
"\n "
|
|
1355
|
+
]);
|
|
1356
|
+
_templateObject = function _templateObject() {
|
|
1357
|
+
return data;
|
|
1358
|
+
};
|
|
1359
|
+
return data;
|
|
1360
|
+
}
|
|
1361
|
+
// client-side cache, shared for the whole session of the user in the browser.
|
|
1362
|
+
var clientSideEmotionCache = createEmotionCache();
|
|
1363
|
+
/**
|
|
1364
|
+
* App theme with `emotion` (good for `@mui`)s
|
|
1365
|
+
*/ var AppThemeEmotion = function(param) {
|
|
1366
|
+
var _emotionCache = param.emotionCache, emotionCache = _emotionCache === void 0 ? clientSideEmotionCache : _emotionCache, theme = param.theme, children = param.children;
|
|
1367
|
+
return /*#__PURE__*/ React.createElement(CacheProvider, {
|
|
1368
|
+
value: emotionCache
|
|
1369
|
+
}, /*#__PURE__*/ React.createElement(ThemeProvider$1, {
|
|
1370
|
+
theme: theme
|
|
1371
|
+
}, /*#__PURE__*/ React.createElement(CssBaseline, null), /*#__PURE__*/ React.createElement(Global, {
|
|
1372
|
+
styles: css(_templateObject(), stylesGlobal)
|
|
1373
|
+
}), children));
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
function _extends$d() {
|
|
1377
|
+
_extends$d = Object.assign || function(target) {
|
|
1378
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1379
|
+
var source = arguments[i];
|
|
1380
|
+
for(var key in source){
|
|
1381
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1382
|
+
target[key] = source[key];
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
return target;
|
|
1387
|
+
};
|
|
1388
|
+
return _extends$d.apply(this, arguments);
|
|
1389
|
+
}
|
|
1390
|
+
var defaults = {
|
|
1391
|
+
tplTitle: ""
|
|
1392
|
+
};
|
|
1393
|
+
/**
|
|
1394
|
+
* We do a couple of things in addition while many other are removed.
|
|
1395
|
+
*
|
|
1396
|
+
* - Add `seo` meta object coming from a CMS probably
|
|
1397
|
+
* - Add `ogimage` and `openGraph.image` as single image source
|
|
1398
|
+
* - Add `og` alias to define `openGraph`
|
|
1399
|
+
* - Add check for `title` equale to `templateTitle` to avoid meta titles like
|
|
1400
|
+
* "My site | My site" often happening in homepages
|
|
1401
|
+
* - Remove the open graph videos and images
|
|
1402
|
+
*
|
|
1403
|
+
* - Shorter code
|
|
1404
|
+
*
|
|
1405
|
+
* @returns
|
|
1406
|
+
*/ var buildTags = function() {
|
|
1407
|
+
var ref2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, seo = ref2.seo, hidden = ref2.hidden, keywords = ref2.keywords, _title = ref2.title, title = _title === void 0 ? "" : _title, titleTemplate = ref2.titleTemplate, defaultTitle = ref2.defaultTitle, noindex = ref2.noindex, nofollow = ref2.nofollow, description = ref2.description, _languageAlternates = ref2.languageAlternates, languageAlternates = _languageAlternates === void 0 ? [] : _languageAlternates, twitter = ref2.twitter, facebook = ref2.facebook, openGraph = ref2.openGraph, ogAlias = ref2.og, canonical = ref2.canonical, metaTags = ref2.metaTags, linkTags = ref2.linkTags;
|
|
1408
|
+
var render = [];
|
|
1409
|
+
var $names = {};
|
|
1410
|
+
var $properties = {};
|
|
1411
|
+
if (titleTemplate) {
|
|
1412
|
+
defaults.tplTitle = titleTemplate;
|
|
1413
|
+
}
|
|
1414
|
+
title = title || (seo === null || seo === void 0 ? void 0 : seo.title) || "";
|
|
1415
|
+
if (title) {
|
|
1416
|
+
if (defaults.tplTitle && defaults.tplTitle !== title) {
|
|
1417
|
+
title = defaults.tplTitle.replace(/%s/g, title);
|
|
1418
|
+
}
|
|
1419
|
+
} else if (defaultTitle) {
|
|
1420
|
+
title = defaultTitle;
|
|
1421
|
+
}
|
|
1422
|
+
if (title) {
|
|
1423
|
+
render.push(/*#__PURE__*/ React.createElement("title", {
|
|
1424
|
+
key: "title"
|
|
1425
|
+
}, title));
|
|
1426
|
+
$properties["og:title"] = title; // overridden later...
|
|
1427
|
+
}
|
|
1428
|
+
$names["robots"] = "".concat(noindex || hidden ? "noindex" : "index", ",").concat(nofollow || hidden ? "nofollow" : "follow");
|
|
1429
|
+
description = description || (seo === null || seo === void 0 ? void 0 : seo.description);
|
|
1430
|
+
if (description) {
|
|
1431
|
+
$names["description"] = description;
|
|
1432
|
+
$properties["og:description"] = description; // overridden later...
|
|
1433
|
+
}
|
|
1434
|
+
keywords = keywords || (seo === null || seo === void 0 ? void 0 : seo.keywords);
|
|
1435
|
+
if (keywords) {
|
|
1436
|
+
$names["keywords"] = isArray(keywords) ? keywords.join(", ") : keywords;
|
|
1437
|
+
}
|
|
1438
|
+
if ((languageAlternates === null || languageAlternates === void 0 ? void 0 : languageAlternates.length) > 0) {
|
|
1439
|
+
languageAlternates.forEach(function(languageAlternate) {
|
|
1440
|
+
render.push(/*#__PURE__*/ React.createElement("link", {
|
|
1441
|
+
rel: "alternate",
|
|
1442
|
+
key: "languageAlternate-".concat(languageAlternate.hrefLang),
|
|
1443
|
+
hrefLang: languageAlternate.hrefLang,
|
|
1444
|
+
href: languageAlternate.href
|
|
1445
|
+
}));
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
if (canonical) {
|
|
1449
|
+
render.push(/*#__PURE__*/ React.createElement("link", {
|
|
1450
|
+
rel: "canonical",
|
|
1451
|
+
href: canonical,
|
|
1452
|
+
key: "canonical"
|
|
1453
|
+
}));
|
|
1454
|
+
$properties["og:url"] = canonical;
|
|
1455
|
+
}
|
|
1456
|
+
if (facebook === null || facebook === void 0 ? void 0 : facebook.appId) $properties["fb:app_id"] = facebook.appId;
|
|
1457
|
+
if (twitter) {
|
|
1458
|
+
if (twitter.cardType) $names["twitter:card"] = twitter.cardType;
|
|
1459
|
+
if (twitter.site) $names["twitter:site"] = twitter.site;
|
|
1460
|
+
if (twitter.handle) $names["twitter:creator"] = twitter.handle;
|
|
1461
|
+
}
|
|
1462
|
+
var og = ogAlias || openGraph;
|
|
1463
|
+
if (og === null || og === void 0 ? void 0 : og.title) $properties["og:title"] = og === null || og === void 0 ? void 0 : og.title;
|
|
1464
|
+
if (og === null || og === void 0 ? void 0 : og.description) $properties["og:description"] = og === null || og === void 0 ? void 0 : og.description;
|
|
1465
|
+
if (og === null || og === void 0 ? void 0 : og.url) $properties["og:url"] = og.url;
|
|
1466
|
+
if (og === null || og === void 0 ? void 0 : og.type) $properties["og:type"] = og.type.toLowerCase();
|
|
1467
|
+
if (og === null || og === void 0 ? void 0 : og.locale) $properties["og:locale"] = og.locale;
|
|
1468
|
+
if (og === null || og === void 0 ? void 0 : og.site_name) $properties["og:site_name"] = og.site_name;
|
|
1469
|
+
var ogimage = (og === null || og === void 0 ? void 0 : og.image) || (seo === null || seo === void 0 ? void 0 : seo.ogimage);
|
|
1470
|
+
if (ogimage) $properties["og:image"] = ogimage;
|
|
1471
|
+
Object.keys($names).forEach(function(key) {
|
|
1472
|
+
render.push(/*#__PURE__*/ React.createElement("meta", {
|
|
1473
|
+
key: key,
|
|
1474
|
+
name: key,
|
|
1475
|
+
content: $names[key]
|
|
1476
|
+
}));
|
|
1477
|
+
});
|
|
1478
|
+
Object.keys($properties).forEach(function(key) {
|
|
1479
|
+
render.push(/*#__PURE__*/ React.createElement("meta", {
|
|
1480
|
+
key: key,
|
|
1481
|
+
property: key,
|
|
1482
|
+
content: $properties[key]
|
|
1483
|
+
}));
|
|
1484
|
+
});
|
|
1485
|
+
if (metaTags && metaTags.length > 0) {
|
|
1486
|
+
metaTags.forEach(function(tag) {
|
|
1487
|
+
var _keyOverride, ref, ref1;
|
|
1488
|
+
render.push(/*#__PURE__*/ React.createElement("meta", _extends$d({
|
|
1489
|
+
key: "meta:".concat((ref1 = (ref = (_keyOverride = tag.keyOverride) !== null && _keyOverride !== void 0 ? _keyOverride : tag.name) !== null && ref !== void 0 ? ref : tag.property) !== null && ref1 !== void 0 ? ref1 : tag.httpEquiv)
|
|
1490
|
+
}, tag)));
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
if (linkTags === null || linkTags === void 0 ? void 0 : linkTags.length) {
|
|
1494
|
+
linkTags.forEach(function(tag) {
|
|
1495
|
+
var _keyOverride;
|
|
1496
|
+
render.push(/*#__PURE__*/ React.createElement("link", _extends$d({
|
|
1497
|
+
key: "link".concat((_keyOverride = tag.keyOverride) !== null && _keyOverride !== void 0 ? _keyOverride : tag.href).concat(tag.rel)
|
|
1498
|
+
}, tag)));
|
|
1499
|
+
});
|
|
1500
|
+
}
|
|
1501
|
+
// TODO: alternates and canonical
|
|
1502
|
+
// canonical = 'https://www.domain.com/';
|
|
1503
|
+
// languageAlternates={[{
|
|
1504
|
+
// hrefLang: 'en',
|
|
1505
|
+
// href: 'https://www.domain.com/en',
|
|
1506
|
+
// }]}
|
|
1507
|
+
// <link rel="alternate" hreflang="x-default" href="https://www.domain.com/nl/">
|
|
1508
|
+
// <link rel="alternate" hreflang="nl" href="https://www.domain.com/nl/">
|
|
1509
|
+
// <link rel="alternate" hreflang="en" href="https://www.domain.com/en/">
|
|
1510
|
+
return render;
|
|
1511
|
+
};
|
|
1512
|
+
|
|
1513
|
+
var _Seo = function(props) {
|
|
1514
|
+
return /*#__PURE__*/ React.createElement(Head, null, buildTags(props));
|
|
1515
|
+
};
|
|
1516
|
+
var Seo = /*#__PURE__*/ memo(_Seo);
|
|
1517
|
+
|
|
1518
|
+
var _SeoDefaults = function(props) {
|
|
1519
|
+
// const router = useRouter();
|
|
1520
|
+
// props.openGraph.url = getSiteUrl(router.asPath);
|
|
1521
|
+
return /*#__PURE__*/ React.createElement(Head, null, buildTags(props));
|
|
1522
|
+
};
|
|
1523
|
+
var SeoDefaults = /*#__PURE__*/ memo(_SeoDefaults);
|
|
1524
|
+
|
|
1525
|
+
function _arrayLikeToArray$7(arr, len) {
|
|
1526
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1527
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1528
|
+
return arr2;
|
|
1529
|
+
}
|
|
1530
|
+
function _arrayWithHoles$7(arr) {
|
|
1531
|
+
if (Array.isArray(arr)) return arr;
|
|
1532
|
+
}
|
|
1533
|
+
function _iterableToArrayLimit$7(arr, i) {
|
|
1534
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1535
|
+
if (_i == null) return;
|
|
1536
|
+
var _arr = [];
|
|
1537
|
+
var _n = true;
|
|
1538
|
+
var _d = false;
|
|
1539
|
+
var _s, _e;
|
|
1540
|
+
try {
|
|
1541
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1542
|
+
_arr.push(_s.value);
|
|
1543
|
+
if (i && _arr.length === i) break;
|
|
1544
|
+
}
|
|
1545
|
+
} catch (err) {
|
|
1546
|
+
_d = true;
|
|
1547
|
+
_e = err;
|
|
1548
|
+
} finally{
|
|
1549
|
+
try {
|
|
1550
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1551
|
+
} finally{
|
|
1552
|
+
if (_d) throw _e;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return _arr;
|
|
1556
|
+
}
|
|
1557
|
+
function _nonIterableRest$7() {
|
|
1558
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1559
|
+
}
|
|
1560
|
+
function _slicedToArray$7(arr, i) {
|
|
1561
|
+
return _arrayWithHoles$7(arr) || _iterableToArrayLimit$7(arr, i) || _unsupportedIterableToArray$7(arr, i) || _nonIterableRest$7();
|
|
1562
|
+
}
|
|
1563
|
+
function _unsupportedIterableToArray$7(o, minLen) {
|
|
1564
|
+
if (!o) return;
|
|
1565
|
+
if (typeof o === "string") return _arrayLikeToArray$7(o, minLen);
|
|
1566
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1567
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1568
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1569
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen);
|
|
1570
|
+
}
|
|
1571
|
+
var NextProgress = function(param1) {
|
|
1572
|
+
param1.startAt; var _showOnShallow = param1.showOnShallow, showOnShallow = _showOnShallow === void 0 ? true : _showOnShallow, _stopDelayMs = param1.stopDelayMs, stopDelayMs = _stopDelayMs === void 0 ? 200 : _stopDelayMs;
|
|
1573
|
+
var events = useRouter().events;
|
|
1574
|
+
// const [progress, setProgress] = useState(0);
|
|
1575
|
+
var ref = _slicedToArray$7(useState(false), 2), running = ref[0], setRunning = ref[1];
|
|
1576
|
+
var timer = useRef(null);
|
|
1577
|
+
var routeChangeStart = useCallback(function(_, param) {
|
|
1578
|
+
var shallow = param.shallow;
|
|
1579
|
+
if (!shallow || showOnShallow) {
|
|
1580
|
+
// setProgress(startAt);
|
|
1581
|
+
setRunning(true);
|
|
1582
|
+
}
|
|
1583
|
+
}, [
|
|
1584
|
+
showOnShallow
|
|
1585
|
+
]);
|
|
1586
|
+
var routeChangeEnd = useCallback(function(_, param) {
|
|
1587
|
+
var shallow = param.shallow;
|
|
1588
|
+
if (!shallow || showOnShallow) {
|
|
1589
|
+
if (timer.current) {
|
|
1590
|
+
clearTimeout(timer.current);
|
|
1591
|
+
}
|
|
1592
|
+
timer.current = setTimeout(function() {
|
|
1593
|
+
// setProgress(100);
|
|
1594
|
+
setRunning(false);
|
|
1595
|
+
}, stopDelayMs);
|
|
1596
|
+
}
|
|
1597
|
+
}, [
|
|
1598
|
+
showOnShallow,
|
|
1599
|
+
stopDelayMs,
|
|
1600
|
+
timer
|
|
1601
|
+
]);
|
|
1602
|
+
useEffect(function() {
|
|
1603
|
+
events.on("routeChangeStart", routeChangeStart);
|
|
1604
|
+
events.on("routeChangeComplete", routeChangeEnd);
|
|
1605
|
+
events.on("routeChangeError", routeChangeEnd);
|
|
1606
|
+
return function() {
|
|
1607
|
+
events.off("routeChangeStart", routeChangeStart);
|
|
1608
|
+
events.off("routeChangeComplete", routeChangeEnd);
|
|
1609
|
+
events.off("routeChangeError", routeChangeEnd);
|
|
1610
|
+
};
|
|
1611
|
+
}, [
|
|
1612
|
+
events,
|
|
1613
|
+
routeChangeStart,
|
|
1614
|
+
routeChangeEnd
|
|
1615
|
+
]);
|
|
1616
|
+
return /*#__PURE__*/ React.createElement(ProgressOverlay, {
|
|
1617
|
+
running: running
|
|
1618
|
+
});
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
function _extends$c() {
|
|
1622
|
+
_extends$c = Object.assign || function(target) {
|
|
1623
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1624
|
+
var source = arguments[i];
|
|
1625
|
+
for(var key in source){
|
|
1626
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1627
|
+
target[key] = source[key];
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
return target;
|
|
1632
|
+
};
|
|
1633
|
+
return _extends$c.apply(this, arguments);
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* @see https://www.framer.com/docs/guide-reduce-bundle-size/
|
|
1637
|
+
*/ var loadMotionFeatures = function() {
|
|
1638
|
+
return import('./motion-features.esm.js').then(function(m1) {
|
|
1639
|
+
return m1.default;
|
|
1640
|
+
});
|
|
1641
|
+
};
|
|
1642
|
+
/**
|
|
1643
|
+
* App main
|
|
1644
|
+
*
|
|
1645
|
+
* It implies a setup for `styled-components` and `framer-motion` libraries.
|
|
1646
|
+
*
|
|
1647
|
+
* About the page transition [wallis' blog post](https://wallis.dev/blog/nextjs-page-transitions-with-framer-motion)
|
|
1648
|
+
*/ var AppMain = function(param) {
|
|
1649
|
+
var Component = param.Component, pageProps = param.pageProps, Layout = param.Layout, // theme,
|
|
1650
|
+
seo = param.seo, _transition = param.transition, transition = _transition === void 0 ? {
|
|
1651
|
+
initial: {
|
|
1652
|
+
opacity: 0
|
|
1653
|
+
},
|
|
1654
|
+
animate: {
|
|
1655
|
+
opacity: 1
|
|
1656
|
+
},
|
|
1657
|
+
exit: {
|
|
1658
|
+
opacity: 0
|
|
1659
|
+
}
|
|
1660
|
+
} : _transition, pre = param.pre, post = param.post;
|
|
1661
|
+
var pathname = useRouter().pathname;
|
|
1662
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(SeoDefaults, _extends$c({}, seo)), pre, /*#__PURE__*/ React.createElement(LazyMotion, {
|
|
1663
|
+
features: loadMotionFeatures
|
|
1664
|
+
}, /*#__PURE__*/ React.createElement(NextProgress, null), /*#__PURE__*/ React.createElement(Layout, null, /*#__PURE__*/ React.createElement(AnimatePresence, {
|
|
1665
|
+
exitBeforeEnter: true,
|
|
1666
|
+
initial: false
|
|
1667
|
+
}, /*#__PURE__*/ React.createElement(m.div, _extends$c({
|
|
1668
|
+
key: pathname
|
|
1669
|
+
}, transition), /*#__PURE__*/ React.createElement(Component, _extends$c({}, pageProps, {
|
|
1670
|
+
key: pathname
|
|
1671
|
+
})))))), post);
|
|
1672
|
+
};
|
|
1673
|
+
|
|
1674
|
+
function _extends$b() {
|
|
1675
|
+
_extends$b = Object.assign || function(target) {
|
|
1676
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1677
|
+
var source = arguments[i];
|
|
1678
|
+
for(var key in source){
|
|
1679
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1680
|
+
target[key] = source[key];
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
return target;
|
|
1685
|
+
};
|
|
1686
|
+
return _extends$b.apply(this, arguments);
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* App
|
|
1690
|
+
*/ var AppEmotion = function(props) {
|
|
1691
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(AppHead, null), /*#__PURE__*/ React.createElement(AppThemeEmotion, _extends$b({}, props), /*#__PURE__*/ React.createElement(AppMain, _extends$b({}, props))));
|
|
1692
|
+
};
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* App theme with `styled-components`
|
|
1696
|
+
*/ var AppThemeSc = function(param) {
|
|
1697
|
+
var theme = param.theme, children = param.children;
|
|
1698
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(StylesGlobal, null), /*#__PURE__*/ React.createElement(ThemeProvider$2, {
|
|
1699
|
+
theme: theme
|
|
1700
|
+
}, children));
|
|
1701
|
+
};
|
|
1702
|
+
|
|
1703
|
+
function _extends$a() {
|
|
1704
|
+
_extends$a = Object.assign || function(target) {
|
|
1705
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1706
|
+
var source = arguments[i];
|
|
1707
|
+
for(var key in source){
|
|
1708
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1709
|
+
target[key] = source[key];
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
return target;
|
|
1714
|
+
};
|
|
1715
|
+
return _extends$a.apply(this, arguments);
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* App
|
|
1719
|
+
*/ var AppBase = function(props) {
|
|
1720
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(AppHead, null), /*#__PURE__*/ React.createElement(AppThemeSc, _extends$a({}, props), /*#__PURE__*/ React.createElement(AppMain, _extends$a({}, props))));
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
function _arrayLikeToArray$6(arr, len) {
|
|
1724
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1725
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1726
|
+
return arr2;
|
|
1727
|
+
}
|
|
1728
|
+
function _arrayWithHoles$6(arr) {
|
|
1729
|
+
if (Array.isArray(arr)) return arr;
|
|
1730
|
+
}
|
|
1731
|
+
function _arrayWithoutHoles$1(arr) {
|
|
1732
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$6(arr);
|
|
1733
|
+
}
|
|
1734
|
+
function _extends$9() {
|
|
1735
|
+
_extends$9 = Object.assign || function(target) {
|
|
1736
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1737
|
+
var source = arguments[i];
|
|
1738
|
+
for(var key in source){
|
|
1739
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1740
|
+
target[key] = source[key];
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
return target;
|
|
1745
|
+
};
|
|
1746
|
+
return _extends$9.apply(this, arguments);
|
|
1747
|
+
}
|
|
1748
|
+
function _iterableToArray$1(iter) {
|
|
1749
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1750
|
+
}
|
|
1751
|
+
function _iterableToArrayLimit$6(arr, i) {
|
|
1752
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1753
|
+
if (_i == null) return;
|
|
1754
|
+
var _arr = [];
|
|
1755
|
+
var _n = true;
|
|
1756
|
+
var _d = false;
|
|
1757
|
+
var _s, _e;
|
|
1758
|
+
try {
|
|
1759
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1760
|
+
_arr.push(_s.value);
|
|
1761
|
+
if (i && _arr.length === i) break;
|
|
1762
|
+
}
|
|
1763
|
+
} catch (err) {
|
|
1764
|
+
_d = true;
|
|
1765
|
+
_e = err;
|
|
1766
|
+
} finally{
|
|
1767
|
+
try {
|
|
1768
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1769
|
+
} finally{
|
|
1770
|
+
if (_d) throw _e;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
return _arr;
|
|
1774
|
+
}
|
|
1775
|
+
function _nonIterableRest$6() {
|
|
1776
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1777
|
+
}
|
|
1778
|
+
function _nonIterableSpread$1() {
|
|
1779
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1780
|
+
}
|
|
1781
|
+
function _slicedToArray$6(arr, i) {
|
|
1782
|
+
return _arrayWithHoles$6(arr) || _iterableToArrayLimit$6(arr, i) || _unsupportedIterableToArray$6(arr, i) || _nonIterableRest$6();
|
|
1783
|
+
}
|
|
1784
|
+
function _toConsumableArray$1(arr) {
|
|
1785
|
+
return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$6(arr) || _nonIterableSpread$1();
|
|
1786
|
+
}
|
|
1787
|
+
function _unsupportedIterableToArray$6(o, minLen) {
|
|
1788
|
+
if (!o) return;
|
|
1789
|
+
if (typeof o === "string") return _arrayLikeToArray$6(o, minLen);
|
|
1790
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1791
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1792
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1793
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen);
|
|
1794
|
+
}
|
|
1795
|
+
var THEME_STORAGE_KEY = "theme";
|
|
1796
|
+
var colorSchemes = [
|
|
1797
|
+
"light",
|
|
1798
|
+
"dark"
|
|
1799
|
+
];
|
|
1800
|
+
var MEDIA = "(prefers-color-scheme: dark)";
|
|
1801
|
+
var ThemeContext = /*#__PURE__*/ createContext({
|
|
1802
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
1803
|
+
setTheme: function(_) {},
|
|
1804
|
+
themes: []
|
|
1805
|
+
});
|
|
1806
|
+
var useTheme = function() {
|
|
1807
|
+
return useContext(ThemeContext);
|
|
1808
|
+
};
|
|
1809
|
+
var ThemeProvider = function(param) {
|
|
1810
|
+
var forcedTheme = param.forcedTheme, _disableTransitionOnChange = param.disableTransitionOnChange, disableTransitionOnChange = _disableTransitionOnChange === void 0 ? false : _disableTransitionOnChange, _enableSystem = param.enableSystem, enableSystem = _enableSystem === void 0 ? true : _enableSystem, _enableColorScheme = param.enableColorScheme, enableColorScheme = _enableColorScheme === void 0 ? true : _enableColorScheme, _themes = param.themes, themes = _themes === void 0 ? [
|
|
1811
|
+
"light",
|
|
1812
|
+
"dark"
|
|
1813
|
+
] : _themes, _defaultTheme = param.defaultTheme, defaultTheme = _defaultTheme === void 0 ? enableSystem ? "system" : "light" : _defaultTheme, _attribute = param.attribute, attribute = _attribute === void 0 ? "data-theme" : _attribute, value = param.value, children = param.children, nonce = param.nonce;
|
|
1814
|
+
var ref = _slicedToArray$6(useState(function() {
|
|
1815
|
+
return getTheme(THEME_STORAGE_KEY, defaultTheme);
|
|
1816
|
+
}), 2), theme1 = ref[0], setThemeState = ref[1];
|
|
1817
|
+
var ref1 = _slicedToArray$6(useState(function() {
|
|
1818
|
+
return getTheme(THEME_STORAGE_KEY);
|
|
1819
|
+
}), 2), resolvedTheme = ref1[0], setResolvedTheme = ref1[1];
|
|
1820
|
+
var attrs = !value ? themes : Object.values(value);
|
|
1821
|
+
var applyTheme = useCallback(function(theme) {
|
|
1822
|
+
var resolved = theme;
|
|
1823
|
+
if (isServer) return;
|
|
1824
|
+
// If theme is system, resolve it before setting theme
|
|
1825
|
+
if (theme === "system" && enableSystem) {
|
|
1826
|
+
resolved = getSystemTheme();
|
|
1827
|
+
}
|
|
1828
|
+
var name = value ? value[resolved] : resolved;
|
|
1829
|
+
var enable = disableTransitionOnChange ? disableAnimation() : null;
|
|
1830
|
+
var d = document.documentElement;
|
|
1831
|
+
if (attribute === "class") {
|
|
1832
|
+
var _classList;
|
|
1833
|
+
(_classList = d.classList).remove.apply(_classList, _toConsumableArray$1(attrs));
|
|
1834
|
+
if (name) d.classList.add(name);
|
|
1835
|
+
} else {
|
|
1836
|
+
if (name) {
|
|
1837
|
+
d.setAttribute(attribute, name);
|
|
1838
|
+
} else {
|
|
1839
|
+
d.removeAttribute(attribute);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if (enableColorScheme) {
|
|
1843
|
+
var fallback = colorSchemes.includes(defaultTheme) ? defaultTheme : null;
|
|
1844
|
+
var colorScheme = colorSchemes.includes(resolved) ? resolved : fallback;
|
|
1845
|
+
d.style.colorScheme = colorScheme;
|
|
1846
|
+
}
|
|
1847
|
+
enable === null || enable === void 0 ? void 0 : enable();
|
|
1848
|
+
}, [
|
|
1849
|
+
attribute,
|
|
1850
|
+
attrs,
|
|
1851
|
+
defaultTheme,
|
|
1852
|
+
disableTransitionOnChange,
|
|
1853
|
+
enableColorScheme,
|
|
1854
|
+
enableSystem,
|
|
1855
|
+
value,
|
|
1856
|
+
]);
|
|
1857
|
+
var setTheme = useCallback(function(theme) {
|
|
1858
|
+
setThemeState(theme);
|
|
1859
|
+
// Save to storage
|
|
1860
|
+
try {
|
|
1861
|
+
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
1862
|
+
} catch (e) {
|
|
1863
|
+
// Unsupported
|
|
1864
|
+
}
|
|
1865
|
+
}, []);
|
|
1866
|
+
var handleMediaQuery = useCallback(function(e) {
|
|
1867
|
+
var resolved = getSystemTheme(e);
|
|
1868
|
+
setResolvedTheme(resolved);
|
|
1869
|
+
if (theme1 === "system" && enableSystem && !forcedTheme) {
|
|
1870
|
+
applyTheme("system");
|
|
1871
|
+
}
|
|
1872
|
+
}, [
|
|
1873
|
+
theme1,
|
|
1874
|
+
enableSystem,
|
|
1875
|
+
forcedTheme,
|
|
1876
|
+
applyTheme
|
|
1877
|
+
]);
|
|
1878
|
+
// Always listen to System preference
|
|
1879
|
+
useEffect(function() {
|
|
1880
|
+
var media = window.matchMedia(MEDIA);
|
|
1881
|
+
// Intentionally use deprecated listener methods to support iOS & old browsers
|
|
1882
|
+
media.addListener(handleMediaQuery);
|
|
1883
|
+
handleMediaQuery(media);
|
|
1884
|
+
return function() {
|
|
1885
|
+
return media.removeListener(handleMediaQuery);
|
|
1886
|
+
};
|
|
1887
|
+
}, [
|
|
1888
|
+
handleMediaQuery
|
|
1889
|
+
]);
|
|
1890
|
+
// localStorage event handling
|
|
1891
|
+
useEffect(function() {
|
|
1892
|
+
var handleStorage = function(e) {
|
|
1893
|
+
if (e.key !== THEME_STORAGE_KEY) {
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
// If default theme set, use it if localstorage === null (happens on local storage manual deletion)
|
|
1897
|
+
var theme = e.newValue || defaultTheme;
|
|
1898
|
+
setTheme(theme);
|
|
1899
|
+
};
|
|
1900
|
+
window.addEventListener("storage", handleStorage);
|
|
1901
|
+
return function() {
|
|
1902
|
+
return window.removeEventListener("storage", handleStorage);
|
|
1903
|
+
};
|
|
1904
|
+
}, [
|
|
1905
|
+
defaultTheme,
|
|
1906
|
+
setTheme
|
|
1907
|
+
]);
|
|
1908
|
+
// Whenever theme or forcedTheme changes, apply it
|
|
1909
|
+
useEffect(function() {
|
|
1910
|
+
applyTheme(forcedTheme !== null && forcedTheme !== void 0 ? forcedTheme : theme1);
|
|
1911
|
+
}, [
|
|
1912
|
+
applyTheme,
|
|
1913
|
+
forcedTheme,
|
|
1914
|
+
theme1
|
|
1915
|
+
]);
|
|
1916
|
+
return /*#__PURE__*/ React$1.createElement(ThemeContext.Provider, {
|
|
1917
|
+
value: {
|
|
1918
|
+
theme: theme1,
|
|
1919
|
+
setTheme: setTheme,
|
|
1920
|
+
forcedTheme: forcedTheme,
|
|
1921
|
+
resolvedTheme: theme1 === "system" ? resolvedTheme : theme1,
|
|
1922
|
+
themes: enableSystem ? _toConsumableArray$1(themes).concat([
|
|
1923
|
+
"system"
|
|
1924
|
+
]) : themes,
|
|
1925
|
+
systemTheme: enableSystem ? resolvedTheme : undefined
|
|
1926
|
+
}
|
|
1927
|
+
}, /*#__PURE__*/ React$1.createElement(ThemeScript, _extends$9({}, {
|
|
1928
|
+
forcedTheme: forcedTheme,
|
|
1929
|
+
disableTransitionOnChange: disableTransitionOnChange,
|
|
1930
|
+
enableSystem: enableSystem,
|
|
1931
|
+
enableColorScheme: enableColorScheme,
|
|
1932
|
+
themes: themes,
|
|
1933
|
+
defaultTheme: defaultTheme,
|
|
1934
|
+
attribute: attribute,
|
|
1935
|
+
value: value,
|
|
1936
|
+
children: children,
|
|
1937
|
+
attrs: attrs,
|
|
1938
|
+
nonce: nonce
|
|
1939
|
+
})), children);
|
|
1940
|
+
};
|
|
1941
|
+
var ThemeScript = /*#__PURE__*/ memo(function(param) {
|
|
1942
|
+
var forcedTheme = param.forcedTheme, attribute = param.attribute, enableSystem = param.enableSystem, enableColorScheme = param.enableColorScheme, defaultTheme = param.defaultTheme, value = param.value, attrs = param.attrs, nonce = param.nonce;
|
|
1943
|
+
var defaultSystem = defaultTheme === "system";
|
|
1944
|
+
// Code-golfing the amount of characters in the script
|
|
1945
|
+
var optimization = function() {
|
|
1946
|
+
var removeClasses = "d.remove(".concat(attrs.map(function(t) {
|
|
1947
|
+
return "'".concat(t, "'");
|
|
1948
|
+
}).join(","), ")");
|
|
1949
|
+
return "var d=document.documentElement.classList;".concat(removeClasses, ";");
|
|
1950
|
+
}();
|
|
1951
|
+
var fallbackColorScheme = function() {
|
|
1952
|
+
if (!enableColorScheme) {
|
|
1953
|
+
return "";
|
|
1954
|
+
}
|
|
1955
|
+
var fallback = colorSchemes.includes(defaultTheme) ? defaultTheme : null;
|
|
1956
|
+
if (fallback) {
|
|
1957
|
+
return "if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'".concat(defaultTheme, "'");
|
|
1958
|
+
} else {
|
|
1959
|
+
return "if(e==='light'||e==='dark')d.style.colorScheme=e";
|
|
1960
|
+
}
|
|
1961
|
+
}();
|
|
1962
|
+
var updateDOM = function(name) {
|
|
1963
|
+
var literal = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, setColorScheme = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
1964
|
+
var resolvedName = value ? value[name] : name;
|
|
1965
|
+
var val = literal ? name + "|| ''" : "'".concat(resolvedName, "'");
|
|
1966
|
+
var text = "";
|
|
1967
|
+
// MUCH faster to set colorScheme alongside HTML attribute/class
|
|
1968
|
+
// as it only incurs 1 style recalculation rather than 2
|
|
1969
|
+
// This can save over 250ms of work for pages with big DOM
|
|
1970
|
+
if (enableColorScheme && setColorScheme && !literal && colorSchemes.includes(name)) {
|
|
1971
|
+
text += "d.style.colorScheme = '".concat(name, "';");
|
|
1972
|
+
}
|
|
1973
|
+
if (attribute === "class") {
|
|
1974
|
+
if (literal || resolvedName) {
|
|
1975
|
+
text += "d.add(".concat(val, ")");
|
|
1976
|
+
} else {
|
|
1977
|
+
text += "null";
|
|
1978
|
+
}
|
|
1979
|
+
} else {
|
|
1980
|
+
if (resolvedName) {
|
|
1981
|
+
text += "d[s](n, ".concat(val, ")");
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
return text;
|
|
1985
|
+
};
|
|
1986
|
+
var scriptSrc = function() {
|
|
1987
|
+
if (forcedTheme) {
|
|
1988
|
+
return "!function(){".concat(optimization).concat(updateDOM(forcedTheme), "}()");
|
|
1989
|
+
}
|
|
1990
|
+
if (enableSystem) {
|
|
1991
|
+
return "!function(){try {".concat(optimization, "var e=localStorage.getItem('").concat(THEME_STORAGE_KEY, '\');if("system"===e||(!e&&').concat(defaultSystem, ')){var t="').concat(MEDIA, '",m=window.matchMedia(t);if(m.media!==t||m.matches){').concat(updateDOM("dark"), "}else{").concat(updateDOM("light"), "}}else if(e){").concat(value ? "var x=".concat(JSON.stringify(value), ";") : "").concat(updateDOM(value ? "x[e]" : "e", true), "}").concat(!defaultSystem ? "else{" + updateDOM(defaultTheme, false, false) + "}" : "").concat(fallbackColorScheme, "}catch(e){}}()");
|
|
1992
|
+
}
|
|
1993
|
+
return "!function(){try{".concat(optimization, 'var e=localStorage.getItem("').concat(THEME_STORAGE_KEY, '");if(e){').concat(value ? "var x=".concat(JSON.stringify(value), ";") : "").concat(updateDOM(value ? "x[e]" : "e", true), "}else{").concat(updateDOM(defaultTheme, false, false), ";}").concat(fallbackColorScheme, "}catch(t){}}();");
|
|
1994
|
+
}();
|
|
1995
|
+
// We MUST use next/script's `beforeInteractive` strategy to avoid flashing on load.
|
|
1996
|
+
// However, it only accepts the `src` prop, not `dangerouslySetInnerHTML` or `children`
|
|
1997
|
+
// But our script cannot be external because it changes at runtime based on React props
|
|
1998
|
+
// so we trick next/script by passing `src` as a base64 JS script
|
|
1999
|
+
var encodedScript = "data:text/javascript;base64,".concat(encodeBase64(scriptSrc));
|
|
2000
|
+
return /*#__PURE__*/ React$1.createElement(Script, {
|
|
2001
|
+
id: "next-theme-script",
|
|
2002
|
+
strategy: "beforeInteractive",
|
|
2003
|
+
src: encodedScript,
|
|
2004
|
+
nonce: nonce
|
|
2005
|
+
});
|
|
2006
|
+
}, // Never re-render this component
|
|
2007
|
+
function() {
|
|
2008
|
+
return true;
|
|
2009
|
+
});
|
|
2010
|
+
// Helpers
|
|
2011
|
+
var getTheme = function(key, fallback) {
|
|
2012
|
+
if (isServer) return undefined;
|
|
2013
|
+
var theme;
|
|
2014
|
+
try {
|
|
2015
|
+
theme = localStorage.getItem(key) || undefined;
|
|
2016
|
+
} catch (e) {
|
|
2017
|
+
// Unsupported
|
|
2018
|
+
}
|
|
2019
|
+
return theme || fallback;
|
|
2020
|
+
};
|
|
2021
|
+
var disableAnimation = function() {
|
|
2022
|
+
var css = document.createElement("style");
|
|
2023
|
+
css.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
|
|
2024
|
+
document.head.appendChild(css);
|
|
2025
|
+
return function() {
|
|
2026
|
+
// Force restyle
|
|
2027
|
+
(function() {
|
|
2028
|
+
return window.getComputedStyle(document.body);
|
|
2029
|
+
})();
|
|
2030
|
+
// Wait for next tick before removing
|
|
2031
|
+
setTimeout(function() {
|
|
2032
|
+
document.head.removeChild(css);
|
|
2033
|
+
}, 1);
|
|
2034
|
+
};
|
|
2035
|
+
};
|
|
2036
|
+
var getSystemTheme = function(e) {
|
|
2037
|
+
if (!e) e = window.matchMedia(MEDIA);
|
|
2038
|
+
var isDark = e.matches;
|
|
2039
|
+
var systemTheme = isDark ? "dark" : "light";
|
|
2040
|
+
return systemTheme;
|
|
2041
|
+
};
|
|
2042
|
+
var encodeBase64 = function(str) {
|
|
2043
|
+
return isServer ? Buffer.from(str).toString("base64") : btoa(str);
|
|
2044
|
+
};
|
|
2045
|
+
|
|
2046
|
+
// import { ThemeVanillaProvider, ThemeVanillaValue } from "@koine/react";
|
|
2047
|
+
/**
|
|
2048
|
+
* App theme with vanilla class based theme (good for `tailwindcss`)
|
|
2049
|
+
*/ var AppThemeVanilla = function(param) {
|
|
2050
|
+
var theme = param.theme, children = param.children;
|
|
2051
|
+
// return (
|
|
2052
|
+
// <ThemeVanillaProvider initialTheme={theme}>{children}</ThemeVanillaProvider>
|
|
2053
|
+
// );
|
|
2054
|
+
return /*#__PURE__*/ React.createElement(ThemeProvider, {
|
|
2055
|
+
defaultTheme: theme,
|
|
2056
|
+
attribute: "class"
|
|
2057
|
+
}, children);
|
|
2058
|
+
};
|
|
2059
|
+
|
|
2060
|
+
function _extends$8() {
|
|
2061
|
+
_extends$8 = Object.assign || function(target) {
|
|
2062
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2063
|
+
var source = arguments[i];
|
|
2064
|
+
for(var key in source){
|
|
2065
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2066
|
+
target[key] = source[key];
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
return target;
|
|
2071
|
+
};
|
|
2072
|
+
return _extends$8.apply(this, arguments);
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* App main
|
|
2076
|
+
*
|
|
2077
|
+
* It does not imply any specific styling or animation solution
|
|
2078
|
+
*/ var AppMainVanilla = function(param) {
|
|
2079
|
+
var Component = param.Component, pageProps = param.pageProps, Layout = param.Layout, seo = param.seo, pre = param.pre, post = param.post;
|
|
2080
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(SeoDefaults, _extends$8({}, seo)), pre, /*#__PURE__*/ React.createElement(Layout, null, /*#__PURE__*/ React.createElement(Component, _extends$8({}, pageProps))), post);
|
|
2081
|
+
};
|
|
2082
|
+
|
|
2083
|
+
function _extends$7() {
|
|
2084
|
+
_extends$7 = Object.assign || function(target) {
|
|
2085
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2086
|
+
var source = arguments[i];
|
|
2087
|
+
for(var key in source){
|
|
2088
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2089
|
+
target[key] = source[key];
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
return target;
|
|
2094
|
+
};
|
|
2095
|
+
return _extends$7.apply(this, arguments);
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
2098
|
+
* App
|
|
2099
|
+
*/ var AppVanilla = function(props) {
|
|
2100
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(AppHead, null), /*#__PURE__*/ React.createElement(AppThemeVanilla, _extends$7({}, props), /*#__PURE__*/ React.createElement(AppMainVanilla, _extends$7({}, props))));
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2103
|
+
function _extends$6() {
|
|
2104
|
+
_extends$6 = Object.assign || function(target) {
|
|
2105
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2106
|
+
var source = arguments[i];
|
|
2107
|
+
for(var key in source){
|
|
2108
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2109
|
+
target[key] = source[key];
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
return target;
|
|
2114
|
+
};
|
|
2115
|
+
return _extends$6.apply(this, arguments);
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* App with authentication provided by `next-auth`
|
|
2119
|
+
*/ var AppAuthEmotion = function(props) {
|
|
2120
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(AppHead, null), /*#__PURE__*/ React.createElement(SessionProvider, {
|
|
2121
|
+
session: props.pageProps.session
|
|
2122
|
+
}, /*#__PURE__*/ React.createElement(AppThemeEmotion, _extends$6({}, props), /*#__PURE__*/ React.createElement(AppMain, _extends$6({}, props)))));
|
|
2123
|
+
};
|
|
2124
|
+
|
|
2125
|
+
function _extends$5() {
|
|
2126
|
+
_extends$5 = Object.assign || function(target) {
|
|
2127
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2128
|
+
var source = arguments[i];
|
|
2129
|
+
for(var key in source){
|
|
2130
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2131
|
+
target[key] = source[key];
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
return target;
|
|
2136
|
+
};
|
|
2137
|
+
return _extends$5.apply(this, arguments);
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* App with authentication provided by `next-auth`
|
|
2141
|
+
*/ var AppAuthSc = function(props) {
|
|
2142
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(AppHead, null), /*#__PURE__*/ React.createElement(SessionProvider, {
|
|
2143
|
+
session: props.pageProps.session
|
|
2144
|
+
}, /*#__PURE__*/ React.createElement(AppThemeSc, _extends$5({}, props), /*#__PURE__*/ React.createElement(AppMain, _extends$5({}, props)))));
|
|
2145
|
+
};
|
|
2146
|
+
|
|
2147
|
+
var AUTH_ROUTES = {
|
|
2148
|
+
login: process.env["AUTH_ROUTE_LOGIN"],
|
|
2149
|
+
profile: process.env["AUTH_ROUTE_PROFILE"],
|
|
2150
|
+
register: process.env["AUTH_ROUTE_REGISTER"],
|
|
2151
|
+
secured: JSON.parse(process.env["AUTH_ROUTES_SECURED"] || "[]")
|
|
2152
|
+
};
|
|
2153
|
+
function getAuthRoutes(t) {
|
|
2154
|
+
return Object.keys(AUTH_ROUTES).reduce(function(map, name) {
|
|
2155
|
+
var routePage = AUTH_ROUTES[name];
|
|
2156
|
+
// @ts-expect-error cannot remember
|
|
2157
|
+
map[name] = isString(routePage) ? t("~:".concat(AUTH_ROUTES[name])) : routePage;
|
|
2158
|
+
return map;
|
|
2159
|
+
}, {});
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* @param url e.g. "http://localhost:3000/signin?callbackUrl=http://localhost:3000/profile"
|
|
2163
|
+
*/ function getCallbackUrl() {
|
|
2164
|
+
var url = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.location.href;
|
|
2165
|
+
return url.split("callbackUrl=")[1] || "";
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
function _arrayLikeToArray$5(arr, len) {
|
|
2169
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2170
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2171
|
+
return arr2;
|
|
2172
|
+
}
|
|
2173
|
+
function _arrayWithHoles$5(arr) {
|
|
2174
|
+
if (Array.isArray(arr)) return arr;
|
|
2175
|
+
}
|
|
2176
|
+
function _arrayWithoutHoles(arr) {
|
|
2177
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$5(arr);
|
|
2178
|
+
}
|
|
2179
|
+
function _defineProperty$7(obj, key, value) {
|
|
2180
|
+
if (key in obj) {
|
|
2181
|
+
Object.defineProperty(obj, key, {
|
|
2182
|
+
value: value,
|
|
2183
|
+
enumerable: true,
|
|
2184
|
+
configurable: true,
|
|
2185
|
+
writable: true
|
|
2186
|
+
});
|
|
2187
|
+
} else {
|
|
2188
|
+
obj[key] = value;
|
|
2189
|
+
}
|
|
2190
|
+
return obj;
|
|
2191
|
+
}
|
|
2192
|
+
function _iterableToArray(iter) {
|
|
2193
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
2194
|
+
}
|
|
2195
|
+
function _iterableToArrayLimit$5(arr, i) {
|
|
2196
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2197
|
+
if (_i == null) return;
|
|
2198
|
+
var _arr = [];
|
|
2199
|
+
var _n = true;
|
|
2200
|
+
var _d = false;
|
|
2201
|
+
var _s, _e;
|
|
2202
|
+
try {
|
|
2203
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
2204
|
+
_arr.push(_s.value);
|
|
2205
|
+
if (i && _arr.length === i) break;
|
|
2206
|
+
}
|
|
2207
|
+
} catch (err) {
|
|
2208
|
+
_d = true;
|
|
2209
|
+
_e = err;
|
|
2210
|
+
} finally{
|
|
2211
|
+
try {
|
|
2212
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
2213
|
+
} finally{
|
|
2214
|
+
if (_d) throw _e;
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
return _arr;
|
|
2218
|
+
}
|
|
2219
|
+
function _nonIterableRest$5() {
|
|
2220
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2221
|
+
}
|
|
2222
|
+
function _nonIterableSpread() {
|
|
2223
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2224
|
+
}
|
|
2225
|
+
function _objectSpread$7(target) {
|
|
2226
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2227
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2228
|
+
var ownKeys = Object.keys(source);
|
|
2229
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
2230
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
2231
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
2232
|
+
}));
|
|
2233
|
+
}
|
|
2234
|
+
ownKeys.forEach(function(key) {
|
|
2235
|
+
_defineProperty$7(target, key, source[key]);
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
return target;
|
|
2239
|
+
}
|
|
2240
|
+
function _slicedToArray$5(arr, i) {
|
|
2241
|
+
return _arrayWithHoles$5(arr) || _iterableToArrayLimit$5(arr, i) || _unsupportedIterableToArray$5(arr, i) || _nonIterableRest$5();
|
|
2242
|
+
}
|
|
2243
|
+
function _toConsumableArray(arr) {
|
|
2244
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$5(arr) || _nonIterableSpread();
|
|
2245
|
+
}
|
|
2246
|
+
function _unsupportedIterableToArray$5(o, minLen) {
|
|
2247
|
+
if (!o) return;
|
|
2248
|
+
if (typeof o === "string") return _arrayLikeToArray$5(o, minLen);
|
|
2249
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2250
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2251
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2252
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen);
|
|
2253
|
+
}
|
|
2254
|
+
/**
|
|
2255
|
+
* FIXME: the use of `useMemo` is a hopefully-temporary solution to fix the FOUC
|
|
2256
|
+
* problem of untranslated text during page transitions
|
|
2257
|
+
*
|
|
2258
|
+
* @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
|
|
2259
|
+
*/ function useT(namespace) {
|
|
2260
|
+
var t = useTranslation().t;
|
|
2261
|
+
// const typedT = <
|
|
2262
|
+
// // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
2263
|
+
// R extends unknown = string,
|
|
2264
|
+
// // Q extends TranslationQuery = TranslationQuery
|
|
2265
|
+
// // O extends TranslationOptions = TranslationOptions
|
|
2266
|
+
// >(
|
|
2267
|
+
// s: N extends TranslateNamespace
|
|
2268
|
+
// ? Paths<Koine.NextTranslations[N]> | AllPaths
|
|
2269
|
+
// : AllPaths,
|
|
2270
|
+
// q?: TranslationQuery,
|
|
2271
|
+
// o?: TranslationOptions
|
|
2272
|
+
// ) =>
|
|
2273
|
+
// // eslint-disable-next-line
|
|
2274
|
+
// t.call(
|
|
2275
|
+
// null,
|
|
2276
|
+
// namespace ? `${namespace}:${s}` : s,
|
|
2277
|
+
// q === "obj" ? null : q,
|
|
2278
|
+
// q === "obj" || o === "obj" ? { returnObjects: true } : o
|
|
2279
|
+
// // ) as R extends (undefined | never | unknown) ? TranslateReturn<TranslationQuery, TranslationOptions> : R;
|
|
2280
|
+
// ) as R;
|
|
2281
|
+
// return typedT;
|
|
2282
|
+
var tMemoized = useMemo(function() {
|
|
2283
|
+
return function(s, q, o) {
|
|
2284
|
+
return t(namespace ? "".concat(namespace, ":").concat(s) : s, q === "obj" ? null : q, q === "obj" || o === "obj" ? {
|
|
2285
|
+
returnObjects: true
|
|
2286
|
+
} : o);
|
|
2287
|
+
};
|
|
2288
|
+
}, [
|
|
2289
|
+
t,
|
|
2290
|
+
namespace
|
|
2291
|
+
]);
|
|
2292
|
+
// return tMemoized as Translate<N>;
|
|
2293
|
+
return tMemoized;
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* @deprecated Not sure whether this will ever be useful
|
|
2297
|
+
*/ function useLooseT(namespace) {
|
|
2298
|
+
var t = useTranslation(namespace).t;
|
|
2299
|
+
// return t;
|
|
2300
|
+
var tMemoized = useMemo(function() {
|
|
2301
|
+
return t;
|
|
2302
|
+
}, [
|
|
2303
|
+
t
|
|
2304
|
+
]);
|
|
2305
|
+
return tMemoized;
|
|
2306
|
+
}
|
|
2307
|
+
function translationAsOptions(t, i18nKey) {
|
|
2308
|
+
var dictionary = t(i18nKey, undefined, {
|
|
2309
|
+
returnObjects: true
|
|
2310
|
+
});
|
|
2311
|
+
return Object.keys(dictionary).map(function(key) {
|
|
2312
|
+
return {
|
|
2313
|
+
value: key,
|
|
2314
|
+
label: dictionary[key]
|
|
2315
|
+
};
|
|
2316
|
+
});
|
|
2317
|
+
}
|
|
2318
|
+
/**
|
|
2319
|
+
* Automatically returns the `date-fns/format` function with the right locale
|
|
2320
|
+
* passed as option (grabbed from next router value).
|
|
2321
|
+
*/ var useDateFormat = function() {
|
|
2322
|
+
var ref = _slicedToArray$5(useState(function() {
|
|
2323
|
+
return function() {
|
|
2324
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
2325
|
+
args[_key] = arguments[_key];
|
|
2326
|
+
}
|
|
2327
|
+
return format.apply(void 0, _toConsumableArray(args));
|
|
2328
|
+
};
|
|
2329
|
+
}), 2), formatter = ref[0], setFormatter = ref[1];
|
|
2330
|
+
var router = useRouter();
|
|
2331
|
+
var locale = useDateLocale(router.locale);
|
|
2332
|
+
useEffect(function() {
|
|
2333
|
+
if (locale) {
|
|
2334
|
+
var newFormatter = function(date, _format, options) {
|
|
2335
|
+
return format(date, _format, _objectSpread$7({}, options || {}, {
|
|
2336
|
+
locale: locale
|
|
2337
|
+
}));
|
|
2338
|
+
};
|
|
2339
|
+
setFormatter(function() {
|
|
2340
|
+
return function() {
|
|
2341
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
2342
|
+
args[_key] = arguments[_key];
|
|
2343
|
+
}
|
|
2344
|
+
return newFormatter.apply(void 0, _toConsumableArray(args));
|
|
2345
|
+
};
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
}, [
|
|
2349
|
+
locale
|
|
2350
|
+
]);
|
|
2351
|
+
return formatter;
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
function _arrayLikeToArray$4(arr, len) {
|
|
2355
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2356
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2357
|
+
return arr2;
|
|
2358
|
+
}
|
|
2359
|
+
function _arrayWithHoles$4(arr) {
|
|
2360
|
+
if (Array.isArray(arr)) return arr;
|
|
2361
|
+
}
|
|
2362
|
+
function _defineProperty$6(obj, key, value) {
|
|
2363
|
+
if (key in obj) {
|
|
2364
|
+
Object.defineProperty(obj, key, {
|
|
2365
|
+
value: value,
|
|
2366
|
+
enumerable: true,
|
|
2367
|
+
configurable: true,
|
|
2368
|
+
writable: true
|
|
2369
|
+
});
|
|
2370
|
+
} else {
|
|
2371
|
+
obj[key] = value;
|
|
2372
|
+
}
|
|
2373
|
+
return obj;
|
|
2374
|
+
}
|
|
2375
|
+
function _iterableToArrayLimit$4(arr, i) {
|
|
2376
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2377
|
+
if (_i == null) return;
|
|
2378
|
+
var _arr = [];
|
|
2379
|
+
var _n = true;
|
|
2380
|
+
var _d = false;
|
|
2381
|
+
var _s, _e;
|
|
2382
|
+
try {
|
|
2383
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
2384
|
+
_arr.push(_s.value);
|
|
2385
|
+
if (i && _arr.length === i) break;
|
|
2386
|
+
}
|
|
2387
|
+
} catch (err) {
|
|
2388
|
+
_d = true;
|
|
2389
|
+
_e = err;
|
|
2390
|
+
} finally{
|
|
2391
|
+
try {
|
|
2392
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
2393
|
+
} finally{
|
|
2394
|
+
if (_d) throw _e;
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
return _arr;
|
|
2398
|
+
}
|
|
2399
|
+
function _nonIterableRest$4() {
|
|
2400
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2401
|
+
}
|
|
2402
|
+
function _objectSpread$6(target) {
|
|
2403
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2404
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2405
|
+
var ownKeys = Object.keys(source);
|
|
2406
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
2407
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
2408
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
2409
|
+
}));
|
|
2410
|
+
}
|
|
2411
|
+
ownKeys.forEach(function(key) {
|
|
2412
|
+
_defineProperty$6(target, key, source[key]);
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
return target;
|
|
2416
|
+
}
|
|
2417
|
+
function _slicedToArray$4(arr, i) {
|
|
2418
|
+
return _arrayWithHoles$4(arr) || _iterableToArrayLimit$4(arr, i) || _unsupportedIterableToArray$4(arr, i) || _nonIterableRest$4();
|
|
2419
|
+
}
|
|
2420
|
+
function _unsupportedIterableToArray$4(o, minLen) {
|
|
2421
|
+
if (!o) return;
|
|
2422
|
+
if (typeof o === "string") return _arrayLikeToArray$4(o, minLen);
|
|
2423
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2424
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2425
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2426
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen);
|
|
2427
|
+
}
|
|
2428
|
+
function useLogin() {
|
|
2429
|
+
var t = useT();
|
|
2430
|
+
var push = useRouter().push;
|
|
2431
|
+
var ref3 = _slicedToArray$4(useState(false), 2), loading = ref3[0], setLoading = ref3[1];
|
|
2432
|
+
var ref1 = _slicedToArray$4(useState(false), 2), ok1 = ref1[0], setOk = ref1[1];
|
|
2433
|
+
var ref2 = _slicedToArray$4(useState(false), 2), fail = ref2[0], setFail = ref2[1];
|
|
2434
|
+
var submit = useCallback(function(data) {
|
|
2435
|
+
setLoading(true);
|
|
2436
|
+
signIn("credentials", _objectSpread$6({}, data, {
|
|
2437
|
+
redirect: false
|
|
2438
|
+
}))// @ts-expect-error FIXME: at some point...
|
|
2439
|
+
.then(function(param) {
|
|
2440
|
+
var ok = param.ok;
|
|
2441
|
+
setLoading(false);
|
|
2442
|
+
setOk(ok);
|
|
2443
|
+
setFail(!ok);
|
|
2444
|
+
if (ok) {
|
|
2445
|
+
var redirectUrl = parseURL(getCallbackUrl());
|
|
2446
|
+
var ref = getAuthRoutes(t), login = ref.login, register = ref.register, profile = ref.profile;
|
|
2447
|
+
if (redirectUrl) {
|
|
2448
|
+
var redirectPath = redirectUrl.pathname;
|
|
2449
|
+
if (profile && (redirectPath === login || redirectPath === register)) {
|
|
2450
|
+
push(profile);
|
|
2451
|
+
} else {
|
|
2452
|
+
push(redirectPath + redirectUrl.search);
|
|
2453
|
+
}
|
|
2454
|
+
} else if (profile) {
|
|
2455
|
+
push(profile);
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
});
|
|
2459
|
+
}, [
|
|
2460
|
+
t,
|
|
2461
|
+
push
|
|
2462
|
+
]);
|
|
2463
|
+
// TODO: useMemo ?
|
|
2464
|
+
return {
|
|
2465
|
+
submit: submit,
|
|
2466
|
+
loading: loading,
|
|
2467
|
+
ok: ok1,
|
|
2468
|
+
fail: fail
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
function _arrayLikeToArray$3(arr, len) {
|
|
2473
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2474
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2475
|
+
return arr2;
|
|
2476
|
+
}
|
|
2477
|
+
function _arrayWithHoles$3(arr) {
|
|
2478
|
+
if (Array.isArray(arr)) return arr;
|
|
2479
|
+
}
|
|
2480
|
+
function _iterableToArrayLimit$3(arr, i) {
|
|
2481
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2482
|
+
if (_i == null) return;
|
|
2483
|
+
var _arr = [];
|
|
2484
|
+
var _n = true;
|
|
2485
|
+
var _d = false;
|
|
2486
|
+
var _s, _e;
|
|
2487
|
+
try {
|
|
2488
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
2489
|
+
_arr.push(_s.value);
|
|
2490
|
+
if (i && _arr.length === i) break;
|
|
2491
|
+
}
|
|
2492
|
+
} catch (err) {
|
|
2493
|
+
_d = true;
|
|
2494
|
+
_e = err;
|
|
2495
|
+
} finally{
|
|
2496
|
+
try {
|
|
2497
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
2498
|
+
} finally{
|
|
2499
|
+
if (_d) throw _e;
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
return _arr;
|
|
2503
|
+
}
|
|
2504
|
+
function _nonIterableRest$3() {
|
|
2505
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2506
|
+
}
|
|
2507
|
+
function _slicedToArray$3(arr, i) {
|
|
2508
|
+
return _arrayWithHoles$3(arr) || _iterableToArrayLimit$3(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$3();
|
|
2509
|
+
}
|
|
2510
|
+
function _unsupportedIterableToArray$3(o, minLen) {
|
|
2511
|
+
if (!o) return;
|
|
2512
|
+
if (typeof o === "string") return _arrayLikeToArray$3(o, minLen);
|
|
2513
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2514
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2515
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2516
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen);
|
|
2517
|
+
}
|
|
2518
|
+
function useLoginUrl() {
|
|
2519
|
+
var ref = _slicedToArray$3(useState(""), 2), currentUrl = ref[0], setCurrentUrl = ref[1];
|
|
2520
|
+
var t = useT();
|
|
2521
|
+
useEffect(function() {
|
|
2522
|
+
setCurrentUrl("?callbackUrl=".concat(window.location.href));
|
|
2523
|
+
}, []);
|
|
2524
|
+
return "".concat(getAuthRoutes(t).login).concat(currentUrl);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
function _arrayLikeToArray$2(arr, len) {
|
|
2528
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
2529
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2530
|
+
return arr2;
|
|
2531
|
+
}
|
|
2532
|
+
function _arrayWithHoles$2(arr) {
|
|
2533
|
+
if (Array.isArray(arr)) return arr;
|
|
2534
|
+
}
|
|
2535
|
+
function _iterableToArrayLimit$2(arr, i) {
|
|
2536
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2537
|
+
if (_i == null) return;
|
|
2538
|
+
var _arr = [];
|
|
2539
|
+
var _n = true;
|
|
2540
|
+
var _d = false;
|
|
2541
|
+
var _s, _e;
|
|
2542
|
+
try {
|
|
2543
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
2544
|
+
_arr.push(_s.value);
|
|
2545
|
+
if (i && _arr.length === i) break;
|
|
2546
|
+
}
|
|
2547
|
+
} catch (err) {
|
|
2548
|
+
_d = true;
|
|
2549
|
+
_e = err;
|
|
2550
|
+
} finally{
|
|
2551
|
+
try {
|
|
2552
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
2553
|
+
} finally{
|
|
2554
|
+
if (_d) throw _e;
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
return _arr;
|
|
2558
|
+
}
|
|
2559
|
+
function _nonIterableRest$2() {
|
|
2560
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2561
|
+
}
|
|
2562
|
+
function _slicedToArray$2(arr, i) {
|
|
2563
|
+
return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest$2();
|
|
2564
|
+
}
|
|
2565
|
+
function _unsupportedIterableToArray$2(o, minLen) {
|
|
2566
|
+
if (!o) return;
|
|
2567
|
+
if (typeof o === "string") return _arrayLikeToArray$2(o, minLen);
|
|
2568
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2569
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2570
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2571
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen);
|
|
2572
|
+
}
|
|
2573
|
+
function useLogout() {
|
|
2574
|
+
var t = useT();
|
|
2575
|
+
var push = useRouter().push;
|
|
2576
|
+
var ref = _slicedToArray$2(useState(false), 2), loading = ref[0], setLoading = ref[1];
|
|
2577
|
+
var ref1 = _slicedToArray$2(useState(false), 2), ok = ref1[0], setOk = ref1[1];
|
|
2578
|
+
var ref2 = _slicedToArray$2(useState(false), 1), fail = ref2[0];
|
|
2579
|
+
var submit = useCallback(function(event) {
|
|
2580
|
+
event.preventDefault();
|
|
2581
|
+
event.stopPropagation();
|
|
2582
|
+
setLoading(true);
|
|
2583
|
+
signOut({
|
|
2584
|
+
redirect: false
|
|
2585
|
+
}).then(function() {
|
|
2586
|
+
setLoading(false);
|
|
2587
|
+
setOk(true);
|
|
2588
|
+
var redirectUrl = parseURL(getCallbackUrl());
|
|
2589
|
+
var currentUrl = parseURL(window.location.href);
|
|
2590
|
+
var secured = getAuthRoutes(t).secured;
|
|
2591
|
+
var signin = t("~:/signin");
|
|
2592
|
+
var profile = t("~:/profile");
|
|
2593
|
+
var targetUrl = redirectUrl || currentUrl;
|
|
2594
|
+
var redirect = "";
|
|
2595
|
+
if (targetUrl) {
|
|
2596
|
+
if (targetUrl.pathname === profile) {
|
|
2597
|
+
redirect = signin;
|
|
2598
|
+
} else if (secured) {
|
|
2599
|
+
for(var i = 0; i < secured.length; i++){
|
|
2600
|
+
if (targetUrl.pathname.match(secured[i])) {
|
|
2601
|
+
redirect = signin;
|
|
2602
|
+
break;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
if (redirect) {
|
|
2608
|
+
push(redirect);
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2611
|
+
}, [
|
|
2612
|
+
t,
|
|
2613
|
+
push
|
|
2614
|
+
]);
|
|
2615
|
+
// TODO: useMemo ?
|
|
2616
|
+
return {
|
|
2617
|
+
submit: submit,
|
|
2618
|
+
loading: loading,
|
|
2619
|
+
ok: ok,
|
|
2620
|
+
fail: fail
|
|
2621
|
+
};
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
function _assertThisInitialized$3(self) {
|
|
2625
|
+
if (self === void 0) {
|
|
2626
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2627
|
+
}
|
|
2628
|
+
return self;
|
|
2629
|
+
}
|
|
2630
|
+
function _classCallCheck$3(instance, Constructor) {
|
|
2631
|
+
if (!(instance instanceof Constructor)) {
|
|
2632
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
function _getPrototypeOf$3(o) {
|
|
2636
|
+
_getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
2637
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
2638
|
+
};
|
|
2639
|
+
return _getPrototypeOf$3(o);
|
|
2640
|
+
}
|
|
2641
|
+
function _inherits$3(subClass, superClass) {
|
|
2642
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
2643
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
2644
|
+
}
|
|
2645
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
2646
|
+
constructor: {
|
|
2647
|
+
value: subClass,
|
|
2648
|
+
writable: true,
|
|
2649
|
+
configurable: true
|
|
2650
|
+
}
|
|
2651
|
+
});
|
|
2652
|
+
if (superClass) _setPrototypeOf$3(subClass, superClass);
|
|
2653
|
+
}
|
|
2654
|
+
function _possibleConstructorReturn$3(self, call) {
|
|
2655
|
+
if (call && (_typeof$3(call) === "object" || typeof call === "function")) {
|
|
2656
|
+
return call;
|
|
2657
|
+
}
|
|
2658
|
+
return _assertThisInitialized$3(self);
|
|
2659
|
+
}
|
|
2660
|
+
function _setPrototypeOf$3(o, p) {
|
|
2661
|
+
_setPrototypeOf$3 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
2662
|
+
o.__proto__ = p;
|
|
2663
|
+
return o;
|
|
2664
|
+
};
|
|
2665
|
+
return _setPrototypeOf$3(o, p);
|
|
2666
|
+
}
|
|
2667
|
+
var _typeof$3 = function(obj) {
|
|
2668
|
+
"@swc/helpers - typeof";
|
|
2669
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
2670
|
+
};
|
|
2671
|
+
function _isNativeReflectConstruct$3() {
|
|
2672
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
2673
|
+
if (Reflect.construct.sham) return false;
|
|
2674
|
+
if (typeof Proxy === "function") return true;
|
|
2675
|
+
try {
|
|
2676
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
2677
|
+
return true;
|
|
2678
|
+
} catch (e) {
|
|
2679
|
+
return false;
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
function _createSuper$3(Derived) {
|
|
2683
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$3();
|
|
2684
|
+
return function _createSuperInternal() {
|
|
2685
|
+
var Super = _getPrototypeOf$3(Derived), result;
|
|
2686
|
+
if (hasNativeReflectConstruct) {
|
|
2687
|
+
var NewTarget = _getPrototypeOf$3(this).constructor;
|
|
2688
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
2689
|
+
} else {
|
|
2690
|
+
result = Super.apply(this, arguments);
|
|
2691
|
+
}
|
|
2692
|
+
return _possibleConstructorReturn$3(this, result);
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2695
|
+
/**
|
|
2696
|
+
* For typescript safety of this component
|
|
2697
|
+
*
|
|
2698
|
+
* @see https://bit.ly/3ceuF8m
|
|
2699
|
+
*/ var Document = /*#__PURE__*/ function(NextDocument1) {
|
|
2700
|
+
_inherits$3(Document, NextDocument1);
|
|
2701
|
+
var _super = _createSuper$3(Document);
|
|
2702
|
+
function Document() {
|
|
2703
|
+
_classCallCheck$3(this, Document);
|
|
2704
|
+
return _super.apply(this, arguments);
|
|
2705
|
+
}
|
|
2706
|
+
var _proto = Document.prototype;
|
|
2707
|
+
_proto.render = function render() {
|
|
2708
|
+
var ___NEXT_DATA__ = this.props.__NEXT_DATA__, locale = ___NEXT_DATA__.locale, defaultLocale = ___NEXT_DATA__.defaultLocale;
|
|
2709
|
+
return /*#__PURE__*/ React.createElement(Html, {
|
|
2710
|
+
lang: locale || defaultLocale,
|
|
2711
|
+
className: "no-js"
|
|
2712
|
+
}, /*#__PURE__*/ React.createElement(Head$1, null, /*#__PURE__*/ React.createElement(Meta, null), /*#__PURE__*/ React.createElement(NoJs, null)), /*#__PURE__*/ React.createElement("body", null, /*#__PURE__*/ React.createElement(Main, null), /*#__PURE__*/ React.createElement(NextScript, null)));
|
|
2713
|
+
};
|
|
2714
|
+
return Document;
|
|
2715
|
+
}(NextDocument);
|
|
2716
|
+
|
|
2717
|
+
var runtime = {
|
|
2718
|
+
exports: {}
|
|
2719
|
+
};
|
|
2720
|
+
|
|
2721
|
+
(function (module) {
|
|
2722
|
+
function _instanceof(left, right) {
|
|
2723
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
2724
|
+
return !!right[Symbol.hasInstance](left);
|
|
2725
|
+
} else {
|
|
2726
|
+
return left instanceof right;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
/**
|
|
2730
|
+
* Copyright (c) 2014-present, Facebook, Inc.
|
|
2731
|
+
*
|
|
2732
|
+
* This source code is licensed under the MIT license found in the
|
|
2733
|
+
* LICENSE file in the root directory of this source tree.
|
|
2734
|
+
*/ var runtime = function(exports) {
|
|
2735
|
+
var define = function define(obj, key, value) {
|
|
2736
|
+
Object.defineProperty(obj, key, {
|
|
2737
|
+
value: value,
|
|
2738
|
+
enumerable: true,
|
|
2739
|
+
configurable: true,
|
|
2740
|
+
writable: true
|
|
2741
|
+
});
|
|
2742
|
+
return obj[key];
|
|
2743
|
+
};
|
|
2744
|
+
var wrap = function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
2745
|
+
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
2746
|
+
var protoGenerator = outerFn && _instanceof(outerFn.prototype, Generator) ? outerFn : Generator;
|
|
2747
|
+
var generator = Object.create(protoGenerator.prototype);
|
|
2748
|
+
var context = new Context(tryLocsList || []);
|
|
2749
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
2750
|
+
// .throw, and .return methods.
|
|
2751
|
+
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
2752
|
+
return generator;
|
|
2753
|
+
};
|
|
2754
|
+
var tryCatch = // Try/catch helper to minimize deoptimizations. Returns a completion
|
|
2755
|
+
// record like context.tryEntries[i].completion. This interface could
|
|
2756
|
+
// have been (and was previously) designed to take a closure to be
|
|
2757
|
+
// invoked without arguments, but in all the cases we care about we
|
|
2758
|
+
// already have an existing method we want to call, so there's no need
|
|
2759
|
+
// to create a new function object. We can even get away with assuming
|
|
2760
|
+
// the method takes exactly one argument, since that happens to be true
|
|
2761
|
+
// in every case, so we don't have to touch the arguments object. The
|
|
2762
|
+
// only additional allocation required is the completion record, which
|
|
2763
|
+
// has a stable shape and so hopefully should be cheap to allocate.
|
|
2764
|
+
function tryCatch(fn, obj, arg) {
|
|
2765
|
+
try {
|
|
2766
|
+
return {
|
|
2767
|
+
type: "normal",
|
|
2768
|
+
arg: fn.call(obj, arg)
|
|
2769
|
+
};
|
|
2770
|
+
} catch (err) {
|
|
2771
|
+
return {
|
|
2772
|
+
type: "throw",
|
|
2773
|
+
arg: err
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
};
|
|
2777
|
+
var Generator = // Dummy constructor functions that we use as the .constructor and
|
|
2778
|
+
// .constructor.prototype properties for functions that return Generator
|
|
2779
|
+
// objects. For full spec compliance, you may wish to configure your
|
|
2780
|
+
// minifier not to mangle the names of these two functions.
|
|
2781
|
+
function Generator() {};
|
|
2782
|
+
var GeneratorFunction = function GeneratorFunction() {};
|
|
2783
|
+
var GeneratorFunctionPrototype = function GeneratorFunctionPrototype() {};
|
|
2784
|
+
var defineIteratorMethods = // Helper for defining the .next, .throw, and .return methods of the
|
|
2785
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
2786
|
+
function defineIteratorMethods(prototype) {
|
|
2787
|
+
[
|
|
2788
|
+
"next",
|
|
2789
|
+
"throw",
|
|
2790
|
+
"return"
|
|
2791
|
+
].forEach(function(method) {
|
|
2792
|
+
define(prototype, method, function(arg) {
|
|
2793
|
+
return this._invoke(method, arg);
|
|
2794
|
+
});
|
|
2795
|
+
});
|
|
2796
|
+
};
|
|
2797
|
+
var AsyncIterator = function AsyncIterator(generator, PromiseImpl) {
|
|
2798
|
+
function invoke(method, arg, resolve, reject) {
|
|
2799
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
2800
|
+
if (record.type === "throw") {
|
|
2801
|
+
reject(record.arg);
|
|
2802
|
+
} else {
|
|
2803
|
+
var result = record.arg;
|
|
2804
|
+
var value1 = result.value;
|
|
2805
|
+
if (value1 && typeof value1 === "object" && hasOwn.call(value1, "__await")) {
|
|
2806
|
+
return PromiseImpl.resolve(value1.__await).then(function(value) {
|
|
2807
|
+
invoke("next", value, resolve, reject);
|
|
2808
|
+
}, function(err) {
|
|
2809
|
+
invoke("throw", err, resolve, reject);
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
return PromiseImpl.resolve(value1).then(function(unwrapped) {
|
|
2813
|
+
// When a yielded Promise is resolved, its final value becomes
|
|
2814
|
+
// the .value of the Promise<{value,done}> result for the
|
|
2815
|
+
// current iteration.
|
|
2816
|
+
result.value = unwrapped;
|
|
2817
|
+
resolve(result);
|
|
2818
|
+
}, function(error) {
|
|
2819
|
+
// If a rejected Promise was yielded, throw the rejection back
|
|
2820
|
+
// into the async generator function so it can be handled there.
|
|
2821
|
+
return invoke("throw", error, resolve, reject);
|
|
2822
|
+
});
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
var previousPromise;
|
|
2826
|
+
function enqueue(method, arg) {
|
|
2827
|
+
function callInvokeWithMethodAndArg() {
|
|
2828
|
+
return new PromiseImpl(function(resolve, reject) {
|
|
2829
|
+
invoke(method, arg, resolve, reject);
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
return previousPromise = // If enqueue has been called before, then we want to wait until
|
|
2833
|
+
// all previous Promises have been resolved before calling invoke,
|
|
2834
|
+
// so that results are always delivered in the correct order. If
|
|
2835
|
+
// enqueue has not been called before, then it is important to
|
|
2836
|
+
// call invoke immediately, without waiting on a callback to fire,
|
|
2837
|
+
// so that the async generator function has the opportunity to do
|
|
2838
|
+
// any necessary setup in a predictable way. This predictability
|
|
2839
|
+
// is why the Promise constructor synchronously invokes its
|
|
2840
|
+
// executor callback, and why async functions synchronously
|
|
2841
|
+
// execute code before the first await. Since we implement simple
|
|
2842
|
+
// async functions in terms of async generators, it is especially
|
|
2843
|
+
// important to get this right, even though it requires care.
|
|
2844
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
|
|
2845
|
+
// invocations of the iterator.
|
|
2846
|
+
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
2847
|
+
}
|
|
2848
|
+
// Define the unified helper method that is used to implement .next,
|
|
2849
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
2850
|
+
this._invoke = enqueue;
|
|
2851
|
+
};
|
|
2852
|
+
var makeInvokeMethod = function makeInvokeMethod(innerFn, self, context) {
|
|
2853
|
+
var state = GenStateSuspendedStart;
|
|
2854
|
+
return function invoke(method, arg) {
|
|
2855
|
+
if (state === GenStateExecuting) {
|
|
2856
|
+
throw new Error("Generator is already running");
|
|
2857
|
+
}
|
|
2858
|
+
if (state === GenStateCompleted) {
|
|
2859
|
+
if (method === "throw") {
|
|
2860
|
+
throw arg;
|
|
2861
|
+
}
|
|
2862
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
2863
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
2864
|
+
return doneResult();
|
|
2865
|
+
}
|
|
2866
|
+
context.method = method;
|
|
2867
|
+
context.arg = arg;
|
|
2868
|
+
while(true){
|
|
2869
|
+
var delegate = context.delegate;
|
|
2870
|
+
if (delegate) {
|
|
2871
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
2872
|
+
if (delegateResult) {
|
|
2873
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
2874
|
+
return delegateResult;
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
if (context.method === "next") {
|
|
2878
|
+
// Setting context._sent for legacy support of Babel's
|
|
2879
|
+
// function.sent implementation.
|
|
2880
|
+
context.sent = context._sent = context.arg;
|
|
2881
|
+
} else if (context.method === "throw") {
|
|
2882
|
+
if (state === GenStateSuspendedStart) {
|
|
2883
|
+
state = GenStateCompleted;
|
|
2884
|
+
throw context.arg;
|
|
2885
|
+
}
|
|
2886
|
+
context.dispatchException(context.arg);
|
|
2887
|
+
} else if (context.method === "return") {
|
|
2888
|
+
context.abrupt("return", context.arg);
|
|
2889
|
+
}
|
|
2890
|
+
state = GenStateExecuting;
|
|
2891
|
+
var record = tryCatch(innerFn, self, context);
|
|
2892
|
+
if (record.type === "normal") {
|
|
2893
|
+
// If an exception is thrown from innerFn, we leave state ===
|
|
2894
|
+
// GenStateExecuting and loop back for another invocation.
|
|
2895
|
+
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
2896
|
+
if (record.arg === ContinueSentinel) {
|
|
2897
|
+
continue;
|
|
2898
|
+
}
|
|
2899
|
+
return {
|
|
2900
|
+
value: record.arg,
|
|
2901
|
+
done: context.done
|
|
2902
|
+
};
|
|
2903
|
+
} else if (record.type === "throw") {
|
|
2904
|
+
state = GenStateCompleted;
|
|
2905
|
+
// Dispatch the exception by looping back around to the
|
|
2906
|
+
// context.dispatchException(context.arg) call above.
|
|
2907
|
+
context.method = "throw";
|
|
2908
|
+
context.arg = record.arg;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
};
|
|
2913
|
+
var pushTryEntry = function pushTryEntry(locs) {
|
|
2914
|
+
var entry = {
|
|
2915
|
+
tryLoc: locs[0]
|
|
2916
|
+
};
|
|
2917
|
+
if (1 in locs) {
|
|
2918
|
+
entry.catchLoc = locs[1];
|
|
2919
|
+
}
|
|
2920
|
+
if (2 in locs) {
|
|
2921
|
+
entry.finallyLoc = locs[2];
|
|
2922
|
+
entry.afterLoc = locs[3];
|
|
2923
|
+
}
|
|
2924
|
+
this.tryEntries.push(entry);
|
|
2925
|
+
};
|
|
2926
|
+
var resetTryEntry = function resetTryEntry(entry) {
|
|
2927
|
+
var record = entry.completion || {};
|
|
2928
|
+
record.type = "normal";
|
|
2929
|
+
delete record.arg;
|
|
2930
|
+
entry.completion = record;
|
|
2931
|
+
};
|
|
2932
|
+
var Context = function Context(tryLocsList) {
|
|
2933
|
+
// The root entry object (effectively a try statement without a catch
|
|
2934
|
+
// or a finally block) gives us a place to store values thrown from
|
|
2935
|
+
// locations where there is no enclosing try statement.
|
|
2936
|
+
this.tryEntries = [
|
|
2937
|
+
{
|
|
2938
|
+
tryLoc: "root"
|
|
2939
|
+
}
|
|
2940
|
+
];
|
|
2941
|
+
tryLocsList.forEach(pushTryEntry, this);
|
|
2942
|
+
this.reset(true);
|
|
2943
|
+
};
|
|
2944
|
+
var values = function values(iterable) {
|
|
2945
|
+
if (iterable) {
|
|
2946
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
2947
|
+
if (iteratorMethod) {
|
|
2948
|
+
return iteratorMethod.call(iterable);
|
|
2949
|
+
}
|
|
2950
|
+
if (typeof iterable.next === "function") {
|
|
2951
|
+
return iterable;
|
|
2952
|
+
}
|
|
2953
|
+
if (!isNaN(iterable.length)) {
|
|
2954
|
+
var i = -1, next1 = function next() {
|
|
2955
|
+
while(++i < iterable.length){
|
|
2956
|
+
if (hasOwn.call(iterable, i)) {
|
|
2957
|
+
next.value = iterable[i];
|
|
2958
|
+
next.done = false;
|
|
2959
|
+
return next;
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2962
|
+
next.value = undefined$1;
|
|
2963
|
+
next.done = true;
|
|
2964
|
+
return next;
|
|
2965
|
+
};
|
|
2966
|
+
return next1.next = next1;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
// Return an iterator with no values.
|
|
2970
|
+
return {
|
|
2971
|
+
next: doneResult
|
|
2972
|
+
};
|
|
2973
|
+
};
|
|
2974
|
+
var doneResult = function doneResult() {
|
|
2975
|
+
return {
|
|
2976
|
+
value: undefined$1,
|
|
2977
|
+
done: true
|
|
2978
|
+
};
|
|
2979
|
+
};
|
|
2980
|
+
var Op = Object.prototype;
|
|
2981
|
+
var hasOwn = Op.hasOwnProperty;
|
|
2982
|
+
var undefined$1; // More compressible than void 0.
|
|
2983
|
+
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
2984
|
+
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
2985
|
+
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
2986
|
+
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
2987
|
+
try {
|
|
2988
|
+
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
2989
|
+
define({}, "");
|
|
2990
|
+
} catch (err) {
|
|
2991
|
+
define = function define(obj, key, value) {
|
|
2992
|
+
return obj[key] = value;
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
exports.wrap = wrap;
|
|
2996
|
+
var GenStateSuspendedStart = "suspendedStart";
|
|
2997
|
+
var GenStateSuspendedYield = "suspendedYield";
|
|
2998
|
+
var GenStateExecuting = "executing";
|
|
2999
|
+
var GenStateCompleted = "completed";
|
|
3000
|
+
// Returning this object from the innerFn has the same effect as
|
|
3001
|
+
// breaking out of the dispatch switch statement.
|
|
3002
|
+
var ContinueSentinel = {};
|
|
3003
|
+
// This is a polyfill for %IteratorPrototype% for environments that
|
|
3004
|
+
// don't natively support it.
|
|
3005
|
+
var IteratorPrototype = {};
|
|
3006
|
+
IteratorPrototype[iteratorSymbol] = function() {
|
|
3007
|
+
return this;
|
|
3008
|
+
};
|
|
3009
|
+
var getProto = Object.getPrototypeOf;
|
|
3010
|
+
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
3011
|
+
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
3012
|
+
// This environment has a native %IteratorPrototype%; use it instead
|
|
3013
|
+
// of the polyfill.
|
|
3014
|
+
IteratorPrototype = NativeIteratorPrototype;
|
|
3015
|
+
}
|
|
3016
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
3017
|
+
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
3018
|
+
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
3019
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
3020
|
+
exports.isGeneratorFunction = function(genFun) {
|
|
3021
|
+
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
3022
|
+
return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
|
|
3023
|
+
// do is to check its .name property.
|
|
3024
|
+
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
3025
|
+
};
|
|
3026
|
+
exports.mark = function(genFun) {
|
|
3027
|
+
if (Object.setPrototypeOf) {
|
|
3028
|
+
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
3029
|
+
} else {
|
|
3030
|
+
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
3031
|
+
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
3032
|
+
}
|
|
3033
|
+
genFun.prototype = Object.create(Gp);
|
|
3034
|
+
return genFun;
|
|
3035
|
+
};
|
|
3036
|
+
// Within the body of any async function, `await x` is transformed to
|
|
3037
|
+
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
3038
|
+
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
3039
|
+
// meant to be awaited.
|
|
3040
|
+
exports.awrap = function(arg) {
|
|
3041
|
+
return {
|
|
3042
|
+
__await: arg
|
|
3043
|
+
};
|
|
3044
|
+
};
|
|
3045
|
+
defineIteratorMethods(AsyncIterator.prototype);
|
|
3046
|
+
AsyncIterator.prototype[asyncIteratorSymbol] = function() {
|
|
3047
|
+
return this;
|
|
3048
|
+
};
|
|
3049
|
+
exports.AsyncIterator = AsyncIterator;
|
|
3050
|
+
// Note that simple async functions are implemented on top of
|
|
3051
|
+
// AsyncIterator objects; they just return a Promise for the value of
|
|
3052
|
+
// the final result produced by the iterator.
|
|
3053
|
+
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
3054
|
+
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
3055
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
3056
|
+
return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
|
|
3057
|
+
: iter.next().then(function(result) {
|
|
3058
|
+
return result.done ? result.value : iter.next();
|
|
3059
|
+
});
|
|
3060
|
+
};
|
|
3061
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
3062
|
+
// result, either by returning a { value, done } result from the
|
|
3063
|
+
// delegate iterator, or by modifying context.method and context.arg,
|
|
3064
|
+
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
3065
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
3066
|
+
var method = delegate.iterator[context.method];
|
|
3067
|
+
if (method === undefined$1) {
|
|
3068
|
+
// A .throw or .return when the delegate iterator has no .throw
|
|
3069
|
+
// method always terminates the yield* loop.
|
|
3070
|
+
context.delegate = null;
|
|
3071
|
+
if (context.method === "throw") {
|
|
3072
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
3073
|
+
if (delegate.iterator["return"]) {
|
|
3074
|
+
// If the delegate iterator has a return method, give it a
|
|
3075
|
+
// chance to clean up.
|
|
3076
|
+
context.method = "return";
|
|
3077
|
+
context.arg = undefined$1;
|
|
3078
|
+
maybeInvokeDelegate(delegate, context);
|
|
3079
|
+
if (context.method === "throw") {
|
|
3080
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
3081
|
+
// "return" to "throw", let that override the TypeError below.
|
|
3082
|
+
return ContinueSentinel;
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
context.method = "throw";
|
|
3086
|
+
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
3087
|
+
}
|
|
3088
|
+
return ContinueSentinel;
|
|
3089
|
+
}
|
|
3090
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
3091
|
+
if (record.type === "throw") {
|
|
3092
|
+
context.method = "throw";
|
|
3093
|
+
context.arg = record.arg;
|
|
3094
|
+
context.delegate = null;
|
|
3095
|
+
return ContinueSentinel;
|
|
3096
|
+
}
|
|
3097
|
+
var info = record.arg;
|
|
3098
|
+
if (!info) {
|
|
3099
|
+
context.method = "throw";
|
|
3100
|
+
context.arg = new TypeError("iterator result is not an object");
|
|
3101
|
+
context.delegate = null;
|
|
3102
|
+
return ContinueSentinel;
|
|
3103
|
+
}
|
|
3104
|
+
if (info.done) {
|
|
3105
|
+
// Assign the result of the finished delegate to the temporary
|
|
3106
|
+
// variable specified by delegate.resultName (see delegateYield).
|
|
3107
|
+
context[delegate.resultName] = info.value;
|
|
3108
|
+
// Resume execution at the desired location (see delegateYield).
|
|
3109
|
+
context.next = delegate.nextLoc;
|
|
3110
|
+
// If context.method was "throw" but the delegate handled the
|
|
3111
|
+
// exception, let the outer generator proceed normally. If
|
|
3112
|
+
// context.method was "next", forget context.arg since it has been
|
|
3113
|
+
// "consumed" by the delegate iterator. If context.method was
|
|
3114
|
+
// "return", allow the original .return call to continue in the
|
|
3115
|
+
// outer generator.
|
|
3116
|
+
if (context.method !== "return") {
|
|
3117
|
+
context.method = "next";
|
|
3118
|
+
context.arg = undefined$1;
|
|
3119
|
+
}
|
|
3120
|
+
} else {
|
|
3121
|
+
// Re-yield the result returned by the delegate method.
|
|
3122
|
+
return info;
|
|
3123
|
+
}
|
|
3124
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
3125
|
+
// the outer generator.
|
|
3126
|
+
context.delegate = null;
|
|
3127
|
+
return ContinueSentinel;
|
|
3128
|
+
}
|
|
3129
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
3130
|
+
// unified ._invoke helper method.
|
|
3131
|
+
defineIteratorMethods(Gp);
|
|
3132
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
3133
|
+
// A Generator should always return itself as the iterator object when the
|
|
3134
|
+
// @@iterator function is called on it. Some browsers' implementations of the
|
|
3135
|
+
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
3136
|
+
// object to not be returned from this call. This ensures that doesn't happen.
|
|
3137
|
+
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
3138
|
+
Gp[iteratorSymbol] = function() {
|
|
3139
|
+
return this;
|
|
3140
|
+
};
|
|
3141
|
+
Gp.toString = function() {
|
|
3142
|
+
return "[object Generator]";
|
|
3143
|
+
};
|
|
3144
|
+
exports.keys = function(object) {
|
|
3145
|
+
var keys = [];
|
|
3146
|
+
for(var key1 in object){
|
|
3147
|
+
keys.push(key1);
|
|
3148
|
+
}
|
|
3149
|
+
keys.reverse();
|
|
3150
|
+
// Rather than returning an object with a next method, we keep
|
|
3151
|
+
// things simple and return the next function itself.
|
|
3152
|
+
return function next() {
|
|
3153
|
+
while(keys.length){
|
|
3154
|
+
var key = keys.pop();
|
|
3155
|
+
if (key in object) {
|
|
3156
|
+
next.value = key;
|
|
3157
|
+
next.done = false;
|
|
3158
|
+
return next;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
// To avoid creating an additional object, we just hang the .value
|
|
3162
|
+
// and .done properties off the next function object itself. This
|
|
3163
|
+
// also ensures that the minifier will not anonymize the function.
|
|
3164
|
+
next.done = true;
|
|
3165
|
+
return next;
|
|
3166
|
+
};
|
|
3167
|
+
};
|
|
3168
|
+
exports.values = values;
|
|
3169
|
+
Context.prototype = {
|
|
3170
|
+
constructor: Context,
|
|
3171
|
+
reset: function reset(skipTempReset) {
|
|
3172
|
+
this.prev = 0;
|
|
3173
|
+
this.next = 0;
|
|
3174
|
+
// Resetting context._sent for legacy support of Babel's
|
|
3175
|
+
// function.sent implementation.
|
|
3176
|
+
this.sent = this._sent = undefined$1;
|
|
3177
|
+
this.done = false;
|
|
3178
|
+
this.delegate = null;
|
|
3179
|
+
this.method = "next";
|
|
3180
|
+
this.arg = undefined$1;
|
|
3181
|
+
this.tryEntries.forEach(resetTryEntry);
|
|
3182
|
+
if (!skipTempReset) {
|
|
3183
|
+
for(var name in this){
|
|
3184
|
+
// Not sure about the optimal order of these conditions:
|
|
3185
|
+
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
|
|
3186
|
+
this[name] = undefined$1;
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
},
|
|
3191
|
+
stop: function stop() {
|
|
3192
|
+
this.done = true;
|
|
3193
|
+
var rootEntry = this.tryEntries[0];
|
|
3194
|
+
var rootRecord = rootEntry.completion;
|
|
3195
|
+
if (rootRecord.type === "throw") {
|
|
3196
|
+
throw rootRecord.arg;
|
|
3197
|
+
}
|
|
3198
|
+
return this.rval;
|
|
3199
|
+
},
|
|
3200
|
+
dispatchException: function dispatchException(exception) {
|
|
3201
|
+
var handle = function handle(loc, caught) {
|
|
3202
|
+
record.type = "throw";
|
|
3203
|
+
record.arg = exception;
|
|
3204
|
+
context.next = loc;
|
|
3205
|
+
if (caught) {
|
|
3206
|
+
// If the dispatched exception was caught by a catch block,
|
|
3207
|
+
// then let that catch block handle the exception normally.
|
|
3208
|
+
context.method = "next";
|
|
3209
|
+
context.arg = undefined$1;
|
|
3210
|
+
}
|
|
3211
|
+
return !!caught;
|
|
3212
|
+
};
|
|
3213
|
+
if (this.done) {
|
|
3214
|
+
throw exception;
|
|
3215
|
+
}
|
|
3216
|
+
var context = this;
|
|
3217
|
+
for(var i = this.tryEntries.length - 1; i >= 0; --i){
|
|
3218
|
+
var entry = this.tryEntries[i];
|
|
3219
|
+
var record = entry.completion;
|
|
3220
|
+
if (entry.tryLoc === "root") {
|
|
3221
|
+
// Exception thrown outside of any try block that could handle
|
|
3222
|
+
// it, so set the completion value of the entire function to
|
|
3223
|
+
// throw the exception.
|
|
3224
|
+
return handle("end");
|
|
3225
|
+
}
|
|
3226
|
+
if (entry.tryLoc <= this.prev) {
|
|
3227
|
+
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
3228
|
+
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
3229
|
+
if (hasCatch && hasFinally) {
|
|
3230
|
+
if (this.prev < entry.catchLoc) {
|
|
3231
|
+
return handle(entry.catchLoc, true);
|
|
3232
|
+
} else if (this.prev < entry.finallyLoc) {
|
|
3233
|
+
return handle(entry.finallyLoc);
|
|
3234
|
+
}
|
|
3235
|
+
} else if (hasCatch) {
|
|
3236
|
+
if (this.prev < entry.catchLoc) {
|
|
3237
|
+
return handle(entry.catchLoc, true);
|
|
3238
|
+
}
|
|
3239
|
+
} else if (hasFinally) {
|
|
3240
|
+
if (this.prev < entry.finallyLoc) {
|
|
3241
|
+
return handle(entry.finallyLoc);
|
|
3242
|
+
}
|
|
3243
|
+
} else {
|
|
3244
|
+
throw new Error("try statement without catch or finally");
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
},
|
|
3249
|
+
abrupt: function abrupt(type, arg) {
|
|
3250
|
+
for(var i = this.tryEntries.length - 1; i >= 0; --i){
|
|
3251
|
+
var entry = this.tryEntries[i];
|
|
3252
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
3253
|
+
var finallyEntry = entry;
|
|
3254
|
+
break;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
3258
|
+
// Ignore the finally entry if control is not jumping to a
|
|
3259
|
+
// location outside the try/catch block.
|
|
3260
|
+
finallyEntry = null;
|
|
3261
|
+
}
|
|
3262
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
3263
|
+
record.type = type;
|
|
3264
|
+
record.arg = arg;
|
|
3265
|
+
if (finallyEntry) {
|
|
3266
|
+
this.method = "next";
|
|
3267
|
+
this.next = finallyEntry.finallyLoc;
|
|
3268
|
+
return ContinueSentinel;
|
|
3269
|
+
}
|
|
3270
|
+
return this.complete(record);
|
|
3271
|
+
},
|
|
3272
|
+
complete: function complete(record, afterLoc) {
|
|
3273
|
+
if (record.type === "throw") {
|
|
3274
|
+
throw record.arg;
|
|
3275
|
+
}
|
|
3276
|
+
if (record.type === "break" || record.type === "continue") {
|
|
3277
|
+
this.next = record.arg;
|
|
3278
|
+
} else if (record.type === "return") {
|
|
3279
|
+
this.rval = this.arg = record.arg;
|
|
3280
|
+
this.method = "return";
|
|
3281
|
+
this.next = "end";
|
|
3282
|
+
} else if (record.type === "normal" && afterLoc) {
|
|
3283
|
+
this.next = afterLoc;
|
|
3284
|
+
}
|
|
3285
|
+
return ContinueSentinel;
|
|
3286
|
+
},
|
|
3287
|
+
finish: function finish(finallyLoc) {
|
|
3288
|
+
for(var i = this.tryEntries.length - 1; i >= 0; --i){
|
|
3289
|
+
var entry = this.tryEntries[i];
|
|
3290
|
+
if (entry.finallyLoc === finallyLoc) {
|
|
3291
|
+
this.complete(entry.completion, entry.afterLoc);
|
|
3292
|
+
resetTryEntry(entry);
|
|
3293
|
+
return ContinueSentinel;
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
},
|
|
3297
|
+
"catch": function(tryLoc) {
|
|
3298
|
+
for(var i = this.tryEntries.length - 1; i >= 0; --i){
|
|
3299
|
+
var entry = this.tryEntries[i];
|
|
3300
|
+
if (entry.tryLoc === tryLoc) {
|
|
3301
|
+
var record = entry.completion;
|
|
3302
|
+
if (record.type === "throw") {
|
|
3303
|
+
var thrown = record.arg;
|
|
3304
|
+
resetTryEntry(entry);
|
|
3305
|
+
}
|
|
3306
|
+
return thrown;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
// The context.catch method must only be called with a location
|
|
3310
|
+
// argument that corresponds to a known catch block.
|
|
3311
|
+
throw new Error("illegal catch attempt");
|
|
3312
|
+
},
|
|
3313
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
3314
|
+
this.delegate = {
|
|
3315
|
+
iterator: values(iterable),
|
|
3316
|
+
resultName: resultName,
|
|
3317
|
+
nextLoc: nextLoc
|
|
3318
|
+
};
|
|
3319
|
+
if (this.method === "next") {
|
|
3320
|
+
// Deliberately forget the last sent value so that we don't
|
|
3321
|
+
// accidentally pass it on to the delegate.
|
|
3322
|
+
this.arg = undefined$1;
|
|
3323
|
+
}
|
|
3324
|
+
return ContinueSentinel;
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
3328
|
+
// or not, return the runtime object so that we can declare the variable
|
|
3329
|
+
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
3330
|
+
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
3331
|
+
return exports;
|
|
3332
|
+
}(// If this script is executing as a CommonJS module, use module.exports
|
|
3333
|
+
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
3334
|
+
// object. Either way, the resulting object will be used to initialize
|
|
3335
|
+
// the regeneratorRuntime variable at the top of this file.
|
|
3336
|
+
module.exports );
|
|
3337
|
+
try {
|
|
3338
|
+
regeneratorRuntime = runtime;
|
|
3339
|
+
} catch (accidentalStrictMode) {
|
|
3340
|
+
// This module should not be running in strict mode, so the above
|
|
3341
|
+
// assignment should always work unless something is misconfigured. Just
|
|
3342
|
+
// in case runtime.js accidentally runs in strict mode, we can escape
|
|
3343
|
+
// strict mode using a global Function call. This could conceivably fail
|
|
3344
|
+
// if a Content Security Policy forbids using Function, but in that case
|
|
3345
|
+
// the proper solution is to fix the accidental strict mode problem. If
|
|
3346
|
+
// you've misconfigured your bundler to force strict mode and applied a
|
|
3347
|
+
// CSP to forbid Function, and you're not willing to fix either of those
|
|
3348
|
+
// problems, please detail your unique predicament in a GitHub issue.
|
|
3349
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
3350
|
+
}
|
|
3351
|
+
}(runtime));
|
|
3352
|
+
|
|
3353
|
+
var regeneratorRuntime$1 = runtime.exports;
|
|
3354
|
+
|
|
3355
|
+
function _assertThisInitialized$2(self) {
|
|
3356
|
+
if (self === void 0) {
|
|
3357
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3358
|
+
}
|
|
3359
|
+
return self;
|
|
3360
|
+
}
|
|
3361
|
+
function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3362
|
+
try {
|
|
3363
|
+
var info = gen[key](arg);
|
|
3364
|
+
var value = info.value;
|
|
3365
|
+
} catch (error) {
|
|
3366
|
+
reject(error);
|
|
3367
|
+
return;
|
|
3368
|
+
}
|
|
3369
|
+
if (info.done) {
|
|
3370
|
+
resolve(value);
|
|
3371
|
+
} else {
|
|
3372
|
+
Promise.resolve(value).then(_next, _throw);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
function _asyncToGenerator$4(fn) {
|
|
3376
|
+
return function() {
|
|
3377
|
+
var self = this, args = arguments;
|
|
3378
|
+
return new Promise(function(resolve, reject) {
|
|
3379
|
+
var gen = fn.apply(self, args);
|
|
3380
|
+
function _next(value) {
|
|
3381
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
|
|
3382
|
+
}
|
|
3383
|
+
function _throw(err) {
|
|
3384
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3385
|
+
}
|
|
3386
|
+
_next(undefined);
|
|
3387
|
+
});
|
|
3388
|
+
};
|
|
3389
|
+
}
|
|
3390
|
+
function _classCallCheck$2(instance, Constructor) {
|
|
3391
|
+
if (!(instance instanceof Constructor)) {
|
|
3392
|
+
throw new TypeError("Cannot call a class as a function");
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
function isNativeReflectConstruct() {
|
|
3396
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3397
|
+
if (Reflect.construct.sham) return false;
|
|
3398
|
+
if (typeof Proxy === "function") return true;
|
|
3399
|
+
try {
|
|
3400
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
|
|
3401
|
+
return true;
|
|
3402
|
+
} catch (e) {
|
|
3403
|
+
return false;
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
function _construct(Parent, args, Class) {
|
|
3407
|
+
if (isNativeReflectConstruct()) {
|
|
3408
|
+
_construct = Reflect.construct;
|
|
3409
|
+
} else {
|
|
3410
|
+
_construct = function _construct(Parent, args, Class) {
|
|
3411
|
+
var a = [
|
|
3412
|
+
null
|
|
3413
|
+
];
|
|
3414
|
+
a.push.apply(a, args);
|
|
3415
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
3416
|
+
var instance = new Constructor();
|
|
3417
|
+
if (Class) _setPrototypeOf$2(instance, Class.prototype);
|
|
3418
|
+
return instance;
|
|
3419
|
+
};
|
|
3420
|
+
}
|
|
3421
|
+
return _construct.apply(null, arguments);
|
|
3422
|
+
}
|
|
3423
|
+
function _defineProperty$5(obj, key, value) {
|
|
3424
|
+
if (key in obj) {
|
|
3425
|
+
Object.defineProperty(obj, key, {
|
|
3426
|
+
value: value,
|
|
3427
|
+
enumerable: true,
|
|
3428
|
+
configurable: true,
|
|
3429
|
+
writable: true
|
|
3430
|
+
});
|
|
3431
|
+
} else {
|
|
3432
|
+
obj[key] = value;
|
|
3433
|
+
}
|
|
3434
|
+
return obj;
|
|
3435
|
+
}
|
|
3436
|
+
function _extends$4() {
|
|
3437
|
+
_extends$4 = Object.assign || function(target) {
|
|
3438
|
+
for(var i = 1; i < arguments.length; i++){
|
|
3439
|
+
var source = arguments[i];
|
|
3440
|
+
for(var key in source){
|
|
3441
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3442
|
+
target[key] = source[key];
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
return target;
|
|
3447
|
+
};
|
|
3448
|
+
return _extends$4.apply(this, arguments);
|
|
3449
|
+
}
|
|
3450
|
+
function _getPrototypeOf$2(o) {
|
|
3451
|
+
_getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
3452
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
3453
|
+
};
|
|
3454
|
+
return _getPrototypeOf$2(o);
|
|
3455
|
+
}
|
|
3456
|
+
function _inherits$2(subClass, superClass) {
|
|
3457
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
3458
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
3459
|
+
}
|
|
3460
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
3461
|
+
constructor: {
|
|
3462
|
+
value: subClass,
|
|
3463
|
+
writable: true,
|
|
3464
|
+
configurable: true
|
|
3465
|
+
}
|
|
3466
|
+
});
|
|
3467
|
+
if (superClass) _setPrototypeOf$2(subClass, superClass);
|
|
3468
|
+
}
|
|
3469
|
+
function _isNativeFunction(fn) {
|
|
3470
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
3471
|
+
}
|
|
3472
|
+
function _objectSpread$5(target) {
|
|
3473
|
+
for(var i = 1; i < arguments.length; i++){
|
|
3474
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
3475
|
+
var ownKeys = Object.keys(source);
|
|
3476
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
3477
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
3478
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
3479
|
+
}));
|
|
3480
|
+
}
|
|
3481
|
+
ownKeys.forEach(function(key) {
|
|
3482
|
+
_defineProperty$5(target, key, source[key]);
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3485
|
+
return target;
|
|
3486
|
+
}
|
|
3487
|
+
function _possibleConstructorReturn$2(self, call) {
|
|
3488
|
+
if (call && (_typeof$2(call) === "object" || typeof call === "function")) {
|
|
3489
|
+
return call;
|
|
3490
|
+
}
|
|
3491
|
+
return _assertThisInitialized$2(self);
|
|
3492
|
+
}
|
|
3493
|
+
function _setPrototypeOf$2(o, p) {
|
|
3494
|
+
_setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
3495
|
+
o.__proto__ = p;
|
|
3496
|
+
return o;
|
|
3497
|
+
};
|
|
3498
|
+
return _setPrototypeOf$2(o, p);
|
|
3499
|
+
}
|
|
3500
|
+
var _typeof$2 = function(obj) {
|
|
3501
|
+
"@swc/helpers - typeof";
|
|
3502
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
3503
|
+
};
|
|
3504
|
+
function _wrapNativeSuper(Class) {
|
|
3505
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
3506
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
3507
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
3508
|
+
if (typeof Class !== "function") {
|
|
3509
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
3510
|
+
}
|
|
3511
|
+
if (typeof _cache !== "undefined") {
|
|
3512
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
3513
|
+
_cache.set(Class, Wrapper);
|
|
3514
|
+
}
|
|
3515
|
+
function Wrapper() {
|
|
3516
|
+
return _construct(Class, arguments, _getPrototypeOf$2(this).constructor);
|
|
3517
|
+
}
|
|
3518
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
3519
|
+
constructor: {
|
|
3520
|
+
value: Wrapper,
|
|
3521
|
+
enumerable: false,
|
|
3522
|
+
writable: true,
|
|
3523
|
+
configurable: true
|
|
3524
|
+
}
|
|
3525
|
+
});
|
|
3526
|
+
return _setPrototypeOf$2(Wrapper, Class);
|
|
3527
|
+
};
|
|
3528
|
+
return _wrapNativeSuper(Class);
|
|
3529
|
+
}
|
|
3530
|
+
function _isNativeReflectConstruct$2() {
|
|
3531
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3532
|
+
if (Reflect.construct.sham) return false;
|
|
3533
|
+
if (typeof Proxy === "function") return true;
|
|
3534
|
+
try {
|
|
3535
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
3536
|
+
return true;
|
|
3537
|
+
} catch (e) {
|
|
3538
|
+
return false;
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
function _createSuper$2(Derived) {
|
|
3542
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$2();
|
|
3543
|
+
return function _createSuperInternal() {
|
|
3544
|
+
var Super = _getPrototypeOf$2(Derived), result;
|
|
3545
|
+
if (hasNativeReflectConstruct) {
|
|
3546
|
+
var NewTarget = _getPrototypeOf$2(this).constructor;
|
|
3547
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
3548
|
+
} else {
|
|
3549
|
+
result = Super.apply(this, arguments);
|
|
3550
|
+
}
|
|
3551
|
+
return _possibleConstructorReturn$2(this, result);
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3554
|
+
var DocumentEmotion = /*#__PURE__*/ function(Document1) {
|
|
3555
|
+
_inherits$2(DocumentEmotion, Document1);
|
|
3556
|
+
var _super = _createSuper$2(DocumentEmotion);
|
|
3557
|
+
function DocumentEmotion() {
|
|
3558
|
+
_classCallCheck$2(this, DocumentEmotion);
|
|
3559
|
+
return _super.apply(this, arguments);
|
|
3560
|
+
}
|
|
3561
|
+
var _proto = DocumentEmotion.prototype;
|
|
3562
|
+
_proto.render = function render() {
|
|
3563
|
+
var ___NEXT_DATA__ = this.props.__NEXT_DATA__, locale = ___NEXT_DATA__.locale, defaultLocale = ___NEXT_DATA__.defaultLocale;
|
|
3564
|
+
return /*#__PURE__*/ React.createElement(Html, {
|
|
3565
|
+
lang: locale || defaultLocale,
|
|
3566
|
+
className: "no-js"
|
|
3567
|
+
}, /*#__PURE__*/ React.createElement(Head$1, null, /*#__PURE__*/ React.createElement(NoJs, null), this.props.emotionStyleTags), /*#__PURE__*/ React.createElement("body", null, /*#__PURE__*/ React.createElement(Main, null), /*#__PURE__*/ React.createElement(NextScript, null)));
|
|
3568
|
+
};
|
|
3569
|
+
return DocumentEmotion;
|
|
3570
|
+
}(_wrapNativeSuper(NextDocument));
|
|
3571
|
+
// `getInitialProps` belongs to `_document` (instead of `_app`),
|
|
3572
|
+
// it's compatible with static-site generation (SSG).
|
|
3573
|
+
DocumentEmotion.getInitialProps = function() {
|
|
3574
|
+
var _ref = _asyncToGenerator$4(regeneratorRuntime$1.mark(function _callee(ctx) {
|
|
3575
|
+
var originalRenderPage, cache, extractCriticalToChunks, initialProps, emotionStyles, emotionStyleTags;
|
|
3576
|
+
return regeneratorRuntime$1.wrap(function _callee$(_ctx) {
|
|
3577
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
3578
|
+
case 0:
|
|
3579
|
+
originalRenderPage = ctx.renderPage;
|
|
3580
|
+
cache = createEmotionCache();
|
|
3581
|
+
extractCriticalToChunks = createEmotionServer(cache).extractCriticalToChunks;
|
|
3582
|
+
ctx.renderPage = function() {
|
|
3583
|
+
return originalRenderPage({
|
|
3584
|
+
enhanceApp: function(App) {
|
|
3585
|
+
return function EnhanceApp(props) {
|
|
3586
|
+
return /*#__PURE__*/ React.createElement(App, _extends$4({
|
|
3587
|
+
emotionCache: cache
|
|
3588
|
+
}, props));
|
|
3589
|
+
};
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
};
|
|
3593
|
+
_ctx.next = 6;
|
|
3594
|
+
return NextDocument.getInitialProps(ctx);
|
|
3595
|
+
case 6:
|
|
3596
|
+
initialProps = _ctx.sent;
|
|
3597
|
+
emotionStyles = extractCriticalToChunks(initialProps.html);
|
|
3598
|
+
emotionStyleTags = emotionStyles.styles.map(function(style) {
|
|
3599
|
+
return /*#__PURE__*/ React.createElement("style", {
|
|
3600
|
+
"data-emotion": "".concat(style.key, " ").concat(style.ids.join(" ")),
|
|
3601
|
+
key: style.key,
|
|
3602
|
+
// eslint-disable-next-line react/no-danger
|
|
3603
|
+
dangerouslySetInnerHTML: {
|
|
3604
|
+
__html: style.css
|
|
3605
|
+
}
|
|
3606
|
+
});
|
|
3607
|
+
});
|
|
3608
|
+
return _ctx.abrupt("return", _objectSpread$5({}, initialProps, {
|
|
3609
|
+
emotionStyleTags: emotionStyleTags
|
|
3610
|
+
}));
|
|
3611
|
+
case 10:
|
|
3612
|
+
case "end":
|
|
3613
|
+
return _ctx.stop();
|
|
3614
|
+
}
|
|
3615
|
+
}, _callee);
|
|
3616
|
+
}));
|
|
3617
|
+
return function(ctx) {
|
|
3618
|
+
return _ref.apply(this, arguments);
|
|
3619
|
+
};
|
|
3620
|
+
}();
|
|
3621
|
+
|
|
3622
|
+
function _assertThisInitialized$1(self) {
|
|
3623
|
+
if (self === void 0) {
|
|
3624
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3625
|
+
}
|
|
3626
|
+
return self;
|
|
3627
|
+
}
|
|
3628
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3629
|
+
try {
|
|
3630
|
+
var info = gen[key](arg);
|
|
3631
|
+
var value = info.value;
|
|
3632
|
+
} catch (error) {
|
|
3633
|
+
reject(error);
|
|
3634
|
+
return;
|
|
3635
|
+
}
|
|
3636
|
+
if (info.done) {
|
|
3637
|
+
resolve(value);
|
|
3638
|
+
} else {
|
|
3639
|
+
Promise.resolve(value).then(_next, _throw);
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
function _asyncToGenerator$3(fn) {
|
|
3643
|
+
return function() {
|
|
3644
|
+
var self = this, args = arguments;
|
|
3645
|
+
return new Promise(function(resolve, reject) {
|
|
3646
|
+
var gen = fn.apply(self, args);
|
|
3647
|
+
function _next(value) {
|
|
3648
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
3649
|
+
}
|
|
3650
|
+
function _throw(err) {
|
|
3651
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3652
|
+
}
|
|
3653
|
+
_next(undefined);
|
|
3654
|
+
});
|
|
3655
|
+
};
|
|
3656
|
+
}
|
|
3657
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
3658
|
+
if (!(instance instanceof Constructor)) {
|
|
3659
|
+
throw new TypeError("Cannot call a class as a function");
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
function _defineProperty$4(obj, key, value) {
|
|
3663
|
+
if (key in obj) {
|
|
3664
|
+
Object.defineProperty(obj, key, {
|
|
3665
|
+
value: value,
|
|
3666
|
+
enumerable: true,
|
|
3667
|
+
configurable: true,
|
|
3668
|
+
writable: true
|
|
3669
|
+
});
|
|
3670
|
+
} else {
|
|
3671
|
+
obj[key] = value;
|
|
3672
|
+
}
|
|
3673
|
+
return obj;
|
|
3674
|
+
}
|
|
3675
|
+
function _extends$3() {
|
|
3676
|
+
_extends$3 = Object.assign || function(target) {
|
|
3677
|
+
for(var i = 1; i < arguments.length; i++){
|
|
3678
|
+
var source = arguments[i];
|
|
3679
|
+
for(var key in source){
|
|
3680
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
3681
|
+
target[key] = source[key];
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
return target;
|
|
3686
|
+
};
|
|
3687
|
+
return _extends$3.apply(this, arguments);
|
|
3688
|
+
}
|
|
3689
|
+
function _getPrototypeOf$1(o) {
|
|
3690
|
+
_getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
3691
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
3692
|
+
};
|
|
3693
|
+
return _getPrototypeOf$1(o);
|
|
3694
|
+
}
|
|
3695
|
+
function _inherits$1(subClass, superClass) {
|
|
3696
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
3697
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
3698
|
+
}
|
|
3699
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
3700
|
+
constructor: {
|
|
3701
|
+
value: subClass,
|
|
3702
|
+
writable: true,
|
|
3703
|
+
configurable: true
|
|
3704
|
+
}
|
|
3705
|
+
});
|
|
3706
|
+
if (superClass) _setPrototypeOf$1(subClass, superClass);
|
|
3707
|
+
}
|
|
3708
|
+
function _objectSpread$4(target) {
|
|
3709
|
+
for(var i = 1; i < arguments.length; i++){
|
|
3710
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
3711
|
+
var ownKeys = Object.keys(source);
|
|
3712
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
3713
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
3714
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
3715
|
+
}));
|
|
3716
|
+
}
|
|
3717
|
+
ownKeys.forEach(function(key) {
|
|
3718
|
+
_defineProperty$4(target, key, source[key]);
|
|
3719
|
+
});
|
|
3720
|
+
}
|
|
3721
|
+
return target;
|
|
3722
|
+
}
|
|
3723
|
+
function _possibleConstructorReturn$1(self, call) {
|
|
3724
|
+
if (call && (_typeof$1(call) === "object" || typeof call === "function")) {
|
|
3725
|
+
return call;
|
|
3726
|
+
}
|
|
3727
|
+
return _assertThisInitialized$1(self);
|
|
3728
|
+
}
|
|
3729
|
+
function _setPrototypeOf$1(o, p) {
|
|
3730
|
+
_setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
3731
|
+
o.__proto__ = p;
|
|
3732
|
+
return o;
|
|
3733
|
+
};
|
|
3734
|
+
return _setPrototypeOf$1(o, p);
|
|
3735
|
+
}
|
|
3736
|
+
var _typeof$1 = function(obj) {
|
|
3737
|
+
"@swc/helpers - typeof";
|
|
3738
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
3739
|
+
};
|
|
3740
|
+
function _isNativeReflectConstruct$1() {
|
|
3741
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3742
|
+
if (Reflect.construct.sham) return false;
|
|
3743
|
+
if (typeof Proxy === "function") return true;
|
|
3744
|
+
try {
|
|
3745
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
3746
|
+
return true;
|
|
3747
|
+
} catch (e) {
|
|
3748
|
+
return false;
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
function _createSuper$1(Derived) {
|
|
3752
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct$1();
|
|
3753
|
+
return function _createSuperInternal() {
|
|
3754
|
+
var Super = _getPrototypeOf$1(Derived), result;
|
|
3755
|
+
if (hasNativeReflectConstruct) {
|
|
3756
|
+
var NewTarget = _getPrototypeOf$1(this).constructor;
|
|
3757
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
3758
|
+
} else {
|
|
3759
|
+
result = Super.apply(this, arguments);
|
|
3760
|
+
}
|
|
3761
|
+
return _possibleConstructorReturn$1(this, result);
|
|
3762
|
+
};
|
|
3763
|
+
}
|
|
3764
|
+
/**
|
|
3765
|
+
* For typescript safety of this component
|
|
3766
|
+
*
|
|
3767
|
+
* @see https://bit.ly/3ceuF8m
|
|
3768
|
+
*/ var DocumentSc = /*#__PURE__*/ function(NextDocument1) {
|
|
3769
|
+
_inherits$1(DocumentSc, NextDocument1);
|
|
3770
|
+
var _super = _createSuper$1(DocumentSc);
|
|
3771
|
+
function DocumentSc() {
|
|
3772
|
+
_classCallCheck$1(this, DocumentSc);
|
|
3773
|
+
return _super.apply(this, arguments);
|
|
3774
|
+
}
|
|
3775
|
+
var _proto = DocumentSc.prototype;
|
|
3776
|
+
_proto.render = function render() {
|
|
3777
|
+
var ___NEXT_DATA__ = this.props.__NEXT_DATA__, locale = ___NEXT_DATA__.locale, defaultLocale = ___NEXT_DATA__.defaultLocale;
|
|
3778
|
+
return /*#__PURE__*/ React.createElement(Html, {
|
|
3779
|
+
lang: locale || defaultLocale,
|
|
3780
|
+
className: "no-js"
|
|
3781
|
+
}, /*#__PURE__*/ React.createElement(Head$1, null, /*#__PURE__*/ React.createElement(Meta, null), /*#__PURE__*/ React.createElement(NoJs, null)), /*#__PURE__*/ React.createElement("body", null, /*#__PURE__*/ React.createElement(Main, null), /*#__PURE__*/ React.createElement(NextScript, null)));
|
|
3782
|
+
};
|
|
3783
|
+
DocumentSc.getInitialProps = function getInitialProps(ctx) {
|
|
3784
|
+
return _asyncToGenerator$3(regeneratorRuntime$1.mark(function _callee() {
|
|
3785
|
+
var sheet, originalRenderPage, initialProps;
|
|
3786
|
+
return regeneratorRuntime$1.wrap(function _callee$(_ctx) {
|
|
3787
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
3788
|
+
case 0:
|
|
3789
|
+
sheet = new ServerStyleSheet();
|
|
3790
|
+
originalRenderPage = ctx.renderPage;
|
|
3791
|
+
_ctx.prev = 2;
|
|
3792
|
+
ctx.renderPage = function() {
|
|
3793
|
+
return originalRenderPage({
|
|
3794
|
+
enhanceApp: function(App) {
|
|
3795
|
+
return function(props) {
|
|
3796
|
+
return sheet.collectStyles(/*#__PURE__*/ React.createElement(App, _extends$3({}, props)));
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
});
|
|
3800
|
+
};
|
|
3801
|
+
_ctx.next = 6;
|
|
3802
|
+
return NextDocument.getInitialProps(ctx);
|
|
3803
|
+
case 6:
|
|
3804
|
+
initialProps = _ctx.sent;
|
|
3805
|
+
return _ctx.abrupt("return", _objectSpread$4({}, initialProps, {
|
|
3806
|
+
styles: /*#__PURE__*/ React.createElement(React.Fragment, null, initialProps.styles, sheet.getStyleElement())
|
|
3807
|
+
}));
|
|
3808
|
+
case 8:
|
|
3809
|
+
_ctx.prev = 8;
|
|
3810
|
+
sheet.seal();
|
|
3811
|
+
return _ctx.finish(8);
|
|
3812
|
+
case 11:
|
|
3813
|
+
case "end":
|
|
3814
|
+
return _ctx.stop();
|
|
3815
|
+
}
|
|
3816
|
+
}, _callee, null, [
|
|
3817
|
+
[
|
|
3818
|
+
2,
|
|
3819
|
+
,
|
|
3820
|
+
8,
|
|
3821
|
+
11
|
|
3822
|
+
]
|
|
3823
|
+
]);
|
|
3824
|
+
}))();
|
|
3825
|
+
};
|
|
3826
|
+
return DocumentSc;
|
|
3827
|
+
}(NextDocument);
|
|
3828
|
+
|
|
3829
|
+
function _assertThisInitialized(self) {
|
|
3830
|
+
if (self === void 0) {
|
|
3831
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
3832
|
+
}
|
|
3833
|
+
return self;
|
|
3834
|
+
}
|
|
3835
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3836
|
+
try {
|
|
3837
|
+
var info = gen[key](arg);
|
|
3838
|
+
var value = info.value;
|
|
3839
|
+
} catch (error) {
|
|
3840
|
+
reject(error);
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
if (info.done) {
|
|
3844
|
+
resolve(value);
|
|
3845
|
+
} else {
|
|
3846
|
+
Promise.resolve(value).then(_next, _throw);
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
function _asyncToGenerator$2(fn) {
|
|
3850
|
+
return function() {
|
|
3851
|
+
var self = this, args = arguments;
|
|
3852
|
+
return new Promise(function(resolve, reject) {
|
|
3853
|
+
var gen = fn.apply(self, args);
|
|
3854
|
+
function _next(value) {
|
|
3855
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
3856
|
+
}
|
|
3857
|
+
function _throw(err) {
|
|
3858
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3859
|
+
}
|
|
3860
|
+
_next(undefined);
|
|
3861
|
+
});
|
|
3862
|
+
};
|
|
3863
|
+
}
|
|
3864
|
+
function _classCallCheck(instance, Constructor) {
|
|
3865
|
+
if (!(instance instanceof Constructor)) {
|
|
3866
|
+
throw new TypeError("Cannot call a class as a function");
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
function _defineProperty$3(obj, key, value) {
|
|
3870
|
+
if (key in obj) {
|
|
3871
|
+
Object.defineProperty(obj, key, {
|
|
3872
|
+
value: value,
|
|
3873
|
+
enumerable: true,
|
|
3874
|
+
configurable: true,
|
|
3875
|
+
writable: true
|
|
3876
|
+
});
|
|
3877
|
+
} else {
|
|
3878
|
+
obj[key] = value;
|
|
3879
|
+
}
|
|
3880
|
+
return obj;
|
|
3881
|
+
}
|
|
3882
|
+
function _getPrototypeOf(o) {
|
|
3883
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
3884
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
3885
|
+
};
|
|
3886
|
+
return _getPrototypeOf(o);
|
|
3887
|
+
}
|
|
3888
|
+
function _inherits(subClass, superClass) {
|
|
3889
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
3890
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
3891
|
+
}
|
|
3892
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
3893
|
+
constructor: {
|
|
3894
|
+
value: subClass,
|
|
3895
|
+
writable: true,
|
|
3896
|
+
configurable: true
|
|
3897
|
+
}
|
|
3898
|
+
});
|
|
3899
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
3900
|
+
}
|
|
3901
|
+
function _objectSpread$3(target) {
|
|
3902
|
+
for(var i = 1; i < arguments.length; i++){
|
|
3903
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
3904
|
+
var ownKeys = Object.keys(source);
|
|
3905
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
3906
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
3907
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
3908
|
+
}));
|
|
3909
|
+
}
|
|
3910
|
+
ownKeys.forEach(function(key) {
|
|
3911
|
+
_defineProperty$3(target, key, source[key]);
|
|
3912
|
+
});
|
|
3913
|
+
}
|
|
3914
|
+
return target;
|
|
3915
|
+
}
|
|
3916
|
+
function _possibleConstructorReturn(self, call) {
|
|
3917
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
3918
|
+
return call;
|
|
3919
|
+
}
|
|
3920
|
+
return _assertThisInitialized(self);
|
|
3921
|
+
}
|
|
3922
|
+
function _setPrototypeOf(o, p) {
|
|
3923
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
3924
|
+
o.__proto__ = p;
|
|
3925
|
+
return o;
|
|
3926
|
+
};
|
|
3927
|
+
return _setPrototypeOf(o, p);
|
|
3928
|
+
}
|
|
3929
|
+
var _typeof = function(obj) {
|
|
3930
|
+
"@swc/helpers - typeof";
|
|
3931
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
3932
|
+
};
|
|
3933
|
+
function _isNativeReflectConstruct() {
|
|
3934
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3935
|
+
if (Reflect.construct.sham) return false;
|
|
3936
|
+
if (typeof Proxy === "function") return true;
|
|
3937
|
+
try {
|
|
3938
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
3939
|
+
return true;
|
|
3940
|
+
} catch (e) {
|
|
3941
|
+
return false;
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
function _createSuper(Derived) {
|
|
3945
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
3946
|
+
return function _createSuperInternal() {
|
|
3947
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
3948
|
+
if (hasNativeReflectConstruct) {
|
|
3949
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
3950
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
3951
|
+
} else {
|
|
3952
|
+
result = Super.apply(this, arguments);
|
|
3953
|
+
}
|
|
3954
|
+
return _possibleConstructorReturn(this, result);
|
|
3955
|
+
};
|
|
3956
|
+
}
|
|
3957
|
+
/**
|
|
3958
|
+
*/ var DocumentVanilla = /*#__PURE__*/ function(NextDocument1) {
|
|
3959
|
+
_inherits(DocumentVanilla, NextDocument1);
|
|
3960
|
+
var _super = _createSuper(DocumentVanilla);
|
|
3961
|
+
function DocumentVanilla() {
|
|
3962
|
+
_classCallCheck(this, DocumentVanilla);
|
|
3963
|
+
return _super.apply(this, arguments);
|
|
3964
|
+
}
|
|
3965
|
+
var _proto = DocumentVanilla.prototype;
|
|
3966
|
+
_proto.render = function render() {
|
|
3967
|
+
var ___NEXT_DATA__ = this.props.__NEXT_DATA__, locale = ___NEXT_DATA__.locale, defaultLocale = ___NEXT_DATA__.defaultLocale;
|
|
3968
|
+
return /*#__PURE__*/ React.createElement(Html, {
|
|
3969
|
+
lang: locale || defaultLocale,
|
|
3970
|
+
className: "no-js"
|
|
3971
|
+
}, /*#__PURE__*/ React.createElement(Head$1, null, /*#__PURE__*/ React.createElement(Meta, null), /*#__PURE__*/ React.createElement(NoJs, null)), /*#__PURE__*/ React.createElement("body", null, /*#__PURE__*/ React.createElement(Main, null), /*#__PURE__*/ React.createElement(NextScript, null)));
|
|
3972
|
+
};
|
|
3973
|
+
DocumentVanilla.getInitialProps = function getInitialProps(ctx) {
|
|
3974
|
+
return _asyncToGenerator$2(regeneratorRuntime$1.mark(function _callee() {
|
|
3975
|
+
var ref, initialProps;
|
|
3976
|
+
return regeneratorRuntime$1.wrap(function _callee$(_ctx) {
|
|
3977
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
3978
|
+
case 0:
|
|
3979
|
+
_ctx.next = 3;
|
|
3980
|
+
return NextDocument.getInitialProps(ctx);
|
|
3981
|
+
case 3:
|
|
3982
|
+
initialProps = _ctx.sent;
|
|
3983
|
+
return _ctx.abrupt("return", _objectSpread$3({}, initialProps, {
|
|
3984
|
+
theme: getInitialThemeFromRequest(((ref = ctx.req) === null || ref === void 0 ? void 0 : ref.headers.cookie /* || document?.cookie */ ) || "")
|
|
3985
|
+
}));
|
|
3986
|
+
case 5:
|
|
3987
|
+
case "end":
|
|
3988
|
+
return _ctx.stop();
|
|
3989
|
+
}
|
|
3990
|
+
}, _callee);
|
|
3991
|
+
}))();
|
|
3992
|
+
};
|
|
3993
|
+
return DocumentVanilla;
|
|
3994
|
+
}(NextDocument);
|
|
3995
|
+
|
|
3996
|
+
function _extends$2() {
|
|
3997
|
+
_extends$2 = Object.assign || function(target) {
|
|
3998
|
+
for(var i = 1; i < arguments.length; i++){
|
|
3999
|
+
var source = arguments[i];
|
|
4000
|
+
for(var key in source){
|
|
4001
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
4002
|
+
target[key] = source[key];
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
return target;
|
|
4007
|
+
};
|
|
4008
|
+
return _extends$2.apply(this, arguments);
|
|
4009
|
+
}
|
|
4010
|
+
var Favicon = function(props) {
|
|
4011
|
+
return /*#__PURE__*/ React.createElement(Head, null, /*#__PURE__*/ React.createElement(FaviconTags, _extends$2({}, props)));
|
|
4012
|
+
};
|
|
4013
|
+
|
|
4014
|
+
function _defineProperty$2(obj, key, value) {
|
|
4015
|
+
if (key in obj) {
|
|
4016
|
+
Object.defineProperty(obj, key, {
|
|
4017
|
+
value: value,
|
|
4018
|
+
enumerable: true,
|
|
4019
|
+
configurable: true,
|
|
4020
|
+
writable: true
|
|
4021
|
+
});
|
|
4022
|
+
} else {
|
|
4023
|
+
obj[key] = value;
|
|
4024
|
+
}
|
|
4025
|
+
return obj;
|
|
4026
|
+
}
|
|
4027
|
+
function _objectSpread$2(target) {
|
|
4028
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4029
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
4030
|
+
var ownKeys = Object.keys(source);
|
|
4031
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
4032
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
4033
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
4034
|
+
}));
|
|
4035
|
+
}
|
|
4036
|
+
ownKeys.forEach(function(key) {
|
|
4037
|
+
_defineProperty$2(target, key, source[key]);
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
return target;
|
|
4041
|
+
}
|
|
4042
|
+
function useForm(// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4043
|
+
schema, i18nNamespace) {
|
|
4044
|
+
var formProps = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
4045
|
+
var t = useT(i18nNamespace);
|
|
4046
|
+
// const form = _useForm<InferType<ObjectSchema<T, object>>>({
|
|
4047
|
+
var form = useForm$1(_objectSpread$2({
|
|
4048
|
+
// @ts-expect-error FIXME:
|
|
4049
|
+
resolver: yupResolver(schema)
|
|
4050
|
+
}, formProps));
|
|
4051
|
+
// const { control, register, setValue } = form;
|
|
4052
|
+
// const field = { control, register, setValue, t };
|
|
4053
|
+
// if ("production" !== process.env["NODE_ENV"]) {
|
|
4054
|
+
// if (debug) {
|
|
4055
|
+
// console.log(
|
|
4056
|
+
// `Form ${i18nNamespace} data`,
|
|
4057
|
+
// form.watch(),
|
|
4058
|
+
// `errors: `,
|
|
4059
|
+
// form.formState.errors
|
|
4060
|
+
// );
|
|
4061
|
+
// }
|
|
4062
|
+
// }
|
|
4063
|
+
// if (formProps.mode === "onChange") {
|
|
4064
|
+
// return { field, ...form };
|
|
4065
|
+
// }
|
|
4066
|
+
return useMemo(function() {
|
|
4067
|
+
var control = form.control, register = form.register, setValue = form.setValue;
|
|
4068
|
+
var field = {
|
|
4069
|
+
control: control,
|
|
4070
|
+
register: register,
|
|
4071
|
+
setValue: setValue,
|
|
4072
|
+
t: t
|
|
4073
|
+
};
|
|
4074
|
+
return _objectSpread$2({
|
|
4075
|
+
field: field
|
|
4076
|
+
}, form);
|
|
4077
|
+
}, [
|
|
4078
|
+
t,
|
|
4079
|
+
form
|
|
4080
|
+
]);
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
4084
|
+
try {
|
|
4085
|
+
var info = gen[key](arg);
|
|
4086
|
+
var value = info.value;
|
|
4087
|
+
} catch (error) {
|
|
4088
|
+
reject(error);
|
|
4089
|
+
return;
|
|
4090
|
+
}
|
|
4091
|
+
if (info.done) {
|
|
4092
|
+
resolve(value);
|
|
4093
|
+
} else {
|
|
4094
|
+
Promise.resolve(value).then(_next, _throw);
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
function _asyncToGenerator$1(fn) {
|
|
4098
|
+
return function() {
|
|
4099
|
+
var self = this, args = arguments;
|
|
4100
|
+
return new Promise(function(resolve, reject) {
|
|
4101
|
+
var gen = fn.apply(self, args);
|
|
4102
|
+
function _next(value) {
|
|
4103
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
4104
|
+
}
|
|
4105
|
+
function _throw(err) {
|
|
4106
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
4107
|
+
}
|
|
4108
|
+
_next(undefined);
|
|
4109
|
+
});
|
|
4110
|
+
};
|
|
4111
|
+
}
|
|
4112
|
+
function _defineProperty$1(obj, key, value) {
|
|
4113
|
+
if (key in obj) {
|
|
4114
|
+
Object.defineProperty(obj, key, {
|
|
4115
|
+
value: value,
|
|
4116
|
+
enumerable: true,
|
|
4117
|
+
configurable: true,
|
|
4118
|
+
writable: true
|
|
4119
|
+
});
|
|
4120
|
+
} else {
|
|
4121
|
+
obj[key] = value;
|
|
4122
|
+
}
|
|
4123
|
+
return obj;
|
|
4124
|
+
}
|
|
4125
|
+
function _objectSpread$1(target) {
|
|
4126
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4127
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
4128
|
+
var ownKeys = Object.keys(source);
|
|
4129
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
4130
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
4131
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
4132
|
+
}));
|
|
4133
|
+
}
|
|
4134
|
+
ownKeys.forEach(function(key) {
|
|
4135
|
+
_defineProperty$1(target, key, source[key]);
|
|
4136
|
+
});
|
|
4137
|
+
}
|
|
4138
|
+
return target;
|
|
4139
|
+
}
|
|
4140
|
+
var api = [
|
|
4141
|
+
"get",
|
|
4142
|
+
"post",
|
|
4143
|
+
"put",
|
|
4144
|
+
"patch",
|
|
4145
|
+
"delete"
|
|
4146
|
+
].reduce(function(api1, method) {
|
|
4147
|
+
api1[method] = function() {
|
|
4148
|
+
var _ref = _asyncToGenerator$1(regeneratorRuntime$1.mark(function _callee(endpoint) {
|
|
4149
|
+
var options, _json, json, params, _headers, headers, _timeout, timeout, requestInit, timeoutNumber, controller, timeoutId, url, response, result, _args = arguments;
|
|
4150
|
+
return regeneratorRuntime$1.wrap(function _callee$(_ctx) {
|
|
4151
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
4152
|
+
case 0:
|
|
4153
|
+
options = _args.length > 1 && _args[1] !== void 0 ? _args[1] : {};
|
|
4154
|
+
_json = options.json, json = _json === void 0 ? {} : _json, params = options.params, _headers = options.headers, headers = _headers === void 0 ? {} : _headers, _timeout = options.timeout, timeout = _timeout === void 0 ? 10000 : _timeout;
|
|
4155
|
+
requestInit = {
|
|
4156
|
+
method: method.toUpperCase(),
|
|
4157
|
+
headers: _objectSpread$1({
|
|
4158
|
+
"content-type": "application/json"
|
|
4159
|
+
}, headers)
|
|
4160
|
+
};
|
|
4161
|
+
timeoutNumber = Number(timeout);
|
|
4162
|
+
url = "/api/".concat(endpoint.replace(/^\/*/, ""));
|
|
4163
|
+
if (method !== "get") {
|
|
4164
|
+
requestInit.body = JSON.stringify(json);
|
|
4165
|
+
}
|
|
4166
|
+
if (timeoutNumber > 0) {
|
|
4167
|
+
controller = new AbortController();
|
|
4168
|
+
timeoutId = setTimeout(function() {
|
|
4169
|
+
return controller.abort();
|
|
4170
|
+
}, timeoutNumber);
|
|
4171
|
+
requestInit.signal = controller.signal;
|
|
4172
|
+
}
|
|
4173
|
+
if (params) {
|
|
4174
|
+
url += buildUrlQueryString(params);
|
|
4175
|
+
}
|
|
4176
|
+
_ctx.next = 12;
|
|
4177
|
+
return fetch(url, requestInit);
|
|
4178
|
+
case 12:
|
|
4179
|
+
response = _ctx.sent;
|
|
4180
|
+
if (timeoutId) {
|
|
4181
|
+
clearTimeout(timeoutId);
|
|
4182
|
+
}
|
|
4183
|
+
_ctx.next = 16;
|
|
4184
|
+
return response.json();
|
|
4185
|
+
case 16:
|
|
4186
|
+
result = _ctx.sent;
|
|
4187
|
+
return _ctx.abrupt("return", result);
|
|
4188
|
+
case 18:
|
|
4189
|
+
case "end":
|
|
4190
|
+
return _ctx.stop();
|
|
4191
|
+
}
|
|
4192
|
+
}, _callee);
|
|
4193
|
+
}));
|
|
4194
|
+
return function(endpoint) {
|
|
4195
|
+
return _ref.apply(this, arguments);
|
|
4196
|
+
};
|
|
4197
|
+
}();
|
|
4198
|
+
return api1;
|
|
4199
|
+
}, {});
|
|
4200
|
+
|
|
4201
|
+
function _arrayLikeToArray$1(arr, len) {
|
|
4202
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4203
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4204
|
+
return arr2;
|
|
4205
|
+
}
|
|
4206
|
+
function _arrayWithHoles$1(arr) {
|
|
4207
|
+
if (Array.isArray(arr)) return arr;
|
|
4208
|
+
}
|
|
4209
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
4210
|
+
try {
|
|
4211
|
+
var info = gen[key](arg);
|
|
4212
|
+
var value = info.value;
|
|
4213
|
+
} catch (error) {
|
|
4214
|
+
reject(error);
|
|
4215
|
+
return;
|
|
4216
|
+
}
|
|
4217
|
+
if (info.done) {
|
|
4218
|
+
resolve(value);
|
|
4219
|
+
} else {
|
|
4220
|
+
Promise.resolve(value).then(_next, _throw);
|
|
4221
|
+
}
|
|
4222
|
+
}
|
|
4223
|
+
function _asyncToGenerator(fn) {
|
|
4224
|
+
return function() {
|
|
4225
|
+
var self = this, args = arguments;
|
|
4226
|
+
return new Promise(function(resolve, reject) {
|
|
4227
|
+
var gen = fn.apply(self, args);
|
|
4228
|
+
function _next(value) {
|
|
4229
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
4230
|
+
}
|
|
4231
|
+
function _throw(err) {
|
|
4232
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
4233
|
+
}
|
|
4234
|
+
_next(undefined);
|
|
4235
|
+
});
|
|
4236
|
+
};
|
|
4237
|
+
}
|
|
4238
|
+
function _defineProperty(obj, key, value) {
|
|
4239
|
+
if (key in obj) {
|
|
4240
|
+
Object.defineProperty(obj, key, {
|
|
4241
|
+
value: value,
|
|
4242
|
+
enumerable: true,
|
|
4243
|
+
configurable: true,
|
|
4244
|
+
writable: true
|
|
4245
|
+
});
|
|
4246
|
+
} else {
|
|
4247
|
+
obj[key] = value;
|
|
4248
|
+
}
|
|
4249
|
+
return obj;
|
|
4250
|
+
}
|
|
4251
|
+
function _iterableToArrayLimit$1(arr, i) {
|
|
4252
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
4253
|
+
if (_i == null) return;
|
|
4254
|
+
var _arr = [];
|
|
4255
|
+
var _n = true;
|
|
4256
|
+
var _d = false;
|
|
4257
|
+
var _s, _e;
|
|
4258
|
+
try {
|
|
4259
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
4260
|
+
_arr.push(_s.value);
|
|
4261
|
+
if (i && _arr.length === i) break;
|
|
4262
|
+
}
|
|
4263
|
+
} catch (err) {
|
|
4264
|
+
_d = true;
|
|
4265
|
+
_e = err;
|
|
4266
|
+
} finally{
|
|
4267
|
+
try {
|
|
4268
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
4269
|
+
} finally{
|
|
4270
|
+
if (_d) throw _e;
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
return _arr;
|
|
4274
|
+
}
|
|
4275
|
+
function _nonIterableRest$1() {
|
|
4276
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4277
|
+
}
|
|
4278
|
+
function _objectSpread(target) {
|
|
4279
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4280
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
4281
|
+
var ownKeys = Object.keys(source);
|
|
4282
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
4283
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
4284
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
4285
|
+
}));
|
|
4286
|
+
}
|
|
4287
|
+
ownKeys.forEach(function(key) {
|
|
4288
|
+
_defineProperty(target, key, source[key]);
|
|
4289
|
+
});
|
|
4290
|
+
}
|
|
4291
|
+
return target;
|
|
4292
|
+
}
|
|
4293
|
+
function _slicedToArray$1(arr, i) {
|
|
4294
|
+
return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
|
|
4295
|
+
}
|
|
4296
|
+
function _unsupportedIterableToArray$1(o, minLen) {
|
|
4297
|
+
if (!o) return;
|
|
4298
|
+
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
4299
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4300
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4301
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
4302
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
4303
|
+
}
|
|
4304
|
+
function useSubmit(url, transformData) {
|
|
4305
|
+
var ref = _slicedToArray$1(useAsyncFn(function() {
|
|
4306
|
+
var _ref = _asyncToGenerator(regeneratorRuntime$1.mark(function _callee(json) {
|
|
4307
|
+
var response;
|
|
4308
|
+
return regeneratorRuntime$1.wrap(function _callee$(_ctx) {
|
|
4309
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
4310
|
+
case 0:
|
|
4311
|
+
if (transformData) json = transformData(json);
|
|
4312
|
+
_ctx.next = 3;
|
|
4313
|
+
return api.post(url, {
|
|
4314
|
+
json: json
|
|
4315
|
+
});
|
|
4316
|
+
case 3:
|
|
4317
|
+
response = _ctx.sent;
|
|
4318
|
+
if ("production" !== process.env["NODE_ENV"]) {
|
|
4319
|
+
console.log("[@koine/next] useSubmit response", response);
|
|
4320
|
+
}
|
|
4321
|
+
return _ctx.abrupt("return", response);
|
|
4322
|
+
case 6:
|
|
4323
|
+
case "end":
|
|
4324
|
+
return _ctx.stop();
|
|
4325
|
+
}
|
|
4326
|
+
}, _callee);
|
|
4327
|
+
}));
|
|
4328
|
+
return function(json) {
|
|
4329
|
+
return _ref.apply(this, arguments);
|
|
4330
|
+
};
|
|
4331
|
+
}(), [
|
|
4332
|
+
url,
|
|
4333
|
+
transformData
|
|
4334
|
+
]), 2), state = ref[0], submit = ref[1];
|
|
4335
|
+
var loading = state.loading, error = state.error, value = state.value;
|
|
4336
|
+
var fail = !loading && (!!error || (value === null || value === void 0 ? void 0 : value.fail));
|
|
4337
|
+
return _objectSpread({
|
|
4338
|
+
submit: submit,
|
|
4339
|
+
loading: loading
|
|
4340
|
+
}, value || {}, {
|
|
4341
|
+
fail: fail
|
|
4342
|
+
});
|
|
4343
|
+
}
|
|
4344
|
+
|
|
4345
|
+
function _arrayLikeToArray(arr, len) {
|
|
4346
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4347
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4348
|
+
return arr2;
|
|
4349
|
+
}
|
|
4350
|
+
function _arrayWithHoles(arr) {
|
|
4351
|
+
if (Array.isArray(arr)) return arr;
|
|
4352
|
+
}
|
|
4353
|
+
function _extends$1() {
|
|
4354
|
+
_extends$1 = Object.assign || function(target) {
|
|
4355
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4356
|
+
var source = arguments[i];
|
|
4357
|
+
for(var key in source){
|
|
4358
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
4359
|
+
target[key] = source[key];
|
|
4360
|
+
}
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
return target;
|
|
4364
|
+
};
|
|
4365
|
+
return _extends$1.apply(this, arguments);
|
|
4366
|
+
}
|
|
4367
|
+
function _iterableToArrayLimit(arr, i) {
|
|
4368
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
4369
|
+
if (_i == null) return;
|
|
4370
|
+
var _arr = [];
|
|
4371
|
+
var _n = true;
|
|
4372
|
+
var _d = false;
|
|
4373
|
+
var _s, _e;
|
|
4374
|
+
try {
|
|
4375
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
4376
|
+
_arr.push(_s.value);
|
|
4377
|
+
if (i && _arr.length === i) break;
|
|
4378
|
+
}
|
|
4379
|
+
} catch (err) {
|
|
4380
|
+
_d = true;
|
|
4381
|
+
_e = err;
|
|
4382
|
+
} finally{
|
|
4383
|
+
try {
|
|
4384
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
4385
|
+
} finally{
|
|
4386
|
+
if (_d) throw _e;
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4389
|
+
return _arr;
|
|
4390
|
+
}
|
|
4391
|
+
function _nonIterableRest() {
|
|
4392
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4393
|
+
}
|
|
4394
|
+
function _objectWithoutProperties$1(source, excluded) {
|
|
4395
|
+
if (source == null) return {};
|
|
4396
|
+
var target = _objectWithoutPropertiesLoose$1(source, excluded);
|
|
4397
|
+
var key, i;
|
|
4398
|
+
if (Object.getOwnPropertySymbols) {
|
|
4399
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
4400
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
4401
|
+
key = sourceSymbolKeys[i];
|
|
4402
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
4403
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
4404
|
+
target[key] = source[key];
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
return target;
|
|
4408
|
+
}
|
|
4409
|
+
function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
4410
|
+
if (source == null) return {};
|
|
4411
|
+
var target = {};
|
|
4412
|
+
var sourceKeys = Object.keys(source);
|
|
4413
|
+
var key, i;
|
|
4414
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
4415
|
+
key = sourceKeys[i];
|
|
4416
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
4417
|
+
target[key] = source[key];
|
|
4418
|
+
}
|
|
4419
|
+
return target;
|
|
4420
|
+
}
|
|
4421
|
+
function _slicedToArray(arr, i) {
|
|
4422
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
4423
|
+
}
|
|
4424
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
4425
|
+
if (!o) return;
|
|
4426
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
4427
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
4428
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
4429
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
4430
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
4431
|
+
}
|
|
4432
|
+
var NextImg = function(props) {
|
|
4433
|
+
return /*#__PURE__*/ React.createElement(NextImage, _extends$1({}, props));
|
|
4434
|
+
};
|
|
4435
|
+
var NextImgSmart = function(props) {
|
|
4436
|
+
var ref = _slicedToArray(useState(false), 2), $loaded = ref[0], setLoaded = ref[1];
|
|
4437
|
+
var ref1 = _slicedToArray(useState(false), 2), $error = ref1[0], setError = ref1[1];
|
|
4438
|
+
var ref2 = getNextImgProps(props), nextImgProps = ref2.nextImgProps, restProps = ref2.restProps;
|
|
4439
|
+
var Wrap = restProps.Wrap;
|
|
4440
|
+
return nextImgProps.priority ? /*#__PURE__*/ React.createElement(NextImage, _extends$1({}, nextImgProps)) : /*#__PURE__*/ React.createElement(Wrap, _extends$1({}, restProps, {
|
|
4441
|
+
$loaded: $loaded,
|
|
4442
|
+
$error: $error
|
|
4443
|
+
}), /*#__PURE__*/ React.createElement(NextImage, _extends$1({}, nextImgProps, {
|
|
4444
|
+
onLoadingComplete: function() {
|
|
4445
|
+
return setLoaded(true);
|
|
4446
|
+
},
|
|
4447
|
+
onError: function() {
|
|
4448
|
+
return setError(true);
|
|
4449
|
+
}
|
|
4450
|
+
})));
|
|
4451
|
+
};
|
|
4452
|
+
function getNextImgProps(_param) {
|
|
4453
|
+
var src = _param.src, alt = _param.alt, layout = _param.layout, blurDataURL = _param.blurDataURL, width = _param.width, height = _param.height, priority = _param.priority, objectFit = _param.objectFit, objectPosition = _param.objectPosition, restProps = _objectWithoutProperties$1(_param, [
|
|
4454
|
+
"src",
|
|
4455
|
+
"alt",
|
|
4456
|
+
"layout",
|
|
4457
|
+
"blurDataURL",
|
|
4458
|
+
"width",
|
|
4459
|
+
"height",
|
|
4460
|
+
"priority",
|
|
4461
|
+
"objectFit",
|
|
4462
|
+
"objectPosition"
|
|
4463
|
+
]);
|
|
4464
|
+
var nextImgProps = {
|
|
4465
|
+
src: src,
|
|
4466
|
+
alt: alt,
|
|
4467
|
+
layout: layout,
|
|
4468
|
+
blurDataURL: blurDataURL,
|
|
4469
|
+
width: width,
|
|
4470
|
+
height: height,
|
|
4471
|
+
priority: priority,
|
|
4472
|
+
objectFit: objectFit,
|
|
4473
|
+
objectPosition: objectPosition
|
|
4474
|
+
};
|
|
4475
|
+
return {
|
|
4476
|
+
nextImgProps: nextImgProps,
|
|
4477
|
+
restProps: restProps
|
|
4478
|
+
};
|
|
4479
|
+
}
|
|
4480
|
+
|
|
4481
|
+
function _extends() {
|
|
4482
|
+
_extends = Object.assign || function(target) {
|
|
4483
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4484
|
+
var source = arguments[i];
|
|
4485
|
+
for(var key in source){
|
|
4486
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
4487
|
+
target[key] = source[key];
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
return target;
|
|
4492
|
+
};
|
|
4493
|
+
return _extends.apply(this, arguments);
|
|
4494
|
+
}
|
|
4495
|
+
function _objectWithoutProperties(source, excluded) {
|
|
4496
|
+
if (source == null) return {};
|
|
4497
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
4498
|
+
var key, i;
|
|
4499
|
+
if (Object.getOwnPropertySymbols) {
|
|
4500
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
4501
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
4502
|
+
key = sourceSymbolKeys[i];
|
|
4503
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
4504
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
4505
|
+
target[key] = source[key];
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
return target;
|
|
4509
|
+
}
|
|
4510
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
4511
|
+
if (source == null) return {};
|
|
4512
|
+
var target = {};
|
|
4513
|
+
var sourceKeys = Object.keys(source);
|
|
4514
|
+
var key, i;
|
|
4515
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
4516
|
+
key = sourceKeys[i];
|
|
4517
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
4518
|
+
target[key] = source[key];
|
|
4519
|
+
}
|
|
4520
|
+
return target;
|
|
4521
|
+
}
|
|
4522
|
+
var Link = /*#__PURE__*/ forwardRef(function Link(_param, ref) {
|
|
4523
|
+
var href = _param.href; _param.prefetch; var replace = _param.replace, scroll = _param.scroll, shallow = _param.shallow, locale = _param.locale, props = _objectWithoutProperties(_param, [
|
|
4524
|
+
"href",
|
|
4525
|
+
"prefetch",
|
|
4526
|
+
"replace",
|
|
4527
|
+
"scroll",
|
|
4528
|
+
"shallow",
|
|
4529
|
+
"locale"
|
|
4530
|
+
]);
|
|
4531
|
+
return /*#__PURE__*/ React.createElement(NextLink, {
|
|
4532
|
+
href: href,
|
|
4533
|
+
replace: replace,
|
|
4534
|
+
scroll: scroll,
|
|
4535
|
+
shallow: shallow,
|
|
4536
|
+
locale: locale,
|
|
4537
|
+
passHref: true
|
|
4538
|
+
}, /*#__PURE__*/ React.createElement(KoineLink, _extends({
|
|
4539
|
+
ref: ref
|
|
4540
|
+
}, props)));
|
|
4541
|
+
});
|
|
4542
|
+
|
|
4543
|
+
var ONE_HOUR = 3600;
|
|
4544
|
+
var ONE_DAY = 84000;
|
|
4545
|
+
/**
|
|
4546
|
+
* Get site absolute url with the given path
|
|
4547
|
+
*
|
|
4548
|
+
* - It uses the `NEXT_PUBLIC_APP_URL` env variable
|
|
4549
|
+
* - It removes the trailing slashes
|
|
4550
|
+
*/ function getSiteUrl() {
|
|
4551
|
+
var path = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
4552
|
+
return normaliseUrl("".concat(process.env["NEXT_PUBLIC_APP_URL"], "/").concat(path));
|
|
4553
|
+
}
|
|
4554
|
+
/**
|
|
4555
|
+
* Utility to load a component with an optional pre-determined delay.
|
|
4556
|
+
*
|
|
4557
|
+
* This was designed to improve anti spam wit async form loading.
|
|
4558
|
+
*
|
|
4559
|
+
* @see https://github.com/vercel/next.js/blob/main/packages/next/next-server/lib/dynamic.tsx
|
|
4560
|
+
* @see https://github.com/vercel/next.js/blob/canary/examples/with-dynamic-import/pages/index.js
|
|
4561
|
+
*/ function load(component, milliseconds) {
|
|
4562
|
+
return new Promise(function(resolve) {
|
|
4563
|
+
setTimeout(function() {
|
|
4564
|
+
return resolve(component);
|
|
4565
|
+
}, milliseconds);
|
|
4566
|
+
});
|
|
4567
|
+
}
|
|
4568
|
+
|
|
4569
|
+
export { AUTH_ROUTES, AnalyticsGoogle, AppAuthEmotion, AppAuthSc, AppBase, AppEmotion, AppHead, AppMain, AppMainVanilla, AppThemeEmotion, AppThemeSc, AppThemeVanilla, AppVanilla, Document, DocumentEmotion, DocumentSc, DocumentVanilla, Favicon, Link, NextImg, NextImgSmart, NextProgress, ONE_DAY, ONE_HOUR, Seo, SeoDefaults, ThemeProvider, api, buildTags, createEmotionCache, getAuthRoutes, getCallbackUrl, getNextImgProps, getSiteUrl, load, translationAsOptions, useDateFormat, useForm, useLogin, useLoginUrl, useLogout, useLooseT, useSubmit, useT, useTheme };
|