@mantou/gem 1.7.1 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/gem.es.js +367 -369
  2. package/dist/gem.umd.js +24 -28
  3. package/elements/base/dialog.d.ts +7 -7
  4. package/elements/base/dialog.d.ts.map +1 -1
  5. package/elements/base/dialog.js +10 -3
  6. package/elements/base/dialog.js.map +1 -1
  7. package/elements/base/gesture.d.ts +4 -13
  8. package/elements/base/gesture.d.ts.map +1 -1
  9. package/elements/base/gesture.js +151 -134
  10. package/elements/base/gesture.js.map +1 -1
  11. package/elements/base/link.d.ts +10 -10
  12. package/elements/base/link.d.ts.map +1 -1
  13. package/elements/base/link.js +69 -63
  14. package/elements/base/link.js.map +1 -1
  15. package/elements/base/modal-factory.d.ts +117 -83
  16. package/elements/base/modal-factory.d.ts.map +1 -1
  17. package/elements/base/modal-factory.js +12 -8
  18. package/elements/base/modal-factory.js.map +1 -1
  19. package/elements/base/reflect.js.map +1 -1
  20. package/elements/base/route.d.ts +12 -5
  21. package/elements/base/route.d.ts.map +1 -1
  22. package/elements/base/route.js +16 -4
  23. package/elements/base/route.js.map +1 -1
  24. package/elements/base/title.d.ts +3 -1
  25. package/elements/base/title.d.ts.map +1 -1
  26. package/elements/base/title.js +14 -16
  27. package/elements/base/title.js.map +1 -1
  28. package/elements/base/unsafe.js.map +1 -1
  29. package/elements/base/use.d.ts +1 -1
  30. package/elements/base/use.d.ts.map +1 -1
  31. package/elements/base/use.js +27 -17
  32. package/elements/base/use.js.map +1 -1
  33. package/helper/i18n.d.ts +2 -2
  34. package/helper/i18n.d.ts.map +1 -1
  35. package/helper/i18n.js.map +1 -1
  36. package/helper/mediaquery.d.ts +16 -18
  37. package/helper/mediaquery.d.ts.map +1 -1
  38. package/helper/mediaquery.js +42 -41
  39. package/helper/mediaquery.js.map +1 -1
  40. package/helper/request.d.ts +1 -1
  41. package/helper/request.d.ts.map +1 -1
  42. package/helper/request.js.map +1 -1
  43. package/helper/ssr-shim.js.map +1 -1
  44. package/helper/theme.d.ts +2 -2
  45. package/helper/theme.d.ts.map +1 -1
  46. package/helper/theme.js +20 -24
  47. package/helper/theme.js.map +1 -1
  48. package/lib/decorators.d.ts +4 -4
  49. package/lib/decorators.d.ts.map +1 -1
  50. package/lib/decorators.js +1 -2
  51. package/lib/decorators.js.map +1 -1
  52. package/lib/element.d.ts +5 -7
  53. package/lib/element.d.ts.map +1 -1
  54. package/lib/element.js +46 -71
  55. package/lib/element.js.map +1 -1
  56. package/lib/history.d.ts +1 -1
  57. package/lib/history.d.ts.map +1 -1
  58. package/lib/history.js +2 -2
  59. package/lib/history.js.map +1 -1
  60. package/lib/store.d.ts +2 -2
  61. package/lib/store.d.ts.map +1 -1
  62. package/lib/store.js.map +1 -1
  63. package/lib/utils.d.ts +8 -32
  64. package/lib/utils.d.ts.map +1 -1
  65. package/lib/utils.js +7 -22
  66. package/lib/utils.js.map +1 -1
  67. package/lib/version.d.ts +1 -1
  68. package/lib/version.js +1 -1
  69. package/package.json +2 -2
  70. package/src/elements/base/dialog.ts +8 -3
  71. package/src/elements/base/gesture.ts +51 -45
  72. package/src/elements/base/link.ts +64 -62
  73. package/src/elements/base/modal-factory.ts +5 -0
  74. package/src/elements/base/route.ts +21 -4
  75. package/src/elements/base/title.ts +8 -11
  76. package/src/elements/base/use.ts +3 -3
  77. package/src/helper/mediaquery.ts +43 -42
  78. package/src/helper/theme.ts +22 -24
  79. package/src/lib/decorators.ts +1 -2
  80. package/src/lib/element.ts +38 -63
  81. package/src/lib/history.ts +2 -1
  82. package/src/lib/utils.ts +11 -43
  83. package/src/lib/version.ts +1 -1
  84. package/src/test/gem-element/advance.test.ts +16 -8
  85. package/src/test/history.test.ts +3 -1
  86. package/src/test/utils.test.ts +8 -1
