estreui 1.1.0 → 1.2.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.
@@ -227,6 +227,7 @@ const eds = {
227
227
  static: "data-static",
228
228
  exported: "data-exported",
229
229
  multiInstance: "data-multi-instance",
230
+ instanceOrigin: "data-instance-origin",
230
231
 
231
232
  // for bind data
232
233
  index: "data-index",
@@ -885,7 +886,7 @@ prompt = (title,
885
886
 
886
887
  // Infinite loop and prograss meter
887
888
  const waitings = new Set();
888
- let latestIO = null;
889
+ // let latestIO = null;
889
890
  let backHolds = 0;
890
891
 
891
892
  /**
@@ -894,8 +895,8 @@ let backHolds = 0;
894
895
  * @param {instanceOrigin: string} / instance access origin code
895
896
  */
896
897
  const wait = function (options, instanceOrigin = "wait_" + Date.now()) {
897
- if (instanceOrigin != n) waitings.add(instanceOrigin);
898
- latestIO = instanceOrigin;
898
+ // if (instanceOrigin != n) waitings.add(instanceOrigin);
899
+ // latestIO = instanceOrigin;
899
900
  pageManager.bringPage("!onRunning", { data: options }, instanceOrigin);
900
901
  return instanceOrigin;
901
902
  }
@@ -908,15 +909,18 @@ const wait = function (options, instanceOrigin = "wait_" + Date.now()) {
908
909
  */
909
910
  const stedy = function (options, delay = 600, instanceOrigin = "stedy_" + Date.now()) {
910
911
  if (instanceOrigin != n) waitings.add(instanceOrigin);
911
- latestIO = instanceOrigin;
912
+ // latestIO = instanceOrigin;
912
913
  setTimeout(_ => {
913
- if (latestIO == instanceOrigin) wait(options, instanceOrigin);
914
+ if (waitings.has(instanceOrigin)) {
915
+ waitings.delete(instanceOrigin);
916
+ wait(options, instanceOrigin);
917
+ }
914
918
  }, delay);
915
919
  return instanceOrigin;
916
920
  }
917
921
 
918
922
  const onBackWhile = function (handle) {
919
- if (handle != n || latestIO != n) {
923
+ if (handle != n) {// || latestIO != n) {
920
924
  backHolds++;
921
925
  return t;
922
926
  }
@@ -929,20 +933,24 @@ const onBackWhile = function (handle) {
929
933
  * @param {instanceOrigin} / instance access origin code
930
934
  */
931
935
  const go = function (instanceOrigin) {
932
- if (instanceOrigin != n) {
933
- if (waitings.has(instanceOrigin) == f) return;
936
+ // if (instanceOrigin != n) {
937
+ // if (waitings.has(instanceOrigin) == f) return;
938
+ // waitings.delete(instanceOrigin);
939
+ // if (latestIO != instanceOrigin && waitings.size > 0) return;
940
+ // }
941
+ if (instanceOrigin != n && waitings.has(instanceOrigin)) {
934
942
  waitings.delete(instanceOrigin);
935
- if (latestIO != instanceOrigin && waitings.size > 0) return;
943
+ // return instanceOrigin;
936
944
  }
937
945
  const aio = pageManager.closePage("!onRunning", f, instanceOrigin);
938
- latestIO = n;
946
+ // latestIO = n;
939
947
  if (backHolds > 0) postAsyncQueue(async _ => {
940
948
  const holds = backHolds;
941
949
  backHolds = 0;
942
950
  await aio;
943
951
  if (window.isLogging) console.log("Release holded back requests");
944
- // for (let i=0; i<holds; i++) await estreUi.onBack();
945
- await estreUi.onBack();
952
+ for (let i=0; i<holds; i++) await estreUi.onBack();
953
+ // await estreUi.onBack();
946
954
  })
947
955
  return aio;
948
956
  }
@@ -1567,14 +1575,20 @@ class EstrePageHandle {
1567
1575
 
1568
1576
  hostType = "unknown";
1569
1577
 
1570
- host = null
1578
+ #host = null;
1579
+ get host() { return this.#host; }
1580
+ #$host = null;
1581
+ get $host() { return this.#$host; }
1571
1582
 
1572
- host = null;
1573
- $host = null;
1574
1583
  id = null;
1584
+ get instanceId() { return !this.isStatic && this.isMultiInstance ? this.id + "^" + this.instanceOrigin : this.id; }
1585
+ get instanceOrigin() { return !this.isStatic && this.isMultiInstance ? this.$host?.attr(eds.instanceOrigin)?.ifEmpty(_ => u) : u; }
1586
+ set instanceOrigin(value) { if (!this.isStatic && this.isMultiInstance) this.$host?.attr(eds.instanceOrigin, value ?? ""); }
1575
1587
 
1576
- page = null;
1577
- pid = null;
1588
+ #page = null;
1589
+ get page() { return this.#page; }
1590
+ get pid() { return this.page?.pid; }
1591
+ get instancePid() { return this.page?.instancePid; }
1578
1592
 
1579
1593
  get isStatic() { return this.$host?.attr(eds.static) == t1; }
1580
1594
  get isFullyStatic() { return this.isStatic; }
@@ -1583,6 +1597,7 @@ class EstrePageHandle {
1583
1597
  const onTop = this.$host?.attr(eds.onTop);
1584
1598
  return onTop == t1 || onTop == "1*";
1585
1599
  }
1600
+ get isMultiInstance() { return this.$host?.attr(eds.multiInstance) == t1; }
1586
1601
 
1587
1602
  get isCanBack() { return false; }
1588
1603
 
@@ -1664,19 +1679,24 @@ class EstrePageHandle {
1664
1679
  // #revokeIntentDataBindProxy = {};
1665
1680
 
1666
1681
  #isProcessing = f;
1682
+ get isProcessing() { return this.#isProcessing; }
1683
+
1684
+ get mainArticle() { return this; }
1667
1685
 
1668
- constructor(host) {
1669
- this.host = host;
1670
- this.$host = $(host);
1671
1686
 
1672
- if (this.host.pageHandle != null && this.host.pageHandle != this) {
1687
+ constructor(host, instanceOrigin) {
1688
+ this.#host = host;
1689
+ this.#$host = $(host);
1690
+
1691
+ if (host.pageHandle != null && host.pageHandle != this) {
1673
1692
  try {
1674
- this.host.pageHandle.release();
1693
+ host.pageHandle.release();
1675
1694
  } catch (ex) {
1676
1695
  if (window.isLogging) console.error(ex.name + "\n", ex.message);
1677
1696
  }
1678
1697
  }
1679
- this.host.pageHandle = this;
1698
+ this.#host.pageHandle = this;
1699
+ if (!this.isStatic && this.isMultiInstance) this.instanceOrigin = instanceOrigin ?? "ai_" + Date.now();
1680
1700
  }
1681
1701
 
1682
1702
  release(remove) {
@@ -1687,14 +1707,13 @@ class EstrePageHandle {
1687
1707
  if (remove === true) this.$host?.remove();
1688
1708
  else {
1689
1709
  if (remove === false) this.$host?.empty();
1690
- this.host = n;
1691
- this.$host = n;
1710
+ this.#host = n;
1711
+ this.#$host = n;
1692
1712
  }
1693
1713
  }
1694
1714
 
1695
1715
  init(page, intent) {
1696
- this.page = page;
1697
- this.pid = page.pid;
1716
+ this.#page = page;
1698
1717
  page.fetchHandler(this);
1699
1718
  if (this.handler == null) this.setHandler(new EstrePageHandler(this));
1700
1719
 
@@ -1718,7 +1737,7 @@ class EstrePageHandle {
1718
1737
  set: (target, prop, value) => {
1719
1738
  if (prop == "data") {
1720
1739
  target.data = this.takeOnPageData(value);
1721
- if (!this.#isProcessing) this.applyActiveStruct();
1740
+ if (!this.mainArticle.isProcessing) this.mainArticle.applyActiveStruct(this.mainArticle.$host, this);
1722
1741
  } else target[prop] = value;
1723
1742
  return t;
1724
1743
  },
@@ -1727,7 +1746,7 @@ class EstrePageHandle {
1727
1746
  this.takeOnPageData(u);
1728
1747
  delete target.data;
1729
1748
  } else delete target[prop];
1730
- if (!this.#isProcessing) this.applyActiveStruct();
1749
+ if (!this.mainArticle.isProcessing) this.mainArticle.applyActiveStruct(this.mainArticle.$host, this);
1731
1750
  return t;
1732
1751
  },
1733
1752
  }) : u;//{ proxy: u, revoke: u };
@@ -1745,13 +1764,13 @@ class EstrePageHandle {
1745
1764
  get: (target, prop) => prop == "isProxy" ? t : target[prop],
1746
1765
  set: (target, prop, value) => {
1747
1766
  target[prop] = this.takeOnPageBind(prop, value);
1748
- if (!this.#isProcessing) this.applyActiveStruct();
1767
+ if (!this.mainArticle.isProcessing) this.mainArticle.applyActiveStruct(this.mainArticle.$host, this);
1749
1768
  return t;
1750
1769
  },
1751
1770
  deleteProperty: (target, prop) => {
1752
1771
  this.takeOnPageBind(prop, u);
1753
1772
  delete target[prop];
1754
- if (!this.#isProcessing) this.applyActiveStruct();
1773
+ if (!this.mainArticle.isProcessing) this.mainArticle.applyActiveStruct(this.mainArticle.$host, this);
1755
1774
  return t;
1756
1775
  },
1757
1776
  }) : u;//{ proxy: u, revoke: u };
@@ -1769,12 +1788,12 @@ class EstrePageHandle {
1769
1788
  get: (target, prop) => prop == "isProxy" ? t : target[prop],
1770
1789
  set: (target, prop, value) => {
1771
1790
  target[prop] = value;
1772
- if (!this.#isProcessing) this.applyActiveStruct();
1791
+ if (!this.mainArticle.isProcessing) this.mainArticle.applyActiveStruct(this.mainArticle.$host, this);
1773
1792
  return t;
1774
1793
  },
1775
1794
  deleteProperty: (target, prop) => {
1776
1795
  delete target[prop];
1777
- if (!this.#isProcessing) this.applyActiveStruct();
1796
+ if (!this.mainArticle.isProcessing) this.mainArticle.applyActiveStruct(this.mainArticle.$host, this);
1778
1797
  return t;
1779
1798
  },
1780
1799
  });
@@ -1788,22 +1807,24 @@ class EstrePageHandle {
1788
1807
  }
1789
1808
  }
1790
1809
 
1791
- apply(process = (data, intent) => {}, $bound = this.$host) {
1810
+ apply(process = (data, intent) => {}, $bound = this.mainArticle.$host, handle = this) {
1811
+ if (this.mainArticle != this) return this.mainArticle.apply(process, $bound, this);
1792
1812
  const isAlreadyProcessing = this.#isProcessing;
1793
1813
  if (!isAlreadyProcessing) this.#isProcessing = t;
1794
1814
  this.placeIntentData();
1795
1815
  process(this.intent.data, this.intent);
1796
1816
  if (!isAlreadyProcessing) this.#isProcessing = f;
1797
- return this.applyActiveStruct($bound);
1817
+ return this.applyActiveStruct($bound, handle);
1798
1818
  }
1799
1819
 
1800
- async applyAsync(process = async (data, intent) => {}, $bound = this.$host) {
1820
+ async applyAsync(process = async (data, intent) => {}, $bound = this.mainArticle.$host, handle = this) {
1821
+ if (this.mainArticle != this) return await this.mainArticle.applyAsync(process, $bound, handle);
1801
1822
  const isAlreadyProcessing = this.#isProcessing;
1802
1823
  if (!isAlreadyProcessing) this.#isProcessing = t;
1803
1824
  this.placeIntentData();
1804
1825
  await process(this.intent.data, this.intent);
1805
1826
  if (!isAlreadyProcessing) this.#isProcessing = f;
1806
- return await this.applyActiveStruct($bound);
1827
+ return await this.applyActiveStruct($bound, handle);
1807
1828
  }
1808
1829
 
1809
1830
  placeIntent(intent = {}) {
@@ -2083,11 +2104,13 @@ class EstrePageHandle {
2083
2104
 
2084
2105
 
2085
2106
  // active struct master
2086
- applyActiveStruct($host = this.$host, replaceHandles = false) {
2107
+ applyActiveStruct($host = this.$host, handle = this, replaceHandles = false) {
2087
2108
  this.initContentBrokers($host);
2088
2109
  this.initLiveElement($host, replaceHandles);
2089
2110
 
2090
- return this.handler.onApplied?.(this, this.intent?.data, this.intent, $host, replaceHandles);
2111
+ const applied = this.handler.onApplied?.(this, this.intent?.data, this.intent, $host, replaceHandles);
2112
+ if (handle != this) handle.handler.onApplied?.(handle, handle.intent?.data, handle.intent, $host, replaceHandles);
2113
+ return applied;
2091
2114
  }
2092
2115
 
2093
2116
  applyActiveStructLocalBind($host = this.$host) {
@@ -2803,13 +2826,27 @@ class EstrePageHostHandle extends EstrePageHandle {
2803
2826
 
2804
2827
  get currentTop() { return this.currentOnTop ?? this.subPageList.at(-1); }
2805
2828
 
2806
- #prevSubPageId = null;
2807
- get prevSubPageId() { return this.#prevSubPageId; };
2808
- set prevSubPageId(id) {
2809
- this.#prevSubPageId = id;
2829
+ #prevSubPageIds = new Set();
2830
+ get latestSubPageId() { return [...this.#prevSubPageIds].pop(); }
2831
+ get prevSubPageId() {
2832
+ const subPageIds = this.subPages.ways;
2833
+ let latestSubPageId = null;
2834
+ while (latestSubPageId = this.latestSubPageId) {
2835
+ this.#prevSubPageIds.delete(latestSubPageId);
2836
+ if (subPageIds.includes(latestSubPageId)) return latestSubPageId;
2837
+ }
2838
+ return null;
2839
+ };
2840
+ set prevSubPageId(id) {
2841
+ if (id == null) return;
2842
+ if (this.#prevSubPageIds.has(id)) this.$prevSubPages.delete(id);
2843
+ this.#prevSubPageIds.add(id);
2810
2844
  };
2811
2845
 
2812
- get isAvailablePrevSubPage() { return this.prevSubPageId != null && this.subPages[this.prevSubPageId] != null; }
2846
+ get isAvailablePrevSubPage() {
2847
+ const latestSubPageId = this.latestSubPageId;
2848
+ return latestSubPageId != null && this.subPages[latestSubPageId] != null;
2849
+ }
2813
2850
 
2814
2851
 
2815
2852
  initSubPages(intent) {
@@ -2825,19 +2862,19 @@ class EstrePageHostHandle extends EstrePageHandle {
2825
2862
  }
2826
2863
 
2827
2864
 
2828
- showSubPage(id, intent) {
2865
+ showSubPage(id, intent, instanceOrigin) {
2829
2866
  return false;
2830
2867
  }
2831
2868
 
2832
- openSubPage(id, intent) {
2869
+ openSubPage(id, intent, instanceOrigin) {
2833
2870
  return false;
2834
2871
  }
2835
2872
 
2836
- bringSubPage(id, intent) {
2873
+ bringSubPage(id, intent, instanceOrigin) {
2837
2874
  return false;
2838
2875
  }
2839
2876
 
2840
- closeSubPage(id, isTermination = false) {
2877
+ closeSubPage(id, instanceOrigin, isTermination = false) {
2841
2878
 
2842
2879
  }
2843
2880
 
@@ -2878,12 +2915,13 @@ class EstreComponent extends EstrePageHostHandle {
2878
2915
  if (registered === false) return false;
2879
2916
  this.unregister(component);
2880
2917
  this.componentList.push(component);
2881
- this.components[component.id] = component;
2918
+ this.components[component.instanceId] = component;
2882
2919
  return registered;
2883
2920
  }
2884
2921
 
2885
2922
  static unregister(component) {
2886
- if (this.components[component.id] != null) delete this.components[component.id];
2923
+ const instanceId = component.instanceId;
2924
+ if (this.components[instanceId] != null) delete this.components[instanceId];
2887
2925
  const index = this.componentList.indexOf(component);
2888
2926
  if (index > -1) this.componentList.splice(index, 1);
2889
2927
  return EstreUiPage.unregisterFrom(component);
@@ -2893,7 +2931,8 @@ class EstreComponent extends EstrePageHostHandle {
2893
2931
  // instance property
2894
2932
  get isCanBack() { switch (this.sectionBound) {
2895
2933
  case "main":
2896
- return !this.isHome && ((estreUi.prevRootTabId != null && estreUi.mainSections[estreUi.prevRootTabId] != null) || estreUi.mainSections["home"] != null);
2934
+ const latestRootTabId = estreUi.latestRootTabId;
2935
+ return !this.isHome && ((latestRootTabId != null && estreUi.mainSections[latestRootTabId] != null) || estreUi.mainSections["home"] != null);
2897
2936
 
2898
2937
  case "blind":
2899
2938
  case "menu":
@@ -2931,8 +2970,8 @@ class EstreComponent extends EstrePageHostHandle {
2931
2970
 
2932
2971
  get isHome() { return this.id == "home" || this.$host.hasClass("home"); }
2933
2972
 
2934
- constructor(component) {
2935
- super(component);
2973
+ constructor(component, instanceOrigin) {
2974
+ super(component, instanceOrigin);
2936
2975
  this.id = component.id;
2937
2976
  }
2938
2977
 
@@ -2967,8 +3006,8 @@ class EstreComponent extends EstrePageHostHandle {
2967
3006
  return this.initContainers(intent);
2968
3007
  }
2969
3008
 
2970
- registerSubPage(element, intent) {
2971
- return this.registerContainer(element, intent);
3009
+ registerSubPage(element, intent, instanceOrigin) {
3010
+ return this.registerContainer(element, intent, instanceOrigin);
2972
3011
  }
2973
3012
 
2974
3013
  unregisterSubPage(pageHandle) {
@@ -2988,11 +3027,12 @@ class EstreComponent extends EstrePageHostHandle {
2988
3027
  $top[$top.length - 1]?.pageHandle?.show(false, false);
2989
3028
  }
2990
3029
 
2991
- registerContainer(element, intent) {
3030
+ registerContainer(element, intent, instanceOrigin) {
2992
3031
  this.unregisterConatiner(element.pageHandle);
2993
- const container = new EstreContainer(element, this);
2994
- this.$container[container.id] = container.$host;
2995
- this.containers[container.id] = container;
3032
+ const container = new EstreContainer(element, this, instanceOrigin);
3033
+ const instanceId = container.instanceId;
3034
+ this.$container[instanceId] = container.$host;
3035
+ this.containers[instanceId] = container;
2996
3036
  this.containerList.push(container);
2997
3037
  const registered = EstreUiPage.registerOrCommitFrom(container);
2998
3038
  container.init(registered, intent);
@@ -3002,10 +3042,11 @@ class EstreComponent extends EstrePageHostHandle {
3002
3042
 
3003
3043
  unregisterConatiner(container) {
3004
3044
  if (container == null) return;
3045
+ const instanceId = container.instanceId;
3005
3046
  const unregitered = EstreUiPage.unregisterFrom(container);
3006
3047
  container.release(!container.isStatic ? true : null);
3007
- if (this.$container[container.id] != null) delete this.$container[container.id];
3008
- if (this.containers[container.id] != null) delete this.containers[container.id];
3048
+ if (this.$container[instanceId] != null) delete this.$container[instanceId];
3049
+ if (this.containers[instanceId] != null) delete this.containers[instanceId];
3009
3050
  const index = this.containerList.indexOf(container);
3010
3051
  if (index > -1) this.containerList.splice(index, 1);
3011
3052
  return unregitered;
@@ -3013,29 +3054,28 @@ class EstreComponent extends EstrePageHostHandle {
3013
3054
 
3014
3055
 
3015
3056
  // handles
3016
- showSubPage(id, intent) {
3017
- return this.showContainer(id, intent);
3057
+ showSubPage(id, intent, instanceOrigin) {
3058
+ return this.showContainer(id, intent, instanceOrigin);
3018
3059
  }
3019
3060
 
3020
- openSubPage(id, intent) {
3021
- return this.openContainer(id, intent);
3061
+ openSubPage(id, intent, instanceOrigin) {
3062
+ return this.openContainer(id, intent, instanceOrigin);
3022
3063
  }
3023
3064
 
3024
- bringSubPage(id, intent) {
3025
- return this.bringContainer(id, intent);
3065
+ bringSubPage(id, intent, instanceOrigin) {
3066
+ return this.bringContainer(id, intent, instanceOrigin);
3026
3067
  }
3027
3068
 
3028
- closeSubPage(id, isTermination = false) {
3029
- return this.closeContainer(id, isTermination);
3069
+ closeSubPage(id, instanceOrigin, isTermination = false) {
3070
+ return this.closeContainer(id, instanceOrigin, isTermination);
3030
3071
  }
3031
3072
 
3032
- showContainer(id, intent) {
3073
+ showContainer(id, intent, instanceOrigin) {
3033
3074
  if (id != null && !this.isClosing) {
3034
- const container = this.containers[id];
3035
- if (container != null) {
3075
+ const show = container => {
3036
3076
  const currentTopHandle = this.currentTop;
3037
- const currentTopHandleId = currentTopHandle.id;
3038
- if (id != currentTopHandleId && currentTopHandleId != this.prevSubPageId) {
3077
+ const currentTopHandleId = currentTopHandle.instanceId;
3078
+ if (id != currentTopHandleId && currentTopHandleId != this.latestSubPageId) {
3039
3079
  this.prevSubPageId = currentTopHandleId;
3040
3080
 
3041
3081
  // if (estreUi.euiState == "onReady" && currentTopHandle != null) switch (currentTopHandle.sectionBound) {
@@ -3060,12 +3100,23 @@ class EstreComponent extends EstrePageHostHandle {
3060
3100
  break;
3061
3101
  }
3062
3102
  return true;
3103
+ };
3104
+
3105
+ const container = this.containers[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
3106
+ if (container != null) return show(container);
3107
+ else if (instanceOrigin == n) {
3108
+ const containerIds = this.containers.ways.filter(it => it.startsWith(id + "^"));
3109
+ if (containerIds.length > 0) {
3110
+ const containerId = containerIds[containerIds.length - 1];
3111
+ const container = this.containers[containerId];
3112
+ if (container != null) return show(container);
3113
+ }
3063
3114
  }
3064
3115
  }
3065
3116
  return false;
3066
3117
  }
3067
3118
 
3068
- openContainer(id, intent) {
3119
+ openContainer(id, intent, instanceOrigin) {
3069
3120
  if (this.isClosing) return false;
3070
3121
  const page = pageManager.getConatiner(id, this.id, this.sectionBound);
3071
3122
  if (page == null) return null;
@@ -3073,13 +3124,12 @@ class EstreComponent extends EstrePageHostHandle {
3073
3124
  this.$host.append(page.live);
3074
3125
  const $container = this.$containers.filter(aiv(eds.containerId, id));
3075
3126
  if ($container == null || $container.length < 1) return null;
3076
- return this.registerContainer($container[0], intent);
3127
+ return this.registerContainer($container[$container.length - 1], intent, instanceOrigin);
3077
3128
  }
3078
3129
 
3079
- closeContainer(id, isTermination = false) {
3130
+ closeContainer(id, instanceOrigin, isTermination = false) {
3080
3131
  if (id != null) {
3081
- const container = this.containers[id];
3082
- if (container != null) {
3132
+ const close = container => {
3083
3133
  const task = container.close(false, isTermination || !container.isStatic);
3084
3134
  if (!isTermination && !this.isClosing) postAsyncQueue(async _ => {
3085
3135
  if (this.isClosing) return;
@@ -3087,9 +3137,8 @@ class EstreComponent extends EstrePageHostHandle {
3087
3137
  const subPageList = this.subPageList.filter(it => !it.isClosing && it != target);
3088
3138
  if (subPageList.length > 0) {
3089
3139
  const prev = this.prevSubPageId;
3090
- if (prev != null && id != prev && this.subPages[prev] != null) {
3091
- if (this.showSubPage(prev)) this.prevSubPageId = null;
3092
- } else subPageList[subPageList.length - 1].show();
3140
+ if (prev != null) this.showSubPage(prev);
3141
+ else subPageList[subPageList.length - 1].show();
3093
3142
  } else {
3094
3143
  await task;
3095
3144
  if (!this.isClosing && !this.isStatic && subPageList.length < 1) this.close(true, true);
@@ -3100,16 +3149,27 @@ class EstreComponent extends EstrePageHostHandle {
3100
3149
  if (isTermination || !container.isStatic) this.unregisterConatiner(container);
3101
3150
  return result;
3102
3151
  });
3152
+ };
3153
+
3154
+ const container = this.containers[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
3155
+ if (container != null) return close(container);
3156
+ else if (instanceOrigin == n) {
3157
+ const containerIds = this.containers.ways.filter(it => it.startsWith(id + "^"));
3158
+ if (containerIds.length > 0) {
3159
+ const containerId = containerIds[containerIds.length - 1];
3160
+ const container = this.containers[containerId];
3161
+ return close(container);
3162
+ }
3103
3163
  }
3104
3164
  }
3105
3165
  return null;
3106
3166
  }
3107
3167
 
3108
- bringContainer(id, intent) {
3168
+ bringContainer(id, intent, instanceOrigin) {
3109
3169
  if (this.containers[id] == null) {
3110
- if (this.openContainer(id, intent)) return this.showContainer(id);
3170
+ if (this.openContainer(id, intent, instanceOrigin)) return this.showContainer(id, u, instanceOrigin);
3111
3171
  else return false;
3112
- } else return this.showContainer(id, intent);
3172
+ } else return this.showContainer(id, intent, instanceOrigin);
3113
3173
  }
3114
3174
 
3115
3175
  onCloseContainer() {
@@ -3162,7 +3222,7 @@ class EstreComponent extends EstrePageHostHandle {
3162
3222
  else return false;
3163
3223
  }
3164
3224
 
3165
- close(isRequest = true, isTermination = false) {
3225
+ close(isRequest = true, isTermination = !this.isStatic) {
3166
3226
  if (isRequest) {
3167
3227
  if (this.isModal) {
3168
3228
  return this.onTop ? estreUi.closeModalTab(this.id, this.$host) : false;
@@ -3231,8 +3291,8 @@ class EstreMenuComponent extends EstreComponent {
3231
3291
 
3232
3292
 
3233
3293
 
3234
- constructor(component) {
3235
- super(component);
3294
+ constructor(component, instanceOrigin) {
3295
+ super(component, instanceOrigin);
3236
3296
  }
3237
3297
 
3238
3298
  release(remove) {
@@ -3265,9 +3325,9 @@ class EstreMenuComponent extends EstreComponent {
3265
3325
  } else super.show(false, setFocus);
3266
3326
  }
3267
3327
 
3268
- close(isRequest = true, isTermination = false) {
3328
+ close(isRequest = true, isTermination = !this.isStatic) {
3269
3329
  if (isRequest) {
3270
- return estreUi.closeMenuArea(this.id, isTermination);
3330
+ return estreUi.closeMenuArea(this.id, this.instanceOrigin, isTermination);
3271
3331
  } else return super.close(false, isTermination);
3272
3332
  }
3273
3333
  }
@@ -3295,8 +3355,8 @@ class EstreHeaderComponent extends EstreComponent {
3295
3355
 
3296
3356
 
3297
3357
 
3298
- constructor(component) {
3299
- super(component);
3358
+ constructor(component, instanceOrigin) {
3359
+ super(component, instanceOrigin);
3300
3360
  }
3301
3361
 
3302
3362
  release(remove) {
@@ -3329,9 +3389,9 @@ class EstreHeaderComponent extends EstreComponent {
3329
3389
  } else super.show(false, setFocus);
3330
3390
  }
3331
3391
 
3332
- close(isRequest = true, isTermination = false) {
3392
+ close(isRequest = true, isTermination = !this.isStatic) {
3333
3393
  if (isRequest) {
3334
- return estreUi.closeHeaderBar(this.id, isTermination);
3394
+ return estreUi.closeHeaderBar(this.id, this.instanceOrigin, isTermination);
3335
3395
  } else return super.close(false, isTermination);
3336
3396
  }
3337
3397
  }
@@ -3359,8 +3419,8 @@ class EstreInstantComponent extends EstreComponent {
3359
3419
 
3360
3420
 
3361
3421
 
3362
- constructor(component) {
3363
- super(component);
3422
+ constructor(component, instanceOrigin) {
3423
+ super(component, instanceOrigin);
3364
3424
  }
3365
3425
 
3366
3426
  release(remove) {
@@ -3393,9 +3453,9 @@ class EstreInstantComponent extends EstreComponent {
3393
3453
  } else super.show(false, setFocus);
3394
3454
  }
3395
3455
 
3396
- close(isRequest = true, isTermination = false) {
3456
+ close(isRequest = true, isTermination = !this.isStatic) {
3397
3457
  if (isRequest) {
3398
- return estreUi.closeInstantBlinded(this.id, isTermination);
3458
+ return estreUi.closeInstantBlinded(this.id, this.instanceOrigin, isTermination);
3399
3459
  } else return super.close(false, isTermination);
3400
3460
  }
3401
3461
  }
@@ -3423,8 +3483,8 @@ class EstreOverlayComponent extends EstreInstantComponent {
3423
3483
 
3424
3484
 
3425
3485
 
3426
- constructor(component) {
3427
- super(component);
3486
+ constructor(component, instanceOrigin) {
3487
+ super(component, instanceOrigin);
3428
3488
  }
3429
3489
 
3430
3490
  release(remove) {
@@ -3457,9 +3517,9 @@ class EstreOverlayComponent extends EstreInstantComponent {
3457
3517
  } else super.show(false, setFocus);
3458
3518
  }
3459
3519
 
3460
- close(isRequest = true, isTermination = false) {
3520
+ close(isRequest = true, isTermination = !this.isStatic) {
3461
3521
  if (isRequest) {
3462
- return estreUi.closeManagedOverlay(this.id, isTermination);
3522
+ return estreUi.closeManagedOverlay(this.id, this.instanceOrigin, isTermination);
3463
3523
  } else return super.close(false, isTermination);
3464
3524
  }
3465
3525
  }
@@ -3534,8 +3594,8 @@ class EstreContainer extends EstrePageHostHandle {
3534
3594
  }
3535
3595
  get stepPagesLength() { return pageManager.getStepPagesLength(this.#articleStepsId, this.id, this.component.id, this.component.sectionBound); }
3536
3596
 
3537
- constructor(container, component) {
3538
- super(container);
3597
+ constructor(container, component, instanceOrigin) {
3598
+ super(container, instanceOrigin);
3539
3599
  this.component = component;
3540
3600
  this.id = this.$host.attr(eds.containerId);
3541
3601
  }
@@ -3615,8 +3675,8 @@ class EstreContainer extends EstrePageHostHandle {
3615
3675
  return this.initArticles(intent);
3616
3676
  }
3617
3677
 
3618
- registerSubPage(element, intent) {
3619
- return this.registerArticle(element, intent);
3678
+ registerSubPage(element, intent, instanceOrigin) {
3679
+ return this.registerArticle(element, intent, instanceOrigin);
3620
3680
  }
3621
3681
 
3622
3682
  unregisterConatiner(pageHandle) {
@@ -3667,11 +3727,12 @@ class EstreContainer extends EstrePageHostHandle {
3667
3727
  }
3668
3728
  }
3669
3729
 
3670
- registerArticle(element, intent) {
3730
+ registerArticle(element, intent, instanceOrigin) {
3671
3731
  this.unregisterArticle(element.pageHandle);
3672
- const article = new EstreArticle(element, this);
3673
- this.$article[article.id] = article.$host;
3674
- this.articles[article.id] = article;
3732
+ const article = new EstreArticle(element, this, instanceOrigin);
3733
+ const instanceId = article.instanceId;
3734
+ this.$article[instanceId] = article.$host;
3735
+ this.articles[instanceId] = article;
3675
3736
  this.articleList.push(article);
3676
3737
  const registered = EstreUiPage.registerOrCommitFrom(article);
3677
3738
  article.init(registered, intent);
@@ -3681,10 +3742,11 @@ class EstreContainer extends EstrePageHostHandle {
3681
3742
 
3682
3743
  unregisterArticle(article) {
3683
3744
  if (article == null) return;
3745
+ const instanceId = article.instanceId;
3684
3746
  const unregistered = EstreUiPage.unregisterFrom(article);
3685
3747
  article.release(!article.isStatic ? true : null);
3686
- if (this.$article[article.id] != null) delete this.$article[article.id];
3687
- if (this.articles[article.id] != null) delete this.articles[article.id];
3748
+ if (this.$article[instanceId] != null) delete this.$article[instanceId];
3749
+ if (this.articles[instanceId] != null) delete this.articles[instanceId];
3688
3750
  const index = this.articleList.indexOf(article);
3689
3751
  if (index > -1) this.articleList.splice(index, 1);
3690
3752
  return unregistered;
@@ -3818,7 +3880,7 @@ class EstreContainer extends EstrePageHostHandle {
3818
3880
 
3819
3881
  close(isRequest = true, isTermination = false) {
3820
3882
  if (isRequest) {
3821
- return this.component.closeContainer(this.id, isTermination) ?? super.close(isTermination);
3883
+ return this.component.closeContainer(this.id, this.instanceOrigin, isTermination) ?? super.close(isTermination);
3822
3884
  } else return super.close(isTermination);
3823
3885
  }
3824
3886
 
@@ -3860,7 +3922,7 @@ class EstreContainer extends EstrePageHostHandle {
3860
3922
 
3861
3923
  if (stepped.length > 0) {
3862
3924
  const sorted = stepped.sort();
3863
- for (var i=sorted.length-1; i>-1; i--) closer.push(this.closeArticle(sorted[i], isTermination));
3925
+ for (var i=sorted.length-1; i>-1; i--) closer.push(this.closeArticle(sorted[i], u, isTermination));
3864
3926
  } else {
3865
3927
  for (var article of this.articleList.reverse()) closer.push(article.close(true, isTermination));
3866
3928
  }
@@ -3872,32 +3934,31 @@ class EstreContainer extends EstrePageHostHandle {
3872
3934
 
3873
3935
 
3874
3936
  // handles
3875
- showSubPage(id, intent) {
3876
- return this.showArticle(id, intent);
3937
+ showSubPage(id, intent, instanceOrigin) {
3938
+ return this.showArticle(id, intent, instanceOrigin);
3877
3939
  }
3878
3940
 
3879
- openSubPage(id, intent) {
3880
- return this.openArticle(id, intent);
3941
+ openSubPage(id, intent, instanceOrigin) {
3942
+ return this.openArticle(id, intent, instanceOrigin);
3881
3943
  }
3882
3944
 
3883
3945
  bringSubPage(id, intent) {
3884
- return this.bringArticle(id, intent);
3946
+ return this.bringArticle(id, intent, instanceOrigin);
3885
3947
  }
3886
3948
 
3887
- closeSubPage(id, isTermination = false) {
3888
- return this.closeArticle(id, isTermination);
3949
+ closeSubPage(id, instanceOrigin, isTermination = false) {
3950
+ return this.closeArticle(id, instanceOrigin, isTermination);
3889
3951
  }
3890
3952
 
3891
- showArticle(id, intent) {
3953
+ showArticle(id, intent, instanceOrigin) {
3892
3954
  if (id != null && !this.isClosing) {
3893
- const $target = this.$article[id];
3894
- if ($target != null && $target.length > 0) {
3955
+ const show = $target => {
3895
3956
  const onlyOne = this.$articles.filter(ntc("dummy")).length === 1;
3896
3957
  const $currentTop = this.$articles.filter(asv(eds.onTop, t1));
3897
3958
  //console.log("current top: ", $currentTop);
3898
3959
  const currentTopHandle = this.currentTop;
3899
3960
  const currentTopHandleId = currentTopHandle.id;
3900
- if (id != currentTopHandleId && currentTopHandleId != this.prevSubPageId) {
3961
+ if (id != currentTopHandleId && currentTopHandleId != this.latestSubPageId) {
3901
3962
  this.prevSubPageId = currentTopHandleId;
3902
3963
 
3903
3964
  // if (estreUi.euiState == "onReady" && currentTopHandle != null) estreUi.pushCurrentState(currentTopHandle);
@@ -3969,23 +4030,36 @@ class EstreContainer extends EstrePageHostHandle {
3969
4030
  }
3970
4031
  return true;
3971
4032
  }
4033
+ };
4034
+
4035
+ const $target = this.$article[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
4036
+ if ($target != null && $target.length > 0) return show($target);
4037
+ else if (instanceOrigin == n) {
4038
+ const articleIds = this.$article.ways.filter(it => it.startsWith(id + "^"));
4039
+ if (articleIds.length > 0) {
4040
+ const articleId = articleIds[articleIds.length - 1];
4041
+ const $target = this.$article[articleId];
4042
+ if ($target != null && $target.length > 0) return show($target);
4043
+ }
3972
4044
  }
3973
4045
  }
3974
4046
  return false;
3975
4047
  }
3976
4048
 
3977
- openArticle(id, intent) {
4049
+ openArticle(id, intent, instanceOrigin) {
3978
4050
  if (this.isClosing) return false;
3979
4051
  const page = pageManager.getArticle(id, this.id, this.component.id, this.component.sectionBound);
3980
4052
  if (page == null) return null;
3981
4053
  if (page.statement == "static") return null;
3982
- var $exist = this.$articles.filter(aiv(eds.articleId, id));
3983
- if ($exist.length > 0) {
3984
- this.closeArticle(id);
4054
+ if (!page.isMultiInstance) {
3985
4055
  var $exist = this.$articles.filter(aiv(eds.articleId, id));
3986
4056
  if ($exist.length > 0) {
3987
- if ($exist[0].pageHandle != null) $exist[0].pageHandle.release(true);
3988
- else $exist.remove();
4057
+ this.closeArticle(id);
4058
+ var $exist = this.$articles.filter(aiv(eds.articleId, id));
4059
+ if ($exist.length > 0) {
4060
+ if ($exist[0].pageHandle != null) $exist[0].pageHandle.release(true);
4061
+ else $exist.remove();
4062
+ }
3989
4063
  }
3990
4064
  }
3991
4065
  const $articles = this.$articles;
@@ -3994,22 +4068,21 @@ class EstreContainer extends EstrePageHostHandle {
3994
4068
  else this.$host.append(page.live);
3995
4069
  const $article = this.$articles.filter(aiv(eds.articleId, id));
3996
4070
  if ($article == null || $article.length < 1) return null;
3997
- const article = this.registerArticle($article[0], intent);
4071
+ const article = this.registerArticle($article[$article.length - 1], intent, instanceOrigin);
3998
4072
  //this.#updateStepNavigation();
3999
4073
  return article;
4000
4074
  }
4001
4075
 
4002
- bringArticle(id, intent) {
4076
+ bringArticle(id, intent, instanceOrigin) {
4003
4077
  if (this.articles[id] == null) {
4004
- if (this.openArticle(id, intent)) return this.showArticle(id);
4078
+ if (this.openArticle(id, intent, instanceOrigin)) return this.showArticle(id);
4005
4079
  else return false;
4006
4080
  } else return this.showArticle(id, intent);
4007
4081
  }
4008
4082
 
4009
- closeArticle(id, isTermination = false) {
4083
+ closeArticle(id, instanceOrigin, isTermination = false) {
4010
4084
  if (id != null) {
4011
- const article = this.articles[id];
4012
- if (article != null) {
4085
+ const close = article => {
4013
4086
  const task = article.close(false, isTermination || !article.isStatic);
4014
4087
  if (!isTermination && !this.isClosing) postAsyncQueue(async _ => {
4015
4088
  if (this.isClosing) return;
@@ -4017,9 +4090,8 @@ class EstreContainer extends EstrePageHostHandle {
4017
4090
  const subPageList = this.subPageList.filter(it => !it.isClosing && it != target);
4018
4091
  if (subPageList.length > 0) {
4019
4092
  const prev = this.prevSubPageId;
4020
- if (prev != null && id != prev && this.subPages[prev] != null) {
4021
- if (this.showSubPage(prev)) this.prevSubPageId = null;
4022
- } else subPageList[subPageList.length - 1].show();
4093
+ if (prev != null) this.showSubPage(prev);
4094
+ else subPageList[subPageList.length - 1].show();
4023
4095
  } else {
4024
4096
  await task;
4025
4097
  if (!this.isClosing && !this.isStatic && subPageList.length < 1) this.close(true, true);
@@ -4030,6 +4102,17 @@ class EstreContainer extends EstrePageHostHandle {
4030
4102
  if (isTermination || !article.isStatic) this.unregisterArticle(article);
4031
4103
  return result;
4032
4104
  });
4105
+ };
4106
+
4107
+ const article = this.articles[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
4108
+ if (article != null) return close(article);
4109
+ else if (instanceOrigin == n) {
4110
+ const articleIds = this.$article.ways.filter(it => it.startsWith(id + "^"));
4111
+ if (articleIds.length > 0) {
4112
+ const articleId = articleIds[articleIds.length - 1];
4113
+ const article = this.articles[articleId];
4114
+ return close(article);
4115
+ }
4033
4116
  }
4034
4117
  }
4035
4118
  return null;
@@ -4075,8 +4158,8 @@ class EstreArticle extends EstrePageHandle {
4075
4158
 
4076
4159
  dateShowers = [];
4077
4160
 
4078
- constructor(article, container) {
4079
- super(article);
4161
+ constructor(article, container, instanceOrigin) {
4162
+ super(article, instanceOrigin);
4080
4163
  this.container = container;
4081
4164
  this.id = this.$host.attr(eds.articleId);
4082
4165
  }
@@ -4121,7 +4204,7 @@ class EstreArticle extends EstrePageHandle {
4121
4204
 
4122
4205
  close(isRequest = true, isTermination = false) {
4123
4206
  if (isRequest) {
4124
- return this.container.closeArticle(this.id, isTermination) ?? super.close(isTermination);
4207
+ return this.container.closeArticle(this.id, this.instanceOrigin, isTermination) ?? super.close(isTermination);
4125
4208
  } else return super.close(isTermination);
4126
4209
  }
4127
4210
 
@@ -4945,11 +5028,11 @@ class EstreUiPage {
4945
5028
  } else if (backHolds < cancellationExceeds - 1) {
4946
5029
  return onBackWhile(handle);
4947
5030
  } else if (backHolds == cancellationExceeds - 1) {
4948
- const instanceOrigin = latestIO;
5031
+ // const instanceOrigin = latestIO;
4949
5032
  backHolds = 0;
4950
5033
  this.isTriggeredCancellation = t;
4951
5034
  this.intentData?.callbackCancellation?.();
4952
- postQueue(_ => go(instanceOrigin));
5035
+ // postQueue(_ => go(instanceOrigin));
4953
5036
  return handle.close();
4954
5037
  }
4955
5038
  }
@@ -5253,6 +5336,25 @@ class EstreUiPage {
5253
5336
  else return null;
5254
5337
  }
5255
5338
 
5339
+ #componentInstanceOrigin;
5340
+ #containerInstanceOrigin;
5341
+ #articleInstanceOrigin;
5342
+
5343
+ get componentInstanceOrigin() { return this.#componentInstanceOrigin; }
5344
+ get containerInstanceOrigin() { return this.#containerInstanceOrigin; }
5345
+ get articleInstanceOrigin() { return this.#articleInstanceOrigin; }
5346
+
5347
+ get instanceOrigin() {
5348
+ if (this.#article != null) return this.#articleInstanceOrigin;
5349
+ else if (this.#container != null) return this.#containerInstanceOrigin;
5350
+ else if (this.#component != null) return this.#componentInstanceOrigin;
5351
+ else return null;
5352
+ }
5353
+
5354
+ get componentInstanceId() { return this.#componentIsMultiInstance ? this.#component + "^" + this.#componentInstanceOrigin : this.component; }
5355
+ get containerInstanceId() { return this.#containerIsMultiInstance ? this.#container + "^" + this.#containerInstanceOrigin : this.container; }
5356
+ get articleInstanceId() { return this.#articleIsMultiInstance ? this.#article + "^" + this.#articleInstanceOrigin : this.article; }
5357
+
5256
5358
  #instances = [];
5257
5359
  get instances() { return this.#instances; }
5258
5360
 
@@ -5307,9 +5409,26 @@ class EstreUiPage {
5307
5409
  pid += "&" + (this.sectionBound == "main" ? "m" : (this.sectionBound == "blind" ? "b" : (this.sectionBound == "overlay" ? "o" : (this.sectionBound == "header" ? "h" : (this.sectionBound == "menu" ? "u" : "")))));
5308
5410
  pid += "=";
5309
5411
  pid += this.#component;
5310
- if (this.#container != null) pid += "#" + this.#container;
5311
- if (this.#article != null) pid += "@" + this.#article;
5312
- if (this.isMultiInstance) pid += "^";
5412
+ if (this.#componentIsMultiInstance) pid += "^";
5413
+ if (this.#container != null) {
5414
+ pid += "#" + this.#container;
5415
+ if (this.#containerIsMultiInstance) pid += "^";
5416
+ }
5417
+ if (this.#article != null) {
5418
+ pid += "@" + this.#article;
5419
+ if (this.#articleIsMultiInstance) pid += "^";
5420
+ }
5421
+ return pid;
5422
+ }
5423
+
5424
+ get instancePid() {
5425
+ var pid = "";
5426
+ pid += "$" + (this.statement == "static" ? "s" : (this.statement == "instant" ? "i" : ""));
5427
+ pid += "&" + (this.sectionBound == "main" ? "m" : (this.sectionBound == "blind" ? "b" : (this.sectionBound == "overlay" ? "o" : (this.sectionBound == "header" ? "h" : (this.sectionBound == "menu" ? "u" : "")))));
5428
+ pid += "=";
5429
+ pid += this.componentInstanceId;
5430
+ if (this.#container != null) pid += "#" + this.containerInstanceId;
5431
+ if (this.#article != null) pid += "@" + this.articleInstanceId;
5313
5432
  return pid;
5314
5433
  }
5315
5434
 
@@ -5412,6 +5531,18 @@ class EstreUiPage {
5412
5531
  return this;
5413
5532
  }
5414
5533
 
5534
+ setInstanceOrigin(instanceOrigin) {
5535
+ if (isArray(instanceOrigin)) {
5536
+ this.#componentInstanceOrigin = instanceOrigin[0];
5537
+ this.#containerInstanceOrigin = instanceOrigin[1];
5538
+ this.#articleInstanceOrigin = instanceOrigin[2];
5539
+ } else equalCase(this.hostType, {
5540
+ "component": _ => this.#componentInstanceOrigin = instanceOrigin,
5541
+ "container": _ => this.#containerInstanceOrigin = instanceOrigin,
5542
+ "article": _ => this.#articleInstanceOrigin = instanceOrigin,
5543
+ });
5544
+ }
5545
+
5415
5546
  setComponentRefer($component) {
5416
5547
  if (this.#commited) return false;
5417
5548
 
@@ -5424,6 +5555,7 @@ class EstreUiPage {
5424
5555
 
5425
5556
  this.#componentStatement = $component.attr(eds.static) == t1 ? "static" : "instant";
5426
5557
  this.#componentIsMultiInstance = $component.attr(eds.multiInstance) == t1;
5558
+ this.#componentInstanceOrigin = $component.attr(eds.instanceOrigin)?.ifEmpty(_ => u);
5427
5559
 
5428
5560
  if (this.#sectionBound == null) {
5429
5561
  const $componentHost = $component.closest("main, nav, header, footer");
@@ -5449,6 +5581,7 @@ class EstreUiPage {
5449
5581
 
5450
5582
  this.#containerStatement = $container.attr(eds.static) == t1 ? "static" : "instant";
5451
5583
  this.#containerIsMultiInstance = $container.attr(eds.multiInstance) == t1;
5584
+ this.#containerInstanceOrigin = $container.attr(eds.instanceOrigin)?.ifEmpty(_ => u);
5452
5585
 
5453
5586
  if ($component == null) $component = $container.closest("section");
5454
5587
 
@@ -5471,6 +5604,7 @@ class EstreUiPage {
5471
5604
 
5472
5605
  this.#articleStatement = $article.attr(eds.static) == t1 ? "static" : "instant";
5473
5606
  this.#articleIsMultiInstance = $article.attr(eds.multiInstance) == t1;
5607
+ this.#articleInstanceOrigin = $article.attr(eds.instanceOrigin)?.ifEmpty(_ => u);
5474
5608
 
5475
5609
  if ($container == null) $container = $article.closest("div.container");
5476
5610
 
@@ -5677,6 +5811,7 @@ class EstreUiPageManager {
5677
5811
  if (pid.indexOf("$") < 0) pid = this.findPid(pid);
5678
5812
  const page = this.get(pid);
5679
5813
  if (page == null) return null;
5814
+ page.setInstanceOrigin(instanceOrigin);
5680
5815
  const sections = page.sections;
5681
5816
  if (sections == null) return null;
5682
5817
 
@@ -5684,35 +5819,38 @@ class EstreUiPageManager {
5684
5819
 
5685
5820
  //check open component
5686
5821
  const isIntentNone = typeof intent == UNDEFINED;
5822
+ const componentInstanceOrigin = page.componentInstanceOrigin;
5687
5823
  var componentIntentPushed = false;
5688
- var component = sections[page.component];
5824
+ var component = sections[page.componentInstanceId];
5689
5825
  var existComponent = false;
5690
5826
  if (component == null) {
5691
5827
  if (page.componentIsInatant) {
5692
5828
  if (page.isMenu) {
5693
5829
  if (page.isComponent) {
5694
- component = estreUi.openMenuArea(page.component, intent);
5830
+ component = estreUi.openMenuArea(page.component, intent, componentInstanceOrigin);
5695
5831
  componentIntentPushed = true;
5696
- } else component = estreUi.openMenuArea(page.component);
5832
+ } else component = estreUi.openMenuArea(page.component, u, componentInstanceOrigin);
5697
5833
  } else if (page.isBlinded) {
5698
5834
  if (page.isComponent) {
5699
- component = estreUi.openInstantBlinded(page.component, intent);
5835
+ component = estreUi.openInstantBlinded(page.component, intent, componentInstanceOrigin);
5700
5836
  componentIntentPushed = true;
5701
- } else component = estreUi.openInstantBlinded(page.component);
5837
+ } else component = estreUi.openInstantBlinded(page.component, u, componentInstanceOrigin);
5702
5838
  } else if (page.isOverlay) {
5703
5839
  if (page.isComponent) {
5704
- component = estreUi.openManagedOverlay(page.component, intent);
5840
+ component = estreUi.openManagedOverlay(page.component, intent, componentInstanceOrigin);
5705
5841
  componentIntentPushed = true;
5706
- } else component = estreUi.openManagedOverlay(page.component);
5842
+ } else component = estreUi.openManagedOverlay(page.component, u, componentInstanceOrigin);
5707
5843
  } else if (page.isHeader) {
5708
5844
  if (page.isComponent) {
5709
- component = estreUi.openHeaderBar(page.component, intent);
5845
+ component = estreUi.openHeaderBar(page.component, intent, componentInstanceOrigin);
5710
5846
  componentIntentPushed = true;
5711
- } else component = estreUi.openHeaderBar(page.component);
5847
+ } else component = estreUi.openHeaderBar(page.component, u, componentInstanceOrigin);
5712
5848
  } else return false;
5713
5849
  } else return false;
5714
5850
  } else existComponent = true;
5715
5851
  if (component == null) return null;
5852
+ const containerInstanceOrigin = page.containerInstanceOrigin;
5853
+ const articleInstanceOrigin = page.articleInstanceOrigin;
5716
5854
  var containerIntentPushed = false;
5717
5855
  var articleIntentPushed = false;
5718
5856
  var container = null;
@@ -5721,13 +5859,13 @@ class EstreUiPageManager {
5721
5859
  var existArticle = false;
5722
5860
  if (page.container != null) {
5723
5861
  //check open container
5724
- container = component.containers[page.container];
5862
+ container = component.containers[page.containerInstanceId];
5725
5863
  if (container == null) {
5726
5864
  if (page.containerIsInatant) {
5727
5865
  if (page.isArticle || page.isContainer || page.container == "root") {
5728
- container = component.openContainer(page.container, intent);
5866
+ container = component.openContainer(page.container, intent, containerInstanceOrigin);
5729
5867
  containerIntentPushed = true;
5730
- } else container = component.openContainer(page.container);
5868
+ } else container = component.openContainer(page.container, u, containerInstanceOrigin);
5731
5869
  } else if (page.isContainer) return false;//static container is cannot open
5732
5870
  else {
5733
5871
 
@@ -5737,13 +5875,13 @@ class EstreUiPageManager {
5737
5875
 
5738
5876
  if (page.article != null) {
5739
5877
  //check open article
5740
- article = container.articles[page.article];
5878
+ article = container.articles[page.articleInstanceId];
5741
5879
  if (article == null) {
5742
5880
  if (page.articleIsInatant) {
5743
5881
  if (page.isArticle || page.article == "main") {
5744
- article = container.openArticle(page.article, intent);
5882
+ article = container.openArticle(page.article, intent, articleInstanceOrigin);
5745
5883
  articleIntentPushed = true;
5746
- } else article = container.openArticle(page.article);
5884
+ } else article = container.openArticle(page.article, u, articleInstanceOrigin);
5747
5885
  } else return false;//static article is cannot open
5748
5886
  } else existArticle = true;
5749
5887
  if (article == null) return null;
@@ -5754,35 +5892,35 @@ class EstreUiPageManager {
5754
5892
  const isRootMain = page.container == "root" && page.article == "main";
5755
5893
  switch (page.hostType) {
5756
5894
  case "article":
5757
- if (!isIntentNone && existArticle && (page.isArticle || page.article == "main")) targetProcessed.article = container.showArticle(page.article, intent);
5895
+ if (!isIntentNone && existArticle && (page.isArticle || page.article == "main")) targetProcessed.article = container.showArticle(page.article, intent, articleInstanceOrigin);
5758
5896
  else targetProcessed.article = article.show();
5759
5897
  success = targetProcessed.article;
5760
5898
  case "container":
5761
5899
  if (success) {
5762
- if (!isIntentNone && existContainer && (page.isContainer || isRootMain)) targetProcessed.container = component.showContainer(page.container, intent);
5900
+ if (!isIntentNone && existContainer && (page.isContainer || isRootMain)) targetProcessed.container = component.showContainer(page.container, intent, containerInstanceOrigin);
5763
5901
  else targetProcessed.container = container.show();
5764
5902
  success = targetProcessed.container;
5765
5903
  }
5766
5904
  case "component":
5767
5905
  if (success) {
5768
5906
  if (page.isHeader) {
5769
- if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showHeaderBar(page.component, intent);
5770
- else targetProcessed.component = estreUi.showHeaderBar(page.component);
5907
+ if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showHeaderBar(page.component, intent, componentInstanceOrigin);
5908
+ else targetProcessed.component = estreUi.showHeaderBar(page.component, u, componentInstanceOrigin);
5771
5909
  } else if (page.isMenu) {
5772
- if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showMenuArea(page.component, intent);
5773
- else targetProcessed.component = estreUi.showMenuArea(page.component);
5910
+ if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showMenuArea(page.component, intent, componentInstanceOrigin);
5911
+ else targetProcessed.component = estreUi.showMenuArea(page.component, u, componentInstanceOrigin);
5774
5912
  } else if (page.isOverlay) {
5775
- if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showManagedOverlay(page.component, intent);
5776
- else targetProcessed.component = estreUi.showManagedOverlay(page.component);
5913
+ if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showManagedOverlay(page.component, intent, componentInstanceOrigin);
5914
+ else targetProcessed.component = estreUi.showManagedOverlay(page.component, u, componentInstanceOrigin);
5777
5915
  } else if (page.isBlinded) {
5778
- if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showInstantBlinded(page.component, intent);
5779
- else targetProcessed.component = estreUi.showInstantBlinded(page.component);
5916
+ if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showInstantBlinded(page.component, intent, componentInstanceOrigin);
5917
+ else targetProcessed.component = estreUi.showInstantBlinded(page.component, u, componentInstanceOrigin);
5780
5918
  } else if (component.isModal) {
5781
- if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.openModalTab(page.component, component, intent);
5782
- else targetProcessed.component = estreUi.openModalTab(page.component, component);
5919
+ if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.openModalTab(page.component, component, intent, componentInstanceOrigin);
5920
+ else targetProcessed.component = estreUi.openModalTab(page.component, u, componentInstanceOrigin);
5783
5921
  } else {
5784
- if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.switchRootTab(page.component, intent);
5785
- else targetProcessed.component = estreUi.mainCurrentOnTop == component || estreUi.switchRootTab(page.component);
5922
+ if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.switchRootTab(page.component, intent, componentInstanceOrigin);
5923
+ else targetProcessed.component = estreUi.mainCurrentOnTop == component || estreUi.switchRootTab(page.component, u, componentInstanceOrigin);
5786
5924
  }
5787
5925
  success = targetProcessed.component;
5788
5926
  }
@@ -5799,21 +5937,25 @@ class EstreUiPageManager {
5799
5937
  if (pid.indexOf("$") < 0) pid = this.findPid(pid);
5800
5938
  const page = this.get(pid);
5801
5939
  if (page == null) return null;
5940
+ page.setInstanceOrigin(instanceOrigin);
5802
5941
  const sections = page.sections;
5803
5942
  if (sections == null) return null;
5804
5943
 
5805
5944
  if (intent?.bringOnBack != n && intent.bringOnBack.hostType == n) intent.bringOnBack.hostType = page.hostType;
5806
5945
 
5807
5946
  const isIntentNone = typeof intent == UNDEFINED;
5808
- var component = sections[page.component];
5947
+ var component = sections[page.componentInstanceId];
5809
5948
  if (component == null) return null;
5949
+ const componentInstanceOrigin = page.componentInstanceOrigin;
5950
+ const containerInstanceOrigin = page.containerInstanceOrigin;
5951
+ const articleInstanceOrigin = page.articleInstanceOrigin;
5810
5952
  var container = null;
5811
5953
  var article = null;
5812
5954
  if (page.container != null) {
5813
- container = component.containers[page.container];
5955
+ container = component.containers[page.containerInstanceId];
5814
5956
  if (container == null) return null;
5815
5957
  if (page.article != null) {
5816
- article = container.articles[page.article];
5958
+ article = container.articles[page.articleInstanceId];
5817
5959
  if (article == null) return null;
5818
5960
  }
5819
5961
  }
@@ -5821,12 +5963,12 @@ class EstreUiPageManager {
5821
5963
  var targetProcessed = { component: null, container: null, article: null };
5822
5964
  switch (page.hostType) {
5823
5965
  case "article":
5824
- if (!isIntentNone && (page.isArticle || page.article == "main")) targetProcessed.article = container.showArticle(page.article, intent);
5966
+ if (!isIntentNone && (page.isArticle || page.article == "main")) targetProcessed.article = container.showArticle(page.article, intent, articleInstanceOrigin);
5825
5967
  else targetProcessed.article = article.show();
5826
5968
  success = targetProcessed.article;
5827
5969
  case "container":
5828
5970
  if (success) {
5829
- if (!isIntentNone && (page.isContainer || (page.article == "main" && page.container == "root"))) targetProcessed.container = component.showContainer(page.container, intent);
5971
+ if (!isIntentNone && (page.isContainer || (page.article == "main" && page.container == "root"))) targetProcessed.container = component.showContainer(page.container, intent, containerInstanceOrigin);
5830
5972
  else targetProcessed.container = container.show();
5831
5973
  success = targetProcessed.container;
5832
5974
  }
@@ -5834,20 +5976,20 @@ class EstreUiPageManager {
5834
5976
  if (success) {
5835
5977
  const isRootMain = page.container == "root" && page.article == "main";
5836
5978
  if (page.isOverlay) {
5837
- if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showManagedOverlay(page.component, intent);
5838
- else targetProcessed.component = estreUi.showManagedOverlay(page.component);
5979
+ if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showManagedOverlay(page.component, intent, componentInstanceOrigin);
5980
+ else targetProcessed.component = estreUi.showManagedOverlay(page.component, u, componentInstanceOrigin);
5839
5981
  } else if (page.isMenu) {
5840
- if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showMenuArea(page.component, intent);
5841
- else targetProcessed.component = estreUi.showMenuArea(page.component);
5982
+ if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showMenuArea(page.component, intent, componentInstanceOrigin);
5983
+ else targetProcessed.component = estreUi.showMenuArea(page.component, u, componentInstanceOrigin);
5842
5984
  } else if (page.isBlinded) {
5843
- if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showInstantBlinded(page.component, intent);
5844
- else targetProcessed.component = estreUi.showInstantBlinded(page.component);
5985
+ if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showInstantBlinded(page.component, intent, componentInstanceOrigin);
5986
+ else targetProcessed.component = estreUi.showInstantBlinded(page.component, u, componentInstanceOrigin);
5845
5987
  } else if (component.isModal) {
5846
- if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.openModalTab(page.component, component, intent);
5847
- else targetProcessed.component = estreUi.openModalTab(page.component, component);
5988
+ if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.openModalTab(page.component, component, intent, componentInstanceOrigin);
5989
+ else targetProcessed.component = estreUi.openModalTab(page.component, component, u, componentInstanceOrigin);
5848
5990
  } else {
5849
- if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.switchRootTab(page.component, intent);
5850
- else targetProcessed.component = estreUi.mainCurrentOnTop == component || estreUi.switchRootTab(page.component, intent);
5991
+ if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.switchRootTab(page.component, intent, componentInstanceOrigin);
5992
+ else targetProcessed.component = estreUi.mainCurrentOnTop == component || estreUi.switchRootTab(page.component, intent, u, componentInstanceOrigin);
5851
5993
  }
5852
5994
  success = targetProcessed.component;
5853
5995
  }
@@ -5868,19 +6010,23 @@ class EstreUiPageManager {
5868
6010
  if (pid.indexOf("$") < 0) pid = this.findPid(pid);
5869
6011
  const page = this.get(pid);
5870
6012
  if (page == null) return null;
6013
+ page.setInstanceOrigin(instanceOrigin);
5871
6014
  const sections = page.sections;
5872
6015
  if (sections == null) return null;
5873
6016
 
5874
- var component = sections[page.component];
6017
+ var component = sections[page.componentInstanceId];
5875
6018
  if (component == null) return null;
5876
6019
  var container = null;
5877
6020
  var article = null;
6021
+ const componentInstanceOrigin = page.componentInstanceOrigin;
6022
+ const containerInstanceOrigin = page.containerInstanceOrigin;
6023
+ const articleInstanceOrigin = page.articleInstanceOrigin;
5878
6024
  var targetProcessed = { component: null, container: null, article: null };
5879
6025
  if (page.container != null) {
5880
- container = component.containers[page.container];
6026
+ container = component.containers[page.containerInstanceId];
5881
6027
  if (container != null) {
5882
6028
  if (page.article != null) {
5883
- article = container.articles[page.article];
6029
+ article = container.articles[page.articleInstanceId];
5884
6030
  if (article != null) {
5885
6031
  targetProcessed.article = article.hide();
5886
6032
  }
@@ -5903,7 +6049,7 @@ class EstreUiPageManager {
5903
6049
  return targetProcessed[page.hostType];
5904
6050
  }
5905
6051
 
5906
- closePage(pid, closeHost = false, instanceOrigin = null) {
6052
+ closePage(pid, closeHost = false, instanceOrigin) {
5907
6053
  return postPromise(resolve => {
5908
6054
  postQueue(async _ => {
5909
6055
  if (pid.indexOf("!") > -1) pid = this.#managedPidMap[pid.replace(/^\!/, "")];
@@ -5913,37 +6059,41 @@ class EstreUiPageManager {
5913
6059
  if (pid.indexOf("$") < 0) pid = this.findPid(pid);
5914
6060
  const page = this.get(pid);
5915
6061
  if (page == null) resolve(null);
6062
+ page.setInstanceOrigin(instanceOrigin);
5916
6063
  const sections = page.sections;
5917
6064
  if (sections == null) resolve(null);
5918
6065
 
5919
- var component = sections[page.component];
6066
+ var component = sections[page.componentInstanceId];
5920
6067
  if (component == null) resolve(null);
5921
6068
  var container = null;
5922
6069
  var article = null;
6070
+ const componentInstanceOrigin = page.componentInstanceOrigin;
6071
+ const containerInstanceOrigin = page.containerInstanceOrigin;
6072
+ const articleInstanceOrigin = page.articleInstanceOrigin;
5923
6073
  var targetProcessed = { component: null, container: null, article: null };
5924
6074
  if (page.container != null) {
5925
- container = component.containers[page.container];
6075
+ container = component.containers[page.containerInstanceId];
5926
6076
  if (container != null) {
5927
6077
  if (page.article != null) {
5928
- article = container.articles[page.article];
6078
+ article = container.articles[page.articleInstanceId];
5929
6079
  if (article != null) {
5930
- targetProcessed.article = await container.closeArticle(page.article);
6080
+ targetProcessed.article = await container.closeArticle(page.article, articleInstanceOrigin);
5931
6081
  }
5932
6082
  }
5933
6083
  if (page.isContainer || closeHost || (page.isArticle && page.articleIsStatic && container.isArticlesAllyStatic)) {
5934
- targetProcessed.container = await component.closeContainer(page.container);
6084
+ targetProcessed.container = await component.closeContainer(page.container, containerInstanceOrigin);
5935
6085
  }
5936
6086
  }
5937
6087
  }
5938
6088
  if (page.isComponent || closeHost || (!page.isComponent && page.containerIsStatic && component.isContainersAllyStatic)) {
5939
6089
  if (page.isOverlay) {
5940
- targetProcessed.component = await estreUi.closeManagedOverlay(page.component);
6090
+ targetProcessed.component = await estreUi.closeManagedOverlay(page.component, componentInstanceOrigin);
5941
6091
  } else if (page.isMenu) {
5942
- targetProcessed.component = await estreUi.closeMenuArea(page.component);
6092
+ targetProcessed.component = await estreUi.closeMenuArea(page.component, componentInstanceOrigin);
5943
6093
  } else if (page.isBlinded) {
5944
- targetProcessed.component = await estreUi.closeInstantBlinded(page.component);
6094
+ targetProcessed.component = await estreUi.closeInstantBlinded(page.component, componentInstanceOrigin);
5945
6095
  } else if (component.isModal) {
5946
- targetProcessed.component = await estreUi.closeModalTab(page.component, $(component));
6096
+ targetProcessed.component = await estreUi.closeModalTab(page.component, $(component), componentInstanceOrigin);
5947
6097
  } else {
5948
6098
  targetProcessed.component = await estreUi.switchRootTab("home");
5949
6099
  }
@@ -10222,8 +10372,12 @@ class EstreMinimalScheduler {
10222
10372
  });
10223
10373
  }
10224
10374
 
10225
- buildScheduleItem(subject, time, origin, associated) {
10375
+ buildScheduleItem(subject, time, origin, associated, itemAdditionalClass) {
10226
10376
  const item = doc.ce(li, uis.scheduleItem);
10377
+ if (itemAdditionalClass != n) kindCase(itemAdditionalClass, {
10378
+ [STRING]: _ => item.className += " " + itemAdditionalClass,
10379
+ [_ARRAY]: _ => itemAdditionalClass.forEach(cls => item.classList.add(cls)),
10380
+ });
10227
10381
  const block = doc.ce(div, uis.schedule);
10228
10382
  const subjectLine = doc.ce(div, "subject_line");
10229
10383
  subjectLine.append(doc.ce(sp, "subject", subject));
@@ -14616,8 +14770,41 @@ const estreUi = {
14616
14770
  initialHistoryOffset: null,
14617
14771
  isBackwardFlow: false,
14618
14772
 
14619
- prevRootTabId: null,
14620
- prevBlindedId: null,
14773
+
14774
+ prevRootTabIds: new Set(),
14775
+ get latestRootTabId() { return [...this.prevRootTabIds].pop(); },
14776
+ get prevRootTabId() {
14777
+ const rootTabIds = this.mainSections.ways;
14778
+ let latestRootTabId = null;
14779
+ while (latestRootTabId = this.latestRootTabId) {
14780
+ this.prevRootTabIds.delete(latestRootTabId);
14781
+ if (rootTabIds.includes(latestRootTabId)) return latestRootTabId;
14782
+ }
14783
+ return null;
14784
+ },
14785
+ set prevRootTabId(id) {
14786
+ if (id == null) return;
14787
+ if (this.prevRootTabIds.has(id)) this.prevRootTabIds.delete(id);
14788
+ this.prevRootTabIds.add(id);
14789
+ },
14790
+
14791
+ prevBlindedIds: new Set(),
14792
+ get latestBlindedId() { return [...this.prevBlindedIds].pop(); },
14793
+ get prevBlindedId() {
14794
+ const blindedIds = this.blindSections.ways;
14795
+ let latestBlindedId = null;
14796
+ while (latestBlindedId = this.latestBlindedId) {
14797
+ this.prevBlindedIds.delete(latestBlindedId);
14798
+ if (blindedIds.includes(latestBlindedId)) return latestBlindedId;
14799
+ }
14800
+ return null;
14801
+ },
14802
+ set prevBlindedId(id) {
14803
+ if (id == null) return;
14804
+ if (this.prevBlindedIds.has(id)) this.prevBlindedIds.delete(id);
14805
+ this.prevBlindedIds.add(id);
14806
+ },
14807
+
14621
14808
 
14622
14809
  //getter and setter
14623
14810
  get isOpenMainMenu() { return this.$mainMenu.attr(eds.opened) == t1; },
@@ -15203,7 +15390,7 @@ const estreUi = {
15203
15390
 
15204
15391
  const currentTopHandle = this.mainCurrentOnTop;
15205
15392
  const currentTopHandleId = currentTopHandle?.id;
15206
- if (id != currentTopHandleId && currentTopHandleId != this.prevRootTabId) {
15393
+ if (id != currentTopHandleId && currentTopHandleId != this.latestRootTabId) {
15207
15394
  this.prevRootTabId = currentTopHandleId;
15208
15395
 
15209
15396
  // if (estreUi.euiState == "onReady" && currentTopHandle != null) {
@@ -15242,29 +15429,34 @@ const estreUi = {
15242
15429
  },
15243
15430
 
15244
15431
  switchRootTabPrev() {
15245
- if (this.prevRootTabId != null) {
15246
- const processed = this.switchRootTab(this.prevRootTabId);
15247
- if (processed) this.prevRootTabId = null;
15432
+ const prev = this.prevRootTabId;
15433
+ if (prev != null) {
15434
+ const processed = this.switchRootTab(prev);
15248
15435
  return processed;
15249
15436
  } else return false;
15250
15437
  },
15251
15438
 
15252
- openInstantBlinded(id, intent) {
15439
+ openInstantBlinded(id, intent, instanceOrigin) {
15253
15440
  const page = pageManager.getComponent(id);
15254
15441
  if (page == null) return null;
15255
15442
  if (page.statement == "static") return null;
15256
15443
  this.$blindArea.append(page.live);
15257
15444
  const $section = this.$blindSections.filter(eid + id);
15258
15445
  if ($section == null || $section.length < 1) return null;
15259
- const component = this.initInstantContent($section[0], intent);
15446
+ const component = this.initInstantContent($section[$section.length - 1], intent, instanceOrigin);
15260
15447
  if (component.isOnTop) component.show(false);
15261
15448
  return component;
15262
15449
  },
15263
15450
 
15264
- showInstantBlinded(id, intent) {
15265
- const $targetSection = this.$blindSections.filter(eid + id);
15451
+ showInstantBlinded(id, intent, instanceOrigin) {
15452
+ let $targetSection = this.$blindSections.filter(eid + id + (instanceOrigin?.let(it => aiv(eds.instanceOrigin, it)) ?? ""));
15266
15453
 
15267
- if ($targetSection.length < 1) return false;
15454
+ if ($targetSection.length < 1) {
15455
+ if (instanceOrigin != null) return false;
15456
+ $targetSection = this.$blindSections.filter(eid + id);
15457
+ if ($targetSection.length < 1) return false;
15458
+ $targetSection = $($targetSection[$targetSection.length - 1]);
15459
+ }
15268
15460
 
15269
15461
  const isModal = $targetSection.hasClass("modal");
15270
15462
 
@@ -15282,7 +15474,7 @@ const estreUi = {
15282
15474
 
15283
15475
  const currentTopHandle = this.blindedCurrentOnTop;
15284
15476
  const currentTopHandleId = currentTopHandle?.id;
15285
- if (id != currentTopHandleId && currentTopHandleId != this.prevBlindedId) {
15477
+ if (id != currentTopHandleId && currentTopHandleId != this.latestBlindedId) {
15286
15478
  this.prevBlindedId = currentTopHandleId;
15287
15479
 
15288
15480
  // if (estreUi.euiState == "onReady" && currentTopHandle != null) {
@@ -15291,8 +15483,13 @@ const estreUi = {
15291
15483
  }
15292
15484
  }
15293
15485
 
15294
- const targetComponent = this.blindSections[id];
15295
- if (targetComponent == null) return false;
15486
+ let targetComponent = this.blindSections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15487
+ if (targetComponent == null) {
15488
+ if (instanceOrigin != null) return false;
15489
+ const componentIds = this.blindSections.ways.filter(it => it.startsWith(id + "^"));
15490
+ if (componentIds.length < 1) return false;
15491
+ targetComponent = this.blindSections[componentIds[componentIds.length - 1]];
15492
+ }
15296
15493
  targetComponent.pushIntent(intent);
15297
15494
  if (targetComponent.isOnTop) {
15298
15495
  unhandled = true;
@@ -15304,9 +15501,14 @@ const estreUi = {
15304
15501
  return !unhandled;
15305
15502
  },
15306
15503
 
15307
- async closeInstantBlinded(id) {
15308
- const component = this.blindSections[id];
15309
- if (component == null) return null;
15504
+ async closeInstantBlinded(id, instanceOrigin, isTermination = !component.isStatic) {
15505
+ let component = this.blindSections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15506
+ if (component == null) {
15507
+ if (instanceOrigin != null) return null;
15508
+ const componentIds = this.blindSections.ways.filter(it => it.startsWith(id + "^"));
15509
+ if (componentIds.length < 1) return null;
15510
+ component = this.blindSections[componentIds[componentIds.length - 1]];
15511
+ }
15310
15512
  const $targetSection = component.$host;
15311
15513
  const isModal = $targetSection.hasClass("modal");
15312
15514
 
@@ -15318,7 +15520,6 @@ const estreUi = {
15318
15520
  } else return null;
15319
15521
  } else {
15320
15522
  if (!component.$host.hasClass("home")) {
15321
- const isTermination = !component.isStatic;
15322
15523
  const closed = await component.close(false, isTermination);
15323
15524
  setTimeout(async _ => {
15324
15525
  const $components = this.$blindSections.filter(naiv(m.id, id));
@@ -15334,22 +15535,27 @@ const estreUi = {
15334
15535
  }
15335
15536
  },
15336
15537
 
15337
- openMenuArea(id, intent) {
15538
+ openMenuArea(id, intent, instanceOrigin) {
15338
15539
  const page = pageManager.getComponent(id);
15339
15540
  if (page == null) return null;
15340
15541
  if (page.statement == "static") return null;
15341
15542
  this.$mainMenu.append(page.live);
15342
15543
  const $section = this.$menuSections.filter(eid + id);
15343
15544
  if ($section == null || $section.length < 1) return null;
15344
- const component = this.initStaticMenu($section[0], intent);
15545
+ const component = this.initStaticMenu($section[$section.length - 1], intent, instanceOrigin);
15345
15546
  if (component.isOnTop) component.show(false);
15346
15547
  return component;
15347
15548
  },
15348
15549
 
15349
- showMenuArea(id, intent) {
15350
- const $targetSection = this.$menuSections.filter(eid + id);
15550
+ showMenuArea(id, intent, instanceOrigin) {
15551
+ let $targetSection = this.$menuSections.filter(eid + id + (instanceOrigin?.let(it => aiv(eds.instanceOrigin, it)) ?? ""));
15351
15552
 
15352
- if ($targetSection.length < 1) return false;
15553
+ if ($targetSection.length < 1) {
15554
+ if (instanceOrigin != null) return false;
15555
+ $targetSection = this.$menuSections.filter(eid + id);
15556
+ if ($targetSection.length < 1) return false;
15557
+ $targetSection = $($targetSection[$targetSection.length - 1]);
15558
+ }
15353
15559
 
15354
15560
  const isModal = $targetSection.hasClass("modal");
15355
15561
 
@@ -15366,8 +15572,13 @@ const estreUi = {
15366
15572
  for (var section of $elseSections) section.pageHandle?.hide(false);
15367
15573
  }
15368
15574
 
15369
- const targetComponent = this.menuSections[id];
15370
- if (targetComponent == null) return false;
15575
+ let targetComponent = this.menuSections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15576
+ if (targetComponent == null) {
15577
+ if (instanceOrigin != null) return false;
15578
+ const componentIds = this.menuSections.ways.filter(it => it.startsWith(id + "^"));
15579
+ if (componentIds.length < 1) return false;
15580
+ targetComponent = this.menuSections[componentIds[componentIds.length - 1]];
15581
+ }
15371
15582
  targetComponent.pushIntent(intent);
15372
15583
  if (targetComponent.isOnTop) {
15373
15584
  unhandled = true;
@@ -15381,9 +15592,14 @@ const estreUi = {
15381
15592
  return !unhandled;
15382
15593
  },
15383
15594
 
15384
- async closeMenuArea(id) {
15385
- const component = this.menuSections[id];
15386
- if (component == null) return null;
15595
+ async closeMenuArea(id, instanceOrigin, isTermination) {
15596
+ let component = this.menuSections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15597
+ if (component == null) {
15598
+ if (instanceOrigin != null) return null;
15599
+ const componentIds = this.menuSections.ways.filter(it => it.startsWith(id + "^"));
15600
+ if (componentIds.length < 1) return null;
15601
+ component = this.menuSections[componentIds[componentIds.length - 1]];
15602
+ }
15387
15603
  const $targetSection = component.$host;
15388
15604
  const isModal = $targetSection.hasClass("modal");
15389
15605
 
@@ -15394,29 +15610,34 @@ const estreUi = {
15394
15610
  return closed;
15395
15611
  } else return null;
15396
15612
  } else {
15397
- const isTermination = !component.isStatic;
15613
+ isTermination ??= !component.isStatic;
15398
15614
  const closed = await component.close(false, isTermination);
15399
15615
  if (isTermination) await this.releaseInstantContent(component);
15400
15616
  return closed;
15401
15617
  }
15402
15618
  },
15403
15619
 
15404
- openHeaderBar(id, intent) {
15620
+ openHeaderBar(id, intent, instanceOrigin) {
15405
15621
  const page = pageManager.getComponent(id);
15406
15622
  if (page == null) return null;
15407
15623
  if (page.statement == "static") return null;
15408
15624
  this.$headerArea.append(page.live);
15409
15625
  const $section = this.$headerSections.filter(eid + id);
15410
15626
  if ($section == null || $section.length < 1) return null;
15411
- const component = this.initHeaderBar($section[0], intent);
15627
+ const component = this.initHeaderBar($section[$section.length - 1], intent, instanceOrigin);
15412
15628
  // if (component.isOnTop) component.show(false);
15413
15629
  return component;
15414
15630
  },
15415
15631
 
15416
- showHeaderBar(id, intent) {
15417
- const $targetSection = this.$headerSections.filter(eid + id);
15632
+ showHeaderBar(id, intent, instanceOrigin) {
15633
+ let $targetSection = this.$headerSections.filter(eid + id + (instanceOrigin?.let(it => aiv(eds.instanceOrigin, it)) ?? ""));
15418
15634
 
15419
- if ($targetSection.length < 1) return false;
15635
+ if ($targetSection.length < 1) {
15636
+ if (instanceOrigin != null) return false;
15637
+ $targetSection = this.$headerSections.filter(eid + id);
15638
+ if ($targetSection.length < 1) return false;
15639
+ $targetSection = $($targetSection[$targetSection.length - 1]);
15640
+ }
15420
15641
 
15421
15642
  const isModal = $targetSection.hasClass("modal");
15422
15643
 
@@ -15433,8 +15654,13 @@ const estreUi = {
15433
15654
  for (var section of $elseSections) section.pageHandle?.hide(false);
15434
15655
  }
15435
15656
 
15436
- const targetComponent = this.headerSections[id];
15437
- if (targetComponent == null) return false;
15657
+ let targetComponent = this.headerSections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15658
+ if (targetComponent == null) {
15659
+ if (instanceOrigin != null) return false;
15660
+ const componentIds = this.headerSections.ways.filter(it => it.startsWith(id + "^"));
15661
+ if (componentIds.length < 1) return false;
15662
+ targetComponent = this.headerSections[componentIds[componentIds.length - 1]];
15663
+ }
15438
15664
  targetComponent.pushIntent(intent);
15439
15665
  if (targetComponent.isOnTop) {
15440
15666
  unhandled = true;
@@ -15446,9 +15672,14 @@ const estreUi = {
15446
15672
  return !unhandled;
15447
15673
  },
15448
15674
 
15449
- async closeHeaderBar(id) {
15450
- const component = this.headerSections[id];
15451
- if (component == null) return null;
15675
+ async closeHeaderBar(id, instanceOrigin, isTermination) {
15676
+ let component = this.headerSections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15677
+ if (component == null) {
15678
+ if (instanceOrigin != null) return null;
15679
+ const componentIds = this.headerSections.ways.filter(it => it.startsWith(id + "^"));
15680
+ if (componentIds.length < 1) return null;
15681
+ component = this.headerSections[componentIds[componentIds.length - 1]];
15682
+ }
15452
15683
  const $targetSection = component.$host;
15453
15684
  const isModal = $targetSection.hasClass("modal");
15454
15685
 
@@ -15459,29 +15690,34 @@ const estreUi = {
15459
15690
  return closed;
15460
15691
  } else return null;
15461
15692
  } else {
15462
- const isTermination = !component.isStatic;
15693
+ isTermination ??= !component.isStatic;
15463
15694
  const closed = await component.close(false, isTermination);
15464
15695
  if (isTermination) await this.releaseInstantContent(component);
15465
15696
  return closed;
15466
15697
  }
15467
15698
  },
15468
15699
 
15469
- openManagedOverlay(id, intent) {
15700
+ openManagedOverlay(id, intent, instanceOrigin) {
15470
15701
  const page = pageManager.getComponent(id, "overlay");
15471
15702
  if (page == null) return null;
15472
15703
  if (page.statement == "static") return null;
15473
15704
  this.$overlayArea.append(page.live);
15474
15705
  const $section = this.$overlaySections.filter(eid + id);
15475
15706
  if ($section == null || $section.length < 1) return null;
15476
- const component = this.initOverlayContent($section[0], intent);
15707
+ const component = this.initOverlayContent($section[$section.length - 1], intent, instanceOrigin);
15477
15708
  // if (component.isOnTop) component.show(false);
15478
15709
  return component;
15479
15710
  },
15480
15711
 
15481
- showManagedOverlay(id, intent) {
15482
- const $targetSection = this.$overlaySections.filter(eid + id);
15712
+ showManagedOverlay(id, intent, instanceOrigin) {
15713
+ let $targetSection = this.$overlaySections.filter(eid + id + (instanceOrigin?.let(it => aiv(eds.instanceOrigin, it)) ?? ""));
15483
15714
 
15484
- if ($targetSection.length < 1) return false;
15715
+ if ($targetSection.length < 1) {
15716
+ if (instanceOrigin != null) return false;
15717
+ $targetSection = this.$overlaySections.filter(eid + id);
15718
+ if ($targetSection.length < 1) return false;
15719
+ $targetSection = $($targetSection[$targetSection.length - 1]);
15720
+ }
15485
15721
 
15486
15722
  const isModal = $targetSection.hasClass("modal");
15487
15723
 
@@ -15498,8 +15734,13 @@ const estreUi = {
15498
15734
  for (var section of $elseSections) section.pageHandle?.hide(false);
15499
15735
  }
15500
15736
 
15501
- const targetComponent = this.overlaySections[id];
15502
- if (targetComponent == null) return false;
15737
+ let targetComponent = this.overlaySections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15738
+ if (targetComponent == null) {
15739
+ if (instanceOrigin != null) return false;
15740
+ const componentIds = this.overlaySections.ways.filter(it => it.startsWith(id + "^"));
15741
+ if (componentIds.length < 1) return false;
15742
+ targetComponent = this.overlaySections[componentIds[componentIds.length - 1]];
15743
+ }
15503
15744
  targetComponent.pushIntent(intent);
15504
15745
  if (targetComponent.isOnTop) {
15505
15746
  unhandled = true;
@@ -15511,9 +15752,14 @@ const estreUi = {
15511
15752
  return !unhandled;
15512
15753
  },
15513
15754
 
15514
- async closeManagedOverlay(id) {
15515
- const component = this.overlaySections[id];
15516
- if (component == null) return null;
15755
+ async closeManagedOverlay(id, instanceOrigin, isTermination) {
15756
+ let component = this.overlaySections[id + (instanceOrigin?.let(it => "^" + it) ?? "")];
15757
+ if (component == null) {
15758
+ if (instanceOrigin != null) return null;
15759
+ const componentIds = this.overlaySections.ways.filter(it => it.startsWith(id + "^"));
15760
+ if (componentIds.length < 1) return null;
15761
+ component = this.overlaySections[componentIds[componentIds.length - 1]];
15762
+ }
15517
15763
  const $targetSection = component.$host;
15518
15764
  const isModal = $targetSection.hasClass("modal");
15519
15765
 
@@ -15524,7 +15770,7 @@ const estreUi = {
15524
15770
  return closed;
15525
15771
  } else return null;
15526
15772
  } else {
15527
- const isTermination = !component.isStatic;
15773
+ isTermination ??= !component.isStatic;
15528
15774
  const closed = await component.close(false, isTermination);
15529
15775
  if (isTermination) await this.releaseInstantContent(component);
15530
15776
  return closed;
@@ -15601,7 +15847,7 @@ const estreUi = {
15601
15847
 
15602
15848
  const delayer = (delay = term) => postPromise(resolve => setTimeout(resolve, delay));
15603
15849
  for (var i=0; i<$oss.length; i++) {
15604
- this.initOverlayContent($oss[i], null, true);
15850
+ this.initOverlayContent($oss[i], null, u, true);
15605
15851
  await delayer();
15606
15852
  }
15607
15853
 
@@ -15612,17 +15858,18 @@ const estreUi = {
15612
15858
 
15613
15859
  releaseOverlayContent(component) {
15614
15860
  if (component == null) return;
15861
+ const instanceId = component.instanceId;
15615
15862
  component.release(component.isStatic ? null : true);
15616
- if (this.blindSections[component.id] != null) delete this.overlaySections[component.id];
15863
+ if (this.blindSections[instanceId] != null) delete this.overlaySections[instanceId];
15617
15864
  const index = this.overlaySectionList.indexOf(component);
15618
15865
  if (index > -1) this.overlaySectionList.splice(index, 1);
15619
15866
  },
15620
15867
 
15621
- initOverlayContent(bound, intent = null, init = false) {
15868
+ initOverlayContent(bound, intent = null, instanceOrigin, init = false) {
15622
15869
  this.releaseOverlayContent(bound.pageHandle);
15623
- const component = new EstreOverlayComponent(bound);
15870
+ const component = new EstreOverlayComponent(bound, instanceOrigin);
15624
15871
  if (!init || component.isStatic) {
15625
- this.overlaySections[component.id] = component;
15872
+ this.overlaySections[component.instanceId] = component;
15626
15873
  this.overlaySectionList.push(component);
15627
15874
  }
15628
15875
  component.init(intent);
@@ -15635,7 +15882,7 @@ const estreUi = {
15635
15882
 
15636
15883
  const delayer = (delay = term) => postPromise(resolve => setTimeout(resolve, delay));
15637
15884
  for (var i=0; i<$bss.length; i++) {
15638
- this.initInstantContent($bss[i], null, true);
15885
+ this.initInstantContent($bss[i], null, u, true);
15639
15886
  await delayer();
15640
15887
  }
15641
15888
 
@@ -15650,17 +15897,18 @@ const estreUi = {
15650
15897
 
15651
15898
  releaseInstantContent(component) {
15652
15899
  if (component == null) return;
15900
+ const instanceId = component.instanceId;
15653
15901
  component.release(component.isStatic ? null : true);
15654
- if (this.blindSections[component.id] != null) delete this.blindSections[component.id];
15902
+ if (this.blindSections[instanceId] != null) delete this.blindSections[instanceId];
15655
15903
  const index = this.blindSectionList.indexOf(component);
15656
15904
  if (index > -1) this.blindSectionList.splice(index, 1);
15657
15905
  },
15658
15906
 
15659
- initInstantContent(bound, intent = null, init = false) {
15907
+ initInstantContent(bound, intent = null, instanceOrigin, init = false) {
15660
15908
  this.releaseInstantContent(bound.pageHandle);
15661
- const component = new EstreInstantComponent(bound);
15909
+ const component = new EstreInstantComponent(bound, instanceOrigin);
15662
15910
  if (!init || component.isStatic) {
15663
- this.blindSections[component.id] = component;
15911
+ this.blindSections[component.instanceId] = component;
15664
15912
  this.blindSectionList.push(component);
15665
15913
  }
15666
15914
  component.init(intent);
@@ -15673,7 +15921,7 @@ const estreUi = {
15673
15921
 
15674
15922
  const delayer = (delay = term) => postPromise(resolve => setTimeout(resolve, delay));
15675
15923
  for (var i=0; i<$mss.length; i++) {
15676
- this.initStaticContent($mss[i], null, true);
15924
+ this.initStaticContent($mss[i], null, u, true);
15677
15925
  await delayer();
15678
15926
  }
15679
15927
 
@@ -15690,17 +15938,18 @@ const estreUi = {
15690
15938
 
15691
15939
  releaseStaticContent(component) {
15692
15940
  if (component == null) return;
15941
+ const instanceId = component.instanceId;
15693
15942
  component.release(component.isStatic ? null : true);
15694
- if (this.mainSections[component.id] != null) delete this.mainSections[component.id];
15943
+ if (this.mainSections[instanceId] != null) delete this.mainSections[instanceId];
15695
15944
  const index = this.mainSectionList.indexOf(component);
15696
15945
  if (index > -1) this.mainSectionList.splice(index, 1);
15697
15946
  },
15698
15947
 
15699
- initStaticContent(bound, intent = null, init = false) {
15948
+ initStaticContent(bound, intent = null, instanceOrigin, init = false) {
15700
15949
  this.releaseStaticContent(bound.pageHandle);
15701
- const component = new EstreComponent(bound);
15950
+ const component = new EstreComponent(bound, instanceOrigin);
15702
15951
  if (!init || component.isStatic) {
15703
- this.mainSections[component.id] = component;
15952
+ this.mainSections[component.instanceId] = component;
15704
15953
  this.mainSectionList.push(component);
15705
15954
  }
15706
15955
  component.init(intent);
@@ -15715,7 +15964,7 @@ const estreUi = {
15715
15964
 
15716
15965
  const delayer = (delay = term) => postPromise(resolve => setTimeout(resolve, delay));
15717
15966
  for (var i=0; i<$mss.length; i++) {
15718
- this.initStaticMenu($mss[i], null, true);
15967
+ this.initStaticMenu($mss[i], null, u, true);
15719
15968
  await delayer();
15720
15969
  }
15721
15970
 
@@ -15730,17 +15979,18 @@ const estreUi = {
15730
15979
 
15731
15980
  releaseStaticMenu(component) {
15732
15981
  if (component == null) return;
15982
+ const instanceId = component.instanceId;
15733
15983
  component.release(component.isStatic ? null : true);
15734
- if (this.menuSections[component.id] != null) delete this.menuSections[component.id];
15984
+ if (this.menuSections[instanceId] != null) delete this.menuSections[instanceId];
15735
15985
  const index = this.menuSectionList.indexOf(component);
15736
15986
  if (index > -1) this.menuSectionList.splice(index, 1);
15737
15987
  },
15738
15988
 
15739
- initStaticMenu(bound, intent = null, init = false) {
15989
+ initStaticMenu(bound, intent = null, instanceOrigin, init = false) {
15740
15990
  this.releaseStaticMenu(bound.pageHandle);
15741
- const component = new EstreMenuComponent(bound);
15991
+ const component = new EstreMenuComponent(bound, instanceOrigin);
15742
15992
  if (!init || component.isStatic) {
15743
- this.menuSections[component.id] = component;
15993
+ this.menuSections[component.instanceId] = component;
15744
15994
  this.menuSectionList.push(component);
15745
15995
  }
15746
15996
  component.init(intent);
@@ -15753,7 +16003,7 @@ const estreUi = {
15753
16003
 
15754
16004
  const delayer = (delay = term) => postPromise(resolve => setTimeout(resolve, delay));
15755
16005
  for (var i=0; i<$hss.length; i++) {
15756
- this.initHeaderBar($hss[i], null, true);
16006
+ this.initHeaderBar($hss[i], null, u, true);
15757
16007
  await delayer();
15758
16008
  }
15759
16009
 
@@ -15769,17 +16019,18 @@ const estreUi = {
15769
16019
 
15770
16020
  releaseHeaderBar(component) {
15771
16021
  if (component == null) return;
16022
+ const instanceId = component.instanceId;
15772
16023
  component.release(component.isStatic ? null : true);
15773
- if (this.headerSections[component.id] != null) delete this.headerSections[component.id];
16024
+ if (this.headerSections[instanceId] != null) delete this.headerSections[instanceId];
15774
16025
  const index = this.headerSectionList.indexOf(component);
15775
16026
  if (index > -1) this.headerSectionList.splice(index, 1);
15776
16027
  },
15777
16028
 
15778
- initHeaderBar(bound, intent = null, init = false) {
16029
+ initHeaderBar(bound, intent = null, instanceOrigin, init = false) {
15779
16030
  this.releaseHeaderBar(bound.pageHandle);
15780
- const component = new EstreHeaderComponent(bound);
16031
+ const component = new EstreHeaderComponent(bound, instanceOrigin);
15781
16032
  if (!init || component.isStatic) {
15782
- this.headerSections[component.id] = component;
16033
+ this.headerSections[component.instanceId] = component;
15783
16034
  this.headerSectionList.push(component);
15784
16035
  }
15785
16036
  component.init(intent);
@@ -15921,9 +16172,9 @@ const estreUi = {
15921
16172
  const currentOnTop = this.blindedCurrentOnTop;
15922
16173
  let processed = false;
15923
16174
  if (currentOnTop != null) processed = await currentOnTop.onBack();
15924
- if (!processed && this.prevBlindedId != null) {
15925
- processed = await this.showInstantBlinded(this.prevBlindedId);
15926
- if (processed) this.prevBlindedId = null;
16175
+ const prevBlindedId = this.prevBlindedId;
16176
+ if (!processed && prevBlindedId != null) {
16177
+ processed = await this.showInstantBlinded(prevBlindedId);
15927
16178
  }
15928
16179
  return processed;
15929
16180
  },