wcz-test 6.10.1 → 6.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ import { createIsomorphicFn, createServerFn } from "@tanstack/react-start";
6
6
  import { getCookie } from "@tanstack/react-start/server";
7
7
  import dayjs from "dayjs";
8
8
  import i18n from "i18next";
9
- import LanguageDetector from "i18next-browser-languagedetector";
10
9
  import { useState, useId, useRef, Fragment, useEffect, useEffectEvent } from "react";
11
10
  import { useTranslation, initReactI18next } from "react-i18next";
12
11
  import { resources } from "virtual:wcz-layout";
@@ -46,6 +45,420 @@ import SettingsBrightness from "@mui/icons-material/SettingsBrightness";
46
45
  import Translate from "@mui/icons-material/Translate";
47
46
  import Done from "@mui/icons-material/Done";
48
47
  import { r } from "./utils-JYv9O0GI.js";
48
+ const {
49
+ slice,
50
+ forEach
51
+ } = [];
52
+ function defaults(obj) {
53
+ forEach.call(slice.call(arguments, 1), (source) => {
54
+ if (source) {
55
+ for (const prop in source) {
56
+ if (obj[prop] === void 0) obj[prop] = source[prop];
57
+ }
58
+ }
59
+ });
60
+ return obj;
61
+ }
62
+ function hasXSS(input) {
63
+ if (typeof input !== "string") return false;
64
+ const xssPatterns = [/<\s*script.*?>/i, /<\s*\/\s*script\s*>/i, /<\s*img.*?on\w+\s*=/i, /<\s*\w+\s*on\w+\s*=.*?>/i, /javascript\s*:/i, /vbscript\s*:/i, /expression\s*\(/i, /eval\s*\(/i, /alert\s*\(/i, /document\.cookie/i, /document\.write\s*\(/i, /window\.location/i, /innerHTML/i];
65
+ return xssPatterns.some((pattern) => pattern.test(input));
66
+ }
67
+ const fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
68
+ const serializeCookie = function(name, val) {
69
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
70
+ path: "/"
71
+ };
72
+ const opt = options;
73
+ const value = encodeURIComponent(val);
74
+ let str = `${name}=${value}`;
75
+ if (opt.maxAge > 0) {
76
+ const maxAge = opt.maxAge - 0;
77
+ if (Number.isNaN(maxAge)) throw new Error("maxAge should be a Number");
78
+ str += `; Max-Age=${Math.floor(maxAge)}`;
79
+ }
80
+ if (opt.domain) {
81
+ if (!fieldContentRegExp.test(opt.domain)) {
82
+ throw new TypeError("option domain is invalid");
83
+ }
84
+ str += `; Domain=${opt.domain}`;
85
+ }
86
+ if (opt.path) {
87
+ if (!fieldContentRegExp.test(opt.path)) {
88
+ throw new TypeError("option path is invalid");
89
+ }
90
+ str += `; Path=${opt.path}`;
91
+ }
92
+ if (opt.expires) {
93
+ if (typeof opt.expires.toUTCString !== "function") {
94
+ throw new TypeError("option expires is invalid");
95
+ }
96
+ str += `; Expires=${opt.expires.toUTCString()}`;
97
+ }
98
+ if (opt.httpOnly) str += "; HttpOnly";
99
+ if (opt.secure) str += "; Secure";
100
+ if (opt.sameSite) {
101
+ const sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
102
+ switch (sameSite) {
103
+ case true:
104
+ str += "; SameSite=Strict";
105
+ break;
106
+ case "lax":
107
+ str += "; SameSite=Lax";
108
+ break;
109
+ case "strict":
110
+ str += "; SameSite=Strict";
111
+ break;
112
+ case "none":
113
+ str += "; SameSite=None";
114
+ break;
115
+ default:
116
+ throw new TypeError("option sameSite is invalid");
117
+ }
118
+ }
119
+ if (opt.partitioned) str += "; Partitioned";
120
+ return str;
121
+ };
122
+ const cookie = {
123
+ create(name, value, minutes, domain) {
124
+ let cookieOptions = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
125
+ path: "/",
126
+ sameSite: "strict"
127
+ };
128
+ if (minutes) {
129
+ cookieOptions.expires = /* @__PURE__ */ new Date();
130
+ cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1e3);
131
+ }
132
+ if (domain) cookieOptions.domain = domain;
133
+ document.cookie = serializeCookie(name, value, cookieOptions);
134
+ },
135
+ read(name) {
136
+ const nameEQ = `${name}=`;
137
+ const ca = document.cookie.split(";");
138
+ for (let i = 0; i < ca.length; i++) {
139
+ let c = ca[i];
140
+ while (c.charAt(0) === " ") c = c.substring(1, c.length);
141
+ if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
142
+ }
143
+ return null;
144
+ },
145
+ remove(name, domain) {
146
+ this.create(name, "", -1, domain);
147
+ }
148
+ };
149
+ var cookie$1 = {
150
+ name: "cookie",
151
+ // Deconstruct the options object and extract the lookupCookie property
152
+ lookup(_ref) {
153
+ let {
154
+ lookupCookie
155
+ } = _ref;
156
+ if (lookupCookie && typeof document !== "undefined") {
157
+ return cookie.read(lookupCookie) || void 0;
158
+ }
159
+ return void 0;
160
+ },
161
+ // Deconstruct the options object and extract the lookupCookie, cookieMinutes, cookieDomain, and cookieOptions properties
162
+ cacheUserLanguage(lng, _ref2) {
163
+ let {
164
+ lookupCookie,
165
+ cookieMinutes,
166
+ cookieDomain,
167
+ cookieOptions
168
+ } = _ref2;
169
+ if (lookupCookie && typeof document !== "undefined") {
170
+ cookie.create(lookupCookie, lng, cookieMinutes, cookieDomain, cookieOptions);
171
+ }
172
+ }
173
+ };
174
+ var querystring = {
175
+ name: "querystring",
176
+ // Deconstruct the options object and extract the lookupQuerystring property
177
+ lookup(_ref) {
178
+ let {
179
+ lookupQuerystring
180
+ } = _ref;
181
+ let found;
182
+ if (typeof window !== "undefined") {
183
+ let {
184
+ search
185
+ } = window.location;
186
+ if (!window.location.search && window.location.hash?.indexOf("?") > -1) {
187
+ search = window.location.hash.substring(window.location.hash.indexOf("?"));
188
+ }
189
+ const query = search.substring(1);
190
+ const params = query.split("&");
191
+ for (let i = 0; i < params.length; i++) {
192
+ const pos = params[i].indexOf("=");
193
+ if (pos > 0) {
194
+ const key = params[i].substring(0, pos);
195
+ if (key === lookupQuerystring) {
196
+ found = params[i].substring(pos + 1);
197
+ }
198
+ }
199
+ }
200
+ }
201
+ return found;
202
+ }
203
+ };
204
+ var hash = {
205
+ name: "hash",
206
+ // Deconstruct the options object and extract the lookupHash property and the lookupFromHashIndex property
207
+ lookup(_ref) {
208
+ let {
209
+ lookupHash,
210
+ lookupFromHashIndex
211
+ } = _ref;
212
+ let found;
213
+ if (typeof window !== "undefined") {
214
+ const {
215
+ hash: hash2
216
+ } = window.location;
217
+ if (hash2 && hash2.length > 2) {
218
+ const query = hash2.substring(1);
219
+ if (lookupHash) {
220
+ const params = query.split("&");
221
+ for (let i = 0; i < params.length; i++) {
222
+ const pos = params[i].indexOf("=");
223
+ if (pos > 0) {
224
+ const key = params[i].substring(0, pos);
225
+ if (key === lookupHash) {
226
+ found = params[i].substring(pos + 1);
227
+ }
228
+ }
229
+ }
230
+ }
231
+ if (found) return found;
232
+ if (!found && lookupFromHashIndex > -1) {
233
+ const language = hash2.match(/\/([a-zA-Z-]*)/g);
234
+ if (!Array.isArray(language)) return void 0;
235
+ const index = typeof lookupFromHashIndex === "number" ? lookupFromHashIndex : 0;
236
+ return language[index]?.replace("/", "");
237
+ }
238
+ }
239
+ }
240
+ return found;
241
+ }
242
+ };
243
+ let hasLocalStorageSupport = null;
244
+ const localStorageAvailable = () => {
245
+ if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
246
+ try {
247
+ hasLocalStorageSupport = typeof window !== "undefined" && window.localStorage !== null;
248
+ if (!hasLocalStorageSupport) {
249
+ return false;
250
+ }
251
+ const testKey = "i18next.translate.boo";
252
+ window.localStorage.setItem(testKey, "foo");
253
+ window.localStorage.removeItem(testKey);
254
+ } catch (e) {
255
+ hasLocalStorageSupport = false;
256
+ }
257
+ return hasLocalStorageSupport;
258
+ };
259
+ var localStorage = {
260
+ name: "localStorage",
261
+ // Deconstruct the options object and extract the lookupLocalStorage property
262
+ lookup(_ref) {
263
+ let {
264
+ lookupLocalStorage
265
+ } = _ref;
266
+ if (lookupLocalStorage && localStorageAvailable()) {
267
+ return window.localStorage.getItem(lookupLocalStorage) || void 0;
268
+ }
269
+ return void 0;
270
+ },
271
+ // Deconstruct the options object and extract the lookupLocalStorage property
272
+ cacheUserLanguage(lng, _ref2) {
273
+ let {
274
+ lookupLocalStorage
275
+ } = _ref2;
276
+ if (lookupLocalStorage && localStorageAvailable()) {
277
+ window.localStorage.setItem(lookupLocalStorage, lng);
278
+ }
279
+ }
280
+ };
281
+ let hasSessionStorageSupport = null;
282
+ const sessionStorageAvailable = () => {
283
+ if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
284
+ try {
285
+ hasSessionStorageSupport = typeof window !== "undefined" && window.sessionStorage !== null;
286
+ if (!hasSessionStorageSupport) {
287
+ return false;
288
+ }
289
+ const testKey = "i18next.translate.boo";
290
+ window.sessionStorage.setItem(testKey, "foo");
291
+ window.sessionStorage.removeItem(testKey);
292
+ } catch (e) {
293
+ hasSessionStorageSupport = false;
294
+ }
295
+ return hasSessionStorageSupport;
296
+ };
297
+ var sessionStorage = {
298
+ name: "sessionStorage",
299
+ lookup(_ref) {
300
+ let {
301
+ lookupSessionStorage
302
+ } = _ref;
303
+ if (lookupSessionStorage && sessionStorageAvailable()) {
304
+ return window.sessionStorage.getItem(lookupSessionStorage) || void 0;
305
+ }
306
+ return void 0;
307
+ },
308
+ cacheUserLanguage(lng, _ref2) {
309
+ let {
310
+ lookupSessionStorage
311
+ } = _ref2;
312
+ if (lookupSessionStorage && sessionStorageAvailable()) {
313
+ window.sessionStorage.setItem(lookupSessionStorage, lng);
314
+ }
315
+ }
316
+ };
317
+ var navigator$1 = {
318
+ name: "navigator",
319
+ lookup(options) {
320
+ const found = [];
321
+ if (typeof navigator !== "undefined") {
322
+ const {
323
+ languages,
324
+ userLanguage,
325
+ language
326
+ } = navigator;
327
+ if (languages) {
328
+ for (let i = 0; i < languages.length; i++) {
329
+ found.push(languages[i]);
330
+ }
331
+ }
332
+ if (userLanguage) {
333
+ found.push(userLanguage);
334
+ }
335
+ if (language) {
336
+ found.push(language);
337
+ }
338
+ }
339
+ return found.length > 0 ? found : void 0;
340
+ }
341
+ };
342
+ var htmlTag = {
343
+ name: "htmlTag",
344
+ // Deconstruct the options object and extract the htmlTag property
345
+ lookup(_ref) {
346
+ let {
347
+ htmlTag: htmlTag2
348
+ } = _ref;
349
+ let found;
350
+ const internalHtmlTag = htmlTag2 || (typeof document !== "undefined" ? document.documentElement : null);
351
+ if (internalHtmlTag && typeof internalHtmlTag.getAttribute === "function") {
352
+ found = internalHtmlTag.getAttribute("lang");
353
+ }
354
+ return found;
355
+ }
356
+ };
357
+ var path = {
358
+ name: "path",
359
+ // Deconstruct the options object and extract the lookupFromPathIndex property
360
+ lookup(_ref) {
361
+ let {
362
+ lookupFromPathIndex
363
+ } = _ref;
364
+ if (typeof window === "undefined") return void 0;
365
+ const language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
366
+ if (!Array.isArray(language)) return void 0;
367
+ const index = typeof lookupFromPathIndex === "number" ? lookupFromPathIndex : 0;
368
+ return language[index]?.replace("/", "");
369
+ }
370
+ };
371
+ var subdomain = {
372
+ name: "subdomain",
373
+ lookup(_ref) {
374
+ let {
375
+ lookupFromSubdomainIndex
376
+ } = _ref;
377
+ const internalLookupFromSubdomainIndex = typeof lookupFromSubdomainIndex === "number" ? lookupFromSubdomainIndex + 1 : 1;
378
+ const language = typeof window !== "undefined" && window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
379
+ if (!language) return void 0;
380
+ return language[internalLookupFromSubdomainIndex];
381
+ }
382
+ };
383
+ let canCookies = false;
384
+ try {
385
+ document.cookie;
386
+ canCookies = true;
387
+ } catch (e) {
388
+ }
389
+ const order = ["querystring", "cookie", "localStorage", "sessionStorage", "navigator", "htmlTag"];
390
+ if (!canCookies) order.splice(1, 1);
391
+ const getDefaults = () => ({
392
+ order,
393
+ lookupQuerystring: "lng",
394
+ lookupCookie: "i18next",
395
+ lookupLocalStorage: "i18nextLng",
396
+ lookupSessionStorage: "i18nextLng",
397
+ // cache user language
398
+ caches: ["localStorage"],
399
+ excludeCacheFor: ["cimode"],
400
+ // cookieMinutes: 10,
401
+ // cookieDomain: 'myDomain'
402
+ convertDetectedLanguage: (l) => l
403
+ });
404
+ class Browser {
405
+ constructor(services) {
406
+ let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
407
+ this.type = "languageDetector";
408
+ this.detectors = {};
409
+ this.init(services, options);
410
+ }
411
+ init() {
412
+ let services = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
413
+ languageUtils: {}
414
+ };
415
+ let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
416
+ let i18nOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
417
+ this.services = services;
418
+ this.options = defaults(options, this.options || {}, getDefaults());
419
+ if (typeof this.options.convertDetectedLanguage === "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1) {
420
+ this.options.convertDetectedLanguage = (l) => l.replace("-", "_");
421
+ }
422
+ if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
423
+ this.i18nOptions = i18nOptions;
424
+ this.addDetector(cookie$1);
425
+ this.addDetector(querystring);
426
+ this.addDetector(localStorage);
427
+ this.addDetector(sessionStorage);
428
+ this.addDetector(navigator$1);
429
+ this.addDetector(htmlTag);
430
+ this.addDetector(path);
431
+ this.addDetector(subdomain);
432
+ this.addDetector(hash);
433
+ }
434
+ addDetector(detector) {
435
+ this.detectors[detector.name] = detector;
436
+ return this;
437
+ }
438
+ detect() {
439
+ let detectionOrder = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.order;
440
+ let detected = [];
441
+ detectionOrder.forEach((detectorName) => {
442
+ if (this.detectors[detectorName]) {
443
+ let lookup = this.detectors[detectorName].lookup(this.options);
444
+ if (lookup && typeof lookup === "string") lookup = [lookup];
445
+ if (lookup) detected = detected.concat(lookup);
446
+ }
447
+ });
448
+ detected = detected.filter((d) => d !== void 0 && d !== null && !hasXSS(d)).map((d) => this.options.convertDetectedLanguage(d));
449
+ if (this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes) return detected;
450
+ return detected.length > 0 ? detected[0] : null;
451
+ }
452
+ cacheUserLanguage(lng) {
453
+ let caches = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.caches;
454
+ if (!caches) return;
455
+ if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
456
+ caches.forEach((cacheName) => {
457
+ if (this.detectors[cacheName]) this.detectors[cacheName].cacheUserLanguage(lng, this.options);
458
+ });
459
+ }
460
+ }
461
+ Browser.type = "languageDetector";
49
462
  function DialogsProvider({ children, unmountAfter = 1e3 }) {
50
463
  const [stack, setStack] = useState([]);
51
464
  const keyPrefix = useId();
@@ -554,11 +967,11 @@ const ToolbarAccount = () => {
554
967
  };
555
968
  const YEAR_IN_SECONDS = 60 * 60 * 24 * 365;
556
969
  const getNavigationOpenStatus = createIsomorphicFn().server(() => {
557
- const cookie = getCookie("navigationOpen");
558
- return cookie === "true";
970
+ const cookie2 = getCookie("navigationOpen");
971
+ return cookie2 === "true";
559
972
  }).client(() => {
560
- const cookie = document.cookie.split("; ").find((row) => row.startsWith("navigationOpen="));
561
- return cookie ? cookie.split("=")[1] === "true" : false;
973
+ const cookie2 = document.cookie.split("; ").find((row) => row.startsWith("navigationOpen="));
974
+ return cookie2 ? cookie2.split("=")[1] === "true" : false;
562
975
  });
563
976
  const DrawerHeader = styled("div")(({ theme }) => ({
564
977
  display: "flex",
@@ -625,7 +1038,7 @@ const Layout = (props) => {
625
1038
  ] });
626
1039
  };
627
1040
  const YEAR_IN_MINUTES = 60 * 24 * 365;
628
- i18n.use(LanguageDetector).use(initReactI18next).init({
1041
+ i18n.use(Browser).use(initReactI18next).init({
629
1042
  resources,
630
1043
  fallbackLng: "en",
631
1044
  supportedLngs: Object.keys(resources),