package/dist/gem.es.js CHANGED
@@ -1,22 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
1
  var __accessCheck = (obj, member, msg) => {
21
2
  if (!member.has(obj))
22
3
  throw TypeError("Cannot " + msg);
@@ -39,10 +20,9 @@ var __privateMethod = (obj, member, method) => {
39
20
  __accessCheck(obj, member, "access private method");
40
21
  return method;
41
22
  };
42
- var _map, _firstItem, _lastItem, _delete, delete_fn, _stringify, _parse, _routeOptions, routeOptions_get, _a, _nextSibling, _parentElement, _inertStore, _b, _cacheCurrentKey, cacheCurrentKey_get, _urlParamsLang, urlParamsLang_get, _cacheLang, cacheLang_get, _isMain, isMain_get, _lang, lang_set;
43
- var GemExports = /* @__PURE__ */ Object.freeze({
23
+ var _map, _firstItem, _lastItem, _delete, delete_fn, _stringify, _parse, _routeOptions, routeOptions_get, _hint, hint_get, _onClick, _preventDefault, _getHint, _a, _getContent, _nextSibling, _parentElement, _inertStore, _b, _cacheCurrentKey, cacheCurrentKey_get, _urlParamsLang, urlParamsLang_get, _cacheLang, cacheLang_get, _isMain, isMain_get, _lang, lang_set;
24
+ var GemExports = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
44
25
  __proto__: null,
45
- [Symbol.toStringTag]: "Module",
46
26
  get GemElement() {
47
27
  return GemElement;
48
28
  },
@@ -88,7 +68,7 @@ var GemExports = /* @__PURE__ */ Object.freeze({
88
68
  get ifDefined() {
89
69
  return ifDefined;
90
70
  }
91
- });
71
+ }, Symbol.toStringTag, { value: "Module" }));
92
72
  /**
93
73
  * @license
94
74
  * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -102,7 +82,7 @@ var GemExports = /* @__PURE__ */ Object.freeze({
102
82
  * subject to an additional IP rights grant found at
103
83
  * http://polymer.github.io/PATENTS.txt
104
84
  */
105
- const directives = new WeakMap();
85
+ const directives = /* @__PURE__ */ new WeakMap();
106
86
  const directive = (f) => (...args) => {
107
87
  const d = f(...args);
108
88
  directives.set(d, true);
@@ -226,9 +206,9 @@ class Template {
226
206
  if (s === "") {
227
207
  insert = createMarker();
228
208
  } else {
229
- const match = lastAttributeNameRegex.exec(s);
230
- if (match !== null && endsWith(match[2], boundAttributeSuffix)) {
231
- s = s.slice(0, match.index) + match[1] + match[2].slice(0, -boundAttributeSuffix.length) + match[3];
209
+ const match2 = lastAttributeNameRegex.exec(s);
210
+ if (match2 !== null && endsWith(match2[2], boundAttributeSuffix)) {
211
+ s = s.slice(0, match2.index) + match2[1] + match2[2].slice(0, -boundAttributeSuffix.length) + match2[3];
232
212
  }
233
213
  insert = document.createTextNode(s);
234
214
  }
@@ -805,8 +785,8 @@ function templateFactory(result) {
805
785
  let templateCache = templateCaches.get(result.type);
806
786
  if (templateCache === void 0) {
807
787
  templateCache = {
808
- stringsArray: new WeakMap(),
809
- keyString: new Map()
788
+ stringsArray: /* @__PURE__ */ new WeakMap(),
789
+ keyString: /* @__PURE__ */ new Map()
810
790
  };
811
791
  templateCaches.set(result.type, templateCache);
812
792
  }
@@ -823,7 +803,7 @@ function templateFactory(result) {
823
803
  templateCache.stringsArray.set(result.strings, template);
824
804
  return template;
825
805
  }
826
- const templateCaches = new Map();
806
+ const templateCaches = /* @__PURE__ */ new Map();
827
807
  /**
828
808
  * @license
829
809
  * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -837,7 +817,7 @@ const templateCaches = new Map();
837
817
  * subject to an additional IP rights grant found at
838
818
  * http://polymer.github.io/PATENTS.txt
839
819
  */
840
- const parts = new WeakMap();
820
+ const parts = /* @__PURE__ */ new WeakMap();
841
821
  const render = (result, container, options) => {
842
822
  let part2 = parts.get(container);
843
823
  if (part2 === void 0) {
@@ -866,7 +846,7 @@ if (typeof window !== "undefined") {
866
846
  }
867
847
  const html = (strings, ...values) => new TemplateResult(strings, values, "html", defaultTemplateProcessor);
868
848
  const svg = (strings, ...values) => new SVGTemplateResult(strings, values, "svg", defaultTemplateProcessor);
869
- const microtaskSet = new Set();
849
+ const microtaskSet = /* @__PURE__ */ new Set();
870
850
  function addMicrotask(func) {
871
851
  if (typeof func !== "function")
872
852
  return;
@@ -896,14 +876,14 @@ function absoluteLocation(currentPath = "", relativePath = "") {
896
876
  const { pathname, search, hash } = new URL(relativePath, location.origin + currentPath);
897
877
  return pathname + search + hash;
898
878
  }
899
- class LinkedList extends (globalThis.EventTarget || Object) {
879
+ class LinkedList extends EventTarget {
900
880
  constructor() {
901
881
  super(...arguments);
902
882
  __privateAdd(this, _delete);
903
883
  __privateAdd(this, _map, void 0);
904
884
  __privateAdd(this, _firstItem, void 0);
905
885
  __privateAdd(this, _lastItem, void 0);
906
- __privateSet(this, _map, new Map());
886
+ __privateSet(this, _map, /* @__PURE__ */ new Map());
907
887
  }
908
888
  get size() {
909
889
  return __privateGet(this, _map).size;
@@ -935,7 +915,7 @@ class LinkedList extends (globalThis.EventTarget || Object) {
935
915
  const firstItem = __privateGet(this, _firstItem);
936
916
  if (!firstItem)
937
917
  return;
938
- __privateMethod(this, _delete, delete_fn).call(this, firstItem.value);
918
+ this.delete(firstItem.value);
939
919
  return firstItem.value;
940
920
  }
941
921
  }
@@ -1030,20 +1010,6 @@ function css(arr, ...args) {
1030
1010
  return raw(arr, ...args);
1031
1011
  }
1032
1012
  const SheetToken = Symbol.for("gem@sheetToken");
1033
- let useNativeCSSStyleSheet = true;
1034
- let CSSStyleSheet = globalThis.CSSStyleSheet;
1035
- try {
1036
- new CSSStyleSheet();
1037
- } catch {
1038
- useNativeCSSStyleSheet = false;
1039
- CSSStyleSheet = class {
1040
- constructor() {
1041
- this.media = { mediaText: "" };
1042
- this.style = "";
1043
- this.replaceSync = (style) => this.style = style;
1044
- }
1045
- };
1046
- }
1047
1013
  function createCSSSheet(rules, mediaQuery2 = "") {
1048
1014
  const styleSheet = new CSSStyleSheet();
1049
1015
  const sheet = {};
@@ -1142,21 +1108,29 @@ function objectMapToString(object, separate, toString) {
1142
1108
  return result;
1143
1109
  }
1144
1110
  function styleMap(object) {
1145
- return objectMapToString(object, ";", (key2, value) => value !== void 0 ? `${camelToKebabCase(key2)}:${value}` : "");
1111
+ return objectMapToString(
1112
+ object,
1113
+ ";",
1114
+ (key2, value) => value !== void 0 ? `${camelToKebabCase(key2)}:${value}` : ""
1115
+ );
1146
1116
  }
1147
1117
  function classMap(object) {
1148
1118
  return objectMapToString(object, " ", (key2, value) => value ? key2 : "");
1149
1119
  }
1150
1120
  const partMap = classMap;
1151
1121
  function exportPartsMap(object) {
1152
- return objectMapToString(object, ",", (key2, value) => value !== void 0 ? `${key2}:${value}` : "");
1122
+ return objectMapToString(
1123
+ object,
1124
+ ",",
1125
+ (key2, value) => value === true || key2 === value ? key2 : value ? `${key2}:${value}` : ""
1126
+ );
1153
1127
  }
1154
- const StoreListenerMap = new WeakMap();
1128
+ const StoreListenerMap = /* @__PURE__ */ new WeakMap();
1155
1129
  function createStore(originStore) {
1156
1130
  if (StoreListenerMap.has(originStore)) {
1157
1131
  throw new GemError("argument error");
1158
1132
  }
1159
- StoreListenerMap.set(originStore, new Set());
1133
+ StoreListenerMap.set(originStore, /* @__PURE__ */ new Set());
1160
1134
  return originStore;
1161
1135
  }
1162
1136
  function createStoreSet(originStoreSet) {
@@ -1181,12 +1155,11 @@ function disconnect(store2, func) {
1181
1155
  const listeners = StoreListenerMap.get(store2);
1182
1156
  listeners == null ? void 0 : listeners.delete(func);
1183
1157
  }
1184
- const version = "1.7.1";
1185
- var VersionExports = /* @__PURE__ */ Object.freeze({
1158
+ const version = "1.7.3";
1159
+ var VersionExports = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1186
1160
  __proto__: null,
1187
- [Symbol.toStringTag]: "Module",
1188
1161
  version
1189
- });
1162
+ }, Symbol.toStringTag, { value: "Module" }));
1190
1163
  /**
1191
1164
  * @license
1192
1165
  * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
@@ -1226,14 +1199,14 @@ const removePart = (part2) => {
1226
1199
  removeNodes(part2.startNode.parentNode, part2.startNode, part2.endNode.nextSibling);
1227
1200
  };
1228
1201
  const generateMap = (list, start, end) => {
1229
- const map = new Map();
1202
+ const map = /* @__PURE__ */ new Map();
1230
1203
  for (let i = start; i <= end; i++) {
1231
1204
  map.set(list[i], i);
1232
1205
  }
1233
1206
  return map;
1234
1207
  };
1235
- const partListCache = new WeakMap();
1236
- const keyListCache = new WeakMap();
1208
+ const partListCache = /* @__PURE__ */ new WeakMap();
1209
+ const keyListCache = /* @__PURE__ */ new WeakMap();
1237
1210
  const repeat = directive((items, keyFnOrTemplate, template) => {
1238
1211
  let keyFn;
1239
1212
  if (template === void 0) {
@@ -1340,7 +1313,7 @@ const repeat = directive((items, keyFnOrTemplate, template) => {
1340
1313
  * subject to an additional IP rights grant found at
1341
1314
  * http://polymer.github.io/PATENTS.txt
1342
1315
  */
1343
- const previousValues$1 = new WeakMap();
1316
+ const previousValues$1 = /* @__PURE__ */ new WeakMap();
1344
1317
  const guard = directive((value, f) => (part2) => {
1345
1318
  const previousValue = previousValues$1.get(part2);
1346
1319
  if (Array.isArray(value)) {
@@ -1366,7 +1339,7 @@ const guard = directive((value, f) => (part2) => {
1366
1339
  * subject to an additional IP rights grant found at
1367
1340
  * http://polymer.github.io/PATENTS.txt
1368
1341
  */
1369
- const previousValues = new WeakMap();
1342
+ const previousValues = /* @__PURE__ */ new WeakMap();
1370
1343
  const ifDefined = directive((value) => (part2) => {
1371
1344
  const previousValue = previousValues.get(part2);
1372
1345
  if (value === void 0 && part2 instanceof AttributePart) {
@@ -1397,7 +1370,7 @@ var __privateSet$1 = (obj, member, value, setter) => {
1397
1370
  setter ? setter.call(obj, value) : member.set(obj, value);
1398
1371
  return value;
1399
1372
  };
1400
- var _renderRoot, _internals, _isAppendReason, _isMounted, _isAsync, _effectList, _memoList, _unmountCallback, _exec, _execEffect, _execMemo, _initEffect, _render, _shouldUpdate, _updateCallback, _update, _updated, _connectedCallback;
1373
+ var _final, _renderRoot, _internals, _isAppendReason, _isMounted, _isAsync, _effectList, _memoList, _unmountCallback, _exec, _execEffect, _execMemo, _initEffect, _render, _shouldUpdate, _updateCallback, _update, _updated, _connectedCallback, _filterEffect;
1401
1374
  function emptyFunction() {
1402
1375
  }
1403
1376
  function execCallback(fun) {
@@ -1417,7 +1390,7 @@ asyncRenderTaskList.addEventListener("start", () => addMicrotask(tick));
1417
1390
  const constructorSymbol = Symbol("constructor");
1418
1391
  const initSymbol = Symbol("init");
1419
1392
  const updateSymbol = Symbol("update");
1420
- class GemElement extends HTMLElement {
1393
+ const _GemElement = class extends HTMLElement {
1421
1394
  constructor({ isAsync, isLight, delegatesFocus, slotAssignment } = {}) {
1422
1395
  super();
1423
1396
  __privateAdd$1(this, _renderRoot, void 0);
@@ -1489,18 +1462,10 @@ class GemElement extends HTMLElement {
1489
1462
  });
1490
1463
  });
1491
1464
  __privateAdd$1(this, _render, () => {
1492
- var _a2, _b2;
1493
1465
  __privateGet$1(this, _execMemo).call(this);
1494
- const styles = useNativeCSSStyleSheet ? "" : html`${(_b2 = (_a2 = this.shadowRoot) == null ? void 0 : _a2.adoptedStyleSheets) == null ? void 0 : _b2.map((e) => html`
1495
- <style media=${e.media.mediaText}>
1496
- ${e.style}
1497
- </style>
1498
- `)}`;
1499
- if (this.render) {
1500
- const r = this.render();
1501
- return r && html`${r}${styles}`;
1502
- }
1503
- return __privateGet$1(this, _renderRoot) === this ? void 0 : html`<slot></slot>${styles}`;
1466
+ if (this.render)
1467
+ return this.render();
1468
+ return __privateGet$1(this, _renderRoot) === this ? void 0 : html`<slot></slot>`;
1504
1469
  });
1505
1470
  __privateAdd$1(this, _shouldUpdate, () => {
1506
1471
  return this.shouldUpdate ? this.shouldUpdate() : true;
@@ -1529,11 +1494,11 @@ class GemElement extends HTMLElement {
1529
1494
  });
1530
1495
  __privateAdd$1(this, _connectedCallback, () => {
1531
1496
  var _a2, _b2, _c;
1532
- this[constructorSymbol] = false;
1533
1497
  if (__privateGet$1(this, _isAppendReason)) {
1534
1498
  __privateSet$1(this, _isAppendReason, false);
1535
1499
  return;
1536
1500
  }
1501
+ Reflect.set(this, constructorSymbol, false);
1537
1502
  (_a2 = this.willMount) == null ? void 0 : _a2.call(this);
1538
1503
  const { observedStores, rootElement: rootElement2 } = this.constructor;
1539
1504
  observedStores == null ? void 0 : observedStores.forEach((store2) => {
@@ -1548,14 +1513,18 @@ class GemElement extends HTMLElement {
1548
1513
  throw new GemError(`not allow current root type`);
1549
1514
  }
1550
1515
  });
1551
- this[constructorSymbol] = true;
1552
- addMicrotask(() => this[initSymbol] = false);
1553
- this[initSymbol] = true;
1554
- this[updateSymbol] = () => {
1516
+ __privateAdd$1(this, _filterEffect, (e) => {
1517
+ e.initialized = false;
1518
+ return e.inConstructor;
1519
+ });
1520
+ addMicrotask(() => Reflect.set(this, initSymbol, false));
1521
+ Reflect.set(this, constructorSymbol, true);
1522
+ Reflect.set(this, initSymbol, true);
1523
+ Reflect.set(this, updateSymbol, () => {
1555
1524
  if (__privateGet$1(this, _isMounted)) {
1556
1525
  addMicrotask(__privateGet$1(this, _update));
1557
1526
  }
1558
- };
1527
+ });
1559
1528
  __privateSet$1(this, _isAsync, isAsync);
1560
1529
  __privateSet$1(this, _renderRoot, isLight ? this : this.attachShadow({ mode: "open", delegatesFocus, slotAssignment }));
1561
1530
  const { adoptedStyleSheets } = new.target;
@@ -1564,37 +1533,16 @@ class GemElement extends HTMLElement {
1564
1533
  if (this.shadowRoot) {
1565
1534
  this.shadowRoot.adoptedStyleSheets = sheets;
1566
1535
  } else {
1567
- this.effect(() => {
1568
- const root = this.getRootNode();
1569
- if (!useNativeCSSStyleSheet) {
1570
- const ele = root === document ? document.body : root;
1571
- ele._sheets = ele._sheets || {};
1572
- sheets.forEach(({ style, media }) => {
1573
- if (ele._sheets[style]) {
1574
- ele._sheets[style].count++;
1575
- } else {
1576
- const s = document.createElement("style");
1577
- s.innerHTML = style;
1578
- s.media = media.mediaText;
1579
- ele.append(s);
1580
- ele._sheets[style] = { ele: s, count: 1 };
1581
- }
1582
- });
1583
- return () => {
1584
- sheets.forEach(({ style }) => {
1585
- ele._sheets[style].count--;
1586
- if (!ele._sheets[style].count) {
1587
- delete ele._sheets[style];
1588
- }
1589
- });
1590
- };
1591
- } else {
1536
+ this.effect(
1537
+ () => {
1538
+ const root = this.getRootNode();
1592
1539
  root.adoptedStyleSheets = [...root.adoptedStyleSheets, ...sheets];
1593
1540
  return () => {
1594
1541
  root.adoptedStyleSheets = removeItems(root.adoptedStyleSheets, sheets);
1595
1542
  };
1596
- }
1597
- }, () => []);
1543
+ },
1544
+ () => []
1545
+ );
1598
1546
  }
1599
1547
  }
1600
1548
  }
@@ -1620,6 +1568,7 @@ class GemElement extends HTMLElement {
1620
1568
  if (__privateGet$1(this, _isMounted)) {
1621
1569
  addMicrotask(__privateGet$1(this, _update));
1622
1570
  }
1571
+ return __privateGet$1(_GemElement, _final);
1623
1572
  }
1624
1573
  closestElement(constructorOrTag) {
1625
1574
  const isConstructor = typeof constructorOrTag === "function";
@@ -1645,6 +1594,10 @@ class GemElement extends HTMLElement {
1645
1594
  } else {
1646
1595
  __privateGet$1(this, _connectedCallback).call(this);
1647
1596
  }
1597
+ return __privateGet$1(_GemElement, _final);
1598
+ }
1599
+ adoptedCallback() {
1600
+ return __privateGet$1(_GemElement, _final);
1648
1601
  }
1649
1602
  disconnectedCallback() {
1650
1603
  var _a2, _b2, _c, _d;
@@ -1659,31 +1612,34 @@ class GemElement extends HTMLElement {
1659
1612
  });
1660
1613
  execCallback(__privateGet$1(this, _unmountCallback));
1661
1614
  (_a2 = this.unmounted) == null ? void 0 : _a2.call(this);
1662
- (_b2 = __privateGet$1(this, _effectList)) == null ? void 0 : _b2.forEach((effectItem) => {
1663
- execCallback(effectItem.preCallback);
1664
- });
1665
- __privateSet$1(this, _effectList, (_c = __privateGet$1(this, _effectList)) == null ? void 0 : _c.filter(({ inConstructor }) => inConstructor));
1666
- __privateSet$1(this, _memoList, (_d = __privateGet$1(this, _memoList)) == null ? void 0 : _d.filter(({ inConstructor }) => inConstructor));
1667
- }
1668
- }
1669
- _renderRoot = new WeakMap();
1670
- _internals = new WeakMap();
1671
- _isAppendReason = new WeakMap();
1672
- _isMounted = new WeakMap();
1673
- _isAsync = new WeakMap();
1674
- _effectList = new WeakMap();
1675
- _memoList = new WeakMap();
1676
- _unmountCallback = new WeakMap();
1677
- _exec = new WeakMap();
1678
- _execEffect = new WeakMap();
1679
- _execMemo = new WeakMap();
1680
- _initEffect = new WeakMap();
1681
- _render = new WeakMap();
1682
- _shouldUpdate = new WeakMap();
1683
- _updateCallback = new WeakMap();
1684
- _update = new WeakMap();
1685
- _updated = new WeakMap();
1686
- _connectedCallback = new WeakMap();
1615
+ (_b2 = __privateGet$1(this, _effectList)) == null ? void 0 : _b2.forEach(({ preCallback }) => execCallback(preCallback));
1616
+ __privateSet$1(this, _effectList, (_c = __privateGet$1(this, _effectList)) == null ? void 0 : _c.filter(__privateGet$1(this, _filterEffect)));
1617
+ __privateSet$1(this, _memoList, (_d = __privateGet$1(this, _memoList)) == null ? void 0 : _d.filter(__privateGet$1(this, _filterEffect)));
1618
+ return __privateGet$1(_GemElement, _final);
1619
+ }
1620
+ };
1621
+ let GemElement = _GemElement;
1622
+ _final = /* @__PURE__ */ new WeakMap();
1623
+ _renderRoot = /* @__PURE__ */ new WeakMap();
1624
+ _internals = /* @__PURE__ */ new WeakMap();
1625
+ _isAppendReason = /* @__PURE__ */ new WeakMap();
1626
+ _isMounted = /* @__PURE__ */ new WeakMap();
1627
+ _isAsync = /* @__PURE__ */ new WeakMap();
1628
+ _effectList = /* @__PURE__ */ new WeakMap();
1629
+ _memoList = /* @__PURE__ */ new WeakMap();
1630
+ _unmountCallback = /* @__PURE__ */ new WeakMap();
1631
+ _exec = /* @__PURE__ */ new WeakMap();
1632
+ _execEffect = /* @__PURE__ */ new WeakMap();
1633
+ _execMemo = /* @__PURE__ */ new WeakMap();
1634
+ _initEffect = /* @__PURE__ */ new WeakMap();
1635
+ _render = /* @__PURE__ */ new WeakMap();
1636
+ _shouldUpdate = /* @__PURE__ */ new WeakMap();
1637
+ _updateCallback = /* @__PURE__ */ new WeakMap();
1638
+ _update = /* @__PURE__ */ new WeakMap();
1639
+ _updated = /* @__PURE__ */ new WeakMap();
1640
+ _connectedCallback = /* @__PURE__ */ new WeakMap();
1641
+ _filterEffect = /* @__PURE__ */ new WeakMap();
1642
+ __privateAdd$1(GemElement, _final, Symbol());
1687
1643
  const gemElementProxyMap = new PropProxyMap();
1688
1644
  function defineAttribute(target, prop, attr) {
1689
1645
  const { booleanAttributes, numberAttributes } = target.constructor;
@@ -1741,11 +1697,11 @@ function defineProperty(target, prop, event, eventOptions) {
1741
1697
  if (v !== proxy[prop]) {
1742
1698
  if (event) {
1743
1699
  proxy[prop] = (v == null ? void 0 : v[isEventHandleSymbol]) ? v : (detail, options) => {
1744
- const evt = new CustomEvent(event, __spreadProps(__spreadValues(__spreadValues({}, options), eventOptions), { detail }));
1700
+ const evt = new CustomEvent(event, { ...options, ...eventOptions, detail });
1745
1701
  that.dispatchEvent(evt);
1746
1702
  v(detail, options);
1747
1703
  };
1748
- proxy[prop][isEventHandleSymbol] = true;
1704
+ Reflect.set(proxy[prop], isEventHandleSymbol, true);
1749
1705
  } else {
1750
1706
  proxy[prop] = v;
1751
1707
  this[updateSymbol]();
@@ -1768,7 +1724,9 @@ function defineRef(target, prop, ref) {
1768
1724
  return ref;
1769
1725
  },
1770
1726
  get element() {
1771
- const gemReflects = [...ele.querySelectorAll("[data-gem-reflect]")].map((e) => e.target);
1727
+ const gemReflects = [...ele.querySelectorAll("[data-gem-reflect]")].map(
1728
+ (e) => e.target
1729
+ );
1772
1730
  for (const e of [ele, ...gemReflects]) {
1773
1731
  const result = e.querySelector(`[ref=${ref}]`);
1774
1732
  if (result)
@@ -1814,7 +1772,7 @@ customElements.define = (name, cls, options) => {
1814
1772
  nativeDefineElement(name, cls, options);
1815
1773
  };
1816
1774
  if (window.__GEM_DEVTOOLS__HOOK__) {
1817
- Object.assign(window.__GEM_DEVTOOLS__HOOK__, __spreadValues(__spreadValues({}, GemExports), VersionExports));
1775
+ Object.assign(window.__GEM_DEVTOOLS__HOOK__, { ...GemExports, ...VersionExports });
1818
1776
  }
1819
1777
  function pushStaticField(target, field, member, isSet = false) {
1820
1778
  const cls = target.constructor;
@@ -1912,7 +1870,7 @@ const store = createStore({
1912
1870
  $hasShouldCloseHandle: false,
1913
1871
  $key: ""
1914
1872
  });
1915
- const paramsMap = new Map();
1873
+ const paramsMap = /* @__PURE__ */ new Map();
1916
1874
  function validData(data) {
1917
1875
  const { $key, $hasCloseHandle, $hasOpenHandle, $hasShouldCloseHandle } = data || {};
1918
1876
  if (store.$key === $key)
@@ -1942,18 +1900,19 @@ function normalizeParams(params) {
1942
1900
  const title = params.title || (pathChanged ? "" : document.title);
1943
1901
  const statusChanged = params.close || params.data || params.open || params.shouldClose;
1944
1902
  const hash = params.hash || (!pathChanged && statusChanged ? decodeURIComponent(location.hash) : "");
1945
- return __spreadProps(__spreadValues({}, params), { title, path, query, hash });
1903
+ return { ...params, title, path, query, hash };
1946
1904
  }
1947
1905
  function updateHistory(p, native) {
1948
1906
  validData(p.data);
1949
1907
  const params = normalizeParams(p);
1950
1908
  const { title, path, query, hash, close, open: open2, shouldClose, data } = params;
1951
- const state2 = __spreadValues({
1909
+ const state2 = {
1952
1910
  $hasCloseHandle: !!close,
1953
1911
  $hasOpenHandle: !!open2,
1954
1912
  $hasShouldCloseHandle: !!shouldClose,
1955
- $key: getKey()
1956
- }, data);
1913
+ $key: getKey(),
1914
+ ...data
1915
+ };
1957
1916
  paramsMap.set(state2.$key, params);
1958
1917
  updateStore(cleanObject(store), state2);
1959
1918
  const url = getUrlBarPath(path) + new QueryString(query) + hash;
@@ -1964,9 +1923,10 @@ function updateHistory(p, native) {
1964
1923
  }
1965
1924
  function updateHistoryByNative(data, title, originUrl, native) {
1966
1925
  validData(data);
1967
- const state2 = __spreadValues({
1968
- $key: getKey()
1969
- }, data || {});
1926
+ const state2 = {
1927
+ $key: getKey(),
1928
+ ...data || {}
1929
+ };
1970
1930
  const { pathname, search, hash } = new URL(originUrl, location.origin + location.pathname);
1971
1931
  const params = normalizeParams({ path: pathname, query: new QueryString(search), hash, title, data });
1972
1932
  paramsMap.set(state2.$key, params);
@@ -2046,9 +2006,10 @@ if (!window._GEMHISTORY) {
2046
2006
  gemHistory.back();
2047
2007
  } else {
2048
2008
  const params = normalizeParams({ title: document.title, hash: location.hash });
2049
- updateStore(store, __spreadValues({
2050
- $key: getKey()
2051
- }, nativeHistory.state || {}));
2009
+ updateStore(store, {
2010
+ $key: getKey(),
2011
+ ...nativeHistory.state || {}
2012
+ });
2052
2013
  paramsMap.set(store.$key, params);
2053
2014
  }
2054
2015
  connect(gemTitleStore, () => {
@@ -2144,14 +2105,24 @@ class ParamsRegExp extends RegExp {
2144
2105
  constructor(pattern) {
2145
2106
  const namePosition = {};
2146
2107
  let i = 0;
2147
- super(`^${pattern.replace(/:([^/$]+)/g, (_m, name) => {
2148
- namePosition[name] = i++;
2149
- return `([^/]+)`;
2150
- }).replace("*", ".*")}$`, "i");
2108
+ super(
2109
+ `^${pattern.replace(/:([^/$]+)/g, (_m, name) => {
2110
+ namePosition[name] = i++;
2111
+ return `([^/]+)`;
2112
+ }).replace("*", ".*")}$`,
2113
+ "i"
2114
+ );
2151
2115
  this.namePosition = namePosition;
2152
2116
  }
2153
2117
  }
2154
2118
  function matchPath(pattern, path) {
2119
+ if (window.URLPattern) {
2120
+ const urLPattern = new window.URLPattern({ pathname: pattern });
2121
+ const matchResult2 = urLPattern.exec({ pathname: path }) || urLPattern.exec({ pathname: `${path}/` });
2122
+ if (!matchResult2)
2123
+ return null;
2124
+ return matchResult2.pathname.groups;
2125
+ }
2155
2126
  const reg = new ParamsRegExp(pattern);
2156
2127
  const matchResult = path.match(reg) || `${path}/`.match(reg);
2157
2128
  if (!matchResult)
@@ -2176,9 +2147,10 @@ function createPath(route, options) {
2176
2147
  }
2177
2148
  function createHistoryParams(route, options) {
2178
2149
  const path = createPath(route, options);
2179
- return __spreadValues({
2180
- path
2181
- }, options);
2150
+ return {
2151
+ path,
2152
+ ...options
2153
+ };
2182
2154
  }
2183
2155
  let GemRouteElement = class extends GemElement {
2184
2156
  constructor({ isLight, routes } = {}) {
@@ -2218,39 +2190,42 @@ let GemRouteElement = class extends GemElement {
2218
2190
  this.routes = routes;
2219
2191
  }
2220
2192
  mounted() {
2221
- this.effect(([key2, path], old) => {
2222
- if (old && key2 === old[0] && path === old[1]) {
2223
- __privateGet2(this, _updateLocationStore).call(this);
2224
- return;
2225
- }
2226
- const { route, params = {} } = GemRouteElement.findRoute(this.routes, path);
2227
- const { redirect, content, getContent } = route || {};
2228
- if (redirect) {
2229
- history.replace({ path: redirect });
2230
- return;
2231
- }
2232
- const title = route == null ? void 0 : route.title;
2233
- if (title)
2234
- updateStore(titleStore, { title });
2235
- const contentOrLoader = content || (getContent == null ? void 0 : getContent(params));
2236
- if (contentOrLoader instanceof Promise) {
2237
- this.loading(route);
2238
- __privateSet2(this, _lastLoader, contentOrLoader);
2239
- const isSomeLoader = () => __privateGet2(this, _lastLoader) === contentOrLoader;
2240
- contentOrLoader.then((content2) => {
2241
- if (isSomeLoader())
2242
- __privateGet2(this, _setContent).call(this, route, params, content2);
2243
- }).catch((err) => {
2244
- if (isSomeLoader())
2245
- this.error(err);
2246
- });
2247
- return;
2193
+ this.effect(
2194
+ ([key2, path], old) => {
2195
+ if (old && key2 === old[0] && path === old[1]) {
2196
+ __privateGet2(this, _updateLocationStore).call(this);
2197
+ return;
2198
+ }
2199
+ const { route, params = {} } = GemRouteElement.findRoute(this.routes, path);
2200
+ const { redirect, content, getContent } = route || {};
2201
+ if (redirect) {
2202
+ history.replace({ path: redirect });
2203
+ return;
2204
+ }
2205
+ const title = route == null ? void 0 : route.title;
2206
+ if (title)
2207
+ updateStore(titleStore, { title });
2208
+ const contentOrLoader = content || (getContent == null ? void 0 : getContent(params));
2209
+ if (contentOrLoader instanceof Promise) {
2210
+ this.loading(route);
2211
+ __privateSet2(this, _lastLoader, contentOrLoader);
2212
+ const isSomeLoader = () => __privateGet2(this, _lastLoader) === contentOrLoader;
2213
+ contentOrLoader.then((content2) => {
2214
+ if (isSomeLoader())
2215
+ __privateGet2(this, _setContent).call(this, route, params, content2);
2216
+ }).catch((err) => {
2217
+ if (isSomeLoader())
2218
+ this.error(err);
2219
+ });
2220
+ return;
2221
+ }
2222
+ __privateGet2(this, _setContent).call(this, route, params, contentOrLoader);
2223
+ },
2224
+ () => {
2225
+ const { path } = history.getParams();
2226
+ return [this.key, path, location.search];
2248
2227
  }
2249
- __privateGet2(this, _setContent).call(this, route, params, contentOrLoader);
2250
- }, () => {
2251
- const { path } = history.getParams();
2252
- return [this.key, path, location.search];
2253
- });
2228
+ );
2254
2229
  }
2255
2230
  shouldUpdate() {
2256
2231
  if (this.inert)
@@ -2272,9 +2247,9 @@ let GemRouteElement = class extends GemElement {
2272
2247
  `;
2273
2248
  }
2274
2249
  };
2275
- _lastLoader = new WeakMap();
2276
- _updateLocationStore = new WeakMap();
2277
- _setContent = new WeakMap();
2250
+ _lastLoader = /* @__PURE__ */ new WeakMap();
2251
+ _updateLocationStore = /* @__PURE__ */ new WeakMap();
2252
+ _setContent = /* @__PURE__ */ new WeakMap();
2278
2253
  GemRouteElement.createLocationStore = () => {
2279
2254
  const { path, query, data } = history.getParams();
2280
2255
  return createStore({ path, query, data, params: {} });
@@ -2288,7 +2263,7 @@ GemRouteElement.findRoute = (target = [], path) => {
2288
2263
  routes = Object.values(target);
2289
2264
  }
2290
2265
  for (const route of routes) {
2291
- if (route.pattern === "*") {
2266
+ if ("*" === route.pattern) {
2292
2267
  defaultRoute = route;
2293
2268
  } else {
2294
2269
  const params = matchPath(route.pattern, path);
@@ -2325,7 +2300,7 @@ GemRouteElement = __decorateClass$6([
2325
2300
  ], GemRouteElement);
2326
2301
  class GemLightRouteElement extends GemRouteElement {
2327
2302
  constructor(options = {}) {
2328
- super(__spreadProps(__spreadValues({}, options), { isLight: true }));
2303
+ super({ ...options, isLight: true });
2329
2304
  }
2330
2305
  }
2331
2306
  var __defProp$5 = Object.defineProperty;
@@ -2339,43 +2314,50 @@ var __decorateClass$5 = (decorators, target, key2, kind) => {
2339
2314
  __defProp$5(target, key2, result);
2340
2315
  return result;
2341
2316
  };
2317
+ function isExternal(path) {
2318
+ return !path.startsWith("/");
2319
+ }
2342
2320
  let GemLinkElement = (_a = class extends GemElement {
2343
2321
  constructor() {
2344
2322
  super();
2345
2323
  __privateAdd(this, _routeOptions);
2346
- this.clickHandle = async (e) => {
2324
+ __privateAdd(this, _hint);
2325
+ __privateAdd(this, _onClick, void 0);
2326
+ __privateAdd(this, _preventDefault, void 0);
2327
+ __privateAdd(this, _getHint, void 0);
2328
+ __privateSet(this, _onClick, async () => {
2347
2329
  var _a2;
2348
- const pathInfo = this.getPathInfo();
2349
- if (!pathInfo)
2330
+ const locationString = this.getLocationString();
2331
+ if (!locationString)
2350
2332
  return;
2351
- if (this.isExternal(pathInfo)) {
2333
+ if (isExternal(locationString)) {
2352
2334
  switch (this.target) {
2353
2335
  case "_self":
2354
- window.location.href = pathInfo;
2336
+ window.location.href = locationString;
2355
2337
  return;
2356
2338
  case "_parent":
2357
- window.parent.location.href = pathInfo;
2339
+ window.parent.location.href = locationString;
2358
2340
  return;
2359
2341
  case "_top":
2360
- window.top.location.href = pathInfo;
2342
+ window.top.location.href = locationString;
2361
2343
  return;
2362
2344
  default:
2363
- window.open(pathInfo);
2345
+ window.open(locationString);
2364
2346
  return;
2365
2347
  }
2366
2348
  }
2367
2349
  const { path, query, hash } = history.getParams();
2368
- if (path + query + hash === pathInfo) {
2350
+ if (path + query + hash === locationString) {
2369
2351
  return;
2370
2352
  }
2371
- e.stopPropagation();
2372
2353
  await ((_a2 = this.prepare) == null ? void 0 : _a2.call(this));
2373
2354
  if (this.route) {
2374
- history.pushIgnoreCloseHandle(__spreadProps(__spreadValues({}, createHistoryParams(this.route, __privateGet(this, _routeOptions, routeOptions_get))), {
2355
+ history.pushIgnoreCloseHandle({
2356
+ ...createHistoryParams(this.route, __privateGet(this, _routeOptions, routeOptions_get)),
2375
2357
  title: this.route.title || this.docTitle
2376
- }));
2358
+ });
2377
2359
  } else if (this.href) {
2378
- const { pathname, search, hash: hash2 } = new URL(pathInfo, location.origin);
2360
+ const { pathname, search, hash: hash2 } = new URL(locationString, location.origin);
2379
2361
  history.pushIgnoreCloseHandle({
2380
2362
  path: pathname,
2381
2363
  query: search,
@@ -2385,37 +2367,18 @@ let GemLinkElement = (_a = class extends GemElement {
2385
2367
  } else {
2386
2368
  history.pushIgnoreCloseHandle({ path: this.path, query: this.query, hash: this.hash, title: this.docTitle });
2387
2369
  }
2388
- };
2389
- this.preventDefault = (e) => {
2370
+ });
2371
+ __privateSet(this, _preventDefault, (e) => {
2390
2372
  e.preventDefault();
2391
- };
2373
+ });
2374
+ __privateSet(this, _getHint, () => {
2375
+ const locationString = this.getLocationString();
2376
+ return isExternal(locationString) ? locationString : new URL(history.basePath + locationString, location.origin).toString();
2377
+ });
2392
2378
  this.tabIndex = 0;
2393
- this.addEventListener("click", this.clickHandle);
2379
+ this.addEventListener("click", __privateGet(this, _onClick));
2394
2380
  }
2395
- getPathInfo() {
2396
- var _a2, _b2;
2397
- if (this.route) {
2398
- const queryProp = ((_a2 = __privateGet(this, _routeOptions, routeOptions_get)) == null ? void 0 : _a2.query) || "";
2399
- const hashProp = ((_b2 = __privateGet(this, _routeOptions, routeOptions_get)) == null ? void 0 : _b2.hash) || "";
2400
- return createPath(this.route, __privateGet(this, _routeOptions, routeOptions_get)) + queryProp + hashProp;
2401
- } else {
2402
- const url = this.href || this.path + this.query + this.hash;
2403
- const { path, query } = history.getParams();
2404
- if (url.startsWith("#")) {
2405
- return `${path}${query}${url}`;
2406
- } else if (url.startsWith("?")) {
2407
- return `${path}${url}`;
2408
- } else if (url.startsWith(".")) {
2409
- return absoluteLocation(path, url);
2410
- } else {
2411
- return url;
2412
- }
2413
- }
2414
- }
2415
- isExternal(pathInfo) {
2416
- return !pathInfo.startsWith("/");
2417
- }
2418
- render(pathInfo = this.getPathInfo()) {
2381
+ render() {
2419
2382
  return html`
2420
2383
  <style>
2421
2384
  :host {
@@ -2434,16 +2397,38 @@ let GemLinkElement = (_a = class extends GemElement {
2434
2397
  </style>
2435
2398
  <a
2436
2399
  part=${this.link}
2437
- @click=${this.preventDefault}
2438
- href=${ifDefined(this.hint === "off" ? void 0 : this.isExternal(pathInfo) ? pathInfo : new URL(history.basePath + pathInfo, location.origin).toString())}
2400
+ @click=${__privateGet(this, _preventDefault)}
2401
+ href=${ifDefined(__privateGet(this, _hint, hint_get) === "off" ? void 0 : __privateGet(this, _getHint).call(this))}
2439
2402
  >
2440
2403
  <slot></slot>
2441
2404
  </a>
2442
2405
  `;
2443
2406
  }
2407
+ getLocationString() {
2408
+ var _a2, _b2;
2409
+ if (this.route) {
2410
+ const queryProp = ((_a2 = __privateGet(this, _routeOptions, routeOptions_get)) == null ? void 0 : _a2.query) || "";
2411
+ const hashProp = ((_b2 = __privateGet(this, _routeOptions, routeOptions_get)) == null ? void 0 : _b2.hash) || "";
2412
+ return createPath(this.route, __privateGet(this, _routeOptions, routeOptions_get)) + queryProp + hashProp;
2413
+ } else {
2414
+ const url = this.href || this.path + this.query + this.hash;
2415
+ const { path, query } = history.getParams();
2416
+ if (url.startsWith("#")) {
2417
+ return `${path}${query}${url}`;
2418
+ } else if (url.startsWith("?")) {
2419
+ return `${path}${url}`;
2420
+ } else if (url.startsWith(".")) {
2421
+ return absoluteLocation(path, url);
2422
+ } else {
2423
+ return url;
2424
+ }
2425
+ }
2426
+ }
2444
2427
  }, _routeOptions = new WeakSet(), routeOptions_get = function() {
2445
2428
  return this.routeOptions || this.options;
2446
- }, _a);
2429
+ }, _hint = new WeakSet(), hint_get = function() {
2430
+ return this.hint || "on";
2431
+ }, _onClick = new WeakMap(), _preventDefault = new WeakMap(), _getHint = new WeakMap(), _a);
2447
2432
  __decorateClass$5([
2448
2433
  attribute
2449
2434
  ], GemLinkElement.prototype, "href", 2);
@@ -2484,16 +2469,13 @@ GemLinkElement = __decorateClass$5([
2484
2469
  connectStore(basePathStore)
2485
2470
  ], GemLinkElement);
2486
2471
  let GemActiveLinkElement = class extends GemLinkElement {
2487
- render() {
2488
- const { path, query, hash } = history.getParams();
2489
- const isMatchPattern = this.pattern && matchPath(this.pattern, path);
2490
- const pathInfo = this.getPathInfo();
2491
- if (isMatchPattern || path + query + hash === pathInfo) {
2492
- this.active = true;
2493
- } else {
2494
- this.active = false;
2495
- }
2496
- return super.render(pathInfo);
2472
+ constructor() {
2473
+ super();
2474
+ this.effect(() => {
2475
+ const { path, query, hash } = history.getParams();
2476
+ const isMatchPattern = this.pattern && matchPath(this.pattern, path);
2477
+ this.active = !!isMatchPattern || path + query + hash === this.getLocationString();
2478
+ });
2497
2479
  }
2498
2480
  };
2499
2481
  __decorateClass$5([
@@ -2521,28 +2503,23 @@ var __decorateClass$4 = (decorators, target, key2, kind) => {
2521
2503
  return result;
2522
2504
  };
2523
2505
  let GemTitleElement = class extends GemElement {
2506
+ constructor() {
2507
+ super();
2508
+ new MutationObserver(() => this.update()).observe(this, { childList: true, characterData: true, subtree: true });
2509
+ }
2524
2510
  static setTitle(title) {
2525
2511
  updateStore(titleStore, { title });
2526
2512
  }
2527
- static updateTitle(str = "", suffix = "") {
2528
- const { title } = titleStore;
2529
- if (title && title !== GemTitleElement.defaultTitle) {
2530
- GemTitleElement.title = title;
2531
- document.title = GemTitleElement.title + suffix;
2532
- } else if (str) {
2533
- GemTitleElement.title = str;
2534
- document.title = GemTitleElement.title + suffix;
2513
+ static updateTitle(title = titleStore.title, prefix = "", suffix = "") {
2514
+ if (title === GemTitleElement.defaultTitle) {
2515
+ document.title = GemTitleElement.title = title;
2535
2516
  } else {
2536
- GemTitleElement.title = GemTitleElement.defaultTitle;
2537
- document.title = GemTitleElement.title;
2517
+ GemTitleElement.title = title;
2518
+ document.title = prefix + GemTitleElement.title + suffix;
2538
2519
  }
2539
2520
  }
2540
- constructor() {
2541
- super();
2542
- new MutationObserver(() => this.update()).observe(this, { childList: true, characterData: true, subtree: true });
2543
- }
2544
2521
  render() {
2545
- GemTitleElement.updateTitle(this.textContent || "", this.suffix);
2522
+ GemTitleElement.updateTitle(this.textContent || void 0, this.prefix, this.suffix);
2546
2523
  if (this.hidden) {
2547
2524
  return html``;
2548
2525
  }
@@ -2551,7 +2528,11 @@ let GemTitleElement = class extends GemElement {
2551
2528
  };
2552
2529
  GemTitleElement.title = document.title;
2553
2530
  GemTitleElement.defaultTitle = document.title;
2531
+ GemTitleElement.defaultPrefix = `${document.title} | `;
2554
2532
  GemTitleElement.defaultSuffix = ` - ${document.title}`;
2533
+ __decorateClass$4([
2534
+ attribute
2535
+ ], GemTitleElement.prototype, "prefix", 2);
2555
2536
  __decorateClass$4([
2556
2537
  attribute
2557
2538
  ], GemTitleElement.prototype, "suffix", 2);
@@ -2571,23 +2552,27 @@ var __decorateClass$3 = (decorators, target, key2, kind) => {
2571
2552
  __defProp$3(target, key2, result);
2572
2553
  return result;
2573
2554
  };
2574
- const eleCache = new Map();
2555
+ const eleCache = /* @__PURE__ */ new Map();
2575
2556
  class GemUseElement extends GemElement {
2576
- getContent() {
2577
- const ele = this.element || (this.selector ? (this.root || document).querySelector(this.selector) : null);
2578
- if (typeof ele === "string") {
2579
- let temp = eleCache.get(ele);
2580
- if (!temp) {
2581
- temp = document.createElement("template");
2582
- temp.innerHTML = ele;
2583
- eleCache.set(ele, temp);
2557
+ constructor() {
2558
+ super(...arguments);
2559
+ __privateAdd(this, _getContent, void 0);
2560
+ __privateSet(this, _getContent, () => {
2561
+ const ele = this.element || (this.selector ? (this.root || document).querySelector(this.selector) : null);
2562
+ if (typeof ele === "string") {
2563
+ let temp = eleCache.get(ele);
2564
+ if (!temp) {
2565
+ temp = document.createElement("template");
2566
+ temp.innerHTML = ele;
2567
+ eleCache.set(ele, temp);
2568
+ }
2569
+ return temp.content.cloneNode(true);
2570
+ } else if (ele instanceof HTMLTemplateElement) {
2571
+ return ele.content.cloneNode(true);
2572
+ } else {
2573
+ return ele == null ? void 0 : ele.cloneNode(true);
2584
2574
  }
2585
- return temp.content.cloneNode(true);
2586
- } else if (ele instanceof HTMLTemplateElement) {
2587
- return ele.content.cloneNode(true);
2588
- } else {
2589
- return ele == null ? void 0 : ele.cloneNode(true);
2590
- }
2575
+ });
2591
2576
  }
2592
2577
  render() {
2593
2578
  return html`
@@ -2602,11 +2587,12 @@ class GemUseElement extends GemElement {
2602
2587
  height: 100%;
2603
2588
  }
2604
2589
  </style>
2605
- ${this.getContent()}
2590
+ ${__privateGet(this, _getContent).call(this)}
2606
2591
  <slot></slot>
2607
2592
  `;
2608
2593
  }
2609
2594
  }
2595
+ _getContent = new WeakMap();
2610
2596
  __decorateClass$3([
2611
2597
  attribute
2612
2598
  ], GemUseElement.prototype, "selector", 2);
@@ -2634,9 +2620,10 @@ var __decorateClass$2 = (decorators, target, key2, kind) => {
2634
2620
  class GemUnsafeElement extends GemElement {
2635
2621
  constructor() {
2636
2622
  super();
2637
- this.effect(() => {
2638
- if (this.shadowRoot) {
2639
- this.shadowRoot.innerHTML = `
2623
+ this.effect(
2624
+ () => {
2625
+ if (this.shadowRoot) {
2626
+ this.shadowRoot.innerHTML = `
2640
2627
  <style>
2641
2628
  :host(:where(:not([hidden]))) {
2642
2629
  display: contents;
@@ -2645,8 +2632,10 @@ class GemUnsafeElement extends GemElement {
2645
2632
  </style>
2646
2633
  ${this.content}
2647
2634
  `;
2648
- }
2649
- }, () => [this.content, this.contentcss]);
2635
+ }
2636
+ },
2637
+ () => [this.content, this.contentcss]
2638
+ );
2650
2639
  }
2651
2640
  render() {
2652
2641
  return void 0;
@@ -2676,18 +2665,21 @@ class GemReflectElement extends GemElement {
2676
2665
  this.target = document.head;
2677
2666
  this.hidden = true;
2678
2667
  this.dataset.gemReflect = "";
2679
- this.effect(() => {
2680
- const childNodes = [...this.childNodes];
2681
- childNodes.forEach((node) => {
2682
- if (node instanceof HTMLElement) {
2683
- node.dataset.reflect = "";
2684
- }
2685
- this.target.append(node);
2686
- });
2687
- return () => {
2688
- childNodes.forEach((node) => node.remove());
2689
- };
2690
- }, () => [this.target]);
2668
+ this.effect(
2669
+ () => {
2670
+ const childNodes = [...this.childNodes];
2671
+ childNodes.forEach((node) => {
2672
+ if (node instanceof HTMLElement) {
2673
+ node.dataset.reflect = "";
2674
+ }
2675
+ this.target.append(node);
2676
+ });
2677
+ return () => {
2678
+ childNodes.forEach((node) => node.remove());
2679
+ };
2680
+ },
2681
+ () => [this.target]
2682
+ );
2691
2683
  }
2692
2684
  }
2693
2685
  __decorateClass$1([
@@ -2697,6 +2689,7 @@ customElements.define("gem-reflect", GemReflectElement);
2697
2689
  const open = Symbol("open mark");
2698
2690
  function createModalClass(options) {
2699
2691
  var _a2;
2692
+ const final2 = Symbol();
2700
2693
  return _a2 = class extends GemElement {
2701
2694
  constructor() {
2702
2695
  super();
@@ -2716,7 +2709,7 @@ function createModalClass(options) {
2716
2709
  this.inertStore = [...document.body.children].filter((e) => !e.inert);
2717
2710
  this.inertStore.forEach((e) => e.inert = true);
2718
2711
  document.body.append(instance);
2719
- const changeStore = () => updateStore(this.store, __spreadValues({ [open]: true }, opts));
2712
+ const changeStore = () => updateStore(this.store, { [open]: true, ...opts });
2720
2713
  setTimeout(() => {
2721
2714
  changeStore();
2722
2715
  history.push({
@@ -2726,24 +2719,28 @@ function createModalClass(options) {
2726
2719
  shouldClose: this.shouldClose.bind(this)
2727
2720
  });
2728
2721
  }, 100);
2722
+ return final2;
2729
2723
  }
2730
2724
  static close() {
2731
2725
  history.back();
2726
+ return final2;
2732
2727
  }
2733
2728
  static closeHandle() {
2734
2729
  var _a3;
2735
2730
  this.inertStore.forEach((e) => e.inert = false);
2736
2731
  (_a3 = this.instance) == null ? void 0 : _a3.remove();
2737
- updateStore(this.store, __spreadValues({ [open]: false }, options));
2732
+ updateStore(this.store, { [open]: false, ...options });
2733
+ return final2;
2738
2734
  }
2739
2735
  static shouldClose() {
2740
2736
  return true;
2741
2737
  }
2742
- }, _a2.inertStore = [], _a2.instance = null, _a2.store = createStore(__spreadValues({
2743
- [open]: false
2744
- }, options)), _a2;
2738
+ }, _a2.inertStore = [], _a2.instance = null, _a2.store = createStore({
2739
+ [open]: false,
2740
+ ...options
2741
+ }), _a2;
2745
2742
  }
2746
- var __defProp2 = Object.defineProperty;
2743
+ var __defProp = Object.defineProperty;
2747
2744
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2748
2745
  var __decorateClass = (decorators, target, key2, kind) => {
2749
2746
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target;
@@ -2751,16 +2748,16 @@ var __decorateClass = (decorators, target, key2, kind) => {
2751
2748
  if (decorator = decorators[i])
2752
2749
  result = (kind ? decorator(target, key2, result) : decorator(result)) || result;
2753
2750
  if (kind && result)
2754
- __defProp2(target, key2, result);
2751
+ __defProp(target, key2, result);
2755
2752
  return result;
2756
2753
  };
2754
+ const final = Symbol();
2757
2755
  let GemDialogBaseElement = (_b = class extends GemElement {
2758
2756
  constructor() {
2759
2757
  super();
2760
2758
  __privateAdd(this, _nextSibling, void 0);
2761
2759
  __privateAdd(this, _parentElement, void 0);
2762
2760
  __privateAdd(this, _inertStore, void 0);
2763
- this.inert = true;
2764
2761
  __privateSet(this, _inertStore, []);
2765
2762
  this.closeHandle = () => {
2766
2763
  var _a2;
@@ -2773,6 +2770,7 @@ let GemDialogBaseElement = (_b = class extends GemElement {
2773
2770
  }
2774
2771
  this.dispatchEvent(new CustomEvent("close"));
2775
2772
  this.opened = false;
2773
+ return final;
2776
2774
  };
2777
2775
  this.openHandle = () => {
2778
2776
  this.hidden = false;
@@ -2784,6 +2782,7 @@ let GemDialogBaseElement = (_b = class extends GemElement {
2784
2782
  document.body.append(this);
2785
2783
  this.dispatchEvent(new CustomEvent("open"));
2786
2784
  this.opened = true;
2785
+ return final;
2787
2786
  };
2788
2787
  this.open = () => {
2789
2788
  if (this.opened)
@@ -2795,14 +2794,18 @@ let GemDialogBaseElement = (_b = class extends GemElement {
2795
2794
  close: this.closeHandle,
2796
2795
  shouldClose: this.shouldClose
2797
2796
  });
2797
+ return final;
2798
2798
  };
2799
2799
  this.close = () => {
2800
2800
  history.back();
2801
+ return final;
2801
2802
  };
2802
2803
  this.forceClose = () => {
2803
2804
  this.opened = false;
2804
2805
  setTimeout(this.close, 100);
2806
+ return final;
2805
2807
  };
2808
+ this.inert = true;
2806
2809
  this.internals.role = "dialog";
2807
2810
  this.internals.ariaModal = "true";
2808
2811
  }
@@ -2819,45 +2822,41 @@ __decorateClass([
2819
2822
  GemDialogBaseElement = __decorateClass([
2820
2823
  connectStore(history.store)
2821
2824
  ], GemDialogBaseElement);
2822
- const themeStoreMap = new WeakMap();
2825
+ const themeStoreMap = /* @__PURE__ */ new WeakMap();
2823
2826
  function getThemeStore(theme) {
2824
2827
  return themeStoreMap.get(theme);
2825
2828
  }
2826
- const themePropMap = new WeakMap();
2827
- function getThemeProp(theme) {
2828
- return themePropMap.get(theme);
2829
- }
2830
- function replaceStyle(style, theme) {
2831
- const themeStore = themeStoreMap.get(theme);
2832
- const themeProp = themePropMap.get(theme);
2833
- const rules = Object.keys(themeStore).reduce((prev, key2) => {
2834
- if (!themeStore[key2] || !themeProp[key2])
2835
- return prev;
2836
- return prev + `${themeProp[key2]}:${themeStore[key2]};`;
2837
- }, "");
2838
- style.textContent = `:root, :host {${rules}}`;
2829
+ const themePropsMap = /* @__PURE__ */ new WeakMap();
2830
+ function getThemeProps(theme) {
2831
+ return themePropsMap.get(theme);
2839
2832
  }
2833
+ const setThemeFnMap = /* @__PURE__ */ new WeakMap();
2840
2834
  function createTheme(themeObj) {
2841
2835
  const salt = randomStr();
2842
2836
  const style = document.createElement("style");
2843
- const themeStore = createStore(themeObj);
2837
+ const store2 = createStore(themeObj);
2844
2838
  const theme = {};
2845
- const themeProp = {};
2846
- themePropMap.set(theme, themeProp);
2847
- themeStoreMap.set(theme, themeStore);
2848
- Object.keys(themeStore).forEach((key2) => {
2849
- themeProp[key2] = `--${camelToKebabCase(key2)}-${salt}`;
2850
- theme[key2] = `var(${themeProp[key2]})`;
2839
+ const props = {};
2840
+ themePropsMap.set(theme, props);
2841
+ themeStoreMap.set(theme, store2);
2842
+ const setTheme = () => Object.keys(store2).forEach((key2) => {
2843
+ if (props[key2])
2844
+ return;
2845
+ props[key2] = `--${camelToKebabCase(key2)}-${salt}`;
2846
+ theme[key2] = `var(${props[key2]})`;
2851
2847
  });
2852
- const replace = () => replaceStyle(style, theme);
2853
- connect(themeStore, replace);
2848
+ setThemeFnMap.set(theme, setTheme);
2849
+ setTheme();
2850
+ const getStyle = () => `:root, :host {${Object.keys(store2).reduce((prev, key2) => prev + `${props[key2]}:${store2[key2]};`, "")}}`;
2851
+ const replace = () => style.textContent = getStyle();
2852
+ connect(store2, replace);
2854
2853
  replace();
2855
2854
  (document.head || document.documentElement).append(style);
2856
2855
  return theme;
2857
2856
  }
2858
2857
  function updateTheme(theme, newThemeObj) {
2859
- const store2 = getThemeStore(theme);
2860
- updateStore(store2, newThemeObj);
2858
+ updateStore(getThemeStore(theme), newThemeObj);
2859
+ setThemeFnMap.get(theme)();
2861
2860
  }
2862
2861
  const splitReg = /\$\d(?:<[^>]*>)?/;
2863
2862
  const matchReg = /\$(\d)(<([^>]*)>)?/g;
@@ -2874,7 +2873,7 @@ function splice(rawValue, ...rest) {
2874
2873
  }
2875
2874
  return html(templateArr, ...values);
2876
2875
  }
2877
- const modules = new Set();
2876
+ const modules = /* @__PURE__ */ new Set();
2878
2877
  const _I18n = class {
2879
2878
  constructor(options) {
2880
2879
  __privateAdd(this, _cacheCurrentKey);
@@ -3051,7 +3050,10 @@ const defaultReqInit = {
3051
3050
  }
3052
3051
  };
3053
3052
  async function request(uri, options = {}) {
3054
- const res = await fetch(uri, __spreadValues(__spreadValues({}, defaultReqInit), options));
3053
+ const res = await fetch(uri, {
3054
+ ...defaultReqInit,
3055
+ ...options
3056
+ });
3055
3057
  if (res.status === 0)
3056
3058
  throw new Error("Request fail");
3057
3059
  if (res.status >= 500)
@@ -3092,63 +3094,59 @@ function put(url, body) {
3092
3094
  function post(url, body) {
3093
3095
  return request(url, { method: "POST", body: serializationBody(body) });
3094
3096
  }
3095
- const matche = (query) => window.matchMedia(query).matches;
3097
+ const match = (query) => window.matchMedia(query).matches;
3096
3098
  const mediaQuery = {
3097
3099
  PRINT: "print",
3098
3100
  get isPrint() {
3099
- return matche(this.PRINT);
3101
+ return match(this.PRINT);
3100
3102
  },
3101
3103
  HOVER: "(hover: hover)",
3102
3104
  get isHover() {
3103
- return matche(this.HOVER);
3104
- },
3105
- PHONE: "(min-width: 319px) and (max-width: 480px)",
3106
- get isPhone() {
3107
- return matche(this.PHONE);
3108
- },
3109
- LAPTOP: "(min-width: 1023px) and (max-width: 1280px) and (orientation: landscape)",
3110
- get isLaptop() {
3111
- return matche(this.LAPTOP);
3105
+ return match(this.HOVER);
3112
3106
  },
3113
- DESKTOP: "(min-width: 1279px) and (orientation: landscape)",
3114
- get isDesktop() {
3115
- return matche(this.DESKTOP);
3107
+ PWA: "(display-mode: standalone)",
3108
+ get isPWA() {
3109
+ return match(this.PWA);
3116
3110
  },
3117
- WIDTHSCREEN: "(min-width: 1919px) and (orientation: landscape)",
3118
- get isWidthScreen() {
3119
- return matche(this.WIDTHSCREEN);
3111
+ MOTION_REDUCE: "(prefers-reduced-motion: reduce)",
3112
+ get isMotionReduce() {
3113
+ return match(this.MOTION_REDUCE);
3120
3114
  },
3121
- PHONE_LANDSCAPE: "(min-width: 479px) and (max-width: 959px) and (orientation: landscape)",
3122
- get isPhoneLandscape() {
3123
- return matche(this.PHONE_LANDSCAPE);
3115
+ DATA_REDUCE: "(prefers-reduced-data: reduce)",
3116
+ get isDataReduce() {
3117
+ return match(this.DATA_REDUCE);
3124
3118
  },
3125
- TABLET: "(min-width: 768px) and (max-width: 1024px)",
3126
- get isTablet() {
3127
- return matche(this.TABLET);
3119
+ WATCH: "(width < 320px)",
3120
+ get isWatch() {
3121
+ return match(this.WATCH);
3128
3122
  },
3129
- SMALL_PHONE: "(min-width: 319px) and (max-width: 480px) and (max-height: 640px)",
3123
+ SMALL_PHONE: "(320px <= width <= 480px) and (height <= 640px)",
3130
3124
  get isSmallPhone() {
3131
- return matche(this.SMALL_PHONE);
3125
+ return match(this.SMALL_PHONE);
3132
3126
  },
3133
- WATCH: "(max-width: 319px)",
3134
- get isWatch() {
3135
- return matche(this.WATCH);
3127
+ PHONE: "(320px <= width <= 480px)",
3128
+ get isPhone() {
3129
+ return match(this.PHONE);
3130
+ },
3131
+ PHONE_LANDSCAPE: "(480px < width < 960px) and (orientation: landscape)",
3132
+ get isPhoneLandscape() {
3133
+ return match(this.PHONE_LANDSCAPE);
3136
3134
  },
3137
- SHORT: "(min-width: 479px) and (max-height: 320px)",
3135
+ SHORT: "(width >= 480px) and (height <= 320px)",
3138
3136
  get isShort() {
3139
- return matche(this.SHORT);
3137
+ return match(this.SHORT);
3140
3138
  },
3141
- PWA: "(display-mode: standalone)",
3142
- get isPWA() {
3143
- return matche(this.PWA);
3139
+ TABLET: "(480px < width <= 1280px)",
3140
+ get isTablet() {
3141
+ return match(this.TABLET);
3144
3142
  },
3145
- MOTION_REDUCE: "(prefers-reduced-motion: reduce)",
3146
- get isMotionReduce() {
3147
- return matche(this.MOTION_REDUCE);
3143
+ DESKTOP: "(width > 1280px) and (orientation: landscape)",
3144
+ get isDesktop() {
3145
+ return match(this.DESKTOP);
3148
3146
  },
3149
- DATA_REDUCE: "(prefers-reduced-data: reduce)",
3150
- get isDataReduce() {
3151
- return matche(this.DATA_REDUCE);
3147
+ WIDTHSCREEN: "(width >= 1920px) and (orientation: landscape)",
3148
+ get isWidthScreen() {
3149
+ return match(this.WIDTHSCREEN);
3152
3150
  }
3153
3151
  };
3154
- export { GemActiveLinkElement, GemDialogBaseElement, GemElement, GemError, GemLightRouteElement, GemLinkElement, GemReflectElement, GemRouteElement, GemTitleElement, GemUnsafeElement, GemUseElement, I18n, LinkedList, PropProxyMap, QueryString, SVGTemplateResult, SheetToken, StoreListenerMap, TemplateResult, absoluteLocation, addMicrotask, addMicrotaskToStack, adoptedStyle, attribute, basePathStore, boolattribute, camelToKebabCase, classMap, cleanObject, connect, connectStore, createCSSSheet, createHistoryParams, createModalClass, createPath, createStore, createStoreSet, createTheme, css, customElement, defaultReqInit, defineAttribute, defineCSSState, defineProperty, defineRef, del, directive, disconnect, emitter, exportPartsMap, get, getThemeProp, getThemeStore, globalemitter, guard, history, html, ifDefined, isArrayChange, kebabToCamelCase, matchPath, mediaQuery, nativeDefineElement, numattribute, objectMapToString, part, partMap, post, property, put, randomStr, raw, refobject, removeItems, render, repeat, request, rootElement, slot, splice, state, styleMap, styled, svg, titleStore, updateStore, updateTheme, useNativeCSSStyleSheet, version };
3152
+ export { GemActiveLinkElement, GemDialogBaseElement, GemElement, GemError, GemLightRouteElement, GemLinkElement, GemReflectElement, GemRouteElement, GemTitleElement, GemUnsafeElement, GemUseElement, I18n, LinkedList, PropProxyMap, QueryString, SVGTemplateResult, SheetToken, StoreListenerMap, TemplateResult, absoluteLocation, addMicrotask, addMicrotaskToStack, adoptedStyle, attribute, basePathStore, boolattribute, camelToKebabCase, classMap, cleanObject, connect, connectStore, createCSSSheet, createHistoryParams, createModalClass, createPath, createStore, createStoreSet, createTheme, css, customElement, defaultReqInit, defineAttribute, defineCSSState, defineProperty, defineRef, del, directive, disconnect, emitter, exportPartsMap, get, getThemeProps, getThemeStore, globalemitter, guard, history, html, ifDefined, isArrayChange, kebabToCamelCase, matchPath, mediaQuery, nativeDefineElement, numattribute, objectMapToString, part, partMap, post, property, put, randomStr, raw, refobject, removeItems, render, repeat, request, rootElement, slot, splice, state, styleMap, styled, svg, titleStore, updateStore, updateTheme, version };