nfx-ui 0.5.2 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.d.ts CHANGED
@@ -14,6 +14,12 @@ declare interface ApiErrorBody {
14
14
  traceId?: string;
15
15
  }
16
16
 
17
+ /**
18
+ * 数组类型。Array type.
19
+ * @example Array<string> => string[]
20
+ */
21
+ declare type Array_2<T> = T[];
22
+
17
23
  /** 可实例化的构造函数类型。Instantiable constructor type. */
18
24
  declare type Constructor<T extends object = object> = new (...args: unknown[]) => T;
19
25
 
@@ -28,6 +34,12 @@ declare type Constructor<T extends object = object> = new (...args: unknown[]) =
28
34
  */
29
35
  export declare function createMap<T extends string, V = T>(list: ReadonlyArray<T>, valueMapper?: (item: T, index: number) => V): Record<T, V>;
30
36
 
37
+ /**
38
+ * 可为 null、undefined 或空字符串。Emptyable: T | null | undefined | "".
39
+ * @example Emptyable<string> => string | null | undefined | ""
40
+ */
41
+ declare type Emptyable<T> = T | null | undefined | "";
42
+
31
43
  /**
32
44
  * 构造失败结果(非 Error 会包装为 Error)。Create a failed result; non-Error wrapped in Error.
33
45
  * @param e - 错误或任意值。Error or any value.
@@ -164,6 +176,12 @@ export declare const isValidEmail: (email: string) => boolean;
164
176
  */
165
177
  export declare const isValidPhoneNumber: (phoneNumber: string) => boolean;
166
178
 
179
+ /**
180
+ * 可为 undefined。Maybe: T | undefined.
181
+ * @example Maybe<number> => number | undefined
182
+ */
183
+ declare type Maybe<T> = T | undefined;
184
+
167
185
  /**
168
186
  * 按 id 将 items 合并进数组:insert 仅插入新 id,upsert 覆盖同 id 并插入新 id;可 prepend 或 append
169
187
  * Merge items into array by id: insert = only new ids, upsert = overwrite same id + insert new; place = prepend | append.
@@ -174,16 +192,16 @@ export declare const isValidPhoneNumber: (phoneNumber: string) => boolean;
174
192
  * @param mode - insert 不覆盖已有 id;upsert 覆盖同 id
175
193
  * @returns 合并后的新数组
176
194
  */
177
- export declare function mergeById<T>(arr: T[], items: T[], idOf: (x: T) => string, place: "prepend" | "append", mode: "insert" | "upsert"): T[];
195
+ export declare function mergeById<T>(arr: Array_2<T>, items: Array_2<T>, idOf: (x: T) => string, place: "prepend" | "append", mode: "insert" | "upsert"): Array_2<T>;
178
196
 
179
197
  /**
180
- * 可为 null 或 undefined。T | null | undefined.
198
+ * 可为 null 或 undefined。Nilable: T | null | undefined.
181
199
  * @example Nilable<boolean> => boolean | null | undefined
182
200
  */
183
201
  declare type Nilable<T> = T | null | undefined;
184
202
 
185
203
  /**
186
- * 可为 null 或 undefined。T | null | undefined.
204
+ * 可为 null 或 undefined。Nilable: T | null | undefined.
187
205
  * @example Nilable<boolean> => boolean | null | undefined
188
206
  */
189
207
  declare type Nilable_2<T> = T | null | undefined;
@@ -196,6 +214,12 @@ declare type Nilable_2<T> = T | null | undefined;
196
214
  */
197
215
  export declare function normalizeAddress(address: string): string;
198
216
 
217
+ /**
218
+ * 可为 null。Nullable: T | null.
219
+ * @example Nullable<string> => string | null
220
+ */
221
+ declare type Nullable<T> = T | null;
222
+
199
223
  /**
200
224
  * 构造成功结果。Create a successful result.
201
225
  * @param v - 结果值。Result value.
@@ -253,7 +277,7 @@ export declare function pollUntil<T>(fetcher: () => Promise<T>, isOK: (data: T)
253
277
  * @param idOf - 取 id 的函数
254
278
  * @returns 若无变化返回原数组,否则返回新数组
255
279
  */
