@object-ui/plugin-detail 4.0.6 → 4.0.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @object-ui/plugin-detail
2
2
 
3
+ ## 4.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 7c9b85c: Fix compatibility with the framework's normalized Expression envelope format.
8
+
9
+ `@objectstack/spec` now emits predicate (`visible` / `enabled`) and template
10
+ (`titleFormat`) fields as `{ dialect, source }` envelopes instead of bare
11
+ strings. The previous implementation assumed strings and crashed the record
12
+ detail view (`TypeError: titleFormat.replace is not a function`) and printed
13
+ `Failed to evaluate expression: ${[object Object]}` for every action visibility
14
+ predicate.
15
+ - `@object-ui/core`: `ExpressionEvaluator.evaluate` / `evaluateCondition` now
16
+ unwrap Expression envelopes transparently.
17
+ - `@object-ui/react`: new `toPredicateInput()` helper to safely normalize
18
+ `boolean | string | Expression` predicate inputs into the `${expr}` form
19
+ expected by `useCondition`.
20
+ - `@object-ui/components`: `action-bar`, `action-button`, `action-group`,
21
+ `action-icon`, `action-menu` renderers use `toPredicateInput()` instead of
22
+ template-literal interpolation that produced `${[object Object]}`.
23
+ - `@object-ui/plugin-detail`, `@object-ui/plugin-kanban`,
24
+ `@object-ui/plugin-calendar`, `@object-ui/app-shell`,
25
+ `@object-ui/console`: title-format helpers accept both legacy strings and
26
+ the new `{ source }` envelope.
27
+
28
+ All changes are backward-compatible — legacy bare strings continue to work.
29
+
3
30
  ## 4.0.6
4
31
 
5
32
  ## 4.0.5
package/dist/index.js CHANGED
@@ -1033,14 +1033,14 @@ function rt(e, t, n, r) {
1033
1033
  let n = e[t.primaryField];
1034
1034
  if (n != null && n !== "") return String(n);
1035
1035
  }
