@ai-matrx/vault 0.1.41 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2764,7 +2764,6 @@ function positiveKnob(resolved, key) {
2764
2764
  }
2765
2765
 
2766
2766
  // src/organizations.ts
2767
- import { shortUuid } from "@ai-matrx/design-system/record-id-format";
2768
2767
  function orderOrganizations(orgs, items, recentItemIds) {
2769
2768
  const counts = /* @__PURE__ */ new Map();
2770
2769
  for (const i of items) if (i.owner.organizationId) counts.set(i.owner.organizationId, (counts.get(i.owner.organizationId) ?? 0) + 1);
@@ -2778,9 +2777,22 @@ function orderOrganizations(orgs, items, recentItemIds) {
2778
2777
  return [...orgs].sort((a, b) => group(a) - group(b) || (recent.get(a.id) ?? 0) - (recent.get(b.id) ?? 0) || a.name.localeCompare(b.name, void 0, { sensitivity: "base" }) || a.id.localeCompare(b.id));
2779
2778
  }
2780
2779
  function organizationHints(orgs) {
2781
- const seen = /* @__PURE__ */ new Map();
2782
- for (const o of orgs) seen.set(o.name.trim().toLowerCase(), (seen.get(o.name.trim().toLowerCase()) ?? 0) + 1);
2783
- return new Map(orgs.filter((o) => (seen.get(o.name.trim().toLowerCase()) ?? 0) > 1).map((o) => [o.id, shortUuid(o.id)]));
2780
+ const groups = /* @__PURE__ */ new Map();
2781
+ for (const o of orgs) {
2782
+ const key = o.name.trim().toLowerCase();
2783
+ groups.set(key, [...groups.get(key) ?? [], o]);
2784
+ }
2785
+ const hints = /* @__PURE__ */ new Map();
2786
+ for (const group of groups.values()) {
2787
+ if (group.length < 2) continue;
2788
+ const longest = Math.max(...group.map((o) => o.id.length));
2789
+ const fragment = (o, n2) => o.id.slice(0, n2);
2790
+ let n = 8;
2791
+ while (n < longest && new Set(group.map((o) => fragment(o, n))).size < group.length) n += 1;
2792
+ const useSuffix = new Set(group.map((o) => fragment(o, n))).size < group.length;
2793
+ for (const o of group) hints.set(o.id, useSuffix ? o.id.slice(-8) : fragment(o, n));
2794
+ }
2795
+ return hints;
2784
2796
  }
2785
2797
 
2786
2798
  // src/shown-until-move.ts