256
- export declare function pruneArray<T>(arr: T[], ids: ReadonlySet<string>, idOf: (x: T) => string): T[];
280
+ export declare function pruneArray<T>(arr: Array_2<T>, ids: ReadonlySet<string>, idOf: (x: T) => string): Array_2<T>;
257
281
 
258
282
  export declare function removeItem(key: string): void;
259
283
 
@@ -276,6 +300,82 @@ export declare type Result<T> = [T, null] | [null, Error];
276
300
  */
277
301
  export declare const rgbToRgba: (rgb: string, alpha: number) => string;
278
302
 
303
+ /**
304
+ * 将 Nilable 数组规范为数组:null/undefined 转为 [] 或 defaultValue。返回类型 Array&lt;T&gt;(即 T[])。
305
+ * Normalize Nilable array to array: null/undefined to [] or defaultValue. Returns Array&lt;T&gt; (i.e. T[]).
306
+ * @param value - 可能为 null 或 undefined 的数组 (array that may be null or undefined)
307
+ * @param defaultValue - 可选,当 value 为 null/undefined 时使用;缺省为 [] (optional default when value is null/undefined; default is [])
308
+ * @returns value ?? defaultValue ?? [] (never null/undefined)
309
+ * @example safeArray(product.tags) // product.tags ?? []
310
+ * @example safeArray(product.tags, ['default'])
311
+ */
312
+ export declare function safeArray<T>(value: Nilable_2<Array_2<T>>, defaultValue?: Array_2<T>): Array_2<T>;
313
+
314
+ /**
315
+ * 将 Nilable 规范为 Maybe:null 转为 undefined,undefined 与 T 原样返回。返回类型 Maybe&lt;T&gt;。等同 value ?? undefined。
316
+ * Normalize Nilable to Maybe: convert null to undefined; undefined and T unchanged. Returns Maybe&lt;T&gt;. Same as value ?? undefined.
317
+ * @param value - 可能为 null 或 undefined 的值 (value that may be null or undefined)
318
+ * @returns 若为 null 或 undefined 则 undefined,否则原值 (undefined if null/undefined, otherwise value)
319
+ * @example safeMaybe(product.price) // 代替 product.price ?? undefined
320
+ */
321
+ export declare function safeMaybe<T>(value: Nilable_2<T>): Maybe<T>;
322
+
323
+ /**
324
+ * 将 Emptyable 字符串规范为 Nilable:空字符串转为 undefined,null/undefined/非空串原样。返回类型 Nilable&lt;T&gt;。常用于表单、接口字段。
325
+ * Normalize Emptyable string to Nilable: "" to undefined; null, undefined, non-empty string unchanged. Returns Nilable&lt;T&gt;. For form/API fields.
326
+ * @param value - 可能为 null、undefined 或空字符串 (value that may be null, undefined or "")
327
+ * @returns 若为 "" 则 undefined,否则原值 (undefined if "", otherwise value)
328
+ * @example safeNilable(product.remark) // "" 也视为「无值」
329
+ */
330
+ export declare function safeNilable<T extends string>(value: Emptyable<T>): Nilable_2<T>;
331
+
332
+ /**
333
+ * 将 Nilable 规范为 Nullable:undefined 转为 null,null 与 T 原样返回。返回类型 Nullable&lt;T&gt;。
334
+ * Normalize Nilable to Nullable: convert undefined to null; null and T unchanged. Returns Nullable&lt;T&gt;.
335
+ * @param value - 可能为 null 或 undefined 的值 (value that may be null or undefined)
336
+ * @returns 若为 undefined 则 null,否则原值 (null if undefined, otherwise value)
337
+ * @example safeNullable(apiResponse.data) // undefined → null,便于区分「未设置」与「空」
338
+ */
339
+ export declare function safeNullable<T>(value: Nilable_2<T>): Nullable<T>;
340
+
341
+ /**
342
+ * 安全取数字:null/undefined/NaN 转为 undefined,合法数字原样。返回类型 Maybe&lt;number&gt;。
343
+ * Safe number: null/undefined/NaN to undefined; valid number unchanged. Returns Maybe&lt;number&gt;.
344
+ * @param value - 可能为 null、undefined 或非数字 (value that may be null, undefined or NaN)
345
+ * @returns 若为 null、undefined 或 NaN 则 undefined,否则数字 (undefined if null/undefined/NaN, otherwise number)
346
+ * @example safeNum(product.price) // 用于严格「有值才用」的场景
347
+ */
348
+ export declare function safeNum(value: Nilable_2<number>): Maybe<number>;
349
+
350
+ /**
351
+ * 若值为 null/undefined 则返回默认值,否则返回原值。等同 value ?? defaultValue。
352
+ * Return defaultValue when value is null/undefined, otherwise value. Same as value ?? defaultValue.
353
+ * @param value - 可能为 null 或 undefined 的值 (value that may be null or undefined)
354
+ * @param defaultValue - 默认值 (default value)
355
+ * @returns value ?? defaultValue
356
+ * @example safeOr(product.stock, 0)
357
+ * @example safeOr(product.name, '')
358
+ */
359
+ export declare function safeOr<T, D>(value: Nilable_2<T>, defaultValue: D): T | D;
360
+
361
+ /**
362
+ * 将 Emptyable 字符串规范为 Stringable:null/undefined/"" 转为 ""。返回类型 Stringable&lt;string&gt;(即 string,"" 为兜底)。
363
+ * Normalize Emptyable string to Stringable: null/undefined/"" to "". Returns Stringable&lt;string&gt; (string with "" as fallback).
364
+ * @param value - 可能为 null、undefined 或空字符串 (value that may be null, undefined or "")
365
+ * @returns 若为 null、undefined 或 "" 则 "",否则原值 ("" if null/undefined/"", otherwise value)
366
+ * @example safeStringable(product.name) // 代替 product.name ?? ""
367
+ */
368
+ export declare function safeStringable<T extends string>(value: Emptyable<T>): Stringable<T>;
369
+
370
+ /**
371
+ * 将 Nilable 数值规范为 Zeroable:null/undefined 转为 0。返回类型 Zeroable&lt;number&gt;(即 number,0 为兜底)。
372
+ * Normalize Nilable number to Zeroable: null/undefined to 0. Returns Zeroable&lt;number&gt; (number with 0 as fallback).
373
+ * @param value - 可能为 null 或 undefined 的数值 (number that may be null or undefined)
374
+ * @returns value ?? 0 (never null/undefined)
375
+ * @example safeZeroable(product.stock) // 代替 product.stock ?? 0
376
+ */
377
+ export declare function safeZeroable(value: Nilable_2<number>): Zeroable<number>;
378
+
279
379
  export declare function setItem(key: string, value: string): void;