1036
- let r = n?.titleFormat;
1037
- if (r) {
1038
- let t = "[-\\u2013\\u2014|/·,:]", n = !1, i = r.replace(/\{([^{}]+)\}/g, (t, r) => {
1036
+ let r = n?.titleFormat, i = typeof r == "string" ? r : r && typeof r == "object" && typeof r.source == "string" ? r.source : void 0;
1037
+ if (i) {
1038
+ let t = "[-\\u2013\\u2014|/·,:]", n = !1, r = i.replace(/\{([^{}]+)\}/g, (t, r) => {
1039
1039
  let i = e[r.trim()];
1040
1040
  return i != null && i !== "" ? (n = !0, String(i)) : "\0";
1041
1041
  });
1042
1042
  if (n) {
1043
- let e = i.replace(RegExp(`\\s*${t}\\s*`, "g"), "").replace(RegExp(`\\s*${t}\\s*`, "g"), "").replace(RegExp("\0", "g"), "").replace(/\s+/g, " ").trim();
1043
+ let e = r.replace(RegExp(`\\s*${t}\\s*`, "g"), "").replace(RegExp(`\\s*${t}\\s*`, "g"), "").replace(RegExp("\0", "g"), "").replace(/\s+/g, " ").trim();
1044
1044
  if (e) return e;
1045
1045
  }
1046
1046
  }
@@ -1168,14 +1168,8 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1168
1168
  console.log("Link copied to clipboard");
1169
1169
  });
1170
1170
  }, [e]), ce = n.useCallback(() => {
1171
- console.log("Duplicate record:", D);
1172
- }, [D]), K = n.useCallback(() => {
1173
- console.log("Export record:", D);
1174
- }, [D]), q = n.useCallback(() => {
1175
- console.log("View history for record:", e.resourceId);
1176
- }, [e]), J = n.useCallback(() => {
1177
1171
  M(!j);
1178
- }, [j]), le = n.useCallback(() => {
1172
+ }, [j]), K = n.useCallback(() => {
1179
1173
  if (N) {
1180
1174
  let e = Object.entries(I);
1181
1175
  if (e.length > 0) {
@@ -1195,7 +1189,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1195
1189
  I,
1196
1190
  D,
1197
1191
  d
1198
- ]), Y = n.useCallback((e, t) => {
1192
+ ]), q = n.useCallback((e, t) => {
1199
1193
  R((n) => ({
1200
1194
  ...n,
1201
1195
  [e]: t
@@ -1209,7 +1203,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1209
1203
  };
1210
1204
  return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
1211
1205
  }, [e.recordNavigation]);
1212
- let ue = n.useMemo(() => {
1206
+ let J = n.useMemo(() => {
1213
1207
  if (!e.autoDiscoverRelated || !z?.fields || e.related && e.related.length > 0) return [];
1214
1208
  let t = [], n = z.fields;
1215
1209
  for (let [e, r] of Object.entries(n)) {
@@ -1226,15 +1220,15 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1226
1220
  e.autoDiscoverRelated,
1227
1221
  e.related,
1228
1222
  z
1229
- ]), de = n.useMemo(() => e.related && e.related.length > 0 ? e.related : ue.map((e) => ({
1223
+ ]), le = n.useMemo(() => e.related && e.related.length > 0 ? e.related : J.map((e) => ({
1230
1224
  title: e.title,
1231
1225
  type: e.type,
1232
1226
  api: e.objectName,
1233
1227
  data: [],
1234
1228
  referenceField: e.referenceField
1235
- })), [e.related, ue]), fe = n.useMemo(() => {
1229
+ })), [e.related, J]), Y = n.useMemo(() => {
1236
1230
  let t = [];
1237
- t.push({
1231
+ return t.push({
1238
1232
  name: "sys_share",
1239
1233
  label: U("detail.share"),
1240
1234
  icon: "share-2",
@@ -1253,28 +1247,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1253
1247
  icon: "edit",
1254
1248
  type: "script",
1255
1249
  className: "sm:hidden",
1256
- onClick: le
1257
- });
1258
- let n = t.length > 0 ? ["separator-before"] : void 0;
1259
- return t.push({
1260
- name: "sys_duplicate",
1261
- label: U("detail.duplicate"),
1262
- icon: "copy",
1263
- type: "script",
1264
- ...n && { tags: n },
1265
- onClick: ce
1266
- }), t.push({
1267
- name: "sys_export",
1268
- label: U("detail.export"),
1269
- icon: "download",
1270
- type: "script",
1271
1250
  onClick: K
1272
- }), t.push({
1273
- name: "sys_view_history",
1274
- label: U("detail.viewHistory"),
1275
- icon: "history",
1276
- type: "script",
1277
- onClick: q
1278
1251
  }), e.showDelete && t.push({
1279
1252
  name: "sys_delete",
1280
1253
  label: U("detail.delete"),
@@ -1292,14 +1265,11 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1292
1265
  N,
1293
1266
  G,
1294
1267
  W,
1295
- le,
1296
- ce,
1297
1268
  K,
1298
- q,
1299
1269
  se
1300
- ]), pe = n.useMemo(() => {
1270
+ ]), ue = n.useMemo(() => {
1301
1271
  let t = e.actions ?? [];
1302
- if (fe.length === 0) return t;
1272
+ if (Y.length === 0) return t;
1303
1273
  let n = !1, r = t.map((e) => {
1304
1274
  let t = e;
1305
1275
  if (t && typeof t == "object" && t.type === "action:bar" && (!t.location || t.location === "record_header")) {
@@ -1307,7 +1277,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1307
1277
  let e = Array.isArray(t.systemActions) ? t.systemActions : [];
1308
1278
  return {
1309
1279
  ...t,
1310
- systemActions: [...e, ...fe]
1280
+ systemActions: [...e, ...Y]
1311
1281
  };
1312
1282
  }
1313
1283
  return e;
@@ -1315,9 +1285,9 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1315
1285
  return n || r.push({
1316
1286
  type: "action:bar",
1317
1287
  location: "record_header",
1318
- systemActions: fe
1288
+ systemActions: Y
1319
1289
  }), r;
1320
- }, [e.actions, fe]);
1290
+ }, [e.actions, Y]);
1321
1291
  return k || e.loading ? /* @__PURE__ */ Q("div", {
1322
1292
  className: S("space-y-4", o),
1323
1293
  children: [
@@ -1421,7 +1391,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1421
1391
  variant: "ghost",
1422
1392
  size: "icon",
1423
1393
  className: "h-6 w-6 shrink-0",
1424
- onClick: J,
1394
+ onClick: ce,
1425
1395
  "aria-label": U(j ? "detail.removeFromFavorites" : "detail.addToFavorites"),
1426
1396
  children: j ? /* @__PURE__ */ Z(Ce, { className: "h-4 w-4 fill-yellow-400 text-yellow-400" }) : /* @__PURE__ */ Z(we, { className: "h-4 w-4 text-muted-foreground" })
1427
1397
  })
@@ -1488,7 +1458,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1488
1458
  }), /* @__PURE__ */ Z(y, { children: U("detail.nextRecord") })] })
1489
1459
  ]
1490
1460
  }),
1491
- pe.map((e, t) => /* @__PURE__ */ Z(Ae, {
1461
+ ue.map((e, t) => /* @__PURE__ */ Z(Ae, {
1492
1462
  schema: e,
1493
1463
  data: D
1494
1464
  }, t)),
@@ -1497,7 +1467,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1497
1467
  children: /* @__PURE__ */ Z(i, {
1498
1468
  variant: N ? "default" : "outline",
1499
1469
  size: "sm",
1500
- onClick: le,
1470
+ onClick: K,
1501
1471
  className: "gap-2 hidden sm:inline-flex",
1502
1472
  children: N ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(P, { className: "h-4 w-4" }), /* @__PURE__ */ Z("span", {
1503
1473
  className: "hidden sm:inline",
@@ -1534,7 +1504,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1534
1504
  objectSchema: z
1535
1505
  }),
1536
1506
  e.autoTabs && !e.tabs?.length ? (() => {
1537
- let t = de.length > 0, n = !!e.activities && e.activities.length > 0, i = !!f, o = /* @__PURE__ */ Q("div", {
1507
+ let t = le.length > 0, n = !!e.activities && e.activities.length > 0, i = !!f, o = /* @__PURE__ */ Q("div", {
1538
1508
  className: "space-y-3 sm:space-y-4",
1539
1509
  children: [
1540
1510
  e.sectionGroups && e.sectionGroups.length > 0 && e.sectionGroups.map((t, n) => /* @__PURE__ */ Z(Ke, {
@@ -1546,7 +1516,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1546
1516
  objectSchema: z,
1547
1517
  objectName: e.objectName,
1548
1518
  isEditing: N,
1549
- onFieldChange: Y
1519
+ onFieldChange: q
1550
1520
  }, n)),
1551
1521
  e.sections && e.sections.length > 0 && e.sections.map((t, n) => /* @__PURE__ */ Z(He, {
1552
1522
  section: t,
@@ -1557,7 +1527,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1557
1527
  objectSchema: z,
1558
1528
  objectName: e.objectName,
1559
1529
  isEditing: N,
1560
- onFieldChange: Y
1530
+ onFieldChange: q
1561
1531
  }, n)),
1562
1532
  e.fields && e.fields.length > 0 && !e.sections?.length && /* @__PURE__ */ Z(He, {
1563
1533
  section: {
@@ -1571,7 +1541,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1571
1541
  objectSchema: z,
1572
1542
  objectName: e.objectName,
1573
1543
  isEditing: N,
1574
- onFieldChange: Y
1544
+ onFieldChange: q
1575
1545
  }),
1576
1546
  e.comments && /* @__PURE__ */ Z(Ye, {
1577
1547
  comments: e.comments,
@@ -1602,7 +1572,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1602
1572
  children: [U("detail.related"), /* @__PURE__ */ Z(r, {
1603
1573
  variant: "secondary",
1604
1574
  className: "text-xs bg-primary/10 text-primary border-transparent",
1605
- children: de.length
1575
+ children: le.length
1606
1576
  })]
1607
1577
  })
1608
1578
  }),
@@ -1635,7 +1605,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1635
1605
  className: "mt-4",
1636
1606
  children: /* @__PURE__ */ Z("div", {
1637
1607
  className: "space-y-3",
1638
- children: de.map((e, t) => /* @__PURE__ */ Z(Ge, {
1608
+ children: le.map((e, t) => /* @__PURE__ */ Z(Ge, {
1639
1609
  title: e.title,
1640
1610
  type: e.type,
1641
1611
  api: e.api,
@@ -1674,7 +1644,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1674
1644
  objectSchema: z,
1675
1645
  objectName: e.objectName,
1676
1646
  isEditing: N,
1677
- onFieldChange: Y
1647
+ onFieldChange: q
1678
1648
  }, n))
1679
1649
  }),
1680
1650
  e.sections && e.sections.length > 0 && /* @__PURE__ */ Z("div", {
@@ -1688,7 +1658,7 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1688
1658
  objectSchema: z,
1689
1659
  objectName: e.objectName,
1690
1660
  isEditing: N,
1691
- onFieldChange: Y
1661
+ onFieldChange: q
1692
1662
  }, n))
1693
1663
  }),
1694
1664
  e.fields && e.fields.length > 0 && !e.sections?.length && /* @__PURE__ */ Z(He, {
@@ -1703,18 +1673,18 @@ var it = ({ schema: e, dataSource: a, className: o, onEdit: s, onDelete: c, onBa
1703
1673
  objectSchema: z,
1704
1674
  objectName: e.objectName,
1705
1675
  isEditing: N,
1706
- onFieldChange: Y
1676
+ onFieldChange: q
1707
1677
  }),
1708
1678
  e.tabs && e.tabs.length > 0 && /* @__PURE__ */ Z(Ue, {
1709
1679
  tabs: e.tabs,
1710
1680
  data: D
1711
1681
  }),
1712
- de.length > 0 && /* @__PURE__ */ Q("div", {
1682
+ le.length > 0 && /* @__PURE__ */ Q("div", {
1713
1683
  className: "space-y-3",
1714
1684
  children: [/* @__PURE__ */ Z("h2", {
1715
1685
  className: "text-lg font-semibold",
1716
1686
  children: U("detail.related")
1717
- }), de.map((e, t) => /* @__PURE__ */ Z(Ge, {
1687
+ }), le.map((e, t) => /* @__PURE__ */ Z(Ge, {
1718
1688
  title: e.title,
1719
1689
  type: e.type,
1720
1690
  api: e.api,
@@ -1,5 +1,5 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`@object-ui/react`),require(`@object-ui/fields`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`@object-ui/fields`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDetail={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.LucideReact,e.ObjectUIReact,e.ObjectUIFields,e.jsxRuntime))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var h=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function g(e){return h.has(e)}function _(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function v(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&g(e.type)?{...e,span:t}:e)}function y(e,t,n){if(t!==void 0)return{fields:v(e,t),columns:t};let r=_(e.length,n);return{fields:v(e,r),columns:r}}function b(e,t){return function(){try{let n=(0,a.useObjectTranslation)();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var x={"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit inline`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`},S=b(x,`detail.back`);function C(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var w=({section:e,data:t,className:c,objectSchema:l,objectName:u,isEditing:d=!1,onFieldChange:f,virtualScroll:p})=>{let[m,h]=n.useState(e.defaultCollapsed??!1),[g,_]=n.useState(null),[v,b]=n.useState(void 0),[x,w]=n.useState(!1),{t:T}=S(),{fieldLabel:E}=(0,a.useSafeFieldLabel)(),D=n.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{_(e),setTimeout(()=>_(null),2e3)})},[]),O=n.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),k=n.useMemo(()=>e.fields.filter(O).length,[e.fields,O]),A=(0,r.useIsMobile)(),j=A?3:6,M=A?.2:.5,N=e.fields.length-k,P=!e.hideEmpty&&!d&&e.fields.length>=j&&k/e.fields.length>=M&&N>0,F=!x&&(e.hideEmpty||P)?e.fields.filter(e=>!O(e)):e.fields;if(F.length===0&&k===e.fields.length)return null;let{fields:I,columns:L}=y(F,e.columns),R=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,s.jsx)(a.SchemaRenderer,{schema:e.render,data:{...t,value:n}});let c=C(e.span,L),p=(()=>{if(n==null)return(0,s.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=l?.fields?.[e.name],r=e.type||t?.type,i={...e};if(t){!e.type&&t.type&&(i.type=t.type),t.options&&!i.options&&(i.options=t.options),t.currency&&!i.currency&&(i.currency=t.currency),t.precision!==void 0&&i.precision===void 0&&(i.precision=t.precision),t.format&&!i.format&&(i.format=t.format);let n=t.reference_to||t.reference;n&&!i.reference_to&&(i.reference_to=n),t.reference_field&&!i.reference_field&&(i.reference_field=t.reference_field)}if(r){let e=(0,o.getCellRenderer)(r);if(e)return(0,s.jsx)(e,{value:n,field:i})}return String(n)})(),m=n!=null&&n!==``,h=g===e.name;return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-1.5 group`,c),children:[(0,s.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:E(u||``,e.name,e.label||e.name)}),d&&!e.readonly?(0,s.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,s.jsx)(`input`,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:n==null?``:String(n),onChange:t=>f?.(e.name,t.target.value)})}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,m&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:m?()=>D(e.name,n):void 0,onKeyDown:m?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),D(e.name,n))}:void 0,role:m?`button`:void 0,tabIndex:m?0:void 0,children:[(0,s.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:p}),m&&(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),D(e.name,n)},children:h?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:T(h?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},z=p?.enabled===!0,B=p?.batchSize??20;n.useEffect(()=>{if(!z){b(void 0);return}if(I.length<=B){b(void 0);return}b(B);let e=setTimeout(()=>b(void 0),100);return()=>clearTimeout(e)},[z,I.length,B]);let ee=v===void 0?I:I.slice(0,v),V=k>0&&(e.hideEmpty||P),H=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-3 sm:gap-4`,L===1?`grid-cols-1`:L===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:ee.map(R)}),V&&(0,s.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,s.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[x?(0,s.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}):(0,s.jsx)(i.Eye,{className:`h-3.5 w-3.5 mr-1.5`}),x?T(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):T(`detail.showEmptyFields`,{count:k,defaultValue:`Show ${k} empty field${k===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,s.jsx)(`div`,{className:(0,r.cn)(c),children:H}):e.collapsible?(0,s.jsx)(r.Collapsible,{open:!m,onOpenChange:e=>h(!e),className:c,children:(0,s.jsxs)(r.Card,{children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title}),e.fields&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:m?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!m&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})})]})}):(0,s.jsxs)(r.Card,{className:(0,r.cn)(e.showBorder===!1?`border-none shadow-none`:``,c),children:[e.title&&(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsx)(r.CardTitle,{className:`flex items-center justify-between`,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title})]})}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})]})},T=({tabs:e,data:t,className:i})=>{let[o,c]=n.useState(e[0]?.key),l=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,s.jsxs)(r.Tabs,{value:o,onValueChange:c,className:i,children:[(0,s.jsx)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:l.map(e=>(0,s.jsx)(r.TabsTrigger,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{children:e.icon}),(0,s.jsx)(`span`,{children:e.label}),e.badge&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),l.map(e=>(0,s.jsx)(r.TabsContent,{value:e.key,className:`mt-4`,children:(0,s.jsx)(n.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,s.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:t},n))}):(0,s.jsx)(a.SchemaRenderer,{schema:e.content,data:t})})},e.key))]})};function E(e){return e&&i.icons[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||i.Inbox}var D=({title:e,type:t,api:c,data:l=[],schema:u,columns:d,className:f,dataSource:p,objectName:m,onNew:h,onViewAll:g,onRowEdit:_,onRowDelete:v,pageSize:y,sortable:b=!1,filterable:x=!1,collapsible:C=!1,defaultCollapsed:w=!1,referenceField:T,icon:D})=>{let[O,k]=n.useState(l),[A,j]=n.useState(!1),[M,N]=n.useState(0),[P,F]=n.useState(null),[I,L]=n.useState(`asc`),[R,z]=n.useState(``),[B,ee]=n.useState(null),[V,H]=n.useState(w),{t:U}=S(),{fieldLabel:te}=(0,a.useSafeFieldLabel)();n.useEffect(()=>{k(l)},[l]),n.useEffect(()=>{c&&p?.getObjectSchema&&!d?.length&&p.getObjectSchema(c).then(ee).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${c}:`,e)})},[c,p,d]),n.useEffect(()=>{c&&!l.length&&(j(!0),p&&typeof p.find==`function`?p.find(c).then(e=>{k(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),j(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),j(!1)}):fetch(c).then(e=>e.json()).then(e=>{k(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>j(!1)))},[c,l,p]);let W=n.useMemo(()=>{if(!R)return O;let e=R.toLowerCase();return O.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[O,R]),G=n.useMemo(()=>P?[...W].sort((e,t)=>{let n=e[P],r=t[P];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return I===`asc`?i:-i}):W,[W,P,I]),K=y&&y>0?y:0,q=K?Math.max(1,Math.ceil(G.length/K)):1,J=K?G.slice(M*K,(M+1)*K):G;n.useEffect(()=>{N(0)},[R,P,I]);let Y=n.useCallback(e=>{P===e?L(e=>e===`asc`?`desc`:`asc`):(F(e),L(`asc`))},[P]),ne=n.useCallback(e=>{window.confirm(U(`detail.deleteRowConfirmation`))&&v?.(e)},[v,U]),X=n.useMemo(()=>{let e=e=>T?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==T):e;if(d&&d.length>0)return e(d);if(!B?.fields)return[];let t=m||c||``;return Object.entries(B.fields).filter(([e])=>!e.startsWith(`_`)&&e!==`id`&&e!==T).map(([e,r])=>{let i={accessorKey:e,header:te(t,e,r.label||e)};if(r.type){let t=(0,o.getCellRenderer)(r.type);if(t){let a={name:e,label:r.label||e,type:r.type,...r.options&&{options:r.options},...r.currency&&{currency:r.currency},...r.precision!==void 0&&{precision:r.precision},...r.format&&{format:r.format},...(r.reference_to||r.reference)&&{reference_to:r.reference_to||r.reference},...r.reference_field&&{reference_field:r.reference_field}};i.cell=e=>e==null?n.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):n.createElement(t,{value:e,field:a})}}return i})},[d,B,m,c,te,T]),re=n.useMemo(()=>{if(u)return u;switch(t){case`grid`:case`table`:return{type:`data-table`,data:J,columns:X,pagination:!1,pageSize:K||10,searchable:!1,exportable:!1};case`list`:return{type:`data-list`,data:J};default:return{type:`div`,children:`No view configured`}}},[t,J,X,u,K]),Z=!!_||!!v,ie=C?`cursor-pointer select-none`:void 0,Q=C?()=>H(e=>!e):void 0,$=E(D),ae=!A&&O.length===0,oe=x;return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`shadow-none`,ae&&`bg-muted/20`,f),children:[(0,s.jsx)(r.CardHeader,{className:(0,r.cn)(`py-3 px-4`,ie),onClick:Q,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[C&&(V?(0,s.jsx)(i.ChevronRight,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,s.jsx)($,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,s.jsx)(`span`,{className:`truncate`,children:e}),(0,s.jsx)(r.Badge,{variant:`secondary`,className:(0,r.cn)(`text-xs font-normal h-5 px-1.5`,O.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${O.length} records`,children:O.length})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[h&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),h()},className:`gap-1 h-7 text-xs`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),U(`detail.new`)]}),g&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),g()},className:`gap-1 h-7 text-xs`,children:[U(`detail.viewAll`),(0,s.jsx)(i.ExternalLink,{className:`h-3 w-3`})]})]})]})}),!V&&(0,s.jsxs)(r.CardContent,{className:(0,r.cn)(`pt-0`,ae?`pb-3 px-4`:`pb-4 px-4`),children:[oe&&(0,s.jsx)(`div`,{className:`mb-3`,children:(0,s.jsx)(r.Input,{placeholder:U(`detail.filterPlaceholder`),value:R,onChange:e=>z(e.target.value),className:`h-8 text-sm`})}),b&&X&&X.length>0&&O.length>0&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:X.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,a=P===t;return(0,s.jsxs)(r.Button,{variant:a?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Y(t),children:[(0,s.jsx)(i.ArrowUpDown,{className:`h-3 w-3`}),n,a&&(I===`asc`?` ↑`:` ↓`)]},t)})}),A?(0,s.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:U(`detail.loading`)}):ae?(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-2 text-sm`,children:[(0,s.jsx)(`span`,{className:`text-muted-foreground italic`,children:U(`detail.noRelatedRecords`)}),h===void 0&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground/70`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.SchemaRenderer,{schema:re}),Z&&J.length>0&&(0,s.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`row-actions`,children:J.map((e,t)=>(0,s.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 text-xs border-b last:border-b-0`,children:[(0,s.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.name||e.title||e.id||`Row ${t+1}`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2`,onClick:()=>_(e),children:[(0,s.jsx)(i.Edit,{className:`h-3 w-3`}),U(`detail.editRow`)]}),v&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2 text-destructive hover:text-destructive`,onClick:()=>ne(e),children:[(0,s.jsx)(i.Trash2,{className:`h-3 w-3`}),U(`detail.deleteRow`)]})]})]},e.id||t))})]}),K>0&&G.length>K&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:M===0,onClick:()=>N(e=>Math.max(0,e-1)),children:[(0,s.jsx)(i.ChevronLeft,{className:`h-3 w-3`}),U(`detail.previousPage`)]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:U(`detail.pageOf`,{current:M+1,total:q})}),(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:M>=q-1,onClick:()=>N(e=>Math.min(q-1,e+1)),children:[U(`detail.nextPage`),(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`})]})]})]})]})},O=({group:e,data:t,className:a,objectSchema:o,objectName:c,isEditing:l=!1,onFieldChange:u})=>{let d=e.collapsible??!0,[f,p]=n.useState(e.defaultCollapsed??!1),m=(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,s.jsx)(w,{section:e,data:t,objectSchema:o,objectName:c,isEditing:l,onFieldChange:u},n))});return d?(0,s.jsxs)(r.Collapsible,{open:!f,onOpenChange:e=>p(!e),className:a,children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[f?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!f&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(`div`,{className:`mt-3`,children:m})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-3`,a),children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),m]})},k=({fields:e,data:t,className:n,objectName:i,objectSchema:c})=>{let{fieldLabel:l}=(0,a.useSafeFieldLabel)();if(!e.length||!t)return null;let u=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return u.length===0?null:(0,s.jsx)(r.Card,{className:(0,r.cn)(`bg-muted/30 border-dashed`,n),children:(0,s.jsx)(r.CardContent,{className:`py-3 px-4`,children:(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-4`,u.length===1?`grid-cols-1`:u.length===2?`grid-cols-2`:u.length===3?`grid-cols-3`:`grid-cols-2 md:grid-cols-4`),children:u.map(e=>{let n=t[e.name],r=c?.fields?.[e.name],a=e.type||r?.type,u={name:e.name,label:e.label,type:a||`text`,...r?.options&&{options:r.options},...r?.currency&&{currency:r.currency},...r?.precision!==void 0&&{precision:r.precision},...r?.format&&{format:r.format}},d=(0,o.getCellRenderer)(a||`text`);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,s.jsx)(`span`,{className:`mr-1`,children:e.icon}),l(i||``,e.name,e.label)]}),(0,s.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:(0,s.jsx)(d,{value:n,field:u})})]},e.name)})})})})};function A(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var j=({comments:e,onAddComment:t,onTogglePin:a,searchable:o=!1,className:c})=>{let{t:l}=S(),[u,d]=n.useState(``),[f,p]=n.useState(!1),[m,h]=n.useState(``),g=n.useCallback(async()=>{let e=u.trim();if(!(!e||!t)){p(!0);try{await t(e),d(``)}finally{p(!1)}}},[u,t]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]),v=n.useMemo(()=>[...m.trim()?e.filter(e=>{let t=m.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,m]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,c),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),l(`detail.comments`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[o&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsxs)(`div`,{className:`relative flex-1`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:l(`detail.searchComments`),value:m,onChange:e=>h(e.target.value),"aria-label":l(`detail.searchComments`)}),m&&(0,s.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>h(``),"aria-label":l(`detail.clearSearch`),type:`button`,children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),t&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:l(`detail.addCommentPlaceholder`),value:u,onChange:e=>d(e.target.value),onKeyDown:_,disabled:f}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:g,disabled:!u.trim()||f,className:`shrink-0 self-end`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]}),v.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m.trim()?l(`detail.noMatchingComments`):l(`detail.noCommentsYet`)}):(0,s.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,s.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:A(e.createdAt)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),l(`detail.pinned`)]})]}),(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),a&&(0,s.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>a(e.id),"aria-label":e.pinned?l(`detail.unpin`):l(`detail.pin`),children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),e.pinned?l(`detail.unpin`):l(`detail.pin`)]})]})]},e.id))})]})]})},M={field_change:i.Edit,create:i.PlusCircle,delete:i.Trash2,comment:i.MessageSquare,status_change:i.ArrowRightLeft},N={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function P(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function F(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var I={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},L=({activities:e,filterable:t=!1,defaultFilter:a=`all`,className:o})=>{let[c,l]=n.useState(a),u=n.useMemo(()=>c===`all`?e:e.filter(e=>e.type===c),[e,c]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),`Activity`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,u.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{children:[t&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(I).map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,c===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>l(e),"aria-pressed":c===e,children:[e!==`all`&&n.createElement(M[e]||i.Edit,{className:`h-3 w-3`}),I[e]]},e))}),u.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:u.map(e=>{let t=M[e.type]||i.Edit;return(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,N[e.type]||`bg-gray-100 text-gray-600`),children:(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`p`,{className:`text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:F(e)})]}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:P(e.timestamp)})]})]},e.id)})})]})]})]})},R=5;function z(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=n?.titleFormat;if(r){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,i=r.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=e[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):`\0`});if(n){let e=i.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var B=({schema:e,dataSource:o,className:c,onEdit:l,onDelete:u,onBack:d,inlineEdit:f=!1,onFieldSave:p,discussionSlot:m,rightRail:h,objectLabel:g,onDataLoaded:_})=>{let[v,y]=n.useState(e.data),[b,x]=n.useState(!e.data&&!!(e.api&&e.resourceId||o&&e.objectName&&e.resourceId)),[C,E]=n.useState(!1),[A,M]=n.useState(!1),[N,P]=n.useState({}),[F,I]=n.useState(null),[B,ee]=n.useState(!1),{t:V}=S();n.useEffect(()=>{v&&_&&_(v)},[v,_]);let H=n.useMemo(()=>{if(e.summaryFields&&e.summaryFields.length>0)return[];let t=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]],n={};for(let e of t)n[e.name]||(n[e.name]=e);if(F?.fields)for(let[e,t]of Object.entries(F.fields))n[e]={...n[e]||{},...t,name:e};let r=e=>v?.[e]!==void 0&&v?.[e]!==null&&v?.[e]!==``,i=[],a=[`status`,`stage`,`state`,`phase`].find(e=>n[e]&&r(e))||Object.keys(n).find(e=>n[e]?.type===`select`&&r(e));a&&i.push(a);let o=Object.keys(n).find(e=>(n[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&r(e));o&&!i.includes(o)&&i.push(o);let s=Object.keys(n).find(e=>(n[e]?.type===`date`||n[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&r(e));return s&&!i.includes(s)&&i.push(s),i},[e.summaryFields,e.sections,e.fields,F,v]),U=e.summaryFields&&e.summaryFields.length>0?e.summaryFields:H,te=n.useCallback(()=>{e.resourceId&&navigator.clipboard.writeText(String(e.resourceId)).then(()=>{ee(!0),setTimeout(()=>ee(!1),1500)})},[e.resourceId]);n.useEffect(()=>{let n=!0;if(e.data){y(e.data),x(!1);return}if(o&&e.objectName&&e.resourceId){x(!0),I(null),y(null);let r=e.objectName,i=e.resourceId,a=`${r}-`,s=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]];(o.getObjectSchema?o.getObjectSchema(r).catch(()=>null):Promise.resolve(null)).then(e=>{if(!n)return;I(e);let c=(0,t.buildExpandFields)(e?.fields,s),l=c.length>0?{$expand:c}:void 0,u=l?o.findOne(r,i,l):o.findOne(r,i),d=()=>{let e=String(i),t=e.startsWith(a)?e.slice(a.length):`${a}${e}`;return(l?o.findOne(r,t,l):o.findOne(r,t)).then(e=>{n&&(y(e),x(!1))}).catch(()=>{n&&(y(null),x(!1))})};return u.catch(()=>null).then(e=>{if(n){if(e){y(e),x(!1);return}return d()}})}).catch(e=>{n&&(console.error(`Failed to fetch detail data:`,e),x(!1))})}else e.api&&e.resourceId&&(x(!0),fetch(`${e.api}/${e.resourceId}`).then(e=>e.json()).then(e=>{n&&y(e?.data||e)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{n&&x(!1)}));return()=>{n=!1}},[e.api,e.resourceId,e.objectName,o,e.sections,e.fields]);let W=n.useCallback(()=>{if(d)d();else if(e.onNavigate){let t=e.backUrl||(e.objectName?`/${e.objectName}`:`/`);e.onNavigate(t,{replace:!0})}else e.backUrl?window.location.href=e.backUrl:window.history.back()},[d,e]),G=n.useCallback(()=>{l?l():e.onNavigate&&e.editUrl?e.onNavigate(e.editUrl):e.onNavigate&&e.objectName&&e.resourceId?e.onNavigate(`/${e.objectName}/${e.resourceId}/edit`):e.editUrl&&(window.location.href=e.editUrl)},[l,e]),K=n.useCallback(()=>{let t=e.deleteConfirmation||V(`detail.deleteConfirmation`);window.confirm(t)&&(u?.(),e.onNavigate&&e.objectName&&e.onNavigate(`/${e.objectName}`,{replace:!0}))},[u,e]),q=n.useCallback(()=>{navigator.share&&e.objectName&&e.resourceId?navigator.share({title:e.title||V(`detail.details`),text:`${e.objectName} #${e.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[e]),J=n.useCallback(()=>{console.log(`Duplicate record:`,v)},[v]),Y=n.useCallback(()=>{console.log(`Export record:`,v)},[v]),ne=n.useCallback(()=>{console.log(`View history for record:`,e.resourceId)},[e]),X=n.useCallback(()=>{E(!C)},[C]),re=n.useCallback(()=>{if(A){let e=Object.entries(N);if(e.length>0){let t={...v,...N};y(t),e.forEach(([e,n])=>{p?.(e,n,t)})}P({})}M(!A)},[A,N,v,p]),Z=n.useCallback((e,t)=>{P(n=>({...n,[e]:t}))},[]);n.useEffect(()=>{if(!e.recordNavigation)return;let t=e.recordNavigation,n=e=>{let n=e.target?.tagName;n===`INPUT`||n===`TEXTAREA`||e.target?.isContentEditable||(e.key===`ArrowLeft`&&t.currentIndex>0?(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex-1])):e.key===`ArrowRight`&&t.currentIndex<t.recordIds.length-1&&(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex+1])))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e.recordNavigation]);let ie=n.useMemo(()=>{if(!e.autoDiscoverRelated||!F?.fields||e.related&&e.related.length>0)return[];let t=[],n=F.fields;for(let[e,r]of Object.entries(n)){let n=r?.reference_to||r?.reference;r&&(r.type===`lookup`||r.type===`master_detail`)&&n&&t.push({title:r.label||e.charAt(0).toUpperCase()+e.slice(1),type:`table`,objectName:n,referenceField:e})}return t},[e.autoDiscoverRelated,e.related,F]),Q=n.useMemo(()=>e.related&&e.related.length>0?e.related:ie.map(e=>({title:e.title,type:e.type,api:e.objectName,data:[],referenceField:e.referenceField})),[e.related,ie]),$=n.useMemo(()=>{let t=[];t.push({name:`sys_share`,label:V(`detail.share`),icon:`share-2`,type:`script`,onClick:q}),e.showEdit&&t.push({name:`sys_edit_mobile`,label:V(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:G}),f&&t.push({name:`sys_toggle_inline_edit_mobile`,label:V(A?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:re});let n=t.length>0?[`separator-before`]:void 0;return t.push({name:`sys_duplicate`,label:V(`detail.duplicate`),icon:`copy`,type:`script`,...n&&{tags:n},onClick:J}),t.push({name:`sys_export`,label:V(`detail.export`),icon:`download`,type:`script`,onClick:Y}),t.push({name:`sys_view_history`,label:V(`detail.viewHistory`),icon:`history`,type:`script`,onClick:ne}),e.showDelete&&t.push({name:`sys_delete`,label:V(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:K}),t},[V,e.showEdit,e.showDelete,f,A,q,G,re,J,Y,ne,K]),ae=n.useMemo(()=>{let t=e.actions??[];if($.length===0)return t;let n=!1,r=t.map(e=>{let t=e;if(t&&typeof t==`object`&&t.type===`action:bar`&&(!t.location||t.location===`record_header`)){n=!0;let e=Array.isArray(t.systemActions)?t.systemActions:[];return{...t,systemActions:[...e,...$]}}return e});return n||r.push({type:`action:bar`,location:`record_header`,systemActions:$}),r},[e.actions,$]);return b||e.loading?(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-4`,c),children:[(0,s.jsx)(r.Skeleton,{className:`h-10 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-64 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-48 w-full`})]}):!v&&!e.data?(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col items-center justify-center py-16 text-center`,c),children:[(0,s.jsx)(`p`,{className:`text-lg font-semibold`,children:V(`detail.recordNotFound`)}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:V(`detail.recordNotFoundDescription`)}),(e.showBack??!0)&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:W,className:`mt-4 gap-2`,children:[(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`}),V(`detail.goBack`)]})]}):(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-6`,c),children:[(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(e.showBack??!0)&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,onClick:W,className:`shrink-0 mt-1`,children:(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.back`)})]}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,s.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:z(v,e,F,V(`detail.details`))}),U.map(t=>{let n=v?.[t];if(n==null||n===``)return null;let i=(e.sections||[]).flatMap(e=>e.fields).concat(e.fields||[]).find(e=>e.name===t),a=F?.fields?.[t],o=i?.type||a?.type,c=String(n),l=null;try{if(o===`currency`){let e=Number(n);Number.isNaN(e)||(c=new Intl.NumberFormat(void 0,{style:`currency`,currency:i?.currency||a?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(o===`date`||o===`datetime`){let e=new Date(n);Number.isNaN(e.getTime())||(c=o===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(o===`percent`){let e=Number(n);if(!Number.isNaN(e)){c=`${e}%`;let t=e<=1?e*100:e;l=Math.max(0,Math.min(100,t))}}}catch{}return l===null?(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${t}: ${c}`,children:c},t):(0,s.jsxs)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${t}: ${c}`,children:[(0,s.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,s.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${l}%`}})}),c]},t)}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:X,"aria-label":V(C?`detail.removeFromFavorites`:`detail.addToFavorites`),children:C?(0,s.jsx)(i.Star,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,s.jsx)(i.StarOff,{className:`h-4 w-4 text-muted-foreground`})})}),(0,s.jsx)(r.TooltipContent,{children:V(C?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),e.objectName&&(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:g||e.objectName}),e.resourceId&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:te,"aria-label":V(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:B?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:B?V(`detail.copied`,{defaultValue:`Copied`}):V(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[e.recordNavigation&&(0,s.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex<=0,onClick:()=>{let t=e.recordNavigation;t.currentIndex>0&&t.onNavigate(t.recordIds[t.currentIndex-1])},children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.previousRecord`)})]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:V(`detail.recordOf`,{current:e.recordNavigation.currentIndex+1,total:e.recordNavigation.recordIds.length})}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex>=e.recordNavigation.recordIds.length-1,onClick:()=>{let t=e.recordNavigation;t.currentIndex<t.recordIds.length-1&&t.onNavigate(t.recordIds[t.currentIndex+1])},children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.nextRecord`)})]})]}),ae.map((e,t)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:v},t)),f&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:A?`default`:`outline`,size:`sm`,onClick:re,className:`gap-2 hidden sm:inline-flex`,children:A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Check,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.save`)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.editInline`)})]})})}),(0,s.jsx)(r.TooltipContent,{children:V(A?`detail.saveChanges`:`detail.editFieldsInline`)})]}),e.showEdit&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsxs)(r.Button,{variant:`default`,onClick:G,className:`gap-2 hidden sm:inline-flex`,children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.edit`)})]})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.editRecord`)})]})]})]}),e.header&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.header,data:v})}),e.highlightFields&&e.highlightFields.length>0&&(0,s.jsx)(k,{fields:e.highlightFields,data:v,objectName:e.objectName,objectSchema:F}),e.autoTabs&&!e.tabs?.length?(()=>{let t=Q.length>0,n=!!e.activities&&e.activities.length>0,i=!!m,a=(0,s.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[e.sectionGroups&&e.sectionGroups.length>0&&e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Z},n)),e.sections&&e.sections.length>0&&e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Z},n)),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Z}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment})]});return!t&&!n&&!i?(0,s.jsx)(`div`,{className:`mt-2`,children:a}):(0,s.jsxs)(r.Tabs,{defaultValue:`details`,className:`w-full`,children:[(0,s.jsxs)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,s.jsx)(r.TabsTrigger,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.details`)}),t&&(0,s.jsx)(r.TabsTrigger,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.related`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:Q.length})]})}),n&&(0,s.jsx)(r.TabsTrigger,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.activity`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:e.activities.length})]})}),i&&(0,s.jsx)(r.TabsTrigger,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.discussion`,{defaultValue:`Discussion`})})]}),(0,s.jsx)(r.TabsContent,{value:`details`,className:`mt-4`,children:a}),t&&(0,s.jsx)(r.TabsContent,{value:`related`,className:`mt-4`,children:(0,s.jsx)(`div`,{className:`space-y-3`,children:Q.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:R},t))})}),n&&(0,s.jsx)(r.TabsContent,{value:`activity`,className:`mt-4`,children:(0,s.jsx)(L,{activities:e.activities})}),i&&(0,s.jsx)(r.TabsContent,{value:`discussion`,className:`mt-4`,children:m})]})})():(0,s.jsxs)(s.Fragment,{children:[e.sectionGroups&&e.sectionGroups.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Z},n))}),e.sections&&e.sections.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Z},n))}),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:Z}),e.tabs&&e.tabs.length>0&&(0,s.jsx)(T,{tabs:e.tabs,data:v}),Q.length>0&&(0,s.jsxs)(`div`,{className:`space-y-3`,children:[(0,s.jsx)(`h2`,{className:`text-lg font-semibold`,children:V(`detail.related`)}),Q.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:R},t))]}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment}),e.activities&&e.activities.length>0&&(0,s.jsx)(L,{activities:e.activities})]}),e.footer&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.footer,data:v})})]})})},ee=({objectName:e,relationshipField:t,fields:a,onCreateRecord:o,onLinkRecord:c,onSearch:l,existingRecords:u=[],className:d})=>{let[f,p]=n.useState(!1),[m,h]=n.useState(`create`),[g,_]=n.useState({}),[v,y]=n.useState(``),[b,x]=n.useState(u),[S,C]=n.useState(!1),[w,T]=n.useState(!1),E=n.useMemo(()=>{if(!v.trim())return b;let e=v.toLowerCase();return b.filter(t=>t.label.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[v,b]),D=n.useCallback(async e=>{if(y(e),l&&e.trim().length>=2){T(!0);try{x(await l(e))}finally{T(!1)}}},[l]),O=n.useCallback((e,t)=>{_(n=>({...n,[e]:t}))},[]),k=n.useCallback(async()=>{if(o){C(!0);try{await o({...g,[t]:!0}),_({}),p(!1)}finally{C(!1)}}},[o,g,t]),A=n.useCallback(async e=>{if(c){C(!0);try{await c(e),y(``),p(!1)}finally{C(!1)}}},[c]),j=n.useMemo(()=>a.filter(e=>e.required).every(e=>g[e.name]?.toString().trim()),[a,g]);return f?(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,d),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsxs)(`span`,{children:[m===`create`?`Create`:`Link`,` `,e]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>p(!1),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),(0,s.jsx)(r.CardContent,{children:(0,s.jsxs)(r.Tabs,{value:m,onValueChange:h,children:[(0,s.jsxs)(r.TabsList,{className:`mb-3 w-full`,children:[o&&(0,s.jsxs)(r.TabsTrigger,{value:`create`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`Create New`]}),c&&(0,s.jsxs)(r.TabsTrigger,{value:`link`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]}),o&&(0,s.jsxs)(r.TabsContent,{value:`create`,className:`space-y-3 mt-0`,children:[a.map(e=>(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:[e.label,e.required&&(0,s.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`})]}),(0,s.jsx)(r.Input,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,placeholder:e.placeholder||`Enter ${e.label.toLowerCase()}`,value:g[e.name]||``,onChange:t=>O(e.name,t.target.value),className:`h-8 text-sm`})]},e.name)),(0,s.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>p(!1),children:`Cancel`}),(0,s.jsxs)(r.Button,{size:`sm`,onClick:k,disabled:!j||S,className:`gap-1.5`,children:[S&&(0,s.jsx)(i.Loader2,{className:`h-3.5 w-3.5 animate-spin`}),`Create`]})]})]}),c&&(0,s.jsxs)(r.TabsContent,{value:`link`,className:`space-y-3 mt-0`,children:[(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.jsx)(r.Input,{placeholder:`Search ${e}…`,value:v,onChange:e=>D(e.target.value),className:`h-8 text-sm pl-8`})]}),(0,s.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:w?(0,s.jsxs)(`div`,{className:`flex items-center justify-center py-4 text-sm text-muted-foreground`,children:[(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-2`}),`Searching…`]}):E.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v?`No records found`:`Type to search records`}):E.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-2 rounded-md hover:bg-accent text-sm transition-colors`,onClick:()=>A(e.id),disabled:S,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description&&(0,s.jsx)(`span`,{className:`block text-xs text-muted-foreground mt-0.5`,children:e.description})]},e.id))})]})]})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,d),children:[o&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`create`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`New `,e]}),c&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`link`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]})};function V(e){let t=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/```([\s\S]*?)```/g,`<pre class="bg-muted rounded p-2 text-xs font-mono my-1 overflow-x-auto">$1</pre>`).replace(/`([^`]+)`/g,`<code class="bg-muted rounded px-1 py-0.5 text-xs font-mono">$1</code>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/@(\w+)/g,`<span class="text-primary font-medium">@$1</span>`).replace(/^- (.+)$/gm,`<li class="ml-4 list-disc">$1</li>`).replace(/\n/g,`<br/>`);return t=t.replace(/(<li[^>]*>.*?<\/li>(?:<br\/>)?)+/g,e=>`<ul class="my-1">${e.replace(/<br\/>/g,``)}</ul>`),t}var H=({value:e,onChange:t,onSubmit:a,mentionSuggestions:o=[],placeholder:c,className:l,disabled:u=!1})=>{let{t:d}=S(),[f,p]=n.useState(!1),[m,h]=n.useState(!1),[g,_]=n.useState(``),[v,y]=n.useState(0),b=n.useRef(null),x=n.useMemo(()=>{if(!g)return o;let e=g.toLowerCase();return o.filter(t=>t.label.toLowerCase().includes(e))},[g,o]),C=n.useCallback((n,r=``)=>{let i=b.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),w=n.useCallback(()=>C(`**`,`**`),[C]),T=n.useCallback(()=>C(`*`,`*`),[C]),E=n.useCallback(()=>C(`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@object-ui/core`),require(`react`),require(`@object-ui/components`),require(`lucide-react`),require(`@object-ui/react`),require(`@object-ui/fields`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`exports`,`@object-ui/core`,`react`,`@object-ui/components`,`lucide-react`,`@object-ui/react`,`@object-ui/fields`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ObjectUIPluginDetail={},e.ObjectUICore,e.React,e.ObjectUIComponents,e.LucideReact,e.ObjectUIReact,e.ObjectUIFields,e.jsxRuntime))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var h=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function g(e){return h.has(e)}function _(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function v(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&g(e.type)?{...e,span:t}:e)}function y(e,t,n){if(t!==void 0)return{fields:v(e,t),columns:t};let r=_(e.length,n);return{fields:v(e,r),columns:r}}function b(e,t){return function(){try{let n=(0,a.useObjectTranslation)();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var x={"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit inline`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`},S=b(x,`detail.back`);function C(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var w=({section:e,data:t,className:c,objectSchema:l,objectName:u,isEditing:d=!1,onFieldChange:f,virtualScroll:p})=>{let[m,h]=n.useState(e.defaultCollapsed??!1),[g,_]=n.useState(null),[v,b]=n.useState(void 0),[x,w]=n.useState(!1),{t:T}=S(),{fieldLabel:E}=(0,a.useSafeFieldLabel)(),D=n.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{_(e),setTimeout(()=>_(null),2e3)})},[]),O=n.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),k=n.useMemo(()=>e.fields.filter(O).length,[e.fields,O]),A=(0,r.useIsMobile)(),j=A?3:6,M=A?.2:.5,N=e.fields.length-k,P=!e.hideEmpty&&!d&&e.fields.length>=j&&k/e.fields.length>=M&&N>0,F=!x&&(e.hideEmpty||P)?e.fields.filter(e=>!O(e)):e.fields;if(F.length===0&&k===e.fields.length)return null;let{fields:I,columns:L}=y(F,e.columns),R=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,s.jsx)(a.SchemaRenderer,{schema:e.render,data:{...t,value:n}});let c=C(e.span,L),p=(()=>{if(n==null)return(0,s.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=l?.fields?.[e.name],r=e.type||t?.type,i={...e};if(t){!e.type&&t.type&&(i.type=t.type),t.options&&!i.options&&(i.options=t.options),t.currency&&!i.currency&&(i.currency=t.currency),t.precision!==void 0&&i.precision===void 0&&(i.precision=t.precision),t.format&&!i.format&&(i.format=t.format);let n=t.reference_to||t.reference;n&&!i.reference_to&&(i.reference_to=n),t.reference_field&&!i.reference_field&&(i.reference_field=t.reference_field)}if(r){let e=(0,o.getCellRenderer)(r);if(e)return(0,s.jsx)(e,{value:n,field:i})}return String(n)})(),m=n!=null&&n!==``,h=g===e.name;return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-1.5 group`,c),children:[(0,s.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:E(u||``,e.name,e.label||e.name)}),d&&!e.readonly?(0,s.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,s.jsx)(`input`,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:n==null?``:String(n),onChange:t=>f?.(e.name,t.target.value)})}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,m&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:m?()=>D(e.name,n):void 0,onKeyDown:m?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),D(e.name,n))}:void 0,role:m?`button`:void 0,tabIndex:m?0:void 0,children:[(0,s.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:p}),m&&(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),D(e.name,n)},children:h?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:T(h?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},z=p?.enabled===!0,B=p?.batchSize??20;n.useEffect(()=>{if(!z){b(void 0);return}if(I.length<=B){b(void 0);return}b(B);let e=setTimeout(()=>b(void 0),100);return()=>clearTimeout(e)},[z,I.length,B]);let ee=v===void 0?I:I.slice(0,v),V=k>0&&(e.hideEmpty||P),H=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-3 sm:gap-4`,L===1?`grid-cols-1`:L===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:ee.map(R)}),V&&(0,s.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,s.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>w(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[x?(0,s.jsx)(i.EyeOff,{className:`h-3.5 w-3.5 mr-1.5`}):(0,s.jsx)(i.Eye,{className:`h-3.5 w-3.5 mr-1.5`}),x?T(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):T(`detail.showEmptyFields`,{count:k,defaultValue:`Show ${k} empty field${k===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,s.jsx)(`div`,{className:(0,r.cn)(c),children:H}):e.collapsible?(0,s.jsx)(r.Collapsible,{open:!m,onOpenChange:e=>h(!e),className:c,children:(0,s.jsxs)(r.Card,{children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title}),e.fields&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:m?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!m&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})})]})}):(0,s.jsxs)(r.Card,{className:(0,r.cn)(e.showBorder===!1?`border-none shadow-none`:``,c),children:[e.title&&(0,s.jsxs)(r.CardHeader,{className:(0,r.cn)(e.headerColor&&`bg-${e.headerColor}`),children:[(0,s.jsx)(r.CardTitle,{className:`flex items-center justify-between`,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`span`,{children:e.title})]})}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,s.jsx)(r.CardContent,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:H})]})},T=({tabs:e,data:t,className:i})=>{let[o,c]=n.useState(e[0]?.key),l=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,s.jsxs)(r.Tabs,{value:o,onValueChange:c,className:i,children:[(0,s.jsx)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:l.map(e=>(0,s.jsx)(r.TabsTrigger,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,s.jsx)(`span`,{children:e.icon}),(0,s.jsx)(`span`,{children:e.label}),e.badge&&(0,s.jsx)(r.Badge,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),l.map(e=>(0,s.jsx)(r.TabsContent,{value:e.key,className:`mt-4`,children:(0,s.jsx)(n.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,s.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:t},n))}):(0,s.jsx)(a.SchemaRenderer,{schema:e.content,data:t})})},e.key))]})};function E(e){return e&&i.icons[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||i.Inbox}var D=({title:e,type:t,api:c,data:l=[],schema:u,columns:d,className:f,dataSource:p,objectName:m,onNew:h,onViewAll:g,onRowEdit:_,onRowDelete:v,pageSize:y,sortable:b=!1,filterable:x=!1,collapsible:C=!1,defaultCollapsed:w=!1,referenceField:T,icon:D})=>{let[O,k]=n.useState(l),[A,j]=n.useState(!1),[M,N]=n.useState(0),[P,F]=n.useState(null),[I,L]=n.useState(`asc`),[R,z]=n.useState(``),[B,ee]=n.useState(null),[V,H]=n.useState(w),{t:U}=S(),{fieldLabel:te}=(0,a.useSafeFieldLabel)();n.useEffect(()=>{k(l)},[l]),n.useEffect(()=>{c&&p?.getObjectSchema&&!d?.length&&p.getObjectSchema(c).then(ee).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${c}:`,e)})},[c,p,d]),n.useEffect(()=>{c&&!l.length&&(j(!0),p&&typeof p.find==`function`?p.find(c).then(e=>{k(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),j(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),j(!1)}):fetch(c).then(e=>e.json()).then(e=>{k(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>j(!1)))},[c,l,p]);let W=n.useMemo(()=>{if(!R)return O;let e=R.toLowerCase();return O.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[O,R]),G=n.useMemo(()=>P?[...W].sort((e,t)=>{let n=e[P],r=t[P];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return I===`asc`?i:-i}):W,[W,P,I]),K=y&&y>0?y:0,q=K?Math.max(1,Math.ceil(G.length/K)):1,J=K?G.slice(M*K,(M+1)*K):G;n.useEffect(()=>{N(0)},[R,P,I]);let Y=n.useCallback(e=>{P===e?L(e=>e===`asc`?`desc`:`asc`):(F(e),L(`asc`))},[P]),X=n.useCallback(e=>{window.confirm(U(`detail.deleteRowConfirmation`))&&v?.(e)},[v,U]),Z=n.useMemo(()=>{let e=e=>T?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==T):e;if(d&&d.length>0)return e(d);if(!B?.fields)return[];let t=m||c||``;return Object.entries(B.fields).filter(([e])=>!e.startsWith(`_`)&&e!==`id`&&e!==T).map(([e,r])=>{let i={accessorKey:e,header:te(t,e,r.label||e)};if(r.type){let t=(0,o.getCellRenderer)(r.type);if(t){let a={name:e,label:r.label||e,type:r.type,...r.options&&{options:r.options},...r.currency&&{currency:r.currency},...r.precision!==void 0&&{precision:r.precision},...r.format&&{format:r.format},...(r.reference_to||r.reference)&&{reference_to:r.reference_to||r.reference},...r.reference_field&&{reference_field:r.reference_field}};i.cell=e=>e==null?n.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):n.createElement(t,{value:e,field:a})}}return i})},[d,B,m,c,te,T]),Q=n.useMemo(()=>{if(u)return u;switch(t){case`grid`:case`table`:return{type:`data-table`,data:J,columns:Z,pagination:!1,pageSize:K||10,searchable:!1,exportable:!1};case`list`:return{type:`data-list`,data:J};default:return{type:`div`,children:`No view configured`}}},[t,J,Z,u,K]),$=!!_||!!v,ne=C?`cursor-pointer select-none`:void 0,re=C?()=>H(e=>!e):void 0,ie=E(D),ae=!A&&O.length===0,oe=x;return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`shadow-none`,ae&&`bg-muted/20`,f),children:[(0,s.jsx)(r.CardHeader,{className:(0,r.cn)(`py-3 px-4`,ne),onClick:re,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[C&&(V?(0,s.jsx)(i.ChevronRight,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,s.jsx)(ie,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,s.jsx)(`span`,{className:`truncate`,children:e}),(0,s.jsx)(r.Badge,{variant:`secondary`,className:(0,r.cn)(`text-xs font-normal h-5 px-1.5`,O.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${O.length} records`,children:O.length})]}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[h&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),h()},className:`gap-1 h-7 text-xs`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),U(`detail.new`)]}),g&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),g()},className:`gap-1 h-7 text-xs`,children:[U(`detail.viewAll`),(0,s.jsx)(i.ExternalLink,{className:`h-3 w-3`})]})]})]})}),!V&&(0,s.jsxs)(r.CardContent,{className:(0,r.cn)(`pt-0`,ae?`pb-3 px-4`:`pb-4 px-4`),children:[oe&&(0,s.jsx)(`div`,{className:`mb-3`,children:(0,s.jsx)(r.Input,{placeholder:U(`detail.filterPlaceholder`),value:R,onChange:e=>z(e.target.value),className:`h-8 text-sm`})}),b&&Z&&Z.length>0&&O.length>0&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:Z.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,a=P===t;return(0,s.jsxs)(r.Button,{variant:a?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Y(t),children:[(0,s.jsx)(i.ArrowUpDown,{className:`h-3 w-3`}),n,a&&(I===`asc`?` ↑`:` ↓`)]},t)})}),A?(0,s.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:U(`detail.loading`)}):ae?(0,s.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-2 text-sm`,children:[(0,s.jsx)(`span`,{className:`text-muted-foreground italic`,children:U(`detail.noRelatedRecords`)}),h===void 0&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground/70`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.SchemaRenderer,{schema:Q}),$&&J.length>0&&(0,s.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`row-actions`,children:J.map((e,t)=>(0,s.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 text-xs border-b last:border-b-0`,children:[(0,s.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.name||e.title||e.id||`Row ${t+1}`}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2`,onClick:()=>_(e),children:[(0,s.jsx)(i.Edit,{className:`h-3 w-3`}),U(`detail.editRow`)]}),v&&(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2 text-destructive hover:text-destructive`,onClick:()=>X(e),children:[(0,s.jsx)(i.Trash2,{className:`h-3 w-3`}),U(`detail.deleteRow`)]})]})]},e.id||t))})]}),K>0&&G.length>K&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:M===0,onClick:()=>N(e=>Math.max(0,e-1)),children:[(0,s.jsx)(i.ChevronLeft,{className:`h-3 w-3`}),U(`detail.previousPage`)]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:U(`detail.pageOf`,{current:M+1,total:q})}),(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:M>=q-1,onClick:()=>N(e=>Math.min(q-1,e+1)),children:[U(`detail.nextPage`),(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`})]})]})]})]})},O=({group:e,data:t,className:a,objectSchema:o,objectName:c,isEditing:l=!1,onFieldChange:u})=>{let d=e.collapsible??!0,[f,p]=n.useState(e.defaultCollapsed??!1),m=(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,s.jsx)(w,{section:e,data:t,objectSchema:o,objectName:c,isEditing:l,onFieldChange:u},n))});return d?(0,s.jsxs)(r.Collapsible,{open:!f,onOpenChange:e=>p(!e),className:a,children:[(0,s.jsx)(r.CollapsibleTrigger,{asChild:!0,children:(0,s.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[f?(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!f&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,s.jsx)(r.CollapsibleContent,{children:(0,s.jsx)(`div`,{className:`mt-3`,children:m})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-3`,a),children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,s.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),m]})},k=({fields:e,data:t,className:n,objectName:i,objectSchema:c})=>{let{fieldLabel:l}=(0,a.useSafeFieldLabel)();if(!e.length||!t)return null;let u=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return u.length===0?null:(0,s.jsx)(r.Card,{className:(0,r.cn)(`bg-muted/30 border-dashed`,n),children:(0,s.jsx)(r.CardContent,{className:`py-3 px-4`,children:(0,s.jsx)(`div`,{className:(0,r.cn)(`grid gap-4`,u.length===1?`grid-cols-1`:u.length===2?`grid-cols-2`:u.length===3?`grid-cols-3`:`grid-cols-2 md:grid-cols-4`),children:u.map(e=>{let n=t[e.name],r=c?.fields?.[e.name],a=e.type||r?.type,u={name:e.name,label:e.label,type:a||`text`,...r?.options&&{options:r.options},...r?.currency&&{currency:r.currency},...r?.precision!==void 0&&{precision:r.precision},...r?.format&&{format:r.format}},d=(0,o.getCellRenderer)(a||`text`);return(0,s.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,s.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,s.jsx)(`span`,{className:`mr-1`,children:e.icon}),l(i||``,e.name,e.label)]}),(0,s.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:(0,s.jsx)(d,{value:n,field:u})})]},e.name)})})})})};function A(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var j=({comments:e,onAddComment:t,onTogglePin:a,searchable:o=!1,className:c})=>{let{t:l}=S(),[u,d]=n.useState(``),[f,p]=n.useState(!1),[m,h]=n.useState(``),g=n.useCallback(async()=>{let e=u.trim();if(!(!e||!t)){p(!0);try{await t(e),d(``)}finally{p(!1)}}},[u,t]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]),v=n.useMemo(()=>[...m.trim()?e.filter(e=>{let t=m.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,m]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,c),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),l(`detail.comments`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[o&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsxs)(`div`,{className:`relative flex-1`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:l(`detail.searchComments`),value:m,onChange:e=>h(e.target.value),"aria-label":l(`detail.searchComments`)}),m&&(0,s.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>h(``),"aria-label":l(`detail.clearSearch`),type:`button`,children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),t&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:l(`detail.addCommentPlaceholder`),value:u,onChange:e=>d(e.target.value),onKeyDown:_,disabled:f}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:g,disabled:!u.trim()||f,className:`shrink-0 self-end`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]}),v.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m.trim()?l(`detail.noMatchingComments`):l(`detail.noCommentsYet`)}):(0,s.jsx)(`div`,{className:`space-y-3`,children:v.map(e=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,s.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:A(e.createdAt)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),l(`detail.pinned`)]})]}),(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),a&&(0,s.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>a(e.id),"aria-label":e.pinned?l(`detail.unpin`):l(`detail.pin`),children:[(0,s.jsx)(i.Pin,{className:`h-3 w-3`}),e.pinned?l(`detail.unpin`):l(`detail.pin`)]})]})]},e.id))})]})]})},M={field_change:i.Edit,create:i.PlusCircle,delete:i.Trash2,comment:i.MessageSquare,status_change:i.ArrowRightLeft},N={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function P(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function F(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var I={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},L=({activities:e,filterable:t=!1,defaultFilter:a=`all`,className:o})=>{let[c,l]=n.useState(a),u=n.useMemo(()=>c===`all`?e:e.filter(e=>e.type===c),[e,c]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),`Activity`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,u.length,`)`]})]})}),(0,s.jsxs)(r.CardContent,{children:[t&&(0,s.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(I).map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,c===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>l(e),"aria-pressed":c===e,children:[e!==`all`&&n.createElement(M[e]||i.Edit,{className:`h-3 w-3`}),I[e]]},e))}),u.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:u.map(e=>{let t=M[e.type]||i.Edit;return(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,N[e.type]||`bg-gray-100 text-gray-600`),children:(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`p`,{className:`text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,s.jsx)(`span`,{className:`text-muted-foreground`,children:F(e)})]}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:P(e.timestamp)})]})]},e.id)})})]})]})]})},R=5;function z(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=n?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0;if(i){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,r=i.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=e[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):`\0`});if(n){let e=r.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var B=({schema:e,dataSource:o,className:c,onEdit:l,onDelete:u,onBack:d,inlineEdit:f=!1,onFieldSave:p,discussionSlot:m,rightRail:h,objectLabel:g,onDataLoaded:_})=>{let[v,y]=n.useState(e.data),[b,x]=n.useState(!e.data&&!!(e.api&&e.resourceId||o&&e.objectName&&e.resourceId)),[C,E]=n.useState(!1),[A,M]=n.useState(!1),[N,P]=n.useState({}),[F,I]=n.useState(null),[B,ee]=n.useState(!1),{t:V}=S();n.useEffect(()=>{v&&_&&_(v)},[v,_]);let H=n.useMemo(()=>{if(e.summaryFields&&e.summaryFields.length>0)return[];let t=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]],n={};for(let e of t)n[e.name]||(n[e.name]=e);if(F?.fields)for(let[e,t]of Object.entries(F.fields))n[e]={...n[e]||{},...t,name:e};let r=e=>v?.[e]!==void 0&&v?.[e]!==null&&v?.[e]!==``,i=[],a=[`status`,`stage`,`state`,`phase`].find(e=>n[e]&&r(e))||Object.keys(n).find(e=>n[e]?.type===`select`&&r(e));a&&i.push(a);let o=Object.keys(n).find(e=>(n[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&r(e));o&&!i.includes(o)&&i.push(o);let s=Object.keys(n).find(e=>(n[e]?.type===`date`||n[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&r(e));return s&&!i.includes(s)&&i.push(s),i},[e.summaryFields,e.sections,e.fields,F,v]),U=e.summaryFields&&e.summaryFields.length>0?e.summaryFields:H,te=n.useCallback(()=>{e.resourceId&&navigator.clipboard.writeText(String(e.resourceId)).then(()=>{ee(!0),setTimeout(()=>ee(!1),1500)})},[e.resourceId]);n.useEffect(()=>{let n=!0;if(e.data){y(e.data),x(!1);return}if(o&&e.objectName&&e.resourceId){x(!0),I(null),y(null);let r=e.objectName,i=e.resourceId,a=`${r}-`,s=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]];(o.getObjectSchema?o.getObjectSchema(r).catch(()=>null):Promise.resolve(null)).then(e=>{if(!n)return;I(e);let c=(0,t.buildExpandFields)(e?.fields,s),l=c.length>0?{$expand:c}:void 0,u=l?o.findOne(r,i,l):o.findOne(r,i),d=()=>{let e=String(i),t=e.startsWith(a)?e.slice(a.length):`${a}${e}`;return(l?o.findOne(r,t,l):o.findOne(r,t)).then(e=>{n&&(y(e),x(!1))}).catch(()=>{n&&(y(null),x(!1))})};return u.catch(()=>null).then(e=>{if(n){if(e){y(e),x(!1);return}return d()}})}).catch(e=>{n&&(console.error(`Failed to fetch detail data:`,e),x(!1))})}else e.api&&e.resourceId&&(x(!0),fetch(`${e.api}/${e.resourceId}`).then(e=>e.json()).then(e=>{n&&y(e?.data||e)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{n&&x(!1)}));return()=>{n=!1}},[e.api,e.resourceId,e.objectName,o,e.sections,e.fields]);let W=n.useCallback(()=>{if(d)d();else if(e.onNavigate){let t=e.backUrl||(e.objectName?`/${e.objectName}`:`/`);e.onNavigate(t,{replace:!0})}else e.backUrl?window.location.href=e.backUrl:window.history.back()},[d,e]),G=n.useCallback(()=>{l?l():e.onNavigate&&e.editUrl?e.onNavigate(e.editUrl):e.onNavigate&&e.objectName&&e.resourceId?e.onNavigate(`/${e.objectName}/${e.resourceId}/edit`):e.editUrl&&(window.location.href=e.editUrl)},[l,e]),K=n.useCallback(()=>{let t=e.deleteConfirmation||V(`detail.deleteConfirmation`);window.confirm(t)&&(u?.(),e.onNavigate&&e.objectName&&e.onNavigate(`/${e.objectName}`,{replace:!0}))},[u,e]),q=n.useCallback(()=>{navigator.share&&e.objectName&&e.resourceId?navigator.share({title:e.title||V(`detail.details`),text:`${e.objectName} #${e.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[e]),J=n.useCallback(()=>{E(!C)},[C]),Y=n.useCallback(()=>{if(A){let e=Object.entries(N);if(e.length>0){let t={...v,...N};y(t),e.forEach(([e,n])=>{p?.(e,n,t)})}P({})}M(!A)},[A,N,v,p]),X=n.useCallback((e,t)=>{P(n=>({...n,[e]:t}))},[]);n.useEffect(()=>{if(!e.recordNavigation)return;let t=e.recordNavigation,n=e=>{let n=e.target?.tagName;n===`INPUT`||n===`TEXTAREA`||e.target?.isContentEditable||(e.key===`ArrowLeft`&&t.currentIndex>0?(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex-1])):e.key===`ArrowRight`&&t.currentIndex<t.recordIds.length-1&&(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex+1])))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e.recordNavigation]);let Z=n.useMemo(()=>{if(!e.autoDiscoverRelated||!F?.fields||e.related&&e.related.length>0)return[];let t=[],n=F.fields;for(let[e,r]of Object.entries(n)){let n=r?.reference_to||r?.reference;r&&(r.type===`lookup`||r.type===`master_detail`)&&n&&t.push({title:r.label||e.charAt(0).toUpperCase()+e.slice(1),type:`table`,objectName:n,referenceField:e})}return t},[e.autoDiscoverRelated,e.related,F]),Q=n.useMemo(()=>e.related&&e.related.length>0?e.related:Z.map(e=>({title:e.title,type:e.type,api:e.objectName,data:[],referenceField:e.referenceField})),[e.related,Z]),$=n.useMemo(()=>{let t=[];return t.push({name:`sys_share`,label:V(`detail.share`),icon:`share-2`,type:`script`,onClick:q}),e.showEdit&&t.push({name:`sys_edit_mobile`,label:V(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:G}),f&&t.push({name:`sys_toggle_inline_edit_mobile`,label:V(A?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:Y}),e.showDelete&&t.push({name:`sys_delete`,label:V(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:K}),t},[V,e.showEdit,e.showDelete,f,A,q,G,Y,K]),ne=n.useMemo(()=>{let t=e.actions??[];if($.length===0)return t;let n=!1,r=t.map(e=>{let t=e;if(t&&typeof t==`object`&&t.type===`action:bar`&&(!t.location||t.location===`record_header`)){n=!0;let e=Array.isArray(t.systemActions)?t.systemActions:[];return{...t,systemActions:[...e,...$]}}return e});return n||r.push({type:`action:bar`,location:`record_header`,systemActions:$}),r},[e.actions,$]);return b||e.loading?(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-4`,c),children:[(0,s.jsx)(r.Skeleton,{className:`h-10 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-64 w-full`}),(0,s.jsx)(r.Skeleton,{className:`h-48 w-full`})]}):!v&&!e.data?(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col items-center justify-center py-16 text-center`,c),children:[(0,s.jsx)(`p`,{className:`text-lg font-semibold`,children:V(`detail.recordNotFound`)}),(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:V(`detail.recordNotFoundDescription`)}),(e.showBack??!0)&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:W,className:`mt-4 gap-2`,children:[(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`}),V(`detail.goBack`)]})]}):(0,s.jsx)(r.TooltipProvider,{children:(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-6`,c),children:[(0,s.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(e.showBack??!0)&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,onClick:W,className:`shrink-0 mt-1`,children:(0,s.jsx)(i.ArrowLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.back`)})]}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,s.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:z(v,e,F,V(`detail.details`))}),U.map(t=>{let n=v?.[t];if(n==null||n===``)return null;let i=(e.sections||[]).flatMap(e=>e.fields).concat(e.fields||[]).find(e=>e.name===t),a=F?.fields?.[t],o=i?.type||a?.type,c=String(n),l=null;try{if(o===`currency`){let e=Number(n);Number.isNaN(e)||(c=new Intl.NumberFormat(void 0,{style:`currency`,currency:i?.currency||a?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(o===`date`||o===`datetime`){let e=new Date(n);Number.isNaN(e.getTime())||(c=o===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(o===`percent`){let e=Number(n);if(!Number.isNaN(e)){c=`${e}%`;let t=e<=1?e*100:e;l=Math.max(0,Math.min(100,t))}}}catch{}return l===null?(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${t}: ${c}`,children:c},t):(0,s.jsxs)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${t}: ${c}`,children:[(0,s.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,s.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${l}%`}})}),c]},t)}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:J,"aria-label":V(C?`detail.removeFromFavorites`:`detail.addToFavorites`),children:C?(0,s.jsx)(i.Star,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,s.jsx)(i.StarOff,{className:`h-4 w-4 text-muted-foreground`})})}),(0,s.jsx)(r.TooltipContent,{children:V(C?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),e.objectName&&(0,s.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:g||e.objectName}),e.resourceId&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:te,"aria-label":V(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:B?(0,s.jsx)(i.Check,{className:`h-3 w-3 text-green-600`}):(0,s.jsx)(i.Copy,{className:`h-3 w-3`})})}),(0,s.jsx)(r.TooltipContent,{children:B?V(`detail.copied`,{defaultValue:`Copied`}):V(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,s.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[e.recordNavigation&&(0,s.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex<=0,onClick:()=>{let t=e.recordNavigation;t.currentIndex>0&&t.onNavigate(t.recordIds[t.currentIndex-1])},children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.previousRecord`)})]}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:V(`detail.recordOf`,{current:e.recordNavigation.currentIndex+1,total:e.recordNavigation.recordIds.length})}),(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex>=e.recordNavigation.recordIds.length-1,onClick:()=>{let t=e.recordNavigation;t.currentIndex<t.recordIds.length-1&&t.onNavigate(t.recordIds[t.currentIndex+1])},children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.nextRecord`)})]})]}),ne.map((e,t)=>(0,s.jsx)(a.SchemaRenderer,{schema:e,data:v},t)),f&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsx)(r.Button,{variant:A?`default`:`outline`,size:`sm`,onClick:Y,className:`gap-2 hidden sm:inline-flex`,children:A?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Check,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.save`)})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.editInline`)})]})})}),(0,s.jsx)(r.TooltipContent,{children:V(A?`detail.saveChanges`:`detail.editFieldsInline`)})]}),e.showEdit&&(0,s.jsxs)(r.Tooltip,{children:[(0,s.jsx)(r.TooltipTrigger,{asChild:!0,children:(0,s.jsxs)(r.Button,{variant:`default`,onClick:G,className:`gap-2 hidden sm:inline-flex`,children:[(0,s.jsx)(i.Edit,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`hidden sm:inline`,children:V(`detail.edit`)})]})}),(0,s.jsx)(r.TooltipContent,{children:V(`detail.editRecord`)})]})]})]}),e.header&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.header,data:v})}),e.highlightFields&&e.highlightFields.length>0&&(0,s.jsx)(k,{fields:e.highlightFields,data:v,objectName:e.objectName,objectSchema:F}),e.autoTabs&&!e.tabs?.length?(()=>{let t=Q.length>0,n=!!e.activities&&e.activities.length>0,i=!!m,a=(0,s.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[e.sectionGroups&&e.sectionGroups.length>0&&e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n)),e.sections&&e.sections.length>0&&e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n)),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment})]});return!t&&!n&&!i?(0,s.jsx)(`div`,{className:`mt-2`,children:a}):(0,s.jsxs)(r.Tabs,{defaultValue:`details`,className:`w-full`,children:[(0,s.jsxs)(r.TabsList,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,s.jsx)(r.TabsTrigger,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.details`)}),t&&(0,s.jsx)(r.TabsTrigger,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.related`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:Q.length})]})}),n&&(0,s.jsx)(r.TabsTrigger,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,s.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[V(`detail.activity`),(0,s.jsx)(r.Badge,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:e.activities.length})]})}),i&&(0,s.jsx)(r.TabsTrigger,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:V(`detail.discussion`,{defaultValue:`Discussion`})})]}),(0,s.jsx)(r.TabsContent,{value:`details`,className:`mt-4`,children:a}),t&&(0,s.jsx)(r.TabsContent,{value:`related`,className:`mt-4`,children:(0,s.jsx)(`div`,{className:`space-y-3`,children:Q.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:R},t))})}),n&&(0,s.jsx)(r.TabsContent,{value:`activity`,className:`mt-4`,children:(0,s.jsx)(L,{activities:e.activities})}),i&&(0,s.jsx)(r.TabsContent,{value:`discussion`,className:`mt-4`,children:m})]})})():(0,s.jsxs)(s.Fragment,{children:[e.sectionGroups&&e.sectionGroups.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sectionGroups.map((t,n)=>(0,s.jsx)(O,{group:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n))}),e.sections&&e.sections.length>0&&(0,s.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((t,n)=>(0,s.jsx)(w,{section:t,data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X},n))}),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,s.jsx)(w,{section:{fields:e.fields,columns:e.columns},data:{...v,...N},objectSchema:F,objectName:e.objectName,isEditing:A,onFieldChange:X}),e.tabs&&e.tabs.length>0&&(0,s.jsx)(T,{tabs:e.tabs,data:v}),Q.length>0&&(0,s.jsxs)(`div`,{className:`space-y-3`,children:[(0,s.jsx)(`h2`,{className:`text-lg font-semibold`,children:V(`detail.related`)}),Q.map((e,t)=>(0,s.jsx)(D,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:o,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:R},t))]}),e.comments&&(0,s.jsx)(j,{comments:e.comments,onAddComment:e.onAddComment}),e.activities&&e.activities.length>0&&(0,s.jsx)(L,{activities:e.activities})]}),e.footer&&(0,s.jsx)(`div`,{children:(0,s.jsx)(a.SchemaRenderer,{schema:e.footer,data:v})})]})})},ee=({objectName:e,relationshipField:t,fields:a,onCreateRecord:o,onLinkRecord:c,onSearch:l,existingRecords:u=[],className:d})=>{let[f,p]=n.useState(!1),[m,h]=n.useState(`create`),[g,_]=n.useState({}),[v,y]=n.useState(``),[b,x]=n.useState(u),[S,C]=n.useState(!1),[w,T]=n.useState(!1),E=n.useMemo(()=>{if(!v.trim())return b;let e=v.toLowerCase();return b.filter(t=>t.label.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[v,b]),D=n.useCallback(async e=>{if(y(e),l&&e.trim().length>=2){T(!0);try{x(await l(e))}finally{T(!1)}}},[l]),O=n.useCallback((e,t)=>{_(n=>({...n,[e]:t}))},[]),k=n.useCallback(async()=>{if(o){C(!0);try{await o({...g,[t]:!0}),_({}),p(!1)}finally{C(!1)}}},[o,g,t]),A=n.useCallback(async e=>{if(c){C(!0);try{await c(e),y(``),p(!1)}finally{C(!1)}}},[c]),j=n.useMemo(()=>a.filter(e=>e.required).every(e=>g[e.name]?.toString().trim()),[a,g]);return f?(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,d),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsxs)(`span`,{children:[m===`create`?`Create`:`Link`,` `,e]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>p(!1),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]})}),(0,s.jsx)(r.CardContent,{children:(0,s.jsxs)(r.Tabs,{value:m,onValueChange:h,children:[(0,s.jsxs)(r.TabsList,{className:`mb-3 w-full`,children:[o&&(0,s.jsxs)(r.TabsTrigger,{value:`create`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`Create New`]}),c&&(0,s.jsxs)(r.TabsTrigger,{value:`link`,className:`flex-1 gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]}),o&&(0,s.jsxs)(r.TabsContent,{value:`create`,className:`space-y-3 mt-0`,children:[a.map(e=>(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`label`,{className:`text-xs font-medium text-muted-foreground mb-1 block`,children:[e.label,e.required&&(0,s.jsx)(`span`,{className:`text-destructive ml-0.5`,children:`*`})]}),(0,s.jsx)(r.Input,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,placeholder:e.placeholder||`Enter ${e.label.toLowerCase()}`,value:g[e.name]||``,onChange:t=>O(e.name,t.target.value),className:`h-8 text-sm`})]},e.name)),(0,s.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:()=>p(!1),children:`Cancel`}),(0,s.jsxs)(r.Button,{size:`sm`,onClick:k,disabled:!j||S,className:`gap-1.5`,children:[S&&(0,s.jsx)(i.Loader2,{className:`h-3.5 w-3.5 animate-spin`}),`Create`]})]})]}),c&&(0,s.jsxs)(r.TabsContent,{value:`link`,className:`space-y-3 mt-0`,children:[(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(i.Search,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,s.jsx)(r.Input,{placeholder:`Search ${e}…`,value:v,onChange:e=>D(e.target.value),className:`h-8 text-sm pl-8`})]}),(0,s.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:w?(0,s.jsxs)(`div`,{className:`flex items-center justify-center py-4 text-sm text-muted-foreground`,children:[(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-2`}),`Searching…`]}):E.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v?`No records found`:`Type to search records`}):E.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:`w-full text-left px-3 py-2 rounded-md hover:bg-accent text-sm transition-colors`,onClick:()=>A(e.id),disabled:S,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description&&(0,s.jsx)(`span`,{className:`block text-xs text-muted-foreground mt-0.5`,children:e.description})]},e.id))})]})]})})]}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,d),children:[o&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`create`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Plus,{className:`h-3.5 w-3.5`}),`New `,e]}),c&&(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,onClick:()=>{h(`link`),p(!0)},className:`gap-1.5`,children:[(0,s.jsx)(i.Link,{className:`h-3.5 w-3.5`}),`Link Existing`]})]})};function V(e){let t=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/```([\s\S]*?)```/g,`<pre class="bg-muted rounded p-2 text-xs font-mono my-1 overflow-x-auto">$1</pre>`).replace(/`([^`]+)`/g,`<code class="bg-muted rounded px-1 py-0.5 text-xs font-mono">$1</code>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/@(\w+)/g,`<span class="text-primary font-medium">@$1</span>`).replace(/^- (.+)$/gm,`<li class="ml-4 list-disc">$1</li>`).replace(/\n/g,`<br/>`);return t=t.replace(/(<li[^>]*>.*?<\/li>(?:<br\/>)?)+/g,e=>`<ul class="my-1">${e.replace(/<br\/>/g,``)}</ul>`),t}var H=({value:e,onChange:t,onSubmit:a,mentionSuggestions:o=[],placeholder:c,className:l,disabled:u=!1})=>{let{t:d}=S(),[f,p]=n.useState(!1),[m,h]=n.useState(!1),[g,_]=n.useState(``),[v,y]=n.useState(0),b=n.useRef(null),x=n.useMemo(()=>{if(!g)return o;let e=g.toLowerCase();return o.filter(t=>t.label.toLowerCase().includes(e))},[g,o]),C=n.useCallback((n,r=``)=>{let i=b.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),w=n.useCallback(()=>C(`**`,`**`),[C]),T=n.useCallback(()=>C(`*`,`*`),[C]),E=n.useCallback(()=>C(`
2
2
  - `,``),[C]),D=n.useCallback(()=>C("`","`"),[C]),O=n.useCallback(()=>{C(`@`,``),h(!0),_(``),y(0)},[C]),k=n.useCallback(n=>{let r=b.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),h(!1),_(``),requestAnimationFrame(()=>r.focus())},[e,t]),A=n.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){h(!0),_(e),y(0);return}}h(!1)},[t]),j=n.useCallback(e=>{if(m&&x.length>0){if(e.key===`ArrowDown`){e.preventDefault(),y(e=>e<x.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),y(e=>e>0?e-1:x.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),k(x[v]);return}if(e.key===`Escape`){h(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),a?.())},[m,x,v,k,a]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`border rounded-md`,l),children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:u||f,title:d(`detail.bold`),children:(0,s.jsx)(i.Bold,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:u||f,title:d(`detail.italic`),children:(0,s.jsx)(i.Italic,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:E,disabled:u||f,title:d(`detail.listFormat`),children:(0,s.jsx)(i.List,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:D,disabled:u||f,title:d(`detail.inlineCode`),children:(0,s.jsx)(i.Code,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:O,disabled:u||f,title:d(`detail.mentionSomeone`),children:(0,s.jsx)(i.AtSign,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(`div`,{className:`flex-1`}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>p(!f),title:d(f?`detail.edit`:`detail.preview`),children:f?(0,s.jsx)(i.Edit,{className:`h-3.5 w-3.5`}):(0,s.jsx)(i.Eye,{className:`h-3.5 w-3.5`})}),a&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:a,disabled:u||!e.trim(),title:d(`detail.submitComment`),children:(0,s.jsx)(i.Send,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(`div`,{className:`relative`,children:f?(0,s.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:V(e)}}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`textarea`,{ref:b,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:c??d(`detail.writeComment`),value:e,onChange:A,onKeyDown:j,disabled:u}),m&&x.length>0&&(0,s.jsx)(`div`,{className:`absolute left-2 bottom-full mb-1 w-56 bg-popover border rounded-md shadow-md z-50 max-h-40 overflow-y-auto`,children:x.map((e,t)=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===v&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),k(e)},children:[e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,s.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.label.charAt(0).toUpperCase()}),(0,s.jsx)(`span`,{children:e.label})]},e.id))})]})})]})};function U(e,t){if(e==null)return[`(empty)`];switch(t){case`json`:try{let t=typeof e==`string`?JSON.parse(e):e;return JSON.stringify(t,null,2).split(`
3
3
  `)}catch{return String(e).split(`
4
4
  `)}case`boolean`:return[String(!!e)];case`number`:return[String(e)];case`date`:try{return[new Date(e).toLocaleString()]}catch{return[String(e)]}default:return String(e).split(`
5
- `)}}function te(e,t){let n=[],r=Math.max(e.length,t.length);for(let i=0;i<r;i++){let r=i<e.length?e[i]:void 0,a=i<t.length?t[i]:void 0;r===a?n.push({type:`unchanged`,value:r}):(r!==void 0&&n.push({type:`removed`,value:r}),a!==void 0&&n.push({type:`added`,value:a}))}return n}var W={added:`bg-green-50 text-green-800 dark:bg-green-950/30 dark:text-green-300`,removed:`bg-red-50 text-red-800 dark:bg-red-950/30 dark:text-red-300`,unchanged:`text-muted-foreground`},G={added:`+`,removed:`-`,unchanged:` `},K=({oldValue:e,newValue:t,fieldName:a,fieldType:o=`string`,mode:c=`unified`,className:l})=>{let{t:u}=S(),[d,f]=n.useState(c),p=n.useMemo(()=>U(e,o),[e,o]),m=n.useMemo(()=>U(t,o),[t,o]),h=n.useMemo(()=>te(p,m),[p,m]),g=h.some(e=>e.type!==`unchanged`),_=n.useMemo(()=>{if(d!==`side-by-side`)return[];let e=[],t=0;for(;t<h.length;){let n=h[t];if(n.type===`unchanged`)e.push({left:n,right:n}),t++;else if(n.type===`removed`){let r=t+1<h.length?h[t+1]:null;r&&r.type===`added`?(e.push({left:n,right:r}),t+=2):(e.push({left:n,right:null}),t++)}else e.push({left:null,right:n}),t++}return e},[d,h]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,l),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:a}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(r.Button,{variant:d===`unified`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`unified`),title:u(`detail.unifiedDiff`),children:(0,s.jsx)(i.Rows3,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:d===`side-by-side`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`side-by-side`),title:u(`detail.sideBySideDiff`),children:(0,s.jsx)(i.Columns2,{className:`h-3.5 w-3.5`})})]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:g?d===`unified`?(0,s.jsx)(`div`,{className:`font-mono text-xs overflow-x-auto`,children:h.map((e,t)=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`px-4 py-0.5 whitespace-pre-wrap border-l-2`,W[e.type],e.type===`added`&&`border-l-green-500`,e.type===`removed`&&`border-l-red-500`,e.type===`unchanged`&&`border-l-transparent`),children:[(0,s.jsx)(`span`,{className:`select-none mr-2 inline-block w-3 text-center opacity-60`,children:G[e.type]}),e.value]},t))}):(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`div`,{className:`grid grid-cols-2 divide-x font-mono text-xs min-w-0`,children:[(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.previousVersion`)}),(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.currentVersion`)}),_.map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.left?W[e.left.type]:`bg-muted/20`),children:e.left?.value??``}),(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.right?W[e.right.type]:`bg-muted/20`),children:e.right?.value??``})]},t))]})}):(0,s.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:u(`detail.noChanges`)})})]})},q=({currentIndex:e,totalRecords:t,recordIds:a,onNavigate:o,onSearch:c,className:l})=>{let{t:u}=S(),[d,f]=n.useState(``),[p,m]=n.useState(!1),h=n.useRef(null),g=e>0,_=e>0,v=e<t-1,y=e<t-1,b=n.useCallback(()=>{g&&o(a[0])},[g,o,a]),x=n.useCallback(()=>{_&&o(a[e-1])},[_,o,a,e]),C=n.useCallback(()=>{v&&o(a[e+1])},[v,o,a,e]),w=n.useCallback(()=>{y&&o(a[a.length-1])},[y,o,a]),T=n.useCallback(e=>{let t=e.target.value;f(t),c?.(t)},[c]),E=n.useCallback(()=>{m(e=>(e?(f(``),c?.(``)):requestAnimationFrame(()=>h.current?.focus()),!e))},[c]);return n.useEffect(()=>{let t=t=>{let n=t.target?.tagName;if(!((n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable)&&t.target!==h.current)){if(t.target===h.current){t.key===`Escape`&&(t.preventDefault(),m(!1),f(``),c?.(``),t.target.blur());return}switch(t.key){case`Home`:t.preventDefault(),g&&o(a[0]);break;case`End`:t.preventDefault(),y&&o(a[a.length-1]);break;case`ArrowLeft`:t.preventDefault(),_&&o(a[e-1]);break;case`ArrowRight`:t.preventDefault(),v&&o(a[e+1]);break}}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,a,g,_,v,y,o,c]),(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5`,l),children:[(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!g,onClick:b,title:u(`detail.firstRecord`),children:(0,s.jsx)(i.ChevronsLeft,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!_,onClick:x,title:u(`detail.previousRecordKey`),children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1.5 tabular-nums`,children:t>0?u(`detail.recordOf`,{current:e+1,total:t}):u(`detail.noRecords`)}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!v,onClick:C,title:u(`detail.nextRecordKey`),children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!y,onClick:w,title:u(`detail.lastRecord`),children:(0,s.jsx)(i.ChevronsRight,{className:`h-4 w-4`})}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Button,{variant:p?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:E,title:u(`detail.searchWhileNavigating`),children:(0,s.jsx)(i.Search,{className:`h-4 w-4`})}),p&&(0,s.jsx)(`div`,{className:`relative`,children:(0,s.jsx)(r.Input,{ref:h,type:`text`,placeholder:u(`detail.searchRecords`),value:d,onChange:T,className:`h-8 w-48 text-sm`})})]})]})},J=28,Y=[`fill-primary stroke-primary`,`fill-blue-500 stroke-blue-500`,`fill-emerald-500 stroke-emerald-500`,`fill-amber-500 stroke-amber-500`],ne=[`fill-primary-foreground`,`fill-white`,`fill-white`,`fill-white`];function X(e,t,n,r,i){let a=[],o=[],s=new Set,c=r/2,l=i/2;a.push({id:e.id,label:e.label,type:e.type,x:c,y:l,level:0}),s.add(e.id);let u=Math.min(r,i)*.32,d=t.filter(e=>!s.has(e.id));if(d.forEach((t,n)=>{let r=2*Math.PI*n/d.length-Math.PI/2,i=c+u*Math.cos(r),f=l+u*Math.sin(r);a.push({id:t.id,label:t.label,type:t.type,x:i,y:f,level:1}),o.push({fromId:e.id,toId:t.id,fromX:c,fromY:l,toX:i,toY:f}),s.add(t.id)}),n>=2){let e=Math.min(r,i)*.46,t=[];d.forEach(e=>{let n=a.find(t=>t.id===e.id);n&&(e.relatedRecords||[]).filter(e=>!s.has(e.id)).forEach(r=>{t.push({node:r,parentX:n.x,parentY:n.y,parentId:e.id}),s.add(r.id)})}),t.forEach((n,r)=>{let i=2*Math.PI*r/Math.max(t.length,1)-Math.PI/2,s=c+e*Math.cos(i),u=l+e*Math.sin(i);a.push({id:n.node.id,label:n.node.label,type:n.node.type,x:s,y:u,level:2}),o.push({fromId:n.parentId,toId:n.node.id,fromX:n.parentX,fromY:n.parentY,toX:s,toY:u})})}return{nodes:a,edges:o}}function re(e,t=6){return e.length<=t?e:e.slice(0,t-1)+`…`}var Z=({record:e,relatedRecords:t,levels:a=1,onNodeClick:o,className:c})=>{let l=n.useRef(null),[u,d]=n.useState({width:500,height:400}),[f,p]=n.useState(null);n.useEffect(()=>{let e=l.current;if(!e)return;let t=e.parentElement;if(!t)return;let n=new ResizeObserver(e=>{for(let t of e){let{width:e}=t.contentRect;e>0&&d({width:e,height:Math.max(300,e*.7)})}});return n.observe(t),()=>n.disconnect()},[]);let{nodes:m,edges:h}=n.useMemo(()=>X(e,t,a,u.width,u.height),[e,t,a,u]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,c),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Network,{className:`h-4 w-4`}),`Relationships`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,` related)`]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:(0,s.jsxs)(`svg`,{ref:l,width:`100%`,height:u.height,viewBox:`0 0 ${u.width} ${u.height}`,className:`select-none`,children:[h.map((e,t)=>(0,s.jsx)(`line`,{x1:e.fromX,y1:e.fromY,x2:e.toX,y2:e.toY,className:`stroke-border`,strokeWidth:1.5,strokeOpacity:.5},`edge-${t}`)),m.map(e=>{let t=f===e.id,n=Y[Math.min(e.level,Y.length-1)],i=ne[Math.min(e.level,ne.length-1)],a=e.level===0?J+6:J;return(0,s.jsxs)(`g`,{className:(0,r.cn)(`cursor-pointer transition-transform`,o&&`hover:opacity-80`),onClick:()=>o?.(e.id),onMouseEnter:()=>p(e.id),onMouseLeave:()=>p(null),children:[(0,s.jsx)(`circle`,{cx:e.x,cy:e.y,r:t?a+3:a,className:n,fillOpacity:e.level===0?1:.85,strokeWidth:2,strokeOpacity:.3}),(0,s.jsx)(`text`,{x:e.x,y:e.y,textAnchor:`middle`,dominantBaseline:`central`,className:(0,r.cn)(`text-[10px] font-medium pointer-events-none`,i),children:re(e.label)}),e.type&&(0,s.jsx)(`text`,{x:e.x,y:e.y+a+12,textAnchor:`middle`,className:`fill-muted-foreground text-[9px] pointer-events-none`,children:e.type}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`rect`,{x:e.x-50,y:e.y-a-28,width:100,height:20,rx:4,className:`fill-popover stroke-border`,strokeWidth:1}),(0,s.jsx)(`text`,{x:e.x,y:e.y-a-16,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-popover-foreground text-[10px] pointer-events-none`,children:e.label})]})]},e.id)})]})})]})};function ie(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Q(e){return e.startsWith(`image/`)}function $(e){return Q(e)?i.Image:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?i.FileText:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?i.FileArchive:i.File}var ae=({attachments:e,onUpload:t,onRemove:a,className:o,readOnly:c=!1})=>{let{t:l}=S(),[u,d]=n.useState(!1),f=n.useRef(null),p=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!0)},[]),m=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1)},[]),h=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),g=n.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-2`,o),children:[t&&!c&&(0,s.jsxs)(`div`,{className:(0,r.cn)(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,u?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:p,onDragLeave:m,onDrop:h,onClick:()=>f.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f.current?.click())},children:[(0,s.jsx)(i.Upload,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`detail.dropFilesToUpload`)}),(0,s.jsx)(`input`,{ref:f,type:`file`,multiple:!0,className:`hidden`,onChange:g})]}),e.length>0&&(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,s.jsx)(i.Paperclip,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:e.length===1?l(`detail.attachmentCount`,{count:e.length}):l(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,s.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=Q(e.type),n=$(e.type);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group`,children:[t&&(e.thumbnailUrl||e.url)?(0,s.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,s.jsx)(n,{className:`h-5 w-5 text-muted-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,s.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:ie(e.size)})]}),a&&!c&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>a(e.id),title:l(`detail.removeAttachment`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})};function oe(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:t.toLocaleString()}catch{return e}}var se=({recordId:e,revisions:t,onRestore:a,className:o})=>{let[c,l]=n.useState(null),[u,d]=n.useState(!1),[f,p]=n.useState(!1),m=n.useMemo(()=>t.find(e=>e.id===c)??null,[t,c]),h=n.useCallback(async()=>{if(!(!m||!a)){if(!u){d(!0);return}p(!0);try{let e=m.snapshot??{};await a(m.id,e),d(!1),l(null)}finally{p(!1)}}},[m,a,u]),g=n.useCallback(()=>{d(!1)},[]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.History,{className:`h-4 w-4`}),`Revision History`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]})}),(0,s.jsx)(r.CardContent,{children:t.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No revisions recorded`}):(0,s.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4`,children:[(0,s.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-3 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=e.id===c;return(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`w-full text-left flex items-start gap-3 py-2 px-2 rounded-md transition-colors relative`,t?`bg-accent`:`hover:bg-accent/50`),onClick:()=>{l(e.id),d(!1)},children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-6 w-6 rounded-full border-2 flex items-center justify-center z-10 mt-0.5`,t?`border-primary bg-primary`:`border-border bg-background`),children:t&&(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-primary-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.user}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:oe(e.timestamp)})]}),(0,s.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[e.changes.length,` field`,e.changes.length===1?``:`s`,` `,`changed`]})]})]},e.id)})})]})}),m&&(0,s.jsxs)(`div`,{className:`lg:w-80 border rounded-md p-3 space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.Eye,{className:`h-4 w-4 text-muted-foreground`}),`Revision Preview`]}),(0,s.jsx)(`div`,{className:`space-y-2`,children:m.changes.map((e,t)=>(0,s.jsxs)(`div`,{className:`text-xs`,children:[(0,s.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e.field}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[(0,s.jsx)(`span`,{className:`line-through text-red-600 dark:text-red-400 truncate max-w-[120px]`,children:e.oldValue==null?`(empty)`:String(e.oldValue)}),(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.jsx)(`span`,{className:`text-green-600 dark:text-green-400 truncate max-w-[120px]`,children:e.newValue==null?`(empty)`:String(e.newValue)})]})]},t))}),m.snapshot&&(0,s.jsxs)(`div`,{className:`border-t pt-2 space-y-1`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Record state at this point`}),(0,s.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-1`,children:Object.entries(m.snapshot).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex justify-between text-xs gap-2`,children:[(0,s.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e}),(0,s.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,children:t==null?`–`:String(t)})]},e))})]}),a&&(0,s.jsx)(`div`,{className:`pt-1 space-y-2`,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:[`This will restore the record to its state at`,` `,oe(m.timestamp),`. Continue?`]}),(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsxs)(r.Button,{variant:`destructive`,size:`sm`,className:`gap-1.5 flex-1`,onClick:h,disabled:f,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),f?`Restoring…`:`Confirm Restore`]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:g,disabled:f,children:`Cancel`})]})]}):(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`w-full gap-1.5`,onClick:h,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),`Restore to this point`]})})]})]})})]})},ce=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),a=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),o=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,s.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,s.jsx)(`span`,{className:`text-muted-foreground line-through`,children:a}),(0,s.jsx)(i.ArrowRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.jsx)(`span`,{className:`text-foreground`,children:o})]})},le=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],ue=({reactions:e,onToggleReaction:t,emojiOptions:a=le,className:o})=>{let[c,l]=n.useState(!1),u=n.useCallback(e=>{t?.(e),l(!1)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1 flex-wrap`,o),children:[e.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>u(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,s.jsx)(`span`,{children:e.emoji}),(0,s.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>l(!c),"aria-label":`Add reaction`,children:(0,s.jsx)(i.SmilePlus,{className:`h-3.5 w-3.5`})}),c&&(0,s.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:a.map(t=>(0,s.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>u(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function de(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var fe=({parentItem:e,replies:t,onAddReply:a,showReplyInput:o=!0,className:c})=>{let{t:l}=S(),[u,d]=n.useState(!1),[f,p]=n.useState(``),[m,h]=n.useState(!1),g=n.useCallback(async()=>{let t=f.trim();if(!(!t||!a)){h(!0);try{await a(e.id,t),p(``)}finally{h(!1)}}},[f,a,e.id]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]);return t.length===0&&!o?null:(0,s.jsxs)(`div`,{className:(0,r.cn)(`ml-10 mt-1`,c),children:[t.length>0&&(0,s.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>d(!u),"aria-expanded":u,children:[u?(0,s.jsx)(i.ChevronDown,{className:`h-3 w-3`}):(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`}),(0,s.jsx)(i.MessageSquare,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:t.length===1?l(`detail.replyCount`,{count:t.length}):l(`detail.replyCountPlural`,{count:t.length})})]}),u&&(0,s.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,s.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,s.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,s.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:de(e.createdAt)})]}),(0,s.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),o&&a&&(0,s.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,s.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:l(`detail.replyPlaceholder`),value:f,onChange:e=>p(e.target.value),onKeyDown:_,disabled:m}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:g,disabled:!f.trim()||m,"aria-label":`Send reply`,children:(0,s.jsx)(i.Send,{className:`h-3 w-3`})})]})]})},pe=({subscription:e,onToggle:t,className:a})=>{let{t:o}=S(),[c,l]=n.useState(!1),u=n.useCallback(async()=>{if(t){l(!0);try{await t(!e.subscribed)}finally{l(!1)}}},[t,e.subscribed]);return(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:(0,r.cn)(`h-8 w-8`,a),onClick:u,disabled:c||!t,"aria-label":e.subscribed?o(`detail.unsubscribeAriaLabel`):o(`detail.subscribeAriaLabel`),title:e.subscribed?o(`detail.subscribedTooltip`):o(`detail.unsubscribedTooltip`),children:e.subscribed?(0,s.jsx)(i.Bell,{className:`h-4 w-4 text-primary`}):(0,s.jsx)(i.BellOff,{className:`h-4 w-4 text-muted-foreground`})})},me={comment:i.MessageSquare,field_change:i.Edit,task:i.CheckSquare,event:i.Calendar,system:i.Zap,email:i.Mail,call:i.Phone},he={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function ge(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function _e(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function ve(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var ye=({items:e,config:t,filterMode:a,onFilterChange:o,hasMore:c=!1,onLoadMore:l,loading:u=!1,onAddComment:d,onAddReply:f,onToggleReaction:p,subscription:m,onToggleSubscription:h,collapseWhenEmpty:g=!1,className:_})=>{let{t:v}=S(),[y,b]=n.useState(`all`),[x,C]=n.useState(``),[w,T]=n.useState(!1),[E,D]=n.useState(!1),O=a??y,k=t?.showFilterToggle!==!1,A=t?.showCommentInput!==!1&&!!d,j=t?.enableReactions??!1,M=t?.enableThreading??!1,N=t?.showSubscriptionToggle??!1,P=n.useMemo(()=>ve(e,O),[e,O]),F=n.useMemo(()=>M?P.filter(e=>!e.parentId):P,[P,M]),I=n.useMemo(()=>{if(!M)return new Map;let e=new Map;for(let t of P)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[P,M]),L=n.useCallback(e=>{o?o(e):b(e)},[o]),R=n.useCallback(async()=>{let e=x.trim();if(!(!e||!d)){T(!0);try{await d(e),C(``)}finally{T(!1)}}},[x,d]),z=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),R())},[R]),B=n.useCallback(async()=>{if(l){D(!0);try{await l()}finally{D(!1)}}},[l]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,_),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),v(`detail.activity`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,P.length,`)`]})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-1`,children:N&&m&&(0,s.jsx)(pe,{subscription:m,onToggle:h})})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[k&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:O,onChange:e=>L(e.target.value),"aria-label":v(`detail.filterActivity`),children:ge(v).map(e=>(0,s.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),A&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:v(`detail.leaveCommentPlaceholder`),value:x,onChange:e=>C(e.target.value),onKeyDown:z,disabled:w}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:R,disabled:!x.trim()||w,className:`shrink-0 self-end`,"aria-label":v(`detail.submitComment`),children:(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`})})]}),P.length===0?g?null:(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v(`detail.noActivity`)}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:F.map(e=>{let t=me[e.type]||i.Zap,n=he[e.type]||`bg-gray-100 text-gray-600`,a=I.get(e.id)??[];return(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_e(e.createdAt)}),e.edited&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,s.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,s.jsx)(ce,{change:e},t))}),j&&e.reactions&&e.reactions.length>0&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(ue,{reactions:e.reactions,onToggleReaction:p?t=>p(e.id,t):void 0})}),j&&(!e.reactions||e.reactions.length===0)&&p&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(ue,{reactions:[],onToggleReaction:t=>p(e.id,t)})})]})]}),M&&(e.replyCount??0)>0&&(0,s.jsx)(fe,{parentItem:e,replies:a,onAddReply:f,showReplyInput:!!f})]},e.id)})})]}),c&&(0,s.jsx)(`div`,{className:`text-center pt-2`,children:(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:B,disabled:E,"aria-label":v(`detail.loadMore`),children:[E?(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-1`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},be=({config:e,items:t,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g=!1,className:_})=>{let v=e?.position??`right`,y=e?.width??`360px`,b=e?.collapsible??!0,x=g&&t.length===0||(e?.defaultCollapsed??!1),{t:C}=S(),[w,T]=n.useState(x);return v===`right`||v===`left`?w&&b?(0,s.jsx)(`div`,{className:(0,r.cn)(`flex items-start pt-4`,v===`right`?`border-l`:`border-r`,_),children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>T(!1),"aria-label":C(`detail.openDiscussion`),children:(0,s.jsx)(i.PanelRightOpen,{className:`h-4 w-4`})})}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col overflow-hidden`,v===`right`?`border-l`:`border-r`,_),style:{width:y,minWidth:y},children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:C(`detail.discussion`)})]}),b&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.closeDiscussion`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,s.jsx)(ye,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,className:`border-0 shadow-none`})})]}):(0,s.jsx)(`div`,{className:(0,r.cn)(``,_),children:b&&w?(0,s.jsxs)(r.Button,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>T(!1),"aria-label":C(`detail.showDiscussion`,{count:t.length}),children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{children:C(`detail.showDiscussion`,{count:t.length})})]}):(0,s.jsxs)(`div`,{children:[b&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),C(`detail.discussion`)]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.hideDiscussion`),children:(0,s.jsx)(i.PanelRightClose,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(ye,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g})]})})},xe=({onSubmit:e,placeholder:t=`Leave a comment…`,disabled:a=!1,className:o})=>{let[c,l]=n.useState(``),[u,d]=n.useState(!1),f=n.useCallback(async()=>{let t=c.trim();if(t){d(!0);try{await e(t),l(``)}finally{d(!1)}}},[c,e]),p=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,o),children:[(0,s.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:t,value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:a||u}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:f,disabled:!c.trim()||u||a,className:`shrink-0 self-end`,"aria-label":`Submit comment`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]})},Se=({query:e,suggestions:t,onSelect:i,visible:a=!0,activeIndex:o=0,className:c})=>{let l=n.useMemo(()=>{if(!e)return t;let n=e.toLowerCase();return t.filter(e=>e.name.toLowerCase().includes(n)||e.id.toLowerCase().includes(n))},[e,t]);return!a||l.length===0?null:(0,s.jsx)(`div`,{className:(0,r.cn)(`bg-popover border rounded-md shadow-md z-50 max-h-48 overflow-y-auto w-56`,c),role:`listbox`,"aria-label":`Mention suggestions`,children:l.map((e,t)=>(0,s.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===o,className:(0,r.cn)(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===o&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),i(e)},children:[e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.name,className:`h-5 w-5 rounded-full object-cover`}):(0,s.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.name.charAt(0).toUpperCase()}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`span`,{className:`truncate`,children:e.name}),e.type!==`user`&&(0,s.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground capitalize`,children:[`(`,e.type,`)`]})]})]},e.id))})};function Ce(e,t,n){return{type:e.type,id:e.id,name:e.name,offset:t,length:n}}t.ComponentRegistry.register(`detail-view`,B,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),t.ComponentRegistry.register(`detail-section`,w,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),t.ComponentRegistry.register(`related-list`,D,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),t.ComponentRegistry.register(`detail`,B,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),e.ActivityTimeline=L,e.CommentAttachment=ae,e.CommentInput=xe,e.DETAIL_DEFAULT_TRANSLATIONS=x,e.DetailSection=w,e.DetailTabs=T,e.DetailView=B,e.DiffView=K,e.FieldChangeItem=ce,e.HeaderHighlight=k,e.InlineCreateRelated=ee,e.MentionAutocomplete=Se,e.PointInTimeRestore=se,e.ReactionPicker=ue,e.RecordActivityTimeline=ye,e.RecordChatterPanel=be,e.RecordComments=j,e.RecordNavigationEnhanced=q,e.RelatedList=D,e.RelationshipGraph=Z,e.RichTextCommentInput=H,e.SectionGroup=O,e.SubscriptionToggle=pe,e.ThreadedReplies=fe,e.applyAutoSpan=v,e.applyDetailAutoLayout=y,e.createMentionFromSuggestion=Ce,e.createSafeTranslationHook=b,e.inferDetailColumns=_,e.isWideFieldType=g,e.useDetailTranslation=S});
5
+ `)}}function te(e,t){let n=[],r=Math.max(e.length,t.length);for(let i=0;i<r;i++){let r=i<e.length?e[i]:void 0,a=i<t.length?t[i]:void 0;r===a?n.push({type:`unchanged`,value:r}):(r!==void 0&&n.push({type:`removed`,value:r}),a!==void 0&&n.push({type:`added`,value:a}))}return n}var W={added:`bg-green-50 text-green-800 dark:bg-green-950/30 dark:text-green-300`,removed:`bg-red-50 text-red-800 dark:bg-red-950/30 dark:text-red-300`,unchanged:`text-muted-foreground`},G={added:`+`,removed:`-`,unchanged:` `},K=({oldValue:e,newValue:t,fieldName:a,fieldType:o=`string`,mode:c=`unified`,className:l})=>{let{t:u}=S(),[d,f]=n.useState(c),p=n.useMemo(()=>U(e,o),[e,o]),m=n.useMemo(()=>U(t,o),[t,o]),h=n.useMemo(()=>te(p,m),[p,m]),g=h.some(e=>e.type!==`unchanged`),_=n.useMemo(()=>{if(d!==`side-by-side`)return[];let e=[],t=0;for(;t<h.length;){let n=h[t];if(n.type===`unchanged`)e.push({left:n,right:n}),t++;else if(n.type===`removed`){let r=t+1<h.length?h[t+1]:null;r&&r.type===`added`?(e.push({left:n,right:r}),t+=2):(e.push({left:n,right:null}),t++)}else e.push({left:null,right:n}),t++}return e},[d,h]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,l),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center justify-between text-sm`,children:[(0,s.jsx)(`span`,{className:`font-medium`,children:a}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,s.jsx)(r.Button,{variant:d===`unified`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`unified`),title:u(`detail.unifiedDiff`),children:(0,s.jsx)(i.Rows3,{className:`h-3.5 w-3.5`})}),(0,s.jsx)(r.Button,{variant:d===`side-by-side`?`secondary`:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>f(`side-by-side`),title:u(`detail.sideBySideDiff`),children:(0,s.jsx)(i.Columns2,{className:`h-3.5 w-3.5`})})]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:g?d===`unified`?(0,s.jsx)(`div`,{className:`font-mono text-xs overflow-x-auto`,children:h.map((e,t)=>(0,s.jsxs)(`div`,{className:(0,r.cn)(`px-4 py-0.5 whitespace-pre-wrap border-l-2`,W[e.type],e.type===`added`&&`border-l-green-500`,e.type===`removed`&&`border-l-red-500`,e.type===`unchanged`&&`border-l-transparent`),children:[(0,s.jsx)(`span`,{className:`select-none mr-2 inline-block w-3 text-center opacity-60`,children:G[e.type]}),e.value]},t))}):(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`div`,{className:`grid grid-cols-2 divide-x font-mono text-xs min-w-0`,children:[(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.previousVersion`)}),(0,s.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50`,children:u(`detail.currentVersion`)}),_.map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.left?W[e.left.type]:`bg-muted/20`),children:e.left?.value??``}),(0,s.jsx)(`div`,{className:(0,r.cn)(`px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]`,e.right?W[e.right.type]:`bg-muted/20`),children:e.right?.value??``})]},t))]})}):(0,s.jsx)(`p`,{className:`px-4 py-3 text-sm text-muted-foreground`,children:u(`detail.noChanges`)})})]})},q=({currentIndex:e,totalRecords:t,recordIds:a,onNavigate:o,onSearch:c,className:l})=>{let{t:u}=S(),[d,f]=n.useState(``),[p,m]=n.useState(!1),h=n.useRef(null),g=e>0,_=e>0,v=e<t-1,y=e<t-1,b=n.useCallback(()=>{g&&o(a[0])},[g,o,a]),x=n.useCallback(()=>{_&&o(a[e-1])},[_,o,a,e]),C=n.useCallback(()=>{v&&o(a[e+1])},[v,o,a,e]),w=n.useCallback(()=>{y&&o(a[a.length-1])},[y,o,a]),T=n.useCallback(e=>{let t=e.target.value;f(t),c?.(t)},[c]),E=n.useCallback(()=>{m(e=>(e?(f(``),c?.(``)):requestAnimationFrame(()=>h.current?.focus()),!e))},[c]);return n.useEffect(()=>{let t=t=>{let n=t.target?.tagName;if(!((n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable)&&t.target!==h.current)){if(t.target===h.current){t.key===`Escape`&&(t.preventDefault(),m(!1),f(``),c?.(``),t.target.blur());return}switch(t.key){case`Home`:t.preventDefault(),g&&o(a[0]);break;case`End`:t.preventDefault(),y&&o(a[a.length-1]);break;case`ArrowLeft`:t.preventDefault(),_&&o(a[e-1]);break;case`ArrowRight`:t.preventDefault(),v&&o(a[e+1]);break}}};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,a,g,_,v,y,o,c]),(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5`,l),children:[(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!g,onClick:b,title:u(`detail.firstRecord`),children:(0,s.jsx)(i.ChevronsLeft,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!_,onClick:x,title:u(`detail.previousRecordKey`),children:(0,s.jsx)(i.ChevronLeft,{className:`h-4 w-4`})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1.5 tabular-nums`,children:t>0?u(`detail.recordOf`,{current:e+1,total:t}):u(`detail.noRecords`)}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!v,onClick:C,title:u(`detail.nextRecordKey`),children:(0,s.jsx)(i.ChevronRight,{className:`h-4 w-4`})}),(0,s.jsx)(r.Button,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:!y,onClick:w,title:u(`detail.lastRecord`),children:(0,s.jsx)(i.ChevronsRight,{className:`h-4 w-4`})}),c&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.Button,{variant:p?`secondary`:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:E,title:u(`detail.searchWhileNavigating`),children:(0,s.jsx)(i.Search,{className:`h-4 w-4`})}),p&&(0,s.jsx)(`div`,{className:`relative`,children:(0,s.jsx)(r.Input,{ref:h,type:`text`,placeholder:u(`detail.searchRecords`),value:d,onChange:T,className:`h-8 w-48 text-sm`})})]})]})},J=28,Y=[`fill-primary stroke-primary`,`fill-blue-500 stroke-blue-500`,`fill-emerald-500 stroke-emerald-500`,`fill-amber-500 stroke-amber-500`],X=[`fill-primary-foreground`,`fill-white`,`fill-white`,`fill-white`];function Z(e,t,n,r,i){let a=[],o=[],s=new Set,c=r/2,l=i/2;a.push({id:e.id,label:e.label,type:e.type,x:c,y:l,level:0}),s.add(e.id);let u=Math.min(r,i)*.32,d=t.filter(e=>!s.has(e.id));if(d.forEach((t,n)=>{let r=2*Math.PI*n/d.length-Math.PI/2,i=c+u*Math.cos(r),f=l+u*Math.sin(r);a.push({id:t.id,label:t.label,type:t.type,x:i,y:f,level:1}),o.push({fromId:e.id,toId:t.id,fromX:c,fromY:l,toX:i,toY:f}),s.add(t.id)}),n>=2){let e=Math.min(r,i)*.46,t=[];d.forEach(e=>{let n=a.find(t=>t.id===e.id);n&&(e.relatedRecords||[]).filter(e=>!s.has(e.id)).forEach(r=>{t.push({node:r,parentX:n.x,parentY:n.y,parentId:e.id}),s.add(r.id)})}),t.forEach((n,r)=>{let i=2*Math.PI*r/Math.max(t.length,1)-Math.PI/2,s=c+e*Math.cos(i),u=l+e*Math.sin(i);a.push({id:n.node.id,label:n.node.label,type:n.node.type,x:s,y:u,level:2}),o.push({fromId:n.parentId,toId:n.node.id,fromX:n.parentX,fromY:n.parentY,toX:s,toY:u})})}return{nodes:a,edges:o}}function Q(e,t=6){return e.length<=t?e:e.slice(0,t-1)+`…`}var $=({record:e,relatedRecords:t,levels:a=1,onNodeClick:o,className:c})=>{let l=n.useRef(null),[u,d]=n.useState({width:500,height:400}),[f,p]=n.useState(null);n.useEffect(()=>{let e=l.current;if(!e)return;let t=e.parentElement;if(!t)return;let n=new ResizeObserver(e=>{for(let t of e){let{width:e}=t.contentRect;e>0&&d({width:e,height:Math.max(300,e*.7)})}});return n.observe(t),()=>n.disconnect()},[]);let{nodes:m,edges:h}=n.useMemo(()=>Z(e,t,a,u.width,u.height),[e,t,a,u]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(`overflow-hidden`,c),children:[(0,s.jsx)(r.CardHeader,{className:`pb-2`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Network,{className:`h-4 w-4`}),`Relationships`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,` related)`]})]})}),(0,s.jsx)(r.CardContent,{className:`p-0`,children:(0,s.jsxs)(`svg`,{ref:l,width:`100%`,height:u.height,viewBox:`0 0 ${u.width} ${u.height}`,className:`select-none`,children:[h.map((e,t)=>(0,s.jsx)(`line`,{x1:e.fromX,y1:e.fromY,x2:e.toX,y2:e.toY,className:`stroke-border`,strokeWidth:1.5,strokeOpacity:.5},`edge-${t}`)),m.map(e=>{let t=f===e.id,n=Y[Math.min(e.level,Y.length-1)],i=X[Math.min(e.level,X.length-1)],a=e.level===0?J+6:J;return(0,s.jsxs)(`g`,{className:(0,r.cn)(`cursor-pointer transition-transform`,o&&`hover:opacity-80`),onClick:()=>o?.(e.id),onMouseEnter:()=>p(e.id),onMouseLeave:()=>p(null),children:[(0,s.jsx)(`circle`,{cx:e.x,cy:e.y,r:t?a+3:a,className:n,fillOpacity:e.level===0?1:.85,strokeWidth:2,strokeOpacity:.3}),(0,s.jsx)(`text`,{x:e.x,y:e.y,textAnchor:`middle`,dominantBaseline:`central`,className:(0,r.cn)(`text-[10px] font-medium pointer-events-none`,i),children:Q(e.label)}),e.type&&(0,s.jsx)(`text`,{x:e.x,y:e.y+a+12,textAnchor:`middle`,className:`fill-muted-foreground text-[9px] pointer-events-none`,children:e.type}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`rect`,{x:e.x-50,y:e.y-a-28,width:100,height:20,rx:4,className:`fill-popover stroke-border`,strokeWidth:1}),(0,s.jsx)(`text`,{x:e.x,y:e.y-a-16,textAnchor:`middle`,dominantBaseline:`central`,className:`fill-popover-foreground text-[10px] pointer-events-none`,children:e.label})]})]},e.id)})]})})]})};function ne(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function re(e){return e.startsWith(`image/`)}function ie(e){return re(e)?i.Image:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?i.FileText:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?i.FileArchive:i.File}var ae=({attachments:e,onUpload:t,onRemove:a,className:o,readOnly:c=!1})=>{let{t:l}=S(),[u,d]=n.useState(!1),f=n.useRef(null),p=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!0)},[]),m=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1)},[]),h=n.useCallback(e=>{e.preventDefault(),e.stopPropagation(),d(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),g=n.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`space-y-2`,o),children:[t&&!c&&(0,s.jsxs)(`div`,{className:(0,r.cn)(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,u?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:p,onDragLeave:m,onDrop:h,onClick:()=>f.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f.current?.click())},children:[(0,s.jsx)(i.Upload,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,s.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`detail.dropFilesToUpload`)}),(0,s.jsx)(`input`,{ref:f,type:`file`,multiple:!0,className:`hidden`,onChange:g})]}),e.length>0&&(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,s.jsx)(i.Paperclip,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:e.length===1?l(`detail.attachmentCount`,{count:e.length}):l(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,s.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=re(e.type),n=ie(e.type);return(0,s.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group`,children:[t&&(e.thumbnailUrl||e.url)?(0,s.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,s.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,s.jsx)(n,{className:`h-5 w-5 text-muted-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,s.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:ne(e.size)})]}),a&&!c&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>a(e.id),title:l(`detail.removeAttachment`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})};function oe(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:t.toLocaleString()}catch{return e}}var se=({recordId:e,revisions:t,onRestore:a,className:o})=>{let[c,l]=n.useState(null),[u,d]=n.useState(!1),[f,p]=n.useState(!1),m=n.useMemo(()=>t.find(e=>e.id===c)??null,[t,c]),h=n.useCallback(async()=>{if(!(!m||!a)){if(!u){d(!0);return}p(!0);try{let e=m.snapshot??{};await a(m.id,e),d(!1),l(null)}finally{p(!1)}}},[m,a,u]),g=n.useCallback(()=>{d(!1)},[]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,o),children:[(0,s.jsx)(r.CardHeader,{className:`pb-3`,children:(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.History,{className:`h-4 w-4`}),`Revision History`,(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,t.length,`)`]})]})}),(0,s.jsx)(r.CardContent,{children:t.length===0?(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No revisions recorded`}):(0,s.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4`,children:[(0,s.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-3 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>{let t=e.id===c;return(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`w-full text-left flex items-start gap-3 py-2 px-2 rounded-md transition-colors relative`,t?`bg-accent`:`hover:bg-accent/50`),onClick:()=>{l(e.id),d(!1)},children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-6 w-6 rounded-full border-2 flex items-center justify-center z-10 mt-0.5`,t?`border-primary bg-primary`:`border-border bg-background`),children:t&&(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-primary-foreground`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.user}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:oe(e.timestamp)})]}),(0,s.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[e.changes.length,` field`,e.changes.length===1?``:`s`,` `,`changed`]})]})]},e.id)})})]})}),m&&(0,s.jsxs)(`div`,{className:`lg:w-80 border rounded-md p-3 space-y-3`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.Eye,{className:`h-4 w-4 text-muted-foreground`}),`Revision Preview`]}),(0,s.jsx)(`div`,{className:`space-y-2`,children:m.changes.map((e,t)=>(0,s.jsxs)(`div`,{className:`text-xs`,children:[(0,s.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e.field}),(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[(0,s.jsx)(`span`,{className:`line-through text-red-600 dark:text-red-400 truncate max-w-[120px]`,children:e.oldValue==null?`(empty)`:String(e.oldValue)}),(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.jsx)(`span`,{className:`text-green-600 dark:text-green-400 truncate max-w-[120px]`,children:e.newValue==null?`(empty)`:String(e.newValue)})]})]},t))}),m.snapshot&&(0,s.jsxs)(`div`,{className:`border-t pt-2 space-y-1`,children:[(0,s.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Record state at this point`}),(0,s.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-1`,children:Object.entries(m.snapshot).map(([e,t])=>(0,s.jsxs)(`div`,{className:`flex justify-between text-xs gap-2`,children:[(0,s.jsx)(`span`,{className:`text-muted-foreground truncate`,children:e}),(0,s.jsx)(`span`,{className:`font-mono truncate max-w-[140px]`,children:t==null?`–`:String(t)})]},e))})]}),a&&(0,s.jsx)(`div`,{className:`pt-1 space-y-2`,children:u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:[`This will restore the record to its state at`,` `,oe(m.timestamp),`. Continue?`]}),(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsxs)(r.Button,{variant:`destructive`,size:`sm`,className:`gap-1.5 flex-1`,onClick:h,disabled:f,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),f?`Restoring…`:`Confirm Restore`]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`sm`,onClick:g,disabled:f,children:`Cancel`})]})]}):(0,s.jsxs)(r.Button,{variant:`outline`,size:`sm`,className:`w-full gap-1.5`,onClick:h,children:[(0,s.jsx)(i.RotateCcw,{className:`h-3.5 w-3.5`}),`Restore to this point`]})})]})]})})]})},ce=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),a=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),o=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,s.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,s.jsx)(`span`,{className:`text-muted-foreground line-through`,children:a}),(0,s.jsx)(i.ArrowRight,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,s.jsx)(`span`,{className:`text-foreground`,children:o})]})},le=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],ue=({reactions:e,onToggleReaction:t,emojiOptions:a=le,className:o})=>{let[c,l]=n.useState(!1),u=n.useCallback(e=>{t?.(e),l(!1)},[t]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex items-center gap-1 flex-wrap`,o),children:[e.map(e=>(0,s.jsxs)(`button`,{type:`button`,className:(0,r.cn)(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>u(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,s.jsx)(`span`,{children:e.emoji}),(0,s.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>l(!c),"aria-label":`Add reaction`,children:(0,s.jsx)(i.SmilePlus,{className:`h-3.5 w-3.5`})}),c&&(0,s.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:a.map(t=>(0,s.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>u(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function de(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var fe=({parentItem:e,replies:t,onAddReply:a,showReplyInput:o=!0,className:c})=>{let{t:l}=S(),[u,d]=n.useState(!1),[f,p]=n.useState(``),[m,h]=n.useState(!1),g=n.useCallback(async()=>{let t=f.trim();if(!(!t||!a)){h(!0);try{await a(e.id,t),p(``)}finally{h(!1)}}},[f,a,e.id]),_=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),g())},[g]);return t.length===0&&!o?null:(0,s.jsxs)(`div`,{className:(0,r.cn)(`ml-10 mt-1`,c),children:[t.length>0&&(0,s.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>d(!u),"aria-expanded":u,children:[u?(0,s.jsx)(i.ChevronDown,{className:`h-3 w-3`}):(0,s.jsx)(i.ChevronRight,{className:`h-3 w-3`}),(0,s.jsx)(i.MessageSquare,{className:`h-3 w-3`}),(0,s.jsx)(`span`,{children:t.length===1?l(`detail.replyCount`,{count:t.length}):l(`detail.replyCountPlural`,{count:t.length})})]}),u&&(0,s.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,s.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,s.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,s.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:de(e.createdAt)})]}),(0,s.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),o&&a&&(0,s.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,s.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:l(`detail.replyPlaceholder`),value:f,onChange:e=>p(e.target.value),onKeyDown:_,disabled:m}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:g,disabled:!f.trim()||m,"aria-label":`Send reply`,children:(0,s.jsx)(i.Send,{className:`h-3 w-3`})})]})]})},pe=({subscription:e,onToggle:t,className:a})=>{let{t:o}=S(),[c,l]=n.useState(!1),u=n.useCallback(async()=>{if(t){l(!0);try{await t(!e.subscribed)}finally{l(!1)}}},[t,e.subscribed]);return(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:(0,r.cn)(`h-8 w-8`,a),onClick:u,disabled:c||!t,"aria-label":e.subscribed?o(`detail.unsubscribeAriaLabel`):o(`detail.subscribeAriaLabel`),title:e.subscribed?o(`detail.subscribedTooltip`):o(`detail.unsubscribedTooltip`),children:e.subscribed?(0,s.jsx)(i.Bell,{className:`h-4 w-4 text-primary`}):(0,s.jsx)(i.BellOff,{className:`h-4 w-4 text-muted-foreground`})})},me={comment:i.MessageSquare,field_change:i.Edit,task:i.CheckSquare,event:i.Calendar,system:i.Zap,email:i.Mail,call:i.Phone},he={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function ge(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function _e(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function ve(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var ye=({items:e,config:t,filterMode:a,onFilterChange:o,hasMore:c=!1,onLoadMore:l,loading:u=!1,onAddComment:d,onAddReply:f,onToggleReaction:p,subscription:m,onToggleSubscription:h,collapseWhenEmpty:g=!1,className:_})=>{let{t:v}=S(),[y,b]=n.useState(`all`),[x,C]=n.useState(``),[w,T]=n.useState(!1),[E,D]=n.useState(!1),O=a??y,k=t?.showFilterToggle!==!1,A=t?.showCommentInput!==!1&&!!d,j=t?.enableReactions??!1,M=t?.enableThreading??!1,N=t?.showSubscriptionToggle??!1,P=n.useMemo(()=>ve(e,O),[e,O]),F=n.useMemo(()=>M?P.filter(e=>!e.parentId):P,[P,M]),I=n.useMemo(()=>{if(!M)return new Map;let e=new Map;for(let t of P)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[P,M]),L=n.useCallback(e=>{o?o(e):b(e)},[o]),R=n.useCallback(async()=>{let e=x.trim();if(!(!e||!d)){T(!0);try{await d(e),C(``)}finally{T(!1)}}},[x,d]),z=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),R())},[R]),B=n.useCallback(async()=>{if(l){D(!0);try{await l()}finally{D(!1)}}},[l]);return(0,s.jsxs)(r.Card,{className:(0,r.cn)(``,_),children:[(0,s.jsx)(r.CardHeader,{children:(0,s.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,s.jsxs)(r.CardTitle,{className:`flex items-center gap-2 text-base`,children:[(0,s.jsx)(i.Activity,{className:`h-4 w-4`}),v(`detail.activity`),(0,s.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,P.length,`)`]})]}),(0,s.jsx)(`div`,{className:`flex items-center gap-1`,children:N&&m&&(0,s.jsx)(pe,{subscription:m,onToggle:h})})]})}),(0,s.jsxs)(r.CardContent,{className:`space-y-4`,children:[k&&(0,s.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,s.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:O,onChange:e=>L(e.target.value),"aria-label":v(`detail.filterActivity`),children:ge(v).map(e=>(0,s.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),A&&(0,s.jsxs)(`div`,{className:`flex gap-2`,children:[(0,s.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:v(`detail.leaveCommentPlaceholder`),value:x,onChange:e=>C(e.target.value),onKeyDown:z,disabled:w}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:R,disabled:!x.trim()||w,className:`shrink-0 self-end`,"aria-label":v(`detail.submitComment`),children:(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`})})]}),P.length===0?g?null:(0,s.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:v(`detail.noActivity`)}):(0,s.jsxs)(`div`,{className:`relative`,children:[(0,s.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,s.jsx)(`div`,{className:`space-y-4`,children:F.map(e=>{let t=me[e.type]||i.Zap,n=he[e.type]||`bg-gray-100 text-gray-600`,a=I.get(e.id)??[];return(0,s.jsxs)(`div`,{children:[(0,s.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,s.jsx)(`div`,{className:(0,r.cn)(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,s.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,s.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_e(e.createdAt)}),e.edited&&(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,s.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,s.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,s.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,s.jsx)(ce,{change:e},t))}),j&&e.reactions&&e.reactions.length>0&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(ue,{reactions:e.reactions,onToggleReaction:p?t=>p(e.id,t):void 0})}),j&&(!e.reactions||e.reactions.length===0)&&p&&(0,s.jsx)(`div`,{className:`mt-1.5`,children:(0,s.jsx)(ue,{reactions:[],onToggleReaction:t=>p(e.id,t)})})]})]}),M&&(e.replyCount??0)>0&&(0,s.jsx)(fe,{parentItem:e,replies:a,onAddReply:f,showReplyInput:!!f})]},e.id)})})]}),c&&(0,s.jsx)(`div`,{className:`text-center pt-2`,children:(0,s.jsxs)(r.Button,{variant:`ghost`,size:`sm`,onClick:B,disabled:E,"aria-label":v(`detail.loadMore`),children:[E?(0,s.jsx)(i.Loader2,{className:`h-4 w-4 animate-spin mr-1`}):(0,s.jsx)(i.ChevronDown,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},be=({config:e,items:t,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g=!1,className:_})=>{let v=e?.position??`right`,y=e?.width??`360px`,b=e?.collapsible??!0,x=g&&t.length===0||(e?.defaultCollapsed??!1),{t:C}=S(),[w,T]=n.useState(x);return v===`right`||v===`left`?w&&b?(0,s.jsx)(`div`,{className:(0,r.cn)(`flex items-start pt-4`,v===`right`?`border-l`:`border-r`,_),children:(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>T(!1),"aria-label":C(`detail.openDiscussion`),children:(0,s.jsx)(i.PanelRightOpen,{className:`h-4 w-4`})})}):(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex flex-col overflow-hidden`,v===`right`?`border-l`:`border-r`,_),style:{width:y,minWidth:y},children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{className:`text-sm font-medium`,children:C(`detail.discussion`)})]}),b&&(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.closeDiscussion`),children:(0,s.jsx)(i.X,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,s.jsx)(ye,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g,className:`border-0 shadow-none`})})]}):(0,s.jsx)(`div`,{className:(0,r.cn)(``,_),children:b&&w?(0,s.jsxs)(r.Button,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>T(!1),"aria-label":C(`detail.showDiscussion`,{count:t.length}),children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),(0,s.jsx)(`span`,{children:C(`detail.showDiscussion`,{count:t.length})})]}):(0,s.jsxs)(`div`,{children:[b&&(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,s.jsx)(i.MessageSquare,{className:`h-4 w-4`}),C(`detail.discussion`)]}),(0,s.jsx)(r.Button,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>T(!0),"aria-label":C(`detail.hideDiscussion`),children:(0,s.jsx)(i.PanelRightClose,{className:`h-3.5 w-3.5`})})]}),(0,s.jsx)(ye,{items:t,config:e?.feed,hasMore:a,onLoadMore:o,loading:c,onAddComment:l,onAddReply:u,onToggleReaction:d,subscription:f,onToggleSubscription:p,filterMode:m,onFilterChange:h,collapseWhenEmpty:g})]})})},xe=({onSubmit:e,placeholder:t=`Leave a comment…`,disabled:a=!1,className:o})=>{let[c,l]=n.useState(``),[u,d]=n.useState(!1),f=n.useCallback(async()=>{let t=c.trim();if(t){d(!0);try{await e(t),l(``)}finally{d(!1)}}},[c,e]),p=n.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return(0,s.jsxs)(`div`,{className:(0,r.cn)(`flex gap-2`,o),children:[(0,s.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:t,value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:a||u}),(0,s.jsx)(r.Button,{size:`icon`,variant:`default`,onClick:f,disabled:!c.trim()||u||a,className:`shrink-0 self-end`,"aria-label":`Submit comment`,children:(0,s.jsx)(i.Send,{className:`h-4 w-4`})})]})},Se=({query:e,suggestions:t,onSelect:i,visible:a=!0,activeIndex:o=0,className:c})=>{let l=n.useMemo(()=>{if(!e)return t;let n=e.toLowerCase();return t.filter(e=>e.name.toLowerCase().includes(n)||e.id.toLowerCase().includes(n))},[e,t]);return!a||l.length===0?null:(0,s.jsx)(`div`,{className:(0,r.cn)(`bg-popover border rounded-md shadow-md z-50 max-h-48 overflow-y-auto w-56`,c),role:`listbox`,"aria-label":`Mention suggestions`,children:l.map((e,t)=>(0,s.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===o,className:(0,r.cn)(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===o&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),i(e)},children:[e.avatarUrl?(0,s.jsx)(`img`,{src:e.avatarUrl,alt:e.name,className:`h-5 w-5 rounded-full object-cover`}):(0,s.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.name.charAt(0).toUpperCase()}),(0,s.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,s.jsx)(`span`,{className:`truncate`,children:e.name}),e.type!==`user`&&(0,s.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground capitalize`,children:[`(`,e.type,`)`]})]})]},e.id))})};function Ce(e,t,n){return{type:e.type,id:e.id,name:e.name,offset:t,length:n}}t.ComponentRegistry.register(`detail-view`,B,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),t.ComponentRegistry.register(`detail-section`,w,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),t.ComponentRegistry.register(`related-list`,D,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),t.ComponentRegistry.register(`detail`,B,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),e.ActivityTimeline=L,e.CommentAttachment=ae,e.CommentInput=xe,e.DETAIL_DEFAULT_TRANSLATIONS=x,e.DetailSection=w,e.DetailTabs=T,e.DetailView=B,e.DiffView=K,e.FieldChangeItem=ce,e.HeaderHighlight=k,e.InlineCreateRelated=ee,e.MentionAutocomplete=Se,e.PointInTimeRestore=se,e.ReactionPicker=ue,e.RecordActivityTimeline=ye,e.RecordChatterPanel=be,e.RecordComments=j,e.RecordNavigationEnhanced=q,e.RelatedList=D,e.RelationshipGraph=$,e.RichTextCommentInput=H,e.SectionGroup=O,e.SubscriptionToggle=pe,e.ThreadedReplies=fe,e.applyAutoSpan=v,e.applyDetailAutoLayout=y,e.createMentionFromSuggestion=Ce,e.createSafeTranslationHook=b,e.inferDetailColumns=_,e.isWideFieldType=g,e.useDetailTranslation=S});
@@ -1 +1 @@
1
- {"version":3,"file":"DetailView.d.ts","sourceRoot":"","sources":["../../../../src/DetailView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AA+D/F,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E;;;;OAIG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAsgChD,CAAC"}
1
+ {"version":3,"file":"DetailView.d.ts","sourceRoot":"","sources":["../../../../src/DetailView.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAA4B,MAAM,kBAAkB,CAAC;AAqE/F,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E;;;;OAIG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAm+BhD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-detail",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "DetailView plugin for Object UI - comprehensive detail page with sections, tabs, and related lists",
@@ -29,11 +29,11 @@
29
29
  "peerDependencies": {
30
30
  "react": "^18.0.0 || ^19.0.0",
31
31
  "react-dom": "^18.0.0 || ^19.0.0",
32
- "@object-ui/components": "^4.0.6",
33
- "@object-ui/core": "^4.0.6",
34
- "@object-ui/fields": "^4.0.6",
35
- "@object-ui/react": "^4.0.6",
36
- "@object-ui/types": "^4.0.6"
32
+ "@object-ui/components": "^4.0.7",
33
+ "@object-ui/core": "^4.0.7",
34
+ "@object-ui/fields": "^4.0.7",
35
+ "@object-ui/react": "^4.0.7",
36
+ "@object-ui/types": "^4.0.7"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/react": "19.2.14",
@@ -43,11 +43,11 @@
43
43
  "vite": "^8.0.10",
44
44
  "vite-plugin-dts": "^5.0.0",
45
45
  "vitest": "^4.1.5",
46
- "@object-ui/components": "4.0.6",
47
- "@object-ui/core": "4.0.6",
48
- "@object-ui/fields": "4.0.6",
49
- "@object-ui/react": "4.0.6",
50
- "@object-ui/types": "4.0.6"
46
+ "@object-ui/components": "4.0.7",
47
+ "@object-ui/core": "4.0.7",
48
+ "@object-ui/fields": "4.0.7",
49
+ "@object-ui/react": "4.0.7",
50
+ "@object-ui/types": "4.0.7"
51
51
  },
52
52
  "keywords": [
53
53
  "objectui",