@yuneta/gobj-ui 7.26.50 → 7.26.52

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.
@@ -1290,6 +1290,8 @@ var PRIVATE_DATA$22 = {
1290
1290
  expected_pop_ids: [],
1291
1291
  given_up: null,
1292
1292
  own_entries: [],
1293
+ traverse_from: -1,
1294
+ entry_change_handler: null,
1293
1295
  popstate_handler: null,
1294
1296
  avatar_provider: null,
1295
1297
  avatar_nodes: [],
@@ -1365,7 +1367,13 @@ function mt_start$21(gobj) {
1365
1367
  let p = gobj.priv;
1366
1368
  if (!p) return;
1367
1369
  note_late_landing(gobj, ev);
1370
+ let from = p.traverse_from;
1371
+ p.traverse_from = -1;
1368
1372
  let hash_moved = window.location.hash !== p.last_hash;
1373
+ if (p.expected_pops === 0 && from >= 0 && retire_dead_entries(gobj, from, hash_moved)) {
1374
+ if (!p.skip_hash) p.last_hash = window.location.hash;
1375
+ return;
1376
+ }
1369
1377
  if (p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) {
1370
1378
  drop_expected_pops(gobj);
1371
1379
  on_traversal(ev);
@@ -1416,6 +1424,15 @@ function mt_start$21(gobj) {
1416
1424
  }
1417
1425
  };
1418
1426
  window.addEventListener("popstate", priv.popstate_handler);
1427
+ let nav = window.navigation;
1428
+ if (nav && typeof nav.addEventListener === "function") {
1429
+ priv.entry_change_handler = (ev) => {
1430
+ let p = gobj.priv;
1431
+ if (!p) return;
1432
+ p.traverse_from = ev && ev.navigationType === "traverse" && ev.from && typeof ev.from.index === "number" ? ev.from.index : -1;
1433
+ };
1434
+ nav.addEventListener("currententrychange", priv.entry_change_handler);
1435
+ }
1419
1436
  keep_dead_entries_across_reload();
1420
1437
  adopt_orphan_back(gobj);
1421
1438
  }
@@ -1458,6 +1475,12 @@ function mt_stop$20(gobj) {
1458
1475
  window.removeEventListener("popstate", priv.popstate_handler);
1459
1476
  priv.popstate_handler = null;
1460
1477
  }
1478
+ if (priv.entry_change_handler) {
1479
+ let nav = window.navigation;
1480
+ if (nav && typeof nav.removeEventListener === "function") nav.removeEventListener("currententrychange", priv.entry_change_handler);
1481
+ priv.entry_change_handler = null;
1482
+ }
1483
+ priv.traverse_from = -1;
1461
1484
  for (let entry of priv.pending_markers) {
1462
1485
  entry.marker_pending = false;
1463
1486
  entry.no_marker = true;
@@ -2855,7 +2878,9 @@ function retire_overlays(gobj) {
2855
2878
  *
2856
2879
  * A page with no next shell keeps them: with no router on the
2857
2880
  * page, a Back over the app's own entries changes nothing on
2858
- * screen anyway, and the next shell retires them all the same.
2881
+ * screen anyway, and the next shell retires them all the same --
2882
+ * at its start, or when a traversal of the reader's lands on them
2883
+ * if the reader moved meanwhile.
2859
2884
  ************************************************************/
2860
2885
  function hand_over_history(gobj) {
2861
2886
  let priv = gobj.priv;
@@ -2975,6 +3000,7 @@ function note_own_entry(gobj) {
2975
3000
  let priv = gobj.priv;
2976
3001
  let key = current_entry_key();
2977
3002
  if (!key || priv.own_entries.includes(key)) return;
3003
+ __dead_entries__.delete(key);
2978
3004
  priv.own_entries.push(key);
2979
3005
  if (priv.own_entries.length > OWN_ENTRIES_PRUNE_AT) {
2980
3006
  let alive = new Set(window.navigation.entries().map((e) => e.key));
@@ -2985,42 +3011,70 @@ function note_own_entry(gobj) {
2985
3011
  * Take off, with ONE history.go(-n), the dead entries a
2986
3012
  * stopped shell left under the current one (hand_over_history).
2987
3013
  * The walk stops at the first entry that is not dead, so it
2988
- * never goes past an entry of the reader's. The traversal is
2989
- * this shell's own (expected_pops): its overlays' markers and
2990
- * the routes it pushes wait for the landing, and a position
2991
- * the URL holds is put back on the entry it lands on, as for
2992
- * any back() of ours (restore_hash). Returns true when it
2993
- * went.
2994
- ************************************************************/
2995
- function retire_dead_entries(gobj) {
2996
- let priv = gobj.priv;
3014
+ * never goes past an entry of the reader's, and at the first
3015
+ * entry of the current document: a navigation to another page
3016
+ * with replace keeps the entry's key, so a later document can
3017
+ * sit on the key of a dead marker, over the entries of the one
3018
+ * before it (up to gobj-ui 7.26.50 the walk went into them and
3019
+ * that document was loaded again). After a reload every entry
3020
+ * is the new document's, and its dead ones go.
3021
+ *
3022
+ * With `from` (the index a traversal of the reader's came
3023
+ * from), it goes on over the dead entries that traversal landed
3024
+ * on, the way it was going: down to the first live one under
3025
+ * them, or up to the first live one over them -- there is none
3026
+ * when they are the newest, and nothing moves. Dead entries
3027
+ * under an entry of the reader's are taken off that way: the
3028
+ * start of a shell never goes past one.
3029
+ *
3030
+ * The traversal is this shell's own (expected_pops): its
3031
+ * overlays' markers and the routes it pushes wait for the
3032
+ * landing. At the start, a position the URL holds is put back
3033
+ * on the entry it lands on, as for any back() of ours
3034
+ * (restore_hash). The keys stay dead while their entries
3035
+ * exist: a later Back or Forward onto them goes over them too.
3036
+ * Returns true when it went.
3037
+ ************************************************************/
3038
+ function retire_dead_entries(gobj, from, hash_moved) {
3039
+ let priv = gobj.priv;
3040
+ let reader = typeof from === "number";
2997
3041
  if (__dead_entries__.size === 0 || priv.expected_pops > 0 || !priv.popstate_handler || !current_entry_key()) return false;
2998
3042
  let nav = window.navigation;
2999
3043
  let entries = nav.entries();
3000
3044
  let index = nav.currentEntry.index;
3001
3045
  let alive = new Set(entries.map((e) => e.key));
3002
3046
  for (let key of __dead_entries__) if (!alive.has(key)) __dead_entries__.delete(key);
3047
+ if (reader && (from === index || !__dead_entries__.has(entries[index].key))) return false;
3048
+ let step = reader && from < index ? 1 : -1;
3003
3049
  let landing = index;
3004
- while (landing > 0 && __dead_entries__.has(entries[landing].key)) landing--;
3005
- let steps = index - landing;
3050
+ while (__dead_entries__.has(entries[landing].key)) {
3051
+ let next = landing + step;
3052
+ if (next < 0 || next >= entries.length || !entries[next].sameDocument) break;
3053
+ landing = next;
3054
+ }
3055
+ if (step > 0 && __dead_entries__.has(entries[landing].key)) return false;
3056
+ let steps = landing - index;
3006
3057
  if (steps === 0) return false;
3007
3058
  let landing_hash = "";
3008
3059
  try {
3009
3060
  landing_hash = new URL(entries[landing].url).hash;
3010
3061
  } catch (e) {
3011
- log_warning(`C_YUI_SHELL: the entry under the dead ones has no url: ${e}`);
3062
+ log_warning(`C_YUI_SHELL: the entry past the dead ones has no url: ${e}`);
3012
3063
  return false;
3013
3064
  }
3014
- for (let i = landing + 1; i <= index; i++) __dead_entries__.delete(entries[i].key);
3015
3065
  priv.expected_pops++;
3016
3066
  priv.expected_pop_hash = landing_hash;
3017
- priv.restore_hash = window.location.hash !== landing_hash ? window.location.hash : "";
3067
+ if (reader) {
3068
+ priv.restore_hash = "";
3069
+ if (hash_moved && window.location.hash !== landing_hash) priv.skip_hash = window.location.hash;
3070
+ } else priv.restore_hash = window.location.hash !== landing_hash ? window.location.hash : "";
3018
3071
  try {
3019
- window.history.go(-steps);
3072
+ window.history.go(steps);
3020
3073
  } catch (e) {
3021
3074
  priv.expected_pops--;
3022
3075
  priv.restore_hash = "";
3023
- log_warning(`C_YUI_SHELL: retiring ${steps} dead history entries failed: ${e}`);
3076
+ priv.skip_hash = "";
3077
+ log_warning(`C_YUI_SHELL: going over ${Math.abs(steps)} dead history entries failed: ${e}`);
3024
3078
  return false;
3025
3079
  }
3026
3080
  clear_deferred_timer(gobj);
@@ -3128,6 +3182,8 @@ function push_overlay_marker(gobj, entry) {
3128
3182
  if (below === null || plain) try {
3129
3183
  window.history.replaceState(Object.assign({}, below, { __yui_below__: entry.id }), "");
3130
3184
  stamped = true;
3185
+ let key = current_entry_key();
3186
+ if (key) __dead_entries__.delete(key);
3131
3187
  } catch (e) {
3132
3188
  log_warning(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
3133
3189
  }
@@ -6796,7 +6852,7 @@ function ac_shell_changed(gobj, event, kw, src) {
6796
6852
  * language the window was opened in (a reader took the
6797
6853
  * aria-labelledby, which changed; the tooltip did not).
6798
6854
  ************************************************************/
6799
- function ac_language_changed$11(gobj, event, kw, src) {
6855
+ function ac_language_changed$12(gobj, event, kw, src) {
6800
6856
  let priv = gobj.priv;
6801
6857
  for (let entry of priv.windows) {
6802
6858
  if (!entry.title_prefix || !entry.$chip) continue;
@@ -6867,7 +6923,7 @@ function create_gclass$20(gclass_name) {
6867
6923
  ],
6868
6924
  [
6869
6925
  "EV_LANGUAGE_CHANGED",
6870
- ac_language_changed$11,
6926
+ ac_language_changed$12,
6871
6927
  null
6872
6928
  ]
6873
6929
  ]]], gmt$20, 0, attrs_table$20, PRIVATE_DATA$20, 0, 0, 0, 0);
@@ -9620,220 +9676,842 @@ function yui_icons_list() {
9620
9676
  });
9621
9677
  return list;
9622
9678
  }
9623
- /************************************************************
9624
- * JSON type discriminator (viewer vocabulary)
9625
- ************************************************************/
9626
- function json_type(value) {
9627
- if (value === null) return "null";
9628
- if (Array.isArray(value)) return "array";
9629
- switch (typeof value) {
9630
- case "string": return "string";
9631
- case "number": return "number";
9632
- case "boolean": return "boolean";
9633
- case "object": return "object";
9634
- default: return "unknown";
9635
- }
9636
- }
9637
- /************************************************************
9638
- * Detect a kw_collapse() sentinel.
9679
+ //#endregion
9680
+ //#region src/yui_time.js
9681
+ /***********************************************************************
9682
+ * yui_time.js
9639
9683
  *
9640
- * The kernel replaces an over-limit dict with:
9641
- * { "__collapsed__": { "path": ..., "size": N } }
9642
- * and an over-limit array with:
9643
- * [ { "__collapsed__": { "path": ..., "size": N } } ]
9684
+ * Time, without a DOM: epochs, and the algebra of PERIODS.
9644
9685
  *
9645
- * Returns { size, path, is_array } or null.
9646
- ************************************************************/
9647
- function is_collapsed(value) {
9648
- if (value && typeof value === "object" && !Array.isArray(value)) {
9649
- let keys = Object.keys(value);
9650
- if (keys.length === 1 && keys[0] === "__collapsed__") {
9651
- let c = value.__collapsed__ || {};
9652
- return {
9653
- size: c.size,
9654
- path: c.path,
9655
- is_array: false
9656
- };
9657
- }
9658
- return null;
9686
+ * Two things live here, and they are the two halves of every date
9687
+ * UI the projects keep rewriting:
9688
+ *
9689
+ * 1) EPOCH <-> the local wall clock. A timestamp travels in the
9690
+ * producer's own unit — seconds, or milliseconds when a topic
9691
+ * says so — and every conversion crosses that `ms` flag. Getting
9692
+ * it wrong puts the same instant on two different clocks in one
9693
+ * screen (it did: a picker asking "from 18:55" local returned
9694
+ * rows a table labelled 16:55).
9695
+ *
9696
+ * 2) The PERIOD. A period is not an enum of five names: it is a
9697
+ * BUCKET, and a bucket is `count` of a `unit`:
9698
+ *
9699
+ * {id: "day", unit: "day", count: 1}
9700
+ * {id: "week", unit: "week", count: 1} ISO, Mon-first
9701
+ * {id: "bimester", unit: "month", count: 2}
9702
+ * {id: "quarter", unit: "month", count: 3}
9703
+ * {id: "semester", unit: "month", count: 6}
9704
+ * {id: "decade", unit: "year", count: 10}
9705
+ * {id: "15min", unit: "minute", count: 15}
9706
+ *
9707
+ * Given that pair, ONE implementation answers every question a
9708
+ * date navigator asks — where does the bucket holding this
9709
+ * instant start and end, what is the previous/next one, what do
9710
+ * I call it — so an app that wants quarters declares a quarter
9711
+ * instead of asking for a new component.
9712
+ *
9713
+ * Buckets are ALIGNED, never "count back from now": months align to
9714
+ * the year (which is why 2, 3, 4, 6 and 12 fall on clean calendar
9715
+ * boundaries), weeks to Monday, hours to local midnight. "Last 7
9716
+ * days" is a different animal — a rolling window — and it is not a
9717
+ * period: see `rolling_bounds()`.
9718
+ *
9719
+ * Everything here is LOCAL time (the user reads a local clock) and
9720
+ * DST-safe: it never adds 86400000 ms to cross a day, it builds the
9721
+ * next date from calendar fields and lets the platform do it.
9722
+ *
9723
+ * Copyright (c) 2026, ArtGins.
9724
+ * All Rights Reserved.
9725
+ ***********************************************************************/
9726
+ /***************************************************************
9727
+ * Constants
9728
+ ***************************************************************/
9729
+ var MS_DAY = 864e5;
9730
+ var PERIOD_UNITS = [
9731
+ "minute",
9732
+ "hour",
9733
+ "day",
9734
+ "week",
9735
+ "month",
9736
+ "year"
9737
+ ];
9738
+ var YUI_PERIODS = {
9739
+ minute: {
9740
+ id: "minute",
9741
+ unit: "minute",
9742
+ count: 1
9743
+ },
9744
+ "5min": {
9745
+ id: "5min",
9746
+ unit: "minute",
9747
+ count: 5
9748
+ },
9749
+ "15min": {
9750
+ id: "15min",
9751
+ unit: "minute",
9752
+ count: 15
9753
+ },
9754
+ hour: {
9755
+ id: "hour",
9756
+ unit: "hour",
9757
+ count: 1
9758
+ },
9759
+ day: {
9760
+ id: "day",
9761
+ unit: "day",
9762
+ count: 1
9763
+ },
9764
+ week: {
9765
+ id: "week",
9766
+ unit: "week",
9767
+ count: 1
9768
+ },
9769
+ fortnight: {
9770
+ id: "fortnight",
9771
+ unit: "week",
9772
+ count: 2
9773
+ },
9774
+ month: {
9775
+ id: "month",
9776
+ unit: "month",
9777
+ count: 1
9778
+ },
9779
+ bimester: {
9780
+ id: "bimester",
9781
+ unit: "month",
9782
+ count: 2
9783
+ },
9784
+ quarter: {
9785
+ id: "quarter",
9786
+ unit: "month",
9787
+ count: 3
9788
+ },
9789
+ semester: {
9790
+ id: "semester",
9791
+ unit: "month",
9792
+ count: 6
9793
+ },
9794
+ year: {
9795
+ id: "year",
9796
+ unit: "year",
9797
+ count: 1
9798
+ },
9799
+ decade: {
9800
+ id: "decade",
9801
+ unit: "year",
9802
+ count: 10
9659
9803
  }
9660
- if (Array.isArray(value) && value.length === 1) {
9661
- let e = value[0];
9662
- if (e && typeof e === "object" && !Array.isArray(e) && Object.keys(e).length === 1 && e.__collapsed__) {
9663
- let c = e.__collapsed__ || {};
9664
- return {
9665
- size: c.size,
9666
- path: c.path,
9667
- is_array: true
9668
- };
9669
- }
9804
+ };
9805
+ var YUI_PERIODS_DEFAULT = [
9806
+ "hour",
9807
+ "day",
9808
+ "week",
9809
+ "month",
9810
+ "year"
9811
+ ];
9812
+ var YUI_ROLLING = {
9813
+ "1h": {
9814
+ id: "1h",
9815
+ secs: 3600,
9816
+ label: "last hour"
9817
+ },
9818
+ "6h": {
9819
+ id: "6h",
9820
+ secs: 21600,
9821
+ label: "last 6h"
9822
+ },
9823
+ "24h": {
9824
+ id: "24h",
9825
+ secs: 86400,
9826
+ label: "last 24h"
9827
+ },
9828
+ "7d": {
9829
+ id: "7d",
9830
+ secs: 604800,
9831
+ label: "last 7 days"
9832
+ },
9833
+ "30d": {
9834
+ id: "30d",
9835
+ secs: 2592e3,
9836
+ label: "last 30 days"
9670
9837
  }
9671
- return null;
9672
- }
9673
- /************************************************************
9674
- * Join / split absolute path segments (kernel convention)
9675
- ************************************************************/
9676
- function seg_join(segments) {
9677
- return segments.map(function(s) {
9678
- return String(s);
9679
- }).join("`");
9838
+ };
9839
+ /***************************
9840
+ * Locale / i18n
9841
+ ***************************/
9842
+ /***************************************************************
9843
+ * The locale to format with.
9844
+ *
9845
+ * NEVER at module top level, and never `navigator.language` raw:
9846
+ * Firefox can report the literal STRING "undefined", and every Intl
9847
+ * constructor throws RangeError on it — a module that built its
9848
+ * formatter on import took the whole bundle down with it (that is why
9849
+ * gui_agent refuses to import the gobj-ui barrel).
9850
+ ***************************************************************/
9851
+ function safe_locale(locale) {
9852
+ if (typeof locale === "string" && locale && locale !== "undefined") return locale;
9853
+ let nav = typeof navigator !== "undefined" ? navigator.language : null;
9854
+ if (typeof nav === "string" && nav && nav !== "undefined") return nav;
9855
+ return "en";
9680
9856
  }
9681
- function seg_split(path) {
9682
- if (path === "" || path === null || path === void 0) return [];
9683
- return path.split("`");
9857
+ /***************************************************************
9858
+ * Translate through the APP's translator when it gave us one, and
9859
+ * degrade to the key itself otherwise — interpolating `{{x}}` by hand,
9860
+ * so a label never renders raw mustaches at a caller that has no i18n.
9861
+ ***************************************************************/
9862
+ function tr(t, key, params) {
9863
+ if (typeof t === "function") return t(key, params);
9864
+ let s = key;
9865
+ for (let k in params || {}) s = s.replaceAll(`{{${k}}}`, String(params[k]));
9866
+ return s;
9684
9867
  }
9685
- /************************************************************
9686
- * Walk a JSON tree by absolute segments; undefined if the
9687
- * path does not resolve.
9688
- ************************************************************/
9689
- function get_by_segments(root, segments) {
9690
- let v = root;
9691
- for (let seg of segments) {
9692
- if (v === null || v === void 0) return;
9693
- if (Array.isArray(v)) v = v[Number(seg)];
9694
- else if (typeof v === "object") v = v[seg];
9695
- else return;
9868
+ /***************************************************************
9869
+ * Intl formatters, built PER CALL (see safe_locale). They are cheap
9870
+ * next to a repaint, and caching them would need a locale-change hook
9871
+ * the library has no business owning.
9872
+ ***************************************************************/
9873
+ function fmt_intl(date, locale, opts) {
9874
+ try {
9875
+ return new Intl.DateTimeFormat(safe_locale(locale), opts).format(date);
9876
+ } catch (e) {
9877
+ return date.toDateString();
9696
9878
  }
9697
- return v;
9698
9879
  }
9699
- /************************************************************
9700
- * Set a value at absolute segments (mutates root).
9701
- *
9702
- * segments == [] means "replace the whole root" — the caller
9703
- * must use the RETURNED value in that case (a primitive/array
9704
- * root cannot be mutated in place).
9705
- ************************************************************/
9706
- function set_by_segments(root, segments, new_value) {
9707
- if (segments.length === 0) return new_value;
9708
- let parent = get_by_segments(root, segments.slice(0, -1));
9709
- if (parent === null || parent === void 0 || typeof parent !== "object") return root;
9710
- let last = segments[segments.length - 1];
9711
- if (Array.isArray(parent)) parent[Number(last)] = new_value;
9712
- else parent[last] = new_value;
9713
- return root;
9880
+ /***************************
9881
+ * Epoch <-> clock
9882
+ ***************************/
9883
+ /***************************************************************
9884
+ * Epoch in the producer's unit -> milliseconds, and back.
9885
+ * `ms` true means the value already IS milliseconds.
9886
+ ***************************************************************/
9887
+ function epoch_to_ms(value, ms) {
9888
+ if (!value) return 0;
9889
+ return ms ? value : value * 1e3;
9714
9890
  }
9715
- /************************************************************
9716
- * Does `value` (or any loaded descendant / its own key)
9717
- * contain the lower-cased search term?
9718
- *
9719
- * Collapsed (not-yet-loaded) subtrees can't be searched, so
9720
- * they never match on content — only their key can match,
9721
- * which the renderer checks separately.
9722
- ************************************************************/
9723
- function subtree_matches(value, term) {
9724
- if (!term) return true;
9725
- if (is_collapsed(value)) return false;
9726
- let type = json_type(value);
9727
- if (type === "object") {
9728
- for (let [k, v] of Object.entries(value)) {
9729
- if (String(k).toLowerCase().includes(term)) return true;
9730
- if (subtree_matches(v, term)) return true;
9731
- }
9732
- return false;
9733
- }
9734
- if (type === "array") {
9735
- for (let v of value) if (subtree_matches(v, term)) return true;
9736
- return false;
9891
+ function ms_to_epoch(value_ms, ms) {
9892
+ if (!value_ms) return 0;
9893
+ return ms ? value_ms : Math.floor(value_ms / 1e3);
9894
+ }
9895
+ /***************************************************************
9896
+ * The LOCAL wall-clock string an `<input type="datetime-local">` takes
9897
+ * ("YYYY-MM-DDTHH:MM:SS", which needs step=1 to keep the seconds), and
9898
+ * the parse back. Empty / unparseable -> 0, which is exactly how a
9899
+ * match condition reads an absent bound.
9900
+ ***************************************************************/
9901
+ function epoch_to_local_input(value, ms) {
9902
+ if (!value) return "";
9903
+ let d = new Date(epoch_to_ms(value, ms));
9904
+ let pad = (n) => String(n).padStart(2, "0");
9905
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
9906
+ }
9907
+ function local_input_to_epoch(v, ms) {
9908
+ if (!v) return 0;
9909
+ let parsed = Date.parse(v);
9910
+ if (Number.isNaN(parsed)) return 0;
9911
+ return ms_to_epoch(parsed, ms);
9912
+ }
9913
+ /***************************************************************
9914
+ * A timestamp for a table cell: the local wall clock, space-separated,
9915
+ * keeping the milliseconds when the producer bothered to send them (a
9916
+ * topic that sets sf_t_ms usually appends several records inside the
9917
+ * same second, and a column that hides that shows a column of ties).
9918
+ ***************************************************************/
9919
+ function fmt_epoch(value, ms) {
9920
+ if (!value) return "";
9921
+ try {
9922
+ let s = epoch_to_local_input(value, ms).replace("T", " ");
9923
+ if (ms) s += `.${String(value % 1e3).padStart(3, "0")}`;
9924
+ return s;
9925
+ } catch (e) {
9926
+ return String(value);
9737
9927
  }
9738
- return String(value).toLowerCase().includes(term);
9739
9928
  }
9740
- /************************************************************
9741
- * Fields whose numeric value is an epoch timestamp.
9929
+ var DATE_TIME_OPTIONS = {
9930
+ day: "numeric",
9931
+ month: "short",
9932
+ year: "numeric",
9933
+ hour: "2-digit",
9934
+ minute: "2-digit",
9935
+ second: "2-digit",
9936
+ hourCycle: "h23"
9937
+ };
9938
+ /***************************************************************
9939
+ * A moment as a VIEW shows it as text: the day, the month and the
9940
+ * year, then the clock of 24 hours with its seconds, in the APP's
9941
+ * language -- `locale` is the language t() answers in (the views
9942
+ * pass `i18next.language`), never the browser's:
9742
9943
  *
9743
- * THE ONE LIST. C_YUI_FORM's jsoneditor takes its
9744
- * `timestampTag` from here: it used to carry its own copy,
9745
- * and a copy is how the two stopped agreeing.
9944
+ * fmt_date_time(d, "es") -> "14 oct 2026, 15:05:09"
9945
+ * fmt_date_time(d, "en") -> "Oct 14, 2026, 15:05:09"
9746
9946
  *
9747
- * TWO SPELLINGS, AND LAS DOS SON DEL BACKEND. timeranger2
9748
- * writes `from_t`/`from_tm` in the match_cond of a query and
9749
- * `fr_t`/`fr_tm` in the metadata of a topic and of a file --
9750
- * which is what a Raw JSON of a treedb actually shows. With
9751
- * only the long pair listed, `to_t` got its date and the
9752
- * `fr_t` right above it did not, which reads as a broken
9753
- * annotator rather than a missing name.
9754
- ************************************************************/
9755
- var TIME_FIELDS = [
9756
- "__t__",
9757
- "__tm__",
9758
- "t",
9759
- "tm",
9760
- "time",
9761
- "from_t",
9762
- "to_t",
9763
- "from_tm",
9764
- "to_tm",
9765
- "fr_t",
9766
- "fr_tm",
9767
- "t_input",
9768
- "t_output"
9769
- ];
9770
- function is_time_field(field) {
9771
- return TIME_FIELDS.indexOf(field) >= 0;
9772
- }
9773
- /************************************************************
9774
- * Format an epoch value as a local wall-clock string.
9775
- * Accepts seconds or milliseconds; returns null when the
9776
- * value is not a usable positive timestamp (0 == "unset").
9777
- ************************************************************/
9778
- function format_epoch(value) {
9779
- if (typeof value !== "number" || !isFinite(value) || value <= 0) return null;
9780
- let ms = Math.abs(value) < 0xe8d4a51000 ? value * 1e3 : value;
9781
- let d = new Date(ms);
9782
- if (isNaN(d.getTime())) return null;
9783
- return d.toLocaleString();
9784
- }
9785
- /************************************************************
9786
- * The text view's payload: the document as text, indented
9787
- * four characters, cut at `max_chars`.
9947
+ * "" for anything that is not a valid Date. A locale Intl refuses
9948
+ * gives the language-free "2026-10-14 15:05:09".
9788
9949
  *
9789
- * Returns {text, capped}. `capped` is what the caller
9790
- * announces under the dump — a cut that is not announced
9791
- * reads as a document that ends there.
9792
- ************************************************************/
9793
- function json_text_dump(root, max_chars) {
9794
- let text;
9950
+ * The time cells of C_YUI_FORM and C_YUI_TREEDB_TOPIC_WITH_FORM and
9951
+ * the reading C_YUI_JSON writes beside a time field all come from
9952
+ * here, so the same moment reads the same in the three.
9953
+ ***************************************************************/
9954
+ function fmt_date_time(date, locale) {
9955
+ if (!(date instanceof Date) || isNaN(date.getTime())) return "";
9795
9956
  try {
9796
- text = JSON.stringify(root, null, 4);
9957
+ return new Intl.DateTimeFormat(safe_locale(locale), DATE_TIME_OPTIONS).format(date);
9797
9958
  } catch (e) {
9798
- return {
9799
- text: "",
9800
- capped: false,
9801
- error: String(e)
9802
- };
9959
+ return epoch_to_local_input(date.getTime(), true).replace("T", " ");
9803
9960
  }
9804
- if (text === void 0) return {
9805
- text: "",
9806
- capped: false,
9807
- error: "not representable as JSON"
9808
- };
9809
- if (typeof max_chars === "number" && max_chars > 0 && text.length > max_chars) return {
9810
- text: text.slice(0, max_chars),
9811
- capped: true
9961
+ }
9962
+ /***************************
9963
+ * Calendar atoms
9964
+ ***************************/
9965
+ /***************************************************************
9966
+ * The day number of a date, counting local calendar days from
9967
+ * 1970-01-01. Built from the FIELDS (Date.UTC of y/m/d), never from
9968
+ * the timestamp: a DST day is 23 or 25 hours long, so dividing a local
9969
+ * epoch by 86400000 drifts a day twice a year.
9970
+ ***************************************************************/
9971
+ function day_number(d) {
9972
+ return Math.floor(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_DAY);
9973
+ }
9974
+ function date_from_day_number(n) {
9975
+ let d = /* @__PURE__ */ new Date(n * MS_DAY);
9976
+ return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
9977
+ }
9978
+ /***************************************************************
9979
+ * The Monday of the week a date falls in (ISO: the week starts on
9980
+ * Monday, and Sunday closes it).
9981
+ ***************************************************************/
9982
+ function start_of_iso_week(d) {
9983
+ let day = d.getDay();
9984
+ let back = day === 0 ? 6 : day - 1;
9985
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate() - back);
9986
+ }
9987
+ /***************************************************************
9988
+ * The ISO week a date belongs to: {week, year}. The YEAR is the ISO
9989
+ * week-year, not the calendar year — 2026-12-31 lives in week 1 of
9990
+ * 2027, and a label that said "week 1 2026" would name a week six
9991
+ * months away.
9992
+ ***************************************************************/
9993
+ function iso_week(d) {
9994
+ let monday = start_of_iso_week(d);
9995
+ let thursday = new Date(monday.getFullYear(), monday.getMonth(), monday.getDate() + 3);
9996
+ let jan1 = new Date(thursday.getFullYear(), 0, 1);
9997
+ return {
9998
+ week: Math.floor((day_number(thursday) - day_number(jan1)) / 7) + 1,
9999
+ year: thursday.getFullYear()
9812
10000
  };
10001
+ }
10002
+ /***************************************************************
10003
+ * The index of the ISO week a date falls in, counting weeks from the
10004
+ * Monday of the epoch week. It is what aligns a MULTI-week bucket (a
10005
+ * fortnight) to a Monday instead of to whatever day 1970-01-01 was.
10006
+ ***************************************************************/
10007
+ function week_index(d) {
10008
+ return Math.floor((day_number(start_of_iso_week(d)) + 3) / 7);
10009
+ }
10010
+ /***************************
10011
+ * Period algebra
10012
+ ***************************/
10013
+ /***************************************************************
10014
+ * Normalize whatever a caller hands us into a spec: an id of the
10015
+ * catalog, or a spec of its own. Returns null for anything that is not
10016
+ * a bucket (a "span" / "custom" mode of a navigator has no algebra).
10017
+ ***************************************************************/
10018
+ function period_spec(period) {
10019
+ if (!period) return null;
10020
+ let spec = typeof period === "string" ? YUI_PERIODS[period] : period;
10021
+ if (!spec || !spec.unit) return null;
10022
+ if (PERIOD_UNITS.indexOf(spec.unit) < 0) return null;
10023
+ let count = parseInt(spec.count, 10);
10024
+ if (!(count > 0)) count = 1;
9813
10025
  return {
9814
- text,
9815
- capped: false
10026
+ id: spec.id || spec.unit,
10027
+ unit: spec.unit,
10028
+ count
9816
10029
  };
9817
10030
  }
9818
- /************************************************************
9819
- * Which view a freshly mounted viewer opens on.
9820
- *
9821
- * Three answers, in order of authority: what the HOST asked
9822
- * for, what the READER chose last time, and `fallback`.
10031
+ /***************************************************************
10032
+ * The START of the bucket that holds `anchor_ms`, as a local Date.
9823
10033
  *
9824
- * The host wins because a viewer mounted to show a graph has
9825
- * to show one. The memory comes next, because reopening a
9826
- * document in the view you just left is the whole point of
9827
- * remembering it. `fallback` is the floor.
10034
+ * Alignment is what makes a bucket a bucket. Each unit floors against
10035
+ * the natural origin of the unit above it, so the boundaries are the
10036
+ * ones a human already has in their head:
9828
10037
  *
9829
- * Anything not in `modes` is treated as unsaid, which covers
9830
- * an absent value, an empty one, and a stored string from an
9831
- * older release that named a view no longer offered.
9832
- ************************************************************/
9833
- function pick_view_mode(asked, remembered, modes, fallback) {
9834
- let known = (m) => Array.isArray(modes) && modes.indexOf(m) >= 0;
9835
- if (known(asked)) return asked;
9836
- if (known(remembered)) return remembered;
10038
+ * minute -> the hour (a 15min bucket starts at :00/:15/:30/:45)
10039
+ * hour -> local midnight (a 6h bucket starts at 00/06/12/18)
10040
+ * day -> 1970-01-01 (count=1 is the plain day; a 10-day
10041
+ * bucket has no calendar origin to
10042
+ * align to, so it aligns to the epoch)
10043
+ * week -> the epoch week, Monday-first (ISO)
10044
+ * month -> January (which is why 2/3/4/6/12 give calendar
10045
+ * bimesters, quarters and semesters)
10046
+ * year -> year 0 (a decade starts at 2020, not 2021)
10047
+ ***************************************************************/
10048
+ function period_start(period, anchor_ms) {
10049
+ let spec = period_spec(period);
10050
+ if (!spec) return null;
10051
+ let d = new Date(anchor_ms);
10052
+ let n = spec.count;
10053
+ switch (spec.unit) {
10054
+ case "minute": {
10055
+ let m = Math.floor(d.getMinutes() / n) * n;
10056
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), m);
10057
+ }
10058
+ case "hour": {
10059
+ let h = Math.floor(d.getHours() / n) * n;
10060
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), h);
10061
+ }
10062
+ case "day": return date_from_day_number(Math.floor(day_number(d) / n) * n);
10063
+ case "week": return date_from_day_number(Math.floor(week_index(d) / n) * n * 7 - 3);
10064
+ case "month": {
10065
+ let mi = d.getFullYear() * 12 + d.getMonth();
10066
+ let s = Math.floor(mi / n) * n;
10067
+ return new Date(Math.floor(s / 12), s % 12, 1);
10068
+ }
10069
+ case "year": {
10070
+ let y = Math.floor(d.getFullYear() / n) * n;
10071
+ return new Date(y, 0, 1);
10072
+ }
10073
+ default: return null;
10074
+ }
10075
+ }
10076
+ /***************************************************************
10077
+ * The start of the bucket `delta` buckets away (delta may be negative).
10078
+ * Calendar arithmetic, never millisecond arithmetic: `new Date(y, m+3, 1)`
10079
+ * overflows the year by itself, and stepping a day across a DST change
10080
+ * keeps landing on midnight.
10081
+ ***************************************************************/
10082
+ function period_shift(period, anchor_ms, delta) {
10083
+ let spec = period_spec(period);
10084
+ if (!spec) return anchor_ms;
10085
+ let s = period_start(spec, anchor_ms);
10086
+ let step = spec.count * (delta || 0);
10087
+ switch (spec.unit) {
10088
+ case "minute": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours(), s.getMinutes() + step).getTime();
10089
+ case "hour": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours() + step).getTime();
10090
+ case "day": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step).getTime();
10091
+ case "week": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step * 7).getTime();
10092
+ case "month": return new Date(s.getFullYear(), s.getMonth() + step, 1).getTime();
10093
+ case "year": return new Date(s.getFullYear() + step, 0, 1).getTime();
10094
+ default: return anchor_ms;
10095
+ }
10096
+ }
10097
+ /***************************************************************
10098
+ * The bucket holding `anchor_ms`, as {from, to} in MILLISECONDS.
10099
+ *
10100
+ * `to` is INCLUSIVE — the last millisecond of the bucket, not the first
10101
+ * of the next one. Both ends of a match condition are inclusive, and an
10102
+ * exclusive end handed to one silently swallows the record that landed
10103
+ * exactly on the boundary.
10104
+ ***************************************************************/
10105
+ function period_bounds(period, anchor_ms) {
10106
+ let spec = period_spec(period);
10107
+ if (!spec) return {
10108
+ from: 0,
10109
+ to: 0
10110
+ };
10111
+ return {
10112
+ from: period_start(spec, anchor_ms).getTime(),
10113
+ to: period_shift(spec, anchor_ms, 1) - 1
10114
+ };
10115
+ }
10116
+ /***************************************************************
10117
+ * The same bucket, in the unit the CONSUMER speaks (a tranger topic
10118
+ * keeps its timestamps in seconds, unless its system_flag says
10119
+ * milliseconds). This is the function a query builder calls.
10120
+ ***************************************************************/
10121
+ function period_bounds_epoch(period, anchor_ms, ms) {
10122
+ let b = period_bounds(period, anchor_ms);
10123
+ if (!b.from) return {
10124
+ from: 0,
10125
+ to: 0
10126
+ };
10127
+ return {
10128
+ from: ms_to_epoch(b.from, ms),
10129
+ to: ms_to_epoch(b.to, ms)
10130
+ };
10131
+ }
10132
+ /***************************************************************
10133
+ * A ROLLING window: `secs` back from now. Not a bucket — it has no
10134
+ * previous and no next, it just ends at `now`.
10135
+ *
10136
+ * The `to` end is left OPEN (0). An iterator with no upper bound keeps
10137
+ * matching the records that land while the card is on screen; pinning
10138
+ * it to "now" would freeze the window at the instant the user clicked.
10139
+ ***************************************************************/
10140
+ function rolling_bounds(rolling, ms, now_ms) {
10141
+ let r = typeof rolling === "string" ? YUI_ROLLING[rolling] : rolling;
10142
+ if (!r || !r.secs) return {
10143
+ from: 0,
10144
+ to: 0
10145
+ };
10146
+ return {
10147
+ from: ms_to_epoch((now_ms === void 0 ? Date.now() : now_ms) - r.secs * 1e3, ms),
10148
+ to: 0
10149
+ };
10150
+ }
10151
+ /***************************************************************
10152
+ * Is this the LAST bucket — the one `now` falls in? It is what greys
10153
+ * out the "next" arrow, and what tells the navigator it is already home.
10154
+ ***************************************************************/
10155
+ function is_current_period(period, anchor_ms, now_ms) {
10156
+ let spec = period_spec(period);
10157
+ if (!spec) return false;
10158
+ let now = now_ms === void 0 ? Date.now() : now_ms;
10159
+ let a = period_start(spec, anchor_ms);
10160
+ let b = period_start(spec, now);
10161
+ return !!a && !!b && a.getTime() === b.getTime();
10162
+ }
10163
+ /***************************************************************
10164
+ * Recognize the bucket a {from, to} pair came from, so a range that
10165
+ * travelled through a URL, a saved view or a backend answer comes back
10166
+ * as the period the user picked instead of as a hand-typed range.
10167
+ *
10168
+ * `from`/`to` are in the CONSUMER's unit (`ms`), and so is the
10169
+ * comparison — that is the whole trap: a bucket ends on the last
10170
+ * MILLISECOND (…23:59:59.999), and a consumer that keeps seconds stored
10171
+ * it truncated (…23:59:59). Comparing in milliseconds, a week saved by a
10172
+ * seconds-based topic came back as "no bucket at all", every time.
10173
+ *
10174
+ * Only an EXACT match counts: both ends must land on the bucket's own
10175
+ * boundaries, as that consumer would have written them. `candidates` are
10176
+ * ids/specs, tried in order. Returns {period, anchor} (anchor in ms) or
10177
+ * null.
10178
+ ***************************************************************/
10179
+ function infer_period(from, to, candidates, ms) {
10180
+ if (!from || !to || to <= from) return null;
10181
+ let from_ms = epoch_to_ms(from, ms);
10182
+ for (let candidate of candidates || Object.keys(YUI_PERIODS)) {
10183
+ let spec = period_spec(candidate);
10184
+ if (!spec) continue;
10185
+ let b = period_bounds_epoch(spec, from_ms, ms);
10186
+ if (b.from === from && b.to === to) return {
10187
+ period: spec,
10188
+ anchor: from_ms
10189
+ };
10190
+ }
10191
+ return null;
10192
+ }
10193
+ /***************************
10194
+ * Period labels
10195
+ ***************************/
10196
+ /***************************************************************
10197
+ * The name of a GRANULARITY (what the segmented control shows):
10198
+ * the spec's own id as an i18n key, so an app that declares
10199
+ * {id: "quarter"} gets "Trimestre" the moment it adds the key.
10200
+ ***************************************************************/
10201
+ function period_name(period, t) {
10202
+ let spec = period_spec(period);
10203
+ if (!spec) return tr(t, String(period && period.id || period || ""));
10204
+ return tr(t, spec.id);
10205
+ }
10206
+ /***************************************************************
10207
+ * The name of the bucket a navigator is PARKED on: what goes between
10208
+ * the two arrows.
10209
+ *
10210
+ * day -> "Today" / "Yesterday" / "13 jul 2026"
10211
+ * week -> "Week 27" (+ year when it is not this one)
10212
+ * month -> "July" (+ year when it is not this one)
10213
+ * quarter -> "Q3 2026" (unit month, count 3)
10214
+ * semester -> "H2 2026" (unit month, count 6)
10215
+ * year -> "2026"
10216
+ * decade -> "2020 – 2029"
10217
+ * any other -> the bucket's own edges: "1 jul – 31 aug 2026"
10218
+ *
10219
+ * The named ones are named because a range reads worse than a name;
10220
+ * everything an app invents falls back to the range, which is always
10221
+ * true and never wrong.
10222
+ ***************************************************************/
10223
+ function period_label(period, anchor_ms, t, locale) {
10224
+ let spec = period_spec(period);
10225
+ if (!spec) return "";
10226
+ let loc = safe_locale(locale);
10227
+ let start = period_start(spec, anchor_ms);
10228
+ let end = new Date(period_bounds(spec, anchor_ms).to);
10229
+ let now = /* @__PURE__ */ new Date();
10230
+ let this_year = start.getFullYear() === now.getFullYear();
10231
+ if (spec.unit === "day" && spec.count === 1) {
10232
+ let diff = day_number(start) - day_number(now);
10233
+ if (diff === 0) return tr(t, "today");
10234
+ if (diff === -1) return tr(t, "yesterday");
10235
+ if (diff === 1) return tr(t, "tomorrow");
10236
+ return fmt_intl(start, loc, this_year ? {
10237
+ day: "numeric",
10238
+ month: "short"
10239
+ } : {
10240
+ day: "numeric",
10241
+ month: "short",
10242
+ year: "numeric"
10243
+ });
10244
+ }
10245
+ if (spec.unit === "hour" && spec.count === 1) {
10246
+ let hh = fmt_intl(start, loc, {
10247
+ hour: "2-digit",
10248
+ minute: "2-digit"
10249
+ });
10250
+ if (day_number(start) === day_number(now)) return hh;
10251
+ return `${hh} · ${fmt_intl(start, loc, {
10252
+ day: "numeric",
10253
+ month: "short"
10254
+ })}`;
10255
+ }
10256
+ if (spec.unit === "week" && spec.count === 1) {
10257
+ let away = week_index(start) - week_index(now);
10258
+ if (away === 0) return tr(t, "this week");
10259
+ if (away === -1) return tr(t, "last week");
10260
+ let w = iso_week(start);
10261
+ return w.year === now.getFullYear() ? tr(t, "week {{n}}", { n: w.week }) : tr(t, "week {{n}} {{y}}", {
10262
+ n: w.week,
10263
+ y: w.year
10264
+ });
10265
+ }
10266
+ if (spec.unit === "month" && spec.count === 1) return fmt_intl(start, loc, this_year ? { month: "long" } : {
10267
+ month: "long",
10268
+ year: "numeric"
10269
+ });
10270
+ if (spec.unit === "month" && (spec.count === 3 || spec.count === 6)) {
10271
+ let n = Math.floor(start.getMonth() / spec.count) + 1;
10272
+ return tr(t, spec.count === 3 ? "quarter {{n}} {{y}}" : "semester {{n}} {{y}}", {
10273
+ n,
10274
+ y: start.getFullYear()
10275
+ });
10276
+ }
10277
+ if (spec.unit === "year") {
10278
+ if (spec.count === 1) return String(start.getFullYear());
10279
+ return `${start.getFullYear()} – ${end.getFullYear()}`;
10280
+ }
10281
+ let opts = spec.unit === "minute" || spec.unit === "hour" ? {
10282
+ day: "numeric",
10283
+ month: "short",
10284
+ hour: "2-digit",
10285
+ minute: "2-digit"
10286
+ } : {
10287
+ day: "numeric",
10288
+ month: "short"
10289
+ };
10290
+ if (start.getFullYear() !== end.getFullYear()) {
10291
+ let y_opts = Object.assign({ year: "numeric" }, opts);
10292
+ return `${fmt_intl(start, loc, y_opts)} – ${fmt_intl(end, loc, y_opts)}`;
10293
+ }
10294
+ let span = `${fmt_intl(start, loc, opts)} – ${fmt_intl(end, loc, opts)}`;
10295
+ return this_year ? span : `${span} ${start.getFullYear()}`;
10296
+ }
10297
+ /************************************************************
10298
+ * JSON type discriminator (viewer vocabulary)
10299
+ ************************************************************/
10300
+ function json_type(value) {
10301
+ if (value === null) return "null";
10302
+ if (Array.isArray(value)) return "array";
10303
+ switch (typeof value) {
10304
+ case "string": return "string";
10305
+ case "number": return "number";
10306
+ case "boolean": return "boolean";
10307
+ case "object": return "object";
10308
+ default: return "unknown";
10309
+ }
10310
+ }
10311
+ /************************************************************
10312
+ * Detect a kw_collapse() sentinel.
10313
+ *
10314
+ * The kernel replaces an over-limit dict with:
10315
+ * { "__collapsed__": { "path": ..., "size": N } }
10316
+ * and an over-limit array with:
10317
+ * [ { "__collapsed__": { "path": ..., "size": N } } ]
10318
+ *
10319
+ * Returns { size, path, is_array } or null.
10320
+ ************************************************************/
10321
+ function is_collapsed(value) {
10322
+ if (value && typeof value === "object" && !Array.isArray(value)) {
10323
+ let keys = Object.keys(value);
10324
+ if (keys.length === 1 && keys[0] === "__collapsed__") {
10325
+ let c = value.__collapsed__ || {};
10326
+ return {
10327
+ size: c.size,
10328
+ path: c.path,
10329
+ is_array: false
10330
+ };
10331
+ }
10332
+ return null;
10333
+ }
10334
+ if (Array.isArray(value) && value.length === 1) {
10335
+ let e = value[0];
10336
+ if (e && typeof e === "object" && !Array.isArray(e) && Object.keys(e).length === 1 && e.__collapsed__) {
10337
+ let c = e.__collapsed__ || {};
10338
+ return {
10339
+ size: c.size,
10340
+ path: c.path,
10341
+ is_array: true
10342
+ };
10343
+ }
10344
+ }
10345
+ return null;
10346
+ }
10347
+ /************************************************************
10348
+ * Join / split absolute path segments (kernel convention)
10349
+ ************************************************************/
10350
+ function seg_join(segments) {
10351
+ return segments.map(function(s) {
10352
+ return String(s);
10353
+ }).join("`");
10354
+ }
10355
+ function seg_split(path) {
10356
+ if (path === "" || path === null || path === void 0) return [];
10357
+ return path.split("`");
10358
+ }
10359
+ /************************************************************
10360
+ * Walk a JSON tree by absolute segments; undefined if the
10361
+ * path does not resolve.
10362
+ ************************************************************/
10363
+ function get_by_segments(root, segments) {
10364
+ let v = root;
10365
+ for (let seg of segments) {
10366
+ if (v === null || v === void 0) return;
10367
+ if (Array.isArray(v)) v = v[Number(seg)];
10368
+ else if (typeof v === "object") v = v[seg];
10369
+ else return;
10370
+ }
10371
+ return v;
10372
+ }
10373
+ /************************************************************
10374
+ * Set a value at absolute segments (mutates root).
10375
+ *
10376
+ * segments == [] means "replace the whole root" — the caller
10377
+ * must use the RETURNED value in that case (a primitive/array
10378
+ * root cannot be mutated in place).
10379
+ ************************************************************/
10380
+ function set_by_segments(root, segments, new_value) {
10381
+ if (segments.length === 0) return new_value;
10382
+ let parent = get_by_segments(root, segments.slice(0, -1));
10383
+ if (parent === null || parent === void 0 || typeof parent !== "object") return root;
10384
+ let last = segments[segments.length - 1];
10385
+ if (Array.isArray(parent)) parent[Number(last)] = new_value;
10386
+ else parent[last] = new_value;
10387
+ return root;
10388
+ }
10389
+ /************************************************************
10390
+ * Does `value` (or any loaded descendant / its own key)
10391
+ * contain the lower-cased search term?
10392
+ *
10393
+ * Collapsed (not-yet-loaded) subtrees can't be searched, so
10394
+ * they never match on content — only their key can match,
10395
+ * which the renderer checks separately.
10396
+ ************************************************************/
10397
+ function subtree_matches(value, term) {
10398
+ if (!term) return true;
10399
+ if (is_collapsed(value)) return false;
10400
+ let type = json_type(value);
10401
+ if (type === "object") {
10402
+ for (let [k, v] of Object.entries(value)) {
10403
+ if (String(k).toLowerCase().includes(term)) return true;
10404
+ if (subtree_matches(v, term)) return true;
10405
+ }
10406
+ return false;
10407
+ }
10408
+ if (type === "array") {
10409
+ for (let v of value) if (subtree_matches(v, term)) return true;
10410
+ return false;
10411
+ }
10412
+ return String(value).toLowerCase().includes(term);
10413
+ }
10414
+ /************************************************************
10415
+ * Fields whose numeric value is an epoch timestamp.
10416
+ *
10417
+ * THE ONE LIST. C_YUI_FORM's jsoneditor takes its
10418
+ * `timestampTag` from here: it used to carry its own copy,
10419
+ * and a copy is how the two stopped agreeing.
10420
+ *
10421
+ * TWO SPELLINGS, AND LAS DOS SON DEL BACKEND. timeranger2
10422
+ * writes `from_t`/`from_tm` in the match_cond of a query and
10423
+ * `fr_t`/`fr_tm` in the metadata of a topic and of a file --
10424
+ * which is what a Raw JSON of a treedb actually shows. With
10425
+ * only the long pair listed, `to_t` got its date and the
10426
+ * `fr_t` right above it did not, which reads as a broken
10427
+ * annotator rather than a missing name.
10428
+ ************************************************************/
10429
+ var TIME_FIELDS = [
10430
+ "__t__",
10431
+ "__tm__",
10432
+ "t",
10433
+ "tm",
10434
+ "time",
10435
+ "from_t",
10436
+ "to_t",
10437
+ "from_tm",
10438
+ "to_tm",
10439
+ "fr_t",
10440
+ "fr_tm",
10441
+ "t_input",
10442
+ "t_output"
10443
+ ];
10444
+ function is_time_field(field) {
10445
+ return TIME_FIELDS.indexOf(field) >= 0;
10446
+ }
10447
+ /************************************************************
10448
+ * Format an epoch value as a local wall-clock string, 24
10449
+ * hours, in the APP's language `locale` (fmt_date_time() of
10450
+ * yui_time.js, as the time cells of the forms and tables;
10451
+ * up to gobj-ui 7.26.51 it was toLocaleString(): the
10452
+ * browser's language, and 12 hours in English).
10453
+ * Accepts seconds or milliseconds; returns null when the
10454
+ * value is not a usable positive timestamp (0 == "unset").
10455
+ ************************************************************/
10456
+ function format_epoch(value, locale) {
10457
+ if (typeof value !== "number" || !isFinite(value) || value <= 0) return null;
10458
+ let ms = Math.abs(value) < 0xe8d4a51000 ? value * 1e3 : value;
10459
+ let d = new Date(ms);
10460
+ if (isNaN(d.getTime())) return null;
10461
+ return fmt_date_time(d, locale);
10462
+ }
10463
+ /************************************************************
10464
+ * The text view's payload: the document as text, indented
10465
+ * four characters, cut at `max_chars`.
10466
+ *
10467
+ * Returns {text, capped}. `capped` is what the caller
10468
+ * announces under the dump — a cut that is not announced
10469
+ * reads as a document that ends there.
10470
+ ************************************************************/
10471
+ function json_text_dump(root, max_chars) {
10472
+ let text;
10473
+ try {
10474
+ text = JSON.stringify(root, null, 4);
10475
+ } catch (e) {
10476
+ return {
10477
+ text: "",
10478
+ capped: false,
10479
+ error: String(e)
10480
+ };
10481
+ }
10482
+ if (text === void 0) return {
10483
+ text: "",
10484
+ capped: false,
10485
+ error: "not representable as JSON"
10486
+ };
10487
+ if (typeof max_chars === "number" && max_chars > 0 && text.length > max_chars) return {
10488
+ text: text.slice(0, max_chars),
10489
+ capped: true
10490
+ };
10491
+ return {
10492
+ text,
10493
+ capped: false
10494
+ };
10495
+ }
10496
+ /************************************************************
10497
+ * Which view a freshly mounted viewer opens on.
10498
+ *
10499
+ * Three answers, in order of authority: what the HOST asked
10500
+ * for, what the READER chose last time, and `fallback`.
10501
+ *
10502
+ * The host wins because a viewer mounted to show a graph has
10503
+ * to show one. The memory comes next, because reopening a
10504
+ * document in the view you just left is the whole point of
10505
+ * remembering it. `fallback` is the floor.
10506
+ *
10507
+ * Anything not in `modes` is treated as unsaid, which covers
10508
+ * an absent value, an empty one, and a stored string from an
10509
+ * older release that named a view no longer offered.
10510
+ ************************************************************/
10511
+ function pick_view_mode(asked, remembered, modes, fallback) {
10512
+ let known = (m) => Array.isArray(modes) && modes.indexOf(m) >= 0;
10513
+ if (known(asked)) return asked;
10514
+ if (known(remembered)) return remembered;
9837
10515
  return fallback;
9838
10516
  }
9839
10517
  /************************************************************
@@ -9980,8 +10658,11 @@ function json_diff_rows(doc_a, doc_b) {
9980
10658
  * `new Date("YYYY-MM-DDT02:30:00")` answers the EARLIER one
9981
10659
  * (ECMAScript's "compatible" disambiguation). An epoch in the
9982
10660
  * SECOND pass of that hour is shown as 02:30 and comes back
9983
- * one hour earlier: saving the record -- any field of it --
9984
- * moves a writable time column that holds it by -3600 s.
10661
+ * one hour earlier. So neither the form's field nor the cell
10662
+ * editor reads a box that still shows what it was filled
10663
+ * with: they give back the value it was filled from (up to
10664
+ * gobj-ui 7.26.48 the cell, and 7.26.50 the field, wrote
10665
+ * -3600 s on a save of any field of the record).
9985
10666
  * - the night the clocks go forward (spring), one hour does not
9986
10667
  * exist. No epoch is shown in it, so nothing read comes back
9987
10668
  * wrong; a wall time TYPED in it is moved forward by the
@@ -9991,8 +10672,8 @@ function json_diff_rows(doc_a, doc_b) {
9991
10672
  * carry. What is safe: a read-only time column never goes back
9992
10673
  * (treedb_write_plan.js, col_goes_back_to_treedb), and a time
9993
10674
  * pkey2 goes back as the record had it, never through this
9994
- * widget (instance_keys_of). A writable time column edited or
9995
- * merely saved inside the repeated hour is the exposed case.
10675
+ * widget (instance_keys_of). A wall time TYPED inside the
10676
+ * repeated hour is the exposed case: it is the first pass.
9996
10677
  *
9997
10678
  * Copyright (c) 2026, ArtGins.
9998
10679
  * All Rights Reserved.
@@ -10045,15 +10726,17 @@ function epoch_to_time_value(epoch, real_type) {
10045
10726
  }
10046
10727
  /************************************************************
10047
10728
  * The value of a time column as a table cell shows it: the
10048
- * local clock the editor opens on, "YYYY-MM-DD HH:mm:ss", as
10049
- * fmt_epoch() of yui_time.js writes a timestamp in a table. ""
10050
- * for no time; a value that is not one is shown as it is, so the
10051
- * reader sees what the column holds.
10052
- ************************************************************/
10053
- function time_value_to_text(value, real_type) {
10729
+ * local clock, 24 hours, in the APP's language `locale`
10730
+ * (fmt_date_time() of yui_time.js: es "14 oct 2026, 15:05:09").
10731
+ * Up to gobj-ui 7.26.51 the form wrote "2026-10-14 15:05:09" and
10732
+ * the treedb table "14 oct 2026, 03:05:09 p. m.", in the
10733
+ * browser's language. "" for no time; a value that is not one is
10734
+ * shown as it is, so the reader sees what the column holds.
10735
+ ************************************************************/
10736
+ function time_value_to_text(value, real_type, locale) {
10054
10737
  let date = time_value_to_date(value, real_type);
10055
10738
  if (!date) return value === null || value === void 0 ? "" : String(value);
10056
- return date_to_datetime_local(date).replace("T", " ");
10739
+ return fmt_date_time(date, locale);
10057
10740
  }
10058
10741
  //#endregion
10059
10742
  //#region src/form_time_cell_editor.js
@@ -12558,6 +13241,36 @@ function table_column_titles(template) {
12558
13241
  });
12559
13242
  return titles;
12560
13243
  }
13244
+ var TIME_CELL_FORMATTERS = /* @__PURE__ */ new WeakSet();
13245
+ /******************************************************************
13246
+ * The formatter of a time cell: the local clock, 24 hours, in the
13247
+ * APP's language (fmt_date_time of yui_time.js, as the cells of
13248
+ * C_YUI_TREEDB_TOPIC_WITH_FORM): es "14 oct 2026, 15:05:09".
13249
+ ******************************************************************/
13250
+ function time_cell_formatter(real_type) {
13251
+ let formatter = function(cell) {
13252
+ return text_node(time_value_to_text(cell.getValue(), real_type, safe_locale(i18next.language)));
13253
+ };
13254
+ TIME_CELL_FORMATTERS.add(formatter);
13255
+ return formatter;
13256
+ }
13257
+ /******************************************************************
13258
+ * Draw the time cells of a table again, in the current language.
13259
+ * Cell by cell, never a redraw of the rows: a row's formatter
13260
+ * builds its nested tables anew -- empty. A cell being edited is
13261
+ * its editor's; Tabulator formats it again when the editor closes.
13262
+ ******************************************************************/
13263
+ function reformat_time_cells(tabulator) {
13264
+ for (let column of tabulator.getColumns()) {
13265
+ let formatter = column.getDefinition().formatter;
13266
+ if (!TIME_CELL_FORMATTERS.has(formatter)) continue;
13267
+ for (let cell of column.getCells()) {
13268
+ let $cell = cell.getElement();
13269
+ if ($cell.classList.contains("tabulator-editing")) continue;
13270
+ $cell.replaceChildren(formatter(cell));
13271
+ }
13272
+ }
13273
+ }
12561
13274
  /******************************************************************
12562
13275
  * Convert a template's items in tabulator columns
12563
13276
  ******************************************************************/
@@ -12670,9 +13383,7 @@ function template2columns(gobj, columns, template, sub_elements) {
12670
13383
  case "time":
12671
13384
  column.editor = form_time_cell_editor(field_desc.real_type);
12672
13385
  column.editorParams = { verticalNavigation: "table" };
12673
- column.formatter = function(cell) {
12674
- return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
12675
- };
13386
+ column.formatter = time_cell_formatter(field_desc.real_type);
12676
13387
  break;
12677
13388
  case "color":
12678
13389
  column.editor = "input";
@@ -12898,7 +13609,8 @@ function get_form_values(gobj, $form) {
12898
13609
  case "input":
12899
13610
  switch (input_type) {
12900
13611
  case "datetime-local":
12901
- value = datetime_local_to_epoch($input.value);
13612
+ if ($input.yui_time_kept && $input.value === $input.yui_time_kept.shown) value = $input.yui_time_kept.value;
13613
+ else value = datetime_local_to_epoch($input.value);
12902
13614
  break;
12903
13615
  default: value = getInputValue($input);
12904
13616
  }
@@ -12966,8 +13678,10 @@ function clear_data(gobj, $form) {
12966
13678
  if (jsoneditor) jsoneditor.set({ text: "" });
12967
13679
  } else if ($input.type === "checkbox") $input.checked = false;
12968
13680
  else if ($input.type === "radio") $input.checked = false;
12969
- else if ($input.type === "datetime-local") $input.value = null;
12970
- else if ($input.type === "color") {
13681
+ else if ($input.type === "datetime-local") {
13682
+ $input.value = null;
13683
+ $input.yui_time_kept = null;
13684
+ } else if ($input.type === "color") {
12971
13685
  $input.value = "#000000";
12972
13686
  if ($input.yui_color_value) {
12973
13687
  $input.yui_color_value.textContent = $input.value;
@@ -13057,6 +13771,7 @@ function set_form_values(gobj, template, $form, record) {
13057
13771
  value = field_desc.default_value;
13058
13772
  modified = true;
13059
13773
  }
13774
+ let stored = value === void 0 ? null : value;
13060
13775
  value = treedb_value_2_form_value(gobj, field_desc, value);
13061
13776
  if (value === void 0) value = null;
13062
13777
  switch (tag) {
@@ -13069,6 +13784,10 @@ function set_form_values(gobj, template, $form, record) {
13069
13784
  switch (input_type) {
13070
13785
  case "datetime-local":
13071
13786
  $input.value = date_to_datetime_local(value);
13787
+ $input.yui_time_kept = {
13788
+ value: stored,
13789
+ shown: $input.value
13790
+ };
13072
13791
  break;
13073
13792
  case "color":
13074
13793
  $input.value = convertColor(value);
@@ -13645,7 +14364,7 @@ function ac_name_json_editors(gobj, event, kw, src) {
13645
14364
  * in the old language until it draws it again, so each is told to
13646
14365
  * (a new onRenderMenu), and the render names it again.
13647
14366
  ************************************************************/
13648
- function ac_language_changed$10(gobj, event, kw, src) {
14367
+ function ac_language_changed$11(gobj, event, kw, src) {
13649
14368
  let $container = gobj_read_attr(gobj, "$container");
13650
14369
  if (!$container) return 0;
13651
14370
  for (let $editor of $container.querySelectorAll(".jsoneditor")) {
@@ -13654,7 +14373,10 @@ function ac_language_changed$10(gobj, event, kw, src) {
13654
14373
  }
13655
14374
  for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) {
13656
14375
  let tabulator = $table.tabulator;
13657
- if (tabulator && tabulator.initialized && $table.template) yui_tabulator_relocalize(tabulator, t, table_column_titles($table.template));
14376
+ if (tabulator && tabulator.initialized && $table.template) {
14377
+ yui_tabulator_relocalize(tabulator, t, table_column_titles($table.template));
14378
+ reformat_time_cells(tabulator);
14379
+ }
13658
14380
  }
13659
14381
  return 0;
13660
14382
  }
@@ -13831,7 +14553,7 @@ function create_gclass$17(gclass_name) {
13831
14553
  ],
13832
14554
  [
13833
14555
  "EV_LANGUAGE_CHANGED",
13834
- ac_language_changed$10,
14556
+ ac_language_changed$11,
13835
14557
  null
13836
14558
  ]
13837
14559
  ]]];
@@ -14227,7 +14949,7 @@ function mt_create$16(gobj) {
14227
14949
  * rewritten in place, and the map's locale with them so a
14228
14950
  * control or a popup built later is right too.
14229
14951
  ***************************************************************/
14230
- function ac_language_changed$9(gobj, event, kw, src) {
14952
+ function ac_language_changed$10(gobj, event, kw, src) {
14231
14953
  let priv = gobj.priv;
14232
14954
  if (priv.xmap) yui_maplibre_relocalize(priv.xmap, t);
14233
14955
  return 0;
@@ -14795,7 +15517,7 @@ function create_gclass$16(gclass_name) {
14795
15517
  ], [["ST_IDLE", [
14796
15518
  [
14797
15519
  "EV_LANGUAGE_CHANGED",
14798
- ac_language_changed$9,
15520
+ ac_language_changed$10,
14799
15521
  null
14800
15522
  ],
14801
15523
  [
@@ -14944,12 +15666,145 @@ function yui_uplot_axes(axes) {
14944
15666
  });
14945
15667
  }
14946
15668
  //#endregion
15669
+ //#region src/yui_uplot_time.js
15670
+ /***********************************************************************
15671
+ * yui_uplot_time.js
15672
+ *
15673
+ * The texts uPlot writes for a moment -- the ticks of a time axis
15674
+ * and the reading of the legend -- in the APP's language, with a
15675
+ * clock of 24 hours, as every other time a gobj-ui view shows
15676
+ * (fmt_date_time of yui_time.js).
15677
+ *
15678
+ * uPlot writes them from templates of its own, in English and
15679
+ * 12 hours: "3pm", "3:05pm", "10/14" (month first), "Oct", and
15680
+ * "2026-10-14 3:05pm" in the legend. Its `fmtDate` option takes
15681
+ * the template and returns the function that writes a Date with
15682
+ * it; this one is given to it:
15683
+ *
15684
+ * legend "{YYYY}-{MM}-{DD} {h}:{mm}{aa}" -> fmt_date_time()
15685
+ * "14 oct 2026, 15:05:09"
15686
+ * "{h}{aa}" "3pm" -> "15:00"
15687
+ * "{h}:{mm}{aa}" "3:05pm" -> "15:05"
15688
+ * "{M}/{D}" "10/14" -> es "14/10", en "10/14"
15689
+ * "{M}/{D}/{YY}" "10/14/26"-> es "14/10/26", en "10/14/26"
15690
+ * "{MMM}" "Oct" -> es "oct", en "Oct"
15691
+ *
15692
+ * The language is asked for on every call, so a redraw after a
15693
+ * language change writes the new one (C_YUI_UPLOT redraws its
15694
+ * axes on EV_LANGUAGE_CHANGED).
15695
+ *
15696
+ * Copyright (c) 2026, ArtGins.
15697
+ * All Rights Reserved.
15698
+ ***********************************************************************/
15699
+ var LEGEND_STAMP = "{YYYY}-{MM}-{DD} {h}:{mm}{aa}";
15700
+ var pad2 = (n) => String(n).padStart(2, "0");
15701
+ var __formatters__ = /* @__PURE__ */ new Map();
15702
+ function intl(locale, opts) {
15703
+ let key = locale + "|" + JSON.stringify(opts);
15704
+ let f = __formatters__.get(key);
15705
+ if (!f) {
15706
+ try {
15707
+ f = new Intl.DateTimeFormat(locale, opts);
15708
+ } catch (e) {
15709
+ f = new Intl.DateTimeFormat("en", opts);
15710
+ }
15711
+ __formatters__.set(key, f);
15712
+ }
15713
+ return f;
15714
+ }
15715
+ var WHOLE = [
15716
+ ["{M}/{D}/{YY}", (d, loc) => intl(loc, {
15717
+ day: "numeric",
15718
+ month: "numeric",
15719
+ year: "2-digit"
15720
+ }).format(d)],
15721
+ ["{M}/{D}", (d, loc) => intl(loc, {
15722
+ day: "numeric",
15723
+ month: "numeric"
15724
+ }).format(d)],
15725
+ ["{h}{aa}", (d) => `${pad2(d.getHours())}:00`]
15726
+ ];
15727
+ var TOKENS = {
15728
+ YYYY: (d) => String(d.getFullYear()),
15729
+ YY: (d) => String(d.getFullYear()).slice(2),
15730
+ MMMM: (d, loc) => intl(loc, { month: "long" }).format(d),
15731
+ MMM: (d, loc) => intl(loc, { month: "short" }).format(d),
15732
+ MM: (d) => pad2(d.getMonth() + 1),
15733
+ M: (d) => String(d.getMonth() + 1),
15734
+ DD: (d) => pad2(d.getDate()),
15735
+ D: (d) => String(d.getDate()),
15736
+ WWWW: (d, loc) => intl(loc, { weekday: "long" }).format(d),
15737
+ WWW: (d, loc) => intl(loc, { weekday: "short" }).format(d),
15738
+ HH: (d) => pad2(d.getHours()),
15739
+ H: (d) => String(d.getHours()),
15740
+ hh: (d) => pad2(d.getHours()),
15741
+ h: (d) => pad2(d.getHours()),
15742
+ AA: () => "",
15743
+ aa: () => "",
15744
+ a: () => "",
15745
+ mm: (d) => pad2(d.getMinutes()),
15746
+ m: (d) => String(d.getMinutes()),
15747
+ ss: (d) => pad2(d.getSeconds()),
15748
+ s: (d) => String(d.getSeconds()),
15749
+ fff: (d) => String(d.getMilliseconds()).padStart(3, "0")
15750
+ };
15751
+ /***************************************************************
15752
+ * A template -> its parts: literal text, or a function of
15753
+ * (date, locale).
15754
+ ***************************************************************/
15755
+ function template_parts(tpl) {
15756
+ let parts = [];
15757
+ let rest = String(tpl);
15758
+ while (rest.length > 0) {
15759
+ let whole = WHOLE.find(([frag]) => rest.startsWith(frag));
15760
+ if (whole) {
15761
+ parts.push(whole[1]);
15762
+ rest = rest.slice(whole[0].length);
15763
+ continue;
15764
+ }
15765
+ let m = /^\{([a-z]+)\}/i.exec(rest);
15766
+ if (m && TOKENS[m[1]]) {
15767
+ parts.push(TOKENS[m[1]]);
15768
+ rest = rest.slice(m[0].length);
15769
+ continue;
15770
+ }
15771
+ let next = rest.indexOf("{", 1);
15772
+ let text = next < 0 ? rest : rest.slice(0, next);
15773
+ parts.push(text);
15774
+ rest = rest.slice(text.length);
15775
+ }
15776
+ return parts;
15777
+ }
15778
+ /***************************************************************
15779
+ * uPlot's `fmtDate` option. `get_locale` answers the app's
15780
+ * language at the moment of the call (the views pass
15781
+ * `() => i18next.language`).
15782
+ ***************************************************************/
15783
+ function yui_uplot_fmt_date(get_locale) {
15784
+ let locale = () => safe_locale(typeof get_locale === "function" ? get_locale() : null);
15785
+ return function(tpl) {
15786
+ if (tpl === LEGEND_STAMP) return (date) => fmt_date_time(date, locale());
15787
+ let parts = template_parts(tpl);
15788
+ return function(date) {
15789
+ let loc = locale();
15790
+ let out = "";
15791
+ for (let part of parts) out += typeof part === "string" ? part : part(date, loc);
15792
+ return out;
15793
+ };
15794
+ };
15795
+ }
15796
+ //#endregion
14947
15797
  //#region src/c_yui_uplot.js
14948
15798
  /***********************************************************************
14949
15799
  * c_yui_uplot.js
14950
15800
  *
14951
15801
  * Graphics, Charts with uPlot
14952
15802
  *
15803
+ * A moment uPlot writes -- a tick of a time axis, the reading of
15804
+ * the legend -- is in the app's language with a clock of 24 hours
15805
+ * (yui_uplot_time.js), and is written again on the shell's
15806
+ * EV_LANGUAGE_CHANGED.
15807
+ *
14953
15808
  * Copyright (c) 2025-2026, ArtGins.
14954
15809
  * All Rights Reserved.
14955
15810
  ***********************************************************************/
@@ -14978,7 +15833,10 @@ var attrs_table$15 = [
14978
15833
  SDATA(data_type_t.DTP_INTEGER, "timeout_idle", 0, 5, "Idle timeout (seconds)"),
14979
15834
  SDATA_END()
14980
15835
  ];
14981
- var PRIVATE_DATA$15 = { theme_observer: null };
15836
+ var PRIVATE_DATA$15 = {
15837
+ theme_observer: null,
15838
+ lang_shell: null
15839
+ };
14982
15840
  var __gclass__$15 = null;
14983
15841
  /******************************
14984
15842
  * Framework Methods
@@ -14996,11 +15854,22 @@ function mt_create$15(gobj) {
14996
15854
  /***************************************************************
14997
15855
  * Framework Method: Start
14998
15856
  ***************************************************************/
14999
- function mt_start$15(gobj) {}
15857
+ function mt_start$15(gobj) {
15858
+ let priv = gobj.priv;
15859
+ let shell = yui_shell_of(gobj);
15860
+ if (shell) {
15861
+ gobj_subscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
15862
+ priv.lang_shell = shell;
15863
+ }
15864
+ }
15000
15865
  /***************************************************************
15001
15866
  * Framework Method: Stop
15002
15867
  ***************************************************************/
15003
- function mt_stop$15(gobj) {}
15868
+ function mt_stop$15(gobj) {
15869
+ let priv = gobj.priv;
15870
+ if (priv.lang_shell && !gobj_is_destroying(priv.lang_shell)) gobj_unsubscribe_event(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
15871
+ priv.lang_shell = null;
15872
+ }
15004
15873
  /***************************************************************
15005
15874
  * Framework Method: Destroy
15006
15875
  ***************************************************************/
@@ -15038,7 +15907,8 @@ function build_ui$14(gobj) {
15038
15907
  height: gobj_read_attr(gobj, "height"),
15039
15908
  series: gobj_read_attr(gobj, "series"),
15040
15909
  axes: yui_uplot_axes(gobj_read_attr(gobj, "axes")),
15041
- scales: gobj_read_attr(gobj, "scales")
15910
+ scales: gobj_read_attr(gobj, "scales"),
15911
+ fmtDate: yui_uplot_fmt_date(() => i18next.language)
15042
15912
  };
15043
15913
  let uplot = new uPlot(uPlot_options, gobj_read_attr(gobj, "data"), $container);
15044
15914
  gobj_write_attr(gobj, "uplot", uplot);
@@ -15160,6 +16030,22 @@ function ac_theme$4(gobj, event, kw, src) {
15160
16030
  return 0;
15161
16031
  }
15162
16032
  /******************************************************
16033
+ * The language changed: the ticks of a time axis and the
16034
+ * reading of the legend ask for it when they are written,
16035
+ * so they are written again.
16036
+ ******************************************************/
16037
+ function ac_language_changed$9(gobj, event, kw, src) {
16038
+ let uplot = gobj_read_attr(gobj, "uplot");
16039
+ if (!uplot) return 0;
16040
+ try {
16041
+ uplot.redraw(true, true);
16042
+ uplot.setLegend(null, false);
16043
+ } catch (e) {
16044
+ log_error(`${gobj_short_name(gobj)}: cannot redraw the chart: ${e}`);
16045
+ }
16046
+ return 0;
16047
+ }
16048
+ /******************************************************
15163
16049
  *
15164
16050
  ******************************************************/
15165
16051
  function ac_del_serie(gobj, event, kw, src) {
@@ -15207,7 +16093,8 @@ function create_gclass$15(gclass_name) {
15207
16093
  ["EV_ADD_SERIE", 0],
15208
16094
  ["EV_DEL_SERIE", 0],
15209
16095
  ["EV_CLEAR", 0],
15210
- ["EV_THEME", 0]
16096
+ ["EV_THEME", 0],
16097
+ ["EV_LANGUAGE_CHANGED", 0]
15211
16098
  ], [["ST_IDLE", [
15212
16099
  [
15213
16100
  "EV_LOAD_DATA",
@@ -15233,6 +16120,11 @@ function create_gclass$15(gclass_name) {
15233
16120
  "EV_THEME",
15234
16121
  ac_theme$4,
15235
16122
  null
16123
+ ],
16124
+ [
16125
+ "EV_LANGUAGE_CHANGED",
16126
+ ac_language_changed$9,
16127
+ null
15236
16128
  ]
15237
16129
  ]]], gmt$15, 0, attrs_table$15, PRIVATE_DATA$15, 0, 0, 0, 0);
15238
16130
  if (!__gclass__$15) return -1;
@@ -18299,7 +19191,8 @@ var PRIVATE_DATA$13 = {
18299
19191
  $search_ctl: null,
18300
19192
  $expand_btn: null,
18301
19193
  $collapse_btn: null,
18302
- $mode_btns: null
19194
+ $mode_btns: null,
19195
+ lang_shell: null
18303
19196
  };
18304
19197
  var __gclass__$13 = null;
18305
19198
  /******************************
@@ -18327,13 +19220,22 @@ function mt_create$13(gobj) {
18327
19220
  * Framework Method: Start
18328
19221
  ***************************************************************/
18329
19222
  function mt_start$13(gobj) {
18330
- if (gobj.priv.root !== null) gobj_change_state(gobj, "ST_READY");
19223
+ let priv = gobj.priv;
19224
+ if (priv.root !== null) gobj_change_state(gobj, "ST_READY");
19225
+ let shell = yui_shell_of(gobj);
19226
+ if (shell) {
19227
+ gobj_subscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
19228
+ priv.lang_shell = shell;
19229
+ }
18331
19230
  render_view$1(gobj);
18332
19231
  }
18333
19232
  /***************************************************************
18334
19233
  * Framework Method: Stop
18335
19234
  ***************************************************************/
18336
19235
  function mt_stop$13(gobj) {
19236
+ let priv = gobj.priv;
19237
+ if (priv.lang_shell && !gobj_is_destroying(priv.lang_shell)) gobj_unsubscribe_event(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
19238
+ priv.lang_shell = null;
18337
19239
  teardown_graph_child$1(gobj);
18338
19240
  }
18339
19241
  /***************************************************************
@@ -19032,7 +19934,7 @@ function leaf_row(key, value, depth) {
19032
19934
  text_node(text)
19033
19935
  ]);
19034
19936
  if (key !== null && is_time_field(String(key))) {
19035
- let wall = format_epoch(value);
19937
+ let wall = format_epoch(value, safe_locale(i18next.language));
19036
19938
  if (wall) body.push([
19037
19939
  "span",
19038
19940
  { class: "JSON_TIME is-size-7 yui-text-quiet ml-2" },
@@ -19283,6 +20185,12 @@ function ac_json_item_clicked(gobj, event, kw, src) {
19283
20185
  }
19284
20186
  /************************************************************
19285
20187
  * EV_LANGUAGE_CHANGED — re-translate chrome + re-render
20188
+ *
20189
+ * Only the TREE is drawn again: it writes the reading of a
20190
+ * time field in the language of the moment it was drawn. The
20191
+ * text view carries its keys (refresh_language reaches them),
20192
+ * and loading the graph again would throw away the reader's
20193
+ * camera for nothing.
19286
20194
  ************************************************************/
19287
20195
  function ac_language_changed$8(gobj, event, kw, src) {
19288
20196
  let priv = gobj.priv;
@@ -19292,7 +20200,7 @@ function ac_language_changed$8(gobj, event, kw, src) {
19292
20200
  if (priv.$search) priv.$search.setAttribute("placeholder", t("search"));
19293
20201
  apply_view_mode$1(gobj);
19294
20202
  }
19295
- render_view$1(gobj);
20203
+ if (current_view_mode$1(gobj) === "tree") render_tree(gobj);
19296
20204
  return 0;
19297
20205
  }
19298
20206
  /************************************************************
@@ -32973,26 +33881,11 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
32973
33881
  switch (field_desc.real_type) {
32974
33882
  case "string":
32975
33883
  case "integer":
32976
- value = time_value_to_date(value, field_desc.real_type);
32977
- if (!value) {
32978
- value = "";
32979
- break;
32980
- }
32981
- const rawLocale = navigator.language;
32982
- const userLocale = typeof rawLocale === "string" && rawLocale && rawLocale !== "undefined" ? rawLocale : void 0;
32983
- const formatter = new Intl.DateTimeFormat(userLocale, {
32984
- day: "numeric",
32985
- month: "short",
32986
- year: "numeric",
32987
- hour: "2-digit",
32988
- minute: "2-digit",
32989
- second: "2-digit",
32990
- hour12: true
32991
- });
32992
- value = createElement2([
33884
+ value = time_value_to_text(value, field_desc.real_type, safe_locale(i18next.language));
33885
+ if (value) value = createElement2([
32993
33886
  "span",
32994
33887
  { class: "is-size-7" },
32995
- formatter.format(value)
33888
+ text_node(value)
32996
33889
  ]);
32997
33890
  }
32998
33891
  break;
@@ -82647,591 +83540,6 @@ function register_c_yui_schema_editor() {
82647
83540
  return create_gclass$1(GCLASS_NAME$1);
82648
83541
  }
82649
83542
  //#endregion
82650
- //#region src/yui_time.js
82651
- /***********************************************************************
82652
- * yui_time.js
82653
- *
82654
- * Time, without a DOM: epochs, and the algebra of PERIODS.
82655
- *
82656
- * Two things live here, and they are the two halves of every date
82657
- * UI the projects keep rewriting:
82658
- *
82659
- * 1) EPOCH <-> the local wall clock. A timestamp travels in the
82660
- * producer's own unit — seconds, or milliseconds when a topic
82661
- * says so — and every conversion crosses that `ms` flag. Getting
82662
- * it wrong puts the same instant on two different clocks in one
82663
- * screen (it did: a picker asking "from 18:55" local returned
82664
- * rows a table labelled 16:55).
82665
- *
82666
- * 2) The PERIOD. A period is not an enum of five names: it is a
82667
- * BUCKET, and a bucket is `count` of a `unit`:
82668
- *
82669
- * {id: "day", unit: "day", count: 1}
82670
- * {id: "week", unit: "week", count: 1} ISO, Mon-first
82671
- * {id: "bimester", unit: "month", count: 2}
82672
- * {id: "quarter", unit: "month", count: 3}
82673
- * {id: "semester", unit: "month", count: 6}
82674
- * {id: "decade", unit: "year", count: 10}
82675
- * {id: "15min", unit: "minute", count: 15}
82676
- *
82677
- * Given that pair, ONE implementation answers every question a
82678
- * date navigator asks — where does the bucket holding this
82679
- * instant start and end, what is the previous/next one, what do
82680
- * I call it — so an app that wants quarters declares a quarter
82681
- * instead of asking for a new component.
82682
- *
82683
- * Buckets are ALIGNED, never "count back from now": months align to
82684
- * the year (which is why 2, 3, 4, 6 and 12 fall on clean calendar
82685
- * boundaries), weeks to Monday, hours to local midnight. "Last 7
82686
- * days" is a different animal — a rolling window — and it is not a
82687
- * period: see `rolling_bounds()`.
82688
- *
82689
- * Everything here is LOCAL time (the user reads a local clock) and
82690
- * DST-safe: it never adds 86400000 ms to cross a day, it builds the
82691
- * next date from calendar fields and lets the platform do it.
82692
- *
82693
- * Copyright (c) 2026, ArtGins.
82694
- * All Rights Reserved.
82695
- ***********************************************************************/
82696
- /***************************************************************
82697
- * Constants
82698
- ***************************************************************/
82699
- var MS_DAY = 864e5;
82700
- var PERIOD_UNITS = [
82701
- "minute",
82702
- "hour",
82703
- "day",
82704
- "week",
82705
- "month",
82706
- "year"
82707
- ];
82708
- var YUI_PERIODS = {
82709
- minute: {
82710
- id: "minute",
82711
- unit: "minute",
82712
- count: 1
82713
- },
82714
- "5min": {
82715
- id: "5min",
82716
- unit: "minute",
82717
- count: 5
82718
- },
82719
- "15min": {
82720
- id: "15min",
82721
- unit: "minute",
82722
- count: 15
82723
- },
82724
- hour: {
82725
- id: "hour",
82726
- unit: "hour",
82727
- count: 1
82728
- },
82729
- day: {
82730
- id: "day",
82731
- unit: "day",
82732
- count: 1
82733
- },
82734
- week: {
82735
- id: "week",
82736
- unit: "week",
82737
- count: 1
82738
- },
82739
- fortnight: {
82740
- id: "fortnight",
82741
- unit: "week",
82742
- count: 2
82743
- },
82744
- month: {
82745
- id: "month",
82746
- unit: "month",
82747
- count: 1
82748
- },
82749
- bimester: {
82750
- id: "bimester",
82751
- unit: "month",
82752
- count: 2
82753
- },
82754
- quarter: {
82755
- id: "quarter",
82756
- unit: "month",
82757
- count: 3
82758
- },
82759
- semester: {
82760
- id: "semester",
82761
- unit: "month",
82762
- count: 6
82763
- },
82764
- year: {
82765
- id: "year",
82766
- unit: "year",
82767
- count: 1
82768
- },
82769
- decade: {
82770
- id: "decade",
82771
- unit: "year",
82772
- count: 10
82773
- }
82774
- };
82775
- var YUI_PERIODS_DEFAULT = [
82776
- "hour",
82777
- "day",
82778
- "week",
82779
- "month",
82780
- "year"
82781
- ];
82782
- var YUI_ROLLING = {
82783
- "1h": {
82784
- id: "1h",
82785
- secs: 3600,
82786
- label: "last hour"
82787
- },
82788
- "6h": {
82789
- id: "6h",
82790
- secs: 21600,
82791
- label: "last 6h"
82792
- },
82793
- "24h": {
82794
- id: "24h",
82795
- secs: 86400,
82796
- label: "last 24h"
82797
- },
82798
- "7d": {
82799
- id: "7d",
82800
- secs: 604800,
82801
- label: "last 7 days"
82802
- },
82803
- "30d": {
82804
- id: "30d",
82805
- secs: 2592e3,
82806
- label: "last 30 days"
82807
- }
82808
- };
82809
- /***************************
82810
- * Locale / i18n
82811
- ***************************/
82812
- /***************************************************************
82813
- * The locale to format with.
82814
- *
82815
- * NEVER at module top level, and never `navigator.language` raw:
82816
- * Firefox can report the literal STRING "undefined", and every Intl
82817
- * constructor throws RangeError on it — a module that built its
82818
- * formatter on import took the whole bundle down with it (that is why
82819
- * gui_agent refuses to import the gobj-ui barrel).
82820
- ***************************************************************/
82821
- function safe_locale(locale) {
82822
- if (typeof locale === "string" && locale && locale !== "undefined") return locale;
82823
- let nav = typeof navigator !== "undefined" ? navigator.language : null;
82824
- if (typeof nav === "string" && nav && nav !== "undefined") return nav;
82825
- return "en";
82826
- }
82827
- /***************************************************************
82828
- * Translate through the APP's translator when it gave us one, and
82829
- * degrade to the key itself otherwise — interpolating `{{x}}` by hand,
82830
- * so a label never renders raw mustaches at a caller that has no i18n.
82831
- ***************************************************************/
82832
- function tr(t, key, params) {
82833
- if (typeof t === "function") return t(key, params);
82834
- let s = key;
82835
- for (let k in params || {}) s = s.replaceAll(`{{${k}}}`, String(params[k]));
82836
- return s;
82837
- }
82838
- /***************************************************************
82839
- * Intl formatters, built PER CALL (see safe_locale). They are cheap
82840
- * next to a repaint, and caching them would need a locale-change hook
82841
- * the library has no business owning.
82842
- ***************************************************************/
82843
- function fmt_intl(date, locale, opts) {
82844
- try {
82845
- return new Intl.DateTimeFormat(safe_locale(locale), opts).format(date);
82846
- } catch (e) {
82847
- return date.toDateString();
82848
- }
82849
- }
82850
- /***************************
82851
- * Epoch <-> clock
82852
- ***************************/
82853
- /***************************************************************
82854
- * Epoch in the producer's unit -> milliseconds, and back.
82855
- * `ms` true means the value already IS milliseconds.
82856
- ***************************************************************/
82857
- function epoch_to_ms(value, ms) {
82858
- if (!value) return 0;
82859
- return ms ? value : value * 1e3;
82860
- }
82861
- function ms_to_epoch(value_ms, ms) {
82862
- if (!value_ms) return 0;
82863
- return ms ? value_ms : Math.floor(value_ms / 1e3);
82864
- }
82865
- /***************************************************************
82866
- * The LOCAL wall-clock string an `<input type="datetime-local">` takes
82867
- * ("YYYY-MM-DDTHH:MM:SS", which needs step=1 to keep the seconds), and
82868
- * the parse back. Empty / unparseable -> 0, which is exactly how a
82869
- * match condition reads an absent bound.
82870
- ***************************************************************/
82871
- function epoch_to_local_input(value, ms) {
82872
- if (!value) return "";
82873
- let d = new Date(epoch_to_ms(value, ms));
82874
- let pad = (n) => String(n).padStart(2, "0");
82875
- return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
82876
- }
82877
- function local_input_to_epoch(v, ms) {
82878
- if (!v) return 0;
82879
- let parsed = Date.parse(v);
82880
- if (Number.isNaN(parsed)) return 0;
82881
- return ms_to_epoch(parsed, ms);
82882
- }
82883
- /***************************************************************
82884
- * A timestamp for a table cell: the local wall clock, space-separated,
82885
- * keeping the milliseconds when the producer bothered to send them (a
82886
- * topic that sets sf_t_ms usually appends several records inside the
82887
- * same second, and a column that hides that shows a column of ties).
82888
- ***************************************************************/
82889
- function fmt_epoch(value, ms) {
82890
- if (!value) return "";
82891
- try {
82892
- let s = epoch_to_local_input(value, ms).replace("T", " ");
82893
- if (ms) s += `.${String(value % 1e3).padStart(3, "0")}`;
82894
- return s;
82895
- } catch (e) {
82896
- return String(value);
82897
- }
82898
- }
82899
- /***************************
82900
- * Calendar atoms
82901
- ***************************/
82902
- /***************************************************************
82903
- * The day number of a date, counting local calendar days from
82904
- * 1970-01-01. Built from the FIELDS (Date.UTC of y/m/d), never from
82905
- * the timestamp: a DST day is 23 or 25 hours long, so dividing a local
82906
- * epoch by 86400000 drifts a day twice a year.
82907
- ***************************************************************/
82908
- function day_number(d) {
82909
- return Math.floor(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_DAY);
82910
- }
82911
- function date_from_day_number(n) {
82912
- let d = /* @__PURE__ */ new Date(n * MS_DAY);
82913
- return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
82914
- }
82915
- /***************************************************************
82916
- * The Monday of the week a date falls in (ISO: the week starts on
82917
- * Monday, and Sunday closes it).
82918
- ***************************************************************/
82919
- function start_of_iso_week(d) {
82920
- let day = d.getDay();
82921
- let back = day === 0 ? 6 : day - 1;
82922
- return new Date(d.getFullYear(), d.getMonth(), d.getDate() - back);
82923
- }
82924
- /***************************************************************
82925
- * The ISO week a date belongs to: {week, year}. The YEAR is the ISO
82926
- * week-year, not the calendar year — 2026-12-31 lives in week 1 of
82927
- * 2027, and a label that said "week 1 2026" would name a week six
82928
- * months away.
82929
- ***************************************************************/
82930
- function iso_week(d) {
82931
- let monday = start_of_iso_week(d);
82932
- let thursday = new Date(monday.getFullYear(), monday.getMonth(), monday.getDate() + 3);
82933
- let jan1 = new Date(thursday.getFullYear(), 0, 1);
82934
- return {
82935
- week: Math.floor((day_number(thursday) - day_number(jan1)) / 7) + 1,
82936
- year: thursday.getFullYear()
82937
- };
82938
- }
82939
- /***************************************************************
82940
- * The index of the ISO week a date falls in, counting weeks from the
82941
- * Monday of the epoch week. It is what aligns a MULTI-week bucket (a
82942
- * fortnight) to a Monday instead of to whatever day 1970-01-01 was.
82943
- ***************************************************************/
82944
- function week_index(d) {
82945
- return Math.floor((day_number(start_of_iso_week(d)) + 3) / 7);
82946
- }
82947
- /***************************
82948
- * Period algebra
82949
- ***************************/
82950
- /***************************************************************
82951
- * Normalize whatever a caller hands us into a spec: an id of the
82952
- * catalog, or a spec of its own. Returns null for anything that is not
82953
- * a bucket (a "span" / "custom" mode of a navigator has no algebra).
82954
- ***************************************************************/
82955
- function period_spec(period) {
82956
- if (!period) return null;
82957
- let spec = typeof period === "string" ? YUI_PERIODS[period] : period;
82958
- if (!spec || !spec.unit) return null;
82959
- if (PERIOD_UNITS.indexOf(spec.unit) < 0) return null;
82960
- let count = parseInt(spec.count, 10);
82961
- if (!(count > 0)) count = 1;
82962
- return {
82963
- id: spec.id || spec.unit,
82964
- unit: spec.unit,
82965
- count
82966
- };
82967
- }
82968
- /***************************************************************
82969
- * The START of the bucket that holds `anchor_ms`, as a local Date.
82970
- *
82971
- * Alignment is what makes a bucket a bucket. Each unit floors against
82972
- * the natural origin of the unit above it, so the boundaries are the
82973
- * ones a human already has in their head:
82974
- *
82975
- * minute -> the hour (a 15min bucket starts at :00/:15/:30/:45)
82976
- * hour -> local midnight (a 6h bucket starts at 00/06/12/18)
82977
- * day -> 1970-01-01 (count=1 is the plain day; a 10-day
82978
- * bucket has no calendar origin to
82979
- * align to, so it aligns to the epoch)
82980
- * week -> the epoch week, Monday-first (ISO)
82981
- * month -> January (which is why 2/3/4/6/12 give calendar
82982
- * bimesters, quarters and semesters)
82983
- * year -> year 0 (a decade starts at 2020, not 2021)
82984
- ***************************************************************/
82985
- function period_start(period, anchor_ms) {
82986
- let spec = period_spec(period);
82987
- if (!spec) return null;
82988
- let d = new Date(anchor_ms);
82989
- let n = spec.count;
82990
- switch (spec.unit) {
82991
- case "minute": {
82992
- let m = Math.floor(d.getMinutes() / n) * n;
82993
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), m);
82994
- }
82995
- case "hour": {
82996
- let h = Math.floor(d.getHours() / n) * n;
82997
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), h);
82998
- }
82999
- case "day": return date_from_day_number(Math.floor(day_number(d) / n) * n);
83000
- case "week": return date_from_day_number(Math.floor(week_index(d) / n) * n * 7 - 3);
83001
- case "month": {
83002
- let mi = d.getFullYear() * 12 + d.getMonth();
83003
- let s = Math.floor(mi / n) * n;
83004
- return new Date(Math.floor(s / 12), s % 12, 1);
83005
- }
83006
- case "year": {
83007
- let y = Math.floor(d.getFullYear() / n) * n;
83008
- return new Date(y, 0, 1);
83009
- }
83010
- default: return null;
83011
- }
83012
- }
83013
- /***************************************************************
83014
- * The start of the bucket `delta` buckets away (delta may be negative).
83015
- * Calendar arithmetic, never millisecond arithmetic: `new Date(y, m+3, 1)`
83016
- * overflows the year by itself, and stepping a day across a DST change
83017
- * keeps landing on midnight.
83018
- ***************************************************************/
83019
- function period_shift(period, anchor_ms, delta) {
83020
- let spec = period_spec(period);
83021
- if (!spec) return anchor_ms;
83022
- let s = period_start(spec, anchor_ms);
83023
- let step = spec.count * (delta || 0);
83024
- switch (spec.unit) {
83025
- case "minute": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours(), s.getMinutes() + step).getTime();
83026
- case "hour": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours() + step).getTime();
83027
- case "day": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step).getTime();
83028
- case "week": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step * 7).getTime();
83029
- case "month": return new Date(s.getFullYear(), s.getMonth() + step, 1).getTime();
83030
- case "year": return new Date(s.getFullYear() + step, 0, 1).getTime();
83031
- default: return anchor_ms;
83032
- }
83033
- }
83034
- /***************************************************************
83035
- * The bucket holding `anchor_ms`, as {from, to} in MILLISECONDS.
83036
- *
83037
- * `to` is INCLUSIVE — the last millisecond of the bucket, not the first
83038
- * of the next one. Both ends of a match condition are inclusive, and an
83039
- * exclusive end handed to one silently swallows the record that landed
83040
- * exactly on the boundary.
83041
- ***************************************************************/
83042
- function period_bounds(period, anchor_ms) {
83043
- let spec = period_spec(period);
83044
- if (!spec) return {
83045
- from: 0,
83046
- to: 0
83047
- };
83048
- return {
83049
- from: period_start(spec, anchor_ms).getTime(),
83050
- to: period_shift(spec, anchor_ms, 1) - 1
83051
- };
83052
- }
83053
- /***************************************************************
83054
- * The same bucket, in the unit the CONSUMER speaks (a tranger topic
83055
- * keeps its timestamps in seconds, unless its system_flag says
83056
- * milliseconds). This is the function a query builder calls.
83057
- ***************************************************************/
83058
- function period_bounds_epoch(period, anchor_ms, ms) {
83059
- let b = period_bounds(period, anchor_ms);
83060
- if (!b.from) return {
83061
- from: 0,
83062
- to: 0
83063
- };
83064
- return {
83065
- from: ms_to_epoch(b.from, ms),
83066
- to: ms_to_epoch(b.to, ms)
83067
- };
83068
- }
83069
- /***************************************************************
83070
- * A ROLLING window: `secs` back from now. Not a bucket — it has no
83071
- * previous and no next, it just ends at `now`.
83072
- *
83073
- * The `to` end is left OPEN (0). An iterator with no upper bound keeps
83074
- * matching the records that land while the card is on screen; pinning
83075
- * it to "now" would freeze the window at the instant the user clicked.
83076
- ***************************************************************/
83077
- function rolling_bounds(rolling, ms, now_ms) {
83078
- let r = typeof rolling === "string" ? YUI_ROLLING[rolling] : rolling;
83079
- if (!r || !r.secs) return {
83080
- from: 0,
83081
- to: 0
83082
- };
83083
- return {
83084
- from: ms_to_epoch((now_ms === void 0 ? Date.now() : now_ms) - r.secs * 1e3, ms),
83085
- to: 0
83086
- };
83087
- }
83088
- /***************************************************************
83089
- * Is this the LAST bucket — the one `now` falls in? It is what greys
83090
- * out the "next" arrow, and what tells the navigator it is already home.
83091
- ***************************************************************/
83092
- function is_current_period(period, anchor_ms, now_ms) {
83093
- let spec = period_spec(period);
83094
- if (!spec) return false;
83095
- let now = now_ms === void 0 ? Date.now() : now_ms;
83096
- let a = period_start(spec, anchor_ms);
83097
- let b = period_start(spec, now);
83098
- return !!a && !!b && a.getTime() === b.getTime();
83099
- }
83100
- /***************************************************************
83101
- * Recognize the bucket a {from, to} pair came from, so a range that
83102
- * travelled through a URL, a saved view or a backend answer comes back
83103
- * as the period the user picked instead of as a hand-typed range.
83104
- *
83105
- * `from`/`to` are in the CONSUMER's unit (`ms`), and so is the
83106
- * comparison — that is the whole trap: a bucket ends on the last
83107
- * MILLISECOND (…23:59:59.999), and a consumer that keeps seconds stored
83108
- * it truncated (…23:59:59). Comparing in milliseconds, a week saved by a
83109
- * seconds-based topic came back as "no bucket at all", every time.
83110
- *
83111
- * Only an EXACT match counts: both ends must land on the bucket's own
83112
- * boundaries, as that consumer would have written them. `candidates` are
83113
- * ids/specs, tried in order. Returns {period, anchor} (anchor in ms) or
83114
- * null.
83115
- ***************************************************************/
83116
- function infer_period(from, to, candidates, ms) {
83117
- if (!from || !to || to <= from) return null;
83118
- let from_ms = epoch_to_ms(from, ms);
83119
- for (let candidate of candidates || Object.keys(YUI_PERIODS)) {
83120
- let spec = period_spec(candidate);
83121
- if (!spec) continue;
83122
- let b = period_bounds_epoch(spec, from_ms, ms);
83123
- if (b.from === from && b.to === to) return {
83124
- period: spec,
83125
- anchor: from_ms
83126
- };
83127
- }
83128
- return null;
83129
- }
83130
- /***************************
83131
- * Period labels
83132
- ***************************/
83133
- /***************************************************************
83134
- * The name of a GRANULARITY (what the segmented control shows):
83135
- * the spec's own id as an i18n key, so an app that declares
83136
- * {id: "quarter"} gets "Trimestre" the moment it adds the key.
83137
- ***************************************************************/
83138
- function period_name(period, t) {
83139
- let spec = period_spec(period);
83140
- if (!spec) return tr(t, String(period && period.id || period || ""));
83141
- return tr(t, spec.id);
83142
- }
83143
- /***************************************************************
83144
- * The name of the bucket a navigator is PARKED on: what goes between
83145
- * the two arrows.
83146
- *
83147
- * day -> "Today" / "Yesterday" / "13 jul 2026"
83148
- * week -> "Week 27" (+ year when it is not this one)
83149
- * month -> "July" (+ year when it is not this one)
83150
- * quarter -> "Q3 2026" (unit month, count 3)
83151
- * semester -> "H2 2026" (unit month, count 6)
83152
- * year -> "2026"
83153
- * decade -> "2020 – 2029"
83154
- * any other -> the bucket's own edges: "1 jul – 31 aug 2026"
83155
- *
83156
- * The named ones are named because a range reads worse than a name;
83157
- * everything an app invents falls back to the range, which is always
83158
- * true and never wrong.
83159
- ***************************************************************/
83160
- function period_label(period, anchor_ms, t, locale) {
83161
- let spec = period_spec(period);
83162
- if (!spec) return "";
83163
- let loc = safe_locale(locale);
83164
- let start = period_start(spec, anchor_ms);
83165
- let end = new Date(period_bounds(spec, anchor_ms).to);
83166
- let now = /* @__PURE__ */ new Date();
83167
- let this_year = start.getFullYear() === now.getFullYear();
83168
- if (spec.unit === "day" && spec.count === 1) {
83169
- let diff = day_number(start) - day_number(now);
83170
- if (diff === 0) return tr(t, "today");
83171
- if (diff === -1) return tr(t, "yesterday");
83172
- if (diff === 1) return tr(t, "tomorrow");
83173
- return fmt_intl(start, loc, this_year ? {
83174
- day: "numeric",
83175
- month: "short"
83176
- } : {
83177
- day: "numeric",
83178
- month: "short",
83179
- year: "numeric"
83180
- });
83181
- }
83182
- if (spec.unit === "hour" && spec.count === 1) {
83183
- let hh = fmt_intl(start, loc, {
83184
- hour: "2-digit",
83185
- minute: "2-digit"
83186
- });
83187
- if (day_number(start) === day_number(now)) return hh;
83188
- return `${hh} · ${fmt_intl(start, loc, {
83189
- day: "numeric",
83190
- month: "short"
83191
- })}`;
83192
- }
83193
- if (spec.unit === "week" && spec.count === 1) {
83194
- let away = week_index(start) - week_index(now);
83195
- if (away === 0) return tr(t, "this week");
83196
- if (away === -1) return tr(t, "last week");
83197
- let w = iso_week(start);
83198
- return w.year === now.getFullYear() ? tr(t, "week {{n}}", { n: w.week }) : tr(t, "week {{n}} {{y}}", {
83199
- n: w.week,
83200
- y: w.year
83201
- });
83202
- }
83203
- if (spec.unit === "month" && spec.count === 1) return fmt_intl(start, loc, this_year ? { month: "long" } : {
83204
- month: "long",
83205
- year: "numeric"
83206
- });
83207
- if (spec.unit === "month" && (spec.count === 3 || spec.count === 6)) {
83208
- let n = Math.floor(start.getMonth() / spec.count) + 1;
83209
- return tr(t, spec.count === 3 ? "quarter {{n}} {{y}}" : "semester {{n}} {{y}}", {
83210
- n,
83211
- y: start.getFullYear()
83212
- });
83213
- }
83214
- if (spec.unit === "year") {
83215
- if (spec.count === 1) return String(start.getFullYear());
83216
- return `${start.getFullYear()} – ${end.getFullYear()}`;
83217
- }
83218
- let opts = spec.unit === "minute" || spec.unit === "hour" ? {
83219
- day: "numeric",
83220
- month: "short",
83221
- hour: "2-digit",
83222
- minute: "2-digit"
83223
- } : {
83224
- day: "numeric",
83225
- month: "short"
83226
- };
83227
- if (start.getFullYear() !== end.getFullYear()) {
83228
- let y_opts = Object.assign({ year: "numeric" }, opts);
83229
- return `${fmt_intl(start, loc, y_opts)} – ${fmt_intl(end, loc, y_opts)}`;
83230
- }
83231
- let span = `${fmt_intl(start, loc, opts)} – ${fmt_intl(end, loc, opts)}`;
83232
- return this_year ? span : `${span} ${start.getFullYear()}`;
83233
- }
83234
- //#endregion
83235
83543
  //#region src/c_yui_period.js
83236
83544
  /***********************************************************************
83237
83545
  * c_yui_period.js
@@ -86168,6 +86476,6 @@ function setup_json_pad(self) {
86168
86476
  return win;
86169
86477
  }
86170
86478
  //#endregion
86171
- export { EditControl, ICONS_TOPIC, MarkerControl, USER_ICON_PREFIX, YUI_FILE_ACCEPT, YUI_PERIODS, YUI_PERIODS_DEFAULT, YUI_ROLLING, addClasses, apply_dev_traces, attach_clear, build_dev_panel, dev_window_was_open, disableElements, enableElements, epoch_to_local_input, epoch_to_ms, expose_view_container, fmt_epoch, getStrokeColor, infer_period, info_traffic, inject_svg_icons, is_current_period, iso_week, local_input_to_epoch, ms_to_epoch, period_bounds, period_bounds_epoch, period_label, period_name, period_shift, period_spec, period_start, refresh_clear, register_c_g6_nodes_tree, register_c_yui_form, register_c_yui_fsm_graph, register_c_yui_gclass, register_c_yui_gobj_tree_js, register_c_yui_json, register_c_yui_json_graph, register_c_yui_json_pad, register_c_yui_map, register_c_yui_nav, register_c_yui_pager, register_c_yui_period, register_c_yui_schema_editor, register_c_yui_service_view, register_c_yui_shell, register_c_yui_treedb_graph, register_c_yui_treedb_schema, register_c_yui_treedb_topic_with_form, register_c_yui_treedb_topics, register_c_yui_uplot, register_c_yui_window, register_c_yui_window_manager, register_c_yui_wizard, removeChildElements, removeClasses, rolling_bounds, safe_locale, set_active_state, set_cancel_state, set_pressed_state, set_submit_state, setup_dev, setup_frontend_view, setup_json_pad, toggleClasses, yui_array_buffer_to_base64, yui_asset_element, yui_asset_id, yui_asset_ids, yui_asset_missing, yui_asset_src, yui_file_control, yui_file_id_label, yui_file_read, yui_file_sha256, yui_file_size_label, yui_files_manifest, yui_icon_is_defined, yui_icons_list, yui_icons_put_user, yui_icons_remove_user, yui_icons_set_user, yui_is_dark, yui_mount_service_view, yui_shell_close_drawer, yui_shell_close_dropdown, yui_shell_confirm_danger, yui_shell_confirm_ok, yui_shell_confirm_yesno, yui_shell_confirm_yesnocancel, yui_shell_escape_order, yui_shell_navigate, yui_shell_open_drawer, yui_shell_overlay_dismissed, yui_shell_pop_escape, yui_shell_push_escape, yui_shell_refresh_avatars, yui_shell_register_event_handler, yui_shell_register_overlay, yui_shell_set_avatar_provider, yui_shell_set_connection_state, yui_shell_set_nav_item_badge, yui_shell_set_sub_routes, yui_shell_set_toolbar_item_badge, yui_shell_set_toolbar_item_icon, yui_shell_set_translator, yui_shell_show_error, yui_shell_show_info, yui_shell_show_modal, yui_shell_show_route_map, yui_shell_show_warning, yui_shell_toggle_drawer, yui_shell_unpark_route, yui_svg_icon_element, yui_svg_sanitize, yui_theme_now, yui_toolbar, yui_user_icon_class, yui_watch_theme };
86479
+ export { EditControl, ICONS_TOPIC, MarkerControl, USER_ICON_PREFIX, YUI_FILE_ACCEPT, YUI_PERIODS, YUI_PERIODS_DEFAULT, YUI_ROLLING, addClasses, apply_dev_traces, attach_clear, build_dev_panel, dev_window_was_open, disableElements, enableElements, epoch_to_local_input, epoch_to_ms, expose_view_container, fmt_date_time, fmt_epoch, getStrokeColor, infer_period, info_traffic, inject_svg_icons, is_current_period, iso_week, local_input_to_epoch, ms_to_epoch, period_bounds, period_bounds_epoch, period_label, period_name, period_shift, period_spec, period_start, refresh_clear, register_c_g6_nodes_tree, register_c_yui_form, register_c_yui_fsm_graph, register_c_yui_gclass, register_c_yui_gobj_tree_js, register_c_yui_json, register_c_yui_json_graph, register_c_yui_json_pad, register_c_yui_map, register_c_yui_nav, register_c_yui_pager, register_c_yui_period, register_c_yui_schema_editor, register_c_yui_service_view, register_c_yui_shell, register_c_yui_treedb_graph, register_c_yui_treedb_schema, register_c_yui_treedb_topic_with_form, register_c_yui_treedb_topics, register_c_yui_uplot, register_c_yui_window, register_c_yui_window_manager, register_c_yui_wizard, removeChildElements, removeClasses, rolling_bounds, safe_locale, set_active_state, set_cancel_state, set_pressed_state, set_submit_state, setup_dev, setup_frontend_view, setup_json_pad, toggleClasses, yui_array_buffer_to_base64, yui_asset_element, yui_asset_id, yui_asset_ids, yui_asset_missing, yui_asset_src, yui_file_control, yui_file_id_label, yui_file_read, yui_file_sha256, yui_file_size_label, yui_files_manifest, yui_icon_is_defined, yui_icons_list, yui_icons_put_user, yui_icons_remove_user, yui_icons_set_user, yui_is_dark, yui_mount_service_view, yui_shell_close_drawer, yui_shell_close_dropdown, yui_shell_confirm_danger, yui_shell_confirm_ok, yui_shell_confirm_yesno, yui_shell_confirm_yesnocancel, yui_shell_escape_order, yui_shell_navigate, yui_shell_open_drawer, yui_shell_overlay_dismissed, yui_shell_pop_escape, yui_shell_push_escape, yui_shell_refresh_avatars, yui_shell_register_event_handler, yui_shell_register_overlay, yui_shell_set_avatar_provider, yui_shell_set_connection_state, yui_shell_set_nav_item_badge, yui_shell_set_sub_routes, yui_shell_set_toolbar_item_badge, yui_shell_set_toolbar_item_icon, yui_shell_set_translator, yui_shell_show_error, yui_shell_show_info, yui_shell_show_modal, yui_shell_show_route_map, yui_shell_show_warning, yui_shell_toggle_drawer, yui_shell_unpark_route, yui_svg_icon_element, yui_svg_sanitize, yui_theme_now, yui_toolbar, yui_user_icon_class, yui_watch_theme };
86172
86480
 
86173
86481
  //# sourceMappingURL=gobj-ui.es.js.map