280
380
 
281
381
  /**
@@ -297,6 +397,12 @@ export declare function setItem(key: string, value: string): void;
297
397
  */
298
398
  export declare const singleton: <T extends object>(className: Constructor<T>) => Constructor<T>;
299
399
 
400
+ /**
401
+ * 可为空字符串的类型。Stringable: T | "",T 为 string 子类型。
402
+ * @example Stringable<string> => string | ""
403
+ */
404
+ declare type Stringable<T extends string> = T | "";
405
+
300
406
  /**
301
407
  * 若值为 null/undefined 则抛出 Promise 使 React Suspense 挂起,否则返回该值。
302
408
  * If value is null/undefined, throw a promise to suspend (React Suspense); otherwise return value.
@@ -371,4 +477,10 @@ export declare type WithRetryOptions = Options & {
371
477
  */
372
478
  export declare function withRetryResult<T>(fn: (bail: (e: Error) => void, attempt: number) => Promise<T>, opts?: WithRetryOptions): Promise<Result<T>>;
373
479
 
480
+ /**
481
+ * 可为 0 的数值类型。Zeroable: T | 0,T 为 number 子类型。
482
+ * @example Zeroable<number> => number | 0
483
+ */
484
+ declare type Zeroable<T extends number> = T | 0;
485
+
374
486
  export { }
package/dist/utils.mjs CHANGED
@@ -30,106 +30,106 @@ function U(t, r, e, o, n) {
30
30
  if (r.length === 0) return t;
31
31
  switch (n) {
32
32
  case "insert":
33
- return w(t, r, e, o);
33
+ return b(t, r, e, o);
34
34
  case "upsert":
35
- return S(t, r, e, o);
35
+ return w(t, r, e, o);
36
36
  }
37
37
  }
38
- function w(t, r, e, o) {
39
- const n = new Set(t.map(e)), i = r.filter((s) => {
40
- const a = e(s);
38
+ function b(t, r, e, o) {
39
+ const n = new Set(t.map(e)), s = r.filter((i) => {
40
+ const a = e(i);
41
41
  return n.has(a) ? !1 : (n.add(a), !0);
42
42
  });
43
- return i.length === 0 ? t : o === "prepend" ? [...i, ...t] : [...t, ...i];
43
+ return s.length === 0 ? t : o === "prepend" ? [...s, ...t] : [...t, ...s];
44
44
  }
45
- function S(t, r, e, o) {
45
+ function w(t, r, e, o) {
46
46
  const n = /* @__PURE__ */ new Map();
47
- t.forEach((u, c) => n.set(e(u), c));
48
- let i = !1;
49
- const s = t.slice();
47
+ t.forEach((u, f) => n.set(e(u), f));
48
+ let s = !1;
49
+ const i = t.slice();
50
50
  for (const u of r) {
51
- const c = e(u), f = n.get(c);
52
- f !== void 0 && s[f] !== u && (s[f] = u, i = !0);
51
+ const f = e(u), c = n.get(f);
52
+ c !== void 0 && i[c] !== u && (i[c] = u, s = !0);
53
53
  }
54
54
  const a = [];
55
55
  for (const u of r) {
56
- const c = e(u);
57
- n.has(c) || a.push(u);
56
+ const f = e(u);
57
+ n.has(f) || a.push(u);
58
58
  }
59
- return a.length > 0 ? (i = !0, o === "prepend" ? [...a, ...s] : [...s, ...a]) : i ? s : t;
59
+ return a.length > 0 ? (s = !0, o === "prepend" ? [...a, ...i] : [...i, ...a]) : s ? i : t;
60
60
  }
61
61
  function H(t, r, e) {
62
62
  let o = !1;
63
- const n = t.filter((i) => {
64
- const s = !r.has(e(i));
65
- return s || (o = !0), s;
63
+ const n = t.filter((s) => {
64
+ const i = !r.has(e(s));
65
+ return i || (o = !0), i;
66
66
  });
67
67
  return o ? n : t;
68
68
  }
69
69
  const V = (t, r) => {
70
70
  const e = t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*[\d.]+)?\)/);
71
71
  if (e) {
72
- const [, o, n, i] = e;
73
- return `rgba(${o}, ${n}, ${i}, ${r})`;
72
+ const [, o, n, s] = e;
73
+ return `rgba(${o}, ${n}, ${s}, ${r})`;
74
74
  }
75
- return b(t, r);
75
+ return S(t, r);
76
76
  }, K = (t, r) => {
77
77
  if (t.startsWith("rgba")) return t;
78
78
  const e = t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
79
79
  if (e) {
80
- const [, o, n, i] = e;
81
- return `rgba(${o}, ${n}, ${i}, ${r})`;
80
+ const [, o, n, s] = e;
81
+ return `rgba(${o}, ${n}, ${s}, ${r})`;
82
82
  }
83
83
  return console.warn("Invalid RGB color format:", t), t;
84
- }, b = (t, r) => {
84
+ }, S = (t, r) => {
85
85
  if (t.indexOf("rgb") !== -1) return t;
86
86
  let e = 0, o = 0, n = 0;
87
87
  return t.startsWith("#") && (t = t.slice(1)), t.length === 3 ? (e = parseInt(t[0] + t[0], 16), o = parseInt(t[1] + t[1], 16), n = parseInt(t[2] + t[2], 16)) : t.length === 6 ? (e = parseInt(t.slice(0, 2), 16), o = parseInt(t.slice(2, 4), 16), n = parseInt(t.slice(4, 6), 16)) : console.warn("Unsupported HEX color format"), `rgba(${e}, ${o}, ${n}, ${r})`;
88
- }, Y = (t, r, e) => {
89
- const o = (f) => {
90
- const g = f.match(/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);
91
- if (g) return [
92
- parseInt(g[1], 16),
93
- parseInt(g[2], 16),
94
- parseInt(g[3], 16)
88
+ }, O = (t, r, e) => {
89
+ const o = (c) => {
90
+ const d = c.match(/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})$/i);
91
+ if (d) return [
92
+ parseInt(d[1], 16),
93
+ parseInt(d[2], 16),
94
+ parseInt(d[3], 16)
95
95
  ];
96
- const d = f.match(/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i);
97
- return d ? [
98
- parseInt(d[1]),
99
- parseInt(d[2]),
100
- parseInt(d[3])
96
+ const l = c.match(/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i);
97
+ return l ? [
98
+ parseInt(l[1]),
99
+ parseInt(l[2]),
100
+ parseInt(l[3])
101
101
  ] : [
102
102
  0,
103
103
  0,
104
104
  0
105
105
  ];
106
- }, [n, i, s] = o(t), [a, u, c] = o(r);
107
- return `rgb(${Math.round(n + (a - n) * e)}, ${Math.round(i + (u - i) * e)}, ${Math.round(s + (c - s) * e)})`;
108
- }, _ = (t) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
109
- function O(t) {
106
+ }, [n, s, i] = o(t), [a, u, f] = o(r);
107
+ return `rgb(${Math.round(n + (a - n) * e)}, ${Math.round(s + (u - s) * e)}, ${Math.round(i + (f - i) * e)})`;
108
+ }, Y = (t) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t);
109
+ function _(t) {
110
110
  return typeof t == "string" ? t : t == null ? "" : typeof t == "number" || typeof t == "boolean" ? String(t) : Array.isArray(t) ? t.map((r) => String(r)).join(", ") : typeof t == "object" ? JSON.stringify(t) : String(t);
111
111
  }
112
112
  function W(t) {
113
113
  return t == null ? "" : typeof t == "number" ? Number.isFinite(t) ? String(t) : "" : typeof t == "string" ? t : typeof t == "boolean" ? t ? "1" : "0" : Array.isArray(t) && t.length > 0 ? String(t[0]) : "";
114
114
  }
115
115
  function q(t, r, ...e) {
116
- const o = {}, n = Array.isArray(r) ? r : [r, ...e], i = new Set(n);
117
- for (const s of Object.keys(t)) i.has(s) || (o[s] = t[s]);
116
+ const o = {}, n = Array.isArray(r) ? r : [r, ...e], s = new Set(n);
117
+ for (const i of Object.keys(t)) s.has(i) || (o[i] = t[i]);
118
118
  return o;
119
119
  }
120
- var l = m.getInstance();
121
- const G = (t) => l.parseAndKeepRawInput(t).getCountryCode(), J = (t) => {
120
+ var g = m.getInstance();
121
+ const G = (t) => g.parseAndKeepRawInput(t).getCountryCode(), J = (t) => {
122
122
  if (!t || !t.replace(/\D/g, "").length) return !1;
123
123
  try {
124
- const r = l.parseAndKeepRawInput(t);
125
- return l.isValidNumber(r);
124
+ const r = g.parseAndKeepRawInput(t);
125
+ return g.isValidNumber(r);
126
126
  } catch {
127
127
  return !1;
128
128
  }
129
- }, I = (t) => [t, null], M = (t) => [null, t instanceof Error ? t : new Error(String(t))];
130
- async function A(t, r) {
129
+ }, N = (t) => [t, null], I = (t) => [null, t instanceof Error ? t : new Error(String(t))];
130
+ async function M(t, r) {
131
131
  try {
132
- return I(await h(async (e, o) => {
132
+ return N(await h(async (e, o) => {
133
133
  try {
134
134
  return await t(e, o);
135
135
  } catch (n) {
@@ -137,41 +137,67 @@ async function A(t, r) {
137
137
  }
138
138
  }, r));
139
139
  } catch (e) {
140
- return M(e);
140
+ return I(e);
141
141
  }
142
142
  }
143
143
  async function z(t, r, e) {
144
- return A(async (o, n) => {
145
- const i = await t();
146
- if (!r(i)) throw new Error("Condition not satisfied");
147
- return i;
144
+ return M(async (o, n) => {
145
+ const s = await t();
146
+ if (!r(s)) throw new Error("Condition not satisfied");
147
+ return s;
148
148
  }, e);
149
149
  }
150
150
  function L(t) {
151
151
  return Math.round(Number(t) * 100);
152
152
  }
153
- function D(t) {
153
+ function A(t) {
154
154
  return (Number(t) / 100).toFixed(2);
155
155
  }
156
156
  function X(t) {
157
- return Number(D(t));
157
+ return Number(A(t));
158
158
  }
159
- function x(t) {
159
+ function Z(t) {
160
160
  return t < 1e3 ? t.toString() : t < 1e6 ? `${(t / 1e3).toFixed(1).replace(/\.0$/, "")}k+` : t < 1e9 ? `${(t / 1e6).toFixed(1).replace(/\.0$/, "")}M+` : `${(t / 1e9).toFixed(1).replace(/\.0$/, "")}B+`;
161
161
  }
162
- function Q(t) {
162
+ function x(t) {
163
163
  let r = null;
164
164
  return async (...e) => r || (r = t(...e).finally(() => r = null), r);
165
165
  }
166
- function Z(t, r) {
166
+ function Q(t, r) {
167
167
  const e = /* @__PURE__ */ new Map();
168
168
  return async (...o) => {
169
- const n = r(...o), i = e.get(n);
170
- if (i) return i;
171
- const s = t(...o).finally(() => e.delete(n));
172
- return e.set(n, s), s;
169
+ const n = r(...o), s = e.get(n);
170
+ if (s) return s;
171
+ const i = t(...o).finally(() => e.delete(n));
172
+ return e.set(n, i), i;
173
173
  };
174
174
  }
175
+ function v(t) {
176
+ return t === void 0 ? null : t;
177
+ }
178
+ function tt(t) {
179
+ return t ?? void 0;
180
+ }
181
+ function rt(t) {
182
+ return t === "" ? void 0 : t;
183
+ }
184
+ function et(t, r) {
185
+ return t ?? r ?? [];
186
+ }
187
+ function nt(t) {
188
+ return t ?? 0;
189
+ }
190
+ function ot(t) {
191
+ return t == null || t === "" ? "" : t;
192
+ }
193
+ function it(t, r) {
194
+ return t ?? r;
195
+ }
196
+ function st(t) {
197
+ if (t == null) return;
198
+ const r = Number(t);
199
+ return Number.isNaN(r) ? void 0 : r;
200
+ }
175
201
  function p(t, r) {
176
202
  if (Object.is(t, r)) return !0;
177
203
  if (typeof t != typeof r) return !1;
@@ -179,33 +205,33 @@ function p(t, r) {
179
205
  const e = Array.isArray(t), o = Array.isArray(r);
180
206
  if (e !== o) return !1;
181
207
  if (e && o)
182
- return t.length !== r.length ? !1 : t.every((s, a) => p(s, r[a]));
183
- const n = Object.keys(t).sort(), i = Object.keys(r).sort();
184
- return n.length !== i.length || !n.every((s, a) => s === i[a]) ? !1 : n.every((s) => p(t[s], r[s]));
208
+ return t.length !== r.length ? !1 : t.every((i, a) => p(i, r[a]));
209
+ const n = Object.keys(t).sort(), s = Object.keys(r).sort();
210
+ return n.length !== s.length || !n.every((i, a) => i === s[a]) ? !1 : n.every((i) => p(t[i], r[i]));
185
211
  }
186
- const v = (t) => {
212
+ const at = (t) => {
187
213
  let r, e = [];
188
214
  return new Proxy(t, { construct(o, n) {
189
215
  if (r || (r = new t(...n), e = n), !p(n, e)) throw new Error("Cannot create multiple instances with different parameters");
190
216
  return r;
191
217
  } });
192
218
  };
193
- function tt(t, r = 100) {
219
+ function ut(t, r = 100) {
194
220
  if (t == null) throw new Promise((e) => setTimeout(e, r));
195
221
  return t;
196
222
  }
197
- const rt = (t) => {
223
+ const ft = (t) => {
198
224
  if (!t) return "";
199
225
  const r = new Date(t);
200
226
  return isNaN(r.getTime()) ? "" : `${r.getFullYear()}/${(r.getMonth() + 1).toString().padStart(2, "0")}/${r.getDate().toString().padStart(2, "0")}`;
201
- }, et = (t) => {
227
+ }, ct = (t) => {
202
228
  if (!t) return "Unknown";
203
229
  const r = new Date(t);
204
230
  if (isNaN(r.getTime())) return "Invalid date";
205
- const e = (/* @__PURE__ */ new Date()).getTime() - r.getTime(), o = Math.floor(e / 1e3), n = Math.floor(o / 60), i = Math.floor(n / 60), s = Math.floor(i / 24), a = Math.floor(s / 30), u = Math.floor(s / 365);
206
- return u > 0 ? `${u} year${u > 1 ? "s" : ""} ago` : a > 0 ? `${a} month${a > 1 ? "s" : ""} ago` : s > 0 ? `${s} day${s > 1 ? "s" : ""} ago` : i > 0 ? `${i} hour${i > 1 ? "s" : ""} ago` : n > 0 ? `${n} minute${n > 1 ? "s" : ""} ago` : "Just now";
231
+ const e = (/* @__PURE__ */ new Date()).getTime() - r.getTime(), o = Math.floor(e / 1e3), n = Math.floor(o / 60), s = Math.floor(n / 60), i = Math.floor(s / 24), a = Math.floor(i / 30), u = Math.floor(i / 365);
232
+ return u > 0 ? `${u} year${u > 1 ? "s" : ""} ago` : a > 0 ? `${a} month${a > 1 ? "s" : ""} ago` : i > 0 ? `${i} day${i > 1 ? "s" : ""} ago` : s > 0 ? `${s} hour${s > 1 ? "s" : ""} ago` : n > 0 ? `${n} minute${n > 1 ? "s" : ""} ago` : "Just now";
207
233
  };
208
- function nt(t) {
234
+ function dt(t) {
209
235
  try {
210
236
  return new Date(t).toLocaleDateString(void 0, {
211
237
  month: "short",
@@ -217,28 +243,28 @@ function nt(t) {
217
243
  return t;
218
244
  }
219
245
  }
220
- const ot = (t) => {
246
+ const lt = (t) => {
221
247
  try {
222
248
  const r = new Date(t);
223
249
  return isNaN(r.getTime()) ? t : `${r.getFullYear()}/${String(r.getMonth() + 1).padStart(2, "0")}/${String(r.getDate()).padStart(2, "0")} ${String(r.getHours()).padStart(2, "0")}:${String(r.getMinutes()).padStart(2, "0")}`;
224
250
  } catch {
225
251
  return t;
226
252
  }
227
- }, st = (t) => {
253
+ }, gt = (t) => {
228
254
  try {
229
255
  const r = new Date(t);
230
256
  return isNaN(r.getTime()) ? t : `${String(r.getMonth() + 1).padStart(2, "0")}/${String(r.getDate()).padStart(2, "0")} ${String(r.getHours()).padStart(2, "0")}:${String(r.getMinutes()).padStart(2, "0")}`;
231
257
  } catch {
232
258
  return t;
233
259
  }
234
- }, it = (t) => {
260
+ }, pt = (t) => {
235
261
  try {
236
262
  const r = new Date(t);
237
263
  return isNaN(r.getTime()) ? t : `${r.getFullYear()}/${String(r.getMonth() + 1).padStart(2, "0")}/${String(r.getDate()).padStart(2, "0")}`;
238
264
  } catch {
239
265
  return t;
240
266
  }
241
- }, at = (t) => {
267
+ }, yt = (t) => {
242
268
  try {
243
269
  const r = new Date(t);
244
270
  return isNaN(r.getTime()) ? t : `${String(r.getHours()).padStart(2, "0")}:${String(r.getMinutes()).padStart(2, "0")}`;
@@ -246,48 +272,56 @@ const ot = (t) => {
246
272
  return t;
247
273
  }
248
274
  };
249
- function ut(t, r) {
275
+ function mt(t, r) {
250
276
  return t.reduce((e, o, n) => (e[o] = r ? r(o, n) : o, e), {});
251
277
  }
252
278
  export {
253
- ut as createMap,
254
- M as err,
255
- it as formatDate,
256
- ot as formatDateTime,
257
- rt as formatDisplayDate,
258
- st as formatMonthDayTime,
259
- x as formatNumberAbbreviated,
260
- et as formatRelativeTime,
261
- nt as formatTickDate,
262
- at as formatTime,
279
+ mt as createMap,
280
+ I as err,
281
+ pt as formatDate,
282
+ lt as formatDateTime,
283
+ ft as formatDisplayDate,
284
+ gt as formatMonthDayTime,
285
+ Z as formatNumberAbbreviated,
286
+ ct as formatRelativeTime,
287
+ dt as formatTickDate,
288
+ yt as formatTime,
263
289
  $ as getApiError,
264
290
  P as getApiErrorMessage,
265
291
  G as getCountryCode,
266
292
  E as getItem,
267
- b as hexToRGBA,
268
- Y as interpolateColor,
269
- _ as isValidEmail,
293
+ S as hexToRGBA,
294
+ O as interpolateColor,
295
+ Y as isValidEmail,
270
296
  J as isValidPhoneNumber,
271
297
  U as mergeById,
272
298
  F as normalizeAddress,
273
- I as ok,
299
+ N as ok,
274
300
  q as omit,
275
- Q as onceAsync,
276
- Z as onceAsyncByKey,
301
+ x as onceAsync,
302
+ Q as onceAsyncByKey,
277
303
  z as pollUntil,
278
304
  H as pruneArray,
279
305
  T as removeItem,
280
306
  K as rgbToRgba,
307
+ et as safeArray,
308
+ tt as safeMaybe,
309
+ rt as safeNilable,
310
+ v as safeNullable,
311
+ st as safeNum,
312
+ it as safeOr,
313
+ ot as safeStringable,
314
+ nt as safeZeroable,
281
315
  C as setItem,
282
- v as singleton,
283
- tt as suspenseIfNull,
316
+ at as singleton,
317
+ ut as suspenseIfNull,
284
318
  L as toDatabasePrice,
285
- D as toDisplayPrice,
319
+ A as toDisplayPrice,
286
320
  X as toDisplayPriceNumber,
287
321
  W as toNumberInputValue,
288
322
  V as toRgbaWithAlpha,
289
- O as toTextInputValue,
290
- A as withRetryResult
323
+ _ as toTextInputValue,
324
+ M as withRetryResult
291
325
  };
292
326
 
293
327
  //# sourceMappingURL=utils.mjs.map